	function right(e) {
		if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
			return false;
		else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
			alert("Sorry, you do not have permission to right click.");
			return false;
		}
		return true;
	}

	               /*document.onmousedown=right;
	document.onmouseup=right;
	if (document.layers) window.captureEvents(Event.MOUSEDOWN);
	if (document.layers) window.captureEvents(Event.MOUSEUP);
	window.onmousedown=right;
	window.onmouseup=right;*/

	/*function openpremierwindow(val,uid,seqno)
	{
		if(val=='B'){
			window.open("basic_result.php?userid="+uid+"&seqno="+seqno,"mywindow","menubar=1,resizable=1,width=665,height=587,scrollbars=1");
		}
		else if(val=='P'){
			window.open("premier_result.php?uid="+uid+"&priid="+seqno,"mywindow","menubar=1,resizable=1,width=665,height=600,scrollbars=1");
		}	
	}*/
	function catch_keyword(){
			ajax=new Ajax();
			keyword=document.getElementById('keyword').value
			if(keyword !=''){ 
			ajax.open('GET','catch_keyword_count.php?keyword='+keyword)
			ajax.send(null);
		}
	}
	function openpremierwindow(val,uid,seqno,catname,companyname,keyword)
	{
		//alert(keyword);
		sendhitcount(uid,'4',keyword)
		if(val=='B'){
			window.open("basic_result.php?userid="+uid+"&seqno="+seqno,"_self","menubar=1,resizable=1,width=665,height=587,scrollbars=1");
			create("basic_result.php",uid,'b',seqno,catname,companyname);
		}
		else if(val=='P'){
			window.open("premier_result.php?uid="+uid+"&priid="+seqno,"_self","menubar=1,resizable=1,width=665,height=600,scrollbars=1");
			create("premier_result.php",uid,'p',seqno,catname,companyname);
		}	
	}
	function create(url,uid,type,priid,catname,companyname)
	{
		var httpRequest;
		var ex_div=document.getElementById("content");
		if (window.XMLHttpRequest) { // Mozilla, Safari, ...
			httpRequest = new XMLHttpRequest();
			http_Request = new XMLHttpRequest()
		
		} else if (window.ActiveXObject) { // IE
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			http_Request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(type=='b'){
			url=url+"?userid="+uid+"&seqno="+priid;
		}else
			url=url+"?uid="+uid+"&priid="+priid;
		
		httpRequest.open('GET', url, true);
		httpRequest.send(null);
		httpRequest.onreadystatechange = function(){
				if(httpRequest.readyState == 4){
					resp=httpRequest.responseText;
					http_Request.open("POST","model/page_cache.php",true)
					http_Request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					parameters= "content="+resp+"&id="+uid+"&catname="+catname+"&companyname="+companyname;
					http_Request.setRequestHeader("Content-length", 4096);
					http_Request.send(parameters);
					//window.location="hello.html";  
				}
		};
	}	
	function selectall1(val) 
	{
		dml=document.sndRFI;
		len = dml.elements.length;
		var i=0;
		for( i=0 ; i<len ; i++) 
		{
			if (dml.elements[i].name=='checkbox[]') 
			{
				if(val==0){
					if(dml.elements[i].checked==true)
						store_values(dml.elements[i].value);
					dml.elements[i].checked=false;
				}
				else{
					if(dml.elements[i].checked==false)
						store_values(dml.elements[i].value);
					dml.elements[i].checked=true;
				}
				
			}

		}
	}
	
	function CountingWords (this_field) {
		
		var char_count = this_field.length;
		var fullStr = this_field + " ";
		var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
		var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
		var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
		var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
		var splitString = cleanedStr.split(" ");
		var word_count = splitString.length -1;
		return word_count;
	}	
	
	function displaylinks(keyval)
	{
			document.simplesrch.action="/searchresults.php?clearsess=1";
			document.simplesrch.submit();
	}
	function displaylinks1()
	{
			document.simplesrch.company.value = document.simplesrch.keyword.value ; 
			document.simplesrch.action="/searchresults.php";
			document.simplesrch.submit();
	}
	function formsubmit()
	{
		document.simplesrch.action="/searchresults.php";
		document.simplesrch.submit();
	}
	function formsubmit_adv()
	{
		document.simplesrch.action="/advanced_search.php";
		document.simplesrch.submit();
	}

	function send_rfi(){
		var url="/check_rfi_session.php";
		xmlHttp1=GetXmlHttpObject(check_rfi)
		xmlHttp1.open("POST", url , true)
		xmlHttp1.send(null)
	}
	function check_rfi() 
	{ 
		if (xmlHttp1.readyState==4 || xmlHttp1.readyState==200)
		{ 
			value = xmlHttp1.responseText;
			if(value!=''){
				var	x=window.open("/rfi.php","mywindow","menubar=1,resizable=1,scrollbars=yes,width=670,height=600"); x.focus(); return false;
			}			
			else
				alert("Please select at least one supplier to send your RFI to");	
		} 
	} 

	function store_values(id)
	{
		var url="/select_rfi_session.php?id="+id;
		xmlHttp2=GetXmlHttpObject(result_rfi)
		xmlHttp2.open("POST", url , true)
		xmlHttp2.send(null)
	}
	function result_rfi() 
	{ 
		if (xmlHttp2.readyState==4 || xmlHttp2.readyState==200)
		{ 
			 value = xmlHttp2.responseText;
			// alert(value);
		} 
	} 


	var i = 0;
	// Set up the image files to be used.
	var logoImages = new Array() // do not change this
	var classname = new Array();
	var buttonImages = new Array()
	var classnameHome = new Array();
	var footerImages =  new Array();
	var classDefault = new Array();
	// To add more image files, continue with the pattern below, adding to the array.
	for (i=0;i<13;i++)
	{
	logoImages[i] = "images/logo_small" + (i+1) + ".jpg"
	buttonImages[i] = "images/go" + (i+1) + ".jpg"
	footerImages[i] = "images/logo_footer" + (i+1) + ".jpg"
	classname[i] = "link" + (i+1);
	classDefault[i] = "linkdefault" + (i+1);
	}
	 
	var p = logoImages.length
	var image_i = 1;
	
	function showImage(img){
		var len = document.images.length;
		var whichImage = Math.round(Math.random()*(p-1));
		document.images[0].src = logoImages[whichImage];  // assuming images[0] is ur logo image
		document.images[len-1].src = footerImages[whichImage];   // assuming images[1] is ur buttton image
		//document.images[2].src = buttonImages[whichImage];   // assuming images[1] is ur buttton image
		if(img == 'swf')
		 document.images[1].src = buttonImages[whichImage];   // assuming images[1] is ur buttton image
		else
		document.images[2].src = buttonImages[whichImage];   // assuming images[1] is ur buttton image
		document.getElementById('homelink').className=classname[whichImage]; // Done.
		document.getElementById('advlink').className=classname[whichImage]; // Done.
		document.getElementById('catlink').className=classname[whichImage]; // Done.
		document.getElementById('searchadvice').className=classname[whichImage]; // Done.
		document.getElementById('companylink').className=classname[whichImage]; // Done.
		document.getElementById('advanced_search').className=classDefault[whichImage]; // Done.
		document.getElementById('categories').className=classDefault[whichImage]; // Done.
		document.getElementById('search').className=classDefault[whichImage]; // Done.
		document.getElementById('home').className=classname[whichImage]; // Done.
		if(document.getElementById('sel_link')!=null)
			document.getElementById('sel_link').className=classname[whichImage]; // Done.
		image_i++;
		if (image_i >= p) image_i = 1;
	}


function MM_swapImgRestore() { //v3.0

   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

 }

 

 function MM_findObj(n, d) { //v4.01

   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

   if(!x && d.getElementById) x=d.getElementById(n); return x;

 }

 

 function MM_swapImage() { //v3.0
MM_swapImgRestore()
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
   
   for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null)
   {
   document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
   }

 }
 
var currentElement;
var j;
j=0;
var divElements = document.getElementsByTagName('div');
function showhide(elementId)
{
	//startdivhide();
	for (i = 0; i < divElements.length; i ++) 
    { 
            currentElement = divElements[i]; 
            currentElement.style.display = 'none'; 
    }
	//document.getElementById('divfirst').style.display = 'none';
	//alert("div"+elementId);	
	document.getElementById("div"+elementId).style.display = "block";
		
}
function startdivhide()
{
	for (i = 0; i < divElements.length; i ++) 
    { 
            currentElement = divElements[i]; 
            currentElement.style.display = 'none'; 
    } 
	document.getElementById('divfirst').style.display = 'block';
	changeBackground(0,0);
	//MM_swapImage('compover','','images/premierlevel_071.gif',1);
	
}
function showsublist(elementId)
{
	
	document.getElementById(elementId).style.display = "block";
		
}

function changeBackground(table_index,td_index)
{
 var parent_table = document.getElementById("parent_table");
 var table_count =5;
 for (i=0;i<table_count;i++)
 {
    var child_table = document.getElementById("child_table" + i);
if(child_table !=null)
{

    var child_tds = child_table.getElementsByTagName("td");
	
    for (j=0;j<child_tds.length;j++)
    {
        if (i == table_index && j == td_index)
        {
          if (child_tds[j] != null){
            child_tds[j].style.backgroundImage = 'url(images/premier_tabdown_n.gif)';
			child_tds[j].style.color = "#646F7C";
		  if(i==0)
		  	child_tds[j].style.backgroundImage = 'url(images/premier_tabdown_l.gif)';
		  if(i==3)
		  	child_tds[j].style.backgroundImage = 'url(images/premier_tabdown_3.gif)';
            continue;
			}
		}
		if (child_tds[j] != null)
			child_tds[j].style.backgroundImage = 'url(images/premier_tabnormal_n.gif)';
            child_tds[j].style.color = "#ffffff";
		  	if(i==0)
				child_tds[j].style.backgroundImage = 'url(images/premier_tabnormal_l.gif)';
			if(i==3)
				child_tds[j].style.backgroundImage = 'url(images/premier_tabnormal_3.gif)';
    }
 }
}
}

function openpop()
{
	
	var v=window.open("/productlist.php","newwindow","menubar=1,resizable=1,scrollbars=1,width=625,height=600"); v.focus(); return false;
}
function openservicespop()
{
	
	var sl=window.open("/serviceslist.php","serwindow","menubar=1,resizable=1,scrollbars=1,width=625,height=600"); sl.focus(); return false;
}

function winopennew(cntval,uid)
		{
			//alert(cntval);
			//return false;
			//var url='popwindo.php?cntname='+escape(cntval);
			var w=window.open("/view_multi_address.php?cntname="+cntval+"&uid="+uid,"newwindow","menubar=1,resizable=1,scrollbars=1,width=625,height=600"); w.focus(); return false;
			//window.open('popwindo.php?cntname='+cntval);
		}
		
//function to disable right click
function right(e) {
 if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
  return false;
 else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
  alert("Sorry, you do not have permission to right click.");
  return false;
 }
 return true;
}

/*document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;*/

//to send RFI
	function pl_store_values(id)
	{
		var url="/select_rfi_session.php?id="+id+"&pl_rfi=pl_rfi_value";
		xmlHttp2=GetXmlHttpObject(pl_send_rfi)
		xmlHttp2.open("POST", url , true)
		xmlHttp2.send(null)
	}
	function pl_send_rfi() 
	{ 
		if (xmlHttp2.readyState==4 || xmlHttp2.readyState==200)
		{ 
			var	rfi=window.open("/rfi.php","rfiwindow_pl","menubar=1,resizable=1,scrollbars=yes,width=670,height=600"); rfi.focus(); return false;			
			
		} 
	} 
	
	function returnto(url){			
		document.simplesrch.action = url;
		document.simplesrch.method = 'post';
		document.simplesrch.submit();		
	}
		