function goPage(page)
{
    if (page != "logout")
        window.location = page;
}

function buttonMouseHover(id, imgPath)
{
	var fr = document.all ? document.all[id] : document.getElementById(id);
	fr.src = imgPath; 
}

function buttonMouseOut(id, imgPath)
{
	var fr = document.all ? document.all[id] : document.getElementById(id);
	fr.src = imgPath;
}

function submitForm(form)
{
	form.submit();
}

function removeCartForm(form)
{
	var act = document.all ? document.all["action"] : document.getElementById("action");
	act.value = "remove";
	form.submit();
}

function updateCartForm(id, q, c, s, form)
{
	var item_id = document.all ? document.all["item_id"] : document.getElementById("item_id");
	var qty = document.all ? document.all["qty"] : document.getElementById("qty");
	var colour = document.all ? document.all["colour"] : document.getElementById("colour");
	var size = document.all ? document.all["size"] : document.getElementById("size");
	var act = document.all ? document.all["action"] : document.getElementById("action");
	
	act.value = "update";
	item_id.value = id;
	qty.value = q;
	colour.value = c;
	size.value = s;
	
	form.submit();
}

function submitDressForm(form)
{
	var colour = document.all ? document.all["colour"] : document.getElementById("colour");
	var dress_size = document.all ? document.all["dress_size"] : document.getElementById("dress_size");
	var qty = document.all ? document.all["quantity"] : document.getElementById("quantity");
	
	var msg = "";
	
	if (colour.value == "")
		msg += "Please fill in colour requirement\n";	
	
	if (dress_size[dress_size.selectedIndex].value == "0")
		msg += "Please select size\n";
		
	if (qty[qty.selectedIndex].value == "0")
		msg += "Please select quantity\n";
		
	if (msg != "")
		alert(msg);
	
	else
		form.submit();
		
}

function swapImg(id, fn)
{
	var img = document.all ? document.all[id] : document.getElementById(id);
	img.src=fn;
}

function expandDetails(id)
{	
	var obj = document.all ? document.all[id] : document.getElementById(id);
	
	if (obj.style.display == "")
		obj.style.display = "none";
	else
		obj.style.display = "";
}

function checkout()
{
	var terms = document.all ? document.all["terms"] : document.getElementById("terms");
	
	if (!terms.checked)
		alert("Please accept the terms and conditions");
	else
		goPage("checkout_post.php");
		
}