<!--

// -------------------------------
// -- 		FONCTIONS GLOBALES
// -------------------------------
var versionMinor = parseFloat(navigator.appVersion); 
var versionMajor = parseInt(versionMinor); 
var IE = (document.all && !window.opera && versionMajor < 7)?true:false;
var IE7 = (navigator.userAgent.lastIndexOf("MSIE 7") > -1)?true:false;
var OP = (window.opera)?true:false;
var FF = (document.getElementById)?true:false;
var NS = (document.layers)?true:false;
// renvoie l'element DOM
function get_item(name,opener){
	if (IE){
		return (opener)?window.opener.document.all[name]:document.all[name];
	}else if (FF){
		return (opener)?window.opener.document.getElementById(name):document.getElementById(name);
	}else if(NS){
		return (opener)?window.opener.document.layers[name]:document.layers[name];
	}
}
function element_exist(nom){
	if (IE || OP){
		return (document.all[nom])?true:false;
	}else if (FF){
		return (document.getElementById(nom))?true:false;
	}else if(NS){
		return (document.layers[nom])?true:false;
	}
}
var element = null;
function get_display(name,opener){
	if(IE ||FF){
		return (opener == true)?window.opener.get_item(name).style.display:get_item(name).style.display;
	}else if(NS){ // NETSCAPE
		return (opener == true)?window.opener.get_item(name).display:get_item(name).display;
	}
}
function change_style(name,prop,value,opener){
	element = get_item(name,opener);
	if(typeof element != 'undefined')
	{
		element.style.setProperty(prop,value,'');
	}
}
function change_display(name,value,opener){
	change_style(name,'display',value,opener);
}
function reverse_display(nom,opener){
	var display = get_display(nom,opener);
	display = (display != 'block')?'block':'none';
	change_display(nom,display,opener);
}
function reverse_visibility(nom,opener){
	var element = get_item(nom);
	if(element)
	{
		var visibility = element.style.visibility;
		element.style.visibility = (visibility == 'hidden')?'visible':'hidden';
	}
}

function get_content(nom){
	if (FF){
		return document.getElementById(nom).innerHTML;
	}else if (document.all){
		return document.all[nom].innerHTML;
	}else if(NS){
		return document.layers[nom].innerHTML;
	}
}
function change_content(nom,valeur){
	if (FF){
		document.getElementById(nom).innerHTML = valeur;
	}else if (document.all){
		document.all[nom].innerHTML = valeur;
	}else if(NS){
		document.layers[nom].innerHTML = valeur;
	}
}
function change_property(name,property,value){
	get_item(name).property = value
}


/*
 * POPUP
 */
function popup(link,oWidth,oHeight)
{
	if(oWidth > screen.availWidth){oWidth = screen.availWidth;}
	if(oHeight > screen.availHeight){oHeight = screen.availHeight;}
	var PosX = (screen.availWidth-oWidth)/2;
	var PosY = (screen.availHeight-oHeight)/2;
	var params = "width="+oWidth+", height="+oHeight+", top=" + (PosY) + ",left=" + (PosX);
	params += ('toolbar=0,menubars=0,location=no,scrollbars=1,directories=0,statubar=0,resizable=0');
	window.open(link,'popuped',params);
}
function popup_listen(file)
{
	var oWidth = 320;
	var oHeight = 120;
	if(IE)
	{
		oHeight += 20;
	}
	if(oWidth > screen.width){oWidth = screen.width;}
	if(oHeight > screen.height){oHeight = screen.height;}
	var PosX = (screen.width-oWidth)/2;
	var PosY = (screen.height-oHeight)/2;
	var params = "width="+oWidth+", height="+oHeight+", top=" + (PosY) + ",left=" + (PosX);
	params += ('toolbar=0,menubars=0,location=no,scrollbars=1,directories=0,statubar=0,resizable=0');
	popup_mp3 = window.open('popup_player.php?file='+file,'popup_mp3',params);
	if (window.focus) {popup_mp3.focus()}
}
/*
 * POPUP DOWNLOAD
 */
function popup_download(dir,file,width,height,relative)
{
	if(width > screen.width){width = screen.width;}
	if(height > screen.height){height = screen.height;}
	var PosX = (screen.width-width)/2;
	var PosY = (screen.height-height)/2;
	
	var params = "width="+width+", height="+(height+40)+", top=" + (PosY) + ",left=" + (PosX);
	params += ('toolbar=0,menubars=0,location=no,scrollbars=1,directories=0,statubar=0,resizable=1');
	var file_pop = (relative == true)?'../':'';
	file_pop += 'popup.php';
	file_pop += '?dir='+dir+'&file='+file+'&width='+width+'&height='+height;
	window.open(file_pop,'popuped',params);
}

/*
 * XMLHTTPREQUEST
 */

var LIB_XHR = 'lib/xhr/';
var xhr = false;
try
{
	xhr = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
	try
	{
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}catch (E){
		xhr = false;
	}
}
if (!xhr && typeof XMLHttpRequest != 'undefined')
{
	try
	{
		xhr = new XMLHttpRequest();
	}catch (e){
		xhr = false;
	}
}

/*
 * CODES TOUCHES
 */
function getKey(ev) {
   var key=(window.event)?ev.keyCode:ev.which;
   return key;
  // var keyString = String.fromCharCode(key).toLowerCase();

}

function block_more_char(element_id,input,nb_char)
{
	if(input.value.length >= nb_char)
	{
		input.value = input.value.substring(0,nb_char);
		get_item(element_id).style.color = 'red';
	}
	else{
		get_item(element_id).style.color = '';
	}
	get_item(element_id).innerHTML = (nb_char-input.value.length)+' left ('+nb_char+' char max.)';
}
/********************************************************************************/
/*
/*							HEADER Advertising
/*
/********************************************************************************/
var current_ads = 0;
function change_header_ads()
{
	if(current_ads < js_ads.length-1)
	{
		current_ads ++;
	}
	else{
		current_ads = 0;
	}
	get_item('header_ads').href="index.php?ads_click="+js_ads[current_ads][0];
	get_item('header_ads').innerHTML=js_ads[current_ads][1];
}

/********************************************************************************/
/*
/*							SHOW
/*
/********************************************************************************/
/*
 * OFFWORLD : add a comment to a playlist
 */
function check_add_playlist_comment(form)
{
	var element = null;
	var message = '';
	if(form.elements['name'] && form.elements['name'].value == '' && form.elements['name'].value == '')
	{
		element = form.elements['name'];
		message = 'You have to specify your name';
	}

	else if(form.elements['comment'].value == '')
	{
		element = form.elements['comment'];
		message = 'You have to post a comment isn\'t ?';
	}
	if(message != '')
	{
		alert(message);
		element.focus();
		return false;
	}
	else
	{
		return true;
	}
}
/*
 * OFFWORLD : add a comment to a playlist
 */
function change_vote(mark,element_id)
{
	var dir_img = 'img/site/';
	var img = '';
	for(var i=0;i<5;i++)
	{
		if(mark > i)
		{
			img = 'poll_on';
		}
		else
		{
			img = 'poll_off';
		}
		document.getElementById('star_'+i+'_'+element_id).src = dir_img+img+'.gif';
	}
}

// PLAYER POPUP
function player_change_display(id,img_id)
{
	var element = get_item(id);
	var display = element.style.display;
	var height = 0;
	var img = '';
	if(display == '' || display == 'none')
	{
		img = 'less';
		display = 'block';
		height = 105;
	}
	else
	{
		img = 'plus';
		display = 'none';
		height = -105;
	}
	element.style.display = display;
	document.getElementById(img_id).src = '../img/site/player_'+img+'.gif';
	
	//window.resizeBy(0, height);
}
/********************************************************************************/
/*
/*							DISPLAY CONTENT
/*
/********************************************************************************/
function change_display_by_icon(element,element_id,content_more,content_less,display_special)
{
	element.className=(element.className=="icon_less")?"icon_more":"icon_less";
	if(content_more || content_less)
	{
		element.innerHTML=(element.className=="icon_less")?content_less:content_more;
	}
	if(!display_special)
	{
		display_special = 'block';
	}
	document.getElementById(element_id).style.display = ((element.className=="icon_more")?'none':display_special);
}
/********************************************************************************/
/*
/*							TOOLTIP
/*
/********************************************************************************/
var current_tooltip = null;
/**
 * Show a tooltip
 *
 * @param dom current_tooltip : (span, p,...)
 * @param string : content of the tooltip
 */
function show_tooltip(caller,content,content_title)
{
	var current_tooltip = get_item('tooltip');
	if(!current_tooltip)
	{
		var current_tooltip = document.createElement('div');
		current_tooltip.setAttribute('id','tooltip');
		document.body.appendChild(current_tooltip);
	}
	if(content_title)
	{
		content = '<h4 style="color:#601414">'+content_title+'</h4>'+'<p>'+content+'</p>';
	}else{
		content = '<p>'+content+'</p>';
	}
	current_tooltip.innerHTML = content;
	current_tooltip.style.visibility = 'visible';
	// append action to DOM
	caller.onmousemove = move_tooltip;

	caller.onmouseout = function()
	{
		current_tooltip.style.visibility="hidden";
	}
}
/**
 * Move an current_tooltip in document area
 */
var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var real_body = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
function move_tooltip(e){
	
	var curX=(!IE)?e.pageX : event.clientX+real_body.scrollLeft;
	var curY=(!IE)?e.pageY : event.clientY+real_body.scrollTop;
	
	//Find out how close the mouse is to the corner of the window
	var rightedge=IE&&!window.opera? real_body.clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
	var bottomedge=IE&&!window.opera? real_body.clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
	
	var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
	current_tooltip = get_item('tooltip');
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<current_tooltip.offsetWidth)
	//move the horizontal position of the menu to the left by it's width
	current_tooltip.style.left=ie? real_body.scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
	else if (curX<leftedge)
	current_tooltip.style.left="5px"
	else
	//position the horizontal position of the menu where the mouse is positioned
	current_tooltip.style.left=curX+offsetxpoint+"px"
	
	//same concept with the vertical position
	if (bottomedge<current_tooltip.offsetHeight)
	{
	current_tooltip.style.top=IE? real_body.scrollTop+event.clientY-current_tooltip.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-current_tooltip.offsetHeight-offsetypoint+"px"
	
	}else{
	current_tooltip.style.top=curY+offsetypoint+"px"
	}
}

/**************************************************/
/*				ADD & REMOVE EVENT
/**************************************************/
// addEvent et removeEvent
function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
	else{ obj["on"+type] = null; }
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
	else{ obj["on"+type] = null; }
}
function trim(str)
{
	return str.replace(/^\s*|\s*$/g, '');
}

/**************************************************/
/*					SCROLL
/**************************************************/
var scroll_timer;
var scroll_step = 5;
function scroll_init(parent, children, direction)
{
	scroll_stop();
	scroll_content(parent, children, direction);
}
function scroll_content(parent, children, direction) {

	Objet=document.getElementById(children);
    if(parseInt(Objet.style.top) + (scroll_step*direction)>0)  {
		clearTimeout(scroll_timer);
	}
	else if(parseInt(Objet.style.top) + (scroll_step*direction)<-(Objet.offsetHeight-document.getElementById(parent).offsetHeight)) {
		clearTimeout(scroll_timer);
	}
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (scroll_step*direction)) + "px";
	}
	scroll_timer = setTimeout("scroll_content('"+parent+"','"+children+"', " + direction + ");", 30);
}
function scroll_stop()
{
	if(scroll_timer)
		clearTimeout(scroll_timer);
	
}
/**************************************************/
/*					AUTOCOMPLETE
/**************************************************/

var cAutocomplete =
{
	sDescription : 'autcomplete class'
}

cAutocomplete.complete = function( hEvent )
{
	if( hEvent == null )
	{
		var hEvent = window.hEvent
	}
	var hElement = ( hEvent.srcElement ) ? hEvent.srcElement : hEvent.originalTarget
	var sAA = hElement.getAttribute( 'autocomplete' ).toString()
	if( sAA.indexOf( 'array:' ) >= 0 )
		hArr = eval( sAA.substring( 6 ) )
	else if(  sAA.indexOf( 'list:' ) >= 0 )
		hArr = sAA.substring( 5 ).split( '|' )

	if( hEvent.keyCode == 16 )  
		return;
		
	var sVal = hElement.value.toLowerCase()
	if( hEvent.keyCode == 8 )
		sVal = sVal.substring( 0, sVal.length - 1 )
	if( sVal.length < 1 )
		return;
	for( var nI = 0; nI < hArr.length; nI++ )
	{
		sMonth = hArr[ nI ]
		nIdx = sMonth.toLowerCase().indexOf( sVal, 0 )
		if( nIdx == 0 && sMonth.length > sVal.length )
		{
			hElement.value = hArr[ nI ]
			if( hElement.createTextRange )
			{
				hRange = hElement.createTextRange()
				hRange.findText( hArr[ nI ].substr( sVal.length ) )
				hRange.select()
			}
			else
			{
				hElement.setSelectionRange( sVal.length, sMonth.length )
			}
			return;
		}
	}
}

cAutocomplete.init = function()
{
	var nI = 0
	var aInputs = document.getElementsByTagName( 'INPUT' )
	for( var nI = 0; nI < aInputs.length; nI ++ )
	{
		if( aInputs[ nI ].type.toLowerCase() == 'text' )
		{
		 	var sLangAtt = aInputs[ nI ].getAttribute( 'autocomplete' )
			if( sLangAtt )
			{
					if( document.attachEvent ) 
					{
						aInputs[ nI ].attachEvent( 'onkeyup', cAutocomplete.complete )
					}
					else if( document.addEventListener )
					{
						aInputs[ nI ].addEventListener( 'keyup', cAutocomplete.complete, false )
					} 
			}
		}
	}
}


/* Display player options (rss, podcast, ...)*/
function show_player_option()
{
    player_ct();
    if(document.getElementById('player_options_ul'))
        document.getElementById('player_options_ul').style.display = 'block';
}
var player_option_timeout = null;
function hide_player_option(menu_id)
{
    player_ct();
    player_option_timeout = setTimeout("document.getElementById('player_options_ul').style.display = 'none'", 750);
}
function player_ct()
{
    if(player_option_timeout)
    {
        clearTimeout(player_option_timeout);
    }
}


var select_id = 0;
var select_timeout = 0;
function select_to_ul(div, select)
{
	select_id++;
	 
	// global container
	div.className = 'select_replacement';
	// new div 
	var div_container = document.createElement('div');
	div_container.id = 'select_replacement_'+select_id;
	div_container.className = 'select_replacement_container';
	// replacement select by ul
	var ul = document.createElement('ul');
	var li = null;
	for(var i = 0; i < select.options.length; i++)
	{
		li = document.createElement('li');
		li.index = i;
		li.innerHTML = select.options[i].innerHTML;
		if(i == select.selectedIndex)
		{
			li.className = 'selected';
		}	
		li.onclick = function()
		{
			select.selectedIndex = this.index;
			select.parentNode.submit();
		}
		ul.appendChild(li);
	}
	// span : selected
	var span = document.createElement('span');
	span.className = 'select_replacement_selected';
	span.innerHTML = select.options[select.selectedIndex].innerHTML;
	div_container.onmouseover = span.onmouseover = function()
	{
		clearTimeout(select_timeout);
		div_container.style.display = 'block';
	}
	div_container.onmouseout = span.onmouseout = function(div_container)
	{
		var div_container = get_item('select_replacement_'+select_id);
		select_timeout = setTimeout("get_item('select_replacement_'+select_id).style.display = 'none'", 500);
	}
	
	div.appendChild(span);
	div_container.appendChild(ul);
	div.appendChild(div_container);
	select.style.display = 'none';
}
-->