 $(function() {
        $('a[@rel*=lightbox]').lightBox();
    });
 


function change_parent_url(url){
	    	document.location=url;
}
		
function check_form(page){
	switch(page){
		case 'product':
			if(document.product_form.color.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Select the color.';
				document.product_form.color.focus();
			return false;
			}
			
			if(document.product_form.style.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Select the style.';
				document.product_form.style.focus();
			return false;
			}
			
			if(document.product_form.size.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Select the size.';
				document.product_form.size.focus();
			return false;
			}
			
			if(document.product_form.quantity.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Enter a quantity.';
				document.product_form.size.focus();
			return false;
			}
			var digits = "0123456789"; 
		 	
			for (var i = 0; i < document.product_form.quantity.value.length; i++)
			  {
				temp = document.product_form.quantity.value.substring(i, i+1)
			
				if (digits.indexOf(temp) == -1 &&
				 document.product_form.quantity.value != "")
				{
				  document.getElementById("cart_message_product").innerHTML = 'Enter a number for quantity';
				  return false;
				}
			  } 			
		break;
		
		case 'prints':
			if((document.product_form.elle_diablo.checked == false) && (document.product_form.el_bastardo.checked == false)){
				document.getElementById("cart_message").innerHTML = 'You need to select a print.';
				document.product_form.elle_diablo.focus();
				return false;
			}
		break;
	}
}

function add_to_cart(page){
		switch(page){
		case 'product':
			if(document.product_form.color.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Select the color.';
				document.product_form.color.focus();
			return false;
			}
			
			if(document.product_form.style.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Select the style.';
				document.product_form.style.focus();
			return false;
			}
			
			if(document.product_form.size.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Select the size.';
				document.product_form.size.focus();
			return false;
			}
			
			if(document.product_form.quantity.value == ""){
				document.getElementById("cart_message_product").innerHTML = 'Enter a quantity.';
				document.product_form.size.focus();
			return false;
			}
			 
			var digits = "0123456789"; 
		 	
			for (var i = 0; i < document.product_form.quantity.value.length; i++)
			  {
				temp = document.product_form.quantity.value.substring(i, i+1)
			
				if (digits.indexOf(temp) == -1 &&
				 document.product_form.quantity.value != "")
				{
				  document.getElementById("cart_message_product").innerHTML = 'Enter a number for quantity';
				  return false;
				}
			  } 
			
			id = document.product_form.id.value;
			color = document.product_form.color.value;
			style = document.product_form.style.value;
			size = document.product_form.size.value;
			quantity = document.product_form.quantity.value;
			
			$.post("script/cart_update.php", {id: ""+id+"", color: ""+color+"", style: ""+style+"", size: ""+size+"", quantity: ""+quantity+""}, function(data){
				document.getElementById("cart_message_product").innerHTML = 'Your item has been added to the cart.';
			});	
			
			document.product_form.color.value = '';
			document.product_form.size.value = '';
			document.product_form.style.value = '';
			document.product_form.quantity.value = '1';
		break;
		
		case 'prints':
			if((document.product_form.elle_diablo.checked == false) && (document.product_form.el_bastardo.checked == false)){
				document.getElementById("cart_message").innerHTML = 'You need to select a print.';
				document.product_form.elle_diablo.focus();
				return false;
			}
			
			diablo = 0;
			bastardo = 0;
			id = 'prints';
			
			
			
			if(document.product_form.elle_diablo.checked == true){
				diablo = 1;	
			}
			
			if(document.product_form.el_bastardo.checked == true){
				bastardo = 1;
			}

			$.post("script/cart_update.php", {id: ""+id+"", elle_diablo: ""+diablo+"", el_bastardo: ""+bastardo+""}, function(data){
				document.getElementById("cart_message").innerHTML = 'Your item has been added to the cart.';
			});	
	
			document.product_form.elle_diablo.checked = false;
			document.product_form.el_bastardo.checked = false;
		break;
	}
}

function image_change(img){
	document.getElementById('product_image').innerHTML = '<img src="img/product_page/' + img + '.jpg" />';
	return true;	
}









