String.prototype.trim = function() {
serachText = this.replace(/^\s+/, '');
return serachText.replace(/\s+$/, '');
};



function callSearch(serachUrl)
{

    	var xmlHttp;
        if(window.XMLHttpRequest)
        { // For Mozilla, Safari, ...
        	var xmlHttp = new XMLHttpRequest();
       	}
        else if(window.ActiveXObject)
        { // For Internet Explorer
        	var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        	xmlHttp.open('POST', serachUrl, true);
        	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        	xmlHttp.onreadystatechange = function()
        	{        	
        		if (xmlHttp.readyState == 4)
        		{        			
        			document.getElementById("hiddenList").innerHTML = xmlHttp.responseText;
				}
        	}
        if(window.XMLHttpRequest)
        { 
        	xmlHttp.send(null);
       	}
        else if(window.ActiveXObject)
        { // For Internet Explorer
        	xmlHttp.send();
        }
        
   }
    
    
      function validate( val ) {
      
//		 var pattern = /^([a-zA-Z0-9,. ]*)$/;
		 var pattern = /^([a-zA-Z0-9,. /-]*)$/;
		if( !pattern.test( val ) ) {
			return false;
   		 }else{
   		    return true;
   		 }
   		
	}
	function doCompletion1(val)
	{    
    if(val.trim()==''){
	    document.getElementById('hiddenList').style.display="none";
	    return;
	  }
	  
	  if(!validate(val.trim())){
	   
	   if(document.getElementById('hiddenList').style.display=="none"){
	    /* var browser=navigator.appName;
	        if(browser=='Netscape')
		    {
			    //document.getElementById('hiddenList').style.left='385px';
			    document.getElementById('hiddenList').style.left='634px';
			    document.getElementById('hiddenList').style.top='37px';
	    	}
		    else
		    {
			    if(parseFloat(navigator.appVersion.split("MSIE")[1])>=8)
			    {
			    document.getElementById('hiddenList').style.left='634px';
			    document.getElementById('hiddenList').style.top='37px';
			    }
			    else
			    {
			    document.getElementById('hiddenList').style.left='634px';
				document.getElementById('hiddenList').style.top='37px';
			    }		    
	    	}*/
	    document.getElementById('hiddenList').style.display="";	   
	   }

		document.getElementById('hiddenList').innerHTML = splChars;
	    return;
	  }
	   
	
	 
	
	  // var browser=navigator.appName;
	    if(val.trim()!=(''))
	    {
	    document.getElementById('hiddenList').style.display="";
	   /* if(browser=='Netscape')
	    {
	    document.getElementById('hiddenList').style.left='634px';
		document.getElementById('hiddenList').style.top='37px';
	    }
	    else
	    {
		    if(parseFloat(navigator.appVersion.split("MSIE")[1])>=8)
		    {
		    document.getElementById('hiddenList').style.left='634px';
			document.getElementById('hiddenList').style.top='37px';
		    }
		    else
		    {
		    document.getElementById('hiddenList').style.left='634px';
			document.getElementById('hiddenList').style.top='37px';		    
		    }
	    }*/
	    document.getElementById("hiddenList").innerHTML =plzWait+"..........<img src='images/ajax-loader.gif'  />";
		var serachUrl = "companyRegister_autocompletor.action?searchId="+val;
    	callSearch(serachUrl);
    	}
    	else
    	{
    	makeSearchEmpty();
    	}
    }
function doCompletion(val)
	{
			
	
	  if(val.trim()==''){
	    document.getElementById('hiddenList').style.display="none";
	    return;
	  }
	  
	  if(!validate(val.trim())){
	   
	   if(document.getElementById('hiddenList').style.display=="none"){
	     //var browser=navigator.appName;
	       /* if(browser=='Netscape')
		    {
			    //document.getElementById('hiddenList').style.left='385px';
			    document.getElementById('hiddenList').style.left='385px';
			    document.getElementById('hiddenList').style.top='27px';
	    	}
		    else
		    {
			    if(parseFloat(navigator.appVersion.split("MSIE")[1])>=8)
			    {
			    document.getElementById('hiddenList').style.left='385px';
			    document.getElementById('hiddenList').style.top='27px';
			    }
			    else
			    {
			    document.getElementById('hiddenList').style.left='25px';
			    document.getElementById('hiddenList').style.top='1px';
			    }		    
	    	}*/
	    document.getElementById('hiddenList').style.display="";	   
	   }
	   
	   	document.getElementById('hiddenList').innerHTML = splChars;
	    return;
	  }
	   
	
	 
	
	  // var browser=navigator.appName;
	    if(val.trim()!=(''))
	    {
	    document.getElementById('hiddenList').style.display="";
	   /* if(browser=='Netscape')
	    {
	    document.getElementById('hiddenList').style.left='385px';
	    document.getElementById('hiddenList').style.top='27px';
	    document.getElementById("hiddenList").innerHTML =plzWait+"..........<img src='images/ajax-loader.gif' style='margin-top:-18px' />";
	    }
	    else
	    {
		    if(parseFloat(navigator.appVersion.split("MSIE")[1])>=8)
		    {
		    document.getElementById('hiddenList').style.left='385px';
		    document.getElementById('hiddenList').style.top='27px';
		    document.getElementById("hiddenList").innerHTML =plzWait+"..........<img src='images/ajax-loader.gif' style='margin-top:-5px' />";
		    }
		    else
		    {
		    document.getElementById('hiddenList').style.left='25px';
		    document.getElementById('hiddenList').style.top='1px';
		    document.getElementById("hiddenList").innerHTML =plzWait+"..........<img src='images/ajax-loader.gif' style='margin-top:-15px' />";
		    }
	    }	*/    
	    document.getElementById("hiddenList").innerHTML =plzWait+"..........<img src='images/ajax-loader.gif' style='margin-top:-18px' />";
	    
		var serachUrl = "companyRegister_autocompletor.action?searchId="+val;
    	callSearch(serachUrl);
    	}
    	else
    	{
    	makeSearchEmpty();
    	}
    }       
    
  
function makeSearchEmpty()
{

	// for company and product search

	if(document.getElementById('hiddenList')!=null){
	 document.getElementById('hiddenList').style.display="none";
 	}
    if(document.getElementById('completeField')!=null){
	 document.getElementById('completeField').value="";
 	}
    // for search topic

	if(document.getElementById('hiddenList1')!=null){
	 document.getElementById('hiddenList1').style.display="none";
 	}
 
 

} 

   function clear(id){
   
     // var obj = document.getElementById("hidden"+id);
      document.getElementById(id).innerHTML = "";
   
   }
   
   
   
   
   function showDescription(id){
   callSearch2(id);
}
     
     
     function callSearch2(id)
{

        var serachUrl = "topic_showDescription.action?id="+id;
        
 
       	var xmlHttp;
        if(window.XMLHttpRequest)
        { // For Mozilla, Safari, ...
        	var xmlHttp = new XMLHttpRequest();
        }
        else if(window.ActiveXObject)
        { // For Internet Explorer
        	var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        	xmlHttp.open('POST', serachUrl, true);
        	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        	xmlHttp.onreadystatechange = function()
        	{        	
        		if (xmlHttp.readyState == 4)
        		{
        			document.getElementById("one").style.visibility='';
        			document.getElementById("one").innerHTML = xmlHttp.responseText;
        			
				}
        	}
        	if(window.XMLHttpRequest)
        	{ 
        		xmlHttp.send(null);
        	}
        	else if(window.ActiveXObject)
        	{ 
        		xmlHttp.send();
        	}        	
        }
   
   
   
	     function getCompany(companyName){
	     // alert(companyName);
          document.getElementById('searchCompany').value = companyName;
          document.forms[0].action = "companyRegister_getCompanyDashboard.action?cname="+companyName;
          document.forms[0].submit();
       }
	
	
	
      
       /*function getProduct(productName){
       	  document.getElementById('searchProductName').value = productName;
          document.forms[0].action = "companyRegister_getPDB.action?pName="+productName;
          document.forms[0].submit();
       }*/


       function getProduct(productName,companyName){
       	  document.getElementById('searchProductName').value = productName;
          document.forms[0].action = "companyRegister_getPDB.action?pName="+productName+"&productCompanyName="+companyName;
          document.forms[0].submit();
       }
       
       
       
       function getXMLHttpRequest()
 {
          var xmlHttp = null;
        if(window.XMLHttpRequest)
                   xmlHttp = new XMLHttpRequest();                 
        if(window.ActiveXObject)
                   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     return xmlHttp;    

 }
 
    function bgColor(){
       
    		 var xmlHttp = getXMLHttpRequest();
		 	 xmlHttp.open('GET', "customize_bgColor.action" , true);
		 	 xmlHttp.onreadystatechange = function(){
		 	 		  	    
			   		if (xmlHttp.readyState == 4){	   		
						   if(xmlHttp.responseText=="0")
						   {
						   }
						   else
						   {
						   	changeCustomizeImage();
						   }
					 }
					 else
					 {
				     }		           
		    }	   		
            xmlHttp.send(null);
    }   
    
    
function funside(dname){
	var vv=document.getElementById('tabside_container').childNodes;

	for(var i=0;i<vv.length;i++){
		
		if(i>2){
		if(i==dname){
			document.getElementById('contentdispalyside'+i).style.display='';
			
		}else{
				document.getElementById('contentdispalyside'+i).style.display='none';
			}
			if(vv[i].id=='mainside'+dname){
				vv[i].className='btnonside';
			}else if((vv[i].id)!=null) {
					if((vv[i].id).substring(0,4)=='mainside'){
						vv[i].className='btnoffside';
				}
			}
		}	
if(i>2){
}else if(vv[i].id=='mainside'+dname){
vv[i].className='btnonside';
}else{
vv[i].className='btnoffside';
}

}
}
 
     
 
   
