mapLoadingMsg=null;

if(!document.getElementById)
{
	window.location="/browseradvice/";
}

function init()
{
	initRolloverImages();
	initRolloverDivs();
	initClickableDivs();
	if(mapLoadingMsg != null )
	{
		mapLoaded = true;
		mapLoadingMsg.style.display="none";
		map.style.display="inline";
	}
}

function glossary(specID)
{
	w=304;h=250;
	x = (screen.width/2) - (w/2);
	y = (screen.height/2) - (h/2);
	features="width="+w+",height="+h+",top="+y+",left="+x;
	url="/glossary/?spec_id="+specID;
	glossaryWindow = window.open(url,"glossaryWindow",features);
}

function ringback()
{
	w=620
	h = (screen.height<850)? screen.height-60 : 850;
	x=(screen.width/2)-(w/2);
	y=(screen.height<850)? 0 : ((screen.height/2)-(h/2));
	features = "scrollbars=1,width=" + w + ",height=" + h + ",left=" + x + ",top=" + y;
	window.open("/ringback/",name,features);
}







//from that test file we got emailed
		
		function HighMap(n){
			
			
//alert("test");

		ocImg = document.getElementById("DSOmap");
		ocImg.style.cursor="help";
		ocImg.src="/images/library/DSO"+n+".gif";
		//if(ocImg.filters){
		//	ocImg.filters[0].apply()
		//	ocImg.style.visibility="visible"
		//	ocImg.filters[0].play()
		//	}
		}
		
		function LowMap(){
			
			
//alert("test");

		ocImg = document.getElementById("DSOmap");
		ocImg.style.cursor="default";
		ocImg.src="/images/library/DSOMap.gif";
	//	if(ocImg.filters){
	//		ocImg.filters[0].apply()
	//		ocImg.style.visibility="visible"
	//		ocImg.filters[0].play()
	//		}
		}
				





//
// DOM rollover script
// apply "rollover" class to an image
// will swap for image with "_ov" appended to the filename
//
function initRolloverImages(){
	var i;
	rolloverImgTags=document.getElementsByTagName("img");
	for(i=0 ; i<rolloverImgTags.length ; i++){
		//
		// Iterate through all img tags
		//
		preLoadImgs=new Array();
		if( rolloverImgTags[i].className=="rollover" ){
			//
			// Set attributes for over and out states
			//
			src=new String(rolloverImgTags[i].src)
			rolloverImgTags[i].setAttribute("outSrc" , src);
			rolloverImgTags[i].setAttribute("overSrc" , src.replace(/\.gif$/,"")+"_ov.gif");
			preLoadImgs[i] = new Image();
			preLoadImgs[i].src=rolloverImgTags[i].overSrc;
			//
			// Create mouse event handlers
			//
			rolloverImgTags[i].onmouseover = function() {
				this.src = this.getAttribute("overSrc");
				}
			rolloverImgTags[i].onmouseout = function() {
				this.src = this.getAttribute("outSrc");
				}
		}
	}
}

//
// DIV background rollovers
// shifts image rather than swapping to avoid flicker in IE
//
function initRolloverDivs(){
	var i;
	rolloverDivTags=document.getElementsByTagName("li");
	for(i=0 ; i<rolloverDivTags.length ; i++){
		//
		// Iterate through all img tags
		//
		if( rolloverDivTags[i].className=="prod_cat" || rolloverDivTags[i].className=="prod_sub_cat" ){
			//
			// Create mouse event handlers
			//
			rolloverDivTags[i].onmouseover = function() {
				this.style.backgroundPosition = 'bottom left';
				}
			rolloverDivTags[i].onmouseout = function() {
				this.style.backgroundPosition = 'top left';
				}
		}
	}
}



// enable whole div to act like a link, taking its href from a child A tag
function initClickableDivs(){
	var i
	divTags=document.getElementsByTagName("div");
	for(i=0;i<divTags.length;i++){
		if(divTags[i].className=="relatedProduct" || divTags[i].className=="prodResultBlock"  || divTags[i].className=="productcat" ){
			href = getChildAnchorHref( divTags[i] );
			target = getChildAnchorTarget( divTags[i] );
			divTags[i].setAttribute("href" , href);
			divTags[i].setAttribute("target" , target);
			// events
			divTags[i].onclick = function() {
				if(this.getAttribute("target")=="blank"){
					window.open(this.getAttribute("href"),"blank");
					}
				else {
					window.location = this.getAttribute("href");
					}
				}

			if(divTags[i].className=="relatedProduct"){
				divTags[i].onmouseover = function() {
					this.style.backgroundColor = "#D9E1EF";
					}
				divTags[i].onmouseout = function() {
					this.style.backgroundColor = "#ffffff";
					}
				}
			}
		}
	}
//

// return href value for first child anchor tag - needed for initClickableDivs
function getChildAnchorHref(elm){
	var i
	nodes = new Array();
	for(i=0;i<elm.childNodes.length;i++){
		if(elm.childNodes[i].nodeName=="A"){
			return elm.childNodes[i].href
		}
	}
	return false;
}
//
function getChildAnchorTarget(elm){
	var i
	nodes = new Array();
	for(i=0;i<elm.childNodes.length;i++){
		if(elm.childNodes[i].nodeName=="A"){
			return elm.childNodes[i].target
		}
	}
	return false;
}
//


function enlargeProduct(id){
	url = "/enlarge/?prod_id="+id
	popUp(460,470,url,"enlargedProduct");
}


function popUp(w,h,url,name){
	x=(screen.width/2)-(w/2);
	y=(screen.height/2)-(h/2);
	features = "width=" + w + ",height=" + h + ",left=" + x + ",top=" + y;
	window.open(url,name,features);
}

function popupLink(url){
	window.opener.window.location=url;
	window.close();
}

function ddPopUp(){
	popUp(304,250,"/directdebit/","dd_PopUp");
	}

function accountNumberInfo(){
	popUp(304,250,"/accountnumber/","acountNumberPopup");
}


function accountNumberConfirm(){
	accountNumberConfirmShown = true;
	msg = "You haven't entered your account number.\n"
	msg+= "It can be found on one of the following and is 9 digits long:\n\n"
	msg+= " * Boxclever Payment Card\n"
	msg+= " * Credit Transfer/Giro Payment Slips\n"
	msg+= " * Direct Debit or Standing Order Reference Number\n"
	msg+= " * Letter from us\n\n"
	msg+= "It would assist us greatly if you are able to supply this number.\n"
	msg+= "Click OK to submit this form or Cancel to enter your account number"
	if(confirm(msg)){
		return true;
	}
	else {
		document.forms[0].account_number.focus()
		return false;
	}

}


