// Very important
var commun_url = "/commun_fr/";

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_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_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_reloadPage(init) {  //Netscape 4 Resize Fix
	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 verif_rech_motcle(masque, val)
{
	if (	(val == "") || (val == masque) || (val.length == 1 ) )
	{
		 alert('Veuillez taper un mot dans le champ de recherche SVP...');
		 return false;
	}
	else
	{
		document.getElementById("search_go").disabled = true;
	}
}
function verif_rech_metier(val)
{
	if (val == "")
	 {
		 alert('Veuillez choisir un métier dans la liste SVP...');
		 return false;
	 }
}
function change_action()
{
	document.form_trade.action = document.form_trade.metier.value;
}
//Fonction qui vide le contenu du champ
function vide_champ(field,rech)
{
	val = field.value;

	if (val == rech)
	{
		field.value = "";
	}
}

function addFavorite(id_site)
{
	js_audience('favoris', id_site);

	qtitle = "Quotatis : Devis comparatifs, devis travaux, devis fenêtres, devis rénovation, devis construction";

	if( window.sidebar && window.sidebar.addPanel ) {
		//Gecko (Netscape 6 etc.) - add to Sidebar
		window.sidebar.addPanel(qtitle,'http://www.quotatis.fr?sqn=1621', '' );
	} else if( window.external && ( navigator.platform == 'Win32' ||
		  ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
		//IE Win32 or iCab -
		window.external.AddFavorite('http://www.quotatis.fr?sqn=1621',qtitle);
	} else if( window.opera && window.print ) {
		//Opera 6+ - add as sidebar panel to Hotlist
		return true;
	} else if( document.layers ) {
		//NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
		//not target page)
		window.alert( 'Please click OK then press Ctrl+D to create a bookmark' );
	} else {
		//other browsers - tell them to add a bookmark (adds current page, not target page)
		window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
	}
	return false;
}


function js_audience(prg, id_site)
{
	obj = MM_findObj('PrgF');
	obj.src = commun_url + "Progs_http/Prog_count_aud.php?prg="+prg+"&id_site="+id_site;
}

// Open a popup
function popup(name,url,width,height,strollbars,resizable)
{
	if (!width) width=600;
	if (!height) height=500;
	var left=(screen.width - width) / 2;
	var top=(screen.height - height) / 2;
	resizable='no';
	scrollbars='no';
	if (resizable) resizable='yes';
	if (scrollbars) scrollbars='yes';
	var popup=window.open(url,'qt_' + name,'alwaysRaised=yes,toolbar=no,height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',toolbar=no,location=no,directories=no,menubar=no,resizable=' + resizable + ',scrollbars=' + scrollbars + ',status=no');
	if (popup.window.focus) popup.window.focus();
}

function popcnil(bPremium)
{
	var positiontop=document.body.clientHeight/2;
	var positionleft=document.body.clientWidth-600;
	positiontop=positionleft=10;
	winopened = window.open(commun_url + 'popup/popcnil.php' + (bPremium ? '?premium=1' : ''),'popcnil','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=600,height=500,top='+ positiontop +',left='+ positionleft);
	winopened.focus();
}

//Fonction qui change l'affichage devis_ok
function change_visu(ids,i)
{
	obj1 = MM_findObj("comp_not_" + i);
	obj2 = MM_findObj("comp_exp_" + i);
	obj3 = MM_findObj("Link_1_" + i);
	obj4 = MM_findObj("Link_2_" + i);

	if (!document.layers)
	{
		obj1 = obj1.style;
		obj2 = obj2.style;
	}

	if(ids == 1)
	{
		obj1.display = '';
		obj2.display = 'none';

		obj3.setAttribute("class", "link_current_1");
		obj3.setAttribute("className", "link_current_1"); // ie
		obj4.setAttribute("class", "link_nav_1");
		obj4.setAttribute("className", "link_nav_1"); // ie
	}
	else{
		obj1.display = 'none';
		obj2.display = '';

		obj3.setAttribute("class", "link_nav_1");
		obj3.setAttribute("className", "link_nav_1"); // ie
		obj4.setAttribute("class", "link_current_1");
		obj4.setAttribute("className", "link_current_1"); // ie
	}
	return false;
}

function checkAll(iId, bUncheck)
{
	if (document.getElementById && document.getElementsByTagName)
	{
		var iLen = iId.length;
		var aFormsInPage = document.getElementsByTagName('form');

		for (var iI = 0; iI < aFormsInPage.length; iI++)
		{
			var oForm = aFormsInPage[iI];
			for (var iJ = 0; iJ < oForm.elements.length; iJ++)
			{
				if (oForm[iJ].id.substring(0, iLen) == iId && oForm[iJ].type == 'checkbox' && !oForm[iJ].disabled)
				{
					oForm[iJ].checked=(typeof bUncheck != 'undefined' && bUncheck) ? false : true;
				}
			}
		}
	}
}
function uncheckAll(iId)
{
	checkAll(iId, true);
}
