function show_cart(item_num,item_type)

{

Dialog.alert({url: "includes/cart.php?op=show_details&item="+item_num, options: {method: 'get'}}, {windowParameters: {className: "alert", width:175}, okLabel: "Close"});

}



function show_image()

{

document.getElementById('cart_main_wrap').style.display="none";

document.getElementById('image_large_div').style.display="";

}

function show_popup()

{

document.getElementById('image_large_div').style.display="none";

document.getElementById('cart_main_wrap').style.display="";

}

function update_quantity(item_type,the_value)

{

    var opt = {

    // Use POST

    method: 'GET',

    // Send this lovely data

    postBody: "",

    // Handle successful response

    onSuccess: function(t) {

		document.getElementById('quantity').innerHTML = t.responseText;

		document.getElementById('submit_button').style.display="";

    },

    // Handle 404

    on404: function(t) {

        alert('Error 404: location "' + t.statusText + '" was not found.');

    },

    // Handle other errors

    onFailure: function(t) {

        alert('Error ' + t.status + ' -- ' + t.statusText);

    }



}

if(the_value!='null')

new Ajax.Request('includes/cart.php?op=update_quantity&type='+item_type+'&id='+the_value, opt);

else

{

document.getElementById('submit_button').style.display="none";

document.getElementById('quantity').innerHTML = '';

}



}



function check_cart()

{

	if(document.getElementById('quantity').innerHTML != '')

	{	

	add_to_cart();

	Dialog.okCallback()

	}

	else

	alert('Please select a color / size.');

}



function select_color(the_max,the_color, the_key)

{

 for(i = 0; i<the_max;i++)

 {

  document.getElementById('color_'+i).style.border="none"

  document.getElementById('color_'+i).style.margin="1.5px 1.5px 1.5px 1.5px"

 }

  document.getElementById('color_'+the_color).style.border="1.5px solid white"

    document.getElementById('color_'+the_color).style.margin="0px 0px 0px 0px"

  document.getElementById('selected_color').innerHTML = '<input type="hidden" name="color" value="'+the_key+'">'

}



function add_to_cart()

{

the_form = new Form.serialize( 'cart_add' )

    var opt = {

    // Use POST

    method: 'GET',

    // Send this lovely data

    postBody: "",

    // Handle successful response

    onSuccess: function(t) {

		document.getElementById('num_cart').innerHTML = t.responseText;
        window.location="show_cart.php"
    },

    // Handle 404

    on404: function(t) {

        alert('Error 404: location "' + t.statusText + '" was not found.');

    },

    // Handle other errors

    onFailure: function(t) {

        alert('Error ' + t.status + ' -- ' + t.statusText);

    }



}

new Ajax.Request('includes/cart.php?op=add_to_cart&'+Form.serialize( 'cart_add' ), opt);



}



 /*

function show_cart(item_num)

{



}





	function showResponse(originalRequest)

	{

		//put returned XML in the textarea

		alert(originalRequest.responseText)

	}                          */