// JavaScript Document
function ShowHideSlide(bool){
	if(bool==false){
		$('#shortcuts').slideUp(600);
		return false;
	}
	$('#shortcuts').show();
	scrollToElement('shortcuts');
	return false;
}

function scrollToElement(ElemID, Dur) {
   var Elem=$('#'+ElemID);
   var duration=500;
   if(Dur) duration=Dur;
   var easing='swing';
   var target=$(Elem).offset().top;
      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {
      });
      return false;
}

var Lim=new Image();Lim.src=HostName+'/images/loader-black.gif';
var Tic=new Image();Tic.src=HostName+'/images/tick.gif';
var Err=new Image();Err.src=HostName+'/images/error.gif';

function overlay(){
$('body').css('position', 'relative');
$('body').append('<div id="overlay-black" class="overlay-black"></div>');

$('#overlay-black').css({
    'position': 'absolute', 
	'z-index': '5',
    'top': '1px',
	'left': '1px',
	'right': '1px',
	'bottom': '1px',
	'background': '#000 url('+HostName+'/images/facebook.gif) no-repeat 49% 310px',
	'opacity':.6
});
}

function unoverlay(){
	$('#overlay-black').remove();
}

function tick(message, custom){
	$('#Message-holder').html('');
	if(!custom) custom='<img src="http://www.belformation.com/images/ok.jpg" class="closeModalBox" style="cursor:pointer"/>';
	jQuery.fn.modalBox({ 
       directCall: { 
          data : '<p align="center">'+message+'<br><br>'+custom+'</p>'
       }
    });
	
	return;
	$('#Message-holder').css({
	'display': 'block',
    'color': 'black', 
    'background': 'url('+HostName+'/images/tick.gif) no-repeat 5px 50%'
	});
	$('#Message-holder').html(message);
}

function error(message){
	$('#Message-holder').css({
	'display': 'block',
    'color': 'red', 
    'background': '#fff url('+HostName+'/images/error.gif) no-repeat 5px 50%'
	});
	$('#Message-holder').html(message);
}

var Mess = new Array();
Mess[1] = "Votre compte est presque pr&ecirc;t. Un e-mail de v&eacute;rification vient de vous &ecirc;tre envoy&eacute;. Pour valider votre inscription, merci de v&eacute;rifier votre adresse e-mail<br />Pour cela, cliquez sur le lien dans l'e-mail de v&eacute;rification que nous venons de vous envoyer.<br /><br /><b style=\"color:red\">NB :</b> Si vous utilisez Hotmail et vous ne trouvez pas notre email, veuillez v&eacute;rifier la boite de courriels ind&eacute;sirables.";

Mess[2] = "Votre offre de formation a bien &eacute;t&eacute; ajout&eacute;e.";
Mess[3] = "Les informations ont &eacute;t&eacute; enregistr&eacute;es avec succ&egrave;s.";
Mess[4] = "Merci d'avoir deposer votre demande de formation, les experts de Belformation.com vont vous contactez prochainement apr&egrave;s avoir trouver la formation qui vous convient.";

function bluildAndSend(elem_hold, target_src, action, additional_parameters, intMessage, redirectToURL, customButtons){
	var dataString = "action="+action;
	if(additional_parameters)
		dataString += '&'+additional_parameters;
	$("div#"+elem_hold).find("input:text").each(function(){
		dataString += '&'+$(this).attr('id') +'='+ encodeURIComponent($(this).val());
	});
	$("div#"+elem_hold).find("input:password").each(function(){
		dataString += '&'+$(this).attr('id') +'='+ encodeURIComponent($(this).val());
	});
	$("div#"+elem_hold).find("input:hidden").each(function(){
		dataString += '&'+$(this).attr('id') +'='+ encodeURIComponent($(this).val());
	});
	$("div#"+elem_hold).find("select").each(function(){
		dataString += '&'+$(this).attr('id') +'='+ encodeURIComponent($(this).val());
	});
	$("div#"+elem_hold).find("textarea").each(function(){
		dataString += '&'+$(this).attr('id') +'='+ encodeURIComponent($(this).val());
	});
	$("div#"+elem_hold).find("input:radio:checked").each(function(){
		dataString += '&'+$(this).attr('id') +'='+ $(this).val();
	});
	
	overlay();
	
	//alert(dataString);
	
	$.ajax({
		type: "POST",
		url: HostName+target_src,
		data: dataString,
		success: function(d){
			if(d=='200'){
				unoverlay();
				if(parseInt(intMessage) > 0)
				{
				if(customButtons)
				tick(Mess[intMessage], customButtons);
				else
				tick(Mess[intMessage]);
				}
					else
					{
					tick("Vos informations ont &eacute;t&eacute; enregistr&eacute;es avec succ&egrave;s.");
					}
				try{
					$('.2bhidden').fadeOut(1000);
				}catch(e){}
				scrollToElement('Message-holder');
				if(redirectToURL){
					location.href=redirectToURL;
				}
				
				return false;
			}
			else
			{
				unoverlay();
				error(d);
				scrollToElement('Message-holder');
				return false;
			}
		}
	});
}



function SearchHeader(page){
	var secteur=$('select#secteur_search').val();
	var region=$('select#region_search').val();
	var type=$('select#type_search').val();
	var titre=encodeURIComponent($('input#titre_search').val());
	var prix_min='0';
	var prix_max='9000000000000';
	
	overlay();
	var Chaine_man = "/listormation.php?recherche=true&secteur="+secteur+"&region="+region+"&type="+type+"&titre="+titre+'&prix_min='+prix_min+'&prix_max='+prix_max;
	location.href=HostName+Chaine_man;
	return false;
	
	$('div#title').html('Vous êtes ici:&nbsp;<a href="http://www.belformation.com"> Accueil</a>&nbsp;&raquo;&nbsp;Recherchez une formation');
	var main = "";
	try{
	scrollToElement('main-1');
	main="main";
	}catch(e){
	scrollToElement('main-center');
	main="main-center";
	}
	
	
	if(parseInt(page) > 0) Chaine_man += "&page="+page;
	$.ajax({
		type: "POST",
		url: HostName+'/recherche-formation.php',
		data: Chaine_man,
		success: function(d){
			$("div#"+main).html(d);
			unoverlay();
		}
	});
}
function searchAgain(defaults){
	location.href='http://www.belformation.com/recherche.bel?'+defaults;
}
function addEmail(){
	var dataString='addEmail=true&email='+$('input#newsletterEmail').val();
	jQuery.fn.modalBox({ 
        directCall: { 
           source : 'http://www.belformation.com/newsletter.php?'+dataString
       }
    });
}

function printOcean(){
	var content=$('#printOceanContainer').html();
	$('body').append('<form id="printOceanContainerForm" name="printOceanContainerForm" action="http://www.belformation.com/inc/print.php" method="post" target="_blank" style="display:none"><textarea id="HTML" name="HTML">'+content+'</textarea></form>');
	setTimeout("$('#printOceanContainerForm').trigger('submit');", 500);
}

$(document).ready(function(){
	$('.di').hover(function(){$(this).stop(true).fadeTo("normal",1);});
	$('.di').mouseout(function(){$(this).stop(true).fadeTo("normal",.8);});
	
	$('.dii').hover(function(){$(this).stop(true).fadeTo("normal",1);});
	$('.dii').mouseout(function(){$(this).stop(true).fadeTo("normal",.6);});
	
	$('.id').hover(function(){$(this).stop(true).fadeTo("normal",.8);});
	$('.id').mouseout(function(){$(this).stop(true).fadeTo("normal",1);});
});

function reveal(cls){
	$(".sharer-"+cls).stop().fadeTo(300, 1);
	/*
	if($(".sharer-"+cls).css('left') != '26px') return;
	$(".sharer-"+cls).stop().animate({
    	opacity: 1,
     	left: '+=5'
  	}, 250);
	*/
}

function unreveal(cls){
	$(".sharer-"+cls).stop().fadeTo(300, 0);
	/*
	if($(".sharer-"+cls).css('left') == '31px') return;
	$(".sharer-"+cls).stop().animate({
    	opacity: 0,
     	left: '-=5'
  	}, 250);
	*/
}

