// www.pixele.fr //
//url = "http://nicko/lemagazinedelatouraine/site/";
url = "http://www.lemagazinedelatouraine.com/";

/* DHTML */
function fadeIn(opacity){
	if (document.getElementById) {
		obj = document.getElementById('confirm');
		obj.style.display = "";
		if (opacity <= 100){
			setOpacity(opacity);
			opacity += 4;
			window.setTimeout("fadeIn("+opacity+")", 2);}
		}}

function fadeOut(opacity){
	if (document.getElementById) {
		obj = document.getElementById('confirm');
		if (opacity >= 0){
			setOpacity(opacity);
			opacity -= 4;
			window.setTimeout("fadeOut("+opacity+")", 2);}
		else{obj.style.display = "none";}
		}}

function setOpacity(opacity) {
	obj = document.getElementById('confirm');
	opacity = (opacity == 100)?99.999:opacity;
	obj.style.filter = "alpha(opacity="+opacity+")";
	obj.style.KHTMLOpacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
}


function sendData(data, page, action, cible){
	if(document.all){var XhrObj = new ActiveXObject("Microsoft.XMLHTTP");}else{var XhrObj = new XMLHttpRequest();}
	var content = document.getElementById(cible);
	if(data == 'null'){XhrObj.open("GET", page);}
	else{XhrObj.open("GET", page+"?"+data);}
	XhrObj.onreadystatechange = function(){if(XhrObj.readyState == 4 && XhrObj.status == 200){
		content.innerHTML = XhrObj.responseText;
		if(action == "confirm" ){
			fadeIn(0);
			}
		else if(action == "redir"){
			location.reload(); 
			}
	}}    
	XhrObj.send(null);
	}

function Cart(id){
		qte = document.getElementById('v_qte').value;
		sendData("v_art="+id+"&v_qte="+qte+"&increment=1", url+"inc/_panier.php" , "confirm","cart");
	}

function Upd(id,qte){
	sendData("v_art="+id+"&v_qte="+qte+"&display=no", url+"inc/_panier.php" , "redir","cart");
	}

function Del(id){
	sendData("del="+id+"&display=no", url+"inc/_panier.php" , "redir" , "cart");
	}

function NewsL(){
		email_newsletter = document.getElementById('email_newsletter').value;
		sendData("email_newsletter="+email_newsletter, url+"inc/blk_newsletter.php" , "","NewsL");
	}

function sameadress(){
	document.f_adr.liv_nom.value = document.f_adr.nom.value;
	document.f_adr.liv_prenom.value = document.f_adr.prenom.value;
	document.f_adr.liv_civilite.selectedIndex = document.f_adr.civilite.selectedIndex;
	document.f_adr.liv_adresse.value = document.f_adr.adresse.value;
	document.f_adr.liv_adresse2.value = document.f_adr.adresse2.value;
	document.f_adr.liv_code_postal.value = document.f_adr.code_postal.value;
	document.f_adr.liv_ville.value = document.f_adr.ville.value;
	document.f_adr.liv_pays.selectedIndex = document.f_adr.pays.selectedIndex;
	document.f_adr.liv_tel.value = document.f_adr.tel.value;
	document.f_adr.liv_tel2.value = document.f_adr.tel2.value;
}


function OuvrirVisible(page,height,width,top,left) {
    var w=window.open(page+".php","pop1","width="+width+",height="+height+",top="+top+",left="+left+", scrollbars=yes, resizable=no");
    w.document.close();
    w.focus();
}


function Photo(pho){
	document.getElementById("Pbig").src = pho;
}

//S MENU
sfHover = function(){
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++){		
		sfEls[i].onmouseover=function(){
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function(){
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");		
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function POn(pere){ document.getElementById(pere).style.backgroundPosition = "left -34px"; }
function POff(pere) { document.getElementById(pere).style.backgroundPosition = ""; }


//PP FLIP BOOK
//function popup livredor
function popup_livre(xml){
window.open(url+'pp_decouvrir.php?xml='+xml,'livre','width=770, height=558');
}


