


function narrow_search(cat_level,cat_code)
{

	var brand=document.getElementById('narrow_brand').value;
	var color=document.getElementById('narrow_color').value;
	var p_size=document.getElementById('narrow_p_size').value;
	var price=document.getElementById('narrow_price').value;


	//alert(price);
	
	url='ajax-narrow-product-search.php?cat_level='
	url =url+cat_level
	url += '&';
	url += 'cat_code=';
	url =url+cat_code;
	url += '&';
	url += 'brand=';
	url =url+brand;
	url += '&';
	url += 'color=';
	url =url+color;
	url += '&';
	url += 'p_size=';
	url =url+p_size;
	url += '&';
	url += 'price=';
	url =url+price;

	javascript:void(0);
	new Ajax.Updater('main2', url);

	url='ajax-narrow-product-search.php?cat_level='
	url =url+cat_level
	url += '&';
	url += 'cat_code=';
	url =url+cat_code;
	url += '&';
	url += 'brand=';
	url =url+brand;
	url += '&';
	url += 'color=';
	url =url+color;
	url += '&';
	url += 'p_size=';
	url =url+p_size;
	url += '&';
	url += 'price=';
	url =url+price;


	javascript:void(0);
	new Ajax.Updater('main2', url);
}

function reset_narrow_search(cat_level,cat_code,brand,color,p_size,price)
{

	
	url='ajax-narrow-product-search.php?cat_level='
	url =url+cat_level
	url += '&';
	url += 'cat_code=';
	url =url+cat_code;
	url += '&';
	url += 'brand=';
	url =url+brand;
	url += '&';
	url += 'color=';
	url =url+color;
	url += '&';
	url += 'p_size=';
	url =url+p_size;
	url += '&';
	url += 'price=';
	url =url+price;



	javascript:void(0);
	new Ajax.Updater('main2', url);

	url='ajax-narrow-product-search.php?cat_level='
	url =url+cat_level
	url += '&';
	url += 'cat_code=';
	url =url+cat_code;
	url += '&';
	url += 'brand=';
	url =url+brand;
	url += '&';
	url += 'color=';
	url =url+color;
	url += '&';
	url += 'p_size=';
	url =url+p_size;
	url += '&';
	url += 'price=';
	url =url+price;



	javascript:void(0);
	new Ajax.Updater('main2', url);
}

function tranpagelink2(from,page,first,last,click,bot,search_vars)
{


	url='ajax-tran-page-link.php?page='
	url +=+page
	url += '&';
	url += 'first=';
	url +=+first;
	url += '&';
	url += 'last=';
	url +=+last;
	url += '&';
	url += 'click=';
	url +=+click;
	url += '&';
	url += 'from=';
	url =url+from;
	url += '&';
	url += 'bot=';
	url +=+bot;
	url += '&';
	url += 'search_vars=';
	url =url+search_vars;


	javascript:void(0);
	new Ajax.Updater('main2',url );
}

function switch_img(img)
{
	//alert(img);
	url='ajax-switch-image.php?img='
	url =url+img


	javascript:void(0);
	new Ajax.Updater('main_img',url );
}

function centerElement(elem) {
    var intH = 0, intW = 0;
    
    if(self.innerHeight) {
       intH = window.innerHeight;
       intW = window.innerWidth;
    } 
    else {
        if(document.documentElement && document.documentElement.clientHeight) {
            intH = document.documentElement.clientHeight;
            intW = document.documentElement.clientWidth;
        }
        else {
            if(document.body) {
                intH = document.body.clientHeight;
                intW = document.body.clientWidth;
            }
        }
    }
//alert (intH+'='+intW);
    var scrollY = 0;

scrollY += document.body.parentNode.scrollTop;
//alert ('3='+scrollY)


    var left = Math.round(intW  / 2)-390;
    var top = Math.round(intH  / 2)-350+scrollY;
//alert(left+'='+top);
    document.getElementById(elem).style.left = left + 'px';
    document.getElementById(elem).style.top = top + 'px';

   "viewport = left = top = ele = null;"
    
}

function showshoppinginfo(pro_code,pro_name,pro_price,pro_color,s_type) {
//alert(pro_code+pro_name+pro_price+pro_color+s_type);
    // Process HTTP response and update input form
    centerElement("shoppinginfoWaiting");
    document.getElementById("shoppinginfoWaiting").className = "shoppinginfowaitingshow";
    centerElement("shoppinginfo");
	saveItem(pro_code,pro_name,pro_price,pro_color,s_type);
     // next row it should be after saving item on cart
    document.getElementById("shoppinginfoWaiting").className = "shoppinginfowaitinghide";
    document.getElementById("shoppinginfo").className="shoppinginfoShow";
    	make_table_detail(pro_code,pro_name,pro_price,pro_color,s_type);
}

function showshoppinginfoFailure() {
    // Process HTTP response and update input form
   document.getElementById("basketWaiting").className = "shoppinginfowaitinghide";
   alert("Problem: " + transport.statusText);
}

function hideshoppinginfo(){
  document.getElementById("shoppinginfo").className="shoppinginfoHide";
}

function make_table_detail(pro_code,pro_name,pro_price,pro_color,s_type)
{

	var qty=document.getElementById('qty_in').value
	var size=document.getElementById(pro_code).value

	url='ajax-make_detail_table.php?pro_code='
	url =url+pro_code
	url += '&';
	url += 'pro_name=';
	url =url+pro_name;
	url += '&';
	url += 'pro_price=';
	url =url+pro_price;
	url += '&';
	url += 'pro_color=';
	url =url+pro_color;
	url += '&';
	url += 'qty=';
	url =url+qty;
	url += '&';
	url += 's_type=';
	url =url+s_type;
	url += '&';
	url += 'pro_size=';
	url =url+size;
	//alert(type+id)	
	javascript:void(0);
	new Ajax.Updater('shoppinginfo', url);
}

function saveItem(pro_code,pro_name,pro_price,pro_color,s_type)
{

	var qty=document.getElementById('qty_in').value
	var size=document.getElementById(pro_code).value
	if(s_type == 'Buy X Get Y')
	{
		var y_size=document.getElementById('y_size').value

	}else{
		
		var y_size=0;
	}

	url='ajax_save_http_item.php?pro_code='
	url =url+pro_code
	url += '&';
	url += 'pro_name=';
	url =url+pro_name;
	url += '&';
	url += 'pro_price=';
	url =url+pro_price;
	url += '&';
	url += 'pro_color=';
	url =url+pro_color;
	url += '&';
	url += 'qty=';
	url =url+qty;
	url += '&';
	url += 's_type=';
	url =url+s_type;
	url += '&';
	url += 'pro_size=';
	url =url+size;
	url += '&';
	url += 'y_size=';
	url =url+y_size;

	javascript:void(0);
	new Ajax.Updater('cart', url);

}

function check_size(pro_code,s_type)
{
	var size=document.getElementById(pro_code).value
	if(s_type == 'Buy X Get Y')
	{
		var y_size=document.getElementById('y_size').value

	}else{
		
		var y_size=0;
	}

	if(size == -1 )
	{
		alert('Please select the size you would like.');
		return false;
	}else{

		if(y_size == -1 )
		{
			alert('Please select the size for your free item.');
			return false;
		}else{
			return true;
		}
	}
}

function replacewithreg(str)
{
	var myString = new String(); 
	myString = str; 
	var myRegExp = new RegExp( /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g); 
	var myResult = myString.replace(myRegExp, "");
	var ss1=str.length
	var ss2=myResult.length
	if(ss1>ss2)
	{
		alert('Please Do not use any special character included !@#$%^&*()+=-[]\\\';,./{}|\":<>?');
		myResult=false;
	}
	return  myResult
}

function clientvalidate()
{
	//alert('user')
	if (document.Formlogin.e_mail.value=="")
	{
		alert("Please fill the E-mail.")
		document.Formlogin.e_mail.focus()
		return false
	}else{
		var user=document.Formlogin.e_mail.value;
			
	}
		
	if (document.Formlogin.pass.value=="")
	{
		alert("Please fill the password.")
		document.Formlogin.pass.focus()
		return false
	}else{
		var str=document.Formlogin.pass.value
		var v2=replacewithreg(str)
		if(v2==false)
		{
			document.Formlogin.pass.focus();
			return false;
		}else{

			var pass=document.Formlogin.pass.value;
			
		}
	}

	

	var wlog=document.Formlogin.wlog.value;

	url='ajax_check_client_login.php?user='
	url =url+user
	url += '&';
	url += 'pass=';
	url =url+pass;
	url += '&';
	url += 'wlog=';
	url =url+wlog;	
	//alert(url)

	javascript:void(0);
	new Ajax.Updater('', url);
	//updateaccountlink();
			
return true
}

function controlshippingaddress(id)
{
	var form=document.getElementById(id);

	if(form.checked == true)
	{
		var ad1=document.edit_client.address1.value;
		var ad2=document.edit_client.address2.value;
		var post_code=document.edit_client.post_code.value;
		var city=document.edit_client.city.value;
		var county=document.edit_client.county.value;

		document.edit_client.sh_address1.value=ad1;
		document.edit_client.sh_address2.value=ad2;
		document.edit_client.sh_post_code.value=post_code;
		document.edit_client.sh_city.value=city;
		document.edit_client.sh_county.value=county;

		
	}else{
		document.edit_client.sh_address1.value='';
		document.edit_client.sh_address2.value='';
		document.edit_client.sh_post_code.value='';
		document.edit_client.sh_city.value='';
		document.edit_client.sh_county.value='';
		
	}
}

function addshipping(shipping_id)
{
	
	var shipping_str=document.getElementById(shipping_id).value

	url='ajax_add_http_shipping.php?shipping_str='
	url =url+shipping_str


	javascript:void(0);
	new Ajax.Updater('cart-area', url);
}

function deleteitem(code,offer,deal,size,y_size)
{
	
	url='ajax_delete_http_item.php?code='
	url =url+code;
	url += '&';
	url += 'offer=';
	url =url+offer;	
	url += '&';
	url += 'deal=';
	url =url+deal;
	url += '&';
	url += 'size=';
	url =url+size;
	url += '&';
	url += 'y_size=';
	url =url+y_size;		


	javascript:void(0);
	new Ajax.Updater('cart-area', url);
	
	updatecarttoplink();

}

function updatecart()
{
//alert('update')
	javascript:void(0);
	new Ajax.Updater('cart-area', 'ajax_update_cart.php');
}

function updatecarttoplink()
{
//alert('update')
	javascript:void(0);
	new Ajax.Updater('cart', 'ajax_update_top_link_cart.php');
}

function saveqty(qty_name,code,offer,size,y_size)
{
	//alert(qty_name)
	var qty=document.getElementById(qty_name).value

	url='ajax_update_http_item_qty.php?qty='
	url =url+qty
	url += '&';
	url += 'code=';
	url =url+code;
	url += '&';
	url += 'offer=';
	url =url+offer;
	url += '&';
	url += 'size=';
	url =url+size;
	url += '&';
	url += 'y_size=';
	url =url+y_size;			
	//alert(url)

	javascript:void(0);
	new Ajax.Updater('cart', url);

}

function checkshipping()
{

	var form=document.getElementById('service_name');
	var shipping=form.options[form.selectedIndex].value;

	if(shipping == '0=0')
	{
		alert('Please select a delivery option.');
	}else{
		
		javascript:void(0);
		new Ajax.Updater('','ajax_update_shipping_checkout_click.php?value='+shipping );
		document.getElementById('checkout1').href="login-both.php?wlog=confirmation";	
	}
}

function checkshipping2()
{
	var form=document.getElementById('service_name');
	var shipping=form.options[form.selectedIndex].value;

	if(shipping == '0=0')
	{
		alert('Please select a delivery option.');
	}else{
		javascript:void(0);
		new Ajax.Updater('','ajax_update_shipping_checkout_click.php?value='+shipping );
		document.getElementById('checkout2').href="confirmation.php";	
	}
}

function saveorder()
{
	
	url='ajax_save_order.php';
	javascript:void(0);
	new Ajax.Updater('', url);

return true
}

function addpcode()
{
	var p_code=document.getElementById('p_code').value;
	//alert(p_code);
	javascript:void(0);
	new Ajax.Updater('cart-area', 'ajax_update_cart.php?p_code='+p_code);

}
function addnewsletter()
	{
	if (document.getElementById('emailnl').value=="")
	{
		alert("Please fill the E-mail.")
		getElementById('emailnl').focus()
		return false
	}else{	
	var emailnl=document.getElementById('emailnl').value;
		javascript:void(0);
		new Ajax.Updater('nl', 'ajax_send_mail_join.php?emailnl='+emailnl);
	}

}
function unsethttpvars()
{
	javascript:void(0);
	new Ajax.Updater('','ajax-unset-http-vars.php' );
} 
