function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) 
		selObj.selectedIndex=0;
}
function target_blank(x){
	document.getElementById(x).target="_blank";
}
function isEmail(str) {
	var supported = 0;
	if(window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if(!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,6}|[0-9]{1,3})(\\]?)$");

	return (!r1.test(str) && r2.test(str));
}

function isDate(str) {
	var arrivoArray = str.split("/"); 
	var dataarrivo=new Date()
	dataarrivo.setFullYear(arrivoArray[2],arrivoArray[1],arrivoArray[0])
	return (dataarrivo);
}

function MyTrim(myObj){
	var i;
	var myObjTmp;
	var myObjTmp2;

	if (myObj==null){
		myObj=''; 
		return myObj;
	}

	if (myObj=='') {
		return myObj;
	}

	for (i = 0; i < myObj.length; i++) {
		if(myObj.charAt(i) == ' '){
			myObjTmp = myObj.substr(i+1)
		} else {
			if (i==0) { 
				myObjTmp = myObj;
			}
			break;
		}
	}

	myObjTmp2 = myObjTmp

	if (myObjTmp.length > 0) {
		for (i = myObjTmp.length-1; i > 0; i--) {// elimina gli spazi finali
			if (myObjTmp.charAt(i) == ' '){
				myObjTmp2 = myObjTmp.substr(0,i)
			} else {
				break;
			}
		}
	}

	myObj = myObjTmp2
	return (myObj)
}
$(document).ready(function(){
	myHeight = $(window).height()
	/*$('#cont_nav').css({
		height: myHeight + 'px'
	});	*/
	/*$('#menuover').css({
		height: myHeight + 'px'
	});	
	
	$('div.cont_gea_blocco').css({
		height: myHeight + 'px'
	});	*/

	
	/*$(window).resize(function () {
		myHeight = $(window).height();
		$('#cont_nav').css({
			height: myHeight + 'px'
		});	
		$('#menuover').css({
			height: myHeight + 'px'
		});	
		$('div.cont_gea_blocco').css({
			height: myHeight + 'px'
		});	
	});*/
	gea1 = 0;
	gea2 = 0;
	$('#gea1').click(function() {
		
		$("div#backstretch div:not(#img_contiene_3)").fadeOut(1000);
		$("div#backstretch div#img_contiene_3").fadeIn(1000);
		x=3;
			
		$('#gea-menu li a').removeClass('active');
		if (gea2 == 1){
			
			$('#vis_gea2').stop().animate({
				 right:-762
				 
			}, 500,'easeInOutExpo', function(){
				$('#vis_gea1').stop().animate({
				 right:0
				}, 1500,'easeInOutExpo', function(){
					
					
				});
			});
			gea1 = 1;
			gea2 = 0;
			$(this).addClass('active');	
		} else {
			
			if (gea1 == 0){
				$('#vis_gea1').stop().animate({
					 right:0
				}, 1500,'easeInOutExpo', function(){
					
				});
				gea1 = 1;
				$(this).addClass('active');
			} else {
				
			
				$('#vis_gea1').stop().animate({
					 right:-762
				}, 500,'easeInOutExpo', function(){
					
				});
				gea1 = 0;
				$(this).removeClass('active');
			}	
		}
	});
	
	$('#gea2').click(function() {
		
		$("div#backstretch div:not(#img_contiene_3)").fadeOut(1000);
		$("div#backstretch div#img_contiene_3").fadeIn(1000);
		x=3;
		$('#gea-menu li a').removeClass('active');
		if (gea1 == 1){
			$('#vis_gea1').stop().animate({
				 right:-762
				 
			 
			}, 500,'easeInOutExpo', function(){
				$('#vis_gea2').stop().animate({
				 right:0
				}, 1500,'easeInOutExpo', function(){
					
					
				});
			});
			gea1 = 0;
					gea2 = 1;
					$(this).addClass('active');
		} else {
			if (gea2 == 0){
				$('#vis_gea2').stop().animate({
					 right:0
				}, 1500,'easeInOutExpo', function(){
					
				});
				gea2 = 1;
				$(this).addClass('active');
			} else {
				
				$('#vis_gea2').stop().animate({
					 right:-762
				}, 500,'easeInOutExpo', function(){
					
				});
				gea2 = 0;
				$(this).removeClass('active');
			}	
		}
	});
	
	
	var x_gea = 1;
	var y_gea = 1;	
	var divtot_gea = $('div.mini_nav_gea ul li').length;
	var rand_gea = 1;
	
	$("div.mini_nav_gea ul li a").click(function() {
		
		valoreid_gea = $(this).attr("id");
		valoreid_gea = valoreid_gea.replace("linkhome_gea_", "")
		Play_2_gea(valoreid_gea);
		return false;
	})
	
	function Play_2_gea(valoreclick_gea){
		
		$("div.mini_nav_gea ul li a").removeClass('attivo')
		y_gea = parseInt(valoreclick_gea);
		
		if (x_gea > divtot_gea){
			x_gea = 1;
		}
		valoreleft=-366*(y_gea-1);
		$("div.cont_geaini").animate({
			 left:valoreleft
		}, 1500,'easeInOutExpo');
		$("div.mini_nav_gea ul li a#linkhome_gea_"+y_gea).addClass('attivo')
		x_gea=y_gea;
	}
	
	
	var x_gea2 = 1;
	var y_gea2 = 1;	
	var divtot_gea2 = $('div.mini_nav_gea2 ul li').length;
	var rand_gea2 = 1;
	
	$("div.mini_nav_gea2 ul li a").click(function() {
		
		valoreid_gea2 = $(this).attr("id");
		valoreid_gea2 = valoreid_gea2.replace("linkhome_gea2_", "")
		Play_2_gea2(valoreid_gea2);
		return false;
	})
	
	function Play_2_gea2(valoreclick_gea2){
		
		$("div.mini_nav_gea2 ul li a").removeClass('attivo')
		y_gea2 = parseInt(valoreclick_gea2);
		
		if (x_gea2 > divtot_gea2){
			x_gea2 = 1;
		}
		valoreleft=-346*(y_gea2-1);
		$("div.cont_gea2ini").animate({
			 left:valoreleft
		}, 1500,'easeInOutExpo');
		$("div.mini_nav_gea2 ul li a#linkhome_gea2_"+y_gea2).addClass('attivo')
		x_gea2=y_gea2;
	}
	
});
