function resetTarget(id, target) {
	var TRAD = window.trad_page.document;
	TRAD.getElementById(id).target = target;
}

function setBackAndSubmit() {
	document.trad_form.back_to_parent.value=1;
	checkFrameValue();
	document.trad_form.submit();
}

function saveAndRedirect(rep, file) {
	document.trad_form.to_rep.value=rep;
	document.trad_form.to_file.value=file;
	checkFrameValue();
	document.trad_form.submit();
}

function checkFrameValue() {
	if ( document.getElementById('trad_frame') != null ) {
		var frameSrc = document.getElementById('trad_frame').src;
		if ( frameSrc.indexOf('trad_rollover') != '-1' ) {
			window.trad_frame.tinyMCE.triggerSave();
			var objTextarea = window.trad_frame.document.getElementById('rollover').value;
			document.trad_form.ROLLOVER_CONTENT.value=objTextarea;
		}
	}
	return true;
}

function setFlashTrad(fieldName, fieldEncodedValue) {
	window.open('trad_flash.php?field='+fieldName+'&value='+fieldEncodedValue, '', 'width=500,height=400');
}

function isRealBrowser() {
	// Mozilla, netscape, etc...
	if (document.implementation && document.implementation.createDocument){
		return true;
	}
	// IE....
	else {
		return false;
	}
}

function checkSaved(dest, mess) {
	if ( document.trad_form.modified.value == 1 ) {
		if ( confirm(mess) ) {
			document.trad_form.dest.value=dest;
			document.trad_form.submit();
		}
		else {
			setTimeout("window.location.href='"+dest+"'", 50);
		}
	}
	else {
		setTimeout("window.location.href='"+dest+"'", 50);
	}
}

function setItemDisable(obj, objLink) {
	if ( obj.value == '' || obj.value == '0' ) {
		obj.value = '2';
		objLink.className = 'disabled';
	}
	else {
		obj.value = '0';
		objLink.className = 'enabled';
	}
	document.trad_form.submit();
	//document.trad_form.trad_submit.className='submit modified';
	//document.trad_form.modified.value=1;
}
function setTradItemValue(obj) {
	document.trad_form.trad_item.value=obj.value;
	document.trad_form.trad_item.focus();
	document.trad_form.from_name.value=obj.name;
	document.trad_form.trad_button.disabled=0;
}
function setFromValue() {
	eval("document.trad_form."+document.trad_form.from_name.value+".value=document.trad_form.trad_item.value;");
	eval("document.trad_form.h_"+document.trad_form.from_name.value+".value=document.trad_form.trad_item.value;");
	document.trad_form.trad_item.value='';
	document.trad_form.from_name.value='';
	document.trad_form.trad_button.disabled=1;
	document.trad_form.trad_submit.className='submit modified';
	document.trad_form.modified.value=1;
}

function tradPage(rep, htm_file) {
	var re = /\.htm/i;
	htm_file=htm_file.replace(re, '');
	checkSaved('trad_page.php?rep='+rep+'&file='+htm_file);
}

function modUrl(url, menu, level) {
	checkSaved('mod_url.php?url='+url+'&menu='+menu+'&level='+level);
}

function setUrlChanged() {
	document.trad_form.trad_submit.className='submit modified';
	document.trad_form.modified.value=1;
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function createXMLDoc(xmlFile) {
	if (isRealBrowser()){
		var myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", xmlFile+"?ms=" + Math.random(), false);
		myXMLHTTPRequest.setRequestHeader("Cache-Control","no-cache");
		myXMLHTTPRequest.send(null);
		xmlDoc = myXMLHTTPRequest.responseXML;
	}
	else {
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
		xmlDoc.async="false";
		xmlDoc.load(xmlFile+'?'+Math.random());
	}
	return xmlDoc;
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(url, affTool, functionCall) {
	if ( typeof(affTool) == 'undefined' ) affTool = false;
	else affTool = affTool;
	if ( typeof(functionCall) == 'undefined' ) functionCall = false;
	else functionCall = functionCall;
    http.onreadystatechange = function() {
    	if(http.readyState == 4){
    		divUnload();
	        var response = http.responseText;
			if ( affTool ) {
				hideSelect();
				var divAjax = document.getElementById('ajax');
				divAjax.innerHTML = response;
				if ( document.getElementById('output') != null ) {
	    			var divOutput = document.getElementById('output');
	    		}
	    		else if ( document.getElementById('output2') != null ) {
	    			var divOutput = document.getElementById('output2');
	    		}
				var divContainer = document.getElementById('container');
				divOutput.style.display='block';
				if ( divContainer.offsetHeight > divOutput.offsetHeight ) {
					divOutput.style.height = (divContainer.offsetHeight+5)+'px';
				}
				if ( isRealBrowser() && divAjax.offsetHeight > divOutput.offsetHeight ) {
					divOutput.style.height = (divAjax.offsetHeight+100)+'px';
				}
				else if ( isRealBrowser() && divOutput.offsetHeight > divContainer.offsetHeight ) {
					divContainer.style.height = (divOutput.offsetHeight+50)+'px';
					if ( divAjax.offsetHeight > divOutput.offsetHeight ) {
						divOutput.style.height = (divAjax.offsetHeight+100)+'px';
					}
	    		}
	    		window.scrollTo(0,0);
	    		
	    	}
	        
	        http.onreadystatechange = function(){};
	        http = null;
	        http = createRequestObject();
	        
	        
	        if ( functionCall ) {
	        	for ( var i = 0 ; i < functionCall.length ; i++ ) {
	        		var call = functionCall[i][0]+"("+functionCall[i][1]+");";
	        		setTimeout(call, 200);
	        	}
	        }
	        
	    }
    }
    http.open('get', url, true);
    http.send(null);
}

function sndReq2(url, functionCall) {
	var domWin = $(window);
	var divOutput = $("div[id=output]");
	var divAjax = divOutput.find("div[id=ajax]");
	$("select").hide();
	divAjax.hide();
	divOutput.height(domWin.height()); 
	divOutput.width(domWin.width());
	divOutput.append("<div id='loading2'>loading</div>");
	divOutput.fadeIn(400);
	window.scrollTo(0,0);
	$.ajax({
		type: 'GET',
		url: url,
		dataType: 'html',
		success: function(html){
			$("div[id=loading2]").remove();
			divAjax.html(html);
			divAjax.slideDown(200);
			appendFunction(functionCall);
		}
	});
	return false;
}

function appendFunction(functionCall) {
	if ( functionCall ) {
    	for ( var i = 0 ; i < functionCall.length ; i++ ) {
    		var call = functionCall[i][0]+"("+functionCall[i][1]+");";
    		setTimeout(call, 200);
    	}
    }
}

function formClose2() {
	$("div[id=ajax]").slideUp(200,function(){
		$("div[id=output]").fadeOut(200);
		$("select").show();
	});
	window.scrollTo(0,0);
}

function hideSelect() {
	var selects = document.getElementsByTagName('select');
	for ( var i = 0 ; i < selects.length ; i++ ) {
		selects[i].style.display='none';
	}
}

function loadTinyMCE(lng,options) {
	if ( typeof(tinyMCELoaded) == 'undefined' ) {
		document.body.appendChild(domEl('script','',{'id':'tmce','type':'text/javascript','src':'../js-scripts/tiny_mce/tiny_mce.js?'+Math.random()}));
	}
	waitForMCE(lng,options);
}

function waitForMCE(lng,options) {
	if ( typeof(lng) == 'undefined' ) var lng = 'gb';
	if ( typeof(tinyMCELoaded) == 'undefined' ) {
		setTimeout("waitForMCE('"+lng+"','"+options+"')",200);
	}
	else {
		if ( typeof(tinyMCEAdvancedLoaded) == 'undefined' ) {
			initTinyMCE(lng,options);
		}
		else {
			launchTinyMCE();
		}
	}
}

function initTinyMCE(lng,options) {
	tinyMCE = new TinyMCE();
	var arrInit = { 
    	mode : "textareas",
    	editor_selector : "editor",
		theme : "advanced", 
		plugins : "advlink",
		language : lng, 
		content_css : "../css/editor.css?"+Math.random(),
		relative_urls : true,
		inline_styles : true,
		submit_patch : false
    };
    tinyMCE.init(arrInit);
    if ( typeof(options) != 'undefined' ) {
    	var arrOptions = options.split(';');
    	var newOption;
    	var arrNewOptions;
    	var key;
    	var value;
    	for ( var i = 0 ; i < arrOptions.length ; i++ ) {
    		newOption = arrOptions[i].split(':');
    		key = newOption[0];
    		value = newOption[1];
    		tinyMCE.defParam(key,value);
    	}
    }
    waitForMCEAdvancedTheme();
}

function waitForMCEAdvancedTheme() {
	if ( typeof(tinyMCEAdvancedLoaded) == 'undefined' ) {
		setTimeout("waitForMCEAdvancedTheme()",200);
	}
	else {
		launchTinyMCE();
	}
}

function launchTinyMCE() {
	tinyMCE.onLoad();
}

function urlInDiv(url, divId, functionCall) {
	if ( typeof(functionCall) == 'undefined' ) functionCall = false;
	else functionCall = functionCall;
	if ( typeof(url) == 'undefined' ) url = this.href;
	if ( typeof(divId) == 'undefined' ) divId = 'options';
    http.onreadystatechange = function() {
    	if(http.readyState == 4){
	        var response = http.responseText;
			document.getElementById(divId).innerHTML = response;
	        
	        http.onreadystatechange = function(){};
	        http = null;
	        http = createRequestObject();
	        
	        divUnload();
	        
	        if ( functionCall ) {
	        	for ( var i = 0 ; i < functionCall.length ; i++ ) {
	        		var call = functionCall[i][0]+"("+functionCall[i][1]+");";
	        		setTimeout(call, 200);
	        	}
	        }
	    }
    }
    http.open('get', url, true);
    http.send(null);
    return false;
}

/*
	domEl() function - painless DOM manipulation
	written by Pawel Knapik  //  pawel.saikko.com
*/
var domEl = function(e,c,a,p,x) {
    if (!c) c='';
    if(e||c) {
        //c=(typeof c=='string'||(typeof c=='object'&&!c.length))?[c]:c;
        if (typeof c=='string') {
			c = c.length ? [c] : [];
		} 
		else if (typeof c=='object' && !c.length) {
			c = [c];
		}
        e=(!e&&c.length==1)?document.createTextNode(c[0]):e;
        var n = (typeof e=='string')?document.createElement(e) :
        !(e&&e===c[0])?e.cloneNode(false):e.cloneNode(true);
        if(typeof e=='string' || e.nodeType!=3) {
            if ( typeof(c[0]) != 'undefined' ) {
            	c[0]===e?c[0]='':'';
        	}
            for(var i=0,j=c.length;i<j;i++) {
            	if ( typeof c[i]=='string' ) {
            		n.appendChild(document.createTextNode(c[i]));
            	}
            	else {
            		n.appendChild(c[i].cloneNode(true));
            	}
            }
            if(a){for (i in a) i=='class'?n.className=a[i]:n.setAttribute(i,a[i]);}
        }
    }
    if(!p) { return n; }
    p=(typeof p=='object'&&!p.length)?[p]:p;
    for(var k=(p.length-1);k>=0;k--) {
        if(x){while(p[k].firstChild)p[k].removeChild(p[k].firstChild);
            if(!e&&!c&&p[k].parentNode)p[k].parentNode.removeChild(p[k]);}
        if(n) p[k].appendChild(n.cloneNode(true));
    }
    return true;
}

/*
	getElementsByClass - algorithm by Dustin Diaz, shortened by Pawel Knapik
*/
function getElementsByClass(s,n,t) {
	var c=[], e=(n?n:document).getElementsByTagName(t?t:'*'),r=new RegExp("(^|\\s)"+s+"(\\s|$)");
	for (var i=0,j=e.length;i<j;i++) r.test(e[i].className)?c.push(e[i]):''; return c }
	
/*
	$() based on prototype.js dollar function idea, optimized by Pawel Knapik.
*/
function $(){var r=[],a=arguments;for(var i=0,j=a.length;i<j;i++){(typeof a[i]=='string')?(r.push(document.getElementById(a[i]))):(r.push(a[i]))}
return(r.length==1)?r[0]:r}



function getAncestorByTagName( node, tag ) {

    var ancestor = node.parentNode;
    if ( ancestor == null ) return null;
    if ( ancestor.nodeName == tag.toUpperCase() ) return ancestor;
    else return getAncestorByTagName(ancestor, tag);

} // end of 'getAncestorByTagName()'

function getPreviousSiblingByTagName( node, tag ) {

    var sibling = node.previousSibling;
    if ( sibling == null ) return null;
    if ( sibling.nodeName == tag.toUpperCase() ) return sibling;
    else return getPreviousSiblingByTagName(sibling, tag);

} // end of 'getPreviousSiblingByTagName()'


function getNextSiblingByTagName( node, tag ) {

    var sibling = node.nextSibling;
    if ( sibling == null ) return null;
    if ( sibling.nodeName == tag.toUpperCase() ) return sibling;
    else return getNextSiblingByTagName(sibling, tag);

} // end of 'getNextSiblingByTagName()'

function createXMLDoc(xmlFile) {
	if (isRealBrowser()){
		var myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", xmlFile+"?ms=" + Math.random(), false);
		myXMLHTTPRequest.send(null);
		xmlDoc = myXMLHTTPRequest.responseXML;
	}
	else {
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
		xmlDoc.async="false";
		xmlDoc.load(xmlFile+"?ms=" + Math.random());
	}
	return xmlDoc;
}

function loading(divId) {
	if ( typeof(divId) == 'undefined' ) {
		divId = 'content';
	}
	var selects = document.getElementById('content').getElementsByTagName('select');
	for ( var i = 0 ; i < selects.length ; i++ ) {
		selects[i].style.display='none';
	}
	var LOADING = document.getElementById(divId);
	var divLoading = domEl('div','',{'class':'loading-'+divId,'id':'loading'});
	divLoading.style.left=LOADING.offsetLeft+'px';
	divLoading.style.top=LOADING.offsetTop+'px';
	if ( divId == 'content' && isRealBrowser() ) {
		divLoading.style.width=(LOADING.offsetWidth - 2)+'px';
		divLoading.style.height=(LOADING.offsetHeight - 2)+'px';
	}
	else {
		divLoading.style.width=(LOADING.offsetWidth)+'px';
		divLoading.style.height=(LOADING.offsetHeight)+'px';
	}
	LOADING.parentNode.appendChild(divLoading);
}

function divUnload() {
	var divLoading = document.getElementById('loading');
    if ( divLoading != null ) {
    	divLoading.parentNode.removeChild(divLoading);
    	if ( divLoading.className != 'loading-view' ) {
		    var selects = document.getElementById('content').getElementsByTagName('select');
			for ( var i = 0 ; i < selects.length ; i++ ) {
				selects[i].style.display='block';
			}
		}
    }
}

function changeCountry(obj) {
	loading('content');
	var arrUri = document.location.href.split('?');
	document.location.href=arrUri[0]+'?chg-country='+obj.value;
}

function getJsDom(el) {
	var mw = window.open('','');
	for ( var i in el ) {
		mw.document.write(i+' : '+el[i]+'<br>');
	}
}

function isEmail(strSaisie) {
    var verif = /^[^@]+@(([\w\-]+\.){1,4}[a-zA-Z]{2,4}|(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5]))$/
    return ( verif.test(strSaisie) );
}

var arrTime = new Array();
function showMenu(id) {
	clearTimeout(arrTime[id]);
	document.getElementById(id).style.display='block';
}

function hideMenu(id) {
	arrTime[id] = setTimeout("hideUl('"+id+"')",150);
}

function hideUl(id) {
	document.getElementById(id).style.display='none';
}

function CreateBookmarkLink(url, title) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}

var subTime;
function showSub(id) {
	clearTimeout(subTime);
	document.getElementById(id).style.display='block';
	document.getElementById(id).parentNode.firstChild.className='hover';
}

function hideSub(id) {
	subTime = setTimeout('hideSub2(\''+id+'\')',50);
}

function hideSub2(id) {
	document.getElementById(id).style.display='none';
	document.getElementById(id).parentNode.firstChild.className='';
}

function criteriaOver() {
	this.style.backgroundColor='#EFEFEF';
	this.style.cursor='pointer';
}

function criteriaOut() {
	this.style.backgroundColor='transparent';
}

function selectorOver() {
	this.className += ' over';
}

function selectorOut() {
	this.className='selector';
}

function critGroupSelect() {
	$(this.parentNode.getElementsByTagName('div')[0].getElementsByTagName('li')).each(function(i){
		if ( this.className != 'section' && this.className != 'sub-section' && this.className != 'disabled' ) {
			criteriaSelect('',this);
		}
	});
	return false;
}

function criteriaSelect(e,obj) {
	clearTimeout(critTime);
	critTime = setTimeout("criteriaHideAll()",5000);
	if ( typeof(e) != 'string' ) {
		if (!e) var e = window.event;
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
	}
	if ( typeof(obj) == 'undefined' ) {
		obj = this;
	}
	var critInput = obj.getElementsByTagName('input')[0];
	critInput.checked=!critInput.checked;
	var critInputs = obj.parentNode.getElementsByTagName('input');
	var critDisplay = obj.parentNode.parentNode.getElementsByTagName('strong')[0];
	var critHiddenText = obj.parentNode.parentNode.getElementsByTagName('input')[0];
	var arrNewDisplay = new Array();
	for ( var i = 0 ; i < critInputs.length ; i++ ) {
		if ( critInputs[i].checked ) {
			if ( typeof(critInputs[i].parentNode.textContent) != 'undefined' ) {
				arrNewDisplay[arrNewDisplay.length] = critInputs[i].parentNode.textContent;
			}
			else {
				arrNewDisplay[arrNewDisplay.length] = critInputs[i].parentNode.innerText;
			}
		}
	}
	if ( arrNewDisplay.length > 0 ) {
		critDisplay.innerHTML = arrNewDisplay.join(', ');
		critDisplay.style.backgroundColor='#FFFFFF';
		critHiddenText.value = arrNewDisplay.join(', ');
	}
	else {
		critDisplay.innerHTML = '--select--';
		critDisplay.style.backgroundColor='#EFEFEF';
		critHiddenText.value = '--select--';
	}
}

function textFocus() {
	this.style.backgroundColor='#FFFFFF';
}

function textBlur() {
	if ( this.value == '' ) {
		this.style.backgroundColor='#EFEFEF';
	}
	else {
		this.style.backgroundColor='#FFFFFF';
	}
}

var critTime;
function criteriaShow(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	clearTimeout(critTime);
	critTime = setTimeout("criteriaHideAll()",5000);
	var thisId = this.id;
	$(".selector").each(function(i){
		if ( this.id != thisId && this.getElementsByTagName('ul')[0].style.display == 'block' ) {
			this.getElementsByTagName('strong')[0].style.overflow='hidden';
			if ( isRealBrowser() ) {
				this.getElementsByTagName('strong')[0].style.height='15px';
			}
			$(this.getElementsByTagName('ul')[0]).slideUp(100);
		}
	});
	var list = this.getElementsByTagName('ul')[0];
	if ( list.style.display != 'block' ) {
		this.getElementsByTagName('strong')[0].style.overflow='visible';
		if ( isRealBrowser() ) {
			this.getElementsByTagName('strong')[0].style.height='auto !important';
		}
		this.getElementsByTagName('strong')[0].className='opened';
		//list.style.display='block';
		$(list).slideDown(100);
	}
	else {
		this.getElementsByTagName('strong')[0].style.overflow='hidden';
		if ( isRealBrowser() ) {
			this.getElementsByTagName('strong')[0].style.height='15px';
		}
		this.getElementsByTagName('strong')[0].className='';
		//list.style.display='none';
		$(list).slideUp(100);
	}
}

function criteriaHideAll() {
	$(".selector").each(function(i){
		if ( this.getElementsByTagName('ul')[0].style.display == 'block' ) {
			this.getElementsByTagName('strong')[0].style.overflow='hidden';
			if ( isRealBrowser() ) {
				this.getElementsByTagName('strong')[0].style.height='15px';
			}
			$(this.getElementsByTagName('ul')[0]).slideUp(100);
		}
	});
}

function criteriaHide() {
	var list = this.getElementsByTagName('ul')[0];
	if ( list.style.display == 'block' ) {
		this.getElementsByTagName('strong')[0].style.overflow='hidden';
		if ( isRealBrowser() ) {
			this.getElementsByTagName('strong')[0].style.height='15px';
		}
		list.style.display='none';
	}
}

function switchContent(obj,labelValue) {
	var clickedClassName = obj.className;
	if ( clickedClassName.indexOf('on') != '-1' ) {
		return false;
	}
	if ( clickedClassName.indexOf('ext') != '-1' ) {
		obj.className = 'ext-on';
		obj.parentNode.getElementsByTagName('a')[0].className = 'int-off';
		obj.parentNode.getElementsByTagName('label')[0].textContent = labelValue;
		obj.parentNode.getElementsByTagName('label')[0].innerText = labelValue;
		obj.parentNode.getElementsByTagName('input')[0].value = 'ext';
	}
	else {
		obj.className = 'int-on';
		obj.parentNode.getElementsByTagName('a')[1].className = 'ext-off';
		obj.parentNode.getElementsByTagName('label')[0].textContent = labelValue;
		obj.parentNode.getElementsByTagName('label')[0].innerText= labelValue;
		obj.parentNode.getElementsByTagName('input')[0].value = 'int';
	}
	setModified();
	return false;
}















































