function loadsai(id)
{
    var _sai = 733;
    if(id == 2)
    {
        _sai = 734;
    }
    $.ajax({
        url: "/sai/sai"+_sai+".html",
        dataType: 'html',
        type: 'get',
        success: function(data){
            $('#UI_ajax').html('<div id="UI_sai" style="background:#fff;">'+data+'</div>');
            $('#UI_sai').modal({containerCss:{
                backgroundColor:"#000000",
                borderColor:"#000000",
                height:420,
                padding:10,
                width:610,
                zIndex:1200
            }});
        }
    });
};

function unloadvideoplayer()
{
    $('#JS_videoplayer_ajax').html('');
}

function loadvideoplayer()
{
    $('#JS_videoplayer_ajax').html('<iframe id="frameYoutube" width="640" height="360" src="http://www.youtube.com/embed/jmkqI4m1Ltk?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>');
    
    var _options = {containerCss: {
            backgroundColor:"#000000",
            borderColor:"#000000",
            height:430,
            padding:10,
            width:640,
            zIndex:1200
        },onShow: function (dialog) {
            $(this).find('simplemodal-close').click(function(){
                $.modal.close();
                unloadvideoplayer();
            });
        },onClose: function (dialog) {
            $.modal.close();
            unloadvideoplayer();
    }};

    $('#UI_videoplayer').modal(_options);
//    $("#UI_videoplayer").modal({});
};

this.vtip = function() {    
    this.xOffset = 15; // x distance from mouse
    this.yOffset = 15; // y distance from mouse       
    
    $(".vtip").hover(    
        function(e) {
            this.t = '<h4>'+$(this).children('span').text()+'</h4>'+$(this).next('.stooltip').html();
            //this.title = ''; 
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
            
            $('body').append( '<div id="vtip"><div class="area"><div class="content">' + this.t + '</div></div></div>' );

                        
            //$('#vtip #vtipArrow').attr("src", 'images/vtip_arrow.png');
            $('#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn('fast');
            
        },
        function() {
            //this.title = this.t;
            $("#vtip").fadeOut("fast").remove();
        }
    ).mousemove(
        function(e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
                         
            $("#vtip").css("top", this.top+"px").css("left", this.left+"px");
        }
    );            
    
};

//jQuery.noConflict();
jQuery(document).ready(function($){

	$("ul.menu li a").click(function() {
		$("ul.menu > li.active").removeClass("active"); 
		$(this).parents("li").addClass("active"); 
	});
	 
	 //
	 $("#licenceTT").css({display: "none"});
	 $('#licenceTTLink').click(function() {
		 $('#licence').toggle();
	 });
	 
	 // faq
	 $(".hide").css({display: "none"});
	 
	 $('.parent_hide').click(function() {
		 $(this).next().toggle('slow');
	 });
	 
	 $("ul#childrenCategories > li > a").click(function() {
		// on enlève la class active de la li la possédant
		$("ul#childrenCategories > li.active").removeClass("active"); 			
		// on ajoute la class active à la li parente cliquée
		$(this).parents("li").addClass("active"); 
	 });

	 // activation des boutons d'accès au formulaire de devis
	 $('button.devis').click(function(){
		 var action = $(this).attr('alt');
		 if(action == undefined){
			 action = '';
		 }
		 window.location = "/forms/devis"+action;
	 });

	 // activation des boutons d'accès au formulaire de devis
	 $('button.souscrire').click(function(){
		 window.location = "/twittcompta/forms/devis";
	 });

	 // activation des boutons d'accès au formulaire de candidature
	 $('button.candidate').click(function(){
		 window.location = "/forms/candidature";
	 });

	 // newsletter	 
	 $('form#FormNewsletter').submit(function(e){
			e.preventDefault();
			$('#msgNeswletter').hide();
			var email = $("#NewsletterEmail").attr('value');
			
			$.ajax({
				type: "POST",
				timeout: 7000,
				data: {email: email},
				url: '/newsletters/index',
				success: function(result) {
					if (result == 'Veuillez saisir une adresse email valide') {
						 setTimeout(function(){$('#msgNeswletter').html(result).fadeIn();},1000);
					 }
					 else if (result == 'Veuillez saisir votre email') {
						 setTimeout(function(){$('#msgNeswletter').html(result).fadeIn();},1000);
					 }
					 else if (result == 'Merci de vérifier votre saisie') {
						 setTimeout(function(){$('#msgNeswletter').html(result).fadeIn();},1000);
					 }
					 else {					 
						 setTimeout(function(){$('#msgNeswletter').html('Votre inscription a bien été prise en compte').fadeIn();},1000);
					 }	
				}
			})
		});
	 // pour la home
	 $('#UI_overview .home .offer').hover(function(){
		$(this).css("background-position", "left -200px");
	 }, function(){
		$(this).css("background-position", "left 0px");
	 });
	 
//	 // tooltip pour la home chacun sa ville
//	 vtip();
//	 $('#JS_compta').click(function()
//	 {
//	    $("#UI_compta").modal(
//		{
//		    overlayClose:true,
//		    opacity:70,
//		    minHeight:450,
//                    minWidth:820,
//		    zIndex: 5000
//		}
//		);
//	 });
//
//
//      
//
//          // tooltip pour la home chacun son métier
//	 vtip();
//	 $('#JS_metier').click(function()
//	 {
//	    $("#UI_metier").modal(
//		{
//		    overlayClose:true,
//		    opacity:70,
//		    minHeight:450,
//                    minWidth:820,
//		    zIndex: 5000
//		}
//		);
//	 });
//
//
//     // tooltip pour la home chacun son métier
//	 vtip();
//	 $('#JS_metier').click(function()
//	 {
//	    $("#UI_metier").modal(
//		{
//		    overlayClose:true,
//		    opacity:70,
//		    minHeight:450,
//                    minWidth:800
//		}
//		);
//	 });



/*
         // affichage contenu categories sur le hover
	 $('#UI_ssnav .rightMenu li').hover(function(){

		 $('#UI_ssnav .rightMenu li').removeClass('current');
		 $(this).addClass('current');
		 $('#UI_ssnav .panel').hide();

		 var n = $(this).parent().children("li").index(this);
		 $('#UI_ssnav .panel:eq('+n+')').fadeIn('fast');

         $('#UI_ssnav .panel:eq('+n+') .ssnav li').data('n', n);
 		 $('#UI_ssnav .panel:eq('+n+') .ssnav li').hover(function(){

			 $('#UI_ssnav .panel:eq('+$(this).data('n')+') .ssnav li').removeClass('current');
			 $(this).addClass('current');
			 $('#UI_ssnav .panel:eq('+$(this).data('n')+') .bloc').hide();
			 var p = $(this).parent().children("li").index(this);
			 $('#UI_ssnav .panel:eq('+$(this).data('n')+') .bloc:eq('+p+')').fadeIn('fast');

		 });
	 });

*/
         

	// tabs de la page méthode
	 $('#UI_offer_tabs .tabs dt').click(function(){
		 
		 $('#UI_offer_tabs .tabs dt').removeClass('current');
		 $(this).addClass('current');
		 $('#UI_offer_tabs .panel').hide();
		 
		 var n = $(this).parent().children("dt").index(this);
		 $('#UI_offer_tabs .panel:eq('+n+')').fadeIn('fast');
		 
         $('#UI_offer_tabs .panel:eq('+n+') .ssnav li').data('n', n);
 		 $('#UI_offer_tabs .panel:eq('+n+') .ssnav li').click(function(){
 			 
			 $('#UI_offer_tabs .panel:eq('+$(this).data('n')+') .ssnav li').removeClass('current');
			 $(this).addClass('current');
			 $('#UI_offer_tabs .panel:eq('+$(this).data('n')+') .bloc').hide();
			 var p = $(this).parent().children("li").index(this);
			 $('#UI_offer_tabs .panel:eq('+$(this).data('n')+') .bloc:eq('+p+')').fadeIn('fast');
			 
		 });
	 });


         // tabs de la page méthode_bis
	 $('#UI_offer_tabs_bis .tabs dt').click(function(){

		 $('#UI_offer_tabs_bis .tabs dt').removeClass('current');
		 $(this).addClass('current');
		 $('#UI_offer_tabs_bis .panel').hide();

		 var n = $(this).parent().children("dt").index(this);
		 $('#UI_offer_tabs_bis .panel:eq('+n+')').fadeIn('fast');

         $('#UI_offer_tabs_bis .panel:eq('+n+') .ssnav li').data('n', n);
 		 $('#UI_offer_tabs_bis .panel:eq('+n+') .ssnav li').click(function(){

			 $('#UI_offer_tabs_bis .panel:eq('+$(this).data('n')+') .ssnav li').removeClass('current');
			 $(this).addClass('current');
			 $('#UI_offer_tabs_bis .panel:eq('+$(this).data('n')+') .bloc').hide();
			 var p = $(this).parent().children("li").index(this);
			 $('#UI_offer_tabs_bis .panel:eq('+$(this).data('n')+') .bloc:eq('+p+')').fadeIn('fast');

		 });
	 });

	 $('#UI_mea dt').hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});
});
/*
function is_int( mixed_var ) {
    // Find whether the type of a variable is integer
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_is_int/
    // +       version: 805.3114
    // +   original by: Alex
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: is_int(186.31);
    // *     returns 1: false
    // *     example 2: is_int(12);
    // *     returns 2: true

    var y = parseInt(mixed_var * 1);
    
    if (isNaN(y)) {
        return false;
    }
    
    return mixed_var == y && mixed_var.toString() == y.toString(); 
}
*/
