var Product = {
	
	image: null,

	size: function() {
		var data_array = $('productsize').value.split("#");
		for (i=$('productcolour').length-1; i>=0; i--) {
			$('productcolour').remove(i);
		}
		var noption;
		for (i=0; i<(data_array.length-1)/2; i++) {
			noption = document.createElement('option');
			noption.text = data_array[i*2+1];
			noption.value = data_array[i*2];
			try {
				$('productcolour').add(noption, null);
			}
			catch(ex) {
				$('productcolour').add(noption);
			}
		}
		Product.color();
	},
	
	color: function() {
		var data_array = $('productcolour').value.split("=");
		Product.image = 'UploadedImages/'+data_array[1];
		$('imagetable').innerHTML = '<a href="UploadedImages/'+data_array[0]+'" rel="lightbox[productimages]">'+
									'<img src="UploadedImages/'+data_array[1]+'" />'+
									'</a>';
		$('zoomimage').href = 'UploadedImages/'+data_array[0];
		if (data_array[3].match(/[^£0.]/)) {
			$('productprice').innerHTML = data_array[2] + "<b>" + data_array[3] + "</b>"
		} else {
			$('productprice').innerHTML = data_array[2]
		}
		$('productoffer').innerHTML = data_array[4];
	},
	
	buy: function() {
		var data_array = $('productcolour').value.split("=");
		window.location = 'http://www.woodempire.co.uk/add_cart.asp?productspec_id=' + data_array[5] + '&qty=' + $('qty').value;
	},
	
	imageShow: function(image) {
		var images = $('imagetable').getElementsByTagName('img');
		if (!Product.image) Product.image = images[0].src;
		images[0].src = image;
	},
	
	imageHide: function() {
		var images = $('imagetable').getElementsByTagName('img');
		images[0].src = Product.image;
	}
}

var Ifame = {
	timer: null,
	speed: 5,
	
	left: function() {
		if (Ifame.timer) clearTimeout(Ifame.timer);
		window.frames["iframe"].scrollBy(-Ifame.speed, 0);
		Ifame.timer = setTimeout("Ifame.left()", 20);
	},
	
	right: function() {
		if (Ifame.timer) clearTimeout(Ifame.timer);
		window.frames["iframe"].scrollBy(Ifame.speed, 0);
		Ifame.timer = setTimeout("Ifame.right()", 20);
	},
	
	stop: function() {
		clearTimeout(Ifame.timer);
	}
	
}

function addtocart()
{
	if(!chkTxtBox(document.frmPcOptions.qty,"Quantity."))return false;
	
	if (IsNumericNoDot(document.frmPcOptions.qty.value)==false)
			{			
				alert("Invalid Numbers in Quantity")
				frmPcOptions.qty.focus()
				return false;				
			}
	if (parseFloat(document.frmPcOptions.qty.value)<="0")
	{
		alert("Invalid Quantity")
		frmPcOptions.qty.focus()
		return false;
	}
	document.frmPcOptions.action ="add_cart.asp";
	document.frmPcOptions.submit();
}

function PopupPic(sPicURL) { 
    window.open( "image.htm?"+sPicURL, "","resizable=yes,HEIGHT=630,WIDTH=630,top=0,left=10"); 
} 

function PopupPicColour(sPicURL) { 
    window.open( "image_colour.html?"+sPicURL, "","resizable=yes,HEIGHT=400,WIDTH=400,top=0,left=10"); 
} 


