$(window).load (function () {
	$('#page_content_scroll').jScrollPane({scrollbarWidth:18,dragMaxHeight:18,dragMinHeight:18,reinitialiseOnImageLoad:true});
});

$(document).ready (function () {
	//$('#page_content_scroll').jScrollPane({scrollbarWidth:18,dragMaxHeight:18,dragMinHeight:18,reinitialiseOnImageLoad:true});
				
	$(".hover").mouseover(function () {
		$(this).fadeTo (100, 1);
	}).mouseout(function () {
		$(this).fadeTo (150, 0);
	});
			
	$("#page_menu li img").mouseover(function () {
		$(this).fadeTo (100, 0.01);
	}).mouseout(function () {
		$(this).fadeTo (150, 1);
	});
				
	$("#page_submenu li img").mouseover(function () {
		if ($(this).attr ("id") != "submenu_selected") {
			$(this).fadeTo (100, 0.5);
		}
	}).mouseout(function () {
		$(this).fadeTo (150, 1);
	});
	
	//$("#order").click (validateOrder);
});

function comingsoon () {
	alert ("This section is coming soon...");
}

function changeHeader (filename) {
	var flashvars = {filename: "../"+filename };
	var params = {wmode: "transparent"};
	var attributes = {};
	swfobject.embedSWF ("_swf/videoheader.swf", "page_flash", "399", "252", "9.0.0", null, flashvars, params, attributes);
}

function addToCart (id) {
	size = $("#size_"+id).val();
	quantity = $("#quantity_"+id).val();
	$.post ("addtobasket.php", {id: id, size: size, quantity: quantity}, function () {
		window.location = "shop.php?p=1";
	});
}

function removeFromBasket (index) {
	$.post ("removefrombasket.php", {index: index}, function () {
		window.location = "shop.php?p=1";
	});
}

function isValidEmail (str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function validateOrder (){
	valid = true;
	
	instId		= "219836";
	cartId		= "metropolis";
	currency	= "GBP";
	M_recipient	= "test@test.com";
	M_subject	= "ORDER FROM METROPOLIS";
	M_sname		= "";
	M_stel		= "";
	M_saddress	= "";
	M_spostcode	= "";
	testMode	= "0";
	desc		= document.form.desc.value;
	amount		= document.form.amount.value;
	name		= document.form.name.value;
	address		= document.form.address.value;
	country		= document.form.country.value;
	postcode	= document.form.postcode.value;
	tel			= document.form.tel.value;
	fax			= document.form.fax.value;
	email		= document.form.email.value;
	basket		= document.form.basket.value;
	mailinglist = document.form.mailinglist.checked;
	
   	if (name == "") {
        alert ( "Please enter your name" );
        valid = false;
    } else if (address == "") {
        alert ( "Please enter your address" );
        valid = false;
    } else if (postcode == "") {
        alert ( "Please enter your postcode" );
        valid = false;
    } else if (tel == "") {
        alert ( "Please enter your telephone number" );
        valid = false;
    } else if (!isValidEmail(email)) {
        alert ( "Please enter your email address" );
        valid = false;
    }
	
	if (valid) {
		$.post ("sendorder.php",
			{desc: desc, email: email, name: name, tel: tel, address: address, postcode: postcode, basket: basket, mailinglist: mailinglist},
			function () {
				
				document.form.onsubmit = "";
				document.form.action = "https://select.worldpay.com/wcc/purchase";
				document.form.submit ();
			}
		);
	}
}


Shadowbox.init ({ });