var $whois_initial_value='Tapez le nom de domaine désiré';
var $whois_error_value='S.V.P entrez un nom de domaine valide...';
var $simple_fqdn_regxp='([a-zA-Z0-9-]+[.])+[a-zA-Z0-9-]+';

$(document).ready(function() {
		//Set actions for domain search
			$('.domaininput').val($whois_initial_value).focus(function(){if($(this).val()==$whois_initial_value||$(this).val()==$whois_error_value){$(this).val('');}}).blur(function(){if($(this).val()==''&&$(this).parents('fieldset').hasClass('error')){$(this).val($whois_error_value);}else if($(this).val()==''){$(this).val($whois_initial_value);}}).keydown(function(){$(this).parents('fieldset').removeClass('error');});$('#domain_search_form').submit(function(evt){var $domaininput=$(this).find('.domaininput');var domain=$domaininput.val();if(domain==''||domain==$whois_initial_value||domain==$whois_error_value||!domain.match($simple_fqdn_regxp)){$(this).find('fieldset').addClass('error');$domaininput.val($whois_error_value);$domaininput.blur();evt.preventDefault();}
domain=escape(domain);});
		
		//Submit form action
		$("#search_submit").bind("click",function(){
			var $domain_value = $('.domaininput').val();

			$name_value = $domain_value.substr(0,  $domain_value.indexOf('.'));
			$tld = $domain_value.substring($name_value.length, $domain_value.length);

			$("#domain_search_form").get(0).setAttribute('action', 'https://moncompte.kenotronix.com/cart.php?a=add&domain=register&sld='+$name_value+'&tld='+$tld);
			$("#domain_search_form").submit();
		
		})
		
		$('#domain_search').keypress(function(e) {
        	if(e.which == 13) {
            	jQuery(this).blur();
            	jQuery('#search_submit').focus().click();
        	} 
    	});
    
		//Setup dropdownmenu
		$(".subnav").each(function () {
				$(this).parent().eq(0).hover(function () {
				$("a",this).first().addClass("open");
				$(".subnav:eq(0)", this).show();
			}, function () {
				$("a",this).first().removeClass("open");
				$(".subnav:eq(0)", this).hide();	
			});
		});


		//Setup section nav
		$("#section_nav a").each(function (i) {
			$(this).bind("click",function(){
			
				
					$("#section_nav a").each(function (ii) {
						$(this).removeClass("selected");
						$("#"+$(this).attr("href").substring(1,$(this).attr("href").length)).hide();
						

					});
					
					$(this).addClass("selected");
					$("#"+$(this).attr("href").substring(1,$(this).attr("href").length)).show();
					
					return false;
			})
			
			if(i!=0){
				$("#"+$(this).attr("href").substring(1,$(this).attr("href").length)).hide();
			}
		});
		
		$(".service_box").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".hosting_plan").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".button_hover").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".incident").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".product").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".facturation").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".emails").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".ticket").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".billing").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".paiement_mode").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".popular").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".post_result").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		$(".article").each(function (i){
			$(this).bind("click",function(){
				window.location.href = $("a",this).get(0);
				//alert($("a",this).get(0));
			});
		
		})
		
		
		
		
		
		
		
		
		
		
		$("#dropdown_menu").bind("click",function(__e) {
			$("#dropdown_menu_open").toggle();
			__e.preventDefault();
			__e.stopPropagation();
			
		});
		$("#dropdown_menu_open").bind("click",function() {
			$("#dropdown_menu_open").toggle();
		})
		
		$('html').click(function() {
			$("#dropdown_menu_open").hide();
 		});
		
		
		$(".dropdown dt a").click(function(__e) {
     	  $(".dropdown dd ul").hide();
  		  $("dd ul",$(this).parent().parent()).toggle();
  		 // $(".dropdown dd ul").toggle();
  		 __e.preventDefault();
  		 return false;
		});
		
		$(".dropdown dd ul li a").click(function(__e) {
   			 var text = $(this).html();
    		$("dt a span",$(this).parent().parent().parent().parent()).html(text);
  		    $("dd ul",$(this).parent().parent().parent().parent()).hide();
  		     __e.preventDefault();
  		    return false;
		}); 
		
		$(document).bind('click', function(e) {
    		var $clicked = $(e.target);
    		if (! $clicked.parents().hasClass("dropdown"))
     	   $(".dropdown dd ul").hide();
     	   
		});


			$(".service_choice").each(function (i){
				$(this).bind("mouseover",function(){
					$(".service_choice").each(function (i){
						$(".server_info",this).css( "height","0px"  );
					});

					$(".server_info",this).css( "height","100px"  );
					
				});
				//if(i==0)$(".server_info",this).css( "height","100px"  );
				$(".server_info",this).delay(1000).css( "-webkit-transition","all .3s ease-in-out");
    			$(".server_info",this).delay(1000).css( "-moz-transition" ,"all .3s ease-in-out");
   				$(".server_info",this).delay(1000).css( "-o-transition" ,"all .3s ease-in-out;");
			});
		
		$(".expandable_list li").each(function (i){
			$(this).attr( "oldheight",$(this).height())
			
			$(this).bind("click",function(){
				//$(this).className = ""
				//alert($(this).clicked);
				var _oldClicked = $(this).attr( "clicked")
				$(".expandable_list li").each(function (i){
					$(this).attr( "clicked", "false"  );
					$(this).css( "height","25px"  );
				});
				
				if(_oldClicked!="true"){
					$(this).attr( "clicked", "true"  );
					$(this).css( "height",(parseInt($(this).attr( "oldheight"))+15)+"px" )
				}else{
					$(this).attr( "clicked", "false"  );
					$(this).css( "height","25px"  )
				}
			})
			$(this).css( "height","25px")
			$(this).delay(1000).css( "-webkit-transition","all .3s ease-in-out");
    		$(this).delay(1000).css( "-moz-transition" ,"all .3s ease-in-out");
   			$(this).delay(1000).css( "-o-transition" ,"all .3s ease-in-out;");
			//$(this).animate({height: 'toggle'});
		})
		
		if($('.accueil_caroussel').length != 0){
			var interval = setInterval(rotate,5000); 
		}
		

	
	});
	
//HOME PAGE IMAGE ROTATION
function rotate(){
	count++
	if(count == 1){
		$('#image_one').animate({left: '0%'}, 1400);
		$('#image_two').css("left", '100%');
		//$('#image_three').css("left", '200%');
		$('#image_three').animate({left: '-100%'}, 1400);
		$('#image_four').animate({left: '-100%'}, 1400);
		$('#image_one').css("z-index","5");
		$('#image_two').css("z-index","1");
		$('#image_four').css("z-index","6");
		$('#image_three').css("z-index","1");
		$('#image_1').addClass("selected");
		$('#image_4').removeClass("selected");
		
		$('#image_wrapper .texte').animate({left: '50%'}, 1600);
		$('#image_wrapper .texte2').css("left", '150%');
		$('#image_wrapper .texte3').animate({left: '-50%'}, 1600);
		//$('#image_wrapper .texte3').css("left", '250%');
		$('#image_wrapper .texte4').animate({left: '-50%'}, 1600);
		
		$('#image_wrapper .texte').css("z-index","7");
		$('#image_wrapper .texte2').css("z-index","1");
		$('#image_wrapper .texte3').css("z-index","1");
		$('#image_wrapper .texte4').css("z-index","8");

		
		//$('#image_one a').show();
		//$('#image_two a').hide();
		//$('#image_three a').hide();
		//$('#image_four a').show();
	}
	
	if(count == 2){
		$('#image_one').animate({left: '-100%'}, 1400);
		$('#image_two').animate({left: '0%'}, 1400);
		$('#image_three').css("left", '100%');
		$('#image_four').css("left", '200%');
		$('#image_one').css("z-index","6");
		$('#image_two').css("z-index","6");
		$('#image_three').css("z-index","4");
		$('#image_four').css("z-index","4");
		$('#image_2').addClass("selected");
		$('#image_1').removeClass("selected");
		
		
		$('#image_wrapper .texte').animate({left: '-50%'}, 1600);
		$('#image_wrapper .texte2').animate({left: '50%'}, 1600);
		$('#image_wrapper .texte3').css("left", '150%');
		$('#image_wrapper .texte4').css("left", '250%');
		
		$('#image_wrapper .texte').css("z-index","7");
		$('#image_wrapper .texte2').css("z-index","8");
		$('#image_wrapper .texte3').css("z-index","1");
		$('#image_wrapper .texte4').css("z-index","1");
		
		
		//$('#image_one a').show();
		//$('#image_two a').show();
		//$('#image_three a').hide();
		//$('#image_four a').hide();
	}
	
	if(count == 3){
		$('#image_one').css("left", '-200%');
		$('#image_one').css("left", '150%');
		$('#image_two').animate({left: '-100%'}, 1400);
		$('#image_three').animate({left: '0%'}, 1400);
		$('#image_four').css("left", '100%');
		
		$('#image_four').css("left", '200%');
		$('#image_one').css("z-index","3");
		$('#image_two').css("z-index","4");
		$('#image_three').css("z-index","6");
		$('#image_four').css("z-index","6");
		$('#image_3').addClass("selected");
		$('#image_2').removeClass("selected");
		
		//$('#image_wrapper .texte').css("left", '-250%');
		$('#image_wrapper .texte').css("left", '150%');
		$('#image_wrapper .texte2').animate({left: '-50%'}, 1600);
		$('#image_wrapper .texte3').animate({left: '50%'}, 1600);
		$('#image_wrapper .texte4').css("left", '150%');
		
		$('#image_wrapper .texte').css("z-index","1");
		$('#image_wrapper .texte2').css("z-index","7");
		$('#image_wrapper .texte3').css("z-index","8");
		$('#image_wrapper .texte4').css("z-index","1");
		
		
		//$('#image_one a').hide();
		//$('#image_two a').show();
		//$('#image_three a').show();
		//$('#image_four a').hide();
	}
	
	if(count == 4){
		$('#image_one').css("left", '100%');
		$('#image_two').css("left", '-200%');
		$('#image_three').animate({left: '-100%'}, 1400);
		$('#image_four').animate({left: '0%'}, 1400);
		$('#image_one').css("z-index","5");
		$('#image_two').css("z-index","4");
		$('#image_three').css("z-index","6");
		$('#image_four').css("z-index","6");
		$('#image_4').addClass("selected");
		$('#image_3').removeClass("selected");
		
		$('#image_wrapper .texte').css("left", '150%');
		$('#image_wrapper .texte2').css("left", '-250%');
		$('#image_wrapper .texte3').animate({left: '-50%'}, 1600);
		$('#image_wrapper .texte4').animate({left: '50%'}, 1600);
		
		$('#image_wrapper .texte').css("z-index","1");
		$('#image_wrapper .texte2').css("z-index","1");
		$('#image_wrapper .texte3').css("z-index","7");
		$('#image_wrapper .texte4').css("z-index","8");
		
		//$('#image_one a').hide();
		//$('#image_two a').hide();
		//$('#image_three a').show();
		//$('#image_four a').show();
	}
	
	//$('#image_wrapper .texte').animate({opacity: '0'},700);
	if(count==3)count=0;
		
}

var count = 1;



