function checkFooter() {

		windowheight = window.innerHeight;
		pageheight = document.getElementById("pagewrapper").offsetHeight;
		footerheight = document.getElementById("footerwrapper").offsetHeight;

		if (!windowheight) { 
			windowheight = document.documentElement.clientHeight;
		}

		if (!windowheight || windowheight == 0) { 
			windowheight = document.body.clientHeight;
			pageheight = document.getElementById("pagewrapper").offsetHeight;
		}

		difference = windowheight - pageheight;

		if(difference > 0) {
			pageheight = pageheight - footerheight;
			document.getElementById('pagewrapper').style.height = pageheight + difference + "px";
		} else if (difference < 0) {
			pageheight = pageheight - footerheight;
			if((pageheight + difference) > 650) {
				document.getElementById('pagewrapper').style.height = pageheight + difference + "px";
			}
		}
	
}


// STORE REQUIRED ACTIONS IN VARIABLE //

var W3CDOM = (document.getElementsByTagName);

function init() {

	windowwidth = window.innerWidth;
	pagewidth = document.getElementById("pagewrapper").offsetWidth;

	if (!windowwidth) {
		windowwidth = document.documentElement.clientWidth;
	}

	if (!windowwidth || windowwidth == 0) {
		windowwidth = document.body.clientWidth;
		pagewidth = document.getElementById("pagewrapper").offsetWidth;
	}

	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	}

	if(windowwidth > 1300) {
		document.getElementById("pagewrapper").style.marginRight = "8%";
		document.getElementById("pagewrapper").style.marginLeft = "8%";
		document.getElementById("pagewrapper").style.backgroundPosition = "-30px 100%";
	} else if(windowwidth > 1100) {
		document.getElementById("pagewrapper").style.marginRight = "3%";
		document.getElementById("pagewrapper").style.marginLeft = "3%"
	} else {
		document.getElementById("pagewrapper").style.marginRight = "0px";
		document.getElementById("pagewrapper").style.marginLeft = "0px"
		document.getElementById("pagewrapper").style.backgroundPosition = "-40px 100%";
	}

	if(document.getElementById("moreinfo") && document.getElementById("footerline")) {
		document.getElementById("footerline").style.width = document.getElementById("moreinfo").offsetWidth + "px";
	}

	if(document.getElementById("pictureback3") && ieversion == 6) {
		document.getElementById("pictureback3").style.display = "none";
		document.getElementById("pictureback3").style.width = document.getElementById("home_box").offsetWidth - 20 + "px";
		document.getElementById("pictureback3").style.display = "block";
	}

	var menu = document.getElementById('menu');
	var litags = menu.getElementsByTagName('li');

	for (var i=0;i<litags.length;i++) {
		if(litags[i].className != "divider") {
			litags[i].onmouseover = mousegoesover;
			litags[i].onmouseout = mousegoesout;
		}
	}

	if(document.getElementById('cat_wrapper')) {
		var catwrapper = document.getElementById('cat_wrapper');
		var cats = catwrapper.getElementsByTagName('div');

		for (var i=0;i<cats.length;i++) {
			cats[i].onmouseover = mousegoesover2;
			cats[i].onmouseout = mousegoesout2;
		}
	}

	if(document.getElementById("heart")) {

		if(windowwidth > 1350) {
			document.getElementById("heart").style.right = 220 + "px";
			document.getElementById("dagger").style.right = 80 + "px";
			document.getElementById("necklace").style.display = "block";
		} else {
			document.getElementById("heart").style.right = 140 + "px";
			document.getElementById("dagger").style.right = 0 + "px";
			document.getElementById("necklace").style.display = "none";
		}

	}

	if(document.getElementById("coeur")) {

		if(windowwidth > 1600) {
			document.getElementById("coeur").style.width = 800 + "px";
		} else if(windowwidth > 1500) {
			document.getElementById("coeur").style.width = 500 + "px";
		} else {
			document.getElementById("coeur").style.width = 360 + "px";
		}

	}


}


function mousegoesover() {
	this.className = "over";
	this.style.cursor = "pointer";
}

function mousegoesout() {
	this.className = "";
}

function mousegoesover2() {
	addClass(this,"over");
}

function mousegoesout2() {
	removeClass(this,"over");
}


	function addEvent2(obj,type,func) {
		if (obj.addEventListener) { obj.addEventListener(type,func,false); return true; }
		if (obj.attachEvent) { return obj.attachEvent("on"+type,func); }
		return false;
	}

	function removeEvent(obj,type,func) {
		if (obj.removeEventListener) { obj.removeEventListener(type,func,false); return true; }
		if (obj.detachEvent) { return obj.detachEvent("on"+type,func); }
		return false;
	}

	function findEvent(e) {
		if (!e) var e = window.event;
		return e;
	}
			
	function findTarget(e) {
		if (e.target) t = e.target;
		else if (e.srcElement) t = e.srcElement;
		while (t.nodeType != 1) {
			document.title += t;
			t = t.parentNode;
		}
		return t;
	}

	function findPos(obj) {
		var x = y = 0;
		if (obj.offsetParent) {
			x = obj.offsetLeft;
			y = obj.offsetTop;
			while (obj = obj.offsetParent) {
				x += obj.offsetLeft
				y += obj.offsetTop
			}
		}
		return [x,y];
	}

	function findViewportSize() {
		var x = y = 0;
		if (self.innerHeight) { // if !ie
			x = self.innerWidth;
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // if ie6 strict
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) { // all other ie
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		return [x,y];
	}

	function findPageSize() {
		var x = y = 0;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) { // if !ie mac
			x = document.body.scrollWidth;
			y = document.body.scrollHeight;
		} else { // if ie mac
			x = document.body.offsetWidth;
			y = document.body.offsetHeight;
		}
		return [x,y];
	}

	function findPageOffset() {
		var x = y = 0;
		if (self.pageYOffset) { // if !ie 
			x = self.pageXOffset;
			y = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) { // if ie6 strict
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		} else if (document.body) { // all other ie
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}
		return [x,y];
	}

	function findMousePos(e)
	{
		var x = y = 0;
		if (e.pageX || e.pageY) {
			x = e.pageX;
			y = e.pageY;
		} else if (e.clientX || e.clientY) 	{
			x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		return [x,y];
	}

	function vector() {
		this.x = 0; this.y = 0; this.z = 0;
	}

	function addClass(object,classname) {
		object.className += " "+classname;
	}

	function checkClass(object,classname) {
		classes = object.className.split(' ');
		var i;
		for (i=0;i<classes.length;i++) {
			if (classes[i] == classname) return true;
		}
		return false;
	}

	function removeClass(object,classname)
	{
		classes = object.className.split(' ');
		var i; var newclass = "";
		for (i=0;i<classes.length;i++) {
			if (classes[i] != classname) newclass += " "+classes[i];
		}
		object.className = newclass;
	}



	function addToFavorites() { 
		var url = "http://www.hiltonphoto.co.uk"; 
		var title = "Hilton Photographic"; 

		if (window.sidebar) { 
			// Mozilla Firefox Bookmark		
			window.sidebar.addPanel(title, url,"");	
		} else if( window.external ) { 
			//IE Favorite		
			window.external.AddFavorite( url, title); 
		}
	}


	function runSlideShow(backid, imageid, imagearray,d) {

		if (!d) var d = 0;

		nextPic = d + 1; if (nextPic >= imagearray.length) nextPic = 0; 

		fadelength = 2000;
		steps = 100;

		// Set Background Image To Match Foreground
		document.getElementById(backid).style.background = "url('"+document.getElementById(imageid).src+"')";

		// Set Foreground Opacity to Transparent
		setTimeout('setOpacity("'+imageid+'",0)',50);

		// Set Foreground to the next Picture
		setTimeout('document.getElementById(\''+imageid+'\').src = \''+imagearray[nextPic]+'\'',100);

		// Loop through changing the Opacity
		for(i = 0; i <= steps; i++) {
			opacity = i/steps * 100;
			setTimeout('setOpacity("'+imageid+'",'+opacity+')',((i*(fadelength/steps))+150));
		}

		d++;
		
		if (d >= imagearray.length) d=0;

		setTimeout( function () { runSlideShow(backid,imageid,imagearray,d) } ,3000);

	}

	function arrayToString(arr) {
		return str = 'new Array("' + arr.join('", "') + '")';
	}

	function setOpacity(id,value) {
		document.getElementById(id).style.opacity = (value / 100);
		document.getElementById(id).style.MozOpacity = (value / 100);
		document.getElementById(id).style.KhtmlOpacity = (value / 100);
		document.getElementById(id).style.filter = "alpha(opacity=" + value + ")";
	}


	function showEngrave(obj) {

		if(obj.checked == true) {

			if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
				var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
			}

			if(ieversion == 6) {
				$('engrave_text').style.display = "block";
			} else {
				$('engrave_text').style.display = "table-row";
			}

			old_price = $('ring-price').innerHTML;
			old_high_street_price = $('high-street-price').innerHTML;

			new_price = Math.round((parseFloat(old_price) + 9.95) * 100) / 100;
			new_high_street_price = Math.round((parseFloat(old_high_street_price) + 9.95) * 100) / 100;

			$('ring-price').innerHTML = new_price.toFixed(2);
			$('high-street-price').innerHTML = new_high_street_price.toFixed(2);

			$('price').value = new_price;

		} else {

			$('engrave_text').style.display = "none";

			old_price = $('ring-price').innerHTML;
			old_high_street_price = $('high-street-price').innerHTML;

			new_price = Math.round((parseFloat(old_price) - 9.95) * 100) / 100;
			new_high_street_price = Math.round((parseFloat(old_high_street_price) - 9.95) * 100) / 100;

			$('ring-price').innerHTML = new_price.toFixed(2);
			$('high-street-price').innerHTML = new_high_street_price.toFixed(2);

			$('price').value = new_price;

		}

	}

	function checkEngrave() {


		if($('engraving').checked == true) {

			message = '';

			if($('engraving_text').value == '') {
				message += "Please enter some text to engrave.\n";
			}
			if($('engrave_font').value == '') {
				message += "Please choose a font for engraving.\n";
			}
			if(message != '') {
				window.alert(message);
				return false;
			} else {
				return true;
			}

		} else {
			return true;
		}

	}

