
YAHOO.util.Event.onContentReady("barreDeMenuSicasov", function () {

		    var oMenuBar = new YAHOO.widget.MenuBar("barreDeMenuSicasov", { 
		                                                autosubmenudisplay: true, 
		                                                hidedelay: 750, 
		                                                lazyload: true });
		
		    oMenuBar.render();
		
		});
	
function getHttpRequest()
{
	var xhr_object = null; 

	if(window.XMLHttpRequest) // Firefox 
		xhr_object = new XMLHttpRequest(); 
	else 
	{
		if(window.ActiveXObject)
		{ // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
		else 
		{ // XMLHttpRequest non support? par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return null;
		}
	}
	return xhr_object;
	
} 

function requeteHTTPAjax(mode,url,commande,synchrone)
{
	var htr = getHttpRequest();
	htr.open(mode, url,synchrone);
	htr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	htr.onreadystatechange=function()
     								{
        								if (htr.readyState == 4)
        								{				
        									eval(htr.responseText);
        								}
     								}	
	htr.send(commande);		

}

function connexion() {
var f = window.document.forms['formulaireConnexion'];
if (f == null) return;
var l = f.elements['login'].value;
var p = f.elements['password'].value;
var c = 'login='+l+'&password='+p+'&redirect=SSO';
requeteHTTPAjax('POST','/sicasov2008/Connexion',c,true);
}

function echecConnexion(s) {
if (s == 'echec') alert('Echec de la connexion, veuillez v�rifier votre login et votre mot de passe SVP.');
else alert("Votre identification a �chou� 3 fois, vous ne pourrez plus faire d'autre tentative avec cette session.");
}

function valideAuthExtranet(p,s,id,niv) {
/*alert('Validation login Extranet, profil : '+p+' session : '+s+' id : '+id);*/
window.location.replace('/info/system/modules/com.sicasov.internet.opencms/pages/autoLoginProfil.jsp?profil='+p+'&session='+s+'&id='+id+'&niveau='+niv+'&r='+Math.random());
}

function modelesContrats(langue,nom)
{

/*
	var ct = document.getElementById("containerContrats");

	while (ct.childNodes.length > 0)
		ct.removeChild(ct.firstChild);
		
	var obj = document.createElement("object");
	obj.data = "../pdf/contrats/" + langue + '/' + nom + ".pdf";
	obj.type = "application/pdf";
	obj.width = "100%";
	obj.height = "500";
	ct.appendChild(obj);
*/	
	document.open("http://www.sicasov.com/common/pdf/contrats/" + langue + '/' + nom + ".pdf","_blank","");
}

function chargerBareme() {
	nomVariete = document.getElementById("choixBareme").value;
	var h = window.location.href;
	var p = h.indexOf('?');
	if (p > 0) h=h.substring(0,p);
	window.location.href=h+'?variete='+nomVariete;
}

function anneeBareme(a) {
	var h = window.location.href;
	var p = h.indexOf('?');
	if (p > 0) h=h.substring(0,p);
	window.location.href=h+'?annee='+a;
}

function selectionMenu(nom)
{
	requeteHTTPAjax("GET","../SelectionMenu?nom=" + nom,null,false);
}

function divLoginPassword(soc,ret,action)
{

	var dps = document.getElementById("zoneLoginPassword");
	var ci  = document.createElement("div"); dps.appendChild(ci);
	ci.className = "identification";
	ci.appendChild(document.createTextNode("Identification"));	
	var cit  = document.createElement("div"); dps.appendChild(cit);
	cit.className = "texteIdentification";
	cit.appendChild(document.createTextNode("Identifiez-vous et consultez les membres et statuts de votre soci?t?/association"));	
	
	var f  = document.createElement("form"); dps.appendChild(f); 
	f.name ="societesFormulaire";
	f.method="POST";
	f.action = "../ConnexionAssociations";

	var inp = document.createElement("input"); 
	inp.type = "hidden";
	inp.name = "societesNom";		inp.value = soc;
	f.appendChild(inp); 

	var inp = document.createElement("input"); 
	inp.name = "societesRetour";	inp.type = "hidden";	inp.value = ret + "?action=" + action;
	f.appendChild(inp); 

	var t = document.createElement("table"); f.appendChild(t); 
	var tb = document.createElement("tbody"); t.appendChild(tb); 

	var tr = document.createElement("tr"); tb.appendChild(tr); 
	var td = document.createElement("td"); tr.appendChild(td); 
	td.appendChild(document.createTextNode("Identifiant")); 

	var tr = document.createElement("tr"); tb.appendChild(tr); 
	var td = document.createElement("td"); tr.appendChild(td); 
	var inp = document.createElement("input"); td.appendChild(inp); 	
	inp.name = "societesIdentifiant";
	inp.type = "text";

	var tr = document.createElement("tr"); tb.appendChild(tr); 
	var td = document.createElement("td"); tr.appendChild(td); 
	td.appendChild(document.createTextNode("Mot de passe")); 

	var tr = document.createElement("tr"); tb.appendChild(tr); 
	var td = document.createElement("td"); tr.appendChild(td); 
	var inp = document.createElement("input");  	
	inp.name = "societesPassword";
	inp.type = "password";
	td.appendChild(inp);

	var tr = document.createElement("tr"); tb.appendChild(tr); 
	var td = document.createElement("td"); tr.appendChild(td); 
	var inp = document.createElement("input");  	
	inp.type = "submit";
	inp.value = "OK";
	td.appendChild(inp);

}	

function lancerRechercheIndex()
{
	var texte = document.formulaireRecherche.submit();
}

function lancerRecherche()
{
	var texte = document.formulaireRecherche.submit();
}

function changerLangue(langue) {
   var monUrl = window.location.href, r;

   var pos = monUrl.indexOf('/fr/');
   if (pos == -1) pos=monUrl.indexOf('/en/');
   if (pos == -1) {
	pos = monUrl.indexOf('__locale=');
	if (pos != -1) {
		r = monUrl.substring(0, pos + 9) + langue;
	} else {
		pos = monUrl.indexOf('?');
		if (pos == -1) r = monUrl + '?__locale=' + langue;
		else r = monUrl.substring(0, pos) + '?__locale=' + langue;
	}   
   } else {
	r = monUrl.substring(0,pos) + '/' + langue + '/' + monUrl.substring(pos+4);
	pos = r.indexOf('?');
	if (pos != -1) r=r.substring(0,pos);
   }   
   if (r.indexOf('?') == -1) window.location = r + '?langue='+langue;
   else window.location = r + '&langue='+langue;   
}

function changerLangueOLD(langue) {
	var monUrl = window.location.href;

        if (monUrl.indexOf('simpleSearchResult.jsp') != -1) {
	  	window.location = '../internet/'+langue+'/index.html?langue='+langue;
	  	return;
	} else if ((monUrl.indexOf('extranet/') != -1) && (monUrl.indexOf('extranet/news') == -1)) {
	  	window.location = '../../extranet/'+langue+'/index.html?langue='+langue;
	  	return;
	}
	
	position = monUrl.indexOf("?",0);
	monUrl = (position == -1)?monUrl:monUrl.substring(0,position);
	//alert(monUrl + "?langue=" + langue);

	if (monUrl.indexOf('extranet/news/') != -1) {
		var p = monUrl.indexOf('/'), last = -1;
		while (p > 0) {last=p; p=monUrl.indexOf('/',last+1);}
		window.location = monUrl.substring(0,last+1)+'/'+monUrl.substring(last+1) + '?langue=' + langue;
	} else if (monUrl.indexOf('news/') != -1) {
		var p = monUrl.indexOf('/'), last = -1;
		while (p > 0) {last=p; p=monUrl.indexOf('/',last+1);}
		window.location = monUrl.substring(0,last+1)+'/'+monUrl.substring(last+1) + '?langue=' + langue;
	} else if (monUrl.indexOf('assoc/') != -1) {
		var p = monUrl.indexOf('/'), last = -1;
		while (p > 0) {last=p; p=monUrl.indexOf('/',last+1);}
		window.location = monUrl.substring(0,last+1)+'../../'+langue+'/assoc/'+monUrl.substring(last+1) + '?langue=' + langue;
	} else {
		var p = monUrl.indexOf('/'), last = -1;
		while (p > 0) {last=p; p=monUrl.indexOf('/',last+1);}
		window.location = monUrl.substring(0,last+1)+'../'+langue+'/'+monUrl.substring(last+1) + '?langue=' + langue;
	}
        
}


function changerLangueIndex(langue)
{
	var monUrl = window.location.href;
	position = monUrl.indexOf("?",0);
	monUrl = (position == -1)?monUrl:monUrl.substring(0,position);
	//alert(monUrl + "?langue=" + langue);
	window.location = monUrl + '?langue=' + langue;
}



function choixMenuAssoc(choix)
{
	requeteHTTPAjax("GET","../ChoixMenuAssoc?choix=" + choix,null,false);
}

	function getWindowHeight() 
	{
		var windowHeight=0;
		if (typeof(window.innerHeight)=='number') 
		{
			windowHeight=window.innerHeight;
		}
		else 
		{
			if (document.documentElement && document.documentElement.clientHeight) 
			{
				windowHeight = document.documentElement.clientHeight;
			}
			else 
			{
				if (document.body&&document.body.clientHeight) 
				{
					windowHeight=document.body.clientHeight;
				}
			}
		}
		return windowHeight;
	}
	
	
	function getSize(size)
	{
		return size.substr(0,size.length - 2);
	}

	function getWindowWidth() 
	{
		var windowWidth=0;
		if (typeof(window.innerWidth)=='number') 
		{
			windowWidth=window.innerWidth;
		}
		else 
		{
			if (document.documentElement && document.documentElement.clientWidth) 
			{
				windowWidth = document.documentElement.clientWidth;
			}
			else 
			{
				if (document.body&&document.body.clientWidth) 
				{
					windowWidth=document.body.clientWidth;
				}
			}
		}
		return windowWidth;
	}

	function reconstruction()
	{
		//alert(screen.availHeight);
		//alert(getWindowHeight());
		if (!document.getElementById("enteteSicasov").style.height)
			document.getElementById("enteteSicasov").style.height = "140px";

		if (!document.getElementById("piedSicasov").style.height)
			document.getElementById("piedSicasov").style.height = "20px";

		if (document.getElementById("containerSicasov"))
		{
			hauteur = (getWindowHeight() - 170);
			alert(hauteur);
			alert(document.getElementById("containerSicasov").style.height);
			if (getSize(document.getElementById("containerSicasov").style.height) < hauteur)
				document.getElementById("containerSicasov").style.height = (getWindowHeight() - 170) + "px";
		}		
	}

