//Global Coremetrics variables for P&A debug
var cmBrandKey = "";
var cmProductNumber="";

var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('body');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('body');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

// compare.js
 
//handle compare check box in search result list 
//when checked, add pid to cookie, add checkbox div to compare list component
//when unchecked, remove pid from cookie, remove checkbox div from compare list component
function setupCompare(checkboxId, pid, pno, brand){
 
	var checkbox = document.getElementById(checkboxId);
	var cookieValue = pid+"|" + pno +"|" +brand;
	 
	if(checkbox.checked== true){
	
    	//check if there are already maximum (4) products selected, if so, give warning message, otherwise, add to list
	    var total = getTotalSelected();
	    if(total ==null || total <4){
	       
			addCookie('comparePID', cookieValue, '1');	 
			addToList(pid, pno, brand);
		}	
		else{		
			//uncheck checkbox in search result list
	       var oldCheckBox = document.getElementById(checkboxId);
	       oldCheckBox.checked = false;
	       //alert("error, already have 4 products selected");
	       dropdownmenu(checkboxId, 'event', 'moreErrorMsgBox')
		} 
	}
	else{		 
		removeCookie('comparePID', cookieValue, '1');	
		removeFromList(pid); 
	}
}




//handle check box in compare list component
//when unchecked, remove pid from cookie, remove checkbox div from component, also uncheck related checkbox in result list
function setupListCompare(checkboxId, pid, pno, brand){
  var listCheckBox = document.getElementById(checkboxId);
 
  var checkbox = document.getElementById("compareBox"+pid);
  if(checkbox!=null){
  	checkbox.checked = listCheckBox.checked;
  }
	
	//setupCompare("compareList"+pid, pid, pno);
	var cookieValue = pid+"|" + pno +"|" +brand;
	 
	if(listCheckBox.checked== false){ 
		removeCookie('comparePID', cookieValue, '1');	
		removeFromList(pid); 
	}
}

function getTotalSelected(){
   var comparisonDiv = document.getElementById("comparisonList");  
   
   if(comparisonDiv ==null){
   	return "0";
   }
   
   var total = comparisonDiv.childNodes.length;
   return total;
}

function addToList(pid, pno, brand){
  var pidCheckBox = document.getElementById("compareList"+pid);
  if(pidCheckBox !=null){
  pidCheckBox.checked = true;
  } 
  else{
        var comparisonDiv = document.getElementById("comparisonList");
	    var divTag = document.createElement("div");
	    var displayBrand = ', ' + brand;
        if ((document.domain).indexOf('safc') > 0)
        {
          displayBrand = '';
        }
	    divTag.setAttribute('id','compareListDiv'+pid);	    	 
		divTag.innerHTML = "<input type=\"checkbox\" name=\"compareListCheckbox\" value=\""
			+pid+"\" checked=\"true\" onclick=\"setupListCompare('compareList"
			+pid+"','"+pid+"','"
			+pno+"','"
			+brand+"');\" id=\"compareList"
			+pid+"\"/>"
			+pno + displayBrand;
		comparisonDiv.appendChild(divTag);	 
  }
  
  var comDiv = document.getElementById("comparisonDiv");
  if(comDiv.style.display == "none"){
  	 comDiv.style.display ="";
  }
}
 
function removeFromList(pid){
   var pidCheckBox = document.getElementById("compareListDiv"+pid);
  if(pidCheckBox !=null){  	
  	var d = document.getElementById('comparisonList'); 
    d.removeChild(pidCheckBox); 
    //if list becomes empty, hide the list
    var children = d.getElementsByTagName('div');
    if(children == null || children.length ==0){
    	hideCompareList();
    }
  }  
}
 
function eraseCompareList(){
   var d = document.getElementById('comparisonList'); 
   d.innerHTML ="";
   hideCompareList();
} 

function hideCompareList(){
  var d = document.getElementById('comparisonDiv'); 
  d.style.display ="none";
}

function validateAndSubmitCompare(comparebutton, name, checkbox){
 var pid = readCookie(name);
  
 if(pid !=null && pid !=""){
     var returnURL = escape(location.href);
	 var currentTagTokens = pid.split( "+" );
	 var total = currentTagTokens.length;
	 if(total>=2 && total <=4){
	 	//eraseCookie(name);  
	 	var catalog = getContextPath();
	  	var url =catalog + '/Compare.do?P_ID=' +pid +'&returnURL='+returnURL; 
	 	location.href = url;
	  }
	  else if(total<2){
//		alert('error, total # of products is'+total);
		dropdownmenu(comparebutton, 'event', 'lessErrorMsgBox');
	  }
	  else if(total>4){
   		  dropdownmenu(comparebutton, 'event', 'moreErrorMsgBox');
	  }
  } 
  else{
  	dropdownmenu(comparebutton, 'event', 'lessErrorMsgBox');
  } 	 
}
  
function clearCompare(name, checkbox){
   var checkboxes = document.getElementsByName(checkbox);
    
   for(i=0; i<checkboxes.length; i++){
   	 checkboxes[i].checked = false;
   }
   eraseCookie(name);
   eraseCompareList();
}

 function createCookie(name,value,days) {
	/*if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";*/
	//document.cookie = name+"="+value+expires+"; path=/";
	
	//make this a session cookie, it expires (gets deleted) when user's session ends, i.e. when the browser is closed.
	 document.cookie = name+"="+value+ "; path=/"; 
	
}
  		 
 function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) {
			return  c.substring(nameEQ.length,c.length);
		}
	}
 	return null;
}
 
 function eraseCookie(name) {
	createCookie(name,"",-1);
}
 
 function addCookie(name, value, days){
 	var oldValue = readCookie(name); 
 	if(oldValue !=null && oldValue !=""){
 	  value = oldValue + '+' + value;
 	} 
 	eraseCookie(name);
 	createCookie(name,value,days); 	 	 
 }
 
 function removeCookie(name, value, days){
 	var oldValue = readCookie(name); 
 	if(oldValue !=null && oldValue !=""){
	 	  var currentTagTokens = oldValue.split( "+" );
	  	  var newValue = "";
	
		  for ( var i = 0; i < currentTagTokens.length; i++ )
		  {
			  	if(currentTagTokens[i] !=value){ 
			  		if(newValue==""){
			  			newValue = currentTagTokens[ i ];
			  		}else{
			    		newValue = newValue +"+"+ currentTagTokens[ i ];
			    	}
			    }  	 	 
		  }
	 
	 	  if(oldValue!= newValue){
		       eraseCookie(name);
		       if(newValue!=""){
		       		createCookie(name,newValue,days);
		       }
		  }
 	} 
 }
 
//total of visible columns 
var visibleTotal; 
function removeItem(total, hide_index, cookieValue) {   
    
	if(visibleTotal == null){
		visibleTotal = total;
	}
	
	if(visibleTotal <=1) return;
	 
	//remove from cookie 
	removeCookie('comparePID', cookieValue, '1');
				 
	visibleTotal = visibleTotal -1;
	 
	hide_index = hide_index%total;
	 
    var tbl = document.getElementById("compareTbl");  
    var elements = tbl.getElementsByTagName("td");
    var index =0;
    
    for(var i = 0;i < elements.length;i++){
       
        if(elements[i].className.indexOf("columnwide")>=0){        	 
        	
            if(index%total == hide_index){            	
            	elements[i].style.display ="none"; 
            }

            var classname = elements[i].className;
            var count = classname.substring(classname.length-1, classname.length);
            count = count-1; 
            //if this is image row, keep image css
            if(classname.indexOf("imageCell")>=0){ 
	            elements[i].className ="imageCell columnwide" + visibleTotal;
            }
            else{
            	elements[i].className ="columnwide" + visibleTotal;
            }
            index = index+1; 
        }        
    }
    //CD 9005496 hide the remove buttons if comparable product tabs are less than three.
    if(visibleTotal <=2){
	    for(var i = 0;i <= 3;i++){
		var rmvdiv = document.getElementById("removeImgDiv"+i);
		if(rmvdiv != null) {
			rmvdiv.style.display ="none";
			rmvdiv.style.position = "absolute"
			}
		}
	}    
} 

function getContextPath(){ 
        try{
            var contextPath= document.getElementById("contextPath");
	        return contextPath.value; 
	    }catch(err){
	      return '/catalog';
	    } 
    }
    

//popuppage.js
var vOrderText;

var gPopupWin

function viewPopupPage(sUrl, sHeight, sWidth, sScrollbars)
{
	viewPopupPage(sUrl, sHeight, sWidth, sScrollbars, 'no');
}

function viewPopupPage(sUrl, sHeight, sWidth, sScrollbars, sToolbars)
{
	viewPopupPage(sUrl, sHeight, sWidth, sScrollbars, sToolbars, 'no', '50', '50');
}



function viewPopupPage(sUrl, sHeight, sWidth, sScrollbars, sToolbars, sMenubar, sTop, sLeft)
{
	if (sHeight == null)
	{
		sHeight = '300';
	}
	if (sWidth == null)
	{
		sWidth = '300';
	}
	if (sScrollbars == null)
	{
		sScrollbars = 'no';
	}
	if (sToolbars == null)
	{
		sToolbars = 'no';
	}
	if (sMenubar == null)
	{
		sMenubar = 'no';
	}
	if (sTop == null)
	{
		sTop = '50';
	}
	if (sLeft == null)
	{
		sLeft = '50';
	}
    var bOpenWindow
	bOpenWindow = 0;
	if (gPopupWin==0)
	{
	   bOpenWindow = 1;
	} else if (gPopupWin.closed) {
	   bOpenWindow = 1;
	   gPopupWin = null;
	}
	if (bOpenWindow == 1)
	{

		if (parseInt(navigator.appVersion) >= 4)
		{
			gPopupWin = open(sUrl,
				'PopupPageWindow',
				'toolbar=' + sToolbars + ',location=no,status=no,directories=no,resizable=yes,width=' + sWidth + ',height=' + sHeight + ',scrollbars=' + sScrollbars + ',menubar=' + sMenubar + ',top=' + sTop + ',left=' + sLeft);
		}
		else
		{
			gPopupWin = open(sUrl,
				'PopupPageWindow',
				'toolbar=' + sToolbars + ',location=no,status=no,directories=no,resizable=yes,width=' + sWidth + ',height=' + sHeight + ',scrollbars=' + sScrollbars + ',menubar=' + sMenubar);
		}
	}
	else
	{
		gPopupWin.location = sUrl
	}
	gPopupWin.focus()

}

//POPUP stuff//
function openPopUpAddlInfo(matNumber)
{
	gPopupWin = 0;
	var caption = "";
	var transportationNumberHtml = "";
	var descriptionHtml = "";
	var additionalFeesHtml = "";
	var tariffCodeHtml = "";
	var casNumberHtml = "";
	var japanFireCodeHtml = "";
	var poisonSubstanceCodeHtml = "";
	
	var DescField = "Desc"+matNumber;
	var description = document.getElementById(DescField).value;

	var	feesField = "Fees"+matNumber;
	var fees = document.getElementById(feesField).value;
		
	var	tariffField = "Tariff"+matNumber;
	var tariffCode = document.getElementById(tariffField).value;
	
	var	casField = "CAS"+matNumber;
	var casNumber = document.getElementById(casField).value;
	
	var	transField = "Trans"+matNumber;
	var transportNumber = document.getElementById(transField).value;
	
	var	jfcField = "JFC"+matNumber;
	var jfc = document.getElementById(jfcField).value;

	var	pscField = "PSC"+matNumber;
	var psc = document.getElementById(pscField).value;

	
	var prodNumberHtml = "<" + "TR" + ">\n" +
			             "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Product Number: " + "<" + "/TD" + ">\n" +
			             "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			             "<" + "TD height=\"20\"" + ">" + matNumber + "<" + "/TD" + ">\n" +
            			 "<" + "/TR" + ">\n";
  	
  	if (description !="")
	{					 
		descriptionHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Description: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + description + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
    	}
  	
    	
  	if (fees !="" && fees.indexOf("Aqis") <= 0)
	{					  
	 additionalFeesHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Additional Fees/Restrictions: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + fees + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
  	}
  	
  	if (tariffCode !="")
	{
	     tariffCodeHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Harmonized Tariff Code: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + tariffCode + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
	}
	
	if (casNumber != "")
	{
	      casNumberHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"CAS Number: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + casNumber + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
	}
	
	if (transportNumber !="")
	{
		transportationNumberHtml = "<" + "TR" + ">\n" +
			              		   "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"UN Transportation Number (IATA): " + "<" + "/TD" + ">\n" +
			              		   "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
						           "<" + "TD height=\"20\"" + ">" + transportNumber + "<" + "/TD" + ">\n" +
            			  		   "<" + "/TR" + ">\n";
    }
	
	if (jfc !="")
	{
		japanFireCodeHtml = "<" + "TR" + ">\n" +
			              	"<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Japan Fire Code: " + "<" + "/TD" + ">\n" +
			              	"<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
						    "<" + "TD height=\"20\"" + ">" + jfc + "<" + "/TD" + ">\n" +
            			  	"<" + "/TR" + ">\n";
    	}
    
    	if (psc !="")
	{
		poisonSubstanceCodeHtml = "<" + "TR" + ">\n" +
			              		  "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Poison/Deleterious Substance Code: " + "<" + "/TD" + ">\n" +
			              		  "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
						          "<" + "TD height=\"20\"" + ">" + psc + "<" + "/TD" + ">\n" +
            			  		  "<" + "/TR" + ">\n";
   	 }

	var cssLines;
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
	{ 	
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 16px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
	else
	{
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 13px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
		
	var popupHtml = "<" + "HTML" + ">\n" +
                    "<" + "BODY" + ">\n" + cssLines + "\n" +
	                "<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\""+">\n" +
      				"<" + "TR" +">\n" +
			        "<" + "TD height=\"25\" bgcolor=\"#e2e2e2\" STYLE=\"font-weight : bold;\" align=\"left\" valign=\"middle\" width=\"4\">&nbsp;" + "<" + "/TD"+">\n" +
			        "<" + "TD height=\"25\" bgcolor=\"#e2e2e2\" STYLE=\"font-weight : bold;\" align=\"left\" valign=\"middle\">Additional Item Information" + "<" + "/TD"+">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
					"<" + "TD width=\"4\""+">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\"" + ">\n";
					
		popupHtml = popupHtml + prodNumberHtml + descriptionHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
			        "<"+ "HR noshade width=\"100%\" size=\"1\"" + ">\n" +
					"<" + "/TD" + ">\n" +
					"<" + "/TR" + ">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\"" + ">\n";
	
		if (browser!="Microsoft Internet Explorer")
		{ 			
		popupHtml = popupHtml + additionalFeesHtml + tariffCodeHtml + transportationNumberHtml + casNumberHtml + japanFireCodeHtml + poisonSubstanceCodeHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n" +
					"<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"window.close()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	             		"<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
         }
         else
         {
         popupHtml = popupHtml + additionalFeesHtml + tariffCodeHtml + transportationNumberHtml + casNumberHtml + japanFireCodeHtml + poisonSubstanceCodeHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n" +
					"<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"javascript:hidePopup();\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	                         "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
         } 
         
	if (browser=="Microsoft Internet Explorer")
	{
		var popper = document.getElementById("PopupDiv");
	//	popper.style.display="block";
		popper.style.display="inline";
		popper.innerHTML = popupHtml;
	}
	else
	{
	    viewPopupPage('',500,620,'yes');
        gPopupWin.document.open();
        gPopupWin.document.write(popupHtml);  
        gPopupWin.document.close();
	}
	  
}

function hidePopup()
{
var popper = document.getElementById("PopupDiv");
		popper.style.display="none"; 
}



function openPopUpInquire(matNumber)
{
	gPopupWin = 0;
	var caption = "";
	var inquireHtml = "";
	
	var inquireField = "Inquire"+matNumber;
	var inquire = document.getElementById(inquireField).value;
	
	
  	if (inquire !="")
	{					 
		inquireHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + inquire + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
    }
    
    var cssLines;
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
	{ 	
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 16px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
	else
	{
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 13px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
  	
	var popupHtml = "<" + "HTML" + ">\n" + 
                    "<" + "BODY" + ">\n" + cssLines + "\n" +
	                "<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\""+">\n" +
      				"<" + "TR" +">\n" +
					"<" + "TD width=\"4\""+">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE border=\"0\" width=\"100%\"" + ">\n";
					
		popupHtml = popupHtml + inquireHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
			        "<"+ "HR noshade width=\"100%\" size=\"1\"" + ">\n" +
					"<" + "/TD" + ">\n" +
					"<" + "/TR" + ">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n";
		
		if (browser!="Microsoft Internet Explorer")
		{ 
		popupHtml = popupHtml+ "<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"window.close()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	                             "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
         }
         else
         {
        popupHtml = popupHtml+ "<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"hidePopup()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	                             "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
         }           
    if (browser=="Microsoft Internet Explorer")
	{
		var popper = document.getElementById("PopupDiv");
		popper.style.display="block"; 
		popper.innerHTML = popupHtml;
	}
	else
	{
	    viewPopupPage('',500,620,'yes');
        gPopupWin.document.open();
        gPopupWin.document.write(popupHtml);  
        gPopupWin.document.close();
	}
}


function openPopUpComplianceInfo(matNumber)
{
	gPopupWin = 0;
	var caption = "";
	var complianceScreeningHtml = "";
	var descriptionHtml = "";
	var additionalFeesHtml = "";
	var drugTypeHtml = "";
	var ndcNumberHtml = "";
	
	var DescField = "Desc"+matNumber;
	var description = document.getElementById(DescField).value;

	var	drugField = "Drug"+matNumber;
	var drug = document.getElementById(drugField).value;

	var	feesField = "Fees"+matNumber;
	var fees = document.getElementById(feesField).value;
		
	var	ndcField = "NDC"+matNumber;
	var ndc = document.getElementById(ndcField).value;
	

	var prodNumberHtml = "<" + "TR" + ">\n" +
			             "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Product Number: " + "<" + "/TD" + ">\n" +
			             "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			             "<" + "TD height=\"20\"" + ">" + matNumber + "<" + "/TD" + ">\n" +
            			 "<" + "/TR" + ">\n";
  	
  	if (description !="")
	{					 
		descriptionHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Description: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + description + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
    }
  	
  	complianceScreeningHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Compliance/Screening Notes: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD class=\"Normal2\" height=\"20\"" + ">" + "This order may require review prior to shipping" + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
  	
  	if (fees !="" && fees.indexOf("Aqis") >= 0)
	{					  
	 additionalFeesHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Additional Fees/Restrictions: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + fees + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
  	}
  	
  	if (drug !="")
	{
	     drugTypeHtml = "<" + "TR" + ">\n" +
			            "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Drug Type: " + "<" + "/TD" + ">\n" +
			            "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			            "<" + "TD height=\"20\"" + ">" + drug + "<" + "/TD" + ">\n" +
            			"<" + "/TR" + ">\n";
	}
	
	if (ndc != "")
	{
	      ndcNumberHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"NDC Number: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + ndc + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
	}
	
	var cssLines;
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
	{ 	
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 16px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
	else
	{
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 13px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
	
		
	var popupHtml = "<" + "HTML" + ">\n" + 
                    "<" + "BODY" + ">\n" + cssLines +"\n" +
	                "<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\""+">\n" +
      				"<" + "TR" +">\n" +
			        "<" + "TD height=\"25\" bgcolor=\"#e2e2e2\" STYLE=\"font-family : @Arial Unicode MS; font-size : small; color : black; font-weight : bold;\" align=\"left\" valign=\"middle\" width=\"4\">&nbsp;" + "<" + "/TD"+">\n" +
			        "<" + "TD height=\"25\" bgcolor=\"#e2e2e2\" STYLE=\"font-family : @Arial Unicode MS; font-size : small; color : black; font-weight : bold;\" align=\"left\" valign=\"middle\">Compliance Information" + "<" + "/TD"+">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
					"<" + "TD width=\"4\""+">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\"" + ">\n";
					
		popupHtml = popupHtml + prodNumberHtml + descriptionHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
			        "<"+ "HR noshade width=\"100%\" size=\"1\"" + ">\n" +
					"<" + "/TD" + ">\n" +
					"<" + "/TR" + ">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\"" + ">\n";

		popupHtml = popupHtml + complianceScreeningHtml + additionalFeesHtml + drugTypeHtml + ndcNumberHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n"; 
					
		if (browser!="Microsoft Internet Explorer")
		{ 
		popupHtml = popupHtml+ "<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"window.close()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	                "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
        }
        else
        {
        popupHtml = popupHtml+ "<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"hidePopup()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	               "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
        }
          
    if (browser=="Microsoft Internet Explorer")
	{
		var popper = document.getElementById("PopupDiv");
 		popper.style.display="block"; 
		popper.innerHTML = popupHtml;
	}
	else
	{
	    viewPopupPage('',500,620,'yes');
        gPopupWin.document.open();
        gPopupWin.document.write(popupHtml);  
        gPopupWin.document.close();
	}
    
}

function openPopUpInquire_translate(matNumber, close_label)
{
	gPopupWin = 0;
	var caption = "";
	var inquireHtml = "";
	
	var inquireField = "Inquire"+matNumber;
	var inquire = document.getElementById(inquireField).value;

  	if (inquire !="")
	{					 
		inquireHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + inquire + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
    }
  	
	var popupHtml = "<" + "HTML" + ">\n" +
                    "<" + "BODY" + ">\n" + 
					"<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".normal { FONT: 13px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n" +
	                "<" + "TABLE class=\"normal\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\""+">\n" +
      				"<" + "TR" +">\n" +
					"<" + "TD width=\"4\""+">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE border=\"0\" width=\"100%\"" + ">\n";
					
		popupHtml = popupHtml + inquireHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
			        "<"+ "HR noshade width=\"100%\" size=\"1\"" + ">\n" +
					"<" + "/TD" + ">\n" +
					"<" + "/TR" + ">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n" +
					"<" + "INPUT type=\"button\" value=\""+ close_label+"\" name=\"button\" onClick=\"window.close()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	                  "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
    viewPopupPage('',500,620,'yes');
    gPopupWin.document.open();
    gPopupWin.document.write(popupHtml);
    gPopupWin.document.close();    
}
 

/***********************************************
use the following script to setup position of popupDiv 
***********************************************/
 
var offsetxpoint=-20 //Customize x offset of tooltip 
var offsetypoint=-70 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
 

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function positionPopupDiv(e){	   

		var tipobj=  document.getElementById("PopupDiv");
		 
		//var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		 
		//Find out how close the mouse is to the corner of the window
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
		 
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
			tipobj.style.top=curY+offsetypoint+"px"
		 
		//tipobj.style.visibility="visible"	 
}

//PricingAvailabilityAjax.js
// PricingAvailabilityAjax.js
//sguo 10/29/2008: make AJax calls for pricing and availability
   
   function loadMissionPAAndClone(trcList, type, productNumber, brandKey){
	    
	    var catalog =  getContextPath();
		var url = catalog + '/PricingAvailability.do?productNumber='+type+'&brandKey='+brandKey;		 
		url= url+'&isMission=true&missionProductNumber='+productNumber +'&trcList=' + trcList;
		var postData = 'loadFor=PRD';				
		setupPending('pricingAvailability');
		
		var newCallback = new Object();
		newCallback.success = successPriceFunction;
		newCallback.failure = failurePriceFunction;
		newCallback.timeout = 50000;
		newCallback.argument = '1';	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	
    function loadMissionPA(type, productNumber, brandKey){
	   
	    var catalog =  getContextPath();
		var url = catalog + '/PricingAvailability.do?productNumber='+type+'&brandKey='+brandKey;		 
		url= url+'&isMission=true&missionProductNumber='+productNumber;
		var postData = 'loadFor=PRD';				
		setupPending('pricingAvailability');
		
		var newCallback = new Object();
		newCallback.success = successPriceFunction;
		newCallback.failure = failurePriceFunction;
		newCallback.timeout = 50000;
		newCallback.argument = '1';	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	 
	//product detail 
	function loadPA(productNumber, brandKey){
	    	    	
		//Set Coremetrics global debug variables for Product Detial
		cmBrandKey = brandKey;
		cmProductNumber = productNumber;
	    
	    	loadGeneralPA(productNumber, brandKey, 'pricingAvailability', 'PRD'); 
	}	
	  
	//product comparison  
	function loadComparisonPA(productNumber, brandKey, priceElement){
		loadGeneralPA(productNumber, brandKey, priceElement, 'comparison');
	}
	 
	function loadGeneralPA(productNumber, brandKey, priceElement, loadFor){
	    var catalog =  getContextPath();
		var url = catalog + '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;		 
		var postData = 'loadFor=' +loadFor;				
		setupPending(priceElement);
		
		var newCallback = new Object();
		newCallback.success = successPriceFunction;
		newCallback.failure = failurePriceFunction;
		newCallback.timeout = 50000;
		newCallback.argument = priceElement;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	  
	function failurePriceFunction(o)
	{

		var siRNAID = o.argument;
		var redCubeImg = "/etc/medialib/sigma-aldrich/search/circular-progress0.Par.0001.Image.download.gif";
		var pricingIndicatorToggler = new PricingIndicatorToggle(new Array('TRC_CONTROL_PRICE_LABEL'), '', '<img src='+redCubeImg+'>');
		pricingIndicatorToggler.togglePricingOff();
		document.getElementById(o.argument).innerHTML = "<div class='noPrice'>" + getErrorPrice()+ "</div>";	
	}
	 
	function CPfailurePriceFunction(o)
	{ 
 		document.getElementById('pricingAvailability').innerHTML = "<div class='noPrice'>" + getErrorPrice()+ "</div>";	
	}
	 
	function successPriceFunction(o)
	{ 
	    try
		{
			var xmlDoc = "";
			if(o.responseXML != null){
				var xmlDoc = o.responseXML.documentElement;
			}						 
			xmlDoc=o.responseText;
			
			//Coremetrics tags for Discontinued Product debug - Product Detial
			if (window.location.href.indexOf('ProductDetail.do') >=0 && xmlDoc.indexOf('cm_sp=DiscontinuedProduct-_-TService') >=0) {
				cmCreatePageviewTag('PRODUCT: '+ cmBrandKey +' (' + cmProductNumber +')', 'PD_DEBUG');
			}
			//End CM Tags	
			 		 
			document.getElementById(o.argument).innerHTML = xmlDoc;				 
		}
		catch(err)
		{
			if(document.getElementById(o.argument))
		    	document.getElementById(o.argument).innerHTML = "<div class='noPrice'>" + getErrorPrice() + "</div>";	
		} 
	}
	  
	function loadPAForMatMission(oldMatNo, missionType,  productNumber, brandKey){ 	
	    var matNo =   missionType + '-' + oldMatNo;
	    
		var quantity = document.getElementById(matNo).value;	
		if(quantity ==''){
		  quantity=1;	 
		}
		var catalog = getContextPath();
		var url = catalog + '/PricingAvailability.do?productNumber='+ missionType +'&brandKey='+brandKey;	
		url= url+'&isMission=true&missionProductNumber='+oldMatNo;		  		  
		var postData='MatNo' +  matNo +'=' + quantity+ '&loadFor=MAT';					
		setupPendingForOneRow(  matNo);
			
		var newCallback = new Object();
		newCallback.success = successPriceRowFunction;
		newCallback.failure = failurePriceRowFunction;
		newCallback.timeout = 50000;		 
		newCallback.argument = matNo;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	 
	function loadPAForMat(matNo, productNumber, brandKey){ 		 
		var quantity = document.getElementById(matNo).value;	
		if(quantity ==''){
		  quantity=1;	 
		}
		var catalog = getContextPath();
		var url = catalog + '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;			  		  
		var postData='MatNo' + matNo +'=' + quantity+ '&loadFor=MAT';			
		 
		setupPendingForOneRow( matNo);
			
		var newCallback = new Object();
		newCallback.success = successPriceRowFunction;
		newCallback.failure = failurePriceRowFunction;
		newCallback.timeout = 50000;		 
		newCallback.argument = matNo;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	 
	function setupPendingForOneRow(matNo){
	    var rowNo = 'row'+matNo;
		var matRow = document.getElementById(rowNo);
		if (matRow.hasChildNodes()) 
		{
		   var tdList = matRow.childNodes; 		   
		   var index=0;
		   for (var i = 0; i < tdList.length; i++) 
		   {
		     var td=matRow.childNodes[i];
		     if(td.nodeName=='TD'){
			     index = index+1;
			     if(index==2){	 
				   td.innerHTML = '<img src="' + getRedCubeImg() + '" >loading..</img>'; 
			     }
			     if(index>2 && index <5){ 
			       td.innerHTML = '';
			     }
			     //if 5th is quantity box, leave it on page
			     if(index==5){
			       var quantity = document.getElementById(matNo)
			       if( td != quantity.parentNode){
			       	  td.innerHTML = '';
			       }
			     }
		     }		     
		   }
		   if(index<10){
		      setupPending(rowNo);
		   }
  
		}else{
		   setupPending(rowNo);
		} 		 
	}
	 
	function successPriceRowFunction(o)
	{
	    var matNo = o.argument;
		var xmlDoc = o.responseText; 
		if(xmlDoc == null ||xmlDoc==''){
		   failurePriceRowFunction(o);
		}
		
		else{			 	 
		    var matRow = document.getElementById('row'+matNo);		    
		     
		    var newdiv = document.createElement('div'); 
  			
  			var className = matRow.className;
  			newdiv.innerHTML = "<table><tr id='" + "row"+matNo +"' class='"+ className +"'>"+ xmlDoc +"</tr></table>";
  			
		   var tempDiv = newdiv.firstChild;
		   var tempTbl = tempDiv.firstChild;
		   var tempRow = tempTbl.firstChild;
		   /*
		   while (tempRow.hasChildNodes())
			{
			  var tempTd =tempRow.firstChild;
			  matRow.appendChild(tempTd);			   
			}	*/
			
			matRow.parentNode.replaceChild(tempRow,matRow);	    
		}
	}
	
	function failurePriceRowFunction(o)
	{	
		var matNo = o.argument;		
		var matRow = document.getElementById('row'+matNo);
		if (matRow.hasChildNodes()) 
		{
		   var tdList = matRow.childNodes; 		   
		   var index=0;
		   for (var i = 0; i < tdList.length; i++) 
		   {
		     var td=matRow.childNodes[i];
		     if(td.nodeName=='TD'){
			     index = index+1;
			     if(index==2){			     			      
				   td.innerHTML = "<div class='noPrice'>" + getErrorPrice() + "</div>";		
			     }			      
		     }		     
		   } 
		} 
	} 

function openLangOnSR(productNumber, brandKey){
	    var divId = productNumber+brandKey;
		var button = document.getElementById(divId);
		button.style.visibility="visible";
		button.style.position="fixed";
		loadLangOnSR(productNumber, brandKey, divId);
}
	
function openPAOnSR(productNumber, brandKey, divID, pricingButtonId, page)
{
	var button = document.getElementById(pricingButtonId);

	if (page!=null && page !='techcontent')	
		button.innerHTML ="<a href=\"javascript:closePAOnSR(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'\');cmTagAndLink('Close Pricing','Search Result Page Details',null,null,null);\">close</a>";
	else
		button.innerHTML ="<a href=\"javascript:closePAOnSR(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'techcontent\');cmCreatePageElementTag('Close Pricing', 'Technical Content Page');\">close</a>";		

	//Set Coremetrics global debug variables for Search Results
	cmBrandKey = brandKey;
	cmProductNumber = productNumber; 

	loadPAOnSR(productNumber, brandKey, divID);
}

	
function closePAOnSR(productNumber, brandKey, divID, pricingButtonId, page)
{

	var button = document.getElementById(pricingButtonId);
	if (page!=null && page !='techcontent')
		button.innerHTML ="<a href=\"javascript:openPAOnSR(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'\');cmTagAndLink('Open Pricing','Search Result Page Details',null,null,null);\">pricing</a>";		
	else
		button.innerHTML ="<a href=\"javascript:openPAOnSR(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'techcontent\');cmCreatePageElementTag('Open Pricing', 'Technical Content Page');\">pricing</a>";	

	var priceDiv = document.getElementById(divID);
	priceDiv.innerHTML ="";		
}
	function loadPAOnSR(productNumber, brandKey, divID){
		var tdDivID = 'td'+divID;
		//document.getElementById(tdDivID).style.padding= '0pt';
		//document.getElementById(tdDivID).style.margin= '0pt';
	    var catalog = getContextPath();
		var url = catalog +  '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;		
		url = url +'&isLoadForm=false';
		 
		var postData = 'loadFor=SR';				
		setupPending(divID);
		
		var newCallback = new Object();
		newCallback.success = SRsuccessPriceFunction;
		newCallback.failure = SRfailurePriceFunction;
		newCallback.timeout = 50000;
		newCallback.argument = divID;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}

	function loadLangOnSR(productNumber, brandKey, divID){
		var tdDivID = 'td'+divID;
		//document.getElementById(tdDivID).style.padding= '0pt';
		//document.getElementById(tdDivID).style.margin= '0pt';
	    var catalog = getContextPath();
		var url = catalog +  '/MsdsLangList.do?productNumber='+productNumber+'&brandKey='+brandKey;		
		 
		var postData = 'loadFor=msds';				
		
		
		var newCallback = new Object();
		
		newCallback.success = LangSuccessFunction;
		newCallback.failure = LangfailureFunction;
		newCallback.timeout = 50000;
		newCallback.argument = divID;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}	 

	function LangSuccessFunction(o)
	{
 
	    var divID =	o.argument;	 
	    
	    try{
			var xmlDoc = o.responseText;	
			
			document.getElementById(divID).innerHTML = xmlDoc;				 
		}
		catch(err)
		{		
		    LangfailureFunction;
		} 
	}
		
	function LangfailureFunction(o)
	{
	   
		var divID = o.argument;
		document.getElementById(divID).innerHTML = "fail";	
	}

	function SRfailurePriceFunction(o)
	{
	   
		var divID = o.argument;
		document.getElementById(divID).innerHTML = "<div class='noPrice'>" + getErrorPrice()+ "</div>";	
	}
	function SRsuccessPriceFunction(o)
	{
 
	    var divID =	o.argument;	 
	    try{
			var xmlDoc = o.responseText;	
			if(xmlDoc == null || xmlDoc.length == 0){
			   document.getElementById(divID).innerHTML = "<div class='noPrice'>" + getErrorPrice() + "</div>";	
			}else{
			
			//Coremetrics tags for Discontinued Product debug - Search Results Page
			if (window.location.href.indexOf('Lookup.do') >=0 && xmlDoc.indexOf('cm_sp=DiscontinuedProduct-_-TService') >=0) {
				cmCreatePageviewTag('PRODUCT: '+ cmBrandKey +' (' + cmProductNumber +')', 'SR_DEBUG');
			}	
			//End CM Tags			
					
				document.getElementById(divID).innerHTML = xmlDoc;				 
			}
		}
		catch(err)
		{		
		    document.getElementById(divID).innerHTML = "<div class='noPrice'>" + getErrorPrice() + "</div>";	
		} 
	}
	
	     
	function clickForPricing(){ 
	   window.location = "/webapp/wcs/stores/servlet/GetCountry?storeId=11001&langId=-1&refURL="+
	                   escape(location.href)
	} 
	
	
	function setupPending(divId){ 
		if(document.getElementById(divId))
			document.getElementById(divId).innerHTML = '<img src="' + getRedCubeImg() + '" >Loading Price & Availability Information</img>';
	}
 
	function getRedCubeImg(){
	    //return getContextPath()+ '/red_caube.gif';
	    return '/etc/medialib/sigma-aldrich/search/circular-progress0.Par.0001.Image.download.gif';
	 
	    
	}
				
	function getContextPath(){ 
        try{
            var contextPath= document.getElementById("contextPath");
	        return contextPath.value; 
	    }catch(err){
	      return '/catalog';
	    } 
    }
    
    function getErrorPrice() {
      try{        
	      var priceError= document.getElementById("priceError");
	      return priceError.value;
	  }catch(err){ 
	      return "no pricing";
	  }	   
	}
	
	function loadShRNAControlsPA(){
	   
	    if(document.getElementById('customizeControl')!=null)
	    	;// do nothing:  The user must press the "Calculate Price Button"
	    else
	    	loadShRNADNAControlsPA();
		
	}	
	// this is to get pricing for shDNA and shgly controls
	function loadShRNADNAControlsPA(){
	   
	    var catalog =  getContextPath();
		var url = catalog + '/PricingAvailability.do?loadFor=CONTROL&productList=';
		url=url+document.hiddenValues.productList.value;

		var postData = 'loadFor=CONTROL';				
//		if(document.getElementById('controlPriceHeader').innerHTML!='Price')
//			setupPendingForShRNAControlPricing();	
		var newCallback = new Object();
//		newCallback.success = trcDNAControlPricingSuccessFunction;
		newCallback.success = trcPrepackControlSuccessFunction;
		newCallback.failure = failurePriceFunction;
		newCallback.timeout = 50000;
		newCallback.argument = '1';	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
		var redCubeImg = "/etc/medialib/sigma-aldrich/search/circular-progress0.Par.0001.Image.download.gif";
		var pricingIndicatorToggler = new PricingIndicatorToggle(new Array('TRC_CONTROL_PRICE_LABEL'), '', '<img src='+redCubeImg+'>');
		pricingIndicatorToggler.togglePricingOn();
		
	}	
	
function successVRSControlPriceFunction(o){ 
		var htmlValue = o.responseText;	   
	    if(htmlValue==''|| htmlValue==null){
			document.getElementById('controlPriceHeader').innerHTML='<a href=\"javascript:clickForPricing()\">Click For Pricing</a>';
		}else{
			document.getElementById('controlPriceHeader').innerHTML='Price';
			
			if(htmlValue != null){
				var responseObj = eval( "(" + htmlValue + ")" );
				
				var priceData = responseObj.priceData;
				//var priceFromCache = responseObj.priceInCache;
				
				for(var i = 0; i < priceData.length; i++)
				{
					var priceObj = priceData[i];
				
					document.getElementById(priceObj.TRCControlPriceFieldId).innerHTML = priceObj.price;
				}
		
			}				 		
		
		}			 
	
}
	function setupPendingForShRNAControlPricing(){		
		document.getElementById('controlPriceHeader').innerHTML='<img src="' + getRedCubeImg() + '" >loading price</img>';			
	}
	
	function loadShRNAVRSControlPrice(){
		
	
		var catalog =  getContextPath();
		var url = catalog + '/ShRNAPricingAvailability.do?PRODUCT_TYPE=SHCONTROL'+getVRSControlPrcingAJAXCallURL();
		var postData = 'loadFor=CONTROL';						
		setupPendingForShRNAControlPricing();	
		var newCallback = new Object();
		newCallback.success = successVRSControlPriceFunction;
		newCallback.failure = failurePriceFunction;
		newCallback.timeout = 50000;
		newCallback.argument = '1';	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	
	function trcPrepackControlSuccessFunction(o)
	{
		var jsonValue = o.responseText;
		trcDNAControlPricingSuccessFunction(jsonValue);
	}
	
	function trcDNAControlPricingSuccessFunction(jsonValue)
	{
		//var htmlValue = o.responseText;
		var redCubeImg = "/etc/medialib/sigma-aldrich/search/circular-progress0.Par.0001.Image.download.gif";
		var pricingIndicatorToggler = new PricingIndicatorToggle(new Array('TRC_CONTROL_PRICE_LABEL'), '', '<img src='+redCubeImg+'>');
		pricingIndicatorToggler.togglePricingOff();
		if(jsonValue==''||jsonValue==null){
			document.getElementById('controlPriceHeader').innerHTML='<a href=\"javascript:clickForPricing()\">Click For Pricing</a>';
		}else{
			//document.getElementById('controlPriceHeader').innerHTML='Price';
			if(jsonValue != null){
				var responseObj = eval( "(" + jsonValue + ")" );
				currency = responseObj.currency;
				var priceLabel = "(" + currency + ")";
				if(document.getElementById('TRC_CONTROL_PRICE_LABEL')!=null)
					document.getElementById('TRC_CONTROL_PRICE_LABEL').innerHTML = priceLabel;
				var priceData = responseObj.priceData;
				for(var i = 0; i < priceData.length; i++)
				{
					var priceObj = priceData[i];
					document.getElementById(priceObj.TRCControlPriceFieldId).innerHTML = priceObj.price;
				}
				document.getElementById("pricingLoaded").value=1;
			}
		}
	}

	function submitMSDSSearchFromPA(country,language,productNumber)
	{
		document.MSDSSearchFromPA.country.value = country;
		document.MSDSSearchFromPA.language.value = language;
		document.MSDSSearchFromPA.productNumber.value = productNumber;
		document.MSDSSearchFromPA.submit();
	}
	
	function submitMSDSSearchFromSearchResults(country,language,productNumber,brand)
	{
		document.MSDSSearchFromSearchResults.country.value = country;
		document.MSDSSearchFromSearchResults.language.value = language;
		document.MSDSSearchFromSearchResults.productNumber.value = productNumber;
		document.MSDSSearchFromSearchResults.brand.value = brand;
		document.MSDSSearchFromSearchResults.submit();
	}
	
	//PricingAvailabilityclip.js
	
var baseName;
var x;
var y;

function isElScrollable()
{
  var contentHeight = document.getElementById(baseName + 'ItemContent').offsetHeight;
  var clipHeight = document.getElementById(baseName + 'ItemContainer').offsetHeight;
 if (baseName.indexOf('RNAI') > 0)
  {
  	return false;
  }
  else
  {
  	return (contentHeight > clipHeight);
  }
}

function setupEl(elBaseName)
{
  baseName = elBaseName;
  if (isElScrollable())
  {
    document.getElementById('ScrollUpContainer').style.width=document.getElementById(elBaseName + 'ItemContent').offsetWidth;
    document.getElementById('ScrollUpContainer').style.height='21px';
    document.getElementById('ScrollDownContainer').style.width=document.getElementById('ScrollUpContainer').style.width;
    document.getElementById('ScrollUpContainer').style.top=getElAbsY(elBaseName + 'Container')+'px';
    document.getElementById('ScrollUpContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.top=getElAbsY(elBaseName + 'Container')+document.getElementById('ScrollUpContainer').offsetHeight+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
    document.getElementById('ScrollDownContainer').style.top=getElAbsY(elBaseName + 'ItemContainer')+document.getElementById(elBaseName + 'ItemContainer').offsetHeight+'px';
    document.getElementById('ScrollDownContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
  }
  else
  {
  	document.getElementById(elBaseName + 'ItemContainer').style.top=getElAbsY(elBaseName + 'Container')+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.left=getElAbsX(elBaseName + 'Container')+40+'px';//-document.getElementById(elBaseName + 'Container').offsetWidth+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.height=document.getElementById(elBaseName + 'ItemContent').offsetHeight+'px';
	
  }
  y=0;
  document.getElementById(elBaseName + 'ItemContent').style.left="0px";
  document.getElementById(elBaseName + 'ItemContent').style.top="0px";
  showEl();
}

function hideElRNAI()
{
  if (baseName != undefined && document.getElementById('ScrollUpContainer') != null)
  {
  document.getElementById('ScrollUpContainer').style.visibility='hidden';
  document.getElementById('ScrollDownContainer').style.visibility='hidden';
  document.getElementById(baseName + 'ItemContainer').style.visibility='hidden';
  document.getElementById(baseName + 'ItemContent').style.visibility='hidden';
  }
}

function showLayer(layerName, shadowLayerName)
        {
            if (document.getElementById) // Netscape 6 and IE 5+
            {
                var targetElement = document.getElementById(layerName);
                var shadowElement = document.getElementById(shadowLayerName);
                targetElement.style.top = shadowElement.style.top;
                targetElement.style.visibility = 'visible';
            }
        }

function hideLayer(layerName)
        {
		
            if (document.getElementById)
            {
                var targetElement = document.getElementById(layerName);
                targetElement.style.visibility = 'hidden';
            }

            if (document.webcontentSearch != null)
            {
	document.webcontentSearch.N4.style.position='relative';
	document.webcontentSearch.N4.style.visibility='visible';
	document.SearchForm.Query.style.position='relative';
	document.SearchForm.Query.style.visibility='visible';
	document.getElementById('wcSearchImage').style.position='relative';
	document.getElementById('wcSearchImage').style.visibility='visible';
	}
        }

counter = 0;
 
function submitAddToCartProduct(brandkey, materialNumber)
{ 
	//setSessionCookie(); 
	var Qty =1;
	try{
		Qty = document.getElementById(materialNumber).value;
		 
		if (Qty == "")
		{
			Qty=1; 
		}
	}catch(ignore){} 	
	  
	var ProductAddToCart = 	document.getElementById('ProductAddToCartForm');	
	ProductAddToCart.Brand.value = brandkey;
	ProductAddToCart.ProdNo_0.value = materialNumber;
	ProductAddToCart.chkAdd0.value = materialNumber;
	ProductAddToCart.MatNo_0.value = "";
	ProductAddToCart.Qty_0.value = Qty;	 
	ProductAddToCart.URL.value = location.href;	 
	counter++;
	if(counter > 1) 
	{ 
		return false; 
	}
	ProductAddToCart.submit();
}
function submitAddToCartRNAI(brandkey, matNo)
{
	//setSessionCookie();

	var type = matNo.substring(0,matNo.indexOf("-"));
	var refSeq = matNo.substring(matNo.indexOf("-")+1);
	var DescField = "DescRNA"+refSeq;
	var RNAIAddToCart = 	document.getElementById('RNAIAddToCartForm');
	RNAIAddToCart.Brand.value = "SIGMA";
	RNAIAddToCart.ProdNo_0.value = refSeq;
	RNAIAddToCart.chkAdd0.value = refSeq;
	RNAIAddToCart.MatNo_0.value = type;
	
	var genedescription = document.getElementById(DescField).value;
	genedescription = genedescription.replace(/\+/g,' ');
	RNAIAddToCart.Desc.value = genedescription;

	var Qty = document.getElementById(matNo).value;
		
	if (Qty == "")
	{
		Qty=1;
	}		
	RNAIAddToCart.Qty_0.value = Qty;
	RNAIAddToCart.URL.value = location.href;
	RNAIAddToCart.submit();
}

function submitAddToShelfProduct(brandkey, productNumber, materialNumber)
{
	var Qty = document.getElementById(materialNumber).value;
	if (Qty == "")
	{
		Qty=1;
	}

	var descriptionField = "Desc"+materialNumber;
	var description = document.getElementById(descriptionField).value;	

	var ProductAddToShelf = document.getElementById('ProductAddToShelfForm');
	ProductAddToShelf.Desc.value = description;
	ProductAddToShelf.Brand.value = brandkey;
	ProductAddToShelf.ProdNo_0.value = materialNumber;
	ProductAddToShelf.chkAdd0.value = materialNumber;
	ProductAddToShelf.MatNo_0.value = "";
	ProductAddToShelf.Qty_0.value = Qty;
	var iof = location.href.indexOf("?");
	if (iof == -1)
		ProductAddToShelf.URL.value =  location.href + "?AddToFav=Search";
	else
		ProductAddToShelf.URL.value =  location.href + "&AddToFav=Search";

	counter++;
	if(counter > 1) 
	{ 
		return false; 
	} 
	ProductAddToShelf.submit();
}

function submitAddToShelfRNAI(brandkey, productNumber, materialNumber)
{
	var type = materialNumber.substring(0,materialNumber.indexOf("-"));
	var refseq = materialNumber.substring(materialNumber.indexOf("-")+1);
	var DescField = "DescRNA"+refseq;
	var genedescription = document.getElementById(DescField).value;
	genedescription = genedescription.replace(/\+/g,' ');
	//setSessionCookie();
	var Qty = document.getElementById(materialNumber).value;
	if (Qty == "")
	{
		Qty=1;
	}

    var RNAIAddToShelf = document.getElementById('RNAIAddToShelfForm');
	RNAIAddToShelf.Brand.value = "SIGMA";
	RNAIAddToShelf.ProdNo_0.value = refseq;
	RNAIAddToShelf.chkAdd0.value = refseq;
	RNAIAddToShelf.MatNo_0.value = type;
	RNAIAddToShelf.Qty_0.value = Qty;
	RNAIAddToShelf.Desc.value = genedescription;
	RNAIAddToShelf.URL.value =  location.href ;	

	counter++;
	if(counter > 1) 
	{ 
		return false; 
	}
	RNAIAddToShelf.submit();
	
}
function submitMsdsSearchRNAI(brandkey, materialNumber, country, language)
{
	var Matno = materialNumber.substring(0,materialNumber.indexOf("-"));

    var RNAImsdsSearch = document.getElementById('RNAImsdsSearchForm');
    
	RNAImsdsSearch.productNumber.value = Matno;
	RNAImsdsSearch.brand.value = brandkey;
	RNAImsdsSearch.country.value = country;
	RNAImsdsSearch.language.value = language;
	RNAImsdsSearch.submit();
}
 

function addProductItemsToCart()
{	
	var items = getSelectItems('SHCONTROL');
	if(items==''){
		alert('No item is selected to add to the shopping cart.');
		return;
	}
		
	
	var selectedItemsDivElement = document.getElementById('selectedControlItems');
	var inputHtml='';
	var itemsArray = items.split('*');	 
	for(i=0;i<itemsArray.length;i++){
		itemInfo = itemsArray[i];
		brandProdNo = itemInfo.split('|');
		var brand=brandProdNo[0];
		var prodNo = brandProdNo[1];
		inputHtml = inputHtml + '<input type="hidden" name="ProdNo_'+i+'" value="'+prodNo+'"/>';
		inputHtml = inputHtml + '<input type="hidden" name="Brand_'+i+'" value="'+brand+'"/>';	
		inputHtml = inputHtml + '<input type="hidden" name="chkAdd'+i+'" value="'+prodNo+'"/>';	
		inputHtml = inputHtml + '<input type="hidden" name="MatNo_'+i+'"/>';	
		inputHtml = inputHtml + '<input type="hidden" name="Qty_'+i+'" value="1" />';	
		
	}
	//alert(inputHtml);
	
	selectedItemsDivElement.innerHTML = inputHtml;
	
	var ProductAddToCart = 	document.getElementById('ProductAddToCartForm');	
		
	ProductAddToCart.URL.value = location.href+'&CONTROL_TAB=Y';	 		
	counter++;
	if(counter > 1) 
	{ 
		return false; 
	}
	ProductAddToCart.submit();
}
function getSelectItems(productType){
	//alert(productType);
	var form;
	if(productType == "SHCONTROL")
		form= document.controlform;
	else
		form = document.cloneform;
	
	var c_value = "";
	if(form.availableItem.length) // that is, there is more than 1 clone available for this gene
	{
		for (var i=0; i < form.availableItem.length; i++){
	    	if (form.availableItem[i].checked)
	    	{
	     		c_value = c_value + form.availableItem[i].value + "*";
	    	}
	  	}
   	}
   	else{
   		if(form.availableItem.checked){
   			c_value = form.availableItem.value;
   		}
   	}
	if (c_value.substring(c_value.length-1, c_value.length) == '*')
		c_value = c_value.substring(0,c_value.length-1);
	return c_value;	
}
function addToFavorite(productNumber, brand, materialNumber){
	var i=0;
	var inputHtml='';

	var selectedItemsDivElement = document.getElementById('selectedItemsToFavorite');
	var ProductAddToFavoriteForm = 	document.getElementById('ProductAddToFavoriteForm');
	
	inputHtml = inputHtml + '<input type="hidden" name="ProdNo_'+i+'" value="'+productNumber+'"/>';
	inputHtml = inputHtml + '<input type="hidden" name="Brand_'+i+'" value="'+brand+'"/>';
	inputHtml = inputHtml + '<input type="hidden" name="chkAdd'+i+'"/>';
	inputHtml = inputHtml + '<input type="hidden" name="MatNo_'+i+'"/>';
	inputHtml = inputHtml + '<input type="hidden" name="Qty_'+i+'" value="1" />';
	
	selectedItemsDivElement.innerHTML = inputHtml;
	ProductAddToFavoriteForm.URL.value = location.href;
	
	ProductAddToFavoriteForm.submit();
}
function addShRNAToCart(displayManager){
	
	var selectedItems = getSelectItems(displayManager.productType);	
	//alert(displayManager.productType);
	if(selectedItems==''){
		alert('No item is selected to add to the shopping cart.');
		return;
	}
	if(displayManager.validateConfigOptions() == false){
		viewConfigError(displayManager);
		return;
	}
	var catalog =  getContextPath();
	var redirectURL = window.location.href;
	var url = catalog + '/AddToCart.do';
	var postData = '?PRODUCT_TYPE=' + displayManager.productType;
	postData += '&selectedItems=' + selectedItems;
	postData += '&redirectURL=' + escape(redirectURL);
	postData += displayManager.getConfigData();	
	if(displayManager.productType=='SHCONTROL')	
		postData+= '&CONTROL_TAB=Y';
	if(document.getElementById('STAND_ALONE_CONTROL_CONFIG')!=null)
		postData+='&STAND_ALONE_CONTROL_CONFIG=Y';
	window.location.href=url+postData;		
}
function addShRNAToFavorite(trcNumber,brand,description,displayManager){

	if(trcNumber==''){
		alert('No item is selected to add in shopping cart.');
		return;
	}
	var catalog =  getContextPath();
	var redirectURL = window.location.href;
	var url = catalog + '/AddToFavorite.do';
	var postData = '?PRODUCT_TYPE=' + displayManager.productType;
	postData += '&selectedItems=' + trcNumber;
	postData += '&Brand=' + brand;
	postData += '&Desc=' + escape(description);
	postData += '&redirectURL=' + escape(redirectURL);
	postData += displayManager.getConfigData();
	window.location.href=url+postData;
}

function submitQuickOrder(productnumber, brandkey) {
	var ProductAddToQuickOrderForm = document.getElementById('ProductAddToQuickOrderForm');
	ProductAddToQuickOrderForm.ProdNo.value = productnumber;
	ProductAddToQuickOrderForm.Brand.value = brandkey; 
	ProductAddToQuickOrderForm.submit();
}

//ProductDetailUtility
// ProductDetailUtility.js
function askScientist(link){
	window.open(link,"AskAScientist",'resizable=yes,scrollbars=yes');
}

function internalProduct(link){
	window.open(link,"AskAScientist","height=500,width=780,scrollbars=yes,menubar=no,resizable=1,toolbar=no,status=no");
}

//layer1 if hidden make visible
//layer2 make hidden
//layer3 make visible
function toggleLayer(layer1,layer2,layer3 ){
	var layer1Obj = document.getElementById(layer1);
	var layer2Obj = document.getElementById(layer2);
	var layer3Obj = document.getElementById(layer3);
	
	if(layer1Obj.className == 'blockDiv'){
		layer1Obj.className = 'openDiv';
	}
	else{
		layer1Obj.className = 'blockDiv';
	}
	
	//layer2 hidden
	layer2Obj.className = 'blockDiv';
	
	//layer3 make visible
	layer3Obj.className = 'openDiv';
}


function nextTab(tabId_){
	 //tabs
	 var tabSpec = document.getElementById("specTab");
	 var tabRel = document.getElementById("relProdTab");
	 var tabRef = document.getElementById("refTab");
	 var tabRev = document.getElementById("revTab");
	 //div
	 var tabSpecDiv = document.getElementById("Specifications");
	 var tabCompDiv = document.getElementById("Components");
	 var tabRelDiv = document.getElementById("RelatedProducts");
	 var tabRefDiv = document.getElementById("References");
	 var tabRevDiv = document.getElementById("Reviews");
 		 
	 if(tabId_ == "specTab"){
 		 tabSpec.className = "tabSelected";
 		 //tabSpec.style.backgroundColor = "white";
 		 tabRel.className = "tabNotSelected";
 		 //tabRel.style.backgroundColor = "transparent";
 		 tabRef.className = "tabNotSelected";
		 if (tabRev != null)
	 		 tabRev.className = "tabNotSelected";
	 		 //tabRef.style.backgroundColor = "transparent";
	 		 //divs
	 		 tabSpecDiv.className = "openDiv";
	 		 tabCompDiv.className = "openDiv";
	 		 tabRelDiv.className = "blockDiv";
	 		 tabRefDiv.className = "blockDiv";
			 if (tabRev != null)
		 		 tabRevDiv.className = "blockDiv";
			 }
			 else if(tabId_ == "relProdTab"){
		 		 tabRel.className = "tabSelected";
		 		 //tabRel.style.backgroundColor = "white";
		 		 tabSpec.className = "tabNotSelected";
		 		 //tabSpec.style.backgroundColor = "transparent";
		 		 tabRef.className = "tabNotSelected";
				 if (tabRev != null)
			 		 tabRev.className = "tabNotSelected";
		 		 //tabRef.style.backgroundColor = "transparent";
		 		 //divs
		 		 tabSpecDiv.className = "blockDiv";
		 		 tabRelDiv.className = "openDiv";
		 		 tabRefDiv.className = "blockDiv";
				 if (tabRev != null)
			 		 tabRevDiv.className = "blockDiv";
		 	}
		 	else if(tabId_ == "refTab"){
		 		 tabRef.className = "tabSelected";
		 		 //tabRef.style.backgroundColor = "white";
		 		 tabRel.className = "tabNotSelected";
		 		 //tabRel.style.backgroundColor = "transparent";
		 		 tabSpec.className = "tabNotSelected";
				 if (tabRev != null)
			 		 tabRev.className = "tabNotSelected";
		 		 //tabSpec.style.backgroundColor = "transparent";
		 		 //divs
		 		 tabSpecDiv.className = "blockDiv";
		 		 tabRelDiv.className = "blockDiv";
		 		 tabRefDiv.className = "openDiv";
				 if (tabRev != null)
			 		 tabRevDiv.className = "blockDiv";
			 }
		 	else if(tabId_ == "revTab"){
				 if (tabRev != null)
			 		 tabRev.className = "tabSelected";
		 		 //tabRef.style.backgroundColor = "white";
		 		 tabRef.className = "tabNotSelected";
		 		 tabRel.className = "tabNotSelected";
		 		 //tabRel.style.backgroundColor = "transparent";
		 		 tabSpec.className = "tabNotSelected";
		 		 //tabSpec.style.backgroundColor = "transparent";
		 		 //divs
		 		 tabSpecDiv.className = "blockDiv";
		 		 tabRelDiv.className = "blockDiv";
				 if (tabRev != null)
			 		 tabRevDiv.className = "openDiv";
		 		 tabRefDiv.className = "blockDiv";
		 		 cmTagAndLink('Reviews','Product Detail Page', null, null, null);
	 }
		 
}

function nextTab3(tabId_,sorter){
		 //tabs
		 var tabSpec = document.getElementById("specTab");
		 var tabRel = document.getElementById("relProdTab");
		 var tabRef = document.getElementById("refTab");
		 var tabRev = document.getElementById("revTab");
		 //div
		 var tabSpecDiv = document.getElementById("Specifications");
		 var tabRelDiv = document.getElementById("RelatedProducts");
		 var tabRefDiv = document.getElementById("References");
		 var tabRevDiv = document.getElementById("Reviews");
		 		 
		 tabRel.className = "tabSelected";
		 
		 tabSpec.className = "tabNotSelected";
		 tabRef.className = "tabNotSelected";
		 if (tabRev != null)
			 tabRev.className = "tabNotSelected";
		 
		 tabSpecDiv.className = "blockDiv";
		 tabRelDiv.className = "openDiv";
		 tabRefDiv.className = "blockDiv";
		 if (tabRev != null)
			 tabRevDiv.className = "blockDiv";
		 var sort = document.getElementById('sortable');
		 sort.value=sorter;
		 ajaxAnywhere.submitAJAX();
		 		 
}

function closeErrorDialogBox(){
	
	cloneConfigErrorDialogBox = document.getElementById("confirmCloneConfigErrorDialog");
	controlConfigErrorDialogBox = document.getElementById("confirmControlConfigErrorDialog");
	if( cloneConfigErrorDialogBox!=null && cloneConfigErrorDialogBox.style.visibility=='visible'){
		closeConfigErrorViewer('confirmCloneConfigErrorDialog', displayManagerSHRNAClones);
	}
	if(controlConfigErrorDialogBox!=null && controlConfigErrorDialogBox.style.visibility=='visible'){
		closeConfigErrorViewer('confirmControlConfigErrorDialog', displayManagerSHRNAControls)
	}
}

function shRNANextTab(tabId_){
	//tabs
	var tabClones = document.getElementById("clonesTab");
	var tabControls = document.getElementById("controlsTab");
	var tabRel = document.getElementById("relProdTab");
	var tabRef = document.getElementById("refTab");
	//div
	var tabClonesDiv = document.getElementById("Clones");
	var tabControlsDiv = document.getElementById("Controls");
	var tabRelDiv = document.getElementById("RelatedProducts");
	var tabRefDiv = document.getElementById("References");
		
	if(tabId_ == "clonesTab"){
		tabClones.className = "tabSelected";
		tabControls.className = "tabNotSelected";
		tabRel.className = "tabNotSelected";
		if(tabRef != null){
			tabRef.className = "tabNotSelected";
		}
		//divs
		tabClonesDiv.className = "openDiv";
		tabControlsDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "blockDiv";
		
	}else if(tabId_ == "controlsTab"){
		tabControls.className = "tabSelected";
		tabRel.className = "tabNotSelected";
		tabClones.className = "tabNotSelected";
		if(tabRef != null){
			tabRef.className = "tabNotSelected";
		}
		//divs	
		tabClonesDiv.className = "blockDiv";
		tabControlsDiv.className = "openDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "blockDiv";		
						
		if(document.getElementById("pricingLoaded").value == 0){
			loadShRNAControlsPA();		
		}
	}
	else if(tabId_ == "relProdTab"){
		tabRel.className = "tabSelected";
		tabClones.className = "tabNotSelected";
		tabControls.className = "tabNotSelected";
		if(tabRef != null){
			tabRef.className = "tabNotSelected";
		}
		//divs
		tabControlsDiv.className = "blockDiv";
		tabClonesDiv.className = "blockDiv";
		tabRelDiv.className = "openDiv";
		tabRefDiv.className = "blockDiv";
	}
	else if(tabId_ == "refTab"){
		if(tabRef != null){
			tabRef.className = "tabSelected";
		}
		tabRel.className = "tabNotSelected";
		tabClones.className = "tabNotSelected";
		tabControls.className = "tabNotSelected";
		//divs
		tabClonesDiv.className = "blockDiv";
		tabControlsDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "openDiv";
	}
	currentFocusedTabId = tabId_;
}

var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
 	return{
	show:function(v,w){
		if(tt == null){
			tt = document.createElement('div');
			tt.setAttribute('id',id);
			t = document.createElement('div');
			t.setAttribute('id',id + 'top');
			c = document.createElement('div');
			c.setAttribute('id',id + 'cont');
			b = document.createElement('div');
			b.setAttribute('id',id + 'bot');
			tt.appendChild(t);
			tt.appendChild(c);
			tt.appendChild(b);
			document.body.appendChild(tt);
			tt.style.opacity = 1;
			tt.style.filter = 'alpha(opacity=100)';
			document.onmousemove = this.pos;
		}
	tt.style.display = 'block';
	c.innerHTML = v;
	tt.style.width = w ? w + 'px' : 'auto';
	if(!w && ie){
		t.style.display = 'none';
		b.style.display = 'none';
		tt.style.width = tt.offsetWidth;
		t.style.display = 'block';
		b.style.display = 'block';
	}
	if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
	h = parseInt(tt.offsetHeight) + top;
	clearInterval(tt.timer);
	tt.timer = setInterval(function(){tooltip.fade(1)},timer);
	},
	pos:function(e){
	
	// For IE6 compatibity - nick 22/08/2008 11:32
		var u = 0, l = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
			u = window.pageYOffset;
			l = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
			u = document.body.scrollTop;
			l = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
			u = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
		} 
		
		u = ie ? event.clientY + u : e.pageY;
		l = ie ? event.clientX + l : e.pageX;
		tt.style.top = (u - h) + 'px';
		tt.style.left = (l + left) + 'px';
	
	
		//var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
		//var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
		//tt.style.top = (u - h) + 'px';
		//tt.style.left = (l + left) + 'px';
	},
	fade:function(d){
		var a = alpha;
		if((a != endalpha && d == 1) || (a != 0 && d == -1)){
			var i = speed;
			if(endalpha - a < speed && d == 1){
				i = endalpha - a;
			}else if(alpha < speed && d == -1){
				i = a;
			}
			alpha = a + (i * d);
			tt.style.opacity = alpha * .01;
			tt.style.filter = 'alpha(opacity=' + alpha + ')';
		}else{
			clearInterval(tt.timer);
			if(d == -1){tt.style.display = 'none'}
		}
	},
	hide:function(){
		clearInterval(tt.timer);
		tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
	}
};
}();

//SearchResultsUtility.js
	
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
var horizontaloffset=1 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
	//alert("what :"+what);
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	//alert(parentEl);
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		//alert(totaloffset)
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}



function show(obj, visible, hidden){
	if (ie5||ns6){
		dropmenuobj.style.left=dropmenuobj.style.top=-500
	}
	obj.visibility=visible
}

function close(dropmenuID){
	dropmenuobj=document.getElementById(dropmenuID)
	dropmenuobj.style.visibility='hidden'
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
	var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+(horizontaloffset*2) //no space to the right of page? Move menu over to the left
	}
	else{
		var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight 
		//take care if footer is higher than window edge
		try{ 
			var footer = document.getElementById('footer');
			var footerTop =getposOffset(footer, "top");			 
			if(windowedge> footerTop){
			  windowedge = footerTop;
			}
		}catch(err){}
		var verticalOffset =90;
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure +verticalOffset){ //move menu up?
			
			edgeoffset =  dropmenuobj.contentmeasure + verticalOffset;			 
			if ((dropmenuobj.y-verticalOffset)<dropmenuobj.contentmeasure){//up no good either? (position at top of viewable window then)
				edgeoffset=dropmenuobj.y
			}			
			 	
		}
	}
	return edgeoffset
}

function dropdownmenu(idName, e, dropmenuID){
		 var left = 0;
		 var top = 0;
		 var bufferTop =-120;
		 var bufferLeft = 40;
		 if(idName == 'BioRefinement'){
		 		 bufferTop = -280;
		 }
		 //hide previous menu
		 if (typeof dropmenuobj!="undefined"){ 
		 		 dropmenuobj.style.visibility="hidden"
		 }

		 var obj = document.getElementById(idName) ;
		 dropmenuobj = document.getElementById(dropmenuID);
		 show(dropmenuobj.style, "visible", "hidden");

		 if(typeof(obj.offsetParent) != 'undefined'){
		 		 for(var xPos = 0,yPos = 0;obj;obj=obj.offsetParent){
		 		 		 xPos += obj.offsetLeft;
		 		 		 yPos += obj.offsetTop;
		 		 }
		 		 left = xPos;
		 		 top = yPos ;
		 }
		 else{
		 		 left = obj.x;
		 		 top = obj.y ;
		 }

		 dropmenuobj.style.left = left + bufferLeft;
		 var isMSIE = /*@cc_on!@*/false;
	      var isSafari = true;
		 if (navigator.userAgent.indexOf('Safari') != -1)
		 {
              isSafari = true;
		 }

		 if ((isMSIE == true || isSafari == true) && (idName.indexOf('refinement') >= 0 || idName.indexOf('SearchLanguage') >= 0))

		 {
		 		 dropmenuobj.style.left = '134px';
		 }

		 dropmenuobj.style.top = top + bufferTop ;
		 return clickreturnvalue();
}


function dropdownmenuFromPA(idName, e, dropmenuID)
{
	var u = 0, l = 0;
	if (e.pageX) {
	    l = e.pageX;
	}
	else if (e.clientX) {
		l = e.clientX + (document.documentElement.scrollLeft ?
		document.documentElement.scrollLeft :
		document.body.scrollLeft);
	}
	if (e.pageY) {
		u = e.pageY;
	}
	else if (e.clientY) {
		u = e.clientY + (document.documentElement.scrollTop ?
		document.documentElement.scrollTop :
		document.body.scrollTop);
	}

	var obj = document.getElementById(idName) ;
	dropmenuobj = document.getElementById(dropmenuID);
	show(dropmenuobj.style, "visible", "hidden");

	dropmenuobj.style.left = l+'px';
	dropmenuobj.style.top = (u-120)+'px';

	return clickreturnvalue();
}


function clickreturnvalue(){
	if ((ie5||ns6) && !enableanchorlink) return false
	else return true
}

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a){
		return true;
	}
	return false;
}

function submitRefinements(formName){
	var elem = document.getElementById(formName);
	var navDescriptors = 'N25=0';
	for (i=0; i<elem.refinementCheckbox.length; i++){
		if (elem.refinementCheckbox[i].checked==true){
			navDescriptors = navDescriptors + "+" + elem.refinementCheckbox[i].value;
		}
	}
	location.href=elem.link.value+ '&'+ navDescriptors;
}

function submitRefinements(formName, oldRefineNum){
	var elem = document.getElementById(formName);
	var navDescriptors = 'N25=' + oldRefineNum;
	for (i=0; i<elem.refinementCheckbox.length; i++){
		if (elem.refinementCheckbox[i].checked==true){
			navDescriptors = navDescriptors + "+" + elem.refinementCheckbox[i].value;
		}
	}
	location.href=elem.link.value+ '&'+ navDescriptors;
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function popup(windowname) {
	toggle(windowname);
}

function populateResults(){
	toggle('popUpDiv');
	var NewObj = document.getElementById('popUpDiv');
	NewObj.innerHTML = '<img src=\"' + getCatalogNameFromURL()+'/images/red_cube.gif\">';

    CreateRequest();
    var url = getCatalogNameFromURL()+ "/ViewAllPathways.do?VAP=X";
    request.open("GET", url, true);
    request.onreadystatechange=UpdatePage;
    request.send(null);
}

function CreateRequest(){
	try{
		request = new XMLHttpRequest();
	}
	catch(trymicrosoft){
		try{
			request = newActiveXObject("Msxml2.XMLHTTP");
		}
		catch(othermicrosoft){
			try{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(failed){
				request = null;
			}
     	}	
	}
}


function  UpdatePage(){
	if (request.readyState == 4){
		var NewData = request.responseText;
		var NewObj = document.getElementById('popUpDiv');
		NewObj.innerHTML = NewData;
		NewObj.style.display='';
	}
}

function submitSearch(){ 
	var searchterm = document.getElementById("N4").value;
	location.href="Lookup.do?D7=0&N3=matchpartialmax&N5=All&N25=0&N1=S_ID&ST=YFG&N4=" + searchterm + "&D10=" + searchterm;
}

function submitSort(var1, var2)
{
	var url = "";
	if(var1 != null && var1 != "")
		url = var2+'&N8='+var1;
	else
		url = var2;
	url = getCatalogNameFromURL() + "/Lookup.do"+url;
	location.href=url;
}
		
function displayRefinements()
{
	document.getElementById('moreRefinementLink').style.display = "none";
	document.getElementById('MoreRefinements').style.display = "block";
}

	function getCatalogNameFromURL(){
	    //use catalog as context path if failed
        var url = '/catalog';
        try{
			var path = location.pathname;
			 
			if(path.indexOf("/")==0){
				  var len = path.length;
				  path = path.substring(1, len);
			      
			      if(path.indexOf("/")>=0){
				        var index = path.indexOf("/");
				        url = "/" + path.substring(0,index);
			      }else{		      		
				     	url = "/" + path;
				  }
			}			
			  
	    }catch(err){}		
		return url;
    } 
    
/***********************************************
use the following script to display/hide tips when mouse over gene icon in search results page
***********************************************/

//var offsetxpoint=-60 //Customize x offset of tooltip
var offsetxpoint=-20 //Customize x offset of tooltip
//var offsetypoint=20 //Customize y offset of tooltip
var offsetypoint=-70 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
	if (ns6||ie){
	 //var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
	   var tipobj=  document.getElementById("dhtmltooltip");
	 	if (typeof thewidth!="undefined" && thewidth!=""){	 
		 tipobj.style.width=thewidth+"px"		
		} 
		if (typeof thecolor!="undefined" && thecolor!=""){
		 tipobj.style.backgroundColor=thecolor		 
		} 
		tipobj.innerHTML=thetext
		enabletip=true
		return false
	}
}

function positiontip(e){
	if (enabletip){		  
		var tipobj=  document.getElementById("dhtmltooltip");
		 
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		 
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
		
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px"
		
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
			tipobj.style.top=curY+offsetypoint+"px"
		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){	 
	if (ns6||ie){
	    var tipobj=  document.getElementById("dhtmltooltip");
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

document.onmousemove=positiontip    


function cmTagAndLink(var1, var2, var3, var4, url)
{
	if(var1 != null && var1 != "")
	{
		if(var1.length == 10 && var1.substring(0,7) == "Sort By")
		{
			if(document.getElementById("sortDropdown") != null)
			{
				if(document.getElementById("sortDropdown").value == null || document.getElementById("sortDropdown").value == "")
					var1 = "Sort By - Relevancy";
			} 
		}  
	}

	if(var3 == null && var4 == null)
	{
		cmCreatePageElementTag(var1, var2);
	}
	else
	{
		cmCreateManualPageviewTag(var1, var2, var3, var4);
	}
	if(url != null)
	{
		location.href = unescape(url);
	}
}

// Survey - Display Email
function surveyShowEmail(value){
	var emailOption = document.getElementById("emailOption");
	var emailTextbox = document.getElementById("emailTextbox");
	var yesBox = document.getElementById("yesCheckbox");
	var noBox = document.getElementById("noCheckbox");
	var errorMsg = document.getElementById("surveyErrorMsg");
	var errorMsg2 = document.getElementById("surveyErrorMsg2");
	errorMsg.style.display = 'none';
	errorMsg2.style.display = 'none';

	if(value == 'yes')
	{
		emailOption.style.display ='none';
		emailTextbox.style.display ='none';
		noBox.checked = false;
	}
	else if(value == 'no')
	{
		emailOption.style.display ='block';
		emailTextbox.style.display ='block';
		yesBox.checked = false;
	}
}

// Survey - Submit
function submitSurvey(query){
    CreateRequest();
	var comment = document.getElementById("surveyTextBox");
	var email = document.getElementById("emailBox").value;
	var checkYes = document.getElementById("yesCheckbox").checked;
	var checkNo = document.getElementById("noCheckbox").checked;
	var checkboxValue = "";
	if(checkYes == true)
		checkboxValue = "yes";
	else if(checkNo == true)
		checkboxValue = "no";
	var url = getCatalogNameFromURL()+ "/Survey.do?survey1=" + comment.value + "&survey2=" + query + "&survey3=" + email + "&survey4=" + checkboxValue;
	var errorMsg = document.getElementById("surveyErrorMsg");
	var errorMsg2 = document.getElementById("surveyErrorMsg2");
	if((comment == null || comment.value == "") || (checkYes == false && checkNo == false)){
		if(comment == null || comment.value == ""){
			errorMsg.style.display = 'block';
		}
		else
			errorMsg.style.display = 'none';
	
		if(checkYes == false && checkNo == false){
			errorMsg2.style.display = 'block';
		}
		else
			errorMsg2.style.display = 'none';
	}		
 	else {
 	    errorMsg.style.display = 'none';
		errorMsg2.style.display = 'none';
	    request.open("GET", url, true);
    	request.onreadystatechange=UpdatePageSurvey;
    	request.send(null);
	}
}

// Survey - Update
function UpdatePageSurvey(){
	if (request.readyState == 4){
		var question = document.getElementById("question");
		var surveyCheckbox = document.getElementById("surveyCheckbox");
		var question2 = document.getElementById("question2");
		var textarea = document.getElementById("textarea");
		var emailOption = document.getElementById("emailOption");
		var emailTextbox = document.getElementById("emailTextbox");
		var submitbutton = document.getElementById("submitbutton");
		question.innerHTML = "<br>";
		surveyCheckbox.innerHTML = "";
		question2.innerHTML = "";
		textarea.innerHTML = "<div id=\"thankyou\" class=\"pad2 margin3 fontBold\"><h2> Thank you for your comments!</h2></div>";
		emailOption.innerHTML = "";
		emailTextbox.innerHTML = "";
		submitbutton.innerHTML = "<br>";
	}
}

function typeaheadLink2(id){
	var queryN25 = getQueryVariable2("N25");
	withinChecked = document.getElementById("searchWithin").checked;

	if(withinChecked == true){
		if(id != "" && queryN25 != "" && queryN25 != "0")
		{
			if(queryN25.indexOf("%2B") >= 0)
				queryN25 = unescape(queryN25);
			queryN25 = queryN25 + "+" + id;
		}	
		else
			queryN25 = id;
	}		
	else
		queryN25 = id;
		
		var e=document.getElementsByName('searchResultsSearch');

		location.href = e[0].action + "?D7=" + document.searchResultsSearch.D7.value + "&F=" + document.searchResultsSearch.F.value + "&N25=" + queryN25 + "&N1=S_ID&ST=RS";

}

function submitResultsSearch(){
	var searchterm = document.searchResultsSearch.resultsN4.value;
	var queryN4 = getQueryVariable2("N4");
	var queryN25 = getQueryVariable2("N25");
	var queryN5 = getQueryVariable("N5");
	var withinChecked = document.getElementById("searchWithin").checked;
	
	if(searchterm == null || searchterm == ""){
		alert("Please enter a search string");
	}
	else {
		if(withinChecked == true){
			document.searchResultsSearch.N3.value = "mode+matchall";
			if(queryN25.indexOf("+") >= 0)
			{
				queryN25 = queryN25.replace("+"," ");
			}	
			
				queryN25 = decodeURI(queryN25);
			document.searchResultsSearch.N25.value = queryN25;
			if(searchterm != "" && queryN4 != "")
			{
				
				queryN4 = decodeURI(queryN4);
				queryN4 = unescape(queryN4);
				document.searchResultsSearch.D10.value = queryN4 + "+" + searchterm;
				document.searchResultsSearch.N4.value = queryN4 + "+" + searchterm;
			}
			else
			{
				document.searchResultsSearch.D10.value = searchterm;
				document.searchResultsSearch.N4.value = searchterm;
			}
		}		
		else
		{
			document.searchResultsSearch.D10.value = searchterm;
			document.searchResultsSearch.N4.value = searchterm;
		}				
		document.searchResultsSearch.N5.value=queryN5;
		document.searchResultsSearch.submit();

	}		
}

function getQueryVariable2(variable) { 
	var query = window.location.search.substring(1); 
	if(query.indexOf(variable) >= 0)
	{
		var vars = query.split("&"); 
		for (var i=0;i<vars.length;i++) { 
			var pair = vars[i].split("="); 
			if (pair[0] == variable) {
				return pair[1]; 
			} 
		} 
	}
	else
		return "";
} 


function showElement(ele){ 
  var d = document.getElementById(ele); 
  d.style.display ="";
}
 
function hideElement(ele){ 
  var d = document.getElementById(ele); 
  d.style.display ="none";
} 

function showAllGroups(parentName, tagName, groupName){
	var group = document.getElementById(parentName).getElementsByTagName(tagName);  
	for(i=0;i<group.length;i++) { 
		if(group[i].getAttribute('name')==groupName){
			 group[i].style.display = "";
		  	 	var substanceDivId = 'substance'+ (group[i].getAttribute('id')).substring(11);
		  	 	var	substanceGroupId = group[i].getAttribute('id');
		  	 	var imgurl = substanceGroupId + 'imghc';
		  	 	if (document.getElementById(imgurl) != null)
		  	 	{
		  	 		showCloseSubstanceGroup("0",substanceDivId,substanceGroupId,document.getElementById(imgurl).value);
		  	 	}
		  	 	document.getElementById("showAll").style.display="none";	 	
		  	 	document.getElementById("hideAll").style.display="";	 	
	   	 }
	}	
}

function hideAllGroups(parentName, tagName, groupName){
	var group = document.getElementById(parentName).getElementsByTagName(tagName);  
	for(i=0;i<group.length;i++) { 
		 if(group[i].getAttribute('name')==groupName){
	   		 group[i].style.display = "none";
	   	 }
   }	
	document.getElementById("hideAll").style.display="none";	 	
	document.getElementById("showAll").style.display="";	 	

}

//flag =1: show substance info group
//	   =0: close substance info group
function showCloseSubstanceGroup(flag, substanceDivId, substanceGroupId){
    var groupDiv = document.getElementById(substanceDivId);
	if(flag=='1'){
	    groupDiv.innerHTML = "<a onClick=\"showCloseSubstanceGroup('0','"+ substanceDivId +"','"+substanceGroupId+"'); hideElement(\'"+substanceGroupId+"\');\"><img src=\"/etc/medialib/sigma-aldrich/images/online-catalog/info.Par.0001.Image.gif\" style=\"vertical-align: bottom;\"></a>";
	}
	else{		
		groupDiv.innerHTML = "<a onClick=\"showCloseSubstanceGroup('1','"+ substanceDivId +"','"+substanceGroupId+"'); showElement(\'"+substanceGroupId+"\');cmTagAndLink('view one group details','Search Result Page Details',null,null,null);\"><img src=\"/etc/medialib/sigma-aldrich/images/online-catalog/info.Par.0001.Image.gif\" style=\"vertical-align: bottom;\"></a>";
  	}

    var imgurl = substanceGroupId + 'imghc';
    var url = '';
    
    if (document.getElementById(imgurl) != null)
	{
		url = document.getElementById(imgurl).value;  	
	}
  	var pExistingImageID = substanceGroupId+'img';
  	var img = document.createElement('img');
    img.onload = function (evt) {
        document.getElementById(pExistingImageID).src=this.src;
    }
    img.src = url;
    return false;
  	
}
function submitFormWithEnter(myfield,e)   
{
	var resultsN4 = document.getElementById('resultsN4').value;
	//if (resultsN4.length >= 2)
	//{
	//	if (document.getElementById('typeaheadTextNEW') != null && document.getElementById('lookaheadwait') != null)
    	//	{
	//		document.getElementById('typeaheadTextNEW').style.display='none';
	//		document.getElementById('lookaheadwait').style.display='block';
	//	}
	//}

	var keycode;   
	if (window.event)   
	{   
		keycode = window.event.keyCode;   
	}   
	else if (e)   
	{   
		keycode = e.which;   
	}   
	else  
	{   
		return true;   
	}   
	if (keycode == 13)   
	{
		submitResultsSearch();      
		return false;   
	}   
	else  
	{   
		return true;   
	}   
}   

//sort.js
// sguo 11/13/2208 fix odd/even row color issue
//show loading status while sort

function sortTable(id,col,rev,table) {
    var tblEl = document.getElementById(id);   
	sortTableOld(id, col,rev,table);
}  
  
//  id  - ID of the TABLE, TBODY, THEAD or TFOOT element to be sorted.
//  col - Index of the column to sort, 0 = first column, 1 = second column, etc.
//  rev - If true, the column is sorted in reverse (descending) order initially.
//  table - The table id number of the column being sorted
function sortTableOld(id, col,rev,table) {
 
  // Get the table or table section to sort.
  var tblEl = document.getElementById(id); 

   
  col = col -1;

  // The first time this function is called for a given table, set up an
  // array of reverse sort flags.
  if (tblEl.reverseSort == null) {
    tblEl.reverseSort = new Array();
  }

  // If this column has not been sorted before, set the initial sort direction.
  if (tblEl.reverseSort[col] == null){
    tblEl.reverseSort[col] = rev;
	//document.getElementById((col+1) + "sortArrowUp" + table).style.visibility="visible";
	//document.getElementById((col+1) + "sortArrowDown" + table).style.visibility="hidden";
  }

  // If this column was the last one sorted, reverse its sort direction.
  if (col == tblEl.lastColumn)
    tblEl.reverseSort[col] = !tblEl.reverseSort[col];

  // Remember this column as the last one sorted.
  tblEl.lastColumn = col;

  // Set the table display style to "none" - necessary for Netscape 6 
  // browsers.
  var oldDsply = tblEl.style.display;
  tblEl.style.display = "none";

  // Sort the rows based on the content of the specified column using a
  // selection sort.

  var tmpEl;
  var i, j;
  var minVal, minIdx;
  var testVal;
  var cmp;

  for (i = 0; i < tblEl.rows.length - 1; i++) {


    // Assume the current row has the minimum value.
    minIdx = i;
    minVal = getTextValue_old(tblEl.rows[i].cells[col]);

    // Search the rows that follow the current one for a smaller value.
    for (j = i + 1; j < tblEl.rows.length; j++) {

      testVal = getTextValue_old(tblEl.rows[j].cells[col]);
      cmp = compareValues(minVal, testVal);
      // Negate the comparison result if the reverse sort flag is set.
      if (tblEl.reverseSort[col])
        cmp = -cmp;
      // Sort by the second column if those values are equal.
      if (cmp == 0 && col != 1 && col!=0)
        cmp = compareValues(getTextValue_old(tblEl.rows[minIdx].cells[0]),
                            getTextValue_old(tblEl.rows[j].cells[0]));
      // If this row has a smaller value than the current minimum, remember its
      // position and update the current minimum value.
      if (cmp > 0) {
        minIdx = j;
        minVal = testVal;
      }
    }

    // By now, we have the row with the smallest value. Remove it from the
    // table and insert it before the current row.
    if (minIdx > i) {
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i]);
    }
  }


  // Make it look pretty.
  makePretty(tblEl, col);

  // Set team rankings.
  //setRanks(tblEl, col, rev);

  // Restore the table's display style.
   tblEl.style.display = oldDsply;

  return false;
}

 
//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------

// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
if (document.ELEMENT_NODE == null) {
  document.ELEMENT_NODE = 1;
  document.TEXT_NODE = 3;
}

//use value in abbr as primary sortkey, otherwise use value of TD
function getTextValue(el) {
  if(el.abbr !=null){
     return el.abbr;
  }else{
    //return getTextValue_old(el);
    return el.innerHTML;
  }
}

function getTextValue_old(el) {

  var i;
  var s;

	//9000545: use ef_sortkey if appliable:
	var sortkey = el.className;
	if(sortkey!=null && sortkey!="" && sortkey.indexOf('ef_sortkey')>=0){ 
		return normalizeString(sortkey);
	}

  // Find and concatenate the values of all text nodes contained within the
  // element.
  s = "";
  for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
      s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
             el.childNodes[i].tagName == "BR")
      s += " ";
    else
      // Use recursion to get text within sub-elements.
      s += getTextValue_old(el.childNodes[i]);

  return normalizeString(s);
}

function compareValues(v1, v2) {

  var f1, f2;

  // If the values are numeric, convert them to floats.

  f1 = parseFloat(v1);
  f2 = parseFloat(v2);
  if (!isNaN(f1) && !isNaN(f2)) {
    v1 = f1;
    v2 = f2;
  }

  // Compare the two values.
  if (v1 == v2)
    return 0;
  if (v1 > v2)
    return 1
  return -1;
}

// Regular expressions for normalizing white space.
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s) {

  s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.

  return s;
}

//-----------------------------------------------------------------------------
// Functions to update the table appearance after a sort.
//-----------------------------------------------------------------------------

// Style class names.
var rowClsNm = "evenRow";
var colClsNm = "sortedColumn";

// Regular expressions for setting class names.
var rowTest = new RegExp(rowClsNm, "gi");
var colTest = new RegExp(colClsNm, "gi");

function makePretty(tblEl, col) {

  var i, j;
  var rowEl, cellEl;

  // Set style classes on each row to alternate their appearance.
  for (i = 0; i < tblEl.rows.length; i++) {
   rowEl = tblEl.rows[i];
   rowEl.className = rowEl.className.replace(rowTest, "");
    if (i % 2 != 0)
      rowEl.className += " " + rowClsNm;
    rowEl.className = normalizeString(rowEl.className);
    // Set style classes on each column (other than the name column) to
    // highlight the one that was sorted.
    for (j = 2; j < tblEl.rows[i].cells.length; j++) {
      cellEl = rowEl.cells[j];
      cellEl.className = cellEl.className.replace(colTest, "");
      if (j == col)
        cellEl.className += " " + colClsNm;
      cellEl.className = normalizeString(cellEl.className);
    }
  }

  // Find the table header and highlight the column that was sorted.
  var el = tblEl.parentNode.tHead;
  rowEl = el.rows[el.rows.length - 1];
  // Set style classes for each column as above.
  for (i = 2; i < rowEl.cells.length; i++) {
    cellEl = rowEl.cells[i];
    cellEl.className = cellEl.className.replace(colTest, "");
    // Highlight the header of the sorted column.
    if (i == col)
      cellEl.className += " " + colClsNm;
      cellEl.className = normalizeString(cellEl.className);
  }
}

// Remember a column as the last one sorted.
function setLastColumn(id, col){ 

   col =col-1;
   var tblEl = document.getElementById(id); 
   if(tblEl !=null){
   		tblEl.value= col; 
   }
}

//this displays 3 sort arrows for OPC pages (none, up and down)
  
//  id  - ID of the TABLE, TBODY, THEAD or TFOOT element to be sorted.
//  col - Index of the column to sort, 0 = first column, 1 = second column, etc.
//  rev - If true, the column is sorted in reverse (descending) order initially.
//  table - The table id number of the column being sorted

function sortTableOPC(id,col,rev,table) { 
    var tblEl = document.getElementById(id); 
  if(tblEl == null){ 
  	return;
  }
  
  col = col -1;
 
  if(tblEl.lastColumn ==null){
     try{
	     var initSort = document.getElementById(table+"initSortCol");
	     if(initSort!=null &&initSort.value !=""){
	     	tblEl.lastColumn = parseInt(initSort.value); 
	     }
     }catch(err){}
  }
 
  // The first time this function is called for a given table, set up an
  // array of reverse sort flags.
  if (tblEl.reverseSort == null) {
    tblEl.reverseSort = new Array();
  }

  // If this column has not been sorted before, set the initial sort direction.
  if (tblEl.reverseSort[col] == null){
    tblEl.reverseSort[col] = rev;
	//document.getElementById((col+1) + "sortArrowUp" + table).style.display="";
	//document.getElementById((col+1) + "sortArrowDown" + table).style.display="none";
  }

  // If this column was the last one sorted, reverse its sort direction.
  if (col == tblEl.lastColumn)
    tblEl.reverseSort[col] = !tblEl.reverseSort[col];

  // Remember this column as the last one sorted.
  tblEl.lastColumn = col;

  // Set the table display style to "none" - necessary for Netscape 6 
  // browsers.
  var oldDsply = tblEl.style.display;
  tblEl.style.display = "none";

  // Sort the rows based on the content of the specified column using a
  // selection sort.

  var tmpEl;
  var i, j, k;
  var minVal, minIdx;
  var testVal;
  var cmp;

   var list = new Array();
   for (k = 0; k < tblEl.rows.length; k++) {
      list[k] = getTextValue_old(tblEl.rows[k].cells[col]); 
   }
     
  for (i = 0; i < tblEl.rows.length - 1; i++) {


    // Assume the current row has the minimum value.
    minIdx = i;
   // minVal = getTextValue_old(tblEl.rows[i].cells[col]);

	minVal = list[i];
	  
	  
    // Search the rows that follow the current one for a smaller value.
    for (j = i + 1; j < tblEl.rows.length; j++) {

     // testVal = getTextValue_old(tblEl.rows[j].cells[col]);
	  testVal = list[j];
 
      cmp = compareValues(minVal, testVal);
      // Negate the comparison result if the reverse sort flag is set.
      if (tblEl.reverseSort[col])
        cmp = -cmp;
       
      // If this row has a smaller value than the current minimum, remember its
      // position and update the current minimum value.
      if (cmp > 0) {
        minIdx = j;
        minVal = testVal;
        
        
      }
    }

    // By now, we have the row with the smallest value. Remove it from the
    // table and insert it before the current row.
    if (minIdx > i) {
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i]); 
      
      list.splice(minIdx, 1); 
      list.splice(i,0,minVal);
      
       
    }
  }


  // Make it look pretty.
  makePretty(tblEl, col);

  // Set team rankings.
  //setRanks(tblEl, col, rev);

  // Restore the table's display style.
   tblEl.style.display = oldDsply;

  //return false;
}

// Coremetrics - Copied from searchResultUtility.js for tablePage
function cmTagAndLink(var1, var2, var3, var4, url)
{
	if(var3 == null && var4 == null)
	{
		cmCreatePageElementTag(var1, var2);
	}
	else
	{
		cmCreateManualPageviewTag(var1, var2, var3, var4);
	}
	if(url != null)
	{
		location.href = unescape(url);
	}
}

//this sorts OPC table cintaining pricing rows
//assuming OPC table is: product row, pricing row, product row, pricing row...
//sort only every other row, ignore pricing rows, when reset order of product rows, move pricing rows as well

//this displays 3 sort arrows for OPC pages (none, up and down)  
//  id  - ID of the TABLE, TBODY, THEAD or TFOOT element to be sorted.
//  col - Index of the column to sort, 0 = first column, 1 = second column, etc.
//  rev - If true, the column is sorted in reverse (descending) order initially.
//  table - The table id number of the column being sorted

function sortTableOPCWithPricing(id,col,rev,table) { 
  
  var tblEl = document.getElementById(id); 
  if(tblEl == null){ 
  	return;
  }
  
  col = col -1;
 
  if(tblEl.lastColumn ==null){
     try{
	     var initSort = document.getElementById(table+"initSortCol");
	     if(initSort!=null &&initSort.value !=""){
	     	tblEl.lastColumn = parseInt(initSort.value); 
	     }
     }catch(err){}
  }
 
  // The first time this function is called for a given table, set up an
  // array of reverse sort flags.
  if (tblEl.reverseSort == null) {
    tblEl.reverseSort = new Array();
  }

  // If this column has not been sorted before, set the initial sort direction.
  if (tblEl.reverseSort[col] == null){
    tblEl.reverseSort[col] = rev;
	//document.getElementById((col+1) + "sortArrowUp" + table).style.display="";
	//document.getElementById((col+1) + "sortArrowDown" + table).style.display="none";
  }

  // If this column was the last one sorted, reverse its sort direction.
  if (col == tblEl.lastColumn)
    tblEl.reverseSort[col] = !tblEl.reverseSort[col];
 
  // Remember this column as the last one sorted.
  tblEl.lastColumn = col;

  // Set the table display style to "none" - necessary for Netscape 6 
  // browsers.
  var oldDsply = tblEl.style.display;
  tblEl.style.display = "none";

  // Sort the rows based on the content of the specified column using a
  // selection sort.

  var tmpEl;
  var i, j, k;
  var minVal, minIdx;
  var testVal;
  var cmp;
    
   var list = new Array();
	//ignore all pricing rows
   for (k = 0; k < tblEl.rows.length; k=k+2) {
      list[k] = getTextValue_old(tblEl.rows[k].cells[col]); 
      list[k+1]="";
   }
     
  for (i = 0; i < tblEl.rows.length - 1; i=i+2) {


    // Assume the current row has the minimum value.
    minIdx = i;
   // minVal = getTextValue_old(tblEl.rows[i].cells[col]);

	minVal = list[i];
	  
	  
    // Search every other rows that follow the current one for a smaller value.
    for (j = i + 2; j < tblEl.rows.length; j=j+2) {

     // testVal = getTextValue_old(tblEl.rows[j].cells[col]);
	  testVal = list[j];
 
      cmp = compareValues(minVal, testVal);
      // Negate the comparison result if the reverse sort flag is set.
      if (tblEl.reverseSort[col])
        cmp = -cmp;
       
      // If this row has a smaller value than the current minimum, remember its
      // position and update the current minimum value.
      if (cmp > 0) {
        minIdx = j;
        minVal = testVal;
        
        
      }
    }

    // By now, we have the row with the smallest value. Remove it from the
    // table and insert it before the current row.
    if (minIdx > i) {
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i]); 
      
      list.splice(minIdx, 1); 
      list.splice(i,0,minVal);
      
      //move pricing row as well
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx+1]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i+1]);  
      
      list.splice(minIdx, 1); 
      list.splice(i+1,0,"");             
    }
  }


  // Make it look pretty.
  makePretty(tblEl, col);

  //make different color for alternative rows but ignore all pricing rows (odd rows)
  makePrettyOPCWithPricing(tblEl, col);
  
  // Set team rankings.
  //setRanks(tblEl, col, rev);

  // Restore the table's display style.
   tblEl.style.display = oldDsply;

  //return false;
}

//make alternative color for rows, ignore all pricing rows (odd rows)
function makePrettyOPCWithPricing(tblEl, col) {

  var i, j;
  var rowEl, cellEl;

  // Set style classes on each row to alternate their appearance.
  for (i = 0; i < tblEl.rows.length; i++) {
   rowEl = tblEl.rows[i]; 
   
    if (i % 2 == 0){
        var j=i/2;
   
        if (j % 2 != 0){
      		rowEl.className= rowClsNm; 
      		
      	}else{
			rowEl.className= "";
      	}
     }
  } 
}

//tablepage.js
var sAuthor = "";
if (document.location.href.indexOf("author") != -1) {
   sAuthor = "/author";
   } 

if (document.location.href.indexOf("TablePage=8654203") != -1) {
	if (document.cookie.indexOf("country=JPN") != -1) {
	document.location.replace(sAuthor + "/technical-service-home/product-catalog-jp.html");
	} else { document.location.replace(sAuthor + "/technical-service-home/product-catalog.html");
	}
   } else if (document.location.href.indexOf("TablePage=16270507") != -1) {
	if (document.cookie.indexOf("country=JPN") != -1) {
	document.location.replace(sAuthor + "/chemistry/chemical-synthesis/chemical-synthesis-catalog-jp.html");
	} else { document.location.replace(sAuthor + "/chemistry/chemical-synthesis/chemical-synthesis-catalog.html");
	}
   } else if (document.location.href.indexOf("TablePage=12693646") != -1) {
	if (document.cookie.indexOf("country=JPN") != -1) {
	document.location.replace(sAuthor + "/analytical-chromatography/analytical-chromatography-catalog-jp.html");
	} else { document.location.replace(sAuthor + "/analytical-chromatography/analytical-chromatography-catalog.html");
	}
   } else if (document.location.href.indexOf("TablePage=9568654") != -1) {
	if (document.cookie.indexOf("country=JPN") != -1) {
	document.location.replace(sAuthor + "/labware/labware-catalog-jp.html");
	} else {document.location.replace(sAuthor + "/labware/labware-catalog.html");
	}
}

function getElAbsX(elName)
{
  el = document.getElementById(elName);
  x = -10;
  while (el != document.body && el!=null)
  {
    x += el.offsetLeft;
    el = el.offsetParent;
  }
  return x;
}

function getElAbsY(elName)
{
  el = document.getElementById(elName);
  y = 0;
  while (el != document.body && el!=null)
  {
    y += el.offsetTop;
    el = el.offsetParent;
  }
  return y;
}

var baseName;
var x;
var y;

function isElScrollable()
{
  var contentHeight = document.getElementById(baseName + 'ItemContent').offsetHeight;
  var clipHeight = document.getElementById(baseName + 'ItemContainer').offsetHeight;
  return (contentHeight > clipHeight);
}

function setupEl(elBaseName)
{
  baseName = elBaseName;
  if (isElScrollable())
  {
    document.getElementById('ScrollUpContainer').style.width=document.getElementById(elBaseName + 'ItemContent').offsetWidth;
    document.getElementById('ScrollUpContainer').style.height='21px';
    document.getElementById('ScrollDownContainer').style.width=document.getElementById('ScrollUpContainer').style.width;
    document.getElementById('ScrollUpContainer').style.top=getElAbsY(elBaseName + 'Container')+'px';
    document.getElementById('ScrollUpContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.top=getElAbsY(elBaseName + 'Container')+document.getElementById('ScrollUpContainer').offsetHeight+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
    document.getElementById('ScrollDownContainer').style.top=getElAbsY(elBaseName + 'ItemContainer')+document.getElementById(elBaseName + 'ItemContainer').offsetHeight+'px';
    document.getElementById('ScrollDownContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
  }
  else
  {
    document.getElementById(elBaseName + 'ItemContainer').style.top=getElAbsY(elBaseName + 'Container')+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.left=getElAbsX(elBaseName + 'Container')+document.getElementById(elBaseName + 'Container').offsetWidth+'px';
    document.getElementById(elBaseName + 'ItemContainer').style.height=document.getElementById(elBaseName + 'ItemContent').offsetHeight+'px';
  }
  y=0;
  document.getElementById(elBaseName + 'ItemContent').style.left="0px";
  document.getElementById(elBaseName + 'ItemContent').style.top="0px";
  showEl();
}

function hideEl()
{
if (document.getElementById('ScrollUpContainer') != null)
{
  document.getElementById('ScrollUpContainer').style.visibility='hidden';
  document.getElementById('ScrollDownContainer').style.visibility='hidden';
    
 if (baseName != undefined){
  	document.getElementById(baseName + 'ItemContainer').style.visibility='hidden';
  	document.getElementById(baseName + 'ItemContent').style.visibility='hidden';
  }
 }
}

function showEl()
{
  if (isElScrollable())
  {
    document.getElementById('ScrollUpContainer').style.visibility='visible';
    document.getElementById('ScrollDownContainer').style.visibility='visible';
  }
  if (baseName != undefined)
  { 
  	document.getElementById(baseName + 'ItemContainer').style.visibility='visible';
  	document.getElementById(baseName + 'ItemContent').style.visibility='visible';
  }
}

var speed=50;
var loop, timer;

function moveEl(move)
{
  y = move;
  document.getElementById(baseName + 'ItemContent').style.top = y;
}

function scrollUp(yinc)
{
  if(y<0){
    moveEl(y-yinc);
    if(loop)
      timer = setTimeout("scrollUp("+yinc+")",speed);
  }
}

function scrollDown(yinc)
{
  if(y>-document.getElementById(baseName + 'ItemContent').offsetHeight+document.getElementById(baseName + 'ItemContainer').offsetHeight){
    moveEl(y-yinc);
    if(loop)
      timer = setTimeout("scrollDown("+yinc+")",speed);
  }
}

function performScroll(yinc)
{
  loop=true;
  if(yinc>0)
    scrollDown(yinc);
  else
    scrollUp(yinc);
}

function scrollStop()
{
  loop=false;
  if(timer) clearTimeout(timer);
}

 
	function zoomImage(caption, imageURL)
	{
		
		if (caption != "")
		{
		caption = "    <" + "B" + ">Caption<" + "/B><" + "BR>\n" + caption;
		}
		var popupHtml = "<" + "HTML" + ">\n" +
	    				"<STYLE type=text/css> .printIcon {display: inline;cursor: pointer;background-image: url(\"/etc/medialib/sigma-aldrich/headers/endeca-search-and/print_icon.Par.0001.Image.gif\");width: 14px;height: 15px;}</STYLE>"+
	                    "<" + "BODY" + ">\n" + 
	                    "  <" + "STYLE type=text/css" + "><" + "!--\n" +
	                    "      .one { FONT: 11px/13px Arial, Helvetica, sans-serif }\n" +
	                    "      .normal { FONT: 13px/15px Arial, Helvetica, sans-serif }\n" +
	                    "  --" + ">" + "<" + "/STYLE" + ">\n" +
	                    "  <" + "DIV class=\"normal\"" + ">\n" + 
	                    "    <" + "SPAN style=\"color: red; font-weight: 900; font-size: 2em; line-height: 1.2em;\"" + ">" + "<" + "SPAN style=\"font-size: .8em; \"" + ">" + "<" + "SUP" + ">" + "&copy;" + "<" + "/SUP" + ">" + "<" + "/SPAN" + ">" + "www.sigma-aldrich.com" + "<" + "HR style=\"color: red; height: 4px;\"" + ">" + "<" + "/SPAN" + ">\n" + 
	                    "    <" + "BR" + ">\n" + 
	                    "    <" + "P align=center" + ">" + "<" + "IMG src=\"" + imageURL + "\"" + ">" + "<" + "/P" + ">\n" + 
	                    "<SPAN style=\"line-height: 1.4em;\">\n" + 
	                    "<DIV style=\"line-height: 1.6em;\">"+caption + "</DIV>"+
	                    "</SPAN>\n"+
	                    "<BR><BR><a href='#' onclick='window.print();'><DIV class=\"printIcon\"><!-- --></DIV><SPAN style=\"font-size: 11px;\">&nbsp;Print</SCAN></a>\n"+
	                    "  <" + "/DIV" + ">\n" + 
	                    "<" + "/BODY" + ">\n" + 
	                    "<" + "/HTML" + ">\n";
	    viewPopupPage('',650,680,'yes');
	    gPopupWin.document.open();
	    gPopupWin.document.write(popupHtml);
	    gPopupWin.document.close();
	}

function dropDownHandler(myform)
	{
		if (document.msdsSearch2 != null && document.msds != null)
		{
		    document.msdsSearch2.language.value = document.msds.languages.value;
		}
		else
		{

			if ( document.searchForm.searchprop.options[document.searchForm.searchprop.selectedIndex].value == 'RNAI' )
			{
		  		window.location.href ="/insite_mission_target_search";
			}
			else if ( document.searchForm.searchprop.options[document.searchForm.searchprop.selectedIndex].value == 'SIRNA' )
			{
    			   window.location.href ="/insite_your_favorite_gene_search";
			}
		}

		
    }    

function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13)
	{
		document.searchForm.refinementValue.value = 'ENTER';
    	document.searchForm.btnSearchFromCornerBox.click();
		return false;
	}
	else
	return true;
}
function printPreview()
{
    var loc = location.search;
    if (loc == "")
        loc += "?";
    else
        loc += "&";
    loc += "PrtPrv=20388431";
    if (typeof(imageLen) != "undefined" && imageLen != 0)
        loc += "&Img=" + imageNum;
      window.open(loc);
}

function redirectURL(url){
	document.cookie = "screenPosition=" + document.body.scrollTop + ";";
	window.location.href = url;
}

function checkAndSubmitAddToCartProduct(isCartShown, brandkey, materialNumber)
{ 
	if(isCartShown.toLowerCase() == 'false'){
	   window.location.href = '/webapp/wcs/stores/servlet/LogonForm?storeId=11001&langId=-1'; 
	}else{
	   submitAddToCartProduct(brandkey, materialNumber);
	}
}

function ClickHereToPrint(){
	var content=document.getElementById('ThePrintableContent').innerHTML;
  	var pwin=window.open('','print_content','width=800,height=800');
	pwin.document.open();
	pwin.document.write('<html>');
	pwin.document.write('<link media=\"all\" type=\"text/css\" href=\"/etc/medialib/sigma-aldrich/headers/endeca-search-and/searchcss.Par.0001.File.tmp/search.css\" rel=\"stylesheet\" />');
	pwin.document.write('<body onload="window.print()">'+content+'</body></html>');
	pwin.document.close();
 	setTimeout(function(){pwin.close();},1000);
	}

function showLotBox() {
	 document.getElementById('certAnalLotBoxOnSearchResults').style.display='block';
}

function showLotBox(certVar) {
	 document.getElementById(certVar).style.display='block';
}

function showHelpPage(shadowElement){
		var targetElement = document.getElementById("helpLinkDiv");
		var helpPageFrame = document.getElementById("helpPageFrame");	
		if(helpPageFrame.src =="" && document.getElementById) // Netscape 6 and IE 5+
		{
		helpPageFrame.src = "/sigma-aldrich/help/help-welcome/cofa-and-cofo/cofa-cofo.html";
		        var shadowElement = document.getElementById(shadowElement);
			if(shadowElement!=null){
				targetElement.style.top = shadowElement.offsetTop; 
			}				
			if (document.getElementById('certAnalLotBoxOnSearchResults') != null)
			{
				targetElement.style.top = document.getElementById('certAnalLotBoxOnSearchResults').offsetTop;
				targetElement.style.width = '580px';
				targetElement.style.left = '42000px';
			}
		               		
		}
		
		/*targetElement.style.visibility = 'visible';   
		if (document.webcontentSearch != null)
      		{
    		document.webcontentSearch.N4.style.visibility='hidden';
   		document.webcontentSearch.N4.style.position='absolute';
   		document.webcontentSearch.N4.style.zIndex='10001';
   		document.SearchForm.Query.style.visibility='hidden';
   		document.SearchForm.Query.style.position='absolute';
   		document.SearchForm.Query.style.zIndex='10001';
   		document.getElementById('wcSearchImage').style.visibility='hidden';
   		document.getElementById('wcSearchImage').style.position='absolute';
   		document.getElementById('wcSearchImage').style.zIndex='10001';
   		}*/
}

function relatedProds(tabId_){
	 //tabs
	 var tabSpec = document.getElementById("specTab");
	 var tabRel = document.getElementById("relProdTab");
	 var tabRef = document.getElementById("refTab");
	 var tabRev = document.getElementById("revTab");
	 //div
	 var tabSpecDiv = document.getElementById("Specifications");
	 var tabCompDiv = document.getElementById("Components");
	 var tabRelDiv = document.getElementById("RelatedProducts");
	 var tabRefDiv = document.getElementById("References");
 	 var tabRevDiv = document.getElementById("Reviews");
	 tabRel.className = "tabSelected";
	 tabSpec.className = "tabNotSelected";
	 tabRef.className = "tabNotSelected";
		 if (tabRev != null)
		   tabRev.className = "tabNotSelected";
		   tabSpecDiv.className = "blockDiv";
		   tabCompDiv.className = "blockDiv";
		   tabRelDiv.className = "openDiv";
		   tabRefDiv.className = "blockDiv";
		if (tabRev != null)
		 tabRevDiv.className = "blockDiv";
		ajaxAnywhere.formName = "main";
		ajaxAnywhere.submitAJAX();
}

function componentSort(sorter)
{
	var sort = document.getElementById('componentsort');
	sort.value=sorter;
	
	ajaxAnywhere.formName = "component";
	ajaxAnywhere.submitAJAX();
}


/*
Copyright 2005  Vitaliy Shevchuk (shevit@users.sourceforge.net)

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

*/

AjaxAnywhere.defaultInstanceName = "default";

// constructor;
function AjaxAnywhere() {

    this.id = AjaxAnywhere.defaultInstanceName;
    this.formName = null;
    this.notSupported = false;
    this.delayBeforeContentUpdate = true;
    this.delayInMillis = 100;

    if (window.XMLHttpRequest) {
        this.req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            this.req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                this.req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e1) {
                this.notSupported = true;
                /* XMLHTTPRequest not supported */
            }
        }
    }

    if (this.req == null || typeof this.req == "undefined")
        this.notSupported = true;
}

/**
* Stores substitutes SubmitButton names in to redo sustitution if a button was eventually inside a refresh zone.
*/
AjaxAnywhere.prototype.substitutedSubmitButtons = new Array();
AjaxAnywhere.prototype.substitutedSubmitButtonsInfo = new Object();

/**
* Returns a Form object that corresponds to formName property of this AjaxAnywhere class instance.
*/
AjaxAnywhere.prototype.findForm = function () {
    var form;
    if (this.formName != null)
        form = document.forms[this.formName];
    else if (document.forms.length > 0)
        form = document.forms[0];

    if (typeof form != "object")
        alert("AjaxAnywhere error: Form with name [" + this.formName + "] not found");
    return form;
}


/**
* Binds this instance to window object using "AjaxAnywhere."+this.id as a key.
*/
AjaxAnywhere.prototype.bindById = function () {
    var key = "AjaxAnywhere." + this.id;
    window[key] = this;
}

/**
* Finds an instance by id.
*/
AjaxAnywhere.findInstance = function(id) {
    var key = "AjaxAnywhere." + id;
    return window[key];
}

/**
* This function is used to submit all form fields by AJAX request to the server.
* If the form is submited with &lt;input type=submit|image&gt;, submitButton should be a reference to the DHTML object. Otherwise - undefined.
*/
AjaxAnywhere.prototype.submitAJAX = function(additionalPostData, submitButton) {

    if (this.notSupported)
        return this.onSubmitAjaxNotSupported(additionalPostData, submitButton);

    if (additionalPostData == null || typeof additionalPostData == "undefined")
        additionalPostData = "";

    this.bindById();

    var form = this.findForm();

    var actionAttrNode = form.attributes["action"];
    var url = actionAttrNode == null?null:actionAttrNode.nodeValue;
    if ((url == null) || (url == ""))
        url = location.href;

    var pos = url.indexOf("#");
        if (pos!=-1)
            url = url.substring(0,pos);
        if ((url == null) || (url == ""))
            url = location.href;
        pos = url.indexOf("#");
        if (pos!=-1)
            url = url.substring(0,pos);

    var zones = this.getZonesToReload(url, submitButton);

    if (zones == null) {
        // submit in tradiditional way :
        this.submitOld(form,submitButton)
        return;
    }

    this.dropPreviousRequest();

    this.req.open("POST", url, true);
    this.req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");

    var postData = this.preparePostData(submitButton);

    if (zones != "")
        postData = '&aazones=' + encodeURIComponent(zones) + "&" + postData + "&" + additionalPostData;
    else
        postData += "&" + additionalPostData;

    this.sendPreparedRequest(postData, form.name);

}
/**
* sends a GET request to the server.
*/
AjaxAnywhere.prototype.getAJAX = function(url, zonesToRefresh) {
    if (this.notSupported)
        return this.onGetAjaxNotSupported(url);

    this.bindById();

    if (zonesToRefresh == null || typeof zonesToRefresh == "undefined")
        zonesToRefresh = "";
    var urlDependentZones = this.getZonesToReload(url);
    if (urlDependentZones == null) {
        location.href = url;
        return;
    }

    if (urlDependentZones.length != 0)
        zonesToRefresh += "," + urlDependentZones;

    this.dropPreviousRequest();

    url += (url.indexOf("?") != -1) ? "&" : "?";

    url += "aaxmlrequest=true&aa_rand=" + Math.random();
    // avoid caching

    if (zonesToRefresh != null && zonesToRefresh != "")
        url += '&aazones=' + encodeURIComponent(zonesToRefresh);

    this.req.open("GET", url, true);

    this.sendPreparedRequest("","");
}

/**
* @private
*/
AjaxAnywhere.prototype.sendPreparedRequest = function (postData, formName) {
    this.req.setRequestHeader("Accept", "text/xml");

    var callbackKey = this.id + "_callbackFunction";
    if (typeof window[callbackKey] == "undefined")
        window[callbackKey] = new Function("AjaxAnywhere.findInstance(\"" + this.id + "\").callback(); ");
    this.req.onreadystatechange = window[callbackKey];

    this.showLoadingMessage(formName);

    this.req.send(postData);

    this.onRequestSent();
}
/**
* Used internally by AjaxAnywhere. Aborts previous request if not completed.
*/
AjaxAnywhere.prototype.dropPreviousRequest = function() {
    if (this.req.readyState != 0 && this.req.readyState != 4) {
        // abort previous request if not completed
        this.req.abort();
        
    }
}

/**
* Internally used to prepare Post data.
* If the form is submited with &lt;input type=submit|image&gt;, submitButton is a reference to the DHTML object. Otherwise - undefined.
*/
AjaxAnywhere.prototype.preparePostData = function(submitButton) {
    var form = this.findForm();
    var result = "&aaxmlrequest=true";
    for (var i = 0; i < form.elements.length; i++) {
        var el = form.elements[i];
        if (el.tagName.toLowerCase() == "select") {
            for (var j = 0; j < el.options.length; j++) {
                var op = el.options[j];
                if (op.selected)
                    result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(op.value);
            }
        } else if (el.tagName.toLowerCase() == "textarea") {
            result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
        } else if (el.tagName.toLowerCase() == "input") {
            if (el.type.toLowerCase() == "checkbox" || el.type.toLowerCase() == "radio") {
                if (el.checked)
                    result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
            } else if (el.type.toLowerCase() == "submit") {
                if (el == submitButton) // is "el" the submit button that fired the form submit?
                    result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
            } else if (el.type.toLowerCase() != "button") {
                result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
            }
        }
    }
    if (typeof submitButton != 'undefined' && submitButton != null && submitButton.type.toLowerCase() == "image") {
        if (submitButton.name == null || submitButton.name == "" || typeof submitButton.name == "undefined")
            result += "&x=1&y=1"; // .x and .y coordinates calculation is not supported.
        else
            result += "&" + encodeURIComponent(submitButton.name) + ".x=1&" +
                      encodeURIComponent(submitButton.name) + ".y=1";
    }
    return result;
}

/**
* Pauses the thread of execution for the specified number of milliseconds
* @private
*/
function delay(millis) {
    date = new Date();
    var curDate = null;
    do {
        curDate = new Date();
    }
    while (curDate - date < millis);
}

/**
* A callback. internally used
*/
AjaxAnywhere.prototype.callback = function() {

    if (this.req.readyState == 4) {

        this.onBeforeResponseProcessing();
        this.hideLoadingMessage();

        if (this.req.status == 200) {

            if (this.req.getResponseHeader('content-type').toLowerCase().substring(0, 8) != 'text/xml')
                alert("AjaxAnywhere error : content-type in not text/xml : [" + this.req.getResponseHeader('content-type') + "]");

            var docs = this.req.responseXML.getElementsByTagName("document");
            var redirects = this.req.responseXML.getElementsByTagName("redirect");
            var zones = this.req.responseXML.getElementsByTagName("zone");
            var exceptions = this.req.responseXML.getElementsByTagName("exception");
            var scripts = this.req.responseXML.getElementsByTagName("script");
            var images = this.req.responseXML.getElementsByTagName("image");

            if (redirects.length != 0) {
                var newURL = redirects[0].firstChild.data;
                location.href = newURL;
            }
            if (docs.length != 0) {
                var newContent = docs[0].firstChild.data;

                //cleanup ressources
                delete this.req;

                document.close();
                document.write(newContent);
                document.close();
            }

            if (images.length != 0) {
                var preLoad = new Array(images.length);
                for (var i = 0; i < images.length; i++) {
                    var img = images[i].firstChild;
                    if (img != null) {
                        preLoad[i] = new Image();
                        preLoad[i].src = img.data;
                    }
                }
                if (this.delayBeforeContentUpdate) {
                    delay(this.delayInMillis);
                }
            }

            if (zones.length != 0) {
                for (var i = 0; i < zones.length; i++) {
                    var zoneNode = zones[i];

                    var name = zoneNode.getAttribute("name");
                    var id = zoneNode.getAttribute("id");

                    var html = "";

                    for (var childIndex = 0; childIndex < zoneNode.childNodes.length; childIndex++) {
                        html += zoneNode.childNodes[childIndex].data
                    }

                    var zoneHolder = name!=null?
                                     document.getElementById("aazone." + name):
                                     document.getElementById(id);

                    if (zoneHolder != null && typeof(zoneHolder) != "undefined") {
                        zoneHolder.innerHTML = html;
                    }

                }
            }
            if (exceptions.length != 0) {
                var e = exceptions[0];
                var type = e.getAttribute("type");
                var stackTrace = e.firstChild.data;
                this.handleException(type, stackTrace);
            }

            if (scripts.length != 0) {
                for (var $$$$i = 0; $$$$i < scripts.length; $$$$i++) {
                    // use $$$$i variable to avoid collision with "i" inside user script
                    var script = scripts[$$$$i].firstChild;
                    if (script != null) {
                        script = script.data;
                        if (script.indexOf("document.write") != -1) {
                            this.handleException("document.write", "This script contains document.write(), which is not compatible with AjaxAnywhere : \n\n" + script);
                        } else {

                            eval("var aaInstanceId = \""+this.id+"\"; \n"+script);
                        }
                    }
                }

                var globals = this.getGlobalScriptsDeclarationsList(script);
                if (globals != null)
                    for (var i in globals) {
                        var objName = globals[i];
                        try {
                            window[objName] = eval(objName);
                        } catch(e) {
                        }
                    }
            }

        } else {
            if (this.req.status != 0)
                this.handleHttpErrorCode(this.req.status);
        }
        this.restoreSubstitutedSubmitButtons();
        this.onAfterResponseProcessing();

    }


}

/**
*  Default sample loading message show function. Overrride it if you like.
*/
AjaxAnywhere.prototype.showLoadingMessage = function(formName) {

    if (formName == 'main')
   {
    
   
    	var div = document.getElementById("AAWaitRelated");
    
   
   
    //if (div == null) {
    //    div = document.createElement("DIV");

      //  document.body.appendChild(div);
       //div.id = "AA_" + this.id + "_loading_div";

	      div.innerHTML = '<img src=\"/etc/medialib/sigma-aldrich/search/circular-progress0.Par.0001.Image.download.gif\" ></img> Loading...<br><BR>';
	   
	    	
	    	
        div.style.position = "absolute";
    //    div.style.border = "1 solid black";
    //    div.style.color = "white";
    //    div.style.backgroundColor = "blue";
    //    div.style.width = "100px";
    //    div.style.heigth = "50px";
    //    div.style.fontFamily = "Arial, Helvetica, sans-serif";
    //    div.style.fontWeight = "bold";
    //    div.style.fontSize = "11px";
   //}
    //div.style.top = document.body.scrollTop + "px";
    //div.style.left = (document.body.offsetWidth - 100 - (document.all?20:0)) + "px";

    div.style.display = "";
    }
}

/**
*  Default sample loading message hide function. Overrride it if you like.
*/
AjaxAnywhere.prototype.hideLoadingMessage = function() {
    var div = document.getElementById("AAWaitRelated");
    if (div != null)
        div.style.display = "none";
}

/**
* This function is used to facilitatte AjaxAnywhere integration with existing projects/frameworks.
* It substitutes default Form.sumbit().
* The new implementation calls AjaxAnywhere.isFormSubmitByAjax() function to find out if the form
* should be submitted in traditional way or by AjaxAnywhere.
*/
AjaxAnywhere.prototype.substituteFormSubmitFunction = function() {
    if (this.notSupported)
        return;

    this.bindById();

    var form = this.findForm();

    form.submit_old = form.submit;
    var code = "var ajax = AjaxAnywhere.findInstance(\"" + this.id + "\"); " +
               "if (typeof ajax !='object' || ! ajax.isFormSubmitByAjax() ) " +
               "ajax.findForm().submit_old();" +
               " else " +
               "ajax.submitAJAX();"
    form.submit = new Function(code);

}
/**
* Substitutes the default behavior of &lt;input type=submit|image&gt; to submit the form via AjaxAnywhere.
*
* @param {boolean} indicates if existing onClick handlers should be preserved.
* If keepExistingOnClickHandler==true,
* Existing handler will be called first if it returns false, or if event.returnValue==false, AjaxAnywhere will not
* continue form submission.
* If keepExistingOnClickHandler==false or undefines, existing onClick event handlers will be replaced.
*
* @param {Array} list of submitButtons and submitImages names. If the parameter is omitted or undefined,
* all elements will be processed
*/
AjaxAnywhere.prototype.substituteSubmitButtonsBehavior = function (keepExistingOnClickHandler, elements) {
    if (this.notSupported)
        return;

    var form = this.findForm();
    if (elements == null || typeof elements == "undefined") { // process all elements
        elements = new Array();
        for (var i = 0; i < form.elements.length; i++) {
            elements.push(form.elements[i]);
        }

        var inputs = document.getElementsByTagName("input");
        for (var i = 0; i < inputs.length; i++) {
            var input = inputs[i];
            if (input.type != null && typeof input.type != "undefined" &&
                input.type.toLowerCase() == "image" && input.form == form) {
                elements.push(input);
            }
        }

        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (el.tagName.toLowerCase() == "input" && (el.type.toLowerCase() == "submit"
                    || el.type.toLowerCase() == "image")) {
                this.substituteSubmitBehavior(el, keepExistingOnClickHandler);

            }
        }
    } else { //process only specified elements
        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (el == null)
                continue;

            if (typeof el != "object")
                el = form.elements[el];

            if (typeof el != "undefined") {
                if (el.tagName.toLowerCase() == "input" && (el.type.toLowerCase() == "submit"
                        || el.type.toLowerCase() == "image"))
                    this.substituteSubmitBehavior(el, keepExistingOnClickHandler);
            }
        }
    }

}
/**
* Performs a single element behavior substitution
*
* @private
*/
AjaxAnywhere.prototype.substituteSubmitBehavior = function (el, keepExistingOnClickHandler) {

    var inList = false;
    for (var i = 0; i < this.substitutedSubmitButtons.length; i++) {
        var btnName = this.substitutedSubmitButtons[i];
        if (btnName == el.name) {
            inList = true;
            break;
        }
    }
    if (!inList)
        this.substitutedSubmitButtons.push(el.name);

    this.substitutedSubmitButtonsInfo[el.name] = keepExistingOnClickHandler;

    if (keepExistingOnClickHandler && (typeof el.onclick != "undefined") && ( el.onclick != null) && ( el.onclick != "")) {
        el.AA_old_onclick = el.onclick;
    }

    el.onclick = handleSubmitButtonClick;
    el.ajaxAnywhereId = this.id;
}

/**
*
* @private
*/
AjaxAnywhere.prototype.restoreSubstitutedSubmitButtons = function() {
    if (this.substitutedSubmitButtons.length == 0)
        return;

    var form = this.findForm();

    for (var i = 0; i < this.substitutedSubmitButtons.length; i++) {
        var name = this.substitutedSubmitButtons[i];
        var el = form.elements[name];
        if (el != null && typeof el != "undefined") {
            if (el.onclick != handleSubmitButtonClick) {
                var keepExistingOnClickHandler = this.substitutedSubmitButtonsInfo[el.name];
                this.substituteSubmitBehavior(el, keepExistingOnClickHandler);
            }
        } else {
            //input type=image
            if (name != null && typeof name != "undefined" && name.length != 0) {
                var elements = document.getElementsByName(name);
                if (elements != null)
                    for (var j = 0; j < elements.length; j++) {
                        el = elements[j];
                        if (el != null && typeof el != "undefined"
                                && el.tagName.toLowerCase() == "input"
                                && typeof el.type != "undefined" && el.type.toLowerCase() == "image") {
                            if (el.onclick != handleSubmitButtonClick) {
                                var keepExistingOnClickHandler = this.substitutedSubmitButtonsInfo[el.name];
                                this.substituteSubmitBehavior(el, keepExistingOnClickHandler);
                            }
                        }
                    }
            }
        }
    }
}

/**
* @private
*/
function handleSubmitButtonClick(_event) {

    if (typeof this.AA_old_onclick != "undefined") {
        if (false == this.AA_old_onclick(_event))
            return false;
        if (typeof window.event != "undefined")
            if (window.event.returnValue == false)
                return false;
    }
    var onsubmit = this.form.onsubmit;
    if (typeof onsubmit == "function") {
        if (false == onsubmit(_event))
            return false;
        if (typeof window.event != "undefined")
            if (window.event.returnValue == false)
                return false;
    }
    AjaxAnywhere.findInstance(this.ajaxAnywhereId).submitAJAX('', this);

    return false;
}
/**
* Override this function if you use AjaxAnywhere.substituteFormSubmitFunction() to
* dynamically inform AjaxAnywhere of the method you want to use for the form submission.
*/
AjaxAnywhere.prototype.isFormSubmitByAjax = function () {
    return true;
}

/**
* Some browsers (notably IE) do not load images from thier cache when content is updated using
* innerHTML. As a result, each image is re-requested from the server even though the image exists
* in the cache. To work around this issue, AjaxAnywhere preloads images present in the new content
* and intrduces a brief dely (default of 100 milleseconds) before calling innerHTML.
* See http://support.microsoft.com/default.aspx?scid=kb;en-us;319546 for further details.
* This function can be used to change this behaviour.
* @param (boolean) isDelay
*/
AjaxAnywhere.prototype.setDelayBeforeLoad = function (isDelay) {
    this.delayBeforeContentUpdate = isDelay;
}

/**
* Returns the current delay behavior.
*/
AjaxAnywhere.prototype.isDelayBeforeLoad = function () {
    return this.delayBeforeContentUpdate;
}

/**
* Sets the delay period in milliseconds. The default delay is 100 milliseconds.
* @param (int) delayMillis
*/
AjaxAnywhere.prototype.setDelayTime = function (delayMillis) {
    this.delayInMillis = delayMillis;
}

/**
* Returns the delay period in milliseconds.
*/
AjaxAnywhere.prototype.getDelayTime = function () {
    return this.delayInMillis;
}

/**
*   If an exception is throws on the server-side during AJAX request, it will be processed
* by this function. The default implementation is alert(stackTrace);
* Override it if you need.
*/
AjaxAnywhere.prototype.handleException = function(type, details) {
    alert(details);
}
/**
*   If an HTTP Error code returned during AJAX request, it will be processed
* by this function. The default implementation is alert(code);
* Override it if you need.
*/
AjaxAnywhere.prototype.handleHttpErrorCode = function(code) {
    var details = confirm("AjaxAnywhere default error handler. XMLHttpRequest HTTP Error code:" + code + " \n\n Would you like to view the response content in a new window?");
    if (details) {
        var win = window.open("", this.id + "_debug_window");
        if (win != null) {
            win.document.write("<html><body><xmp>" + this.req.responseText);
            win.document.close();
            win.focus();
        } else {
            alert("Please, disable your pop-up blocker for this site first.");
        }
    }
}

/**
* Override it if you need.
*/

/**
*   If the HTML received in responce to AJAX request contains JavaScript that defines new
* functions/variables, they must be propagated to the proper context. Override this method
* to return the Array of function/variable names.
*/
AjaxAnywhere.prototype.getGlobalScriptsDeclarationsList = function(script) {
    return null;
}

/**
* This function should be overridden by AjaxAnywhere user to implement client-side
* determination of zones to reload.
*
* If the form is submited with &lt;input type=submit|image&gt;, submitButton is a reference to the DHTML object. Otherwise - undefined.
*
* @Returns a comma separated list of zones to reload, or "document.all" to reload
* the whole page. Returns null if the request must be sent in traditional way
*
*/
AjaxAnywhere.prototype.getZonesToReload = function(url, submitButton) {
    return this.getZonesToReaload();
    // backward compatibility only
}
/**
* depreceted : wrond spelling : Reaload will be removed in later versions
*/
AjaxAnywhere.prototype.getZonesToReaload = function(url, submitButton) {
    return "";
}

/**
* Override this method to implement a custom action
*/
AjaxAnywhere.prototype.onRequestSent = function () {
};
/**
* Override this method to implement a custom action
*/
AjaxAnywhere.prototype.onBeforeResponseProcessing = function () {
};
/**
* Override this method to implement a custom action
*/
AjaxAnywhere.prototype.onAfterResponseProcessing = function () {
};

/**
* Provides a default implementation from graceful degradation for getAJAX()
* calls location.href=url if XMLHttpRequest is unavailable, reloading the entire page .
*/
AjaxAnywhere.prototype.onGetAjaxNotSupported = function (url) {
    location.href = url;
    return false;
};

/**
* Provides a default implementation from graceful degradation for submitAJAX()
* calls form.submit() if XMLHttpRequest is unavailable, reloading the entire page
*/
AjaxAnywhere.prototype.onSubmitAjaxNotSupported = function (additionalPostData, submitButton) {
    var form = this.findForm();

    var actionAttrNode = form.attributes["action"];
    var url = actionAttrNode == null?null:actionAttrNode.nodeValue;
    var url_backup = url;
    if (typeof additionalPostData != 'undefined' && additionalPostData != null) {
        url += (url.indexOf("?") != -1) ? "&" : "?";
        url += additionalPostData;
        form.attributes["action"].nodeValue= url;
        // only POST method allows sending additional
        // date by altering form action URL.
        form.setAttribute("method", "post");
    }

    this.submitOld(form,submitButton);

    form.attributes["action"].nodeValue= url_backup;
    return false;
};
/**
* submit the form in tradiditional way :
* @private
*/

AjaxAnywhere.prototype.submitOld = function (form,submitButton){
    var submitHolder = null;
    if (submitButton!=null && typeof submitButton!="undefined"){
        submitHolder = document.createElement("input");
        submitHolder.setAttribute("type","hidden");
        submitHolder.setAttribute("name",submitButton.name);
        submitHolder.setAttribute("value",submitButton.value);
        form.appendChild(submitHolder);

    }

    if (typeof form.submit_old == "undefined")
        form.submit();
    else
        form.submit_old();

    if (submitButton!=null ){
        form.removeChild(submitHolder);
    }
}

// default instance.
ajaxAnywhere = new AjaxAnywhere();
ajaxAnywhere.bindById();

function submitRegSearch(){ 
	var searchterm = document.regularSearch.N4.value;
	if(searchterm == null || searchterm == ""){
		alert("Please enter a search string");
	}
	else {
		document.regularSearch.D10.value = searchterm;
	 	document.regularSearch.submit();
	}		 	
}

function submitDocumentSearch(){
    var searchterm = document.webcontentSearch.N4.value;
	if(searchterm == null || searchterm == ""){
		alert("Please enter a search string");
	}
	else {
	document.webcontentSearch.D10.value = searchterm;
 	document.webcontentSearch.submit();
	}	
}

//Added for CD 9008263
var msdsCMEnabled = 1;

function submitMSDSSearch(){
                  if (document.msds != null && document.msds.languages != null && document.msds.languages.value != null)
    {
	document.msdsSearch2.language.value = document.msds.languages.value;
    }	
    var ProdNo=document.msds.ProductNumber.value;
    ProdNo=ProdNo.replace(/ /g, "");
    ProdNo=ProdNo.toUpperCase();
    document.msdsSearch2.productNumber.value = ProdNo;
    document.msdsSearch2.submit();
}

function submitCofASearch(){
  	document.cofa.submit();
 	}

function validateAndSubmitCofASearch(){
 	var lotNo = document.getElementById('LotNo');
 	var productNumber = document.getElementById('symbol');
	var errorMsg = document.getElementById('cofaErrorMsg');
	var errorMsg2 = document.getElementById('cofaErrorMsg2');
	if(lotNo == null || lotNo.value =="" || productNumber == null || productNumber.value ==""){
  		if(lotNo == null || lotNo.value ==""){
  	        errorMsg.style.display = 'block';
 	    	}
 	    	else {
 	    	    errorMsg.style.display = 'none';
		}		  	    
 	    	if(productNumber == null || productNumber.value ==""){
 	    	    errorMsg2.style.display = 'block';
		}		  	    
  	    else{
  	        errorMsg2.style.display = 'none';
  	    }
	}
 	    else{
  		//document.cofa.submit(); 			  	 
		var url = document.cofa.action + '?symbol='+ productNumber.value+'&LotNo='+lotNo.value +'&ajax=true';	 						 		  
		var postData='';					
		var newCallback = new Object();
		newCallback.success = successCofAFunction;
		newCallback.failure = failureCofAFunction;
		newCallback.timeout = 50000;		 
		//newCallback.argument = matNo;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);			 
  	}
}

function validateBrandSelection(){
	var x=document.getElementsByName("brandTest");
	var checked = 0;
	var brand='';
	for(var i=0; i<x.length; i++){
	if(x[i].checked){
	   checked = 1; 
	   brand=x[i].value;
	   break;
	}
}

    if(checked == 0){
  	       alert("Please select a Product Name.");
  	    }else{
  		var lotNo = document.getElementById('LotNo');
  	    var productNumber = document.getElementById('symbol');	 
  		var url = document.cofa.action + '?symbol='+ productNumber.value+'&LotNo='+lotNo.value +'&brandTest='+brand;
  		window.location.href= url;
	  	}
  	}

function successCofAFunction(o)
{
var xmlDoc = o.responseText; 
if(xmlDoc == null ||xmlDoc==''){
   failureCofAFunction(o);
}
else{
    var url = xmlDoc.toString(); 			 	 
	if(url.indexOf("redirect") ==0){ 
	   url = url.substring(9,url.length); 
	   window.location.href= url;
	}
	else{		
		var form = document.getElementById('brandSelectionForm');
		form.innerHTML = xmlDoc;
	    var brandSelectionDiv = document.getElementById('cofaBrandSelection');	    				      
	    brandSelectionDiv.style.visibility ='visible';
	    }
}
}

function failureCofAFunction(o)
	{	
	 var errorMsg = document.getElementById('cofaErrorMsg');
	 errorMsg.innerHTML = "Fail to Get CofA";
  	 errorMsg.style.display = 'block';			 
	} 
function closeBrandSelectionLayer(){
	var brandSelectionDiv = document.getElementById('cofaBrandSelection');	    				      
	brandSelectionDiv.style.visibility ='hidden';
	}
	function getTSLink()
	{
	if (document.cookie.indexOf("country=USA") != -1)
		{
		window.location.href="/insite_techservice";
		}
		else if(document.cookie.indexOf("country") != -1)
		{
		window.location.href="/insite_customer_service";
		}
		else
		{
	        window.location.href="/sigma-aldrich/home.html";
	    }
	}

// Added for FYG 3
snpDetails = new Array();

function loadYFG(url, divID){
	    //var catalog = getContextPath();
				
		var postData = '';				

		setupYFGPending(divID);

		var newCallback = new Object();
		
		newCallback.success = YFGsuccessFunction;
		newCallback.failure = YFGfailureFunction;
		newCallback.timeout = 6000000;
		newCallback.argument = divID;	
		var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
	}
	
function YFGsuccessFunction(o) {
	    var divID =	o.argument;	 	    
	    try{
			var xmlDoc = o.responseText;				
			
					
			document.getElementById(divID).innerHTML = xmlDoc;				
			if (divID == 'SnpTable')
		    {		    	
		    	snpDetails = getSnpDetails();			    		    	
		    }			 
			document.getElementById(divID).setAttribute ('style', '');
		}
		catch(err)
		{	
		    YFGfailureFunction;
		} 
	}
	
function getSnpDetails() {
		var x = document.getElementById('snpArrayX').getAttribute("value");
		var y = document.getElementById('snpArrayY').getAttribute("value");		
		var arr = document.getElementById('snpArray'); //.getAttribute("value");
	 	var snparrs = arr.getElementsByTagName('input'); 	
	 	var snp = new Array(x);
	 	
	 	for (var i=0; i<x; i++) 
	 	{	 		
	 		snp[i] = new Array(y);
	 		for (var j=0; j<y; j++) 
	 		{
	 			var num = i * y  + j;
	 			snp[i][j] = snparrs[num].value;
	 		}
	 	} 		 	
	 	return snp;
	}
	
function YFGfailureFunction(o) {
		var divID = o.argument;
		document.getElementById(divID).innerHTML = "Connection error. Please try your search again.";	
	}
	
function setupYFGPending(divId) { 
		if(document.getElementById(divId))
			document.getElementById(divId).innerHTML = '<div style=\"padding-left:450px;padding-top:10px;\"><img src="/etc/medialib/sigma-aldrich/search/circular-progress.Par.0001.Image.gif" /></div>';
			
	}

function literatureTableToggle(url, toggle) {
	
		if (toggle == 'More')
		{
			document.getElementById('TableToggleMore').style.display = 'none';
			document.getElementById('TableToggleLess').style.display = 'inline';
			loadYFG(url,'LitTable');
		}
		else
		{
			document.getElementById('TableToggleMore').style.display = 'inline';
			document.getElementById('TableToggleLess').style.display = 'none';
			loadYFG(url,'LitTable');
		}
	}	
		
function enableClearFilterButton(enabled)  {
    var clearButton = document.getElementById('clearFilterButton');    
    if (enabled == true) {
        clearButton.removeAttribute("disabled");       
    }
    else {
        clearButton.setAttribute("disabled", "disabled");        
    }
}		


function updateFilterSelectionDisplay(filterType)  {            
   var filters = document.getElementById('filterType');  
   var aLinks = filters.getElementsByTagName('li');
   for (var i=0; i<aLinks.length; ++i) {
       var item = aLinks[i];       
       var selectedFilterId = 'filter_'+filterType;
      // if (item.hasClassName('Selected') && item.id != selectedFilterId)
      
       if (HasClassName(item,"Selected") && item.id != selectedFilterId)  
       {       	
           //item.removeClassName('Selected');
           RemoveClassName(item,"Selected");
       }
       else if (item.id == 'filter_'+filterType) 
       {
           if(!HasClassName(item,"Selected")) {
               AddClassName(item,"Selected", true);
           }
       }
    }
}


function setAnalyzeSize(link, newSize) {	
	var url = getURL(link) + "&refresh=cloudContent";  
	loadYFG(url, 'cloudContent');
}

function getCurrentFilterSelection()  {	
    var filterType="";
    var filters = document.getElementById('filterType');      
    if (filters ) {
        var aLinks = filters.getElementsByTagName('li');        
        for (var i=0; i<aLinks.length; ++i) {
           var item = aLinks[i];           
           //if (item.hasClassName('Selected')) {
           if (item.className == 'Selected') {           	   
               var item_id=item.id;
               filterType = item_id.substring(1+item_id.indexOf('_'));
               break;
            }
        }
    }
    return filterType;
}	

function getCurrentAnalyzeSize()  {
  var analyze = document.getElementById('analyzeSize');   	  
  if (analyze == null)
  return 50;
  return analyze.options[analyze.selectedIndex].value;
}

function getCurrentTagSearchTerm()  {
    var filter = document.getElementById('tagCloudAndFilter');  
    if (filter)
        return filter.getAttribute('tagSearchTerm');
    else
        return '';
}

function getFilterCategory()  {
	var filter = document.getElementById('tagCloudAndFilter');  
    if (filter)
        return filter.getAttribute('filterCategory');
    else
        return '';
    
}

function getCurrentSort() {
	var paging = document.getElementById('pageContainer');  
	if (paging)
		return paging.getAttribute('sortType');
	else
		return 'relevance';
}

function getCurrentPageSize() {
	var paging = document.getElementById('pageContainer');  
	if (paging)
		return paging.getAttribute('pageSize');
	else
		return '10';
}

function getCurrentPageNumber() {
	var paging = document.getElementById('pageContainer');  	
	if (paging)
		return paging.getAttribute('pageNum');
	else
		return '1';
}

function getTotalLiteratureCount()  {
	var paging = document.getElementById('pageContainer'); 
    if (paging)
		return paging.getAttribute('totalLiteratureCount');
	else
		return "-1";
}

function getTotalPageCount()  {
	var paging = document.getElementById('pageContainer'); 
    if (paging)
		return paging.getAttribute('totalPageCount');
	else 
		return "1";
}

function setCurrentTagSearchTermAndFilterCategory(newTerm, newCategory)  {
    var filter = document.getElementById('tagCloudAndFilter');  
    if (filter) 
    {
        filter.setAttribute('tagSearchTerm', newTerm);
        filter.setAttribute('filterCategory', newCategory);
    }    
}

function getCurrentSearchTermHistory() {
	var termHistory = document.getElementById('tagCloudAndFilter');  
    if (termHistory)
    {    	
        return termHistory.getAttribute('tagSearchTermList');
    }
    else
        return '';
}

function setCurrentSearchTermHistory(newTerm) {
	var filter = document.getElementById('tagCloudAndFilter');  
	var terms = filter.getAttribute("tagSearchTermList");
	//var terms = filter.getAttribute("tagSearchTerm");
	
	terms = terms + '**' + newTerm;
    if (newTerm != '')
    {    	
    	filter.setAttribute('tagSearchTermList', terms);
    }
    else 
    {
    	filter.setAttribute('tagSearchTermList', '');
    }       
}

function getCurrentFilterCategoryList() {
	var cat = document.getElementById('tagCloudAndFilter');  
    if (cat)
    {    	
        return cat.getAttribute('filterCategoryList');
    }
    else
        return '';
}

function setCurrentFilterCategoryList(newTerm) {
	var filter = document.getElementById('tagCloudAndFilter');  
	var terms = filter.getAttribute("filterCategoryList");
	//var terms = filter.getAttribute("filterCategory");
	
	terms = terms + '**' + newTerm;
    if (newTerm != '')
    {    	
    	filter.setAttribute('filterCategoryList', terms);
    }
    else 
    {
    	filter.setAttribute('filterCategoryList', '');
    }       
}

function removeTagSearchTerm(term, idx) {
	var filter = document.getElementById('tagCloudAndFilter');  
	var terms = filter.getAttribute("tagSearchTermList");		
	var terms_arr = terms.split('**');
	var newterms = '';
	for (i = 0; i < terms_arr.length; i++){
		if (i != idx && terms_arr[i].length > 0)
		{
			newterms = newterms + '**' + terms_arr[i];
		}
	}
    //var newterms = terms.replace('**'+term, '');      
    var newterm = ''; 
    if (newterms != '')
    {  
	    newterm = newterms.substring(newterms.lastIndexOf('**')+2);	    
	    newterms = newterms.substring(0, newterms.lastIndexOf('**'));	   
	    filter.setAttribute('tagSearchTermList', newterms);  
	}  
    return newterm;
}

function removeFilterCategory(category, idx) {
	var filter = document.getElementById('tagCloudAndFilter');  
	var cats = filter.getAttribute("filterCategoryList");		
	var cats_arr = cats.split('**');
     	var newcats = '';
	for (i = 0; i < cats_arr.length; i++){
		if (i != idx && cats_arr[i].length > 0)
		{
			newcats = newcats + '**' + cats_arr[i];
		}
	}  
    var newcat = ''; 
    if (newcats != '')
    {  
	    newcat = newcats.substring(newcats.lastIndexOf('**')+2);		    
	    newcats = newcats.substring(0, newcats.lastIndexOf('**'));	   
	    filter.setAttribute('filterCategoryList', newcats);  
	} 	
    return newcat;
}
		
function setFilterType(filterType, link)  {    
    if (filterType != getCurrentFilterSelection()) 
    {    	
        updateFilterSelectionDisplay(filterType);
        var url = getURL(link) + "&refresh=cloudContent";        
    
        loadYFG(url, 'cloudContent');
    }
}

function getURL(link) {
	var url = link + "&AnalyzeSize=" + getCurrentAnalyzeSize() 
        		+ "&FilterCategory=" + getFilterCategory()
        		+ "&FilterCategoryList=" + getCurrentFilterCategoryList()
        		+ "&TagSearchTerm=" + getCurrentTagSearchTerm() 
        		+ "&FilterSelection=" + getCurrentFilterSelection()
        		+ "&SearchTermHistory=" + getCurrentSearchTermHistory()
        		+ "&PageNumber=" + getCurrentPageNumber()
        		+ "&PageSize=" + getCurrentPageSize()
        		+ "&Sort=" + getCurrentSort();
    return url;        		 
}

function setFilterTermAndCategory(newTerm, newTermCategory, link, flag)  {	
    if (flag == true || newTerm != getCurrentTagSearchTerm() || newtermCategory != getFilterCategory()) 
    {        
        //enableClearFilterButton(true);
        setCurrentTagSearchTermAndFilterCategory(newTerm, newTermCategory); 
        setCurrentSearchTermHistory(newTerm);       
        setCurrentFilterCategoryList(newTermCategory);         
        setCurrentPageNumber(1);
        url = getURL(link) + "&refresh=all";        
	    if(document.getElementById('literatureContent'))
			document.getElementById('literatureContent').innerHTML = '';
        loadYFG(url, 'TagCloudArea');        
    }
}

function deleteTagSearchTermAndCategory(link, term, category, idx) {		
	var newterm = removeTagSearchTerm(term, idx);
	var newcategory = removeFilterCategory(category, idx);
	if (newterm != '')
	{
	  setFilterTermAndCategory(newterm,newcategory, link, true);
	} 
    else 
    {
    	clearFilterTerm(link);
    }
}

function clearFilterTerm(link)  {
    if (getCurrentTagSearchTerm().length > 0) 
    {            
	setCurrentTagSearchTermAndFilterCategory('', '');
	setCurrentSearchTermHistory('');
	setCurrentFilterCategoryList('');           	
	setCurrentPageNumber(1);
    	url = getURL(link) + "&refresh=all";        
	    if(document.getElementById('literatureContent'))
			document.getElementById('literatureContent').innerHTML = '';
        loadYFG(url, 'TagCloudArea');               
    }
}

function setSelectedSnpRegion(obj) {
    clearSelectedSnpRegion();
    obj.getElementsByTagName('img')[0].selected = true;
    obj.getElementsByTagName('img')[0].src = "/etc/medialib/sigma-aldrich/headers/endeca-search-and/sigmared.Par.0001.Image.gif";
 }	

function showSnpExonDetail(id) {
    document.getElementById('regionTitleSpan').innerHTML = "in exon" + id + " region";
    showSnpDetail(getExonDetails(id));
}

function showSnpIntronDetail(id) {
    document.getElementById('regionTitleSpan').innerHTML = "in intron" + id + " region";
    showSnpDetail(getIntronDetails(id));
}

function showSnpUpstreamDetail() {
    document.getElementById('regionTitleSpan').innerHTML = "in upstream region";
    showSnpDetail(getUpstreamDetails());
}

function showSnpDownstreamDetail() {
    document.getElementById('regionTitleSpan').innerHTML = "in downstream region";
    showSnpDetail(getDownstreamDetails());
}

function showSnpAllDetail() {
    document.getElementById('regionTitleSpan').innerHTML = "";
    showSnpDetail(getAllDetails());    
}	

function getAllDetails() {
    return snpDetails;
}

function clearSelectedSnpRegion() {
    var graph = document.getElementById('snpGraphDiv');
    var imgs = graph.getElementsByTagName('img');
    for (var i=0; i<imgs.length; ++i) {
        if (imgs[i].selected==true) {
            imgs[i].selected = false;
            if (i==0 || i==imgs.length-1) {
                imgs[i].src = "/etc/medialib/sigma-aldrich/headers/endeca-search-and/orange.Par.0001.Image.gif";
            }
            else {
                imgs[i].src = "/etc/medialib/sigma-aldrich/headers/endeca-search-and/blue.Par.0001.Image.gif";
            }
        }
    }
}

function showSnpDetail(details) {	
    var htmlString = [];
    htmlString.push("<table class='SnpDetailTable' width='100%'>");
    htmlString.push("<tr style='height:40px'>");
    htmlString.push("<th class='thSnpId SilverHeading'>SNP ID</th><th class='thGeneId SilverHeading'>Gene ID</th><th class='thGeneSymbol SilverHeading'>Gene<br>Symbol</th><th class='thRefSeq SilverHeading'>Refseq</th><th class='thChromosome SilverHeading'>Chromosome</th><th class='thFunctionCode SilverHeading'>Function<br>Code</th><th class='thReadingFrame SilverHeading'>Reading<br>Frame</th><th class='thAllele SilverHeading'>Allele</th><th class='thResidue SilverHeading'>Residue</th>");
    htmlString.push("</tr>");
    if (isArray(details) && details.length > 0) {
        var shade = false;
        for (var i=0; i<details.length; ++i) {
            if (shade) {
                htmlString.push("<tr class='LightGray'>");
            }
            else {
                htmlString.push("<tr>");
            }
            shade = !shade;
            for (var j=0; j<9; ++j) {
                htmlString.push("<td>" + details[i][j] + "</td>");
            }
            htmlString.push("</tr>");
        }
    }
    else {
        htmlString.push("<tr><td colspan='9'><span class='YfgNote'>no data is available</span></td></tr>");
    }
    htmlString.push("</table>");
    
    document.getElementById('snpDetailDataDiv').innerHTML = htmlString.join("");
    window.location.hash = "#snpDetailTop";
}


function getExonDetails(id) {
    var exons = new Array();
    var count =0;    
    for (var i=0; i<snpDetails.length; ++i) {
        if (id == snpDetails[i][9]) {
            exons[count++] = snpDetails[i];
        }
    }
    return exons;
}

function getIntronDetails(id) {
    var introns = new Array();
    var count =0;    
    for (var i=0; i<snpDetails.length; ++i) {
        if (id == snpDetails[i][10]) {
            introns[count++] = snpDetails[i];
        }
    }
    return introns;
}

function getUpstreamDetails() {
    var ups = new Array();
    var count =0;
    for (var i=0; i<snpDetails.length; ++i) {
        if (snpDetails[i][11] > 0) {
            ups[count++] = snpDetails[i];
        }
    }
    return ups;
}

function getDownstreamDetails() {
    var ds = new Array();
    var count =0;
    for (var i=0; i<snpDetails.length; ++i) {
        if (snpDetails[i][12] > 0) {
            ds[count++] = snpDetails[i];
        }
    }
    return ds;
}	

function isArray(o) {
    return (typeof o == 'object' && typeof o.length == 'number');
}

function clearSurvey(o) {
		 if (o.value == 'Tell Us More' || o.value == 'Tell Us More - leave email to discuss.')
		 {
		 		 o.value='';
		 }
}

function submitYFGSurvey(query) {
    CreateRequest();
	var comment = document.getElementById("surveyTextBox");
	var checkboxValue;
	var tab = document.getElementById("tabName").value;
	for (var i=0; i < document.YFGsurvey.group1.length; i++)
   	{
   	  if (document.YFGsurvey.group1[i].checked)
      {
     	 checkboxValue = document.YFGsurvey.group1[i].value;
      }
   }

	var url = getCatalogNameFromURL()+ "/Survey.do?survey1=" + comment.value + "&survey2=''&survey3=''&survey4=" + checkboxValue+"&survey5="+ tab;
	var errorMsg2 = document.getElementById("surveyErrorMsg");
	if(checkboxValue == null)
	{
		errorMsg2.style.display = 'block';
	}		
 	else 
 	{
		errorMsg2.style.display = 'none';
	    request.open("GET", url, true);
    	request.onreadystatechange=UpdateYFGPageSurvey;
    	request.send(null);
    	
	}
}

function UpdateYFGPageSurvey() {
	if (request.readyState == 4){
		var textarea = document.getElementById("survey");
		textarea.innerHTML = "<div id=\"thankyou\" class=\"pad2 margin3 fontBold\"><h2> Thank you for your comments!</h2></div>";
	}
}	

function setCurrentPageNumber(newPageNum) {
	var paging = document.getElementById("pageContainer");	
    if (paging) 
    {
        paging.setAttribute('pageNum', newPageNum);       
    }    
}

function setCurrentPageSize(newPageSize) {
	var paging = document.getElementById("pageContainer");	
    if (paging) 
    {
        paging.setAttribute('pageSize', newPageSize);       
    }    
}

function setCurrentSort(newSort) {	
	var paging = document.getElementById("pageContainer");
	if (paging)
	{
		paging.setAttribute('sortType', newSort);
	}
}

function setPageSize(newSize, link)  {
 var currentPageSize = getCurrentPageSize();	
    if (newSize != currentPageSize) {        
        setCurrentPageNumber(1);
        setCurrentPageSize(newSize);
       	var url = getURL(link) + "&refresh=literature";  
        loadYFG(url, 'literatureContent');  
    }
}
	
function showPage(newPageNum, link) 
{	
	var currentPageNum = getCurrentPageNumber();	    
    if (newPageNum != currentPageNum) {        
       
        setCurrentPageNumber(newPageNum);        
        var url = getURL(link) + "&refresh=literature";   
    	
        loadYFG(url, 'literatureContent');         
        
    }
}

function sortBy(sortType, link)
{
	var currentsorttype = getCurrentSort();	
    if (sortType != currentsorttype)
    {				
		setCurrentPageNumber(1);
		
		setCurrentSort(sortType);		
		var url = getURL(link) + "&refresh=literature";   
    	
        loadYFG(url, 'literatureContent');   
    }
}

function loadCatalogTable(divID) {
    var tdDivID = 'td'+divID;
    var currLocPath = (location.pathname.replace(new RegExp('[^a-zA-Z0-9&]', 'g'),''));
    currLocPath = currLocPath.replace('printerview','');
    currLocPath = currLocPath.replace('author','');
    var postData = 'contenturl='+currLocPath+getURLQueryWithoutQuestionMark();
    var catalogURL = getContextPath()+ '/TechContentTablePage.do?';

    //var newCallback = new Object();

    //newCallback.success = SRsuccessLoadTable;
    //newCallback.failure = SRfailureLoadTable;
    //newCallback.timeout = 50000;
    //newCallback.argument = divID;

    //var transaction = YAHOO.util.Connect.asyncRequest('POST', catalogURL, newCallback, postData);
    
	jQuery.ajax({
		url: catalogURL,
		data: postData,
		dataType: "html",
		error: function(jqXHR, textStatus, errorThrown) {
			var o = new Object();
			o.argument = divID;
			SRfailureLoadTable(o);
		},
		success: function(data, textStatus, jqXHR){
			var o = new Object();
			o.responseText = data;
			o.argument = divID;
			SRsuccessLoadTable(o);
		},
		timeout: 50000,
		type: "POST"
	});
}

function SRsuccessLoadTable(o)
{
    var divID = o.argument;
    try{
		var xmlDoc = o.responseText;
		if(xmlDoc == null || xmlDoc.length == 0){
		   document.getElementById(divID).innerHTML = getTechContentTableLoadError();
		}else{
			document.getElementById(divID).innerHTML = xmlDoc;				 
		}
	}
	catch(err)
	{		
	    document.getElementById(divID).innerHTML = getTechContentTableLoadError();
	} 
}

function SRfailureLoadTable(o)
{
	var divID = o.argument;
	document.getElementById(divID).innerHTML = getTechContentTableLoadError();	
}

function submitRefinement(command, refinementNumber) 
{
	//alert('Beginning of Submit Refinement - Location.Href='+location.href);
	if (command =='Refine'){   
			var url = location.href;
			var iof = url.indexOf("?");
			if (iof > 0)
			{
				url = url.substring(0,iof);
			}

			var intIndexOfMatch = refinementNumber.indexOf(" "); 
			// Loop over the string value replacing all space with $
			 while (intIndexOfMatch != -1){			  
				 refinementNumber = refinementNumber.replace(/ /,"$"); 	 
				 intIndexOfMatch = refinementNumber.indexOf(" ");
			 }
			 
			qs = window.location.search.substring(1);
			qsList = qs.split("&");
			for (i=0;i<qsList.length;i++)
			{
				if (qsList[i]!='')
				{
					if (qsList[i].indexOf("refinementValue") < 0 )
					{
						if (url.indexOf('?')==-1)
							url = url + '?' + qsList[i];
						else
							url = url +  '&' + qsList[i];
					}else{
						if (url.indexOf('?')==-1)
							url = url + '?refinementValue=' + refinementNumber;
						else							
							url = url + '&refinementValue=' + refinementNumber;
					}
				}
			}
			if(url.indexOf("refinementValue")<0){
				if(url.indexOf("?")<0){
					url = url + '?refinementValue=' + refinementNumber;
				}else{
					url = url + '&refinementValue=' + refinementNumber;
				}
			}
			//alert('End of Submit Refinement - Location.href='+url);
			location.href=url;
			return;
	} 
}
function getURLQueryWithoutQuestionMark()
{
	return document.location.search.replace('?', '&');
}

function getTechContentTableLoadError()
{
	try
	{
		var techContentTableLoadError= document.getElementById("techContentTableLoadError");
    		return techContentTableLoadError.value;
	}
    	catch(err)
    	{
		return "<DIV class=\"noPrice\"><IMG src=\"/etc/medialib/sigma-aldrich/headers/endeca-search-and/nodata.Par.0001.Image.15.gif\">&nbsp;We were unable to return a product list due to a system problem.  Please refresh this page or try viewing it later.</DIV>";
	}
}

//Added for Product Optimization

 function loadPA_alt_pack_size(productNumber, brandKey){ 
    var priceElement= 'pricingAvailability'; 
    var loadFor ='ALT_PACK_SIZE';  
    var catalog =  getContextPath();
	var url = catalog + '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;		 
	var postData = 'loadFor=' +loadFor;				
	setupPending(priceElement); 
	var newCallback = new Object();
	newCallback.success = successPriceFunction;
	newCallback.failure = failurePriceFunction;
	newCallback.timeout = 50000;
	newCallback.argument = priceElement;	
	var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
}

function validateAndSubmitCompareReplacements(comparebutton, total, originalProductId){
	var pid='';
	for (var i=0;i<=total;i++){
		var onechkbox = document.getElementById('compareBox'+i);
	   if (onechkbox.checked == true)
		{  			     
			 if(pid==''){
			 	pid=onechkbox.value;
			 }else{
			 	pid = pid+ '+'+ onechkbox.value;
			 }
		} 	
	} 
	 if(pid !=null && pid !=""){
	     var returnURL = escape(location.href);
		 var currentTagTokens = pid.split( "+" );
		 var total = currentTagTokens.length;
		 if(total>=2 && total <=4){
		 	var catalog = getContextPath();
		  	var url =catalog + '/Compare.do?P_ID=' +pid +'&returnURL='+returnURL +'&isFromAltPage=true&originalProductId='+originalProductId; 
		 	location.href = url;
		  }
		  else if(total<2){
			dropdownmenu(comparebutton, 'event', 'lessErrorMsgBox');
		  }
		  else if(total>4){
	   		  dropdownmenu(comparebutton, 'event', 'moreErrorMsgBox');
		  }
	  } 
	  else{
	  	dropdownmenu(comparebutton, 'event', 'lessErrorMsgBox');
	  } 	 
}
 
function displayReplace(productNumber, brand, matNo, fromUrlLabel){
	var fromUrl = escape(location.href);
	var catalog = getContextPath();		
	var url = catalog +'/Replacement.do?productNumber=' + productNumber + 
	'&brand='+brand + 
	'&matNo='+matNo +
	'&fromUrl=' +fromUrl
	+'&fromUrlLabel=' +fromUrlLabel;
	location.href=url;		
}

function openPAOnALT(productNumber, brandKey, divID, pricingButtonId){
	var closeButtonText  = "close"; 
		 try{
	   closeButtonText  = document.getElementById("closeButton").value; 
		 }catch(ignore){}
	var button = document.getElementById(pricingButtonId);
	button.innerHTML ="<a href=\"javascript:closePAOnALT(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\');cmTagAndLink('Close Pricing','Alternative Products Page Details',null,null,null);\">"+closeButtonText+"</a>";
	loadPAOnALT(productNumber, brandKey, divID);
}

function loadPAOnALT(productNumber, brandKey, divID){
	var tdDivID = 'td'+divID;
	var catalog = getContextPath();
	var url = catalog +  '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;		
	url = url +'&isLoadForm=false';
	var postData = 'loadFor=ALT';				
	setupPending(divID);
	var newCallback = new Object();
	newCallback.success = SRsuccessPriceFunction;
	newCallback.failure = SRfailurePriceFunction;
	newCallback.timeout = 50000;
	newCallback.argument = divID;	
	var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
}
	
function closePAOnALT(productNumber, brandKey, divID, pricingButtonId){
 var pricingButtonText  = "pricing";
	 try{			  
	   pricingButtonText  = document.getElementById("pricingButton").value;
	 }catch(ignore){}

	var button = document.getElementById(pricingButtonId);
	button.innerHTML ="<a href=\"javascript:openPAOnALT(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\');cmTagAndLink('Open Pricing','Alternative Products Page Details',null,null,null);\">"+pricingButtonText+"</a>";
	var priceDiv = document.getElementById(divID);
	priceDiv.innerHTML ="";		
	hidePAtip();
}

function loadComparisonPA_ALT(productNumber, brandKey, priceElement){
	loadGeneralPA(productNumber, brandKey, priceElement, 'comparison_ALT');
}
//Clean up inline code
function submitAddToCartProductQuantity(brandkey, materialNumber, quantityinputbox)	{ 
	var Qty =1;
		try{
			 Qty = document.getElementById("quantityinputboxid").value;			
			 if (Qty == "")			  
			 	Qty=1;		 
		 }catch(ignore){} 
		 
	var ProductAddToCart = 	document.getElementById('ProductAddToCartForm');	
	ProductAddToCart.Brand.value = brandkey;
	ProductAddToCart.ProdNo_0.value = materialNumber;
	ProductAddToCart.chkAdd0.value = materialNumber;
	ProductAddToCart.MatNo_0.value = "";
	ProductAddToCart.Qty_0.value = Qty;	 
	ProductAddToCart.URL.value = location.href;	 
	counter++;
	if(counter > 1) 
	{ 
		return false; 
	}
	ProductAddToCart.submit();
}
	 
function showhint_LD(hintDivId, obj, e, tipwidth){ 
	if ((ie||ns6) && document.getElementById(hintDivId)&& document.getElementById("hintbox")){
		hintContentDiv=document.getElementById(hintDivId);
		var newDiv = document.createElement('div');
		newDiv.innerHTML =  hintContentDiv.innerHTML;
		dropmenuobj=document.getElementById("hintbox");				
		dropmenuobj.innerHTML= "";			
		dropmenuobj.appendChild(newDiv);		
				
		var elements = dropmenuobj.getElementsByTagName('input');
		for(var i=0; i<elements.length; i++){
		  if(elements[i].name == 'quantityinputbox'){ 
		  	elements[i].setAttribute('id','quantityinputboxid');
		  	break;
		  } 
		}
			
		elements = dropmenuobj.getElementsByTagName('div');
		for(var i=0; i<elements.length; i++){ 
		  if(elements[i].className == 'availabilitymessageclass'){			  
		  	elements[i].setAttribute('id','availabilitymessagediv'); 
		  	break;
		  }
	}

	dropmenuobj.style.left=dropmenuobj.style.top=-500;
		if (tipwidth!=""){
			dropmenuobj.widthobj=dropmenuobj.style;
			dropmenuobj.widthobj.width=tipwidth;
		}
		dropmenuobj.x=getposOffset(obj, "left");
		dropmenuobj.y=getposOffset(obj, "top");
		dropmenuobj.style.left=dropmenuobj.x +obj.offsetWidth+"px";
		dropmenuobj.style.top=dropmenuobj.y +"px";
		dropmenuobj.style.visibility="visible"			
	}
}
	
function hidePAtip(){
	dropmenuobj=document.getElementById("hintbox");	
	dropmenuobj.style.visibility="hidden"
	dropmenuobj.style.left="-500px"
}

function openPAOnSR_LD(productNumber, brandKey, divID, pricingButtonId, page){
	 var button = document.getElementById(pricingButtonId);
	 var closeButtonText  = "close"; 
		 try{
	   closeButtonText  = document.getElementById("closeButton").value; 
		 }catch(ignore){}
		 if(page!=null){
	 		 button.innerHTML ="<a href=\"javascript:closePAOnSR_LD(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Close Pricing', '"+page+"',null,null,null);\">"+closeButtonText+"</a>";
		 }else{
	 		 button.innerHTML ="<a href=\"javascript:closePAOnSR_LD(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Close Pricing','Search Result Page Details',null,null,null);\">"+closeButtonText+"</a>";
		 }
		 //Set Coremetrics global debug variables for Search Results
		 cmBrandKey = brandKey;
		 cmProductNumber = productNumber; 
		 loadPAOnSR_LD(productNumber, brandKey, divID);
}
	
function loadPAOnSR_LD(productNumber, brandKey, divID){
	var tdDivID = 'td'+divID;
	var catalog = getContextPath();
	var url = catalog +  '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;		
	url = url +'&isLoadForm=false';
	var postData = 'loadFor=SR_LD';				
	setupPending(divID);
	var newCallback = new Object();
	newCallback.success = SRsuccessPriceFunction;
	newCallback.failure = SRfailurePriceFunction;
	newCallback.timeout = 50000;
	newCallback.argument = divID;	
	var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
}

function closePAOnSR_LD(productNumber, brandKey, divID, pricingButtonId, page){
	 var button = document.getElementById(pricingButtonId);			 
	 var pricingButtonText  = "pricing";
	 try{			  
	   pricingButtonText  = document.getElementById("pricingButton").value;
	 }catch(ignore){}
		 if (page!=null){
	 		 button.innerHTML ="<a href=\"javascript:openPAOnSR_LD(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Open Pricing','"+page+"',null,null,null);\">"+pricingButtonText+"</a>";
		 }else{		     
	 		 button.innerHTML ="<a href=\"javascript:openPAOnSR_LD(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Open Pricing','Search Result Page Details',null,null,null);\">"+pricingButtonText+"</a>";
		 }
		 var priceDiv = document.getElementById(divID);
		 priceDiv.innerHTML ="";		 		 
		 hidePAtip();
}
	
//lost demand: this is called by popup div of P&A details, use a new loadfor type = MAT_LD  
function loadPAForMat_LD(matNo, productNumber, brandKey, quantityinputbox, availabilitymessagediv){ 	
	var Qty =1; 
	try{
		 Qty = document.getElementById("quantityinputboxid").value;	 
		 if (Qty == "")			  
		 	Qty=1;	 
	 }catch(ignore){ 
		 }  
		 
	var catalog = getContextPath(); 
	var url = catalog + '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;	 
	var postData='MatNo' + matNo +'=' + Qty+ '&loadFor=MAT_LD';	 
	var matRow = document.getElementById(availabilitymessagediv);  
	matRow.innerHTML = '<img src="' + getRedCubeImg() + '">&nbsp;Checking availability</img>'; 
	var newCallback = new Object();
	newCallback.success = successPriceRowLDFunction;
	newCallback.failure = failurePriceRowLDFunction;
	newCallback.timeout = 50000;	
	newCallback.argument = availabilitymessagediv;	
	var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);		 
}
	
function successPriceRowLDFunction(o){ 
	var availabilitymessagediv = o.argument;
	var xmlDoc = o.responseText; 
	if(xmlDoc == null ||xmlDoc==''){
	   failurePriceRowLDFunction(o);
	}
	var matRow = document.getElementById(availabilitymessagediv);
	matRow.innerHTML = xmlDoc;		
}	

function failurePriceRowLDFunction(o) {	
	var availabilitymessagediv = o.argument;		
	var matRow = document.getElementById(availabilitymessagediv);
	matRow.innerHTML = "<div class='noPrice'>" + getErrorPrice() + "</div>";	 
} 
	
//product detail 
function loadPA_LD(productNumber, brandKey){ 
	//Set Coremetrics global debug variables for Detail Pages
	cmBrandKey = brandKey;
	cmProductNumber = productNumber;
	var priceElement= 'pricingAvailability'; 
	var loadFor ='PRD_LD';  
	var catalog =  getContextPath();
	var url = catalog + '/PricingAvailability.do?productNumber='+productNumber+'&brandKey='+brandKey;		 
	var postData = 'loadFor=' +loadFor;				
	setupPending(priceElement); 
	var newCallback = new Object();
	newCallback.success = successPriceFunction;
	newCallback.failure = failurePriceFunction;
	newCallback.timeout = 50000;
	newCallback.argument = priceElement;	
	var transaction = YAHOO.util.Connect.asyncRequest('POST', url, newCallback, postData);
}
//Stable Isotopes Availability Msg
function openPAOnSR_LD_Endeca(productNumber, brandKey, divID, pricingButtonId, page){
	 var button = document.getElementById(pricingButtonId);
	 var closeButtonText  = "close"; 
		 try{
	   closeButtonText  = document.getElementById("closeButton").value; 
		 }catch(ignore){}
		 if(page!=null){
	 		 button.innerHTML ="<a href=\"javascript:closePAOnSR_LD_Endeca(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Close Pricing', '"+page+"',null,null,null);\">"+closeButtonText+"</a>";
		 }else{
	 		 button.innerHTML ="<a href=\"javascript:closePAOnSR_LD_Endeca(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Close Pricing','Search Result Page Details',null,null,null);\">"+closeButtonText+"</a>";
		 }
		 //Set Coremetrics global debug variables for Search Results
		 var p = "endecaPA"+divID;
		 
		document.getElementById(p).style.display="block";

}

function closePAOnSR_LD_Endeca(productNumber, brandKey, divID, pricingButtonId, page){
	 var button = document.getElementById(pricingButtonId);			 
	 var pricingButtonText  = "pricing";
	 try{			  
	   pricingButtonText  = document.getElementById("pricingButton").value;
	 }catch(ignore){}
		 if (page!=null){
	 		 button.innerHTML ="<a href=\"javascript:openPAOnSR_LD_Endeca(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Open Pricing','"+page+"',null,null,null);\">"+pricingButtonText+"</a>";
		 }else{		     
	 		 button.innerHTML ="<a href=\"javascript:openPAOnSR_LD_Endeca(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Open Pricing','Search Result Page Details',null,null,null);\">"+pricingButtonText+"</a>";
		 }
		 var priceDiv = document.getElementById("endecaPA"+divID);
		 priceDiv.style.display="none";		 		 
		 hidePAtip();
} 

function closePAOnSR_LD(productNumber, brandKey, divID, pricingButtonId, page){
	 var button = document.getElementById(pricingButtonId);			 
	 var pricingButtonText  = "pricing";
	 try{			  
	   pricingButtonText  = document.getElementById("pricingButton").value;
	 }catch(ignore){}
		 if (page!=null){
	 		 button.innerHTML ="<a href=\"javascript:openPAOnSR_LD(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Open Pricing','"+page+"',null,null,null);\">"+pricingButtonText+"</a>";
		 }else{		     
	 		 button.innerHTML ="<a href=\"javascript:openPAOnSR_LD(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\',\'"+page+"\');cmTagAndLink('Open Pricing','Search Result Page Details',null,null,null);\">"+pricingButtonText+"</a>";
		 }
		 var priceDiv = document.getElementById(divID);
		 priceDiv.innerHTML ="";		 		 
		 hidePAtip();
}

function RemoveClassName(objElement, strClass)    {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {

         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper )
            {

            // remove array item
            arrList.splice(i, 1);

            // decrement loop counter as we have adjusted the array's contents
            i--;

            }

         }

      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   // there is nothing to remove

   }


function HasClassName(objElement, strClass)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {

         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper )
            {

            // we found it
            return true;

            }

         }

      }

   // if we got here then the class name is not there
   return false;

   }

function AddClassName(objElement, strClass, blnMayAlreadyExist)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // if the new class name may already exist in list
      if ( blnMayAlreadyExist )
         {

         // get uppercase class for comparison purposes
         var strClassUpper = strClass.toUpperCase();

         // find all instances and remove them
         for ( var i = 0; i < arrList.length; i++ )
            {

            // if class found
            if ( arrList[i].toUpperCase() == strClassUpper )
               {

               // remove array item
               arrList.splice(i, 1);

               // decrement loop counter as we have adjusted the array's contents
               i--;

               }

            }

         }

      // add the new class to end of list
      arrList[arrList.length] = strClass;

      // add the new class to beginning of list
      //arrList.splice(0, 0, strClass);
      
      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   else
      {

      // assign modified class name attribute      
      objElement.className = strClass;
   
      }

   }

function openPopUpAddlInfoRS(matNumber)
{
	gPopupWin = 0;
	var caption = "";
	var transportationNumberHtml = "";
	var descriptionHtml = "";
	var additionalFeesHtml = "";
	var tariffCodeHtml = "";
	var casNumberHtml = "";
	var japanFireCodeHtml = "";
	var poisonSubstanceCodeHtml = "";
	
	var DescField = "Desc"+matNumber;
	var description = document.getElementById(DescField).value;

	var	feesField = "Fees"+matNumber;
	var fees = document.getElementById(feesField).value;
		
	var	tariffField = "Tariff"+matNumber;
	var tariffCode = document.getElementById(tariffField).value;
	
	var	casField = "CAS"+matNumber;
	var casNumber = document.getElementById(casField).value;
	
	var	transField = "Trans"+matNumber;
	var transportNumber = document.getElementById(transField).value;
	
	var	jfcField = "JFC"+matNumber;
	var jfc = document.getElementById(jfcField).value;

	var	pscField = "PSC"+matNumber;
	var psc = document.getElementById(pscField).value;

	
	var prodNumberHtml = "<" + "TR" + ">\n" +
			             "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Product Number: " + "<" + "/TD" + ">\n" +
			             "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			             "<" + "TD height=\"20\"" + ">" + matNumber + "<" + "/TD" + ">\n" +
            			 "<" + "/TR" + ">\n";
  	
  	if (description !="")
	{					 
		descriptionHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Description: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + description + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
    	}
  	
    	
  	if (fees !="" && fees.indexOf("Aqis") <= 0)
	{					  
	 additionalFeesHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Additional Fees/Restrictions: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + fees + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
  	}
  	
  	if (tariffCode !="")
	{
	     tariffCodeHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Harmonized Tariff Code: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + tariffCode + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
	}
	
	if (casNumber != "")
	{
	      casNumberHtml = "<" + "TR" + ">\n" +
			              "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"CAS Number: " + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
			              "<" + "TD height=\"20\"" + ">" + casNumber + "<" + "/TD" + ">\n" +
            			  "<" + "/TR" + ">\n";
	}
	
	if (transportNumber !="")
	{
		transportationNumberHtml = "<" + "TR" + ">\n" +
			              		   "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"UN Transportation Number (IATA): " + "<" + "/TD" + ">\n" +
			              		   "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
						           "<" + "TD height=\"20\"" + ">" + transportNumber + "<" + "/TD" + ">\n" +
            			  		   "<" + "/TR" + ">\n";
    }
	
	if (jfc !="")
	{
		japanFireCodeHtml = "<" + "TR" + ">\n" +
			              	"<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Japan Fire Code: " + "<" + "/TD" + ">\n" +
			              	"<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
						    "<" + "TD height=\"20\"" + ">" + jfc + "<" + "/TD" + ">\n" +
            			  	"<" + "/TR" + ">\n";
    	}
    
    	if (psc !="")
	{
		poisonSubstanceCodeHtml = "<" + "TR" + ">\n" +
			              		  "<" + "TD height=\"20\" STYLE=\"font-weight : bold;\" width=\"20%\" nowrap" + ">" +"Poison/Deleterious Substance Code: " + "<" + "/TD" + ">\n" +
			              		  "<" + "TD height=\"20\" width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
						          "<" + "TD height=\"20\"" + ">" + psc + "<" + "/TD" + ">\n" +
            			  		  "<" + "/TR" + ">\n";
   	 }

	var cssLines;
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
	{ 	
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 16px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
	else
	{
	cssLines = "<" + "STYLE type=text/css" + "><" + "!--\n" +
                    ".Normal2 { FONT: 13px sans-serif }\n" +
                    "--" + ">" + "<" + "/STYLE" + ">\n"; 
	}
		
	var popupHtml = "<" + "HTML" + ">\n" +
                    "<" + "BODY" + ">\n" + cssLines + "\n" +
	                "<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\""+">\n" +
      				"<" + "TR" +">\n" +
			        "<" + "TD height=\"25\" bgcolor=\"#e2e2e2\" STYLE=\"font-weight : bold;\" align=\"left\" valign=\"middle\" width=\"4\">&nbsp;" + "<" + "/TD"+">\n" +
			        "<" + "TD height=\"25\" bgcolor=\"#e2e2e2\" STYLE=\"font-weight : bold;\" align=\"left\" valign=\"middle\">Additional Item Information" + "<" + "/TD"+">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
					"<" + "TD width=\"4\""+">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\"" + ">\n";
					
		popupHtml = popupHtml + prodNumberHtml + descriptionHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
      				"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
			        "<"+ "HR noshade width=\"100%\" size=\"1\"" + ">\n" +
					"<" + "/TD" + ">\n" +
					"<" + "/TR" + ">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +
					"<" + "TABLE class=\"Normal2\" border=\"0\" width=\"100%\"" + ">\n";
	
		if (browser!="Microsoft Internet Explorer")
		{ 			
		popupHtml = popupHtml + additionalFeesHtml + tariffCodeHtml + transportationNumberHtml + casNumberHtml + japanFireCodeHtml + poisonSubstanceCodeHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n" +
					"<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"window.close()\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	             		"<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
         }
         else
         {
         popupHtml = popupHtml + additionalFeesHtml + tariffCodeHtml + transportationNumberHtml + casNumberHtml + japanFireCodeHtml + poisonSubstanceCodeHtml +
					"<" + "/TABLE"+">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "TR" +">\n" +
				    "<" + "TD width=\"4\"" + ">" + "&nbsp;" + "<" + "/TD" + ">\n" +
					"<" + "TD" +">\n" +  
					"<"+"BR" + ">\n" +
					"<"+"BR" + ">\n" +
					"<" + "INPUT type=\"button\" value=\"Close\" name=\"button\" onClick=\"javascript:hidePopup();\"" + ">\n" + 
					"<" + "/TD" +">\n" +
					"<" + "/TR" +">\n" +
					"<" + "/TABLE" +">\n" +
	                         "<" + "/BODY" + ">\n" + 
                    "<" + "/HTML" + ">\n";
         }  
		  
	if (browser=="Microsoft Internet Explorer")
	{ 
	    if(jQuery("#PopupDiv").length>0){ 
		}else{  
				jQuery("body").append("<div id=\"PopupDiv\" style=\"display:none\"></div>");
		}
		 
		jQuery("#PopupDiv").html(popupHtml);
		var pos = $("#row"+matNumber).offset();   
		var top =pos.top +40;	
	 	jQuery("#PopupDiv").css( { "left": (pos.left) + "px", "top": top + "px", "display": "inline", "z-index": "9002", "position": "absolute", "width": "620px", "background-color":"white", "border":"1px solid #B3B3B3" } );
	 	jQuery("#PopupDiv").show();	    		
	}
	else
	{
	    viewPopupPage('',500,620,'yes');
        gPopupWin.document.open();
        gPopupWin.document.write(popupHtml);  
        gPopupWin.document.close();
	}
	  
}
