﻿
var sTagRoot = 'ctl00_cphMaster_'

function GetKeyPressedCode(e) {
	var evt;
	evt = e || window.event;
	return evt.which || evt.keyCode;
}

function MyGetElementById(sID) {
	var oObj = document.getElementById(sID)
	if (oObj == null) {
		sID = sTagRoot + sID
		oObj = document.getElementById(sID)
	}
	//            alert(sID + " : " + oObj)
	return oObj;
}

function GetTagID(sID) {
	var oObj = document.getElementById(sID)
	if (oObj == null) {
		sID = sTagRoot + sID
		oObj = document.getElementById(sID)
	}
	return sID;
}


function MyGetElementByPartialId(partialid, tagname) {

	// Find an element by it's ID even if the ID has been extended by Master Pages or other means
	var re = new RegExp(partialid, 'g');
	if (tagname == '' || tagname == null) tagname = '*';
	var elems = document.getElementsByTagName(tagname), i = 0, el;
	while (el = elems[i++]) {
		if (el.id.match(re)) {
			return el;
			break;
		}
	}
	// If didn't get it by limiting to tagname, try 'em all
	if (tagname != "*") {
		tagname = "*";
		var elems = document.getElementsByTagName(tagname), i = 0, el;
		while (el = elems[i++]) {
			if (el.id.match(re)) {
				return el;
				break;
			}
		}
	}
	return null;
}

function ShowBalloon(id, url, alt) {

	try {
		var img = MyGetElementById(id + '_balloon')
		if (url) {
			img.src = url;
			DisplayLayer(1, id);
		}
		else
			DisplayLayer(0, id);
	}
	catch (ex) { }
}

// hides masthead and changes class to add background with curves to top of content area
function hideMasthead() {
    $("#ctl00_btm").addClass("hide-masthead");
    $("#ctl00_ctl00_btm").addClass("hide-masthead");
    $("#mainContent").addClass("hide-masthead");
}




var sPP4Link = "";
var sPP6Link = "";
var sPP8Link = "";
var sPP10Link = "";

function SetPPButton(sType, sCode) {
  if (sType == "4") {
    sPP4Link = "../../ProductDesc.aspx?code=" + escape(sCode) + "&type=4&eq=&key=it";
  }  else if (sType == "6") {
    sPP6Link = "../../ProductDesc.aspx?code=" + escape(sCode) + "&type=4&eq=&key=it";
  } else if (sType == "8") {
    sPP8Link = "../../ProductDesc.aspx?code=" + escape(sCode) + "&type=4&eq=&key=it";
  } else if (sType == "10") {
    sPP10Link = "../../ProductDesc.aspx?code=" + escape(sCode) + "&type=4&eq=&key=it";
  }
  //alert(sPP10Link);
}

function AddPPButtonClick(sType) {
  //alert( sType + " ; " + sPP6Link + " : " + sPP8Link + " : " + sPP10Link);
  if (sPP4Link != "" && sType == "4") {
    document.location.href = sPP4Link;
  } else if (sPP6Link != "" && sType == "6") {
    document.location.href = sPP6Link;
  } else if (sPP8Link != "" && sType == "8") {
    document.location.href = sPP8Link;
  } else if (sPP10Link != "" && sType == "10") {
    document.location.href = sPP10Link;
  } else {
    alert("Please select the color of your Power-Pole Anchor");
  }
 }



 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=/";
 }

 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);
 }

