function showHide(id){
   el = document.getElementById(id);
   el.style.display = (el.style.display != 'block')? 'block' : 'none';
}
function KeyIsNumber(KeyCode)
{
		var event = window.event;
if(event.shiftKey) return false;
//alert(KeyCode);
 //0-9(48-57),backspace(8),TAB(9),-(189),.(190),DEL(46)
 if(((KeyCode>47)&&(KeyCode<58))||((KeyCode>95)&&(KeyCode<106))||(KeyCode==109)||(KeyCode==110)||(KeyCode==8)||(KeyCode==9)||(KeyCode==37)||(KeyCode==39)||(KeyCode==46))
 {
 return true;
 }
 else
 {
 return false;
 }
}
function add_to_cart(item_id)
{
    return_false = 0;
    if( return_false == 0 ) { 
    	//document.logonform_header.operation.value = operation; 
    	//document.logonform_header.logon_id.value = document.forgot_password.email.value; 
    	//alert(document.shopping_cart_form.operation.value);
    	//alert(document.shopping_cart_form.item_id.value);
    	document.shopping_cart_form.item_id.value=item_id; 
    	document.shopping_cart_form.action=domain_url + "/shopping-cart"; 
    	document.shopping_cart_form.submit(); }
}
function modify_cart(operation, cookie_id)
{
    return_false = 0;

  	var allcookies = document.cookie;
  	var arrCookie=allcookies.split("; ");
		for(var i=0;i<arrCookie.length;i++){
			if( arrCookie[i].indexOf("shopping_cart[P_") >= 0 )
			{
				var cookie_pos = arrCookie[i].indexOf("P_");
				var cookie_end = arrCookie[i].indexOf("]", cookie_pos);
		    if (cookie_end == -1)
		    {
		    	cookie_end = arrCookie[i].length;
		    }
		    var obj;
		    
		    obj = document.getElementById(unescape(arrCookie[i].substring(cookie_pos, cookie_end)));
		    if( obj!=null )
		    {
		    	if( obj.value =="" )
		    	{
		    		alert("Quantity cannot empty");
		        obj.focus();
		        return;
		    	}
//		    	else alert(obj.value);
		    }
//		    else alert(unescape(arrCookie[i].substring(cookie_pos, cookie_end)));
			}
		}
    if( return_false == 0 )
    {
        document.shopping_cart_form.operation.value = operation;
        document.shopping_cart_form.cookie_id.value = cookie_id;
        //document.shopping_cart_form.action = "shoppingcart.php";
        document.shopping_cart_form.submit();
    }
}

function checkout(url_to)
{
  document.shopping_cart_form.operation.value = "CHECKOUT";
	if( url_to == 1 )
		document.shopping_cart_form.action = domain_url + "/billing-and-shipping-information";
	else
		document.shopping_cart_form.action = domain_url + "/checkout";
	document.shopping_cart_form.submit();
}
function getCookie(cookie_name)
{
  var allcookies = document.cookie;
  var cookie_pos = allcookies.indexOf(cookie_name);
  
  if (cookie_pos != -1)
  {
    cookie_pos += cookie_name.length + 1;
    var cookie_end = allcookies.indexOf(";", cookie_pos);
    
    if (cookie_end == -1)
    {
    	cookie_end = allcookies.length;
    }
    
    var value = unescape(allcookies.substring(cookie_pos, cookie_end));
  }
  
  return value;
}
function Logout(logout_url)
{
	return_false = 0;

	if( logout_url == "1" ){
		if( return_false == 0 ) { 
			document.shopping_cart_form.logout.value = "LOGOUT"; 
			document.shopping_cart_form.action = domain_url + "/login"; 
			document.shopping_cart_form.submit(); 
			}
	}else{
		if( return_false == 0 ) { 
			document.header_form.logout.value = "LOGOUT"; 
			document.header_form.action = domain_url + "/login"; 
			document.header_form.submit(); 
			}
	}
}
function change_currency(currency,logout_url)
{
	if( logout_url == "1" ){
		document.shopping_cart_form.currency.value = currency; 
		document.shopping_cart_form.submit(); 
	}else{
		document.header_form.currency.value = currency; 
		document.header_form.submit(); 
	}
}

