﻿// Fichier JScript

// nettoyer le contenu d'un champ de saisie
function clearValue(element,valeur)
{
    if($(element).value==valeur)
        $(element).clear();
}

// changer la valeur d'un champ de saisie
function changeValue(element,valeur)
{
    if($(element).value=="")
        $(element).value = valeur;
}

// fonction permettant de garantir que l'overlay est bien a sa place.
function opacifier()
{
    var wid = $("global").getWidth();
    var hei = $("global").getHeight();
    $('overlay').setStyle({
        width: wid+'px',
        height: hei+'px'});
    $("overlay").show();
}

// fonction permettant d'effacer l'overlay
function eclaircir()
{
    $("overlay").hide();
}

// fonction pour ajouter aux favoris
function favoris()
{       
    browserName = navigator.appName;
    browserVer = parseInt(navigator.appVersion);
    if (browserName == "Microsoft Internet Explorer" & browserVer >= 4) 
    {
        window.external.AddFavorite('http:www.nextmedia.fr', 'Next Media');
    }
    if ( navigator.appName != 'Microsoft Internet Explorer' ) 
    { 
        window.sidebar.addPanel('Next Media', 'http:www.nextmedia.fr','');   
    } 
}

// fonction pour ouvrir la pop up de recommandation
function recommander()
{
    window.open('recommander.aspx','', 'width=550px, height=380px, scrollbars = yes');
}

// fonction qui ouvre la pop up de consultation du plan d'accés
function ouvrirPlan()
{
    window.open('plan.aspx','', 'width=550px, height=380px, scrollbars = yes');
}

// fonction qui permet de fermer une fenêtre
function fermer()
{
    window.close();
}

// fonction qui lance une impression
function imprimer()
{
    window.print();
}

//centre un div passer en paramètre
function centrerDiv(sId,largeur,hauteur)
{
	var height=document.getElementById(sId).offsetHeight;//hauteur de l'élément à positionner
	if (hauteur)
		height = hauteur;
	var width=document.getElementById(sId).offsetWidth;//largeur de l'élément à positionner
	if (largeur)
		width = largeur;
	var pHeight=hauteur_fenetre(); //Hauteur de l'élément parent
	var pWidth=largeur_fenetre(); //Largeur de l'élément parent
	var posY=(pHeight/2)-(height/2);
	if (posY <0 ) posY = 0;
	var posX=(pWidth/2)-(width/2);
	if (posX <0 ) posX = 0;
	document.getElementById(sId).style.top=posY+"px";
	document.getElementById(sId).style.left=posX+"px";
}

// retourne la largeur de la fenêtre du navigateur
function largeur_fenetre()
{
 if( typeof( window.innerWidth ) == 'number' ) {
	myWidth = window.innerWidth;
 } 
 else if( document.documentElement && document.documentElement.clientWidth  ) {
	myWidth = document.documentElement.clientWidth;
 }
 else if( document.body &&  document.body.clientWidth  ) {
	myWidth = document.body.clientWidth; 
 }
 return myWidth;
} 

// retourne la hauteur de la fenêtre du navigateur
function hauteur_fenetre()
{
 if( typeof( window.innerHeight ) == 'number' ) {
	myHeight = window.innerHeight;
 }
 else if( document.documentElement && document.documentElement.clientHeight  ) {
	myHeight = document.documentElement.clientHeight;
 }
 else if( document.body && document.body.clientHeight ) {
	myHeight = document.body.clientHeight;
 }
 return myHeight;
}

