//toggle menu 

function formatText(index, panel) {
	return index + "";
}
$(document).ready(function() {
	//$("#tabs").tabs();
	$(".toggle").show();
	$(".scrolltotop").show();
	$(".featured").hide();
	$(".slider_wrapper .slider").show();
	$("<"+"div class='clear'><"+"span><!-- --><"+"/span><"+"/div>").insertAfter("ol.submenu");
	$("span.empty").html("&nbsp;");
	$("<"+"li class='seperator'><"+"span><!-- --><"+"/span><"+"/li>").insertBefore(".navigation");
	$("<"+"li class='seperator'><"+"span><!-- --><"+"/span><"+"/li>").insertAfter(".navigation:last");
	swapValues = [];
	$(".swap_value").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if($(this).val() == swapValues[i]) {
				$(this).css({'color' : '#000'});
				$(this).val("");
			}
		}).blur(function(){
			if($.trim($(this).val()) == "") {
				$(this).css({'color' : '#a6a6a6'});
				$(this).val(swapValues[i]);
			}
		});
	});
	
	$("ol#navigation li.navigation").hover(function() {
		$(this).addClass("active");
	}, function() {
		$(this).removeClass("active");
	});
	$(".toggle").hover(function() {
		var toggleClass = $(this).attr("class").substr($(this).attr("class").indexOf(" ")+1);
		if($(".megamenu."+toggleClass).is(":hidden")) {
			$(this).attr({src: "http://www.triangle-sarl.com/Web/Images/OrangeArrowDown.gif"});
		}
	}, function() {
		var toggleClass = $(this).attr("class").substr($(this).attr("class").indexOf(" ")+1);
		if($(".megamenu."+toggleClass).is(":hidden")) {
			$(this).attr({src: "http://foerderbruecke.conveying-systems.info/images/design/down_arrow_white.gif"});
		}
	});
	$(".toggle").click(function() {
		var toggleClass = $(this).attr("class").substr($(this).attr("class").indexOf(" ")+1);
		if($(".megamenu."+toggleClass).is(":visible")) {
			$("li.navigation").removeClass("active");
			$("li.seperator").removeClass("active")
			$(this).parent("li").addClass("active");
			$("li.navigation").removeClass("open");
			$(this).parent("li").next("li.seperator").removeClass("seperator-active");
			$(this).attr({src: "http://foerderbruecke.conveying-systems.info/images/design/down_arrow_white.gif"});
			$(".megamenu."+toggleClass).hide();
			$("#wrapper_megamenu").hide();
		} else {
			$("li.navigation").removeClass("active");
			$("li.seperator").removeClass("active")
			$("li.navigation").removeClass("open");
			$("li.navigation img").attr({src: "http://foerderbruecke.conveying-systems.info/images/design/down_arrow_white.gif"});
			$(".megamenu").hide();
			$("#wrapperMegamenu").show();
			$(".megamenu."+toggleClass).show();
			$(this).parent("li").addClass("open");
			$(this).parent("li").next("li.seperator").addClass("seperator-active");
			$(this).attr({src: "http://foerderbruecke.conveying-systems.info/images/design/up_arrow_white.gif"});
		}
	});
	$("ol.submenu").each(function() {
		$(this).find("li:first").css({'width' : '145px'});
	});
});


//timer header

 Maintenant = new Date;
 TempMaintenant = Maintenant.getTime();
 Future = new Date(2010, 6, 13);
 TempFuture = Future.getTime();
 DiffSec = Math.floor((TempFuture-TempMaintenant)/1000);
 DiffMin = Math.floor(DiffSec/60);
 Diffheure = Math.floor(DiffMin/60);
 DiffJour = Math.floor(Diffheure/24);
  while (DiffMin>=60)
		{
		DiffMin = DiffMin-60;
		}
  while (Diffheure>=24)
		{
		Diffheure = Diffheure-24;
		}
  while (DiffSec>=60)
		{
		DiffSec = DiffSec-60;
		}



//Init
$(document).ready(function() {
	showHover();	
	scrollHoz();			
	jCarouselCR();
	jQuery("#colR .upPortail:eq(0)").addClass("upDegrade");

});


//Scroll Horizontal
function scrollHoz() {
	if( $(".scrollTo").length < 1 ) return false;
	$(".scrollTo").each(function(i){
		var links = $(this).find(".scrollTo-Links a");
		
		links.click(function(){
			index = links.index(this);
			links.removeClass("current");
			$(this)
				.addClass("current")
				.parents(".scrollTo")
				.find(".scrollTo-Mask")
				.scrollTo( "ul:eq(" + index + ")", 1000, {axis:"x"} );
			return false;
		})
	});
	$(".scrollTo-Links li:first-child a").click();
	$(".scrollTo-Links li img").reflect({height:0.5,opacity:0.2});
}

//show hover H4
function showHover() {
	if( $(".showHover li").length < 1 ) return false;
	$('.showHover li').hover(
		function() {
			$(this).addClass("show");
			return false;
		},
		function() {
			$(this).removeClass("show");
           return false;
		}					
	);
}


//Jcarousel
function jCarouselCR() {
	if( $(".jCarousel-CR").length < 1 ) return false;
	var nbItem = $(".jCarousel-CR li").length;
	$(".jCarousel-CR")
		.jcarousel({scroll:4, start: nbItem})
	    .parents(".jCarouselParent").css('left','0');
	$(".jCarousel-CR li img").reflect({height:0.5,opacity:0.2});
}



