﻿var ID_control='';

function openIframe(id,link) {
	toggleFormOff(id,true,true);
	document.getElementById(id + '_Close').style.display='';
	document.getElementById(id + '_message_box_ifr').src=link;
	ID_control=id;

}

function CloseIframe(id){

    document.getElementById(id + '_message_box_ifr').src = '';    
    toggleFormOff(id,false,false);
}

// toggle disable/enable all form fields
function toggleFormOff(id,action,disableLinks) {

    var form = document.forms[0];
    for(i = 0; i < form.elements.length; i++){
        form.elements[i].disabled = action;
    }
    var div_masque      = document.getElementById(id + '_Masque');
    var div_close       = document.getElementById(id + '_Close');
    if (action==true){
        if (id== 'START_IMAGE' ) 
            {div_masque.className='doBlur2';
            div_masque.observe('click', (function(event) { CloseIframe(id); }).bind(this)); 
            }
        else
            div_masque.className='doBlur';
        div_masque.style.height = getHeightDocument() + 'px';
        div_masque.style.width = getWidthDocument() + 'px';
        //div_close.style.top = '200px'; //getHeightDocument()/3 + 'px'; //pour centrer (plus ou moins :)
        //div_close.style.left = '500px'; //getWidthDocument()/3 + 'px';
        div_masque.style.display = '';
        scroll(0,0);
        var htmlElement = document.getElementsByTagName('html')[0];
        htmlElement.style.overflow = 'hidden';

    }else{
        div_masque.className='noBlur';
        div_masque.style.display = 'none';
        div_close.style.display = 'none';
        var htmlElement = document.getElementsByTagName('html')[0];
        htmlElement.style.overflow = '';
    }

    //    if (disableLinks) { // disable links tabindexes so the visitor can not navigate away from page by tabing to a link and hitting enter
    //        for (ai = 0; ai < document.links.length; ai++) {
    //            document.links[ai].href = '#';
    //        }
    //    }
}

function UnBlur() {
    toggleFormOff(ID_control,false,false);
    document.getElementById(ID_control + '_Close').style.display='none';
    document.getElementById(ID_control + '_message_box_ifr').src='';
    ID_control='';
}

function getWidthDocument(){
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getHeightDocument(){
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}