<!--
/* ---------------------------------------------
 * Created:		20.02.2007
 * Revision:		11.03.2007
 * Author:		Philippe Jos
 * Copyrights:		Philippe Jos
 * Email:		jos.philippe@wanadoo.fr
 * ---------------------------------------------
 */

function attachEventListener( node, eventType, func, useCapture  ) {
	if( node.addEventListener ) node.addEventListener( eventType, func, useCapture );
	else if( node.attachEvent ) node.attachEvent( "on" + eventType, func );
}


function getEventTarget(e){
	if(e.target) return( e.target );
	else if(e.srcElement) return( e.srcElement );
}


function getQueryStringArgs() {
	return( decodeURIComponent(window.location.search).slice(1) );
}		

function queryStringToObject() {
	var query, args, pairs, pos;

	query = new Object();							
	args = getQueryStringArgs();						
	pairs = args.split("&");						
	for(var i = 0; i < pairs.length; i++) {
		pos = pairs[i].indexOf('=');					
		if(pos == -1) continue;						
		query[ pairs[i].slice( 0, pos ) ] = pairs[i].slice( pos+1 );	
	}

	return(query);								
}

function trace(str){
	window.defaultStatus = str;
}

function isHttpProtocol(){
	return( window.location.protocol != "file:" );
}

function goToURL(url){ 
	window.location.href = url;
}

function goToEncodeURL(url){ 
	window.location.href = encodeURI(url);
}

function loadImage( imgPath ){
	var img = new Image();
	img.src = imgPath;

	return(img);
}

function createImage( src, w, h ){
	var img = document.createElement("img");
	img.src = src;
	img.alt = "";
	if(w)img.width = w;	
	if(h)img.height = h;
	return(img);
}

function createImageExt( src, w, h, id, cls, alt ){
	var img = createImage( src, w, h );
	if(id) img.id = id;
	if(cls) img.className = cls;
	if(alt){
		img.alt = alt;
		img.title = alt;
	}

	return(img);
}

function firstCharToUpperCase( str ){
	return( str.charAt(0).toUpperCase() + str.slice(1) );
}

function removeCommentText( node ){
	var child, name, len;

	len = node.childNodes.length;
	for( var i=len-1; i>= 0; i-- ){					
		child = node.childNodes[i];
		name = child.nodeName;
		if(name == "#text" || name == "#comment")
			node.removeChild( node.childNodes[i] );   	
	}
}


function changeId( oldId, newId ){
	document.getElementById( oldId ).id= newId;
}


function appendNewDiv( dest, newId, cls ){
	var div = document.createElement("div");
	if(newId) div.id = newId;
	if(cls) div.className = cls;

	if(dest){
		if(typeof dest == "string") document.getElementById( dest ).appendChild( div );
		else if(typeof dest == "object") dest.appendChild( div );
	}
	return( div );
}


function appendNewTextBlock( dest, newId, cls, text ){
	var p = document.createElement("p");
	if(newId) p.id = newId;
	if(cls) p.className = cls;
	
	if(text == "&nbsp;" || text == "" ) p.innerHTML = "&nbsp;"; 
	else p.appendChild( document.createTextNode( text ) );

	if(dest){
		if(typeof dest == "string") document.getElementById( dest ).appendChild( p );
		else if(typeof dest == "object") dest.appendChild( p );
	}
	return( p );
}

function appendNewListItem( dest, cls, text ){
	var li = document.createElement("li");
	if(cls) li.className = cls;
	if(text) li.appendChild( document.createTextNode( text ) );

	if(dest){
		if(typeof dest == "string") document.getElementById( dest ).appendChild( li );
		else if(typeof dest == "object") dest.appendChild( li );
	}

	return( li );
}

function appendNewLink( dest, link, text ){
	var a = document.createElement("a");
	a.href = link;
	if(text) a.appendChild( document.createTextNode( text ) );

	if(dest){
		if(typeof dest == "string") document.getElementById( dest ).appendChild( a );
		else if(typeof dest == "object") dest.appendChild( a );
	}

	return( a );
}

function setBtnImgSrc( img, src ) {
	try{ 
		img.src="image/button/" + src;
	}catch(exp){}
}

function setTemplateIds(){
	changeId( "Header" , "eHeader" );
	changeId( "Content" , "eContent" );
	changeId( "Footer" , "eFooter" );
}

function appendMenuNavigation(){
	var menuNav = new MenuSpecification( "eNavigation", "xml/navigation.xml", "image/navigation/", 155, 21, "10px 0 0 0" );

	MenuFact.Generate( menuNav );
}