/* KEYVISUAL */
var interval;
jQuery(document).ready(function(){
	//slide down login
	jQuery('.switchLogin').click(function() {
		jQuery('#intranetLogin').slideDown("slow");
		jQuery('#intranetLogin').removeClass('hidden');
		return false;
	});
	//keyvisual
	jQuery('#keyvisualSwitch li').click(function(){ 
		switchKeyvisual(this);
		return false;
	});
});

function switchKeyvisual(e){
	var n = e.id.replace('sw','');
	jQuery('#front-keyvisual .kv .kvLi').fadeOut('slow');
	jQuery('#keyvisualSwitch li').removeClass('selected');
	jQuery('#sw'+n).addClass('selected');
	interval = setInterval("showMe("+n+")",400);
}

function showMe(n){
	jQuery('#front-keyvisual .cont'+n+'').fadeIn('slow');
	clearInterval(interval);
}
//light box for pictures
jQuery(document).ready(function(){
	jQuery("a[rel='lightbox']").lightBox({
		imageLoading: '../resources/images/lightbox-ico-loading.gif',
		imageBtnClose: '../resources/images/lightbox-btn-close.gif',
		imageBtnPrev: '../resources/images/lightbox-btn-prev.gif',
		imageBtnNext: '../resources/images/lightbox-btn-next.gif'
	});
});

/* TABS */
jQuery(document).ready(function(){
	jQuery('.tabs li a').click(function(){
		switchTab(this);
		return false;		
	});

});
function switchTab(a){
	//deselect all tabs
	jQuery('.tabs li').removeClass('selected');
	//select the one
	jQuery(a).parent().addClass('selected');
	var id = a.getAttribute('href'); 
	id=id.split('#')[1];
	jQuery('.tabContent').addClass('hidden');
	jQuery('#'+id).removeClass('hidden');
}

//change language
jQuery(document).ready(function(){
	jQuery("#langsw").bind("change", function(e){
		//gets root url
		var url = document.location.toString() ; //url
		var e_url = '' ; //edited url
		var p = 0 ; //position
		var p2 = 0 ;//position 2
		p = url.indexOf("//") ;
		e_url = url.substring(p+2) ;
		p2 = e_url.indexOf("/") ;
		var root_url = url.substring(0,p+p2+3);

		if (this.value == 'en'){
			window.location = root_url + "home";
		}else if(this.value == 'it'){
			window.location = root_url + "it/Home";
		}else if(this.value == 'de'){
			window.location = root_url + "de/Home";
		}else{
			window.location = root_url;
		}
	});
});