/*****************CountryStore********************This function has been used to act as an Object container for each Region's list of countries. The internal function "addCountry" createsa new Array for each one.***********************************************/var sCountry;function CountryStore(){	this.l = 0;	this.Countries = new Array();	this.addCountry = function () {		//Define an associative array with all the relevant data for this country; 		this.Countries[this.l++] = 		{			Name:		arguments[0],		 	Location:	arguments[1],		 	State:		arguments[2],		 	City:			arguments[3],			address:	arguments[4],			address1:	arguments[5],			zip:			arguments[6],			Email:		arguments[7],			Phone:		arguments[8],			Fax:			arguments[9],			StType:		arguments[10] 		}	}}/*****getAllCountriesForRegion*****Given the name of a region, eg "Europe", this function finds the corresponding Object called"Europe". It then loops through all the Countries stored within this Object and builds a new table for them all to display.***********************************************/function getAllCountriesForRegion( region ){	var currentCountryList;	//Does this region have any countries?	if ( typeof ( currentCountryList = eval( region ) ) != "object")	{		return alert('Not found');	}	strContent = new String("<table width=\"100%\"><tr><th>Name</th><th>Area</th><th>Population</th></tr>");	for (var i=0; i < currentCountryList.l; i++)	{		strContent += "<tr><td><a href=\"0/" + currentCountryList.Countries[i].Location +  "?OpenDocument\">" + 		currentCountryList.Countries[i].Name + "</a></td>";		strContent += "<td>"+currentCountryList.Countries[i].State+"</td>"		strContent += "<td>"+currentCountryList.Countries[i].City+"</td></tr>";	}	strContent +="</table>";	return strContent;}function getAllCitiesByState( varCountry, varState, varStoreType ){	var currentCountryList;	var countStores = 0;	errorMessage = "<br>There are no stores in the location you selected. Please select another location.<br>";	strContent = new String("")	strContent +=  "<div id=\"contentTitle\" style = \"padding-left: 0px;\">"  //"<td colspan=\"9\" height=\"28\" width=\"478\">" //<font color=\"green\" face=\"verdana\" size=\"+1\">"	strContent += varState	strContent += "</div></td>" // "</font></td><br><br>"	//Does this region have any countries?	var varExist = true;	if ( varCountry == "USA") {		if ("undefined" == typeof(USA) ) {			varExist = false;		}	} else {		if ("undefined" == typeof(CANADA) ) {			varExist = false;		}	}			if ( !varExist ) {		strContent += errorMessage;		strContent +="</table>";		strContent += "</font>"		return strContent;			}		if ( typeof ( currentCountryList = eval( varCountry) ) != "object")	{		return alert('Not found');	}	if (varCountry == "USA") {		fieldString = USAString 	} else {		fieldString = CanadaString 	}	varStateCode = getStateCode( fieldString, varState )	var tmpCity  = "";	var tmpStoreType = document.getElementById("selStoreType")		for (var i=0; i < currentCountryList.l; i++)	{		if (currentCountryList.Countries[i].State==varStateCode ) {			if (tmpCity != currentCountryList.Countries[i].City ) {				tmpType = true;				if (varStoreType != "All Stores")  {					if (currentCountryList.Countries[i].StType.indexOf(varStoreType)==-1) {						tmpType = false; }				}				if (tmpType == true) {					tmpCity = currentCountryList.Countries[i].City 					strContent += "<br><a href=\"javascript: getAllStores( selectedCountry , selectedState, "+tmpStoreType.value+", '" + tmpCity + "')\">" + tmpCity + "</a>";					countStores ++;				}			}		}	}		if (	countStores == 0) {		strContent += errorMessage;	}	strContent +="</table>";		strContent += "</font>"	return strContent;}function getAllStores( varCountry, varState, varStoreType, varCity){	var currentCountryList;	var countStores = 0;	//Does this region have any countries?	if ( typeof ( currentCountryList = eval( varCountry) ) != "object")	{		return alert('Not found');	}	if (varCountry == "USA") {		fieldString = USAString 	} else {		fieldString = CanadaString 	}	varStateCode = getStateCode( fieldString, varState )	for (var i=0; i < currentCountryList.l; i++)	{		if (currentCountryList.Countries[i].State==varStateCode ) {			if (currentCountryList.Countries[i].City ==varCity) {							tmpType = true;				if (selectedStoreType  != "All Stores")  {					if (currentCountryList.Countries[i].StType.indexOf(selectedStoreType )==-1) {						tmpType = false; }				}				if (tmpType == true) {							// Call Function to get Store Details					tmpStoreData = currentCountryList.Countries[i];					countStores ++									}			}		}	}	if (countStores == 1 ) {		window.location = "0/" + tmpStoreData.Location + "?Open&SourceBranch=1"	} else {		openDbRelativeURL("StoresLoc?OpenView&Country="+varCountry+"&State="+varState+"&City=" +varCity+"&StoreType=" + varStoreType ) //&Query=" + "(FIELD+Country+Contains+USA)&count=-1");	}	}function getAllStoresByCity( varCountry, varState, varStoreType, varCity){	var currentCountryList;	var countStores = 0;	//Does this region have any countries?	if ( typeof ( currentCountryList = eval( varCountry) ) != "object")	{		return alert('Not found');	}	if (varCountry == "USA") {		fieldString = USAString 	} else {		fieldString = CanadaString 	}	varStateCode = getStateCode( fieldString, varState )	strContent = new String("")	strContent +=  "<div id=\"contentTitle\" style = \"padding-left: 0px;\">" //"<td colspan=\"9\" height=\"28\" width=\"478\">" //<font color=\"green\" face=\"verdana\" size=\"+1\">"	strContent += varCity + ", "+ varState 	strContent += "</div></td>" // "</font></td><br>"	for (var i=0; i < currentCountryList.l; i++)	{		if (currentCountryList.Countries[i].State==varStateCode ) {			if (currentCountryList.Countries[i].City ==varCity) {							tmpType = true;				if (varStoreType != "All Stores")  {					if (currentCountryList.Countries[i].StType.indexOf(varStoreType)==-1) {						tmpType = false; }				}				if (tmpType == true) {							// Call Function to get Store Details					tmpStoreData = currentCountryList.Countries[i];					getStoreDetail(varCountry, varState);					strContent += "<br><a href=\"/na/us/praxairSL.nsf/0/" + tmpStoreData.Location + "?Open&SourceBranch=1\">" + "View Map" + "</a>";					countStores ++										strContent += "<tr><br></td>"				}			}		}	}	strContent +="</table>";		if (countStores == 1 ) {		window.location = "0/" + tmpStoreData.Location	} else {		return strContent;	}}function getStoreDetail(varCountry, varState){	strContent += "<tr>"	strContent += "<td>" // colspan=\"3\" rowspan=\"14\" align=\"left\" height=\"629\" valign=\"top\" width=\"223\"><!-- Start First Column --><font face=\"verdana\" size=\"2\">"	strContent += "<br><b>" + tmpStoreData.Name + "</b>"	if (tmpStoreData.address != "") {		strContent += "<br>" + tmpStoreData.address	}	if (tmpStoreData.address1 != "") {		strContent += "<br>" + tmpStoreData.address1	}	strContent += "<br>" + tmpStoreData.City + ", " + tmpStoreData.State + "  " + tmpStoreData.zip	strContent += "<br>" + varCountry	if (tmpStoreData.Phone != "") {		strContent += "<br>Tel.: " + tmpStoreData.Phone	}	if (tmpStoreData.Fax != "") {		strContent += "<br>Fax: " + tmpStoreData.Fax	}	/*	strContent += "<font color=\"teal\" face=\"verdana\" size=\"-2\">"	var tmpString=tmpStoreData.StType.split(";");	for (var i=0; i < tmpString.length; i++)	{		if (tmpString[i] != "")			strContent += "<br>" + tmpString[i];	}	strContent += "</font>"*/}// Auxiliar functions// *******************************************************************function populateData(varCountry) {	tmpState = document.getElementById("selState");	count= 0;	// Clear the old list (above element 0) 	tmpState.options.length = count; 		if (varCountry == "USA") {		sCountry = "USA"		var varState = getArrayfromString( USAString )	} else if (varCountry == "CANADA") {		sCountry = "CANADA"		var varState = getArrayfromString(CanadaString )	} else {		var varState = new Array("-- Select a State/Province --")	}	for (x in varState)	{		if (count ==0)			{				tmpState.options[count++] = new Option( varState[x], "noSelection" ); 			}		else			tmpState.options[count++] = new Option( varState[x] ); 	}}function populateState() {	tmpState = document.getElementById("selState");	count= 0;	// Clear the old list (above element 0) 	tmpState.options.length = count; 	//var varState = new Array("-- Select a State/Province --")	tmpState.options[count++] = new Option( "-- Select a State/Province --", "noSelection" ); 	var varCountry = new Array( "CANADA", "USA");	for (y in varCountry)	{	if (varCountry[y] == "USA") {		var varState = getArrayfromString( USAString )	} else if (varCountry[y] == "CANADA") {		var varState = getArrayfromString(CanadaString )	} else {		var varState = new Array("-- Select a State/Province --")	}	for (x in varState)	{		//if (count ==0)		//	tmpState.options[count++] = new Option( varState[x], "noSelection" ); 		//else			tmpState.options[count++] = new Option( TrimStr(varState[x]) ); 	}	}}function doSearchForm() {	//var tmpCountry = document.getElementById("selCountry").value	var tmpState = document.getElementById("selState")	var tmpStoreType= document.getElementById("selStoreType").value	var varIndex = tmpState.selectedIndex;	tmpState = tmpState.options[varIndex].text;		var tmpStatus = true;	var tmpErrorMSG = "Please select a State/Province.\n"/*		if ( tmpCountry == "noSelection") {		tmpErrorMSG += " - Select a Country\n";		 tmpStatus = false;	} */	//alert(tmpState)	if (( tmpState == "-- Select a State/Province --") || ( tmpState == "")) {		//tmpErrorMSG += " - Select a State/Province";		 tmpStatus = false;	}	if ( tmpStatus == true) {		tmpCountry = getCountry(tmpState);				openDbRelativeURL("StoresLoc?OpenView&Country="+tmpCountry+"&State="+tmpState+"&StoreType=" + tmpStoreType) //&Query=" + "(FIELD+Country+Contains+USA)&count=-1");	} else {		alert(tmpErrorMSG);		}}// Function to Get Stores from XML Filefunction doStoreSearch(varCountry, varState, varSoreType ) {	divId = "LeftPanelResult"	textExample = '<B>Loading content...</B>'			textReturn = getAllCitiesByState( varCountry, varState, varSoreType )	divControl(1)	document.getElementById(divId).innerHTML = textReturn}function doStoreSearchCity(varCountry, varState, varSoreType, varCity  ) {	divId = "LeftPanelResult"	textExample = '<B>Loading content...</B>'			textReturn = getAllStoresByCity( varCountry, varState, varSoreType, varCity )	divControl(5)	document.getElementById(divId).innerHTML = textReturn}function loadDefaults() {	if (selectedCountry != "") { 	/*		// Country defaults		var tmpCountry = document.getElementById("selCountry")		if (selectedCountry == "USA") {			varIndex = 2; }		else 			{ varIndex = 1; }		tmpCountry .options[varIndex ].selected=true		*/		// State Defaults		//populateData(selectedCountry)		populateState();		var tmpState = document.getElementById("selState")		for (var i=0; i < tmpState.length; i++) { 			if ((tmpState.options[i].text).indexOf(selectedState) !=-1) {				tmpState.options[i].selected=true			}		}		var tmpStoreType = document.getElementById("selStoreType")		dispselectedStoreType = selectedStoreType;		if (selectedStoreType =="Health Care" )			dispselectedStoreType = "Homecare";		for (var i=0; i < tmpStoreType.length; i++) {			if ((tmpStoreType.options[i].text).indexOf(dispselectedStoreType) !=-1) {				tmpStoreType.options[i].selected=true			}		}		if (selectedCity != "") {			doStoreSearchCity(selectedCountry, selectedState, selectedStoreType, selectedCity )		} else {			doStoreSearch(selectedCountry, selectedState, selectedStoreType )		}	}}function getArrayfromString( fieldString ) {	var myArray = fieldString.split(";")	if (sCountry == "USA")		myArray[0] =  "-- Select a State --";		else		myArray[0] = "-- Select a Province/Territory --";		for (i=1;i<myArray.length;i++)	{		//alert(myArray[i]);		valStringSearch = myArray[i].indexOf("|")		myArray[i] = myArray[i].substring(0,valStringSearch)	}	return myArray}function getStateCode( fieldString, varState ) {	valStringSearch = fieldString.indexOf(varState);	valResult = fieldString.substring(valStringSearch)	valStringSearch = valResult.indexOf("|")	valResult = valResult.substring(valStringSearch)	valStringSearch = valResult.indexOf(";")	if (valStringSearch==-1) valStringSearch=3;	valResult = valResult.substring(1,valStringSearch)	return valResult}function flagSelectCountry( varFlag ) {	tmpCountry = document.getElementById("selCountry")	if (varFlag == "canada" ) {		if (tmpCountry.selectedIndex == 2) {			alert("Use the Selection Box at the right to choose the Province.") }		tmpCountry.selectedIndex=2;	} else {		if (tmpCountry.selectedIndex == 1) {			alert("Use the Selection Box at the right to choose the State.") }		tmpCountry.selectedIndex=1;	}}function getCountry(varStateSel) {	var varCountry = new Array( "CANADA", "USA");	var retValue = "";	var varIndex = -1;	for (y in varCountry)	{		if (varCountry[y] == "USA") {			var varState = getArrayfromString( USAString )		} else if (varCountry[y] == "CANADA") {			var varState = getArrayfromString(CanadaString )		} else {			var varState = new Array("-- Select a State/Province --")		}		for (x in varState)		{			//alert(varState[x] + " - " + varStateSel + " - " ) 			if (varState[x].indexOf(varStateSel) !=-1) {				varIndex = y;				}		}	}		if (varIndex == -1) {		alert("Country not found!") 	} else {		retValue = varCountry[varIndex];	}	return retValue;}function goBack( varLevel ) {	history.go(-1)/*	if (varLevel == 1) {		// Return Search Box and hide the map		divControl(4);	} else if (varLevel == 2) {		// Return Search Box and hide the map		divControl(3);		doStoreSearch();	} else if (varLevel == 3) {		// Return Search Box and hide the map		divControl(3);		getAllStoresByCity( varCountry, varState , tmpStoreData.City )	}*/	}function divControl(varDiv) {	//safe function to hide an element with a specified id	if (document.getElementById) { // DOM3 = IE5, NS6		if(varDiv == 1) {			div1 = "LeftPanelStart";			div2 = "LeftPanelResult"			hideshowdiv(div1, false);			hideshowdiv(div2, true);		} else if (varDiv == 2){			div1 =  "SearchPanel" 			div2 = "PanelMap";			hideshowdiv(div1, false);			hideshowdiv(div2, true);		} else if (varDiv == 3){			div1 = "PanelMap";					div2 =  "SearchPanel" 			hideshowdiv(div1, false);			hideshowdiv(div2, true);		} else if (varDiv == 4){			div1 = "LeftPanelResult"					div2 = "LeftPanelStart";			hideshowdiv(div1, false);			hideshowdiv(div2, true);		} else if (varDiv == 5){			div1 = "LeftPanelResult"					div2 = "SearchPanel";			div3 = "LeftPanelStart";						hideshowdiv(div1, true);			hideshowdiv(div2, false);			hideshowdiv(div3, false);					}			}}function hideshowdiv(varDivElemnt, varAction) {	tmpDiv = document.getElementById(varDivElemnt);	if (varAction) {		// Show the div		tmpDiv.style.display = 'block';		tmpDiv.style.display = '';	} else {		// Hide the div		tmpDiv.style.display = 'block';		tmpDiv.style.display = 'none';			}}function TrimStr(inputString) {	// rather than return a non-string, convert the input to a string.	s = inputString.toString();	// the space in the patterns below is important!	// the two patterns mean,	// one or more spaces at the beginning,	// one or more spaces at the end.	s = s.replace(/^ +/, '').replace(/ +$/, '');	// this pattern means, two or more spaces in a row	// note there are two spaces before the plus sign.	innerspace = /  +/;	while (s.match(innerspace))		s = s.replace(innerspace, ' ');	return s;}