var xmlHttp;
var prev_function_name=new Array();
var prev_products_id=new Array();
var search=new Array();
var keyword=new Array();
var from_search=0;
//var APP_BASE_NAME="http://www.versionvin.com/_beta/";

var url=document.location.href;
if(url.indexOf("/1000bourgognes.com/")>0)
{
	document.location.href=url.replace("http://","http://www.");
}
function hide(divname)
{
	if(document.getElementById(divname)){
		document.getElementById(divname).style.display="none";
		document.getElementById(divname).style.display="";
		//document.getElementById(divname).innerHTML=banner;
	}
}

function seo(title, keywords, description)
{
	document.charset="ISO-8859-15";

	if (document.getElementsByTagName) {
		var lungime=document.getElementsByTagName('meta').length;
	
	var meta;var i;
	for(i=0;i<lungime;i++)
		{
			
			meta=document.getElementsByTagName('meta')[i];
			if(meta.name=="description") meta.content=description;
			if(meta.name=="keywords") meta.content=keywords;
	}
	}
	document.title='1000bourgognes.com : '+title;
	
}

function setcookie(value)
{
	
	var test='';
	test=getCookie("function_name");
	document.cookie="function_name="+value+";path=/";
	var nr=new Array();
	if(getCookie("prev_function_name")){var tmp=getCookie("prev_function_name");
	var nr=tmp.split(",");
	var id=nr.length;
	prev_function_name[id]=value;}
	else prev_function_name[0]=value;
	document.cookie="prev_function_name="+prev_function_name+";path=/";
mf_inchis('login')
	
}

function setcookie_prodid(value)
{
	
	var test='';
	var prev_prod_id=getCookie("products_id");

	document.cookie="products_id="+value+";path=/";
	//document.cookie="prev_products_id="+prev_prod_id+";path=/";
	var nr=new Array();
	if(getCookie("prev_products_id"))
	{
		var tmp=getCookie("prev_products_id");
		var nr=tmp.split(",");
		var id=nr.length;
	}else id=0;
	prev_products_id[id]=value;
	document.cookie="from_search=0;path=/";

	document.cookie="prev_products_id="+prev_products_id+";path=/";
	mf_inchis('login')
}
function mf_inchis(id) {

	var x = 'none'
	if(document.getElementById(id)) document.getElementById(id).style.display = x;
	//if(id=="login") refreshLoginBox();
}
function setcookie_search(value,keyword)
{
	var prev_search=getCookie("search");
	document.cookie="search_str="+value+";path=/";
	document.cookie="from_search=1;path=/";
	var nr=new Array();
	if(getCookie("search"))
	{
		var tmp=getCookie("search");
		var nr=tmp.split(",");
		var id=nr.length;
	}else id=0;
	search[id]=value;
	document.cookie="search_str="+search+";path=/";
	
	var prev_keyword=getCookie("keyword");
	document.cookie="keyword_str="+keyword+";path=/";
	var nr=new Array();
	if(getCookie("keyword"))
	{
		var tmp=getCookie("keyword");
		var nr=tmp.split(",");
		var id=nr.length;
	}else id=0;
	keyword[id]=value;
	document.cookie="keyword_str="+keyword+";path=/";
	mf_inchis('login')
}
function image_preloader(divname)
{
	if(document.getElementById(divname)) document.getElementById(divname).innerHTML="<div id='loading'><img src='http://1000bourgognes.com/preloader/ajax-loader.gif' /><p>En cours de chargement...</p></div>";
}

function image_preloader_mic(divname)
{
	if(document.getElementById(divname)) document.getElementById(divname).innerHTML="<div id='loading'><img src='http://1000bourgognes.com/preloader/ajax-loader-mic.gif' /><p>En cours de chargement...</p></div>";
}

function ascundere_cos(id)
{
	if (document.getElementById(id)) {
		document.getElementById(id).style.display="none";	
	}
}

function getCookie( name ) 
{
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	//alert(document.cookie);
	if ( ( !start ) && 	( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	
	return unescape( document.cookie.substring( len, end ) );
}


//cart stuff
function  productsAddToCart(str,products_id,selectId)
{
	activare_cos('cos');
	//image_preloader_mic('cos');
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if(str=="buy_now")
	{
		var index=document.getElementById(selectId);
		var quantity = index.options[index.selectedIndex].value;
	
	}
	else if(str=="add_product") quantity=selectId;
	else quantity=selectId;
	alert("Ce produit a été ajouté à votre panier");
	var url="shopping_cart.php"
	url=url+"?products_id="+products_id+"&action="+str+"&quantity="+quantity;
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=AddToCart 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
	
	
}

function  productsAddToCartMare(str,products_id,selectId)
{
	ascundere_cos("cos");
	image_preloader('main_content');
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if(str=="buy_now")
	{
		var index=document.getElementById(selectId);
		var quantity = index.options[index.selectedIndex].value;
	
	}
	else if(str=="add_product") quantity=selectId;
	else quantity=selectId;
	
	var url="shopping_cart_mare.php"
	url=url+"?products_id="+products_id+"&action="+str+"&quantity="+quantity+"&url=shopping_cart_mare.php";
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
}
function  productsListCart(str)
{
	image_preloader_mic('cos');
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="shopping_cart.php"
	//url=url+"?products_id="+products_id+"&action="+str+"&quantity="+quantity;
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=AddToCart 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
}
function  refreshLoginBox(str)
{
	
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="login.php"
	//url=url+"?products_id="+products_id+"&action="+str+"&quantity="+quantity;
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=AddToCart 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
}
function  showLoginPage(str)
{
	image_preloader("main_content");
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="login.php"
	url=url+"?sid="+Math.random()+str
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
}

function showShoppingCart(str) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="shopping_cart_mare.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showShoppingCart');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showShoppingCart')
}

function showCheckoutShipping(str) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkout_shipping.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCheckoutShipping');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showCheckoutShipping')
}

function showCheckoutSuccess(str) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkout_success.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCheckoutSuccess');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showCheckoutSuccess')
	
}
function showCheckoutProcess(str,orders_id) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkout_process.php"
	url=url+"?process=1&checkout_process"
	//alert(str);
	if(str=="paybox") url+="&paybox=1";
	if(orders_id!='') url+="&orders_id="+orders_id;
	url=url+"&sid="+Math.random()

	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCheckoutProcess');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showCheckoutProcess')
	
}
function showCheckoutPayment(str,orders_id) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkout_payment.php"
	url=url+"?payment_error="+str
	
		if(orders_id>0) url+="&orders_id="+orders_id;

	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCheckoutPayment');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showCheckoutPayment')
	
}

function showNewsletterUnsubscribe(str) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="newsletters_unsubscribe.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showNewsletterUnsubscribe');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showNewsletterUnsubscribe')
	
}

function showCheckoutShippingAddress(str) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkout_shipping_address.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCheckoutShippingAddress');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showCheckoutShippingAddress')
}

function showCheckoutPaymentAddress(str) 
{ 
	ascundere_cos('cos');
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkout_payment_address.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCheckoutPaymentAddress');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showCheckoutPaymentAddress')
}
//end cart stuff

function showProductsZones(str,name,page)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="index.php"
	url=url+"?appellations_id="+str
	
	if(page!='') url+="&page="+page;
	url=url+"&name="+name;
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
    hide('newsletter');
	setcookie('showProductsZones');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showProductsZones')
}

function showProductsZonesPremier(str,name,page)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="index.php"
	url=url+"?appellations_premier_id="+str
	
	if(page!='') url+="&page="+page;
	url=url+"&name="+name;
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
    hide('newsletter');
	setcookie('showProductsZones');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showProductsZones')
}


function showTellAFriend(str)
{
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	
	var url="tell_a_friend.php"
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
    if(str=='[object Window]') str=1;
    hide('newsletter');
	setcookie('showTellAFriend');
	setcookie_prodid(0);
	seo(str,str,str);
	makeHistory(reportOptionValue(str),'showTellAFriend')
	
}
function makePOSTRequest(url, parameters) {
     xmlHttp=GetXmlHttpObject()
      
      xmlHttp.onreadystatechange = stateChanged;
      xmlHttp.open('POST', url, true);
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
	 
      xmlHttp.setRequestHeader("Connection", "close");
      xmlHttp.send(parameters);
   }
function getAllPostElements(form_name,url)
{
	var i;
	var params='';
	//alert(document.getElementById(form_name).elements.length);
	for(i=0;i<document.getElementById(form_name).elements.length;i++)
	{
	//alert(document.getElementById(form_name).elements[i].type+" "+document.getElementById(form_name).elements[i].value);
		if(document.getElementById(form_name).elements[i].type=="radio" || document.getElementById(form_name).elements[i].type=="checkbox" ){
			if( document.getElementById(form_name).elements[i].checked ) 		params+="&"+document.getElementById(form_name).elements[i].name+'='+encodeURI(document.getElementById(form_name).elements[i].value);
				//alert(document.getElementById(form_name).elements[i].name+" "+document.getElementById(form_name).elements[i].value);

			if( document.getElementById(form_name).elements[i].checked && document.getElementById(form_name).elements[i].name=="payment" && document.getElementById(form_name).elements[i].value=="moneyorder") url+="?process=1";
		}
		else
		params+="&"+document.getElementById(form_name).elements[i].name+'='+encodeURI(document.getElementById(form_name).elements[i].value);
	}
	//alert(url);
	makePOSTRequest(url,params);
}
function submitLoginBox(str)
{ 
	mf('login')
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	//var name=document.loginform.username.value;
	//var pass=document.loginform.password.value;
	var name=document.getElementById("username").value;
	var pass=document.getElementById("pass").value;
	
	if(name=="Votre e-mail" || pass=="password") alert("Enter your name and password");
	else{
	var url="login.php"
	url=url+"?q="+str+"&action=process"
	url=url+"&email_address="+name+"&password="+pass
	url=url+"&sid="+Math.random()
	document.getElementById("login").style.display="none";
	document.getElementById("logout").style.display="block";
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
    hide('newsletter');
	showLoginBox();
	//setcookie('showDomains');
	//makeHistory(reportOptionValue(str),'showDomains')
	}
}
function showLoginBox(str)
{ 
	//mf('login')
	//image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	
	var url="test.php"
	url=url+"?q="+str+"&action=process"
	//url=url+"&email_address="+name+"&password="+pass
	url=url+"&sid="+Math.random()
	
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1;
    hide('newsletter');
	//setcookie('showDomains');
	//makeHistory(reportOptionValue(str),'showDomains')
	
}

//domains stuff
function showDomains(str)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="domains.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
    hide('newsletter');
	setcookie('showDomains');
	setcookie_prodid(0);
	seo('Nos Domaines','Nos Domaines','Nos Domaines');

	makeHistory(reportOptionValue(str),'showDomains')
}

function showDomainsDetails(str,name)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="domains_details.php"
	url=url+"?domains_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	hide('newsletter');
	setcookie('showDomainsDetails');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showDomainsDetails')
}
//end domains stuff


function showInfoPages(str,name)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	seo(name,name, name);
	var url="info_pages.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
    makeHistory(reportOptionValue(escape(name)),'showInfoPages')
	hide('newsletter');
	setcookie('showInfoPages');
	setcookie_prodid(str);
	//alert(window.history.length);
	//window.history[window.history.length]='index.php?showInfoPages='+str;
	
}

function showNews(str)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="news.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
	setcookie('showNews');
	setcookie_prodid(0);
	seo('Actualités','Actualités','Actualités');

	makeHistory(reportOptionValue(str),'showNews')
}
function showNewsArhive(str)
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="news.php"
	url=url+"?arhive=1"
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
	setcookie('showNewsArhive');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showNewsArhive')
}

function showNewsDetails(str,name)
{
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="news_details.php"
	url=url+"?news_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=0;
	hide('newsletter');
	setcookie('showNewsDetails');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showNewsDetails')
	
}

function showCreateAccount(str,name,customers_id) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="create_account.php"
	url=url+"?parent_id="+str+"&customers_id="+customers_id
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
	setcookie('showCreateAccount');
	setcookie_prodid(0);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showCreateAccount')
}

function showContactUs(str) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="contact_us.php"
	url=url+"?parent_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	str='[object Window]'
	if(str=='[object Window]') str=1;
	hide('newsletter');
	setcookie('showContactUs');
	setcookie_prodid(0);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showContactUs')
}

function showPasswordForgotten(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="password_forgotten.php"
	url=url+"?sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showPasswordForgotten');
	setcookie_prodid(0);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showPasswordForgotten')
}

function showEspacePro(str,name) 
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="espace_pro.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
	setcookie('showEspacePro');
	setcookie_prodid(0);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showEspacePro')
}

function showAdvancedSearch(str,name) 
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="advanced_search.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1
	setcookie('showAdvancedSearch');
	setcookie_prodid(0);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showAdvancedSearch')
}

function showAppellations(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="appellations.php"
	url=url+"?appellation="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
		if(str=='[object Window]') str=1
	setcookie('showAppellations');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showAppellations')
}
function showAppellationById(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="appellations_view.php"
	url=url+"?appellations_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1
	setcookie('showAppellationById');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showAppellationById')
}

function showAppellationPremierById(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="appellations_premier_view.php"
	url=url+"?appellations_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1
	setcookie('showAppellationPremierById');
	setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showAppellationPremierById')
}
function showCommandeEnQuantite(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="commande_en_quantite.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	

	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showCommandeEnQuantite');
	setcookie_prodid(0);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showCommandeEnQuantite')
}



function showProductInfo(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="product_info.php"
	url=url+"?products_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
   // setcookie('showProductInfo');
	//setcookie_prodid(str);
	seo(name,name,name);
	makeHistory(reportOptionValue(str),'showProductInfo')
}

function showAccountEdit(str) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="account_edit.php"
	url=url+"?products_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAccountEdit');
	setcookie_prodid(0);
	seo(str,str,str);
	makeHistory(reportOptionValue(str),'showAccountEdit')
}

function showAddressBook(str) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="address_book.php"
	url=url+"?sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAddressBook');
	setcookie_prodid(0);
	seo(str,str,str);
	makeHistory(reportOptionValue(str),'showAddressBook')
}

function showAddressBookProcess(id,actiune,confirm) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="address_book_process.php"
	url=url+"?"+actiune+"="+id
	url=url+"&action="+confirm
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAddressBookProcess');
	setcookie_prodid(0);
	//makeHistory(reportOptionValue(str),'showAddressBookProcess')
}

function showAccountPassword(str) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="account_password.php"
	url=url+"?sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAccountPassword');
	setcookie_prodid(0);
	seo(str,str,str);
	makeHistory(reportOptionValue(str),'showAccountPassword')
}

function showAccountHistory(str) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="account_history.php"
	url+="?page="+str;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAccountHistory');
	setcookie_prodid(0);
	seo(str,str,str);

	makeHistory(reportOptionValue(str),'showAccountHistory')
}

function showAccountNewsletter(str) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="account_newsletters.php"
	url=url+"?sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAccountNewsletter');
	setcookie_prodid(0);
	seo(str,str,str);
	makeHistory(reportOptionValue(str),'showAccountNewsletter')
}

function showAccountHistoryInfo(str,name) //facut de Andrei (copy/paste). f posibil sa nu fie chiar bine
{ 
	image_preloader("main_content");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="account_history_info.php"
	url=url+"?order_id="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	if(str=='[object Window]') str=1;
	hide('newsletter');
    setcookie('showAccountHistoryInfo');
	setcookie_prodid(str);
	seo(name,name,name);

	makeHistory(reportOptionValue(str),'showAccountHistoryInfo')
}

//search stuff
function submitRecherche(color_id,domain_id,appellation_id,classement_id,millesime_id,is_id)
{
	
	
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	if(is_id==0 || is_id==-1)
	{
		var color=document.getElementById(color_id);
		var color_value = color.options[color.selectedIndex].value;
		
		var domain=document.getElementById(domain_id);
		var domain_value = domain.options[domain.selectedIndex].value;

		var appellation=document.getElementById(appellation_id);
		var appellation_value = appellation.options[appellation.selectedIndex].value;

		var classement=document.getElementById(classement_id);
		var classement_value = classement.options[classement.selectedIndex].value;

		var millesime=document.getElementById(millesime_id);
		var millesime_value = millesime.options[millesime.selectedIndex].value;
	}
	else{
		var color_value = color_id;
		var domain_value=domain_id;
		var appellation_value=appellation_id;
		var classement_value = classement_id;
		var millesime_value = millesime_id;
		
	}
	
	
	var keyword='';
	if(document.getElementById("keyword") ){
	var url="index.php?keyword="+document.getElementById("keyword").value+"&";
	var keyword=document.getElementById("keyword").value;
	}else var url="index.php?";
	
	if(is_id==0) 
	{
		
		url=url+"colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	}
	else if(is_id==-1 )
	{	
		if(document.getElementById("avans") && document.getElementById("avans").checked) url=url+"colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
		else  url=url+"colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	}
	else if(is_id==-2) 
	{
		url=url+"colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value+"&keyword="+document.getElementById("keyword_home").value;
		var keyword=document.getElementById("keyword_home").value;
	}else  url=url+"colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value+"&page="+is_id;
	if(document.getElementById("avans") && !document.getElementById("avans").checked) is_id=-2;
	//if(document.getElementById("keyword_home")) document.getElementById("keyword_home").value='';
	url=url+"&sid="+Math.random()+"&afisare="+is_id
	url+="&decode=1"
	if(document.getElementById("keyword_home") && document.getElementById("keyword_home").value!='') url+="&display_search=0";
	image_preloader('main_content');
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
	setcookie('submitRecherche');
	var str=color_value+","+domain_value+","+appellation_value+","+classement_value+","+millesime_value+","+is_id;

	setcookie_search(str,keyword);
	
	makeHistory(reportOptionValue(str),'submitRecherche')
}
//end search stuff

function activare_checkbox(div_id)
{
	if(document.getElementById("avans").checked)
	{
		document.getElementById(div_id).style.display="block";
	}
	else 		document.getElementById(div_id).style.display="none";

}

function showAccount(str)
{
	 xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	
	
	image_preloader('main_content');
	var url="account.php"
	//url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	setcookie('showAccountHistoryInfo');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(str),'showAccount')
    hide('newsletter');
}

function showInvited(str)
{
	image_preloader('main_content');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="invited.php"
	//url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	seo(str,str,str);
    hide('newsletter');
}
function orderby(order,params,how,page)
{
	image_preloader('main_content');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="index.php"
	url=url+"?order="+order+"&page="+page+"&"+params+"&how="+how+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	//seo(str,str,str);
    hide('newsletter');
}

function orderby_search(color_id,domain_id,appellation_id,classement_id,millesime_id,order,how,is_id)
{
	 xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	
		var color_value = color_id;
		var domain_value=domain_id;
		var appellation_value=appellation_id;
		var classement_value = classement_id;
		var millesime_value = millesime_id;
	
	
	var url="index.php";
	
	
		
	url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	if(document.getElementById("keyword")) {
		url=url+"&keyword="+document.getElementById("keyword").value;
		
		
	}
	url=url+"&order="+order+"&"+"&how="+how

	url=url+"&sid="+Math.random()+"&page="+is_id
	image_preloader('main_content');
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
	
}
function showBouchon(str)
{
	image_preloader('main_content');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="bouchon.php"
	//url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	seo(str,str,str);
    hide('newsletter');
}

function showUsedBouchon(str)
{
	image_preloader('main_content');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="used_bouchon.php"
	url=url+"?page="+str;
	//url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	seo(str,str,str);
    hide('newsletter');
}
function showSpecials(name)
{
	image_preloader('main_content');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="specials.php"
	//url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	url=url+"?sid="+Math.random()
	seo(name,name,name);
	if(name>0) {url+="&page="+name;seo('OFFRES DECOUVERTES','OFFRES DECOUVERTES','OFFRES DECOUVERTES');}
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
	setcookie('showSpecials');
	setcookie_prodid(0);
	makeHistory(reportOptionValue(name),'showSpecials')
}

function showLogout()
{
	image_preloader('main_content');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var url="logoff.php"
	//url=url+"?colors_id="+color_value+"&domains_id="+domain_value+"&appellations_id="+appellation_value+"&classification_id="+classement_value+"&year="+millesime_value;
	url=url+"?sid="+Math.random()
	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
    hide('newsletter');
}
function stateChanged() 
{ 
	
	if (xmlHttp.readyState==4  || xmlHttp.readyState=="complete")
	{ 
		if (document.getElementById("main_content")) {
		document.getElementById("main_content").innerHTML=xmlHttp.responseText }
		if(document.getElementById("kk")) 	{document.checkout_confirmation.submit();}

	}
		
} 

function AddToCart() 
{ 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("cos").innerHTML=xmlHttp.responseText 
	} 
	
} 


function GetXmlHttpObject()
{ 
	
	var A;
 			
 			var msxmlhttp = new Array(
				'Msxml2.XMLHTTP.5.0',
				'Msxml2.XMLHTTP.4.0',
				'Msxml2.XMLHTTP.3.0',
				'Msxml2.XMLHTTP',
				'Microsoft.XMLHTTP');
			for (var i = 0; i < msxmlhttp.length; i++) {
				try {
					A = new ActiveXObject(msxmlhttp[i]);
				} catch (e) {
					A = null;
				}
			}
 			
			if(!A && typeof XMLHttpRequest != "undefined")
				A = new XMLHttpRequest();
			if (!A)
				sajax_debug("Could not create connection object.");
			return A;
}