function goToProducts(product_id, visit_date)
{
	window.location.href = "/shop/product.php?productid=" + product_id + "&visit_date=" + visit_date;
}

function getCookieId(name)
{ 
   var cookie = document.cookie.split("; ");
   for (i=0; i < cookie.length; i++)
   {
      value = cookie[i].split("="); 
      if (value[0] == name)
      { 
        result = value[1]; 
        return result;   
      }
   }
}

function getCookieDate(name)
{ 
   var cookie = document.cookie.split("; ");
   for (i=0; i < cookie.length; i++)
   {
      value = cookie[i].split("="); 
      if (value[0] == name)
      { 
        result = value[1]; 
        return result;   
      }
   }
}

function setCookie(name,value)
{	
	var path="/";   
    var today = new Date();
    var expires = new Date(); 
   	expires.setTime(today.getTime() + (1000*60*60));
    avviso=name + "=" + value + "; expires=" + expires.toGMTString() + "; path=" + path;
   	document.cookie=avviso;
}

function setCookieId(name, value)
{
	var path="/";
	var today = new Date();
    var expires = new Date();
	expires.setTime(today.getTime() + (1000*60*60));
	cercotesto = value.indexOf("&");//-1 se non esiste!!!
	startIndexId = value.indexOf("productid=")+10;
	value_length = value.length;
	//SENZA &CAT=...
	if (cercotesto == -1)
		only_id = value.substring(startIndexId, value_length);
		else
			only_id = value.substring(startIndexId, cercotesto)

	avviso=name + "=" + only_id + "; expires=" + expires.toGMTString() + "; path=" + path;
	document.cookie=avviso;
}

function setCookieIdExtraProducts(name, id)
{
	var path="/";
	var today = new Date();
    var expires = new Date();
	expires.setTime(today.getTime() + (1000*60*60));
	avviso=name + "=" + id + "; expires=" + expires.toGMTString() + "; path=" + path;
	document.cookie=avviso;
}

function goto_URL_extra_products(product_id)
{
    setCookieIdExtraProducts('product_id',product_id);
	window.location.href = "/shop/product.php?productid=" + product_id;
}

function goto_URL(link)
{
	window.location.href = link.options[link.selectedIndex].value;
}

function deleteCookieDate(name)
{
   var expireDate = new Date()
   expireDate.setDate(expireDate.getDate()-1000)
   document.cookie = name+"=;path=/;expires=" + expireDate.toGMTString()
}

function deleteCookieId(name)
{
   var expireDate = new Date()
   expireDate.setDate(expireDate.getDate()-1000)
   document.cookie = name+"=;path=/;expires=" + expireDate.toGMTString()
}

function lose_focus(){document.getElementById("campodata").blur();}
function get_focus(){document.getElementById("campodata").focus();} 
function show_select(){document.getElementById("biglietto").style.visibility="visible";} 
function hide_select(){document.getElementById("biglietto").style.visibility="hidden";} 
function enable_submit(){document.getElementById("invio").disabled = false;}
function disable_submit(){document.getElementById("invio").disabled = true;}