// JavaScript Document version 1.05


function getCssStyleValue (element /*element html*/, style/*style recherché*/){
  if(element.currentStyle){
    return element.currentStyle[style];
  }
  else{
    return window.getComputedStyle(element,null).getPropertyValue(style);
  }
}
///////////////////////
function centerPopUp (file,w,h,scrollbar,name){
var cx = Math.round ((screen.availWidth / 2) - (w / 2));
var cy = Math.round ((screen.availHeight / 2) - (h / 2));
scrollbar=(scrollbar == "undefined")?'no':scrollbar;
name=(name == "undefined")?'popUp':name;
window.open(file, name, 'height='+ h +', width='+ w +', top='+ cy +', left='+ cx +', toolbar=no, menubar=yes, location=no, toolbar = no,resizable=yes, scrollbars='+scrollbar+', status=no');
}
function openPop (file,w,h,scrollbar,name){
scrollbar=(scrollbar == "undefined")?'no':scrollbar;
name=(name == "undefined")?'popUp':name;
window.open(file, name, 'height='+ h +', width='+ w +', top=0, left=0, toolbar=no, menubar=yes, location=no, toolbar = no,resizable=yes, scrollbars='+scrollbar+', status=no');
}
////////////////////////////// messages d'alertes simple
function simpleAlert(msg){
	var al = new Alert_window();
	//al.setCloseButton("X","Fermer");
	al.create(msg);
}


function pop_up(){	
fenetre=window.open('','popup','toolbar=0, location=0, directories=0, status=0,  resizable=1, scrollbars=1, height=650,width=650');
}

function pop_up2(){	
fenetre2=window.open('','popup2','toolbar=0, location=0, directories=0, status=0,  resizable=1, scrollbars=1, height=650,width=650');
}
//////////////////////////////////////////////////////popup centrage et redim
function pop_redim(nx,ny) {
	xall = (screen.availWidth / 2);
	yall = (screen.availHeight / 2);
	window.resizeTo(nx,ny);
	self.moveTo(xall - (nx / 2), yall - (ny / 2));
	self.focus();
}

///////////////////////////////////fermer pop ou fenetre
function pop_fermer() { 
	opener=self; 
	self.close(); 
} 

function ouvre_ferme_inline(id) {
	var d = document.getElementById(id);
	
	if(d){
		if (d.style.display=='inline') d.style.display='none'; 			
		else d.style.display='inline';
	}
			
}

function ouvre_ferme_block(id) {
	var d = document.getElementById(id);
	if(d){
		if (d.style.display=='block') d.style.display='none'; 			
		else d.style.display='block';
	}
}

function setStyle(identifiant, style, value){
var id=identifiant;
var styl=style;
var val=value;
if (document.all) { /// si IE
	document.getElementById(id).style.setAttribute(styl,val,"false");
}
else document.getElementById(id).setAttribute("style",style+":"+value+";");
}

function getSrc(img){
var	src=document.getElementById(img).src;
return src;
}

function setSrc(img, src){
document.getElementById(img).src=src;
}

function changeImg(id, name_img1, name_img2, dir_img){
var nameImg=getSrc(id);
nameImg=nameImg.split(dir_img);

if(name_img1==nameImg[1]){
	setSrc(id,dir_img+name_img2);
}
else setSrc(id,dir_img+name_img1);
	
}

var global_onclick = new Array();
function disableDoubleClick(id){
	if(document.getElementById(id)){
		global_onclick[id]=document.getElementById(id).onclick;	
		document.getElementById(id).onclick='';
		return true;
	}
	else return false;
}

function enableDoubleClick(id){
	if(document.getElementById(id)){
		document.getElementById(id).onclick=global_onclick[id];	
		//alert(global_onclick[id]);
		global_onclick[id]='';
		return true;
	}
	else return false;
}


// function page contribution 

function verif_form(form){
	var vf = new Verif_form(form, "Les champs colorés sont obligatoires");
	vf.colore ("#ffffff","#F18C11");
	vf.colorText ("#000000","#000000");
	vf.add_object("nom","vide",null,"Saisissez votre nom!");
	vf.add_object("prenom","vide",null,"Saisissez votre prénom!");
	vf.add_object("email","mail",null,"Saisissez une adresse e-mail valide!");
	vf.add_object("message","vide",null,"Saisissez votre message!");

	if(document.getElementById("adressea").value == 'Sélection du média') { 
		alert('Choisissez un média!');
		return false;
	} 
	return vf.control();
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getViewSize() { //// renvoie taille de la zone d'affichage
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  /// pr enlever espace occupé par scrollbars
  if(typeof(window.innerHeight) == 'number'){
	 if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
		myWidth=myWidth-(window.innerWidth - document.documentElement.clientWidth);
		myHeight=myHeight-(window.innerHeight - document.documentElement.clientHeight);
	}
	/*else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
		myWidth=myWidth-(window.innerWidth - document.body.clientWidth);
		myHeight=myHeight-(window.innerHeight - document.body.clientHeight);
	 }*/
  }  
   return [ myWidth, myHeight ];
}
function initPositionDiv(elem){
	var tab = new Array();
	tab = getScrollXY();
	elem.style.top=tab[1]+'px';
	elem.style.left=tab[0]+'px';
	elem.style.height= getViewSize()[1]+'px';
	window.setTimeout(function(){initPositionDiv(elem)}, 10);
}

function popup_html(affichage)
{
	var affichage = affichage;
	var newDiv=document.createElement("div");
	var opa=0.5;
	newDiv.style.position="absolute";
	newDiv.style.zIndex=100;
	initPositionDiv(newDiv);
	newDiv.style.width='100%';
	newDiv.style.backgroundColor='#000000';
	newDiv.style.opacity=opa;
	newDiv.style.filter = "alpha(opacity=" + (opa*100) + ")"; /// pr IE
	document.body.appendChild(newDiv);
	
	var newDiv2=document.createElement("div");
	newDiv2.style.position="absolute";
	newDiv2.style.zIndex=200;
	newDiv2.style.textAlign='left';
	newDiv2.style.width='577px';
	newDiv2.style.top='1';
 	newDiv2.style.border='10px solid white';
	newDiv2.style.backgroundColor='#ffffff';
	newDiv2.style.marginLeft='-'+Math.round((577+20)/2)+'px';
	newDiv2.style.left='50%';
	newDiv2.innerHTML = affichage; 
	document.body.appendChild(newDiv2);
	var temp=getViewSize()[1]-newDiv2.offsetHeight;
		if(temp>0){newDiv2.style.top=getScrollXY()[1]+(temp/2)+'px';}
		else{newDiv2.style.top=getScrollXY()[1]+'px';}

}
function attente(form)
{
	if(verif_form(form)== true) {
		popup_html("Veuillez patienter pendant l'envoi du message. Le temps d'attente dépend du poids de votre pièce jointe");
		
		return true;
	} else {
		return false;
	}
	
}
