/**
*
* Ensemble des scripts communs � l'ensemble des pages de l'application.
* creator : f.boulier@anios.com
* date    : 19/03/2008
*
*/

/**
* Fonction d'affichage du d�tail d'une offre. 
* Cette affichage se  fait dans une popup.
*/
function viewDetailOffre(id) {
	window.open("viewDetailOffer.do?ident=" + id,'','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=350,width=550');
}

/**
* Fonction d'affichage du d�tail d'une candidature. 
* Cette affichage se  fait dans une popup.
*/
function viewDetailCandidature(id) {
	window.open("viewDetailCandidature.do?ident=" + id,'','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=350,width=550');
}

/**
* Fonction de refus d'une candidature. 
*/
function refuserCandidature(id) {
	javascript:alert('<bean:message key="msg.refuserCandidature" />');	
}


/**
* Fonction d'appel de l'action "Postuler � une offre". 
* Cette affichage se  fait dans la page.
*/
function applyOffer(id) {
	window.document.location = "postulerOffreInit.do?ident=" + id;
}

/**
* Fonction d'impression de la page en cours. 
*/
function printPage(){
    window.document.getElementById("print").style.visibility = "hidden"; 
    window.print();
    window.document.getElementById("print").style.visibility = "visible"; 
}

/**
* Cette fonction rend invisible une div de la page.
*/
function toggle(targetId) {
	target = document.all(targetId);
	if (target.style.display == "none"){
		target.style.display="";
	} else {
		target.style.display="none";
	}
}

/**
* Ouverture d'une pop-up
*/
function openwin(rul, w, h) {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }	
    window.open(rul, "npage", " + width="+w+" + height="+h+" + left="+(myWidth-w)/2+" + top="+(myHeight-h)/2+" srollbars=yes");
 }
 
 
 /**
 * Affichage de la date en temps réel.
 * Script créé par le webmaster de http://cust.er.free.fr
 */
function rafraichirHeure()
{
	var text = '';
	var date = new Date();
 
	/* Fonction ' JOUR ' */
	if ( date.getDate() <= 9 ) {
  		var jour = '0'+date.getDate();
 	} else {
  		var jour = date.getDate();
 	}
 
	/* Fonction ' MOIS ' */
	if ( date.getMonth() <= 9 ) {
  		var mois = '0'+date.getMonth();
 	} else {
  		var mois = date.getMonth();
 	}
 
	/* Fonction ' HEURES ' */
	if ( date.getHours() <= 9 ) {
  		var heure = '0'+date.getHours();
 	} else {
  		var heure = date.getHours();
 	}
 
	/* Fonction ' MINUTES ' */
	if ( date.getMinutes() <= 9 ) {
  		var minutes = '0'+date.getMinutes();
 	} else {
  		var minutes = date.getMinutes();
 	}
 
	/* Fonction ' SECONDES ' */
	if ( date.getSeconds() <= 9 ) {
  		var secondes = '0'+date.getSeconds();
 	} else {
  		var secondes = date.getSeconds();
 	}
 
	text +=  jour+'/'+mois+'/'+date.getFullYear();
	text += ' - ';
	text +=  heure+':'+minutes+':'+secondes;
 
	document.getElementById('affiche_heure').innerHTML = text;
}
