function addLoadEvent(func) {var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } }
function getElementsByClassName(classname) { var a = []; var re = new RegExp('\\b' + classname + '\\b'); var els = document.getElementsByTagName("*"); for(var i=0,j=els.length; i<j; i++) if(re.test(els[i].className))a.push(els[i]); return a; }
addLoadEvent(runBookmark);
function runBookmark(){ var bookmark = document.getElementById("bookmark"); if(!bookmark){ return true; } var title = bookmark.getAttribute("title"); bookmark.onclick = function(){ return addBookmark(title, bookmark); }; }
addLoadEvent(openPopup);
function openPopup(){
	var popupLinks = getElementsByClassName("openPopup");
	for ( var i=0; i < popupLinks.length; i++ ){
		var trigger = popupLinks[i].getAttribute("className") || popupLinks[i].getAttribute("class");
		switch(trigger)
		{
			case "openPopup prodPopup":
			popupLinks[i].onclick = function(){
				return popup( this, "Product", "601", "700", "yes" );
			}
		break;
		case "openPopup terms":
			popupLinks[i].onclick = function(){
				return popup( this, "Terms", "551", "700", "yes" );
			}
		break;
		case "openPopup emailPopup":
			popupLinks[i].onclick = function(){
				return popup( this, "EmailFriend", "441", "470", "yes" );
			}
		break;
		case "openPopup forgotten":
			popupLinks[i].onclick = function(){
				return popup( this, "forgotten", "440", "280", "" );
			}
		break;
		case "openPopup security":
			popupLinks[i].onclick = function(){
				return popup( this, "security", "440", "385", "" );
			}
		break;
		case "openPopup productSymbols":
			popupLinks[i].onclick = function(){
				return popup( this, "productSymbols", "481", "650", "yes" );
			}
		break;
		case "openPopup galleryPopup":
			popupLinks[i].onclick = function(){
				return popup( this, "galleryPopup", "717", "690", "" );
			}
		break;
		case "openPopup paypalPopup":
			popupLinks[i].onclick = function(){
				return popup( this, "paypalPopup", "440", "360", "" );
			}
		break;
		}
	}
}
function popup( vURL, vWinName, vWidth, vHeight, vScrollbar) { if (! window.focus)return true; var vhref; var vSWidth = screen.width; var vSHeight = screen.height;	if(vScrollbar == "yes") { vWidth = new Number(vWidth) + 16 }var vleftPos = (vSWidth / 2) - (vWidth / 2); var vtopPos = (vSHeight / 2) - (vHeight / 2); if (typeof(vURL) == 'string'){ vhref = vURL; } else { vhref = vURL.href; } window.open(vhref, vWinName, 'scrollbars=' + vScrollbar + ',statusbar=no,menubar=0,width=' + vWidth + ',height=' + vHeight + ',left=' + vleftPos + ',top=' + vtopPos); return false; }
function addBookmark(title,url) { if (window.sidebar) { window.sidebar.addPanel(title, url,""); } else if( document.all ) { window.external.AddFavorite( url, title); } else if( window.opera && window.print ) { return true; } }

//addLoadEvent(changeFaqHead); 
function changeFaqHead(offClass, onClass, faqID){ var list = new Array(); var faqNumber = document.getElementById(faqID); list = getElementsByClassName(onClass); for (var i = 0; i < list.length; i++){ if(list[i].className==onClass){ list[i].className = offClass;} } faqNumber.className = onClass;}

/* function to change the background image of table td if a checkbox is checked */
function historyBasketBg(check, bgChange){ var bgChange = document.getElementById(bgChange); var ifChecked = document.getElementById(check); var tds = bgChange.getElementsByTagName("td"); for (var j=0; j<tds.length; j++){ if (ifChecked.checked == true){ tds[j].style.background="url(/common/img/basket/blueBg.gif) no-repeat bottom left";} else { tds[j].style.background="url(/common/img/basket/whiteBg.gif) no-repeat bottom left";} tds[0].style.backgroundPosition="-3px bottom"; tds[2].style.backgroundPosition="-3px bottom";} }

/* function to reset all checkboxes to unchecked */
function historyBasketClearCheck(){ var basket = document.getElementById("previousOrders"); var checkBoxes = basket.getElementsByTagName("input"); var tds = basket.getElementsByTagName("td"); for (var i=0; i<checkBoxes.length; i++){ if (checkBoxes.checked == true){ checkBoxes[i].checked = true;} else {checkBoxes[i].checked = false;} }
	/*	
	for (var j=0; j<tds.length; j++){
		tds[j].style.background="url(/common/img/basket/whiteBg.gif) no-repeat bottom left";
		if (tds[j].className == "date"){
			tds[j].style.backgroundPosition="-3px bottom";}
		if (tds[j].className == "offerLogo"){
			tds[j].style.backgroundPosition="-3px bottom";}
	}*/
}
