//============================================
	function noFct() {
//============================================
// JS vide
//============================================
}

//============================================
   function callback(hash) {
//============================================
// Run for ajaxContent history
//============================================
	// hash doesn't contain the first # character.
	if(hash) {
		// restore ajax loaded state
		$("#ajaxContent").load(hash);
		//alert(hash)
	} else {
		// start page
		$("#ajaxContent").empty();
	}
}


//============================================
   function jqueryLoad(page) {
//============================================
// Run init de jQuery
//============================================
 $(document).ready(function() {
 
 	//########## INDEX.PHP : Popup de la page d'index
    if(page=="index"){
	  $("#resume").click(function(){
		  $(this).slideUp('slow');
		  $(this).html('');
	  });
	  $("#messages").click(function(){
		  $(this).slideUp('slow');
	  });
	  $(".hideAreas").click(function(){
		  $("#resume").slideUp('slow');
		  $("#messages").slideUp('slow');
		  document.getElementById("ajaxContent").innerHTML = "<div><img class='loading' src='ressources/ajaxLoading.gif'>Chargement en cours...</div>";
	  });
	  $(".menu").click(function(){
		  $(".menu").removeClass('menuActive');
		  $(this).addClass('menuActive');
                    var onglet = $(this).attr("name");
                    if(onglet!="none") changeIdentity(onglet);
	  });

	}
	
	//########## CONTENTTNS.PHP : pour fermer automatique l'intro et les messages quand panier
    if(page=="contentTns"){
		$("#resume").slideUp('slow');
	}
	
	//########## CONTENTTNS.PHP : pour fermer automatique l'intro et les messages quand panier
    if(page=="inputTissus"){
      $("#TISSU1").show();
      $("a.catTissuSelect:first").css('background-color','#EE8');
         
      $("a.catTissuSelect").click(function(){
         $(".tissuCatContent").fadeOut('slow');
         $("a.catTissuSelect").css('background-color','#FFF');
         $(this).css('background-color','#EE8');
         
         var ot="";
         var cb=document.forms.entryform.cbOptionTissu;
         for (var i=0; i<cb.length;i++)
         if (cb[i].checked)
             ot=ot+cb[i].value+"#";
             
         document.forms.entryform.options_tissu.value=ot;
            
         var crtCat = $(this).attr("name");
         $("#"+crtCat).fadeIn('slow');
	  });

      $("input.cbTissu").click(function(){
         var ot="";
         var cb=document.forms.entryform.cbOptionTissu;
         for (var i=0; i<cb.length;i++)
         if (cb[i].checked)
             ot=ot+cb[i].value+"#";
             
         document.forms.entryform.options_tissu.value=ot;
	  });

	}
	
	//########## ZOOM.PHP : hide empty categories
	if(page=="zoom"){
	}

	//########## CONTENTSITEMAP.PHP : elt affichage images
	if(page=="sitemap"){
	$("div.jqShowImg").click(function(){
				//$(this).slideUp();
				var img="<a href='zoom.php?ref="+$(this).attr('id')+"' rel='lyteframe[g]' rev='width:940px;height:540px;' onclick='myLytebox.updateLyteboxItems();'><img src='http://refim.mildecor75.com/"+$(this).attr('id')+"sm.jpg'/>";
				$(this).html(img);
				$(this).slideDown('slow');
				 });
	}

	//########## STATISITIQUES.PHP : elt affichage images
	if(page=="statistiques"){
	$("div.jqShowImg").click(function(){
				//$(this).slideUp();
				var img="<a href='zoom.php?ref="+$(this).attr('id')+"' rel='lyteframe[g]' rev='width:940px;height:540px;' onclick='myLytebox.updateLyteboxItems();'><img src='http://refim.mildecor75.com/"+$(this).attr('id')+"sm.jpg'/>";
				$(this).html(img);
				$(this).slideDown('slow');
				 });
	}
});
}


//============================================
	function find(site) {
//============================================
// Appelée pour la recherche libre
//============================================
var findString=document.getElementById('inputFind').value;
$("#resume").slideUp('slow');
$("#messages").slideUp('slow');
ajaxCall("contentFind.php?fs="+findString+"&site="+site);
}

//============================================
	function changeIdentity(id) {
//============================================
// Changement DHTML du bandeau en fonction de la catégorie cliquée
//============================================
document.getElementById('identity').style.backgroundImage="url(ressources/identity"+id+".jpg)";

if(id=="Colonial") {
	document.getElementById('showroom').style.top="340px";
	document.getElementById('showroom').style.left="48%";	// navigation droite
	}
else if(id=="Industriel") {
	document.getElementById('showroom').style.top="320px";
	document.getElementById('showroom').style.left="22%";	// navigation droite
	}
else if(id=="Canape") {
	document.getElementById('showroom').style.top="320px";
	document.getElementById('showroom').style.left="22%";	// navigation droite
	}
else if(id=="Cheminee") {
	document.getElementById('showroom').style.top="216px";
	document.getElementById('showroom').style.left="35%";	// navigation droite
	}
else if(id=="Design") {
	document.getElementById('showroom').style.top="180px";
	document.getElementById('showroom').style.left="49%";	// navigation droite
	}
else if(id=="Transformables") {
	document.getElementById('showroom').style.top="180px";
	document.getElementById('showroom').style.left="49%";	// navigation droite
	}
else {
	document.getElementById('showroom').style.top="180px";
	document.getElementById('showroom').style.left="48%";	// navigation droite
	}
}

//============================================
	function refreshOptions() {
//============================================
// Obsolète
//============================================
var laius="";
var cb=document.forms.crtForm.toCheck;
for (var i=0; i<cb.length;i++)
	if (cb[i].checked)
		laius=laius+cb[i].value+", ";
		
document.forms.crtForm.RESUME.value=laius;
}

//============================================
	function checkOblig() {
//============================================
// Obsolète
//============================================
if(document.forms.crtForm['EMAIL'].value=="" || document.forms.crtForm['EMAIL'].value==null || document.forms.crtForm['EMAIL'].value.indexOf('@', 0) == -1 || document.forms.crtForm['EMAIL'].value.indexOf('.', 0) == -1)
	{
	alert("L'adresse eMail est obligatoire et doit être valide\nEx. : loulou@gmail.com");
	return false;
	}
if(document.forms.crtForm['CITY'].value=="" || document.forms.crtForm['CITY'].value==null)
	{
	alert("La ville est obligatoire");
	return false;
	}

return true;
}

//============================================
	function ajaxCall(url) {
//============================================
// Appel AJAX au serveur, alim DIV 'ajaxContent'
//============================================
url = url + "&rsrnd=" + new Date().getTime();

//alert(url);
var x;
try {
	x=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	try {
		x=new ActiveXObject("Microsoft.XMLHTTP");
	} catch (oc) {
		x=null;
	}
}
if(!x && typeof XMLHttpRequest != "undefined")
	x = new XMLHttpRequest();

x.open("GET", url, true);
x.onreadystatechange = function() {
	if (x.readyState != 4)
		return;

document.getElementById("ajaxContent").innerHTML = x.responseText;
myLytebox.updateLyteboxItems();
}
x.send(null);
delete x;
}


//============================================
	function ajaxCallDiv(url,div) {
//============================================
// Appel AJAX au serveur, alim DIV 'div'
//============================================
url = url + "&rsrnd=" + new Date().getTime();

//alert(url);
//alert(div);

var x;
try {
	x=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	try {
		x=new ActiveXObject("Microsoft.XMLHTTP");
	} catch (oc) {
		x=null;
	}
}
if(!x && typeof XMLHttpRequest != "undefined")
	x = new XMLHttpRequest();

x.open("GET", url, true);
x.onreadystatechange = function() {
	if (x.readyState != 4)
		return;

document.getElementById(div).innerHTML = x.responseText;
}
x.send(null);
delete x;
}



//============================================
	function ajaxRefreshRef(ref) {
//============================================
// rafraichi le contenu d'une référence
//============================================
url = "contentOneRef.php?ref" + ref + "&rsrnd=" + new Date().getTime();

var x;
try {
	x=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	try {
		x=new ActiveXObject("Microsoft.XMLHTTP");
	} catch (oc) {
		x=null;
	}
}
if(!x && typeof XMLHttpRequest != "undefined")
	x = new XMLHttpRequest();

x.open("GET", url, true);
x.onreadystatechange = function() {
	if (x.readyState != 4)
		return;

document.getElementById("ref").innerHTML = x.responseText;
}
x.send(null);
delete x;
}


//============================================
	function ajaxSend(url) {
//============================================
// Appel AJAX au serveur "dead send"
//============================================
url = url + "&rsrnd=" + new Date().getTime();

var x;
try {
	x=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	try {
		x=new ActiveXObject("Microsoft.XMLHTTP");
	} catch (oc) {
		x=null;
	}
}
if(!x && typeof XMLHttpRequest != "undefined")
	x = new XMLHttpRequest();

x.open("GET", url, true);
x.onreadystatechange = function() {
	if (x.readyState != 4)
		return;
}
x.send(null);
delete x;
}


//============================================
	function refMAJ(ref,msg) {
//============================================
// Indication que la réf a été mise à jour
//============================================
document.getElementById("adminMenu"+ref).innerHTML="<div class='adminMsgRefMAJ exergue'>"+msg+"</div>";
}


//============================================
	function refDel(ref) {
//============================================
// AJAX suppression d'une référence
//============================================
if(confirm('Voulez-vous supprimer la référence '+ref+' ?'))
	{
	ajaxSend('gestion/QR/deleteRef.php?ref='+ref);
//	document.getElementById(ref).className='refDeleted';
	refMAJ(ref,"Supprimée !");
	}
	else alert('Référence non supprimée');
}

//============================================
	function addProspect() {
//============================================
// AJAX suppression d'une référence
//============================================
	alert("coucou");
	return;
	$params="name=" + document.getElementById('name') + "&forname=" + document.getElementById('forname') + "&mail=" + document.getElementById('mail');
	ajaxSend('gestion/QR/insertProspect.php?name='+ref);
	document.getElementById("newsLetter").innerHTML="<h1>Inscription confirmée</h1><br/>Merci pour votre confiance.";
}

//============================================
	function refSetPrice(ref,price) {
//============================================
// AJAX mise à jour du prix
//============================================
input=prompt('Prix de la référence '+ref+' : \n(pas de € ni de centimes)',price);
if(input!=null)
	{
	url='gestion/QR/updateRefPrice.php?ref='+ref+'&price='+input;
	alert(url);
	ajaxSend(url);
	ajaxRefreshRef(ref);
	}
	else alert('Prix inchangé');
}

