// General stuff
top.name = "CPC";
top.focus();


// Browser compatibility functions
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;


// Called from search.asp
function switchOptions(stype) {
  reset_boxes();

  if (stype=="advanced") {
//	positionLayer('advOptions',162,398);
//	positionLayer('formButts',162,760);
	positionLayer('advOptions',0,2);
	positionLayer('formButts',0,2);
	showLayer('advOptions');
	showLayer('advIntro');
	showLayer('advNav');
	
	showLayer('formButts');
	hideLayer('quickOptions');
	hideLayer('quickIntro');
	hideLayer('quickNav');

	//location.href="advanced-search-e.asp"
  } else {
//	positionLayer('quickOptions',162,398);
//	positionLayer('formButts',162,502);
	positionLayer('quickOptions',0,2);
	positionLayer('formButts',0,2);
	showLayer('quickOptions');
	showLayer('quickIntro');
	showLayer('quickNav');
	showLayer('formButts');
	hideLayer('advOptions');
	hideLayer('advIntro');
	hideLayer('advNav');
  }
}

function hideLayer(lay) {
//	if (ie4) {document.all[lay].style.visibility = "hidden";}
	if (ns4) {document.layers[lay].visibility = "hidden";}
	if (ie4) {document.all[lay].style.display = "none";}
//	if (ns4) {document.layers[lay].display = "none";}
	if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showLayer(lay) {
//	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4) {document.layers[lay].visibility = "show";}
	if (ie4) {document.all[lay].style.display = "block";}
//	if (ns4) {document.layers[lay].display = "block";}
	if (ns6) {document.getElementById([lay]).style.display = "block";}
}
function positionLayer(lay,x,y) {
	if (ie4) {document.all[lay].style.left=x; 
			  document.all[lay].style.top=y;}
	if (ns4) {document.layers[lay].left=x;
			  document.layers[lay].top=y;}
	if (ns6) {document.getElementById([lay]).style.left=x;
			  document.getElementById([lay]).style.top=y;}
}

function reset_boxes(){
	for (i = 0;  i < document.search.checkboxlist.length;  i++) {
		document.search.checkboxlist[i].checked = false;
		highlight(document.search.checkboxlist[i],'TR')
	}
}

// Called from search.asp
function GetCheckedBoxes() 
{
	var checkSelected = false;
	var checkBoxList = "";
	for (i = 0;  i < document.search.checkboxlist.length;  i++)
	{
		if (document.search.checkboxlist[i].checked) 
		{
			checkBoxList = checkBoxList + document.search.checkboxlist[i].value + ",";
		}
	}
	//Remove last comma from checkBoxList
	checkBoxList = checkBoxList.substring(0,checkBoxList.length-1)
	document.search.CheckBoxes.value = checkBoxList;
//	alert(checkBoxList);

}

// Used to highlight rows or table areas. Can be called from Search screens
// to emphasize the fact that either Postal Code or Address has to be entered.
function highlight(inpObj,what) {
//return true;
	var E = inpObj;
	while (E.tagName!=what)
			{E=E.parentElement;}
	
/*	if (E.className == "RR_HIGHLIGHT") 
		E.className = "RR_NORMAL"
	else
		E.className = "RR_HIGHLIGHT"
*/
	if (!inpObj.checked) 
		E.className = "RR_NORMAL"
	else
		E.className = "RR_HIGHLIGHT"
}


function mapIt(street, city, province, lang, postalcode)
{

	var queryString = "/tools/POL/Mapquest/advantage.asp?transaction=locMap&country=ca&template=map&address=" + street + "&city=" + city + "&stateProvince=" + province + "&lang=" + lang + "&postalcode=" + postalcode;

//	var queryString = "/tools/POL/Mapquest/advantage.asp?transaction=locMap&country=ca&template=map&address=" + street + "&city=" + city + "&stateProvince=" + province + "&lang=" + lang;
//	var queryString = "/scripts/mqinterconnect.exe?link=map-" + lang + "&streetaddress=" + street + "&city=" + city + "&state=" + province + "&country=canada";
//	var queryString = "/scripts/mqinterconnect.exe?link=map&streetaddress=" + street + "&city=" + city + "&state=" + province + "&country=canada";
/*	alert(lang);
	alert(street);
	alert(city);
	alert(province);
	alert(queryString);
*/	
	window.open(queryString,"OutletMap","height=645,width=680,scrollbars,resizable");
}

function retrace() {
		history.back()
}
function printPage() {
		window.print();
}



