Ajax.Responders.register({
    onCreate : startLoading,
    onComplete : stopLoading
  });

function ajax_stock_box(){
 var myAjax = new Ajax.Updater('stock_box_div', 'ajax.stock.php', {method: 'post', parameters: 'colour='+escape($F('id[1]')) + '&size='+escape($F('size_select')) + '&pq='+escape($F('pq')) + '&product_id='+escape($F('productid')) });
}

function ajax_image_change(){
 var myAjax2 = new Ajax.Updater('ajax_image_div', 'ajax.changeimage.php', {method: 'post', parameters: 'colour='+escape($F('id[1]')) + '&product_id='+escape($F('productid')) });
}

function toggle( targetId ){
if (document.getElementById) {
 target = document.getElementById (targetId);
if (target.style.display == "none") {
 target.style.display = "";
 }
else {
 target.style.display = "none";
}
}
}

function toggle_off( targetId ){
if (document.getElementById) {
 target = document.getElementById (targetId);
 target.style.display = "none";
}
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,top=150,left=150')
}


var colour_selection="";
var size_selection = "";
var quantity_selection = "";

function check_colour()
{
if ((colour_selection=="") || (size_selection=="") || (quantity_selection==""))
{
if (colour_selection=="") {
alert("Please select a colour.");
return (false);
}
else if (size_selection=="")  {
alert("Please select a size.");
return (false);
}
else  {
alert("Please select the quantity required.");
return (false);
}
}
else {
if ( ($F('id[1]') == "") || ($F('size_select') == "") || ($F('pq') == "") ) {
alert("Please select colour, size and quantity.");
return (false);
}
}


return true;
}

function set_colour_dropdown(set_colour) {

for(var i=0;i<=document.getElementById('id[1]').length-1;i=i+1)
{
var ddlText=document.getElementById('id[1]').options[i].value;
if(ddlText==set_colour)
{
 document.getElementById('id[1]').selectedIndex=i;
 break;
}
}

colour_selection = "true";
ajax_image_change();
ajax_stock_box();
}

function showEmailToFriend(){
 new Effect.SlideDown('product_col_1_email_to_friend');
}

function hideEmailToFriend(){
 new Effect.SlideUp('product_col_1_email_to_friend');
}

function email_friend_form(){
 var myAjax = new Ajax.Updater('email_friend_div', 'ajax.emailfriend.php', {method: 'post', parameters: 'your_name='+escape($F('your_name')) + '&your_email='+escape($F('your_email')) + '&friends_name='+escape($F('friends_name')) + '&friends_email='+escape($F('friends_email')) + '&product_id='+escape($F('productid')) + '&pmes='+escape($F('pmes')) });
}

function add_to_wishlist(s1) {
 var myAjax2 = new Ajax.Updater('add_to_wishlist_div', 'ajax.addtowishlist.php', {method: 'post', parameters: 's1type=' + escape(s1) + '&product_id='+escape($F('productid')) });
}

function product_clear_loader() {
document.getElementById('ajax_image_div').style.background='url(images/spacer.gif)';
}

