// JavaScript Document
function change_selection(select_id,cat_id) {
	 document.location.href="change_select.php?select_id="+select_id+"&cat_id="+cat_id;
}
function change_selection_sscat(select_id,sscat_id,cat_id,sscat_parent) {
	 document.location.href="change_select.php?select_id="+select_id+"&sscat_id="+sscat_id+"&cat_id="+cat_id+"&sscat_parent="+sscat_parent;
}
function decrementPanier(i) {
  var input = document.getElementById("num"+i).value;
		if (input>1) {
			 document.getElementById("num"+i).value = (Number(input)-1);
		}
		return;
}

function incrementPanier(i) {
  var input = document.getElementById("num"+i).value;
	 document.getElementById("num"+i).value = (Number(input)+1);
		return;
}

function decrementPanier2(i,strurl,prod) {
  var input = Number(document.getElementById("numPan"+i).value)-1;
		if (input > 0) {
				url= "addPanier2.php?prod_id="+prod+"&quantite="+input+"&url="+strurl;
				document.location.href=url;
		}
		return;
}

function incrementPanier2(i,strurl,prod) {
  var input = Number(document.getElementById("numPan"+i).value)+1;
	 url= "addPanier2.php?prod_id="+prod+"&quantite="+input+"&url="+strurl;
		document.location.href=url;
		return;
}

function addpanier(sscat,prod,i,type_img,flag_popup) {
	 /*if (flag_popup == 0) {
			  return initAdspecify('lien1','cv1',500,300);
				window.open('popup_validation.php','_blank','width=200,height=200,scrollbars=1,left=' + ((screen.width - 640)/2) + ',top=200');
				
		} else {*/
				var input = document.getElementById("num"+i).value;
				url= "addPanier.php?sscat_parent="+sscat+"&prod_id="+prod+"&quantite="+input+"&add=1&type_img="+type_img;
				document.location.href=url;
		//}
}
function addpaniercat(cat_id,sscat,prod,i,type_img,flag_popup) {
	 /*if (flag_popup == 0) {
			  return initAdspecify('lien1','cv1',500,300);
				window.open('popup_validation.php','_blank','width=200,height=200,scrollbars=1,left=' + ((screen.width - 640)/2) + ',top=200');
				
		} else {*/
				var input = document.getElementById("num"+i).value;
				url= "addPanier.php?cat_id="+cat_id+"&sscat_parent="+sscat+"&prod_id="+prod+"&quantite="+input+"&add=1&type_img="+type_img;
				document.location.href=url;
		//}
}
function addpanier_select(current,prod,i,flag_popup) {
	 /*if (flag_popup == 0) {
				return initAdspecify('lien1','cv1',500,300);
		} else {*/
				var input = document.getElementById("num"+i).value;
				url= "addPanier.php?current="+current+"&selection=1&prod_id="+prod+"&quantite="+input+"&add=1";
				document.location.href=url;
		//}
}
function addpanierProd(prod,i,flag_popup) {
	 /*if (flag_popup == 0) {
				return initAdspecify('lien1','cv1',500,300);
		} else {*/
				var input = document.getElementById("num"+i).value;
				url= "addPanier.php?prod_id="+prod+"&selection=2&quantite="+input;
				document.location.href=url;
		//}
}


function show_promo(){
	 document.getElementById('nouveaute').style.visibility = 'hidden';
	 document.getElementById('nouveaute').style.position = 'absolute';
	 document.getElementById('promotion').style.visibility = 'visible';
	 document.getElementById('promotion').style.position = 'static';
}
function show_nouv(){
	 document.getElementById('promotion').style.visibility = 'hidden';
	 document.getElementById('promotion').style.position = 'absolute';
	 document.getElementById('nouveaute').style.visibility = 'visible';
	 document.getElementById('nouveaute').style.position = 'static';
}


function changeTypeImage(url,variable) {
	 url = url.replace('&type_img=0','');
	 url = url.replace('&type_img=1','');
	 url = url.concat("&type_img="+variable);
  document.location.href=url;
		return;
}

function tri(url,variable) {
	 for(i=0;i<20;i++) {
	   url = url.replace('&tri='+i,'');
		}
	 url = url.replace('&tri=a','');
	 url = url.replace('&tri=b','');
	 url = url.replace('&tri=c','');
	 url = url.replace('&tri=d','');
	 url = url.concat("&tri="+variable);
  document.location.href=url;
		return;
}

function affich_div(div_id) {
	 if(document.getElementById(div_id).style.visibility=='hidden') {
			 document.getElementById(div_id).style.visibility='visible';
			 document.getElementById(div_id).style.display='block';
		} else {
			 document.getElementById(div_id).style.visibility='hidden';
			 document.getElementById(div_id).style.display='none';
		}
}

function verifylocalite () {
	 if(document.getElementById('cp').value==''){
    document.getElementById('msg_error2').innerHTML='Veuillez inserer votre Code Postal !!';
		} else if(!isNaN(document.getElementById('cp').value) && document.getElementById('cp').value.substr(0,1)=='4') {
		  document.getElementById('msg_error').innerHTML = "Votre localit� est bien desservie en point service.<br/>Pour continuer votre inscription	<a href='#' onClick='return goInscript();'>Cliquez ici</a>";
		} else {
			 document.getElementById('msg_error').innerHTML = "D�sol�, votre localit� n�est pas desservie !!";
		}
		return false;
}

function verifylocaliteIndex () {
	
	 if(document.getElementById('cp').value == ''){
			  document.getElementById('cp').style.borderColor = '#FF0000';
		} else if(!isNaN(document.getElementById('cp').value) && document.getElementById('cp').value.substr(0,1)=='4') {
		  document.getElementById('msg_error').innerHTML = '<span style="font-size:9px">Votre localit� est bien desservie en point service.</span><p style="margin:0; padding:0; text-align:center"><a href="compte.php"><img src="images/commun/creer_compte.jpg" border="0" alt=""/></a></p>';
		} else {
			 document.getElementById('msg_error').innerHTML = "<span style='font-size:9px'>D�sol�, votre localit� n�est pas desservie !!</span>";
		}
		
}

function goInscript() {
		document.location.href='inscription.php';
		//window.close();
}

function auth_cond() {
	 var loginCond = document.getElementById('loginCond').value;
	 var passwordCond = document.getElementById('passwordCond').value;
		if(loginCond != '' && passwordCond != '') {
				x_authClient(loginCond, passwordCond, result_auth_cond);
		} else {
			 document.getElementById('myauthCond').style.visibility="visible";
    document.getElementById('myauthCond').style.display="block";
		}
}
function result_auth_cond(result) {
	 if(result==1) {
			 document.getElementById('myauthCond').style.visibility="visible";
		} else {
			 document.getElementById("dejaclient2").innerHTML = result;
		}
}

function auth_condCompte() {
	 var loginCond = document.getElementById('loginCond').value;
	 var passwordCond = document.getElementById('passwordCond').value;
		if(loginCond != '' && passwordCond != '') {
				x_authClient(loginCond, passwordCond, result_auth_condCompte);
		} else {
			 document.getElementById('myauthCond').style.visibility="visible";
    document.getElementById('myauthCond').style.display="block";
		}
}
function result_auth_condCompte(result) {
	 if(result==1) {
			 document.getElementById('myauthCond').style.visibility="visible";
				document.getElementById('dejaclient2').style.visibility="hidden";
		} else {
			 document.getElementById('dejaclient2').innerHTML = result;
				document.getElementById('dejaclient2').style.visibility="visible";
				document.getElementById('myauthCond').style.visibility="hidden";
				//document.location.href="compte.php";
				window.parent.location.href="liste.php";
				document.location.href="liste.php";
		}
}


function verify_selection () {
	
	 if(document.getElementById('cp').value == ''){
			  document.getElementById('cp').style.borderColor = '#FF0000';
		} else if(!isNaN(document.getElementById('cp').value) && document.getElementById('cp').value.substr(0,1)=='4') {
		  document.getElementById('msg_error').innerHTML = '<span style="font-size:9px">Votre localit� est bien desservie en point service.</span><p style="margin:0; padding:0; text-align:center"><a href=""><img src="images/commun/creer_compte.jpg" border="0" alt=""/></a></p>';
		} else {
			 document.getElementById('msg_error').innerHTML = "<span style='font-size:9px'>D�sol�, votre localit� n�est pas desservie !!</span>";
		}
		
}


function addtolist(list_id,prod_id,quantite) {
	 if(list_id != 0)  {
			 x_addtolist(list_id, prod_id, quantite, result_addtolist);
		}
}

function result_addtolist(result) {
	 if(result==1) {
			 dhtmlwindow.open("offre", "iframe", "popup_confirmation_liste.php", "Mes Liste", "width=300px,height=100px,resize=0,scrolling=1,center=1,left=300px,top=100px", "recal")
		}
}

function supplist(list_id) {
	 if(list_id != 0)  {
			 x_supplist(list_id, result_supplist);
		}
}
function result_supplist(result) {
	 if(result==1) {
				window.parent.location.href="mes-listes.php";
		}
}





