//// JScript File
function myClass()
{
    var m_fibre2fashion_ad_width = "" ;
	var m_fibre2fashion_ad_height ="" ;
    var m_fibre2fashion_ad_border_color ="";
    var m_fibre2fashion_ad_border_style ="";
	var m_fibre2fashion_ad_border_width="";
	var m_fibre2fashion_color_bg ="";
	var m_fibre2fashion_color_link="";
	var m_header_text_color ="";
	var m_header_bg_color ="";
	this.show_adds1 = show_adds;
	
    function SmartTagInt(business_xmlFile,callback,divObj)
    {
	    var xmlDoc = init();
	    xmlDoc.async="true";		
	    xmlDoc.onreadystatechange = processRequest;
    	
	    function init() 
	    {
          if (document.implementation.createDocument) 
          {
            return document.implementation.createDocument("","",null);
          }
          else if (window.ActiveXObject) 
          {
            return new ActiveXObject("Microsoft.XMLDOM");
          }
        }
        
        function processRequest () 
        {
          if (xmlDoc.readyState == 4) 
          {
		    if (callback) callback(xmlDoc.documentElement,divObj);
		  }
        }
        
        this.doRequest = function()
        {
		    xmlDoc.load(business_xmlFile);
        }
    }

    function CallbackReceiveRequest(xmlObj,divObj)
    {
   
		var d = document.getElementById(divObj); 
	    xmlNodes = xmlObj.selectNodes("//Keyword")	
	    var cont = document.body.innerText.toLowerCase();
	    var pat= "";
	    var iden= "";
	    var count = 0;
    	
	    for( i=0;i<xmlNodes.length;i++)
	    {	    
		    pat = xmlNodes(i).childNodes(0).text;
		    if (document.getElementById("iden"))
		    {
				iden = document.getElementById("iden").value;
			}
		    
		    if(cont.search('\\b' + pat.toLowerCase() + '\\b') != '-1')
		    {
			    count = count + 1;
				xmlNodes1 = xmlObj.selectNodes("//Keyword[Value='" + pat + "']/Links/Link");
				
			    for(var j=0;j<xmlNodes1.length;j++)
			    {
			        var Link = xmlNodes1(j).childNodes(0).text;
			        var Caption = xmlNodes1(j).getAttribute("Caption");
			        var Style = xmlNodes1(j).getAttribute("Style");
    			    
			        var objNavCloseLink = document.createElement("a");
			        if(Style == "Bold")
			        {
			            objNavCloseLink.innerHTML ="<b>"+Caption+"</b> | ";
			        }
			        else if(Style == "Font-3")
			        {
			            objNavCloseLink.innerHTML =Caption+"</font> |  ";
			        }
			        else
			        {               
	                    objNavCloseLink.innerHTML ="<font style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000; font-weight:normal; text-align:center; text-decoration:none;'>"+Caption+" | </font> ";
	                }
	                objNavCloseLink.setAttribute('href',Link);  
            		document.getElementById("SmartTagDiv").style.display="block";
            		document.getElementById("SmartTagDiv").style.overflow="hidden";
            		if(divObj == "BussinessDiv")
                		{
                			document.getElementById("bnheader").style.display="block";
                			document.getElementById("mainBU").style.display="block";
                			document.getElementById("clear2").style.display="block";
                		}
                		else if(divObj == "UsedMachineryDiv")
                		{
                			document.getElementById("umheader").style.display="block";
                			document.getElementById("mainUM").style.display="block";
                			document.getElementById("clear1").style.display="block";
                	}
			        d.style.display="block";
			        d.style.overflow="hidden";
			        d.appendChild( objNavCloseLink );
			        objNavCloseLink.className = "test";
	           }	
		    }   
		    
        }
    }

    function AJAXInteractionTag(business_xmlFile, callback,divObj)
    {
        var req = init();
        req.onreadystatechange = processRequest;
            
        function init()
        {
          if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
          } else if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
         }
        }
        
        function processRequest ()
        {
          if (req.readyState == 4)
          {
            if (req.status == 200) 
            {
              if (callback) callback(req.responseXML,divObj);
            }
          }
        }

        this.doGet = function()
        {
          req.open("GET", business_xmlFile, true);
          req.send(null);
        }
        
        this.doPost = function(body)
        {
          req.open("POST", business_xmlFile, true);
          req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          req.send(body);
        }
    }

    function linkContentSub(responseXML,divObj)
    {
        var d = document.getElementById(divObj);
        var xmlDoc = responseXML;	
        var nsResolver = xmlDoc.createNSResolver( xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);

        if (divObj=="NewsDiv")
        {
			var personIterator = xmlDoc.evaluate("//id", xmlDoc, nsResolver, XPathResult.ANY_TYPE , null );
        }
        else
        {
			var personIterator = xmlDoc.evaluate("//Value", xmlDoc, nsResolver, XPathResult.ANY_TYPE , null );
        }
        
        var thisNode = personIterator.iterateNext();
        var cont = document.body.innerHTML;
	    var pat= "";
	    var iden= "";
        		
        while (thisNode)
        {
            var pat = thisNode.textContent;
            if (document.getElementById("iden"))
		    {
				iden = document.getElementById("iden").value;
			}
            
            if(cont.search('\\b' + pat + '\\b') != '-1')
	        {
        	
		        xmlNodes1 = xmlDoc.evaluate("//Keyword[Value='" + pat + "']/Links/Link",xmlDoc, nsResolver, XPathResult.ANY_TYPE, null);
	            var thisNode1 = xmlNodes1.iterateNext();
        	        
	                while (thisNode1) 
	                {
    	           
	                    var Caption = thisNode1.attributes["Caption"].value;
	                    if(typeof(thisNode1.attributes["Style"]) != "undefined")
	                    {
	                        var Style = thisNode1.attributes["Style"].value;
            	        }
            	        else
            	        {
            	            var Style = "";
            	        }
                	    
	                    var Link = thisNode1.textContent;
                	         
                        var objNavCloseLink = document.createElement("a");
                            if(Style == "Bold")
		                    {
		                        objNavCloseLink.innerHTML ="<b>"+Caption+"</b> | ";
		                    }
		                    else if(Style == "Font-3")
		                    {
		                        objNavCloseLink.innerHTML =Caption+" |  ";
		                    }
		                    else
		                    {               
                                objNavCloseLink.innerHTML ="<font style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000; font-weight:normal; text-align:center; text-decoration:none;'>"+Caption+" | </font> ";
                            }                     
                        objNavCloseLink.setAttribute('href',Link);
		                document.getElementById("SmartTagDiv").style.display="block";
                		document.getElementById("SmartTagDiv").style.overflow="hidden";
                		if(divObj == "BussinessDiv")
                		{
                			document.getElementById("bnheader").style.display="block";
                			document.getElementById("mainBU").style.display="block";
                			document.getElementById("clear2").style.display="block";
                		}
                		else if(divObj == "UsedMachineryDiv")
                		{
                			document.getElementById("umheader").style.display="block";
                			document.getElementById("mainUM").style.display="block";
                			document.getElementById("clear1").style.display="block";
                		}
                        d.style.display="block";
			            d.style.overflow="hidden";
			            d.appendChild( objNavCloseLink );
			            objNavCloseLink.className = "test";
        			    
                        thisNode1 = xmlNodes1.iterateNext();
                    }        	
		    }
		    
            if(iden != "" && divObj=="NewsDiv" && thisNode.textContent==iden)
	        {
        		
		        xmlNodes1 = xmlDoc.evaluate("//Keyword[id='" + iden + "']/Links/Link",xmlDoc, nsResolver, XPathResult.ANY_TYPE, null);
	            var thisNode1 = xmlNodes1.iterateNext();
        	     
	                while (thisNode1) 
	                {
    	           
	                    var Caption = thisNode1.attributes["Caption"].value;
	                    if(typeof(thisNode1.attributes["Style"]) != "undefined")
	                    {
	                        var Style = thisNode1.attributes["Style"].value;
            	        }
            	        else
            	        {
            	            var Style = "";
            	        }
                	    
	                    var Link = thisNode1.textContent;
                	         
                        var objNavCloseLink = document.createElement("a");
                            if(Style == "Bold")
		                    {
		                        objNavCloseLink.innerHTML ="<b>"+Caption+"</b> | ";
		                    }
		                    else if(Style == "Font-3")
		                    {
		                        objNavCloseLink.innerHTML =Caption+" |  ";
		                    }
		                    else
		                    {               
                                objNavCloseLink.innerHTML ="<font style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#f6f6f6; font-weight:normal; text-decoration:none;'>"+Caption+" | </font>";
                            }                     
                        objNavCloseLink.setAttribute('href',Link);
		                document.getElementById("SmartTagDiv").style.display="block";
                		document.getElementById("SmartTagDiv").style.overflow="hidden";
                		if(divObj == "NewsDiv")
                		{
                			document.getElementById("newsheader").style.display="block";
                			document.getElementById("mainNews").style.display="block";
                		}
                        d.style.display="block";
			            d.style.overflow="hidden";
			            d.appendChild( objNavCloseLink );
			            objNavCloseLink.className = "test";
        			    
                        thisNode1 = xmlNodes1.iterateNext();
                    }        	
		    }		    
            thisNode = personIterator.iterateNext();    
        }
    }		
    	
    function linkContent()
    {
	    var business_xmlFile = "/smartTag/business_keywords.xml";
	    var usedmachinery_xmlFile = "/smartTag/usedmachinery_keywords.xml";
    	
	     if (document.implementation && document.implementation.createDocument)
	     {
            var ai = new AJAXInteractionTag(business_xmlFile,linkContentSub,"BussinessDiv");
		    ai.doGet();
		     var bi = new AJAXInteractionTag(usedmachinery_xmlFile,linkContentSub,"UsedMachineryDiv");
		    bi.doGet();
		     
		    return;
          } else
          {//IE
            var si = new SmartTagInt(business_xmlFile,CallbackReceiveRequest,"BussinessDiv");
	        si.doRequest();
			var ui = new SmartTagInt(usedmachinery_xmlFile,CallbackReceiveRequest,"UsedMachineryDiv");
			ui.doRequest();
					
	 	    return;
          }
    }

    function displayadds1()
    {
             document.write('<div' +
                           ' id="SmartTagDiv"' +
                           ' style="width:100%; '+
					       '; float:left; margin:0 auto;'+
					       '; display:none'+
					       '; overflow=hidden">');
			 document.write('<table width="100%" align="left" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign=top><fieldset style="border: 1px solid #adadad; padding:0px 2px 5px 2px;"><legend align="left"><font style="font-family: Arial; font-size: 12px; color:#adadad; margin:0 5 0 5;">Advertisement</font></legend>');
    	       document.write('<div style="clear:both;margin:5px;display:none;" id="clear1"></div>');
    			document.write('<div id="mainUM" style="display:none;width:100%; height:35px; float:left; margin:0 auto;">');
    	         document.write('<div id="umheader" style="display:none;width:35%; height:35px; float:left; text-align:center; background-color:#F5E731; padding-top:5px;"><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px;font-weight:bold; color:#000000; text-decoration:none; text-align:left;">');
	             document.write('Find Used Machinery Buyer/Seller</span></div>');   
    	       document.write('<div id="UsedMachineryDiv"'+
    		               ' style="text-align:left; display:none;width:65%; height:35px; float:left; background-color:#F5EDA9; padding-top:4px;"><span style="padding-left:10px;">');	   					    
    	       document.write('</span></div>');
    	       document.write('</div>');
    	       document.write('<div style="clear:both;margin:5px;display:none;" id="clear2"></div>');
    	          document.write('<div id="mainBU" style="width:100%; height:35px; float:left; margin:0 auto;">');
    	         document.write('<div id="bnheader" style="display:none;width:20%; height:35px; float:left; text-align:center; background-color:#F5E731; padding-top:5px;"><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px;font-weight:bold; color:#000000; text-decoration:none; text-align:center;">');
	             document.write('Find Buyer/Seller</span></div>');   
    	       document.write('<div id="BussinessDiv"'+
    		               ' style="text-align:left; display:none;width:80%; height:35px; float:left; background-color:#F5EDA9; padding-top:4px;"><span style="padding-left:10px;">');	   					    
    	       document.write('</span></div>');
    	       document.write('</filedset></td></tr></table>');
    	       document.write('</div>');
    }
    function show_adds(width,height,border_color,border_style,border_width,bg,link,header_text,header_bg)    {			        m_fibre2fashion_ad_width = width;        m_fibre2fashion_ad_height =height ;
        m_fibre2fashion_ad_border_color = border_color;
        m_fibre2fashion_ad_border_style =border_style;
	    m_fibre2fashion_ad_border_width=border_width;
	    m_fibre2fashion_color_bg =bg;
	    m_fibre2fashion_color_link=link;
	    m_header_text_color =header_text;
	    m_header_bg_color = header_bg;	    displayadds1()	    linkContent()    } 
}var obj1= new myClass();obj1.show_adds1(window.fibre2fashion_ad_width,window.fibre2fashion_ad_height,window.fibre2fashion_ad_border_color,window.fibre2fashion_ad_border_style,window.fibre2fashion_ad_border_width,window.fibre2fashion_color_bg,window.fibre2fashion_color_link,window.header_text_color,window.header_bg_color);