// JavaScript Document

function checkpassword()
{
	password = document.getElementById("password");
	repassword = document.getElementById("repassword");
	
	if(password!="")
	{
		if(password == repassword)
		{
			alert("Password does not match");
			return false;
		}
	}
	else
	{
		alert("Please enter a password");
		return false;
	}
	return true;
}


function checkField()
{
	fieldArray = formfields;
	error = "";
	size = fieldArray.length;
	for(i=0; i<size; i++)
	{
		element = document.getElementById(fieldArray[i]);
		if(fieldArray[i] == "password")
		{
			if(element.value!=document.getElementById("repassword").value)
			{			
				error += "- Password doesnt match\n";
			}
		}
		if(element.value=="")
		{
			error += "- " + fieldArray[i] + "\n";
		}
	}
	
	if(error)
	{
		alert("Missing Fields: \n" + error);
		return false;
	}
	return true;
}

function goto(url)
{
	window.location.href = url;
}

function addcart(itemid)
{
	quantitydl = document.getElementById("quantity");
	var myindex  = quantitydl.selectedIndex;
    var quantity = quantitydl.options[myindex].value;
	
	var colourid = 0;
	if(document.getElementById("colour"))
	{
		colourdl = document.getElementById("colour");
		var myindex  = colourdl.selectedIndex;
		var colourid = colourdl.options[myindex].value;
	}
	window.location.href = "/bagage/action/addtocart.php?itemid="+itemid+"&quantity="+quantity+"&colourid="+colourid;
}

function addwishlist(itemid)
{
	quantitydl = document.getElementById("quantity");
	var myindex  = quantitydl.selectedIndex;
    var quantity = quantitydl.options[myindex].value;
	
	var colourid = 0;
	if(document.getElementById("colour"))
	{
		colourdl = document.getElementById("colour");
		var myindex  = colourdl.selectedIndex;
		var colourid = colourdl.options[myindex].value;
	}
	window.location.href = "/bagage/action/addtowishlist.php?itemid="+itemid+"&quantity="+quantity+"&colourid="+colourid;
}