/*====================================================================================================*/
/*====================================================================================================*/
function StartBlender() {
	xBlender=document.getElementById("blender");
	if (xBlender) {
		xBLENDimages=xBlender.getElementsByTagName("img");
		xNUMimages=xBLENDimages.length;
		for (i=0;i<xNUMimages;i++) {
			xIMG=xBLENDimages[i];
			setOpacity(xIMG, 0);
			xIMG.style.zIndex=i;
			xIMG.style.display="block";
		} //next i<xNUMimages
		setOpacity(xIMG, 100);
		setInterval("FadeInImage()", 10000);
	}//end if (xBlender)
}//end function
/*====================================================================================================*/
function FadeInImage() {
	xBlender=document.getElementById("blender");
	if (xBlender) {
		xBLENDimages=xBlender.getElementsByTagName("img");
		xNUMimages=xBLENDimages.length;
		xWORKINGimage=xBLENDimages[0];
		xWORKINGzIndex=xWORKINGimage.style.zIndex;
		for (i=0;i<xNUMimages;i++) {
			xCHECKINGimage=xBLENDimages[i];
			xCHECKINGzIndex=xCHECKINGimage.style.zIndex;
			if (xCHECKINGzIndex<xWORKINGzIndex) {
				xWORKINGimage=xCHECKINGimage;
				xWORKINGzIndex=xCHECKINGzIndex;
			}//end if (xCHECKINGzIndex<xWORKINGzIndex)
		}//next i<xNUMimages
		xIMAGEtoMove=xWORKINGimage;
		xZINDEXtoGoTo=xWORKINGzIndex+xNUMimages;
		setOpacity(xIMAGEtoMove, 0);
		xIMAGEtoMove.style.zIndex=xZINDEXtoGoTo;
		for (o=0;o<=100;o++) {
			setTimeout("setOpacity(xIMAGEtoMove, "+o+")", 10*o)
		}//next o<=100
	}//end if (xBlender)
}//end function
/*====================================================================================================*/
function setOpacity(theObject, theOpacity) {
    theObject.style.opacity=(theOpacity/100);
    theObject.style.MozOpacity=(theOpacity/100);
    theObject.style.KhtmlOpacity=(theOpacity/100);
    theObject.style.filter='alpha(opacity='+theOpacity+')';
}//end function
/*====================================================================================================*/
function ShowMap(thePostCode) {
	if (GBrowserIsCompatible()) {
		var map;
		var localSearch=new GlocalSearch();
		var icon=new GIcon();
		icon.image="http://www.bigstorage.info/images/css/bigbox.png";
		icon.shadow="http://www.bigstorage.info/images/css/bigboxshadow.png";
		icon.iconSize=new GSize(20, 18);
		icon.shadowSize=new GSize(37, 34);
		icon.iconAnchor=new GPoint(10, 34);
		map=new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		localSearch.setSearchCompleteCallback(null, 
			function() {
				if (localSearch.results[0]) {
					var resultLat=localSearch.results[0].lat;
					var resultLng=localSearch.results[0].lng;
					var point=new GLatLng(resultLat,resultLng);
					map.setCenter(point, 11);
					var marker=new GMarker(point,icon);
					map.addOverlay(marker);
				}//end if (localSearch.results[0])
			});	
		localSearch.execute(thePostCode + ", UK");
	}//end if (GBrowserIsCompatible())
}//end function
/*====================================================================================================*/
function setHighlights() {
	xInputs=document.getElementsByTagName("input");
	for (i=0;i<xInputs.length;i++) {
		if (xInputs[i].type=="text") {
			xInputs[i].onfocus=function() {
					if (this.defaultValue==this.value) {
						this.select();
					}//end if ()
				}//end function
			xInputs[i].onmouseup=function(){return false};//because safari is special
		}//end if (xInputs[i].type=="text")
	}//next i<xInputs.length
	xTextAreas=document.getElementsByTagName("textarea");
	for (i=0;i<xTextAreas.length;i++) {
		xTextAreas[i].onfocus=function() {
				if (this.defaultValue==this.value) {
					this.select();
				}//end if ()
			}//end function
		xTextAreas[i].onmouseup=function(){return false};//because safari is special
	}//next i<xTextAreas.length
}//end function
/*====================================================================================================*/
function compute(form)  {
	overAllTotal=0;	//reset total
	for (j=0;j<form.qty.length;j++ ) {
		itemQty=form.qty[j].value;
			if (!isNaN(itemQty)) {
				itemTotal=itemQty*form.volume[j].value;
				overAllTotal+=itemTotal;
				form.total[j].value=itemTotal;
			} else {
				form.qty[j].value="err";
				form.total[j].value=0;
			}//end if (!isNaN(itemQty))
		form.overAllTotal.value=overAllTotal;
	} //next j < form.qty.length
}//end function
/*====================================================================================================*/
function SetHomeButtons() {
	theUL=document.getElementById("homebuttons");
	if (theUL) {
		theLIs=theUL.getElementsByTagName("li");
		if (theLIs) {
			for (i=0;i<theLIs.length;i++) {
				theLI=theLIs[i];
				theImage=theLI.getElementsByTagName("img")[0];
				if (theImage) {
					theAltImage=theImage.src.replace("icon0", "alticon0");
					theImage.parentNode.parentNode.style.background="url("+theAltImage+")";
					theImageID=theImage.id;
					setTimeout("StartBlending('"+theImageID+"')", 1500+(1500*i))
				}//end if (theImage)
			}//next i<i<theLIs.length
		}//end if (theLIs)
	}//end if (theUL)
//	setTimeout("StartBlending('homebuttons1', 1)", 1000);
//	setTimeout("StartBlending('homebuttons2', 2)", 2000);
//	setTimeout("StartBlending('homebuttons3', 3)", 3000);
//	setTimeout("StartBlending('homebuttons4', 4)", 4000);
//	setTimeout("StartBlending('homebuttons5', 5)", 5000);
//	setTimeout("StartBlending('homebuttons6', 6)", 6000);
}//end function
/*====================================================================================================*/
function StartBlending(theImageID) {
	setInterval("Blend('"+theImageID+"')", 10000);
}//end function
/*====================================================================================================*/
/*====================================================================================================*/
function Blend(theImageID) {
	theImage=document.getElementById(theImageID);
	theOpacity=theImage.style.opacity;
	if (!theOpacity) {theOpacity=1};
	if (theOpacity>=.99) {theOpacity=1};
	if (theOpacity<=.01) {theOpacity=0};
	theOpacity=theOpacity*100;
	if (theOpacity==100) {
		for (o=0;o<100;o++) {
			setTimeout("setOpacity("+theImageID+", "+(100-o)+")", o*10);
		}//next o>0		
	}//end if (theOpacity)
	if (theOpacity==0) {
		for (o=0;o<100;o++) {
			setTimeout("setOpacity("+theImageID+", "+o+")", o*10);
		}//next o>0
	}//end if (theOpacity)

}//end function
/*====================================================================================================*/
function getCookie(c_name) {
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}//end function
/*====================================================================================================*/
function setCookie(c_name,value,exdays) {
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}//end function
/*====================================================================================================*/
function mainCookie() {
var cmob=getCookie("cmob");
setCookie("cmob","no",10);
}//end function
/*====================================================================================================*/
function checkCookie() {
var cmob=getCookie("cmob");
if (cmob!="no") {
	mainCookie();
  window.location = "http://www.bigstorage.info/mobile/"
  }
}//end function
/*====================================================================================================*/
function checkres() {
	ScreenWidth = screen.width;
	
	if (ScreenWidth < 500) {
		checkCookie();
	}
}//end function
/*====================================================================================================*/
window.onload=function() {
	StartBlender();
	setHighlights();
	SetHomeButtons();
	checkres();
}//end function
/*====================================================================================================*/












/*====================================================================================================*/
