function oProduct(pCode)
  {
   location.href='/basf/agprocan/agsolutions/WebASProd.nsf/WebProductProfile/'+pCode+'?OpenDocument';
  }

function getMSDS(useServlet)
  {
   var cSelect=document.getElementById("SelectMSDS");
   var curValue=cSelect.options[cSelect.selectedIndex].value;
   if (curValue=="")
      { 
       cSelect=document.getElementById("SelectPL");
       curValue=cSelect.options[cSelect.selectedIndex].value;
      }
      
   if (curValue!="") {   
	if(useServlet == "download" ){	
		downloadMSDS(curValue) 
		}
	else{
			openMSDS(curValue) 
		}
	  }
     }
     

function openMSDS(oValue)
  { 
    var t=oValue.split("|");
   location.href='./WebAttachments/'+t[0]+'/$File/'+t[1];
  }
   
function openWhereToBuy(region, language, tipe)
{	var t;
	var variety = '';
  


	if (tipe == 'Public')
	{	t=document.getElementById('DocCode');
		var docCode = t.value;	
	}
	else if (tipe == 'CC')
	{	t=document.getElementById('Variety');
		variety = t.options[t.selectedIndex].value;
		variety = '&VY=' + variety;
	}
  
  	 t = document.getElementById('PostalCode');
  	postalCode = t.value
	
	
	//check for valid Postal Code 
	var objRegExp  =/^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i;
	if (objRegExp.test(postalCode))
	{	t=document.getElementById('Distance');
  		var distance=t.options[t.selectedIndex].text;
		
		if (tipe == 'Public')
		{ 	location.href ='/basf/agprocan/agsolutions/WebAsProd.nsf/WebWhereToBuy?OpenNavigator&PL=' + postalCode + '&DC=' + docCode + '&Dist=' + distance + '&RN=' + region + '&LN=' + language		
		}
		else
		{ 	location.href ='/basf/agprocan/agsolutions/WebAsProd.nsf/WebWhereToBuyClearfield?OpenNavigator&PL=' + postalCode + '&Dist=' + distance + '&RN=' + region + '&LN=' + language + '&TP=' + tipe + variety
		}
 	}
	else
	{     showPopFrame('popUpDef', 400, 200, '/basf/agprocan/agsolutions/WebAsProd.nsf/WebInvalidPC?OpenForm&color=DG' );
 	}

}


function downloadMSDS(oValue)
  { 
    var t=oValue.split("|");
    
    var servletPath = document.getElementById("servletPath").value;
	servletPath += "&key=" + t[0] + "&filename=" + t[1];
	//alert(servletPath);
   location.href= servletPath
  }


function getMSDSPopup(useServlet)
  {
   var cSelect=document.getElementById("SelectMSDS");
   var curValue=cSelect.value;
      
   if (curValue!="") {   
	if(useServlet == "download" ){	
		downloadMSDSPopup(curValue) 
		}
	else{
			openMSDSPopup(curValue) 
		}
	  }
     }

function getLabelPopup(useServlet)
  {
     cSelect=document.getElementById("SelectPL");
     curValue=cSelect.value;
     
   if (curValue!="") {   
	if(useServlet == "download" ){	
		downloadMSDSPopup(curValue) 
		}
	else{
			openMSDSPopup(curValue) 
		}
	  }
}
     

function downloadMSDSPopup(oValue)
  { 
    var t=oValue.split("|");
    
    var servletPath = document.getElementById("servletPath").value;
	servletPath += "&key=" + t[0] + "&filename=" + t[1];
	//alert(servletPath);
	parent.hidePop('popUpDef');
   parent.location.href= servletPath
  }

function openMSDSPopup(oValue)
  { 
    var t=oValue.split("|");
    var webAttachmentPath = document.getElementById("webAttachmentPath").value;
    parent.hidePop('popUpDef');
   parent.location.href= webAttachmentPath + t[0]+'/$File/'+t[1];
  }

function resetTitleOverlay()
   {
    sChange('msdsOverlay','display','none');
    sChange('productOverlay','display','none');
    
    t=document.getElementById('SelectMSDS');
    t.selectedIndex=0;
    
    t=document.getElementById('SelectPL');
    t.selectedIndex=0;
    
    
   }


function getMSDSLabelPopup(useServlet)
  {
   var cSelect=document.getElementById("pop");
   var curValue=cSelect.value;
      
   if (curValue!="") {   
	if(useServlet == "download" ){	
		//downloadMSDS(curValue) 
		downloadMSDSPopup(curValue) 
		}
	else{
			//openMSDS(curValue) 
			openMSDSPopup(curValue) 
		}
	  }
     }

function popupMSDSFrame(){
	var cSelect=document.getElementById("SelectMSDS");
   var curValue=cSelect.options[cSelect.selectedIndex].value;
   if (curValue=="")
      { 
       cSelect=document.getElementById("SelectPL");
       curValue=cSelect.options[cSelect.selectedIndex].value;
      }
      if(curValue != "" ) {
      
//	showPopFrame('popUpDef', 240, 100, '/basf/agprocan/agsolutions/WebASProd.nsf/WebDownloadPopupURL?OpenForm&pop=' +curValue )
	}
}

function openRelatedFile()
  {
   var t=document.getElementById('relatedFileSelect');
   var t2=t.options[t.selectedIndex].value;
   if (t2!="")(window.open(t2,'_blank'))
  }
 
 function perDownloadMSDSLabel(pageLink)
 	{
 	parent.hidePop('popUpDef');
 	parent.location.href=pagelink;
 	}

