
// Fonction de stockage des scripts à charger 
// FuncOL = new Array(); 
// function StkFunc(Obj) { 
    // FuncOL[FuncOL.length] = Obj; 
// } 
     
// Execution des scripts au chargement de la page 
// window.onload = function() { 
    // for(i=0; i<FuncOL.length; i++) 
        // {FuncOL[i]();} 
// }

// window.onload(trace("toto"));

// function addLoadEvent(func) {
        // var oldonload = window.onload;
        // if (typeof window.onload != 'function') {
                // window.onload = func;
        // }
        // else {
                // window.onload = function() {
                        // oldonload();
                        // func();
						
                // }
        // }

// }


/* desactivation selection et click droit */

  
var detect = navigator.userAgent.toLowerCase();

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
	
	
function disableselect(e){
// return false;
return true;
}

function reEnable(){
return true;
}

//if IE4+
// document.onselectstart=new Function ("return false");
// document.oncontextmenu=new Function ("return false");
document.onselectstart=new Function ("return true");
document.oncontextmenu=new Function ("return true");


//if NS6
if (window.sidebar){
document.onmousedown=disableselect;
document.onmouseup=reEnable;
document.oncontextmenu=disableselect;
}


/* / desactivation */

/* controle de la position de la souris */

function register_position(){

// mouse_x = 0;
// mouse_y = 0;

// document.onmousemove = function(){ position(); }
document.onmousemove = position;


}

function position(evt){

if(!evt) evt = window.event;
mouse_x = evt.clientX;
mouse_y = evt.clientY;
// alert(mouse_x);

} 

function control_httprequest(){var req = false;if (window.XMLHttpRequest) {try{req = new XMLHttpRequest();} catch (e) {req = false;}} else if(window.ActiveXObject){try{req = new ActiveXObject("Msxml2.XMLHTTP");}catch (e){try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch (e){req = false;}}}return req;}

/* / controle de la posirtion de la souris */


function setAlpha(elementId,alpha)
{
	document.getElementById(elementId).style.opacity = alpha / 100;
	/** Test pour notre cher IE */
	if (document.body.filters != undefined)
	{
		document.getElementById(elementId).style.filter = 'alpha(opacity:' + alpha + ')';
	}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// sortir d'un frame pas cool
if (window!=top) { top.location=window.location; }


// POP CENTER

function PopupCentrer(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  //var top='0';
  //var left='0';
/*  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); */
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


// FIX PNG

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}




/* script form */

function clear_champs(id, nom_label){
	
	if(document.getElementById(id).value == nom_label){
	document.getElementById(id).value="";
	}
	
}

// bouton radio page creer_agence.php								
function check_situation(arg){

	/* init */
	document.getElementById('hid_ch_situation_investir').value = "off";
	document.getElementById('hid_ch_situation_possagence').value = "off";
	document.getElementById('hid_ch_situation_autre').value = "off";
	document.getElementById('ch_situation_investir').style.background = "";
	document.getElementById('ch_situation_possagence').style.background = "";
	document.getElementById('ch_situation_autre').style.background = "";
	/* fin init */
	
	select_doc = document.getElementById('hid_' + arg).value;
	if(select_doc == "off"){
		result_ch = "on";
		document.getElementById(arg).style.background = "url(./images/ficheproduit/coin-info-on.gif) 2px 3px no-repeat";
	}
	
	document.getElementById('hid_' + arg).value = result_ch;
	
}

// bouton radio page vendre_estimer.php								
function check_souhait_contact(arg){

	/* init */
	document.getElementById('hid_ch_etre_appele').value = "off";
	document.getElementById('hid_ch_avoir_rdv').value = "off";
	document.getElementById('ch_etre_appele').style.background = "";
	document.getElementById('ch_avoir_rdv').style.background = "";

	/* fin init */
	
	select_doc = document.getElementById('hid_' + arg).value;
	if(select_doc == "off"){
		result_ch = "on";
		document.getElementById(arg).style.background = "url(./images/ficheproduit/coin-info-on.gif) 2px 3px no-repeat";
	}
	
	document.getElementById('hid_' + arg).value = result_ch;
	
}

// bouton radio page rechercher.php								
function check_type_bien(arg){

	/* init */
	document.getElementById('ch_all').value = "off";
	document.getElementById('ch_18').value = "off";
	document.getElementById('ch_1').value = "off";
	document.getElementById('ch_5').value = "off";
	document.getElementById('ch_2').value = "off";
	document.getElementById('ch_6').value = "off";
	document.getElementById('ch_16').value = "off";
	document.getElementById('ch_3').value = "off";
	document.getElementById('ch_15').value = "off";
	document.getElementById('ch_14').value = "off";
	document.getElementById('ch_17').value = "off";
	document.getElementById('ch_8').value = "off";

	document.getElementById('all').style.background = "";
	document.getElementById('18').style.background = "";
	document.getElementById('1').style.background = "";
	document.getElementById('5').style.background = "";
	document.getElementById('2').style.background = "";
	document.getElementById('6').style.background = "";
	document.getElementById('16').style.background = "";
	document.getElementById('3').style.background = "";
	document.getElementById('15').style.background = "";
	document.getElementById('14').style.background = "";
	document.getElementById('17').style.background = "";
	document.getElementById('8').style.background = "";
	
	

	/* fin init */
	
	select_doc = document.getElementById('ch_' + arg).value;
	if(select_doc == "off"){
		result_ch = "on";
		document.getElementById(arg).style.background = "url(./images/common/icone_puce-on.png) 0 -3px no-repeat";
	}else{
		result_ch = "off";
		document.getElementById(arg).style.background = "url(./images/common/icone_puce.png) 0 -3px no-repeat";
	}
	
	document.getElementById('ch_' + arg).value = result_ch;
	
}



function reponse_form(arg){
	var timerPost;
	// alert(arg);
	if(arg == "form_vendreestimer"){
		document.getElementById('art_reponse').innerHTML = "Votre e-mail à bien été envoyé ! Nos équipes prendrons contact avec vous prochainement.";
		timerPost = setTimeout("window.location='./vendre_estimer.php'",3000);
	}
	if(arg == "form_creeragence"){
		document.getElementById('art_reponse').innerHTML = "Votre e-mail à bien été envoyé ! Nos équipes prendrons contact avec vous prochainement.";
		timerPost = setTimeout("window.location='./demande_rdv_partner.php'",3000);
	}
	if(arg == "form_contact"){
		document.getElementById('art_reponse').innerHTML = "Votre e-mail à bien été envoyé ! Nos équipes prendrons contact avec vous prochainement.";
		timerPost = setTimeout("window.location='./contact.php'",3000);
	}
	
}									  

function acces_page(source, page){
	
	req = control_httprequest();
	
	// var value_select = document.getElementById(ch_select).value;	
	// var expl_ch_result = ch_result.split("|");
	total_page = document.getElementById("val_total_page").value;
	// document.getElementById("debug_pagination").innerHTML = page + " - " + total_page + " - " + source;
	
	if(source == "localisation_agence"){
	var File = "agence_request_list_vign";
	}else if(source == "derniere_annonce"){
	var File = "request_list_vignette";
	}else{
	var File = "request_list_vignette";
	}

	var method = "GET";
	var dossier = "./_module/";
	var nom_app = File + ".php?page_select=" + page;
	req.open(method, dossier + nom_app , false);
	req.send(null);

	var result = req.responseText;

		// alert(source);
	
	for(o=0 ; o < Number(total_page) ; o++){
	//color:#a5131d; font-size:10px; border-bottom:#a5131d 1px solid;
		
		
		if(o == page){
			document.getElementById("pagi_" + o).style.borderBottom = "1px solid #a5131d";
			document.getElementById("pagi_" + o).style.color = "#a5131d";
		}else{
			document.getElementById("pagi_" + o).style.border = "none";
			document.getElementById("pagi_" + o).style.color = "#666666";
		}
		
	}
	
	document.getElementById("_list_vign").innerHTML = result;
	
	
}			


function lexique(lettre){
	
	req = control_httprequest();
	var File = "lexique_" + lettre;

	var method = "GET";
	var dossier = "./_html/lexique/";
	var nom_app = File + ".html";
	req.open(method, dossier + nom_app , false);
	req.send(null);

	var result = req.responseText;
	
	document.images['img_lettre'].src = "./images/lexique/bt-/" + lettre + "-cadrelettre-lexique.gif";
	document.getElementById("list_lexique").innerHTML = result;
	
	
}			

function aff_fiche(source, id_fiche, pvec){

	/* cache div */
	// document.getElementById("_list_vign").style.position = "absolute";
	// document.getElementById("_list_vign").style.zIndex = "0";
	// document.getElementById("_list_vign").style.visibility = "hidden";
	/* * */
	document.getElementById("zone_vign").style.position = "absolute";
	document.getElementById("zone_vign").style.zIndex = "0";
	document.getElementById("zone_vign").style.visibility = "hidden";
	/* * */
	// document.getElementById("cadre_top").style.position = "absolute";
	// document.getElementById("cadre_top").style.zIndex = "0";
	// document.getElementById("cadre_top").style.visibility = "hidden";
	/* *** */
	
	/* aff div */
	document.getElementById("div_fiche").style.position = "relative";
	document.getElementById("div_fiche").style.zIndex = "10";
	document.getElementById("div_fiche").style.visibility = "visible";
	
	req = control_httprequest();

	var File = "request_fiche_bien";

	var method = "GET";
	var dossier = "./_module/";
	var nom_app = File + ".php?id_fiche=" + id_fiche + "&pec=" + pvec + "&source=" + source;
	req.open(method, dossier + nom_app , false);
	req.send(null);

	var result = req.responseText;

	document.getElementById("div_fiche").innerHTML = result;
	// document.getElementById("div_fiche").innerHTML = "";
	
	// alert(id_fiche);
}


function aff_vign(source, id_fiche, pvec){

	/* cache div */
	// document.getElementById("_list_vign").style.position = "relative";
	// document.getElementById("_list_vign").style.zIndex = "10";
	// document.getElementById("_list_vign").style.visibility = "visible";
	/* * */
	document.getElementById("zone_vign").style.position = "relative";
	document.getElementById("zone_vign").style.zIndex = "10";
	document.getElementById("zone_vign").style.visibility = "visible";
	/* * */
	// document.getElementById("cadre_top").style.position = "relative";
	// document.getElementById("cadre_top").style.zIndex = "10";
	// document.getElementById("cadre_top").style.visibility = "visible";
	/* *** */
	
	/* aff div */
	document.getElementById("div_fiche").style.position = "absolute";
	document.getElementById("div_fiche").style.zIndex = "0";
	document.getElementById("div_fiche").style.visibility = "hidden";
	
	// req = control_httprequest();

	// var File = "request_fiche_bien";

	// var method = "GET";
	// var dossier = "./_module/";
	// var nom_app = File + ".php?id_fiche=" + id_fiche + "&pec=" + pvec + "&source=" + source;
	// req.open(method, dossier + nom_app , false);
	// req.send(null);

	// var result = req.responseText;

	// document.getElementById("div_fiche").innerHTML = result;
	
	// alert(id_fiche);
}


function charge_photo(source){
	document.images['zoomVisuel'].src = source;
}


function charge_localisation(ch_select, arg, ch_result, size_ch){

	req = control_httprequest();
	
	var value_select = document.getElementById(ch_select).value;	
	var expl_ch_result = ch_result.split("|");

	var File = "mod_tampon_httprequest";

	var method = "GET";
	var dossier = "./_module/";
	var nom_app = File + ".php?" + arg + "=" + value_select + "&sizech=" + size_ch;
	req.open(method, dossier + nom_app , false);
	req.send(null);

	var result = req.responseText;

	OPTIONS = result;
	
	// alert(value_select);
	
	for(var i in expl_ch_result){

		OPTIONSVIDE = "<select name=\"name_" + expl_ch_result[i] + "\" id=\"" + expl_ch_result[i] + "\" class=\"FormChSelectInsc\" >\n<option></option>\n</select>";
	
		if(i ==  0){
		document.getElementById("div_" + expl_ch_result[i]).innerHTML = OPTIONS;
		document.getElementById("" + expl_ch_result[i]).style.width = size_ch + "px";
		document.getElementById("" + expl_ch_result[i]).disabled = false;
		}else{
		document.getElementById("div_" + expl_ch_result[i]).innerHTML = OPTIONSVIDE;
		document.getElementById("" + expl_ch_result[i]).style.width = size_ch + "px";
		document.getElementById("" + expl_ch_result[i]).disabled = true;
		}
		
		if(((ch_select ==  "pays")||(ch_select ==  "pays2"))&&(value_select != "France")){
		document.getElementById("div_" + expl_ch_result[i]).innerHTML = OPTIONSVIDE;
		document.getElementById("" + expl_ch_result[i]).style.width = size_ch + "px";
		document.getElementById("" + expl_ch_result[i]).disabled = true;
		}
		
		if(value_select ==  "all"){
		document.getElementById("div_" + expl_ch_result[i]).innerHTML = OPTIONSVIDE;
		document.getElementById("" + expl_ch_result[i]).style.width = size_ch + "px";
		document.getElementById("" + expl_ch_result[i]).disabled = true;
		}
		
	}
	

}
	
	
/* function open app box */

function getScrollPosition()
{
	return Array((document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft,(document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop);
}

function openApp(dossier, nom_app, box_height, box_width, name_box){

	req = control_httprequest();
	
	req.open('GET', dossier + nom_app , false);
    req.send(null);

	document.getElementById('load_fl').innerHTML = req.responseText;
	
	
	//appel de la box
	
	// switch (option){
		// case "load_fl" : break;
	// }
	
	// IdClip = "1"; 
	
	document.getElementById(name_box).style.display = "block";
	document.getElementById(name_box).style.height = box_height + 'px';
	document.getElementById(name_box).style.width = box_width + 'px';
	document.getElementById('ClipBack').style.display = "block";
	
	document.getElementById(name_box).style.opacity = 0;
    document.getElementById(name_box).style.filter = "alpha(opacity=" + (0) + ")";
	
	// name_obx = name_box;
	
	setTimeout("animationClipLight('-1', '" + name_box + "', '"+box_height+"', '"+box_width+"')",1);
	
}

function valDimWin(){

// traitement de la largeur
	
	 if(checkIt('msie') > 0){
		valHeightWin = document.documentElement.clientHeight;
		valWidthWin = document.documentElement.clientWidth;
	 }else{
		valHeightWin = window.innerHeight;
		// valWidthWin = window.innerWidth;
		valWidthWin = document.documentElement.clientWidth;
	 }
	 
	 return valHeightWin + "|" + valWidthWin;

}
	 

function animationClipLight (x, name_box, DimH, DimW) {
			
	// appel des dims de la fenetre
	 valDimExp = valDimWin().split("|");
	 valHeightWin = valDimExp[0];
	 valWidthWin = valDimExp[1];
	 
	 PosLeft = Math.ceil((Number(valWidthWin)-Number(DimW)) / 2);
	 PosTop = Math.ceil((Number(valHeightWin)-Number(DimH)) / 2);
	
	 largeur_ecran_ideal = PosLeft;
	 hauteur_ecran_ideal = PosTop;

	 /* anim par la droite */
	 // document.getElementById(name_box).style.left = (largeur_ecran_ideal-(x*2)) + "px";
	 // document.getElementById(name_box).style.top = (hauteur_ecran_ideal)  + "px";
	 
	 /* anim par la hauteur */
	 document.getElementById(name_box).style.left = (largeur_ecran_ideal) + "px";
	 document.getElementById(name_box).style.top = ((hauteur_ecran_ideal-20)+(x*2))  + "px";
	 document.getElementById(name_box).style.height = (x*(DimH/10))  + "px";
	 
	 document.getElementById(name_box).style.opacity = x*0.1;
	 document.getElementById(name_box).style.filter = "alpha(opacity=" + (x*20) + ")";

	var appelSuivant = "animationClipLight(" + (x+1) + ", '" + name_box + "', " + DimH + ", " + DimW + ")";
	
	if (x < 10) {
		setTimeout(appelSuivant, 20);
	 }
			 
}

function lightclose(name_box){
	document.getElementById(name_box).style.display = "none";
	document.getElementById('ClipBack').style.display = "none";
	window.location = "";
}


/* send mdp */


function SendMdp(VAL){
	
	var type = "forget_mdp";
	
	req = control_httprequest();
	var File = "request_controle";
	
	var method = "GET";
	var dossier = "./_module/";

	var nom_app = File + ".php?i=fp&act=" + type + "&value=" + VAL;
	req.open(method, dossier + nom_app , false);
	req.send(null);

	ReponsePhp = req.responseText;
	
	VAL = ReponsePhp; // tmp
	
	// alert(VAL);
	
	openApp('./_html/', 'pop_fopwd.php?act=ok_mail&email=' + VAL + '', '300', '600', 'glbwin');
	
	// document.formulaire_mdp.submit();
}



