// changefontsize.js

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

// 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; 
        }        
    }    
} 

	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){
	    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;	
			 		 
			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";
		loadLangOnSR(productNumber, brandKey, divId);
	}
	
	function openPAOnSR(productNumber, brandKey, divID, pricingButtonId){
		var button = document.getElementById(pricingButtonId);
		button.innerHTML ="<a href=\"javascript:closePAOnSR(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\');cmTagAndLink('Close Pricing','Search Result Page Details',null,null,null);\">close</a>";

		loadPAOnSR(productNumber, brandKey, divID);
	}

	function closePAOnSR(productNumber, brandKey, divID, pricingButtonId){
	    var button = document.getElementById(pricingButtonId);
		button.innerHTML ="<a href=\"javascript:openPAOnSR(\'" + productNumber + "\', \'" + brandKey + "\',\'" + divID + "\',\'" + pricingButtonId + "\');cmTagAndLink('Open Pricing','Search Result Page Details',null,null,null);\">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{		
				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').style.visibility='hidden';
  document.getElementById('ScrollDownContainer').style.visibility='hidden';
  document.getElementById(baseName + 'ItemContainer').style.visibility='hidden';
  document.getElementById(baseName + 'ItemContent').style.visibility='hidden';
  }
}
function hideEl()
{
  if (baseName != undefined)
  { 
  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';
            }
        }

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;
	ProductAddToShelf.URL.value =  location.href ;	
	 
	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 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";
		tabRev.className = "tabNotSelected";
		//tabRef.style.backgroundColor = "transparent";
		//divs
		tabSpecDiv.className = "openDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "blockDiv";
		tabRevDiv.className = "blockDiv";
	}
	else if(tabId_ == "relProdTab"){
		tabRel.className = "tabSelected";
		//tabRel.style.backgroundColor = "white";
		tabSpec.className = "tabNotSelected";
		//tabSpec.style.backgroundColor = "transparent";
		tabRef.className = "tabNotSelected";
		tabRev.className = "tabNotSelected";
		//tabRef.style.backgroundColor = "transparent";
		//divs
		tabSpecDiv.className = "blockDiv";
		tabRelDiv.className = "openDiv";
		tabRefDiv.className = "blockDiv";
		tabRevDiv.className = "blockDiv";
	}
	else if(tabId_ == "refTab"){
		tabRef.className = "tabSelected";
		//tabRef.style.backgroundColor = "white";
		tabRel.className = "tabNotSelected";
		//tabRel.style.backgroundColor = "transparent";
		tabSpec.className = "tabNotSelected";
		tabRev.className = "tabNotSelected";
		//tabSpec.style.backgroundColor = "transparent";
		//divs
		tabSpecDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "openDiv";
		tabRevDiv.className = "blockDiv";
	}
	else if(tabId_ == "revTab"){
		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";
		tabRevDiv.className = "openDiv";
		tabRefDiv.className = "blockDiv";
		cmTagAndLink('Reviews','Product Detail Page', null, null, null);
		location.href="#reviews";
	}
	
}

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;
	dropmenuobj.style.top = top + bufferTop ;
	//alert(dropmenuobj.style.left);
	//alert(dropmenuobj.style.top);
	//alert(dropmenuobj.style.top);
	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 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("+"," ");
			}	
			if(queryN25.indexOf("%2B") >= 0)
				queryN25 = unescape(queryN25);
			document.searchResultsSearch.N25.value = queryN25;
			if(searchterm != "" && queryN4 != "")
			{
				if(queryN4.indexOf("%2B") >= 0)
					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.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);
		  		 	}
		  		 		 	
	   	 }
   }	
}

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";
	   	 }
   }	
}

//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 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;

  // If not the current column, hide the up/down arrows, show none arrow
  if (tblEl.lastColumn != null && tblEl.lastColumn != col){ 
	try{
	    document.getElementById((tblEl.lastColumn+1) + "sortArrowNone" + table).style.visibility="visible";
	}catch(err){}
	
	//document.getElementById((tblEl.lastColumn+1) + "sortArrowUp" + table).style.visibility="hidden";
	//document.getElementById((tblEl.lastColumn+1) + "sortArrowDown" + table).style.visibility="hidden";
  }

  // 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];

  //hide arrow for none sorting if existing
  try{
    document.getElementById((col+1) + "sortArrowNone" + table).style.visibility="hidden";
  }catch(err){}
  
  
  // Display the correct arrow for the sort direction
  if(tblEl.reverseSort[col] == rev){    
	//document.getElementById((col+1) + "sortArrowUp" + table).style.visibility="visible";
	//document.getElementById((col+1) + "sortArrowDown" + table).style.visibility="hidden";
  }
  else{
	//document.getElementById((col+1) + "sortArrowUp" + table).style.visibility="hidden";
	//document.getElementById((col+1) + "sortArrowDown" + table).style.visibility="visible";
  }

  // 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!="" && 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){}
  }
 
  // If last sorted column is not the current column, hide the up/down arrows, show none arrow
  if (tblEl.lastColumn != null && tblEl.lastColumn != col){ 
 
	try{
	    document.getElementById((tblEl.lastColumn+1) + "sortArrowNone" + table).style.display="";
	}catch(err){}
	
	document.getElementById((tblEl.lastColumn+1) + "sortArrowUp" + table).style.display="none";
	document.getElementById((tblEl.lastColumn+1) + "sortArrowDown" + table).style.display="none";
  }

  // 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];

  //hide arrow for none sorting if existing
  try{
    document.getElementById((col+1) + "sortArrowNone" + table).style.display="none";
  }catch(err){}
  
  
  // Display the correct arrow for the sort direction
  if(tblEl.reverseSort[col] == rev){    
	document.getElementById((col+1) + "sortArrowUp" + table).style.display="";
	document.getElementById((col+1) + "sortArrowDown" + table).style.display="none";
  }
  else{
	document.getElementById((col+1) + "sortArrowUp" + table).style.display="none";
	document.getElementById((col+1) + "sortArrowDown" + table).style.display="";
  }

  // 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){}
  }
 
  // If last sorted column is not the current column, hide the up/down arrows, show none arrow
  if (tblEl.lastColumn != null && tblEl.lastColumn != col){ 
 
	try{
	    document.getElementById((tblEl.lastColumn+1) + "sortArrowNone" + table).style.display="";
	}catch(err){}
	
	document.getElementById((tblEl.lastColumn+1) + "sortArrowUp" + table).style.display="none";
	document.getElementById((tblEl.lastColumn+1) + "sortArrowDown" + table).style.display="none";
  }

  // 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];

  //hide arrow for none sorting if existing
  try{
    document.getElementById((col+1) + "sortArrowNone" + table).style.display="none";
  }catch(err){}
  
  
  // Display the correct arrow for the sort direction
  if(tblEl.reverseSort[col] == rev){    
	document.getElementById((col+1) + "sortArrowUp" + table).style.display="";
	document.getElementById((col+1) + "sortArrowDown" + table).style.display="none";
  }
  else{
	document.getElementById((col+1) + "sortArrowUp" + table).style.display="none";
	document.getElementById((col+1) + "sortArrowDown" + table).style.display="";
  }

  // 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()
{
  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 submitRefinement(command, refinementNumber) 
{   
	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].indexOf("refinementValue") < 0 )
				{
					if (i==0)
					{
						url = url + '?' + qsList[i];
					}
					else
					{
						url = url +  '&' + qsList[i];
					}
				}else{
				
					if (i==0)
					{ 
						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;
				}
			}
			
			location.href=url;
			return;
	} 
}
 
	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.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 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; 
			}						               		
		}
		targetElement.style.visibility = 'visible';   
	}
