/**
 * pageHandler stuff
 */

if (!pageHandler)
{
    var pageHandler = {};
}

pageHandler.getId = function()
{
    return this.id;
}

pageHandler.getRef = function()
{
    return this.ref;
}

pageHandler.getLang = function()
{
    return this.lang;
}

pageHandler.getTitle = function()
{
    return this.title;
}

pageHandler.getAuthor = function()
{
    return this.author;
}

pageHandler.getKeywords = function()
{
    return this.keywords;
}

pageHandler.getThread = function()
{
    return this.thread;
}

pageHandler.getTags = function()
{
    return this.tags;
}

pageHandler.hasTag = function(tag)
{
    return (this.tags.indexOf(tag) != -1);
}

pageHandler.getTopic = function()
{
    return this.topic;
}

pageHandler.setTopic = function(topic)
{
    this.topic = topic;
}

pageHandler.getMarker = function()
{
    return this.marker;
}

pageHandler.setMarker = function(marker)
{
    this.marker = marker;
}

pageHandler.setMarkerParameter = function(name, value)
{
    if (typeof this.marker != "object")
    {
        this.marker = {};
    }

    this.marker[name] = value;
}

pageHandler.getMarkerParameter = function(name)
{
    if (typeof this.marker == "object")
    {
        return this.marker[name];
    }

    return null;
}

/**
 * Accessibility stuff
 */

function accessiblePopup(elt, width, height)
{
    if (!width)
    {
        width = screen.width;
    }

    if (!height)
    {
        height = screen.height;
    }

    var left = Math.floor((screen.width - width) / 2);
    var top = Math.floor((screen.height - height) / 2);
    var popupWindow = window.open(
        elt.getAttribute('href'),
        "popup",
        "top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + ", menubar=yes, toolbar=yes, resizable=yes, scrollbars=yes"
    );

    popupWindow.focus();

    return false;
}

function accessiblePrint(elt)
{
    if (window.print)
    {
        window.print();
    }
    else if (elt)
    {
        window.location.href = elt.getAttribute('href');
    }

    if (elt)
    {
        return false;
    }
}

function accessibleAddToFavorite(elt)
{
    if (window.sidebar && window.sidebar.addPanel)
    {
        window.sidebar.addPanel(document.title, document.location.href, '');
    }
    else if (document.all && window.external)
    {
        window.external.AddFavorite(document.location.href, document.title);
    }
    else if (elt)
    {
        window.location.href = elt.getAttribute('href');
    }

    if (elt)
    {
        return false;
    }
}


/**
 * @author intbonjf 2007-05-29
 * Use this function to register a function to be executed when the page has
 * loaded.
 * This works on most of the recent JavaScript-enabled browsers, from Firefox2
 * to... IE5 for Mac :)
 */
function addLoadListener(func)
{
	if (window.addEventListener)
	{
	  window.addEventListener("load", func, false);
	}
	else if (document.addEventListener)
	{
	  document.addEventListener("load", func, false);
	}
	else if (window.attachEvent)
	{
	  window.attachEvent("onload", func);
	}
	else if (typeof window.onload != "function")
	{
	  window.onload = func;
	}
	else
	{
	  var oldonload = window.onload;
	  window.onload = function() {
	     oldonload();
	     func();
	  };
	}
}




/*********** SPECIFIC TO EVOLON PROJECT ********************/

/* Ajout au favoris */
function addToFavorite(anchor) {
	var siteURL = anchor.getAttribute('href');
	var siteNOM = anchor.getAttribute('title');
	
	if (window.external) {
		/* Internet Explorer 4+, et ses dérivés (Crazy Browser, Avent Browser ...) */
		window.external.AddFavorite(siteURL, siteNOM);
	} else if (window.sidebar) {
        /* Netscape 6+ ; Mozilla, FireFox et compagnie (K-Meleon ...) */
        window.sidebar.addPanel(siteNOM, siteURL,"");
     }
}

// appreview.js
// JavaScript Document

var flag = false;
var currentElem = null;
var currentElemDefaultSRC = null;

var currentInfo = 'appGeneric';
var defaultInfo = 'appGeneric';

/*function changeImg(elem,newInfo,newSRC)
{
    if(currentElem != null)
    {   if(currentElem.nextSibling.className == undefined){
            currentElem.src = currentElemDefaultSRC;
            currentElem.className = 'application-image-verysmall';
        }
        //For FF
        if(currentElem.nextSibling.className != undefined){
            currentElem.nextSibling.className = 'application-image-verysmall';    
        }    
    }

    document.getElementById(currentInfo).style.display = 'none';
    document.getElementById(newInfo).style.display = 'block';                      
    
    if(currentElem.nextSibling.className == undefined){
        currentElem = elem.firstChild;
        currentElemDefaultSRC = elem.firstChild.src;
        elem.firstChild.src = newSRC;
        elem.firstChild.className = 'framed';
    }
   alert(currentElem.nextSibling.className);
    if(currentElem.nextSibling.className != undefined){
        currentElem = elem.firstChild.nextSibling;
        currentElemDefaultSRC = elem.firstChild.nextSibling.src;
        elem.firstChild.nextSibling.src = newSRC;
        elem.firstChild.nextSibling.className = 'framed';
    }
       

    //For FF
    if(elem.firstChild.nextSibling.className != undefined){
        elem.firstChild.nextSibling.className = 'framed application-image-verysmall';
    }
    currentInfo = newInfo;
}


function restoreInfo() {
    if(flag == false && currentElem != null) {
        document.getElementById(currentInfo).style.display = 'none';
        document.getElementById(defaultInfo).style.display = 'block';                        
        currentElem.src = currentElemDefaultSRC;
        currentElem.className = '';
    
     //For FF
        if(currentElem.nextSibling.className != undefined)
            currentElem.nextSibling.className = ''; 
        currentInfo = defaultInfo;             
        }  
           
}
*/
function changeImg(elem,newInfo,newSRC)
{      
    if(navigator.appName == "Netscape"){ 
    	if(currentElem != null)
    	{
    		currentElem.src = currentElemDefaultSRC;
    		currentElem.className = 'application-image-verysmall';
    	}
    
    	document.getElementById(currentInfo).style.display = 'none';
    	document.getElementById(newInfo).style.display = 'block';
    	
    	currentElem = elem.firstChild.nextSibling;
    	currentElemDefaultSRC = elem.firstChild.nextSibling.src;
    
    	
    	elem.firstChild.nextSibling.src = newSRC;
    
    	//elem.firstChild.className = 'application-image-verysmall';
    	elem.firstChild.nextSibling.className = 'framed application-image-verysmall';
    	
	currentInfo = newInfo;
    }
    else{
        if(currentElem != null)
    	{
    		currentElem.src = currentElemDefaultSRC;
    		currentElem.className = 'application-image-verysmall';
    	}
    	
    	document.getElementById(currentInfo).style.display = 'none';
    	document.getElementById(newInfo).style.display = 'block';
    
    	currentElem = elem.firstChild;
    	currentElemDefaultSRC = elem.firstChild.src;
    	
    	elem.firstChild.src = newSRC;
    	//elem.firstChild.className = 'application-image-verysmall';
    	elem.firstChild.className = 'framed application-image-verysmall';
    	
    	currentInfo = newInfo;
    }
}

function restoreInfo()
{
	if(flag == false && currentElem != null)
	{
		document.getElementById(currentInfo).style.display = 'none';
		document.getElementById(defaultInfo).style.display = 'block';
		
		currentElem.src = currentElemDefaultSRC;
		currentElem.className = 'application-image-verysmall';
		
		currentInfo = defaultInfo;
	}
}

function setFlag(newFlag) {
	flag = newFlag;
}



//flashobject.js
/*
 * FlashObject embed
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.1.1 - 05-17-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 + '" id="' + this.id + '" align="' + this.align + '"';
        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 + '" name="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        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; }
}

function change_langue(url){
	document.formlogin.action = url.value;
	document.formlogin.submit();
}







//KEYBENENIT JS


// JavaScript Document
function showInfo(divID) {
	if(document.getElementById) {
		document.getElementById(divID).style.display = 'block';
	}
}
function hideInfo(divID) {
	if(document.getElementById) {
		document.getElementById(divID).style.display = 'none';
	}
}

// JavaScript Document
var currentLi = null;
var currentKeyInfo = null;
	
function showKeyBenefitInfo(elem,divID) {

	if(document.getElementById) {
		if(elem != currentLi) {
			//var newKeyInfo = document.getElementById(divID);
			if(currentLi != null) {
				currentLi.parentNode.className = '';
			}
			elem.parentNode.className = 'current';
			currentLi = elem;
			
			if(currentKeyInfo != null) {
				currentKeyInfo.style.display = 'none';
			}
			var newKeyInfo = document.getElementById(divID);
			newKeyInfo.style.display = 'block';
			currentKeyInfo = newKeyInfo;
			
		}
	}
}


function initKeyBenefits()
{
	document.getElementById('contentLocation').className = 'contentLocationKeyInfo';
}



// LINKS
function showLinksForCountry(nodeId)
{
	if(document.getElementById)
	{
		var node = document.getElementById(nodeId);
		if(node != currentLinksNode)
		{
			if(currentLinksNode != null)
			{
				currentLinksNode.style.display = 'none';
			}
			currentLinksNode = node;
			node.style.display = 'block';
		}
	}
}