///////////////////////////////////////////  FUNZIONE MOVIMENTO PANNELLINI HOMEPAGE

function pan(mybox,myeff) {
	
	if (myeff != undefined) {
			$("#panBox"+mybox).hide('fold',600);
			$("#p"+mybox).attr("class", "");
	} else {
	
	var openpan = "";
	
	
	////////////// trovo il pannellino aperto
	
	$(".slidingPan").each(function() {
		elem = this;		
			if($(elem).css("display") == 'block') {
					openpan = $(elem).attr("id");
					opennum = openpan.substring(openpan.length-1,openpan.length );
					//console.log(opennum);
					
			}
	});
	
	////////////// apro il pannello e chiudo quello già aperto se c'è.
	
	if (openpan != "" && openpan == ("panBox"+mybox)) {
		$("#"+openpan).hide('drop',500);
		$("#p"+mybox).attr("class", "");	
	}
	else if (openpan != "" && openpan != ("panBox"+mybox)){
		$("#"+openpan).hide('drop',500);
		$("#panBox"+mybox).show('drop',500);
		$("#p"+opennum).attr("class", "");
		$("#p"+mybox).attr("class", "sel");			
	} else {
		$("#panBox"+mybox).show('drop',500);		
		$("#p"+mybox).attr("class", "sel");		
	}
	}

}


function panInit(){
	$(document).ready(function(){
		for (i=1;i<=4;i++) {
  	 $("#panBox"+i).hide();
		} 
	});
}



///////////////////  OROLOGIO HOME PAGE

function printClockItaly(){

	var timeendItaly = new Date();
	
	if(document.currenttimeItaly === undefined){
		timeendItaly.setHours(document.mtimeItalyh);
		timeendItaly.setMinutes(document.mtimeItalyi);
		timeendItaly.setSeconds(document.mtimeItalys);

		document.currenttimeItaly = timeendItaly.getTime();
	}else{
		document.currenttimeItaly  += 1000;
		
	}
	

	timeendItaly.setTime(document.currenttimeItaly);
	
	var hours_passed = timeendItaly.getHours();
	if(hours_passed < 10){
		hours_passed = "0" + hours_passed;
	}
	var minutes_passed = timeendItaly.getMinutes();
	if(minutes_passed < 10){
		minutes_passed = "0" + minutes_passed;
	}
	var seconds_passed = timeendItaly.getSeconds();
	if(seconds_passed < 10){
		seconds_passed = "0" + seconds_passed;
	}
	

	italy.innerHTML = hours_passed + ":" + minutes_passed + "<strong>:" + seconds_passed + "</strong>";
	
	timercountItaly = setTimeout("printClockItaly()", 1000);
	
}


function printClockUsa(){

	var timeendUsa = new Date();
	
	if(document.currenttimeUsa === undefined){
		timeendUsa.setHours(document.mtimeUsah);
		timeendUsa.setMinutes(document.mtimeUsai);
		timeendUsa.setSeconds(document.mtimeUsas);

		document.currenttimeUsa = timeendUsa.getTime();
	}else{
		document.currenttimeUsa  += 1000;
		
	}
	

	timeendUsa.setTime(document.currenttimeUsa);
	
	var hours_passed = timeendUsa.getHours();
	if(hours_passed < 10){
		hours_passed = "0" + hours_passed;
	}
	var minutes_passed = timeendUsa.getMinutes();
	if(minutes_passed < 10){
		minutes_passed = "0" + minutes_passed;
	}
	var seconds_passed = timeendUsa.getSeconds();
	if(seconds_passed < 10){
		seconds_passed = "0" + seconds_passed;
	}
	

	usa.innerHTML = hours_passed + ":" + minutes_passed + "<strong>:" + seconds_passed + "</strong>";
	
	timercountUsa = setTimeout("printClockUsa()", 1000);
	
}

function printClockChina(){

	var timeendChina = new Date();
	
	if(document.currenttimeChina === undefined){
		timeendChina.setHours(document.mtimeChinah);
		timeendChina.setMinutes(document.mtimeChinai);
		timeendChina.setSeconds(document.mtimeChinas);

		document.currenttimeChina = timeendChina.getTime();
	}else{
		document.currenttimeChina  += 1000;
		
	}
	

	timeendChina.setTime(document.currenttimeChina);
	
	var hours_passed = timeendChina.getHours();
	if(hours_passed < 10){
		hours_passed = "0" + hours_passed;
	}
	var minutes_passed = timeendChina.getMinutes();
	if(minutes_passed < 10){
		minutes_passed = "0" + minutes_passed;
	}
	var seconds_passed = timeendChina.getSeconds();
	if(seconds_passed < 10){
		seconds_passed = "0" + seconds_passed;
	}
	

	china.innerHTML = hours_passed + ":" + minutes_passed + "<strong>:" + seconds_passed + "</strong>";
	
	timercountChina = setTimeout("printClockChina()", 1000);

}
