// script_ensavoir.js: les diverses fonctions d'ouverture de fenêtres annexes En savoir +
//------------------------------------

//------------------------------------
// ouverture de la page Photos
/**function OpenPhotos(theURL) { 
	w=window.open(theURL,"Photos","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=400,height=430");
	MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
	VERS=parseInt(navigator.appVersion);
	if ((!MSIE) || (VERS >=5))
		w.focus();
}**/
//------------------------------------
// ouverture de la page Appel gratuit eStara
function OpenAppelgratuit(theURL) { 
	w=window.open(theURL,"Appel_gratuit","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=494,height=515");
	MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
	VERS=parseInt(navigator.appVersion);
	if ((!MSIE) || (VERS >=5))
		w.focus();
}
//------------------------------------
// ouverture de la page Info Consommateur
function OpenInfoconso(theURL) { 
	w=window.open(theURL,"Photos","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=300,height=260");//laisser à cette hauteur pour autorisation admin 
	MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
	VERS=parseInt(navigator.appVersion);
	if ((!MSIE) || (VERS >=5))
		w.focus();
}
//------------------------------------
// fermeture de la page Photos
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
//------------------------------------
// ouverture de la page stats eStat
function OpeneStat() {
  var estatURL = "http://pagesjaunes.estat.com/";
  w=window.open( ( estatURL ), "eStat", "" );
}
//------------------------------------
// ouverture de la page stats eStara
function OpeneStara() {
  var estaraURL = "#";
  w=window.open( ( estaraURL ), "eStara", "" );
}
//------------------------------------
// ouverture de la page Info annonceur generique
function OpenInfoannonceur(url) {
	w=window.open(url,"Info","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=870,height=470");
	MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
	VERS=parseInt(navigator.appVersion);
	if ((!MSIE) || (VERS >=5))
		w.focus();
}
//------------------------------------
// ouverture de la page Info annonceur avocats
function OpenInfoavocat(url) {
	/*var estaraURL = "../avocat/info_annonceur.htm";*/
	w=window.open(url,"Info","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=870,height=470");
	MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
	VERS=parseInt(navigator.appVersion);
	if ((!MSIE) || (VERS >=5))
		w.focus();
}
//------------------------------------
// ouverture de la page Info editeur
function OpenInfoediteur() {
	var infoediteurURL = "http://www.pagesjaunes.fr/plusdeservices/infosite/mentionLegale.do";
	w=window.open( ( infoediteurURL ), "Info", "" );
}
//------------------------------------
// ouverture de la page Info editeur
function OpenInfoediteur() {
	var infoediteurURL = "static/html/info_editeur.html";
	w=window.open( ( infoediteurURL ), "Info", "" );
}
//------------------------------------
// Enregistrement dans favoris
function addFav() 
{ 
	if (document.all) 
	{ 
		window.external.AddFavorite(location.href, document.title); 
	} 
	else 
	{ 
		alert('Vous pouvez faire CTRL + D pour ajouter cette page dans vos signets, ou favoris.') 
	} 
}
//------------------------------------
// Imprimer
function printWindow() {
	bV = parseInt(navigator.appVersion)
	if (bV >= 4) 
		window.print()
}
//------------------------------------
// Itineraire
function pj_switch_menu (le_titre1, le_titre2) {
	document.getElementById(le_titre1);
	document.getElementById(le_titre2);
	var le_form1= document.getElementById("form_"+le_titre1);
	var le_form2= document.getElementById("form_"+le_titre2);
	le_form1.style.display='block';
	le_form2.style.display='none';
}
//------------------------------------
<!--
function MM_findObj(n, d) { //v4.0
	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 && document.getElementById) 
		x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  	for (i=0; i<(args.length-2); i+=3) 
	{
		test=args[i+2]; 
		val=MM_findObj(args[i]);
    	if (val) 
		{
			nm=val.name; 
			if ((val=val.value)!="") 
			{
      			if (test.indexOf('isEmail')!=-1) 
				{ 
					p=val.indexOf('@');
        			if (p<1 || p==(val.length-1))
						errors+='- '+nm+' doit contenir une adresse email.\n';
      			} else 
					if (test!='R') 
					{
	        			if (isNaN(val)) 
							errors+='- '+nm+' doit contenir un chiffre.\n';
	        			if (test.indexOf('inRange') != -1) 
						{ 
							p=test.indexOf(':');
	          				min=test.substring(8,p); 
							max=test.substring(p+1);
							if (val<min || max<val) 
								errors+='- '+nm+' doit contenir un chiffre entre '+min+' et '+max+'.\n';
						}
					} 
			} else 
				if (test.charAt(0) == 'R') 
					errors += '- '+nm+' est demand\xE9.\n'; 
		}
	}
	if (errors) 
		alert('l\'erreur suivante s\'est produite:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->

//------------------------------------
// ouverture page CG eStat generique
function OpenCGEstatGen() {
	var conditiongenURL = "../html/estara_gen_conditions_generales.html";
	w=window.open( ( conditiongenURL ), "eStara", "scrollbars=yes,resizable=yes,width=700" );
}
//------------------------------------
// ouverture page Aide FAQ eStat generique
function OpenAideEstatGen() {
	var aidefaqURL = "../html/estara_gen_modemploi.html";
	w=window.open( ( aidefaqURL ), "eStara2", "scrollbars=yes,resizable=yes,width=700" );
}
//-------------------------------------
// redimentionnement de la police selon systeme
function scaleFont(){
	if (navigator.appVersion.indexOf("Win") != -1) { 
		document.body.style.fontSize='66%';
	} else {
		document.body.style.fontSize='70%';
	}
}
function initShowHide(){
	var obj = document.getElementsByTagName("span");
	for(i=1;i<obj.length;i++)
	{
		if(document.getElementById('showhide'+i)){      
		obj['showhide'+i].style.visibility = 'hidden';
		}
	}

}

function show(id) {
	if (document.getElementById(id)) {
		document.getElementById(id).style.display = 'inline';
	}
	if (document.getElementById(id+'_bloc')) {
		document.getElementById(id+'_bloc').style.display = 'block';
	}

}

//-------------------------------------
// showHide horaires
function ShowHide(id) {
    var obj = document.getElementsByTagName("span");
    if (obj[id].style.visibility != 'visible')
	{
		obj[id].style.visibility = 'visible';
		obj[id].style.left = '0px';
		obj[id].style.zIndex = '100';
    } else {
    	obj[id].style.visibility = 'hidden';
    }
}


//-------------------------------------
function ShowContact(ref){
	var obj = document.getElementsByTagName("span");
	var visi;
	for (Val in contact[ref]){
		if (contact[ref][Val][0] <= curr_date)
		{
			visi='block';
			if (contact[ref][Val][1] < curr_date)
				visi='none';
		}
	}
	obj[ref].style.display=visi;
}

// main ________________________________
var the_date = new Date();
var the_month = the_date.getMonth() + 1;
if(the_month < 10)
	the_month = "0" + the_month;
var the_day = the_date.getDate();
if(the_day < 10)
	the_day = "0" + the_day;
var the_minutes = the_date.getMinutes();
if(the_minutes < 10)
	the_minutes = "0" + the_minutes;
var the_hours = the_date.getHours();
if(the_hours < 10)
	the_hours = "0" + the_hours;
var the_seconds = the_date.getSeconds();
if(the_seconds < 10)
	the_seconds = "0" + the_seconds;
var current_date = the_date.getFullYear() + "-" + the_month + "-" + the_day + "T" + the_hours + ":" + the_minutes + ":" + the_seconds;
var curr_date = the_date.getFullYear() + "/" + the_month + "/" + the_day;
var is_news_valid = 1;
var contact= new Array();




//-------------------------------------
// gestion hauteur IFRAME catalogue
var iframeids=["frCat"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() 
{
	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
			resizeIframe(iframeids[i])
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
		}
	}
}

function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid)
	if (currentfr){
		currentfr.style.display="block"
		currentfr.width = '100%';
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else 
			if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
				currentfr.height = currentfr.Document.body.scrollHeight;
				
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else 
			if (currentfr.attachEvent){
				currentfr.detachEvent("onload", readjustIframe) // Bug fix line
				currentfr.attachEvent("onload", readjustIframe)
			}
	}
}

function readjustIframe(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
	if (document.getElementById)
		document.getElementById(iframeid).src=url
}

if (window.addEventListener) 
	window.addEventListener("load", initShowHide, false)
else if (window.attachEvent)
		window.attachEvent("onload", initShowHide)
	else
		window.onload=initShowHide;

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else 
	if (window.attachEvent)
		window.attachEvent("onload", resizeCaller)
	else
		window.onload=resizeCaller

var debug=0;

//Ajouts de véronique - pour gestion des vignettes zoomées 
window.addEvent('domready',function(){
	var vignette = $('vignette');
//============= HERVE : attention ca plante, y compris le Ajax, si aucune image dans l esplus ===============
	if ( vignette ) { var classe_vignette = vignette.getFirst();
	var vignettes = classe_vignette.getChildren();
	vignettes.each(function(vigne){
		var span = $(vigne).getLast();
		$(vigne).addEvent('mouseover',function(){
			//Patch pour IE6, la vignette passe sous le formulaire plan lors du rollover -_-
			if (window.ie && $('form_mail')){
				$('patch_cache1').setStyle('visibility','hidden');
				$('patch_cache2').setStyle('visibility','hidden');
			}
			t = this.getLast().getCoordinates();
			
			u = document.createElement('iframe');
			u.setStyles(
			{'width' : t['width'], 'height': t['height'], 'top': t['top'], 'left' : t['left']}
			);
			u.setStyle('position','absolute');
			u.setStyle('border','none');
			u.setStyle('z-index','2000');
			u.id = 'img_frame';
			u.frameborder='0';
			u.allowtransparency = false;
			u.inject(document.body);
		});
		$(vigne).addEvent('mouseout',function(){
			if (window.ie && $('form_mail')){
				$('patch_cache1').setStyle('visibility','visible');
				$('patch_cache2').setStyle('visibility','visible');
			}
			$('img_frame').remove();
		});
	});
}
//=========== fin commentaire HERVE			
	//-------------------------------------
	//Année en cours dans footer
	if ($('annee_actuelle')){
		$('annee_actuelle').setText(the_date.getFullYear());
	}
});



