$(document).ready(function(){
	
	$("body").bind('click', function(e){ 
		if(e.target.id == "espace_secure" || check_parent(e.target, "espace_secure")){
			$("#espace_secure").animate({width:'253px'}, 300);
		} 
		else {
			$("#espace_secure").animate({width:'53px'}, 300); } 
		}
	);
	
	
	$("label").inFieldLabels({fadeOpacity:0});

	
});


function connectExtranet(){
	$.post("/ajax/connexionExtranet.php", { ident: $("#ident").attr("value"), passw: $("#passw").attr("value") }, function(data){
	   if(data=='ok'){ 
	   		$('#connect').html('<div align="center"><b>CONNEXION R\311USSIE !</b><br/><br/>Vous allez \352tre automatiquement redirig\351(e).<br/><br/><em>Veuillez patienter...</em></div>');
			window.setTimeout('document.location.href="/Extranet";', 2000);
		   /*$('#ctn_fiche_refs').html('<a href="/Extranet"><img src="/images/new/ok_extranet.png" border="0" /></a>');
		   $(".fiche_refs").css('display', 'block');*/
	   }
	   else {
	   		$('#connect').html('<div style="color:red;" align="center"><b>ERREUR DE CONNEXION !</b><br/>L\'identifiant et/ou le mot de passe sont incorrects.<br/><br/><a href="/index.php" style="color:red;">Veuillez recommencez.</a></div>');
	   }
	 });
}

function disconnectExtranet(){
	$.post("/ajax/connexionExtranet.php", { logout: 1 }, function(data){
	   if(data=='disconnected'){
		  $('#connected').html('<div align="center"><b>D\311CONNEXION R\311USSIE !</b><br/><br/>Vous allez \352tre automatiquement redirig\351(e) vers l\'accueil.<br/><em>Veuillez patienter...</em></div>');
			window.setTimeout('document.location.href="/index.php";', 2000);
	   }
	 });
}

function check_parent(elem, parent_id) {
	if(!elem.parentNode) return false;
	if(elem.parentNode.id == parent_id) return true;
	return check_parent(elem.parentNode, parent_id);	
}


/*Fonction Visionneuse*/
function appelFlash(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
    }
    else {
	    return document[movieName];
    }
} 

function afficherPartage(cle){
	appelFlash("laVisionneuse_"+cle).afficherPartage();	
}

function afficherExport(cle){
	appelFlash("laVisionneuse_"+cle).afficherExport();	
}


