/****************************************************************************************/
/**************************** Survol IE >> afficher le sous menu  ***********************/
/***************************************************************************************/	
sfHover = function() {
	
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			this.style.zIndex = "+999";
			var formNotif = '';
			if( formNotif = document.getElementById("form_notif_settings") )
			{
				lists = formNotif.getElementsByTagName("select")
				for (var j=0; j<lists.length; j++) {
					lists[j].style.display = 'none';
				}
			}
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			var formNotif = '';
			if( formNotif = document.getElementById("form_notif_settings") )
			{
				lists = formNotif.getElementsByTagName("select")
				for (var j=0; j<lists.length; j++) {
					lists[j].style.display = 'block';
				}
			}
		}
	}
}
$.fn.search = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};

function mycarousel_initCallback(carousel) {
    jQuery('.pagination a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        alert('hello')
        return false;
    });
}

$(document).ready(function(){
    //Affichage bloc access rapide
    
    if ( $("#bloc_acces_rapide").length )
    {
        document.getElementById('bloc_acces_rapide').style.display="block";
    }

	// gestion du bloc de connexion
	
	$("#general #bandeau .identification input").focus(function() { $('#general #bandeau .identification').addClass('open');});
	if ( $("#identifiant_header").length )
   	{$("#identifiant_header").search();}
   	if ( $("#recherche_barre_navig").length )
	{$("#recherche_barre_navig").search();}
	if ( $("#date_begin").length )
	{$("#date_begin").search();}
	if ( $("#date_end").length )
	{$("#date_end").search();}
	if ( $("#recherche_full").length )
	{if ( document.getElementById('recherche_full').value ==document.getElementById('recherche_full_default').value){$("#recherche_full").search();}}
	$('#onglet').click(function() {});
 	$('#onglet').tabs();
 	if ( $("div.table_matiere").length )
 	{ $("div.table_matiere div").hide();$('div.table_matiere a').click(function() {var target =$(this).attr('href');$(target).toggle();return false;});}
 	
	$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional['fr']));
	$("#date_end").datepicker({showOn: 'both', buttonImage: '/extension/smiledesign/design/coe_public/images/content/ico_date.png', buttonImageOnly: true});
	$("#date_begin").datepicker({showOn: 'button', buttonImage: '/extension/smiledesign/design/coe_public/images/content/ico_date.png', buttonImageOnly: true});
 });

if (window.attachEvent) window.attachEvent("onload", sfHover);

function afficheDiv(id, count){
	for (var i=0; i<count; i++) {
		if(i==id){
			document.getElementById('li_'+i).className="encour";
			document.getElementById('div_'+i).style.display="block";
		}else{
			document.getElementById('li_'+i).className="";
			document.getElementById('div_'+i).style.display="none";
		}
	}
}

function clickAccesRapide(id, count, my_module, flash_onglet, nb_continent) {
	afficheDiv(id,count);
	if ( id == flash_onglet )
	{
		afficheListePays( flash_onglet, '-1', nb_continent );	
		document.getElementById('div_'+flash_onglet+'_flash').style.display="block";
	}
	$.ajax({ url: my_module });
}

function afficheListePays( flash_onglet, id, count ) {
	document.getElementById('div_'+flash_onglet+'_flash').style.display="none";
	for (var i=0; i<count; i++) {
		if(i!=id){
			document.getElementById('div_'+flash_onglet+'_flash_'+i).style.display="none";
		}
	}
	if (id!=-1)
	{	
		document.getElementById('div_'+flash_onglet+'_flash_'+id).style.display="block";
	}
}
function insertMedia()
{
    for( var k = 0, l = arguments.length; k < l; k++ )
    {
        document.write( arguments[k] );
    }
}

function selectAll(nbTotal, id, etat) {
    for(i=0;i< nbTotal;i++) {
        if ( $('#'+id+'_'+i).length )
        {
	        document.getElementById( id+'_'+i ).checked = etat;
	        var j = 0;
	        while( document.getElementById( id+'_'+i+'_'+j ) ) {
	        	document.getElementById( id+'_'+i+'_'+j ).checked = etat;
	        	j++;
	        }
        }
    }
}

