// JavaScript Document

function check(){
	if ((document.getElementById('user').value == "") || (document.getElementById('password').value == "")) {
		alert("I campi user e password devono essere valorizzati.")
		return false;
	} 
	
	return true;
}

function mmenu(mID) {
	var menu = $('#' + mID);
	menu.slideToggle('slow');
}

/* Apertura pop-up */
function openPopup(url, name, w, h, s){
	var prop = "width=" + w + ", height=" + h + ", scrollbars=" + s + ", top=100, left=100";
	window.open(url, name, prop);
}

function showFaqOnLoad(){
	if(window.location.hash != ''){
		if(window.location.hash.indexOf('#faq-') > -1) {
			id = window.location.hash.replace('#faq-', "");
			if(document.getElementById('submenu-' + id))
				var menu = $('#submenu-' + id);
				menu.slideToggle('slow');
		}
	}
}

function showGlossarioOnLoad(){
	if(window.location.hash != ''){
		if(window.location.hash.indexOf('#glossario-') > -1) {
			id = window.location.hash.replace('#glossario-', "");
			if(document.getElementById('submenu-' + id))
				var menu = $('#submenu-' + id);
				menu.slideToggle('slow');
		}
	}
}

$(document).ready(function () {
	$('input.txt').bind('focus', function () { if($(this).val() == 'username' || $(this).val() == 'password') $(this).val(''); });
});

function updateGraph (id, name) {
	var anno = $('#anno').val();
	
	var curDate = new Date().getTime();
	
	// the update url to download the xml update from
	var url = "/xmlGraph.php?c=" + id + "&name=" + name + "&anno=" + anno + "&dummy=" + (curDate / 1000);
	  
	// show a spinning wheel while downloading the update
	var spinning_wheel = true; 
   
	// number of seconds to wait before a download times out
	var timeout = 30; 
   
	// number of times to try downloading before displaying an error
	var retry = 2; 
      
	// the update mode (see the update function)
	var mode = "reset";
   
	document.my_chart.Update_URL( url, spinning_wheel, timeout, retry, mode );   

}
