MM_preloadImages('/images/price_topbar2.gif', '/images/price_leftgraybar.gif', '/images/engineer.gif', '/images/engineer2.gif', '/images/sectionA.gif', '/images/sectionA2.gif', '/images/sectionB.gif', '/images/sectionB2.gif', '/images/sectionC.gif', '/images/sectionC2.gif', '/images/sectionD.gif', '/images/sectionD2.gif', '/images/sectionE.gif', '/images/sectionE2.gif', '/images/sectionF.gif', '/images/sectionF2.gif', '/images/sectionG.gif', '/images/sectionG2.gif', '/images/sectionH.gif', '/images/sectionH2.gif', '/images/sectionI.gif', '/images/sectionI2.gif', '/images/sectionJ.gif', '/images/sectionJ2.gif', '/images/sectionss.gif', '/images/sectionss2.gif', '/images/login.gif', '/images/feedback.gif', '/images/newsletter_icon.gif', '/images/download_center.gif');

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function g_SubmitSearch()
{   
	// process only the Enter key
	if (event.keyCode == 13)
	{
		event.returnValue=false;
        event.cancel = true;
		document.getElementById('TopPage1_submitBtn').click();
	}
}//SubmitSearch

function g_OpenPriceMediaPopUpWithSpeedSelection(strPath){								
	
	var selectSpeed, i, radioSpeed;		
	
		
	radioSpeed = document.forms[0].speed;
		
	if(radioSpeed="undefined")
	{
		selectSpeed = "128";
	}
	else
	{
		for (i = 0 ; i<radioSpeed.length;i++){
			if(radioSpeed[i].checked){
				selectSpeed = radioSpeed[i].value;
				break;
			}				
		}		
	}
	
	g_OpenPriceMediaPopup(strPath + selectSpeed);									
	
}//submitVideo

function g_OpenPriceMediaPopUpWithSpeedSelectionWeb(strPath){								
	
	var selectSpeed, i, radioSpeed;		
	
		
	radioSpeed = document.forms[0].speed;
		
	if(radioSpeed="undefined")
	{
		selectSpeed = "128";
	}
	else
	{
		for (i = 0 ; i<radioSpeed.length;i++){
			if(radioSpeed[i].checked){
				selectSpeed = radioSpeed[i].value;
				break;
			}				
		}		
	}
	
	g_OpenPriceMediaPopupWeb(strPath + selectSpeed);
	
}//submitVideo

function g_OpenTrainingModule(link){
	TMWindow=window.open('/content/flash/ptm/ptm.asp?Section=' + link,'PTM','width=977,height=540');	
	TMWindow.focus();
	TMWindow.moveTo(0,0);
	//newWindow.location.href = link;
}
function g_OpenSendAFriendPopup(link){
	SAFWindow=window.open(link,'SAF','width=680,height=450');	
	SAFWindow.focus();
	//SAFWindow.moveTo(0,0);
}

function g_OpenPriceMediaPopup(link){
	//alert(link);
	//For Live site
	//PMEWindow = window.open("http://64.254.148.130/media/" + link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	
	//For staging site
	//PMEWindow = window.open("http://stage.price-hvac.com/media/" + link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	
	//localhost
	PMEWindow = window.open("/media/" + link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	if (PMEWindow == null)
		return false;
	PMEWindow.focus();		
	//PMEWindow.moveTo(0,0);
	return true;
}
function g_OpenPriceMediaPopupWeb(link){
	PMEWindow = window.open("/media/" + link,'PME','toolbar=no,scrollbars=yes,width=750,height=885');
	if (PMEWindow == null)
		return false;
	PMEWindow.focus();		
	return true;
}

function g_OpenPriceMediaPopup2(link){
	PMEWindow = window.open(link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	if (PMEWindow == null)
		return false;
	PMEWindow.focus();		
	//PMEWindow.moveTo(0,0);
	return true;
}
function g_OpenPriceMediaPopup3(link){
	//Live Site
	//PMEWindow = window.open("http://64.254.148.130/" + link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	//Staging Site
	//PMEWindow = window.open("http://stage.price-hvac.com/" + link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	//localhost
	PMEWindow = window.open(link,'PME','toolbar=no,scrollbars=yes,width=490,height=700');
	
	
	if (PMEWindow == null)
		return false;
	PMEWindow.focus();		
	//PMEWindow.moveTo(0,0);
	return true;
}
function g_OnCountryListChange(ddlistCountry){
	test = document.getElementById('txtBoxBusinessNo');
	intSelectedCountry = ddlistCountry.value;
	ddlistProvince=document.getElementById('ddlistProvince');
	if(ddlistProvince){
		if(intSelectedCountry > 2)	
			ddlistProvince.selectedIndex = 1;
		//else
		//	ddlistProvince.selectedIndex = 0;
	}
	
}

function g_ToggleSearchResult(section, imgSwapImageID, imgNone, imgBlock){
	divToggleSection = eval(section + ".style");
	if(divToggleSection.display == '' || divToggleSection.display == 'block'){
		adjustHeight(-150);
		divToggleSection.display = 'none';	
		MM_swapImage(imgSwapImageID, '', imgNone, 1);				
	}
	else{
		adjustHeight(150);
		divToggleSection.display = 'block';	
		MM_swapImage(imgSwapImageID, '', imgBlock, 1);						
	}

	
}//g_ToggleSearchResult

function g_ToggleImageOnMouseOverAndOut(section, imgSwapImageID, imgOver, imgOut){
	divToggleSection = eval(section + ".style");
	if(divToggleSection.display == '' || divToggleSection.display == 'block'){	
		MM_swapImage(imgSwapImageID, '', imgOver, 1);				
	}
	else{		
		MM_swapImage(imgSwapImageID, '', imgOut, 1);						
	}
}//g_ToggleSearchResult


function g_SetRowBackgroundColor(colID1, colID2, color){
	if (document.getElementById){
		var nodeObj1 = document.getElementById(colID1);
		var nodeObj2 = document.getElementById(colID2);
		nodeObj1.style.backgroundColor = color;   
		nodeObj2.style.backgroundColor = color;  
	}//if			
}//setRowBg

function hideUnhide2(section){
	if(eval(section + ".style.display==''") || eval(section + ".style.display=='block'")){
		eval(section + ".style.display='none';");					
	}
	else{
		eval(section + ".style.display='block';");							
	}
}//hideUnhide2

function g_ReplaceHrefAnchor(strURL, strReplaceString){
	rExp = /\#.*/gi;
	strURL += strReplaceString;
	return strURL.replace(rExp, strReplaceString);	
}

function g_intDetectFlashJS(){
	if(navigator.plugins && navigator.plugins.length){
		x = navigator.plugins["Shockwave Flash"]
		if(x)
			return 1;
		if(navigator.plugins["Shockwave Flash 2.0"])
			return 1;	
	}
	else if(navigator.mimeTypes && navigator.mimeTypes.length){
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			return 1;
	}
	return 0;
}

function g_RedirectToURL(strURL){
	window.location.href = strURL;
}

function g_AddToFavorites(strURL, strPageName){
	if (window.external)
		window.external.AddFavorite(strURL, strPageName) 
	else
		alert("Sorry! Your browser doesn't support this function.");
}

/* ======================== obsolete ======================= */

/*
function g_DisableSubmitAfterValidate(strElementName){
	if (typeof(Page_ClientValidate) == 'function') { 
		if (Page_ClientValidate() == false) { return false; }
	} 
	btnSubmit = document.forms[0].elements(strElementName);
	btnSubmit.value = "Please wait..."
	btnSubmit.disabled = true;
	theform = document.forms[0];
	theform.submit();
}	
*/
function submitVideo2(strPath)
{
	open("/media/" + strPath + "","PME","toolbar=no,scrollbars=yes,width=490,height=700");
}//submitVideo2
/*
function mmLoadMenus() {
  if (window.mm_menu_1102145645_0) return;
  window.mm_menu_1102145645_0 = new Menu("root",230,18,"Arial, Verdana, Helvetica, sans-serif",12,"#ffffff","#666666","#003366","#ffffff","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_1102145645_0.addMenuItem("Engineering&nbsp;Guide","window.open('/catalog/EG_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;A: Linear Diffusers and Grilles","window.open('/catalog/A_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;B: Ceiling Component Diffusers","window.open('/catalog/B_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;C: Ceiling Diffusers","window.open('/catalog/C_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;D: Grilles and Registers","window.open('/catalog/D_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;E: Specialized Environments","window.open('/catalog/E_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;F: Terminal Units","window.open('/catalog/F_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;G: Fire-Rated Diffusers","window.open('/catalog/G_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;H: Security Products","window.open('/catalog/H_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;I: Underfloor Products","window.open('/catalog/I_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;J: Displacement Ventilation","window.open('/catalog/J_all/default.aspx', '_top');");
  mm_menu_1102145645_0.addMenuItem("Section&nbsp;SS: Stainless Steel","window.open('/catalog/SS_all/default.aspx', '_top');");
   mm_menu_1102145645_0.hideOnMouseOut=true;
   mm_menu_1102145645_0.menuBorder=0;
   mm_menu_1102145645_0.menuLiteBgColor='#ffffff';
   mm_menu_1102145645_0.menuBorderBgColor='#cccccc';
   mm_menu_1102145645_0.bgColor='#cccccc';
   
  window.mm_menu_1102145437_1 = new Menu("root",116,18,"Arial, Verdana, Helvetica, sans-serif",12,"#ffffff","#666666","#003366","#ffffff","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_1102145437_1.addMenuItem("Training&nbsp;Modules","window.open('/media/trainingModule.aspx', '_top');");
  mm_menu_1102145437_1.addMenuItem("Virtual&nbsp;Tours","window.open('/media/virtualTour.aspx', '_top');");
  mm_menu_1102145437_1.addMenuItem("Product&nbsp;Videos","window.open('/media/productVideo.aspx', '_top');");
  mm_menu_1102145437_1.addMenuItem("Smoke&nbsp;Test&nbsp;Videos","window.open('/media/smokeTestVideo.aspx', '_top');");
   mm_menu_1102145437_1.hideOnMouseOut=true;
   mm_menu_1102145437_1.menuBorder=0;
   mm_menu_1102145437_1.menuLiteBgColor='#ffffff';
   mm_menu_1102145437_1.menuBorderBgColor='#cccccc';
   mm_menu_1102145437_1.bgColor='#cccccc';   
   
   
  window.mm_menu_1102144532_0 = new Menu("root",183,18,"Arial, Verdana, Helvetica, sans-serif",12,"#ffffff","#666666","#003366","#ffffff","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);  
  mm_menu_1102144532_0.addMenuItem("Catalog","window.open('/literature/default.aspx#catalog', '_top');");
  mm_menu_1102144532_0.addMenuItem("Color&nbsp;Charts","window.open('/literature/default.aspx#colorcharts', '_top');");
  mm_menu_1102144532_0.addMenuItem("Engineering&nbsp;Guides","window.open('/literature/default.aspx#engineeringguides', '_top');");
  mm_menu_1102144532_0.addMenuItem("Installation&nbsp;and&nbsp;Service&nbsp;Manuals","window.open('/literature/default.aspx#installationandservicemanuals', '_top');");
  mm_menu_1102144532_0.addMenuItem("Single&nbsp;Page&nbsp;Ads/Ad&nbsp;Slicks","window.open('/literature/default.aspx#singlepageadsadslicks', '_top');");  
  mm_menu_1102144532_0.addMenuItem("Videos","window.open('/literature/default.aspx#videos', '_top');");
  
   mm_menu_1102144532_0.hideOnMouseOut=true;
   mm_menu_1102144532_0.menuBorder=0;
   mm_menu_1102144532_0.menuLiteBgColor='#ffffff';
   mm_menu_1102144532_0.menuBorderBgColor='#cccccc';
   mm_menu_1102144532_0.bgColor='#cccccc';
  window.mm_menu_1102145930_2 = new Menu("root",153,18,"Arial, Verdana, Helvetica, sans-serif",12,"#ffffff","#666666","#003366","#ffffff","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_1102145930_2.addMenuItem("Price&nbsp;Digital&nbsp;Catalog&nbsp;5.0","window.open('/software/pricedigitalcatalog.aspx', '_top');");
  mm_menu_1102145930_2.addMenuItem("Price&nbsp;Smoke&nbsp;Test&nbsp;CD&nbsp;1.0","window.open('/software/smoketest.aspx', '_top');");
  mm_menu_1102145930_2.addMenuItem("Price&nbsp;Video&nbsp;CD&nbsp;2.0","window.open('/software/VCD.aspx', '_top');");
  mm_menu_1102145930_2.addMenuItem("Price&nbsp;Training&nbsp;Module","window.open('/software/PTM.aspx', '_top');");
  mm_menu_1102145930_2.addMenuItem("Quick&nbsp;Select&nbsp;for&nbsp;Terminals","window.open('/software/quickselectforterminals.aspx', '_top');");
  mm_menu_1102145930_2.addMenuItem("PriceCAD&nbsp;CD","window.open('/software/CAD.aspx', '_top');");
  mm_menu_1102145930_2.addMenuItem("Quick&nbsp;Pricer","window.open('/software/default.aspx', '_top');");
   mm_menu_1102145930_2.hideOnMouseOut=true;
   mm_menu_1102145930_2.menuBorder=0;
   mm_menu_1102145930_2.menuLiteBgColor='#ffffff';
   mm_menu_1102145930_2.menuBorderBgColor='#cccccc';
   mm_menu_1102145930_2.bgColor='#cccccc';


  window.mm_menu_1102144533_0 = new Menu("root",161,18,"Arial, Verdana, Helvetica, sans-serif",12,"#ffffff","#666666","#003366","#ffffff","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_1102144533_0.addMenuItem("Overview","window.open('/About/default.aspx', '_top');");
  mm_menu_1102144533_0.addMenuItem("History","window.open('/About/history.aspx', '_top');");
  mm_menu_1102144533_0.addMenuItem("Values","window.open('/About/values.aspx', '_top');");
  mm_menu_1102144533_0.addMenuItem("President's Message","window.open('/About/messages.aspx', '_top');");
   mm_menu_1102144533_0.hideOnMouseOut=true;
   mm_menu_1102144533_0.menuBorder=0;
   mm_menu_1102144533_0.menuLiteBgColor='#ffffff';
   mm_menu_1102144533_0.menuBorderBgColor='#cccccc';
   mm_menu_1102144533_0.bgColor='#cccccc';

  mm_menu_1102145930_2.writeMenus();
} // mmLoadMenus()
*/
function hideUnhide(section,imageID,frameID){
	if(eval(section + ".style.display==''") || eval(section + ".style.display=='block'")){
		eval(section + ".style.display='none';");
		MM_swapImage(imageID,'','/images/expand.gif',1);		
	}
	else{
		eval(section + ".style.display='block';");
		MM_swapImage(imageID,'','/images/collapse.gif',1);			
	}			
	rExp = /viewvideo.aspx/gi;  //create a regular expression to search whether we are currently on the viewvideo page
	results = parent.window.location.href.search(rExp);
	//alert(results);
	if (results > 0 ){
		if(frameID.length > 0){	
			var browserName=navigator.appName; 
			if (browserName=="Netscape")
				parent.document.getElementById(frameID).height =document.getElementById(frameID).contentDocument.height + 10;
			else
				parent.document.getElementById(frameID).height =parent.document.frames('video').document.body.scrollHeight;				
		}
	}
}

function hide(section){
	if(eval(section + ".style.display==''") || eval(section + ".style.display=='block'")){
		eval(section + ".style.display='none';");						
	}
}	
function hideAll(section,imageID,show){	
	rExp = /viewvideo.aspx/gi;  //create a regular expression to search whether we are currently on the viewvideo page
	results = parent.window.location.href.search(rExp);
	//alert(results);
	if (results < 0 ){//means we're at default.aspx
		eval(section + ".style.display='none';");
		MM_swapImage(imageID,'','/images/expand.gif',1);
	}//if
	/*
	eval(section + ".style.display='" + show + "';");
	if (show=='none')
		MM_swapImage(imageID,'','/images/expand.gif',1);					
	else
		MM_swapImage(imageID,'','/images/collapse.gif',1);					
	*/
}

String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function()
{
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function()
{
	return this.replace(/\s+$/,"");
}