//slider home


//tabs navig

$(function(){
	
	
	//color picker
	
	$('.custom_field').ColorPicker({
	onSubmit: function(hsb, hex, rgb, el) {
		$(el).val(hex);
		$(el).ColorPickerHide();
	},
	onBeforeShow: function () {
		$(this).ColorPickerSetColor(this.value);
	}
})
.bind('keyup', function(){
	$(this).ColorPickerSetColor(this.value);
});
	
		
		
	//hide symbol fist from price
	
//	$('.price_hide_symb:lt(3)').css('display','none');
	
	$(".tab_content").css('display','none');
	
	$(".tab_content:first").css('display','block');
	
	
	$("ul.tabs li").hover(function() {
		
		$(".tab_content").css('display','none');
		
		var activeTab = $(this).attr("class");
		
		$("#"+activeTab).css('display','block');
		
		return false;
	});
	
		
	$(".hosting .css3_holder").hide();
		
	$(".hosting .css3_holder:first").show();
	
	
	$("ul.os_icon li:not('li.not-clickable')").click(function() {
		
		$("ul.os_icon li:not('li.not-clickable')").animate({opacity:1}, {duration:900});		
		
		$(this).animate({opacity:0.3}, {duration:450});
		
		$('html, body').animate({scrollTop: $('#hosting_current_price').offset().top}, 1200);
		
		
		$(".hosting .css3_holder").hide();
		
		var activeTab = $(this).attr("class");
		
		$("#"+activeTab).fadeIn("slow");
		
		return false;
	});
	
});

//css3 shadow flex

$(function(){
	
	
		
		
	$("ul.css3_holder").hover(function(){
		
		$(".item-2").animate({boxShadow: 'none'}).removeClass('parent_li');
		
	}, function() {
		
		$(".item-2").animate({boxShadow: '0 0 10px #333'}).addClass('parent_li');
		
		});
		
		
		$(".item-2").animate({boxShadow: '0 0 10px #333'}).addClass('parent_li');
	
				 
$(".item-1, .item-2, .item-3").hover(function(){	
	
		$(this).animate({boxShadow: '0 0 10px #333'}).addClass('parent_li');
	
	
	}, function(){	
	
		$(this).animate({boxShadow: 'none'}).removeClass('parent_li');
	
	
	});
	
//change value	
				 
$(".os_icon li").hover(function(){
	
	var titre = $(this).find('img').attr('alt');
				
	$("#changed_value").val(titre);
								
	});
	

});

//simple image fading

function slideSwitch() {
	
    var $active = $('#slideshow_1 li.active');

    if ( $active.length == 0 ) $active = $('#slideshow_1 li:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow_1 li:first');

    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


function slideSwitch2() {
	
    var $active = $('#slideshow_2 li.active');

    if ( $active.length == 0 ) $active = $('#slideshow_2 li:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow_2 li:first');

    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 4500 );
    setInterval( "slideSwitch2()", 7000 );
});

//css attribut to javascript

$(function() {
   
   	$("#preloader, #langchange ul.show, #nonclient").css({opacity: 0.8});
   
});

$(".input_shadow").hover(function(){	
	
		$(this).animate({boxShadow: '0 0 3px #999'});
	
	
	}, function(){	
	
		$(this).animate({boxShadow: 'none'});
	
	
	});

$("#changed_value").hover(function(){	
	
		$(this).animate({boxShadow: 'none'});
	
	
	});
	
$(".boxShadow").hover(function(){	
	
		$(this).animate({boxShadow: '0 0 3px #999'});
	
	
	},function(){	
	
		$(this).animate({boxShadow: 'none'});
	
	
	});
	
//SETTING UP OUR POPUP

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#PopUpPromo").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#PopUpPromo").height();
	var popupWidth = $("#PopUpPromo").width();
	//centering
	$("#PopUpPromo").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	

	//CLOSING POPUP
	//Click the x event!
	$("#PopUpPromoClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});


	var $unique = $('input.unique');
			$unique.click(function() {
				$unique.removeAttr('checked');
				$(this).attr('checked', true);
			});





		$('#form_check_home_submiter').click(function(){
			
			
			 if($("#sld").val() != "votre domaine" && $("#sld").val() != "your domain") {
			
			check_domain('#form_check_home','#updater');
			
			$('html, body').animate({scrollTop: $('#form_check_home').offset().top}, 1200);
			
			 }
			
			})
			
	

$(".clickable_area").click(function(){
   	window.location=$(this).find("a").attr("href");return false;
});

