var urlXiti = "http://logi11.xiti.com";
// http://logi6.xiti.com/hit.xiti
function callXitiTag(portal, page) {
hsh = new Date();
hsd = document;
if (document.location.search.indexOf("ref") > 0) {
	xtreq = document.location.search.substring(1, document.location.search.length);
	myreq = xtreq.substring(xtreq.indexOf("ref"), xtreq.length);
	pos3 = myreq.indexOf("&");
	if (pos3 == -1) pos3 = myreq.indexOf("%26")
	if (pos3 == -1) pos3 = myreq.length;
	hsr = myreq.substring(myreq.indexOf("=")+1, pos3);
}
else {
	hsr = hsd.referrer.replace(/[<>]/g, '');
	hsr = hsr.replace(/&/g, '$')
}
hsi = '<img width="1" height="1" src="'+urlXiti+'?s=138609&s2=' + portal;
hsi += '&p=' + page;
hsi += '&hl=' + hsh.getHours() + 'x' + hsh.getMinutes() + 'x' + hsh.getSeconds();
if(parseFloat(navigator.appVersion)>=4)
{Xiti_s=screen;hsi += '&r=' + Xiti_s.width + 'x' + Xiti_s.height + 'x' + Xiti_s.pixelDepth + 'x' + Xiti_s.colorDepth;}
hsd.writeln(hsi + '&ref=' + hsr + '"><\!--');
}
function xt_clic(typecl,nivsite,page,url,nvlle) {
hsh = new Date();
hsd = document;
hsr = hsd.referrer.replace(/[<>]/g, '');
xt_img = new Image();
hsi = urlXiti+'?s=138609';
hsi += '&s2='+nivsite;
hsi += '&p='+page+'&clic='+typecl+'&hl=' + hsh.getHours() + 'x' + hsh.getMinutes() + 'x' + hsh.getSeconds();
if(parseFloat(navigator.appVersion)>=4)
{Xiti_s=screen;hsi += '&r=' + Xiti_s.width + 'x' + Xiti_s.height + 'x' + Xiti_s.pixelDepth + 'x' + Xiti_s.colorDepth;}
hsi += '&ref=' + hsr.replace(/&/g, '$');
xt_img.src = hsi;
if (url != null)
{ if ((nvlle=='')||(nvlle==null)) { hsd.location = url;} else {xfen = window.open(url,'xfen',''); xfen.focus();}}
else
{return;}
}

var compteur = 0;
function submitonce()
{
	var valide;
	if (compteur == 0) {
			// on valide le formulaire une seule fois
			compteur = compteur + 1;
			valide = true;
	}
	else {
		// on bloque la validation
		valide = false;
	}
	return valide;
}

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.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_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);
}

function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
			if (obj.style) {
				obj=obj.style;
				v=(v=='show')?'visible':(v='hide')?'hidden':v;
			}
			obj.visibility=v;
		}
	}
}

function isPrintable() { //v2.0
	if( this.navigator.appName.indexOf("Netscape") != -1 ) window.print();
	if( this.navigator.appName.indexOf("Microsoft") != -1) {
		var i = navigator.appVersion.indexOf("MSIE");
		var version = navigator.appVersion.substring(i+5, i+9);
		if(parseFloat(version) >= 5.5) window.print();
		else MM_openBrWindow('/statique/imprim.html','imprim','scrollbars=no,resizable=no,width=400,height=300');
	}
}

function unselectOtherOptions(menuselected) {
	var i;
	for (i=0;i<document.forms['myform'].elements.length;i++) {
		if ( !(menuselected == document.forms['myform'].elements[i]) ) {
			document.forms['myform'].elements[i].selectedIndex = -1;
		}
	}
}

function selectMultiSpe(itemchecked) {
	var i;
	for (i=0;i<document.forms['specialites'].brancheMultiSpe.length;i++) {
		document.forms['specialites'].brancheMultiSpe[i].checked = false;
		if(itemchecked == i) document.forms['specialites'].brancheMultiSpe[i].checked = true;
	}
}

function unselectMultiSpe(itemchecked) {
	var i;
	for (i=0;i<document.forms['specialites'].brancheMultiSpe.length;i++) {
		if(itemchecked == i) document.forms['specialites'].brancheMultiSpe[i].checked = false;
	}
}

// comptage caracteres pour limite textarea
function CharCount(objText,Limit) {
	if(objText.value.length > Limit - 1) {
		objText.value = objText.value.replace(/.$/,"");
	}
}

function charAlert(textField, limit)
{
	if(textField.value.length > limit)
	{
		/* must be > 5, not == 5 or else the substring statement on the next line will cause the function to run again if the user dismisses the alert by pressing the 'enter' key rather than clicking 'OK'. */
			textField.value= textField.value.substring(0, limit)
		// set field's value equal to first five characters.

		textField.blur()
		/* move cursor out of form element to keep it from placing itself at position zero, causing an overwrite of the first character */

		alert(limit + " caractères maximum")
	}
}


function afficherItineraire() {
	itinerairewin = window.open("", "itinerairewin", "scrollbars=yes,resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes");
	document.forms["itineraire"].target.value = "itinerairewin";
	document.forms["itineraire"].submit();
}

// moteur de recherche interne
function dateHtml(date_html)
{
	var vardate = date_html.substring(8, 10) + "/" + date_html.substring(5, 7) + "/" + date_html.substring(0, 4);
	return vardate;
}

function datePdf(date_pdf)
{
	var jour = date_pdf.substring(4, 6);
	var mois = date_pdf.substring(0, 3);
	if (mois=="Jan")
	{
		mois="01";
	}
	if (mois=="Feb")
	{
		mois="02";
	}
	if (mois=="Mar")
	{
		mois="03";
	}
	if (mois=="Apr")
	{
		mois="04";
	}
	if (mois=="May")
	{
		mois="05";
	}
	if (mois=="Jun")
	{
		mois="06";
	}
	if (mois=="Jul")
	{
		mois="07";
	}
	if (mois=="Aug")
	{
		mois="08";
	}
	if (mois=="Sep")
	{
		mois="09";
	}
	if (mois=="Oct")
	{
		mois="10";
	}
	if (mois=="Nov")
	{
		mois="11";
	}
	if (mois=="Dec")
	{
		mois="12";
	}
	var annee = date_pdf.substring(7, 12);
	return (jour + "/" + mois + "/" + annee);
}

function rechercheRepertoire(current_url)
{
	var i = "http://".length + 1;
	var indexe = current_url.indexOf('/', i);
	return current_url.substring(indexe + 1, indexe + 4);
}

function couleur(current_url)
{
	var couleur = "#FCEAAC";
	var i = "http://".length + 1;
	var debut = current_url.indexOf('/', i) + 1;
	var fin = current_url.indexOf('/', debut);
	var portail = current_url.substring(debut, fin);
	if (portail == "interim")
	{
		couleur = "#DFE7F9";
	}
	return couleur;
}
function rapportPage(doc_total, doc_actuel)
{
	var code_html = "&nbsp;";
	if (doc_total > 5)
	{
		var page_total = (doc_total - doc_total % 5) / 5;
		if ((doc_total % 5) != 0)
		{
			page_total = page_total + 1;
		}
		var page_actuelle = (doc_actuel - doc_actuel % 5) / 5;
		if ((doc_actuel % 5) != 0)
		{
			page_actuelle = page_actuelle + 1;
		}
		code_html = page_actuelle + "/" + page_total;
	}
	return code_html;
}

function boutPrecedent(doc_actuel, rep)
{
	var code_html = "&nbsp;";
	if (doc_actuel > 5)
	{
		code_html = "<input type='image' src='/images/all/btn_prev.gif' border='0' name='precedent' alt='Documents précédents'>";
	}
	return code_html;
}

function boutSuivant(doc_total, doc_actuel, rep)
{
	var code_html = "&nbsp;";
	if (doc_total != doc_actuel)
	{
		code_html = "<input type='image' src='/images/all/btn_next.gif'  border='0' name='suivant' alt='Documents suivants'>";
	}
	return code_html;
}

// fin moteur recherche interne

function minuteur(temps)
{
  setTimeout('fermer()', temps);
}
function fermer()
{
	window.close();
}
function changeRadio(inputName, radioName )
{
	//inpuName = le nom du bouton radio
	if ( inputName.value != "" )
	{
		//radioName[0].value = true;
		document.forms['candidature'].disponibilite[1].checked = true;
	}
}

function razValue(inputName)
{
	//inpuName = le nom du bouton radio
	if ( inputName.checked = true)
	{
		document.forms['candidature'].jourdisponibilite.value = "";
		document.forms['candidature'].moisdisponibilite.value = "";
		document.forms['candidature'].anneedisponibilite.value = "";
	}
}

/**
/* Methode permettant de passer directement au champ suivant pour la saisie de date
/* champ1 : champ de départ
/* champ2 : champ d'arrivée
*/
function Compter(champ1, champ2)
{
	// Nombre de caractères max 2 pour jour et mois
	var max = 2;
	// Longueur actuelle du champ1
	var taille = champ1.value.length
	// Si le nombre de caractères est >= au nombre max autorisé, on passe au champ suivant
	if (taille >= max)
	{
		champ2.focus();
	}
}

/**
/* Methode permettant deffacer un champ quand il est selectionne : permet correction plus aisée avec methode ci dessus
/* champ1 : champ de départ
*/
function EffaceChamp(champ1)
{
	champ1.value = "";
	champ1.focus();
}
