function fnOpenWindow(url,parameters)
{
	parameters=parameters.replace(/\s+/g,'');

	var aParameters=parameters.split(',');
	var data=new Array();
	for (var i=0;i<aParameters.length;i++) {
		var pr=aParameters[i];
		var key = pr.substr(0,pr.indexOf('='));
		var value=pr.substr(pr.indexOf('=')+1);
		data[key]=value;
	}

	if ( (data['hposition'])&&(data['width'])&&(data['hposition']!='system') )
	{
		var posX=null;
		if (data['hposition']=='left')
		{
			posX=0;
		}
		if ( (window.screen)&&(window.screen.availWidth) )
		{
			if (data['hposition']=='center')
				posX=(window.screen.availWidth-data['width'])/2;
			if (data['hposition']=='right')
				posX=window.screen.availWidth-data['width'];
		}

		if (posX!=null)
			parameters+=",left="+parseInt(posX);
	}

	if ( (data['vposition'])&&(data['height'])&&(data['vposition']!='system') )
	{
		var posY=null;
		if (data['vposition']=='top')
		{
			posY=0;
		}
		if ( (window.screen)&&(window.screen.availHeight) )
		{
			if (data['vposition']=='center')
				posY=(window.screen.availHeight-data['height'])/2;
			if (data['vposition']=='bottom')
				posY=window.screen.availHeight-data['height'];
		}

		if (posY!=null)
			parameters+=",top="+parseInt(posY);
	}


	var oWnd=window.open(url,'',parameters);
	oWnd.focus();
}


function addClass(obj,newClass) {
	if(!obj.className.match(new RegExp(newClass)))
		obj.className+=(obj.className.length>0? " ": "") + newClass;
}
	
function removeClass(obj,oldClass) {
	obj.className=obj.className.replace(new RegExp("( ?|^)"+oldClass+"\\b"), "");
}

function graphic() {
	var h2Collection = document.getElementsByTagName('h2');
	for (var i = 0; i < h2Collection.length; i++) {
		h2Collection[i].appendChild(document.createElement('span'));
	}
}

/* IE fixes
-------------------- */
function testStyleSet() {
	
	var b = document.getElementsByTagName('body')[0];
	if (!b.currentStyle) return;
	ieTester = eval('document.getElementsByTagName("body")[0].currentStyle.position');

	if (ieTester == 'relative') {
		return true;
	}
	else {return false}
	
}


function ieGraphic() {
	
	
	if(!testStyleSet()) return;
	
	var ulCollection = document.getElementsByTagName('ul');
	for (var i = 0; i < ulCollection.length; i++) {
		if(ulCollection[i].getElementsByTagName('li')[0]){
			addClass(ulCollection[i].getElementsByTagName('li')[0],'first-child');
		
			
			var allliCollection = ulCollection[i].getElementsByTagName('li');
			var liCollection = new Array();
			var k = 0;
			for (var j = 0; j < allliCollection.length; j++) {
				if(allliCollection[j].parentNode == ulCollection[i]) {
					liCollection[k] = allliCollection[j];
					k++;
				}
			}			
			for (var j = 0; j < liCollection.length; j++) {
				if(j>0) {
					addClass(liCollection[j],'piped');
				}
				if(j == (liCollection.length - 1)) {
					addClass(liCollection[j],'last-child');
				}
				liCollection[j].onmouseover = function() {
					addClass(this,'hover');
				}
				liCollection[j].onmouseout = function() {
					removeClass(this,'hover');
				}
			}
			
		}
	}
	var tableCollection = document.getElementsByTagName('table');
	for (var i = 0; i < tableCollection.length; i++) {
		if (tableCollection[i].getElementsByTagName('tbody')[0]) {
			var trCollection = tableCollection[i].getElementsByTagName('tbody')[0].getElementsByTagName('tr');
		}
		else {
			var trCollection = tableCollection[i].getElementsByTagName('tr');
		}
		if(trCollection[0])
			addClass(trCollection[0],'first-child');
		
	}
	var trCollection = document.getElementsByTagName('tr');
	for (var i = 0; i < trCollection.length; i++) {
		var tdCollection = trCollection[i].getElementsByTagName('td');
		if(tdCollection[0])
			addClass(tdCollection[0],'first-child');
		var thCollection = trCollection[i].getElementsByTagName('th');
		if(thCollection[0])
			addClass(thCollection[0],'first-child');		
	}	
	var btnCollection = document.getElementsByTagName('button');
	for (var i = 0; i < btnCollection.length; i++) {
		btnCollection[i].onmouseover = function () {
			if(this.id!='site-search-submit')
			addClass(this,'hover');
		}
		btnCollection[i].onmouseout = function () {
			if(this.id!='site-search-submit')
			removeClass(this,'hover');
		}
	}
	var inpCollection = document.getElementsByTagName('input');
	for (var i = 0; i < inpCollection.length; i++) {
		if(inpCollection[i].type=='submit') {
			inpCollection[i].onmouseover = function () {
				addClass(this,'hover');
			}
			inpCollection[i].onmouseout = function () {
				removeClass(this,'hover');
			}
		}
	}
}

/* Target blank
-------------------- */
function setExternals() {
	var aCollection = document.getElementsByTagName('a');
	for(var i=0; i<aCollection.length; i++) {
		switch (aCollection[i].rel) {
			case "external" :
			case "bookmark" :
				aCollection[i].onclick = function(evt) {
					if ((evt)&&(evt.ctrlKey))
						return;
					window.open(this.href);
					return false;
				}
			break;
		}
	}
}

/* Init
-------------------- */
var init = function() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if(!document.getElementsByTagName)
		return;
		graphic();
		setExternals();
	/*@cc_on @*/
	/*@if (@_win32) {
		ieGraphic();
	}
	@elif (!@_win32) {
		ieMacMess();
	}
	/*@end @*/
}

function ieMacMess(){
	var iealert = document.createElement('div');
	iealert.setAttribute('class','ie-mac');
	var ietext = 'Internet Explorer mac users / Utilisateurs Internet Explorer Mac<br />Please upgrade your browser / Votre navigateur n\'est plus &agrave; jour<br /><a href="http://www.microsoft.com/mac/products/internetexplorer/internetexplorer.aspx?pid=internetexplorer">http://www.microsoft.com/mac/products/internetexplorer/internetexplorer.aspx?pid=internetexplorer</a>';
	document.getElementsByTagName('body')[0].appendChild(iealert);
	iealert.innerHTML = ietext;
}

window.onload = init;
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, null);
}
else {
	/*@cc_on @*/
	/*@if (@_win32)
		document.write("<script defer src='/elements/js/ie_init.js' type='text/javascript'><"+"/script>");
	/*@end @*/	
}