	/* 
	******************************************
	  SuckerFish JavaScript for Main Menu
	  Fixes non-standards compliant browsers
	******************************************
	*/

	sfHover = function() {
		if(document.getElementById("mainNav")) {
			var sfEls = document.getElementById("mainNav").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);	


	function showHandsetImage(objID, newImage) {
		var theObj = document.getElementById(objID);
		theObj.src = "_img/blank-trans.png";
		theObj.src = newImage;
	}



	/* 
		Window Open Function
	*/
	var popUpWin = 0;

	function popUpWindow(URLStr, left, top, width, height, centered, scrollbars) {
	
		// if window is already open, close it
		if(popUpWin) {
			if(!popUpWin.closed) popUpWin.close();
		}

		// if we're supposed to center the window, then ignore the left and top values and reset them accordingly
		if (centered && centered > 0) {
			left = (screen.width/2) - (width/2);
			top = (screen.height/2) - (height/2);
		}
		
		// scrollbars
		if (!scrollbars) {
			scrollbars = 0;	
		}
		else {
			scrollbars = 1;	
		}

		// open the window
		popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbars+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
		
		//focus
		popUpWin.focus();
	}



	// Impact Facts - Read Cookie
	function getFlashMessage(affiliate) {
		var cookieName = "impact_" + affiliate;
		var cookieValue = readCookie(cookieName);
		if (cookieValue) {
			return cookieValue;
			// alert("cookie is: " + cookieValue);
		}
		else {
			// alert("returning 0");
			return 0;
		}
	}
	
	// Impact Facts - Set Cookie
	function setFlashMessage(msgNumber, affiliate) {
		var cookieName = "impact_" + affiliate;
		createCookie(cookieName,msgNumber,3650);
		// alert ("msgNumber: " + msgNumber + " | affiliate: " + affiliate);
	}



	function toggleView(objID, viewState) {  
		var theObj = document.getElementById(objID); 
		
		// if we didn't pass in view state explicitly, then determine from current object properties
		if (!viewState) { 
			var viewState = theObj.style.display;
			if (viewState == 'none') { viewState = 'show'; } // if current state is "none" then we're showing the layer
		}
		
		if (viewState == 'show') {
			theObj.style.display = 'block';
		}
		else {
			theObj.style.display = 'none';
		}
	}
	
	function toggleVisibility(objID, viewState) {  
		var theObj = document.getElementById(objID); 

		// if we didn't pass in view state explicitly, then determine from current object properties
		if (!viewState) { 
			var viewState = theObj.style.visibility;
			if (viewState == 'hidden') { viewState = 'show'; } // if current state is "none" then we're showing the layer
		}

		if (viewState == 'show') {
			theObj.style.visibility = 'visible';
		}
		else {
			theObj.style.visibility = 'hidden';
		}
	}
	
	
	
	function showAlert() {
		// calculate left position of the alert layer
		var pageSize = getPageSize();
		var windowWidth = pageSize[2];
		var objWrapper = document.getElementById('alertWrapper'); 
		var leftPos = windowWidth/2 - 130;
		objWrapper.style.left = leftPos + "px";
		
		toggleView('alertWrapper');
	}
	function hideAlert() { 
		toggleView('alertWrapper');
	}


	function showHideFAQ(objID) {
		var theObj = document.getElementById(objID);
		var currentState = theObj.style.backgroundImage;

		for (var i=0; i<theObj.childNodes.length; i++) {
			if (theObj.childNodes[i].className == 'faqsidebarbox_head') { 
				var headTag = theObj.childNodes[i];
				
				for (var j=0; j<theObj.childNodes[i].childNodes.length; j++) {
					if (theObj.childNodes[i].childNodes[j].tagName == 'H5') { 
						var h5Tag = theObj.childNodes[i].childNodes[j];
					}
				}
			}
			if (theObj.childNodes[i].className == 'faqsidebarbox_body') { 
				var bodyTag = theObj.childNodes[i];
			}
		}

		if (currentState == 'none') {
			theObj.style.backgroundImage = 'url(/_img/boxes/faqbox_ffffff.gif)';
			theObj.style.marginTop = '10px';
			headTag.style.backgroundImage = 'url(/_img/boxes/faqbox_ffffff.gif)';
			h5Tag.style.borderBottom = '1px solid white'; // this fixes IE not displaying the bg properly
			h5Tag.style.backgroundImage = 'url(/_img/boxes/faqbox_ffffff.gif)';
			bodyTag.style.display = 'block';
		}
		else {
			theObj.style.backgroundImage = 'none';
			theObj.style.marginTop = '0px';
			headTag.style.backgroundImage = 'none';
			h5Tag.style.borderBottom = 'none'; // this fixes IE not displaying the bg properly
			h5Tag.style.backgroundImage = 'none';
			bodyTag.style.display = 'none';
		}
	}

	function toggleShipping() {
		var theCheckbox = document.getElementById('sameShipping');
		
		if (theCheckbox.checked) { 
			toggleView('shippingWrapper', 'hide');
		}
		else {
			toggleView('shippingWrapper', 'show');
		}
	}

	function chooseVerifyMethod(theValue) {
		// if showing account number
		if (theValue == 'account') {
			toggleVisibility('accountNumWrapper','show');
			toggleVisibility('ssnWrapper','hide');
			document.getElementById('verify_acct_label').style.color = 'black';
			document.getElementById('verify_ssn_label').style.color = '#999';
		}
		// if verifying by ssn
		else {
			toggleVisibility('accountNumWrapper','hide');
			toggleVisibility('ssnWrapper','show');
			document.getElementById('verify_acct_label').style.color = '#999';
			document.getElementById('verify_ssn_label').style.color = 'black';
		}
	}



	//
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.com
	// Edit for Firefox by pHaez
	//
	function getPageSize(){
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
	//	console.log(self.innerWidth);
	//	console.log(document.documentElement.clientWidth);
	
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
	//	console.log("xScroll " + xScroll)
	//	console.log("windowWidth " + windowWidth)
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
	//	console.log("pageWidth " + pageWidth)
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}
	

	// cookie create, read, delete functions	
	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);
	}
