
//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
var effects = true ;

var overlayDuration2 = 0.2;	// shadow fade in/out duration
var overlayOpacity2 = 0.8;	






function opacity2(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    var pSize = getPageSizeArray() ;
    var destWidth = pSize[2] ;
    var destHeight = pSize[3] ;
    var curWidth = 0 ;
    var curHeight = 0 ;
    var step = 10 ;
    var end = 0 ;


		
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 


    	//document.getElementById(id).style.left = destWidth/2 ;
    	//document.getElementById(id).style.top = destHeight/2 ;
        for(i = opacStart; i >= opacEnd; i-=step) { 
        	  //curWidth = steps * destWidth ;
        	  //curHeight = steps * destHeight ;
        	  if (opacEnd==i) {end = 2 ;} else { end = 0 ; }
        	  
            setTimeout("changeOpac2('" + id + "',"+i+","+end+")",(timer * speed)); 
            timer++; 
        } 

        


    } else if(opacStart < opacEnd) { 
    	
		//changeOpac2("myDiv", opacEnd, 0, 0) ;

document.getElementById("myDiv").style.width = pSize[2]+'px';
		document.getElementById("myDiv").style.height = pSize[3]+'px';
		changeOpac2("myDiv", opacStart, 0, 0) ;
		document.getElementById("myDiv").style.display = '' ;



        for(i = opacStart; i <= opacEnd; i+=step) 
            {
            	if (opacEnd==i) {end = 1 ;} else { end = 0 ; } 
            setTimeout("changeOpac2('" + id + "',"+i+","+end+")",(timer * speed)); 
            timer++; 
        }
    } 
} 


//change the opacity for different browsers 
function changeOpac2(id, opacity, end) { 
	
    var object = document.getElementById(id).style; 
    
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")";
    //object.width=width;
    //object.height=height;
    if (end==2)
    {
      document.getElementById("myDiv").style.width = '0px';
		  document.getElementById("myDiv").style.height = '0px';
		  //changeOpac2("myDiv", opacStart, 0, 0) ;
		  document.getElementById("myDiv").style.display = 'none' ;
    	
    }
}


function fadeIn() 
{	
	opacity2("myDiv", 0,50, 200) ;
}

function fadeOut()
{
	opacity2("myDiv", 50, 0, 200) ;

}





function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
	
    var object = document.getElementById(id).style; 
    
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftPageOpacity(id, opac, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == opac) { 
        opacity(id, opac, 100, millisec); 
    } else { 
        opacity(id, 100, opac, millisec); 
    } 
} 

function changeWebsiteOpacity(start, end) { 
   if (ie5) opacity('websitePageBody', start, end, 10); 
   else opacity('websitePage', start, end, 10); 
} 




function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
/*
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
*/
}

function initializedrag(e){
/*
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
*/
}

function loadwindow(url,title,width,height, ntop, nleft){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{

//document.getElementById("dwindow").style.display=''	


document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"

//document.getElementById("cframetr").style.width=width+"px"
//document.getElementById("cframetr").style.height=height+"px"
document.getElementById("cframe").style.width=(width-20)+"px"
document.getElementById("cframe").style.height=(height-46)+"px"

//document.getElementById("dwindow").style.left=nleft+"px"
//document.getElementById("dwindow").style.top=ns6? ntop+"px" : ntop+"px"
document.getElementById("cframe").src=url
document.getElementById("dwindowtitle").innerHTML=title

// Permet de centrer
var a = getPageSizeArray() ;
var calc = ((a[0]-width)/2)+((a[2]-a[0])/2) ;

  if (nleft=='0' && ntop=='0')
  {
    document.getElementById("dwindow").style.left="0px"
    document.getElementById("dwindow").style.top="0px"
    document.getElementById("dwindow").style.display=''	
    effects = false ;
    
  } else {
    document.getElementById("dwindow").style.left= calc+"px"
    document.getElementById("dwindow").style.top=ns6? "160"+"px" : "160"+"px"
    //new Effect.Grow(document.getElementById("dwindow"));	
    document.getElementById("dwindow").style.display=''	  
    //changeWebsiteOpacity(100, 50) ;
fadeIn();    
    
  }

}
}


function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
	
if (effects)
{
	//document.getElementById("dwindow").style = "background-color:#fff";
	document.getElementById("dwindow").style.display='none'	
	//changeWebsiteOpacity(50, 100) ;
	fadeOut();
	
	//document.getElementById("dwindow").style.background = "#FFFFFF";
//  new Effect.Shrink(document.getElementById("dwindow"));
} else {
	document.getElementById("dwindow").style.display='none'	
	
}	
	
//document.getElementById("dwindow").style.display="none"
document.getElementById("cframe").src=''
document.getElementById("dwindowtitle").innerHTML=''
}

function reloadit(){
document.getElementById("cframe").src=document.getElementById("cframe").src ;
}

function stopdrag(){
/*
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
*/
}





/**********************************************************************************   
LoadingBar 
*   Copyright (C) 2001 <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a>
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a> 
*********************************************************************************/

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()

numImages = 20
loaderWidth = 250

var px = bw.ns4||window.opera?"":"px";

currentImg = 0
function lib_doc_size(){ 
  this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;
  this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
  if(!this.x2||!this.y2) return message('Document has no width or height') 
  this.x50=this.x2/2;this.y50=this.y2/2;
  return this;
}

//Lib objects  ********************
function lib_obj(obj,nest){ 
  nest=(!nest) ? "":'document.'+nest+'.'
  this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;	
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; 
  this.ref=this.css
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0; 
  return this
}
//Moving object to **************
lib_obj.prototype.moveIt = function(x,y){
  this.x=x; this.y=y; this.css.left=x+px; this.css.top=y+px;
}
//Clipping object to ******
lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){ 
  this.ct=t; this.cr=r; this.cb=b; this.cl=l
  if(bw.ns4){
    this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
  }else{
    if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
    this.css.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
    if (setwidth){
		this.css.pixelWidth = r;
		this.css.pixelHeight = b;
		this.css.width = r+px; 
		this.css.height = b+px;
	}
  }
}
var oLoad2
function startLoading(){
  page = new lib_doc_size()
  oLoadCont = new lib_obj('divLoadCont')
  oLoad = new lib_obj('divLoad1','divLoadCont')
  oLoad2 = new lib_obj('divLoad2','divLoadCont.document.divLoad1')
  oLoadText = new lib_obj('divLoadText','divLoadCont.document.divLoad1')
  oLoad.moveIt(page.x50-loaderWidth/2,page.y50-20)
  oLoadText.moveIt(loaderWidth/2 - oLoadText.w/2,10)
  oLoad.clipTo(0,loaderWidth,40,0,1)
  oLoad2.per = loaderWidth/numImages
}
function loadIt(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (!ok){
    oLoadCont.css.visibility = "hidden"
    oLoadCont = null;
	oLoad1 = null;
	oLoad2 = null;
  }
}

//DISPLAY FUNCTION - DELETE START -------- DELETE THIS *************
//LEAVE THIS FUNCTION WHILE TESTING. DELETE WHEN READY
function loadIt_display(ok){
  currentImg ++
  if (oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)
  if (currentImg<=numImages) setTimeout("loadIt_display(1)",200)
  else{
    oLoadCont.css.visibility = "hidden"
  }
}
//DISPLAY FUNCTION - DELETE END *************************************

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSizeArray(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}







