/////////////////////////////////////////////////////////////////////////////////////
// SCRIPT : fonctionnalités de base du site
// ...
/////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////
// SOMMAIRE :
// Fonctions générales
// - Mailto
// - Envoie des dates sur la page d'accueil
// - Clignotement
// - Menu gauche
// - Vide un champs 
// Fonctions clients
// Fonctions panier
// Popup
/////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////
// Fonctions générales
/////////////////////////////////////////////////////////////////////////////////////

// Aller a une page 
function allerA(page) {
	document.location.href=page;
}

// Mailto
function encodeMailto(a,b,c){
	var tg="<";
	var name=a;
	var at="@";
	var host=b;
	var text="Email direct";
	document.write(tg+"a hr"+"ef=mai"+"lto:"+name);
	document.write(at+host+" class='"+c+"'>"+text+tg+"/a>");
}

// Envoie des dates sur la page d'accueil
function sendDate(type){
	$('type_date').value=type;	
	$('choisir').submit();	
}

// Clignotement
function blinkIt(){
	if (!document.all){
		return;
	}else{
		for(i=0;i<document.all.tags('blink').length;i++){
			s=document.all.tags('blink')[i];
			s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
		}
	}
}
setInterval('blinkIt()',500)

// Menu gauche
window.addEvent('domready', function() {
	if($('menuGauche')){
		var accordion = new Accordion('div.toggler', 'div.content', {
			display: ouverturesousmenugauche,
			opacity: false,
			duration: 400,
			alwaysHide: true
		});
	}
});

// Vide un champs 
function clearChamp(elt,defaut){
	if(defaut){
		if(elt.value==defaut){
			elt.value='';
		}
	}else{
		elt.value='';
	}
}

/* Ajouter au favoris */
function favoris() {
	/* IE */
	if ( navigator.appName != 'Microsoft Internet Explorer' ){ 
		window.sidebar.addPanel("Votre Horoscope Du Jour","http://www.votrehoroscopedujour.com/",""); 
	}
	/* FireFox */
	else { 
		window.external.AddFavorite("http://www.votrehoroscopedujour.com/","Votre Horoscope Du Jour"); 
	} 
}

/////////////////////////////////////////////////////////////////////////////////////
// Fonctions clients
/////////////////////////////////////////////////////////////////////////////////////

// Se loguer
function logClient(prefixe){
	el = $(prefixe+'login');
	ep = $(prefixe+'password');
	login = '';
	pass = '';
	if(el){login = el.value;}
	if(ep){pass = ep.value;}
	$('AddToBasket').setAttribute("src", 'login-client.php?password='+pass+'&login='+login);
	return false;
}

// Se déloguer
function unlogClient(){
	$('AddToBasket').setAttribute("src", 'login-client.php?out=1');
	//return false;
}

/////////////////////////////////////////////////////////////////////////////////////
// Fonctions panier
/////////////////////////////////////////////////////////////////////////////////////

// ajoute un produit au panier
function ajoutProduitPanier(id_produit){	
	$('AddToBasket').setAttribute("src", 'ajout-panier.php?id_produit=' + id_produit);
}

/////////////////////////////////////////////////////////////////////////////////////
// Popup
/////////////////////////////////////////////////////////////////////////////////////
// Ouvrir une fausse popup
function ouvrirPopup(page,w,h){
	if(!w || w==0){w=600;}
	if(!h || h==0){h=300;}
	SqueezeBox.fromElement(page, { handler:'iframe',size:{x:w,y:h} });
}
// CGV
function PopupVoyanceTel(id) {
	ouvrirPopup("popup-voyance-tel.php?id_produit="+id,500,150);
	//SqueezeBox.assign($$('a.aPopIframe'));
};