/*********************************************************************
/GLOBAL VARIABLES/
*********************************************************************/
theDoc = document


/*********************************************************************
RIGHT NAV ALWAYS ON THE TOP
*********************************************************************/
var targetDelay = 0;
var thumbDelay = 0

function iniRightNav() {
	objNavWindow = new divMaker('divNavWindow');
	objNavWindow.startPos = objNavWindow.y;
	objNavContent = new divMaker('divNavContent','divNavWindow');
	checkNavPosition();
	objNavWindow.show();
}

function iniFAQ() {
	objFaqScrollWindow = new divMaker('divFaqScrollWindow');
	objFaqScrollContent = new divMaker('divFaqScrollContent','divFaqScrollWindow');
	objFaqScrollContent.moveTo(497,null);
}

function checkNavPosition() {
	obj = objNavWindow;

	if(is.ie)      target = theDoc.body.scrollTop;
	else if(is.ns) target = window.pageYOffset;
	if(target<obj.startPos) target = obj.startPos;

	if(obj.y != target){
		obj.target = target
		moveToTarget(obj.target,obj.objName);
	}
	setTimeout('checkNavPosition();',800);

}

function moveToTarget(target,objName) {
	obj = eval(objName);
	oldY = obj.y;
	distance = (obj.target - oldY)*0.08;
	newY = oldY +distance;
	obj.moveTo(null,newY);
	targetDelay = setTimeout("moveToTarget("+obj.target+","+obj.objName+")", 15);
	if (distance<0.05 && distance>-0.05) {
		obj.moveTo(null,target);
		clearTimeout(targetDelay);
	}
}

//preloadImg('thumb_on','/image_lang/fr/rd/sd_thumb_search.gif')
//preloadImg('thumb_off','/image_lang/fr/rd/sd_thumb_search_again.gif')

function handleThumb() {
		obj = objNavThumb;
		obj.target = (!obj.flagThumb) ? obj.thumbPosTop : obj.thumbPosBot;
		moveToTarget(obj.target,obj.objName);
		//statutThumb = (flagThumb) ? 'off' : 'on';  //HANDLE the rollover
		//swapThumb(statutThumb);
		obj.flagThumb = !obj.flagThumb;
}
/*
function swapThumb(staut) {
	var objImg = (is.dom && (!is.mac)) ? theDoc.getElementById('thumb') :
				 (is.ie4 || (is.ie && is.mac && is.dom))? theDoc.all['thumb'] :
				  is.ns4 ? window.document.divWindowForm.document.divContentForm.document.images['thumb'] : 0;
	objImg.src = (staut=='on') ? thumb_on.src : thumb_off.src;
}
*/


/*********************************************************************
'///////////////////HANDLE FORM ELEMENTS//////////////////////
*********************************************************************/
function isValidEmail(strEmail) {
	if (!/^[\.\w-]+@[\.\w-]+\.\w{2,4}$/g.test(strEmail))
		return false;
	else
		return true;
}
function checkFocus(obj) {
	if (obj.value=='type-in your email') obj.value='';
}
/*********************************************************************
PRELOAD AN IMAGE
*********************************************************************/
function preloadImg(imgObj,imgSrc) {
	eval(imgObj+' = new Image()')

	eval(imgObj+'.src = "'+imgSrc+'"')
}
/*********************************************************************
PRELOAD ROLLOVER IMAGES [ON-OFF]
*********************************************************************/
function preloadRol(imgObj,imgSrc,imgExt) {
	eval(imgObj+'_on = new Image()')
	eval(imgObj+'_on.src = "'+imgSrc+'_on.'+imgExt+'"')
	eval(imgObj+'_off = new Image()')
	eval(imgObj+'_off.src = "'+imgSrc+'_off.'+imgExt+'"')
}

/*********************************************************************
 ROLLOVER
*********************************************************************/

var rolFlag = 1
function rol(id,ref){
	statut = (rolFlag) ? 'on' : 'off';	rolFlag = (rolFlag) ? 0 : 1;
	if(!ref || is.ie4 || is.dom) theDoc.images[id].src=eval(id+'_'+statut+'.src');
	//<% 'CHECKER si ça marche avec ref ... %>
}

/*********************************************************************
 MULTI ROLLOVER
*********************************************************************/
navRolFlagMulti = 1
function navRolMulti(id) {
	indiceName = 'navIndice'+id
	statut = (navRolFlagMulti) ? 'on' : 'off';
	navRolFlagMulti = !navRolFlagMulti;
	theDoc[indiceName].src = eval('navIndice_'+statut+'.src');
	theDoc[id].src = eval(id+'_'+statut+'.src');
}

/*********************************************************************
 POPUP
*********************************************************************/
function popup(url, largeur, hauteur) {
	var str = 'TOOLBAR=NO, LOCATION=NO,DIRECTORIES=NO,TOP=0, LEFT=0, STATUS=NO,MENUBAR=NO,SCROLLBARS=NO,RESIZABLE=NO,COPYHISTORY=YES,WIDTH='+ largeur +',HEIGHT='+
	hauteur;
	window.open(url, "PopUp", str)
}

/*********************************************************************
BROWSER SNIFFER
*********************************************************************/
function browser() {
	nav = navigator;
	bwName = nav.appName;
	bwAgent = nav.userAgent;
	bwVer = parseInt(nav.appVersion);
	this.pc=(bwAgent.indexOf("Windows") != -1)  ? true:false;
	this.mac=(bwAgent.indexOf("Mac") != -1)  ? true:false;

	this.dom=theDoc.getElementById?true:false;

	this.op =(bwAgent.indexOf("Opera") != -1) ? true:false;
	this.ie =(bwAgent.indexOf("MSIE")!= -1  && !this.op) ? true:false;
	this.ns =(bwName=="Netscape") ? true:false;

	this.ie4 = (bwAgent.indexOf('MSIE 4')!= -1) ? true:false;
	this.ie6 = (bwAgent.indexOf("MSIE 6.")!= -1) ? true:false;
	this.ie5up = (this.ie && bwVer>=4) ? true:false;

	this.ns4 =(this.ns && bwVer==4) ? true:false;
	this.ns6=(this.ns && bwVer==5 &&(bwAgent.indexOf("Gecko") != -1)) ? true:false;;

	this.op5 = (bwAgent.indexOf("Opera 5.") != -1) ? true:false;;
	this.op6 =( (bwAgent.indexOf("Opera 6")!=-1) || (bwAgent.indexOf("Opera/6")!=-1) ) ? true:false;
}
is = new browser()

/*********************************************************************
DHTML OBJ CONSTRUCTOR
*********************************************************************/
function divMaker(id,ParentLay) {
	//customize to use ParentLayer
    Reflay = (ParentLay) ? 'document.'+ParentLay+'.' : ''
    this.elm = is.dom?theDoc.getElementById(id):is.ie4?theDoc.all[id]:is.ns4?eval(Reflay+'document.'+id):0;
    this.css = is.dom?this.elm.style:is.ie4?this.elm.style:is.ns4?this.elm:0;
    this.doc = (is.dom || is.ie4)?theDoc:is.ns4?this.css.document:0;
    this.x = (is.dom || is.ie4)?this.elm.offsetLeft:is.ns4?this.css.left:0;
    this.y = (is.dom || is.ie4)?this.elm.offsetTop:is.ns4?this.css.top:0;
    this.w = (is.dom || is.ie4)?this.elm.offsetWidth:is.ns4?this.css.clip.width:0;
    this.h = (is.dom || is.ie4)?this.elm.offsetHeight:is.ns4?this.css.clip.height:0;
	this.divName = id;
	this.objName = 'obj'+id.substr(3);

this.moveTo = moveTo;
this.show = show;
}
function moveTo(x,y) {
	if (x!=null) {
		this.x = x
		if (is.ie4) this.css.pixelLeft = this.x
		else this.css.left = this.x
	}
	if (y!=null) {
		this.y = y
		if (is.ie4) this.css.pixelTop = this.y
		else this.css.top = this.y
	}
}
function show() {
	this.css.visibility = (is.ns4)? "show" : "visible"
}
////////////////////////////////

/*********************************************************************
HANDLE RESIZE ON NETSCAPE BROWSER
*********************************************************************/
if(!window.saveInnerWidth) {window.onresize = resize;window.saveInnerWidth = window.innerWidth;window.saveInnerHeight = window.innerHeight}
function resize() {
    if (saveInnerWidth < window.innerWidth||saveInnerWidth > window.innerWidth||saveInnerHeight > window.innerHeight ||saveInnerHeight < window.innerHeight)
		top.location=top.location;
}

/*********************************************************************
PRINT
*********************************************************************/
////////////////// Auteur : Wicket Man

ie=document.all?1:0;
function printIt() {
ver=navigator.appVersion.indexOf("4");
if (ver!=-1&&ie) print();
else window.print();
}
////////////////// The code by Captain <cerebrum@iname.com>
////////////////// Mead & Company, http://www.meadroid.com/wpm/
// fake print() for IE4.x
if ( !printIsNativeSupport() )
	if (ie)
  window.print = printFrame;
// main stuff
function printFrame(frame, onfinish) {
  if ( !frame ) frame = window;
  if ( frame.document.readyState != "complete" &&
       !confirm("The document to print is not downloaded yet! Continue with printing?") )
  {
    if ( onfinish ) onfinish();
    return;
  }
  if ( printIsNativeSupport() ) {
    var focused = document.activeElement;
    frame.focus();
    frame.self.print();
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    return;
  }
  var eventScope = printGetEventScope(frame);
  var focused = document.activeElement;
  window.printHelper = function() {
    execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
    printFireEvent(frame, eventScope, "onafterprint");
    printWB.outerHTML = "";
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    window.printHelper = null;
  }
  document.body.insertAdjacentHTML("beforeEnd",
    "<object id=\"printWB\" width=0 height=0 \
    classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");
  printFireEvent(frame, eventScope, "onbeforeprint");
  frame.focus();
  window.printHelper = printHelper;
  setTimeout("window.printHelper()", 0);
}
function printIsNativeSupport() {
  var agent = window.navigator.userAgent;
  var i = agent.indexOf("MSIE ")+5;
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;
}
function printFireEvent(frame, obj, name) {
  var handler = obj[name];
  switch ( typeof(handler) ) {
    case "string": frame.execScript(handler); break;
    case "function": handler();
  }
}
function printGetEventScope(frame) {
  var frameset = frame.document.all.tags("FRAMESET");
  if ( frameset.length ) return frameset[0];
  return frame.document.body;
}

function checkSearchString() {

if ( this.document.forms['form1'].qu.value != '' ) {
	this.document.forms['form1'].submit();
}
return false;

}

function doNothing() {
}

function SendToFriend(curRelPath) {

	if (is.ns4) {
		//alert('ns4 case'+tmpURL)
		tmpURL = self.document.divScrollWindowMain.layers.divScrollContentMain.src
		var splitted = tmpURL.split('/');
		splitted.shift();
		splitted.shift();
		splitted.shift();
		splitted.shift();
		splitted.shift();
		var splitted2 = splitted[0].split('&');
		var splitted3 = splitted2[1].split('=');
		currentUrl = splitted3[1]
		}
	else {
		currentUrl = top.currentDocid
		}

	if (!curRelPath ) { var locRelPath = "" ;}
		else { locRelPath = curRelPath}

	window.open('/page/popup/SendToFriend.asp?docid='+currentUrl, 'SendToFriendPopUp','width=540,height=420,COPYHISTORY=YES' );
}

if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return};
function HM_f_PopDown(){return};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
