// JavaScript Document
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

function MM_swapImage() { //v3.0
  //MM_swapImgRestore();
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openWindow(theURL,winName,imageWidth,imageHeight) { //v2.0
	var posLeft = (screen.availWidth-imageWidth) / 2
	var posTop 	= (screen.availHeight-imageHeight) / 2 
	features = "width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop;
  window.open(theURL,winName,features);
}


// Open PopupWindow
function openPicture(imageType,imageName,nametitle,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	var posLeft = (screen.availWidth-imageWidth) / 2
	var posTop 	= (screen.availHeight-imageHeight) / 2 
	
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	
	newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Image Popup</title><link href="../css/common.css" rel="stylesheet" type="text/css" media="all" /></head><body><div id="popUp"><div id="cont"><div style="border-bottom:1px solid #BFBFBF; padding:0; margin:0;"><h4><strong>'); 
	newWindow.document.write(nametitle+'</strong></h4></div><div id="centerImg">');
	newWindow.document.write('<img src=\"'+imageName+'\" alt="photo" /></div><div><img src="../imgs/pop_bottom.gif" alt="photo" />');
	//newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	
	
	newWindow.document.write('</div></div><div id="popBut"><a href="javascript:window.close()"><img src="../imgs/pop_but.gif" alt="photo" /></a></div></div></body></html>');
	newWindow.document.close();
	newWindow.focus();
// use : onClick="openPicture('jpg','images/ps5_z.jpg','638','272','Image alt','','')"
}

// change images state
var imminus = new Image();
var implus = new Image();
imminus.src = "../imgs/iconopen_minus.gif";
implus.src = "../imgs/iconopen_plus.gif";

function doButtons(objId) {
	obj = MM_findObj(objId);
	reseticon(imminus.src, implus.src, obj);
	(obj.src == implus.src)?(obj.src=imminus.src):(obj.src=implus.src);
}

// Take the state passed in, and change it.
function changeState(layerRef, state) {
	hideLayers(layerRef,10);
	mlayer=MM_findObj(layerRef);
	//alert (mlayer.style.display);
	(mlayer.style.display=="block")?(mlayer.style.display="none"):(mlayer.style.display=state);

}

// Hide all layers	
function hideLayers (LayerExclude, LayerInPage) { 
	for (i=1; i<=LayerInPage; i++) {
		if ( MM_findObj("layer"+i) && (("layer"+i)!=LayerExclude) ) {
			curlayer=MM_findObj("layer"+i);
			curlayer.style.display="none";
		}
	}
}


function reseticon (orgicon, iconreplace, excludeicon) {
	var imgs = document.getElementsByTagName('img');
	//alert (imgs.length);
	for (var i=0; i<imgs.length; i++) {
		if (imgs[i].src.indexOf('.gif') != -1) { // On cible seulement les lments input de type image avec une extension de type .gif
			if (imgs[i].src==orgicon && imgs[i].src!=excludeicon.src) {
				imgs[i].src=iconreplace;
			}
		}
	}	
}


function changeLegend(strLegend){
	document.getElementById("legend_on").innerHTML = strLegend;
} 

/* change the border of thumb photos */
function curItm(obj, id) {	
	resbackground(id);
	obj.style.backgroundColor="#2954af";
}

function curPhoto(obj, id) {
	resbrd(id);
	obj.style.border="1px solid #2954af";
}

function setAltTag(imgId,altText) {
	var imgObj=MM_findObj(imgId);
	if (imgObj!=null) {
		imgObj.alt=altText;
		imgObj.title=altText;
	}	
}

function resbrd(id) {
	var nav = document.getElementById(id);
	var imgs = nav.getElementsByTagName('img');
	for (var i=0; i<imgs.length; i++) {
		imgs[i].style.borderWidth='1px';
		imgs[i].style.borderColor='';
	}
}

function resbackground(id) {
	var nav = document.getElementById(id);
	var imgs = nav.getElementsByTagName('a');
	for (var i=0; i<imgs.length; i++) {
		imgs[i].style.backgroundColor='#0099cc';
	}
}

function getElementsByBaseTagClass(base, tag, className) { 
    var classPat = new RegExp('\\b'+className+'\\b'); 
    var nodes = base.getElementsByTagName(tag); 
    var matching = []; 
    for (var i = 0; i < nodes.length; i++) { 
        if (classPat.test(nodes[i].className)) { 
            matching.push(nodes[i]); 
        } 
    } 
	return matching; 
} 
function faq(id) {
	curfaq = MM_findObj(id);	
	if (curfaq.style.display=="") {
		curfaq.style.display="block";
	} else if (curfaq.style.display=="none") {
		curfaq.style.display="block";
	} else if (curfaq.style.display=="block") {
			curfaq.style.display="none";
	}
}
function imgChange(id, curlink) {
	var img1= new Image();
	var img2= new Image();
	img1.src="../imgs/dot2.gif";
	img2.src="../imgs/arrow4.gif";
	if (curlink.length==1) {
	} else {
		for (i=0; i < curlink.length; i++) {
			if (i!=id){
				curlink[i].src=img2.src;	
			}
		}
		curlink[id].src=img1.src;		
	}
}

function hightlight (id, curlink) {
	if (curlink.length==1) {
	} else {
		for (i=0; i < curlink.length; i++) {
			if (i!=id)
			curlink[i].style.color="";	
			curlink[i].style.backgroundColor="";
		}
		curlink[id].style.color="#2954AF";		
		curlink[id].style.backgroundColor="#fff";		
	}
}
/*
 * FlashObject embed
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.1.0 - 03-31-2005
 *
 * writes the embed code for a flash movie, includes plugin detection
 *
 * Usage:
 *
 *	myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *	myFlash.write("objId");
 *
 * for best practices, see:
 *  http://blog.deconcept.com/2005/03/31/proper-flash-embedding-flashobject-best-practices/
 *
 */

var FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver;
	this.align = "middle";

	this.params = new Object();
	this.variables = new Object();

	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.bypassTxt = "<p>Already have Macromedia Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

var FOP = FlashObject.prototype;

FOP.addParam = function(name, value) { this.params[name] = value; }

FOP.getParams = function() { return this.params; }

FOP.getParam = function(name) { return this.params[name]; }

FOP.addVariable = function(name, value) { this.variables[name] = value; }

FOP.getVariable = function(name) { return this.variables[name]; }

FOP.getVariables = function() { return this.variables; }

FOP.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" wmode="opaque" id="' + this.id + '" align="' + this.align + '"  scale="noborder" ';
        for (var param in this.getParams()) {
		flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs()) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
		 flashHTML += '<param name="SCALE" value="noborder" />';
		 flashHTML += '<param name="wmode" value="opaque" />';
        if (this.getParamTags()) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    return flashHTML;	
}

FOP.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) { 
    	variablePairs.push(name + "=" + escape(this.getVariable(name))); 
    }
    return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}

FOP.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else if (this.altTxt) {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

/* ---- detection functions ---- */
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y = x.description;
   			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	return (getFlashVersion() >= ver) ? true:false; }

// get value of query string param
function getQueryParamValue(param) {
	var q = document.location.search || document.location.href.split("#")[1];
	if (q) {
		var detectIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
		if (q.length > 1 && detectIndex > -1) {
			return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
		} else {
			return "";
		}
	}
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}


//Lan.tt
function trim(str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isEmail(s)
{
	if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
            return true ;
        else
            return false ;
    
}
function sendcontact(mquestion){
	var frm=MM_findObj("frmfaq");
	var mthemeid=MM_findObj("themeid");
	var quest=MM_findObj("question");
	//
	var href=window.location+"";
	var pos=href.indexOf("theme=");	
	if(pos==-1){
		var pos=href.indexOf("theme_id=");
		var id=href.substr(pos+9);
	}else{
		var id=href.substr(pos+6);
	}	
	//
	mthemeid.value=id;
	quest.value=mquestion;
	//frm.action="default.asp?nav1=contacts&nav2=nous";
	frm.submit();
}
//-->
function goFunc(){
		var obj=document.getElementById('cbSelector');//MM_findObj('cbSelector',document);
		var index=obj.selectedIndex;
		window.location="?nav1=func&nav2="+obj.options[index].value;
	}
	
function fCheckNumber(obj){
	var re = /^([0-9]*[0-9]$)/;
	var sEMail = obj.value;
	if (sEMail.search(re) == -1){
			return false;
		}
	return true;
}
