// JavaScript Document

/* script preload page */
function opacity(elt) 
{ 
    opaciT = opaciT - transition;
    var object = document.getElementById(elt).style; 
    object.opacity = (opaciT / 100); 
    object.MozOpacity = (opaciT / 100); 
    object.KhtmlOpacity = (opaciT / 100); 
    object.filter = "alpha(opacity=" + opaciT + ")"; 
     if(opaciT<=0)
     {
          document.getElementById(elt).style.visibility="hidden";
          clearInterval(timer);
     }
}
var speed = 10; 
var transition = 10;
var timer= 0;
var opaciT = 100; 
function preload() 
{ 
     if (document.getElementById) 
     {
          document.getElementById('preloadIMG').style.visibility="hidden";
          timer = setInterval("opacity('preloader')",speed);
     }
     else 
     {
          if (document.layers) 
          {    
               document.preloadIMG.visibility = "hidden";
               timer = setInterval("opacity('preloader')",speed);
         } 
             else 
          {
               document.all.preloadIMG.style.visibility = "hidden";
               timer = setInterval("opacity('preloader')",speed);
          } 
     }
}

function SetFormActionAndSubmit(formaction,formtarget,formname){
	document.forms[formname].action = formaction;
	document.forms[formname].target = formtarget;
	document.forms[formname].submit();
}

function SetFormElementValue(formelement,formvalue,formname){
	document.forms[formname].elements[formelement].value = formvalue;
}

function ConfirmAction(confirmphrase){
	if(!confirm(confirmphrase)){
		return false;
	}
}

function ConfirmDeletePage(confirmphrase, formname,formrequest, formaction,formtarget){
	if(confirm(confirmphrase)){
		SetFormElementValue('formrequest',formrequest,formname);
		SetFormActionAndSubmit(formaction,formtarget,formname);
        return true;
	} else {
		return false;
	}
}

function changecss(SSName,myclass,element,value) {
	var stylesheet = document.styleSheets[(document.styleSheets.length - 1)];
    for( var i in document.styleSheets ){
                if( document.styleSheets[i].href && document.styleSheets[i].href.indexOf(SSName) )
                        //stylesheet = document.styleSheets[i];
						SSIndex = i;
        }

	var CSSRules
	if (document.all) {
		CSSRules = 'rules';
	}
	else if (document.getElementById) {
		CSSRules = 'cssRules';
	}
	for (var i = 0; i < document.styleSheets[SSIndex][CSSRules].length; i++) {
		if (document.styleSheets[SSIndex][CSSRules][i].selectorText == myclass) {
			document.styleSheets[SSIndex][CSSRules][i].style[element] = value;
			//stylesheet[CSSRules][i].style[element] = value;
		}
	}	
} // use like this changecss(0,'.myclass','backgroundColor','yellow')

function alertSize() {
  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;
  }
  if(document.getElementById('Global')){
    document.getElementById('Global').style.height=myHeight+'px';
    var tempWidth= (myHeight/100*80);
    document.getElementById('Global').style.width=(tempWidth/900*1440)+'px';
    var tempMarginLeft= (tempWidth/900*1440);
    document.getElementById('Global').style.marginLeft=-(tempMarginLeft/2)+'px';
    document.getElementById('Global').style.fontSize=((myHeight/100*80)/525*13)+'px';
  }
  if(document.getElementById('DemandeBoxBody')){
    document.getElementById('DemandeBoxBody').style.height=((myHeight/100*90)-40)+'px';
  }
  if(document.getElementById('CenterScreen')){
    document.getElementById('CenterScreen').style.height=(myHeight/100*80)+'px';
    var tempWidth= (myHeight/100*80);
    document.getElementById('CenterScreen').style.width=(tempWidth/900*1440)+'px';
    var tempMarginLeft= (tempWidth/900*1440);
    document.getElementById('CenterScreen').style.marginLeft=-(tempMarginLeft/2)+'px';
  }

//window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}

function alertSizeIframes() {
var global = jQuery('#FormulaireBlock');
global.queue('bodyQueue', function(){
  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;
  }
  if(document.getElementById('FormulaireBlock')){
    myHeight2 = parent.document.getElementById('Global').style.height.replace('px','');
    var tempHeight2= (myHeight2/100*80);
    document.getElementById('FormulaireBlock').style.width=((tempHeight2/900*1440)/100*65)+'px';
    document.getElementById('FormulaireBlock').style.fontSize=((myHeight2/100*80)/525*13)+'px';
  }
  jQuery(this).dequeue('bodyQueue');
}).delay(100, 'bodyQueue');
global.queue('bodyQueue', function(){
	var i=1;	for(i=1; i=22; i++){
		var myFrame = jQuery('#myFrame'+i,parent.document.body);
		myFrame.height(jQuery('#FormulaireBlock',document.body).height()+10);
	}
});
global.dequeue('bodyQueue');
	}

/* ------------------------------------------------------------------------------------------------------------------------------------ */
/* --- script montrer|cacher ---------------------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------------------ */

function montrer(obj){
  document.getElementById(obj).style.display="block" ;
}
function cacher(obj) {
  document.getElementById(obj).style.display="none";
}

/* ------------------------------------------------------------------------------------------------------------------------------------ */
/* --- script detect elements à cacher ------------------------------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------------------------------------------------------------------ */
function DetectElementToHide(elemt,elemtname,vertid) {
  var divs = document.getElementsByTagName(elemt);
  for (var i = 0; i < divs.length; i++){                      
      var divname = divs[i].id; 
      if(divname.indexOf(elemtname) == 0) { 
	    if(divname==vertid) {
		   montrer(divname);
		  //IconsMoveDown(divname,1500);
		} else {
	      cacher(divname);
        }
      }
   }
}


/* ------------------------------------------------------------------------------------------------------------------------------------ */
/* --- script swap images ------------------------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------------------ */

function SwapMyImages(MyId,MyImgSrc)
	{

	if (document.all){
	  document.all(MyId).src=MyImgSrc;
	}
	else if (document.getElementById){
	  document.getElementById(MyId).src=MyImgSrc;
	}
	else if (document.layers){
	document.layers[MyId].src=MyImgSrc;
	}

	}


/* ------------------------------------------------------------------------------------------------------------------------------------ */
/* --- script get value of radio button ----------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------------------ */

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



