

function header() {
}

function menu(prefix) {
	if(prefix==null)
		prefix="";/*prefisso per gli url della pagina*/
	document.write("<ul>");

	document.write("<li><a href='"+prefix+"./'>Home</a></li>");
	document.write("<li id='cart'><a title='Carrello' href='"+prefix+"carrello.php'>Carrello</a></li>");
	document.write("<li><a title='Listino' href='"+prefix+"listino.php'>Listino</a></li>");
	document.write("<li><a title='FAQ' href='"+prefix+"faq.htm'>FAQ</a></li>");
	document.write("<li><a title='Chi siamo' href='"+prefix+"chisiamo.htm'>Chi siamo</a></li>");
	document.write("<li><a title='Contatti' href='"+prefix+"contatti.htm'>Contatti</a></li>");
	document.write("</ul>");
}

/**** non credo sia utilizzata la funzione seguente, viene usata la funzione menu(prefix) con prefix='../'    *****/
function menu_pannello() {
	document.write("<ul style='float: right'>");
	document.write("<li><a href='../'>Home</a></li>");
	document.write("<li id='cart'><a title='Carrello' href='../carrello.php'>Carrello</a></li>");
	document.write("<li><a title='FAQ' href='../faq.htm'>FAQ</a></li>");
	document.write("<li><a title='Termini del Servizio' href='../regolamento.php'>ToS</a></li>");
	document.write("<li><a title='Chi siamo' href='../chisiamo.htm'>Chi siamo</a></li>");
	document.write("<li><a title='Contatti' href='../contatti.htm'>Contatti</a></li>");
	document.write("</ul>");
}

function footer() {
	document.write("<p><br />ilbello Srl - CF/P.Iva 09502751002 - REA: RM 1167751<br />Iscrizione R.I. di Roma #09502751002 - Sede legale: via Tizzani 64<br />&copy; 2005-2012 <a title='hosting professionale' href='http://www.hostingprofessionale.net'>HostingProfessionale.net</a><br /><br /></p>");
}

function uptime() {
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write("<a title='Uptime' href='http://www.serviceuptime.com/users/uptimemonitoring.php?S=2d91211e1d27f699999a695392608924&Id=5089' target='_blank' border='0'><img border='0' src='"+ gaJsHost +"hostingprofessionale.net/img/uptime.gif' alt='Monitoraggio uptime' /></a>");
}

function adjust_height_right(){
	var content = document.getElementById("content");
	var left = document.getElementById("left");
	var right =document.getElementById("right");
  	if (left.clientHeight > right.clientHeight){
		right.style.height = left.clientHeight +"px";
		left.style.height = left.clientHeight+"px";
	}
}

function print_grey_box(content){
	document.write('<div class="left_top_box">');
		document.write('<div class="left_topbox_head">');
			document.write('<div class="topbox_corner_lu"></div>');
			document.write('<div class="topbox_corner_ru"></div>');
		document.write('</div>');
		document.write('<div class="topbox_side_l">');
			document.write('<div class="topbox_side_r">');
				document.write('<div class="left_topbox_center">');
					document.write(content);
				document.write('</div>');
			document.write('</div>');
		document.write('</div>');
		document.write('<div class="left_topbox_bottom">');
			document.write('<div class="topbox_corner_ld"></div>');
			document.write('<div class="topbox_corner_rd"></div>');
		document.write('</div>');
	document.write('</div>');
}

function login_form() {
	var cookie_username=readCookie("logged_username");
	var logged_username=null;
	if (cookie_username) logged_username=cookie_username.replace("%40", "@");
	//alert(logged_username);

	if (logged_username) {
		document.write('<div class=\"login\" id=\"welcome_back\">Utente '+logged_username+', <a href=\"pannello/pannello.php\">Vai al pannello</a></div>');
	}
	else {
		// Login SSL (fixare per test da localhost)
		document.write('<form class="login" action="https://ssl.hostingprofessionale.net/c/?autentica" method="post">');
		document.write('<p>Email:<input id="email" type="text" name="email" />');
		document.write('Password:<input id="passw" type="password" name="loginpass" />');
		document.write('<input type="hidden" name="loginpass_md5" id="loginpass_md5" />');
		document.write('<input type="hidden" name="dest" value="pannello" />');
		document.write('<input id="submit" type="submit" name="Invia" value="Login" onClick="javascript:loginmd5()" style="width:54px;" /></p>');
		document.write('</form>');
	}
}


// Javascript/MD5 pretty secure login
function loginmd5() {
	pass=$("#loginpass").val();				// form v1 (login.php)
	if (pass==null) pass=$("#passw").val(); // form v2 (altrove)

	pass_md5=$.md5(pass);
	$("#loginpass_md5").val(pass_md5);

	$("#loginpass").val("");
	$("#passw").val("");
}

// Modifica visibilità oggetto_id
function switchVisibility(obj) {
	var el = document.getElementById(obj);
	if (el.style.display != 'none' ) el.style.display = 'none';
	else el.style.display = '';
}

// Sostituisce contenuto di un div
function switchText(obj,string1,string2){
	var el = document.getElementById(obj);
	if ( el.firstChild.data == string1 ) el.firstChild.data = string2;
	else if(el.firstChild.data == string2) el.firstChild.data = string1;
}

// Cookie stuff
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function navigationBar(){
	url = document.location.href.split('/');
	page = url[url.length-1];
	/*document.write(page);*/

	switch (page){

		case 'chisiamo.htm':
			bar = new Array('Home','Chi Siamo');
		break;
		case 'contatti.htm':
			bar = new Array('Home','Contatti');
		break;
		case 'carrello.php':
			bar = new Array('Home','Carrello');
		break;
		case 'listino.php':
			bar = new Array('Home','Listino');
		break;
		case 'faq.htm':
			bar = new Array('Home','FAQ');
		break;

		case 'registrazione-domini.htm':
			bar = new Array('Home','Registrazione Domini');
		break;

		case 'hosting.htm':
			bar = new Array('Home','Hosting');
		break;
		/**HOSTING GENERICO**/
		case 'hosting-php-compatibile.php':
			bar = new Array('Home','Hosting','Hosting PHP');
		break;
		case 'confronti-hosting-php-compatibile.php':
			bar = new Array('Home','Hosting','Hosting PHP', 'Confronti Hosting PHP');
		break;
		case 'hosting-personal.php':
			bar = new Array('Home','Hosting','Hosting PHP', 'Hosting Personal');
		break;
		case 'hosting-giga.php':
			bar = new Array('Home','Hosting','Hosting PHP', 'Hosting Giga');
		break;
		case 'hosting-top.php':
			bar = new Array('Home','Hosting','Hosting PHP','Hosting Top');
		break;

		/**HOSTING ECOMMERCE**/
		case 'hosting-ecommerce.php':
			bar = new Array('Home','Hosting','Hosting E-commerce');
		break;
		case 'confronti-hosting-ecommerce.php':
			bar = new Array('Home','Hosting','Hosting E-commerce', 'Confronti Hosting E-commerce');
		break;
		case 'hosting-opencart.php':
			bar = new Array('Home','Hosting','Hosting E-commerce' , 'Hosting OpenCart');
		break;
		case 'hosting-magenta.php':
			bar = new Array('Home','Hosting','Hosting E-commerce' , 'Hosting Magenta');
		break;
		case 'hosting-magenta_plus.php':
			bar = new Array('Home','Hosting','Hosting E-commerce' , 'Hosting Magenta Plus');
		break;

		/**HOSTING CMS**/
		case 'categoria-hosting-cms.php':
			bar = new Array('Home','Hosting','Hosting Specifico CMS');
		break;
		case 'confronti-hosting-cms.php':
			bar = new Array('Home','Hosting','Hosting Specifico CMS', 'Confronti Hosting CMS');
		break;
		case 'hosting-joomla.php':
			bar = new Array('Home','Hosting','Hosting Specifico CMS' , 'Hosting Joomla');
		break;
		case 'hosting-wordpress.php':
			bar = new Array('Home','Hosting','Hosting Specifico CMS' , 'Hosting WordPress');
		break;

		/**HOSTING WEBAGENCY**/

		case 'offerte-hosting-web-agency.php':
			bar = new Array('Home','Offerte Hosting Web Agency');
		break;

		/**SOLUZIONI PERSONALIZZATE**/

		case 'hosting-personalizzato.htm':
			bar = new Array('Home','Soluzioni Personalizzate');
		break;

		/*SERVIZI AGGIUNTIVI*/

		case 'servizi-aggiuntivi-backup_giornaliero.php':
			bar = new Array('Home','Servizi Aggiuntivi' , 'Backup Giornaliero');
		break;
		case 'servizi-aggiuntivi-statistiche.php':
			bar = new Array('Home','Servizi Aggiuntivi' , 'Statistiche AWStats');
		break;
		case 'servizi-aggiuntivi-crontab.php':
			bar = new Array('Home','Servizi Aggiuntivi' , 'Crontab');
		break;
		case 'servizi-aggiuntivi-email_10.php':
			bar = new Array('Home','Servizi Aggiuntivi' , 'Email Aggiuntive');
		break;
		case 'servizi-aggiuntivi-db_extra.php':
			bar = new Array('Home','Servizi Aggiuntivi' , 'Database Upgrade');
		break;
		case 'servizi-aggiuntivi-https_ssl_ip.php':
			bar = new Array('Home','Servizi Aggiuntivi' , 'Certificati SSL');
		break;

		default:
			bar = new Array();
		break;
	}

	url =  getUrlArray();
	document.write('<div id="navigation_bar" class="floatcontainer"><ul>');
	for (i=0; i<bar.length; i++){
		if (url[bar[i]]!=undefined)
			 itemUrl=url[bar[i]];
		else
			 itemUrl='';
		document.write('<li><a href=\''+ itemUrl  +'\'>' +bar[i]+'</a></li>');
		document.write('<li>&gt;</li>');
	}
	document.write('</ul></div>');
}

function getUrlArray(){
	/** array associativo: chiave è il titolo dell'elemento, valore è l'url relativo**/
	var url = {
	'Home':'index.htm',
	'Hosting':'hosting.htm',
	'Hosting PHP Generico':'hosting-php-compatibile.php',
	'Confronti Hosting PHP Generico':'confronti-hosting-php-compatibile.php',
	'Hosting E-commerce':'categoria-hosting-ecommerce.php',
	'Confronti Hosting E-commerce':'confronti-hosting-ecommerce.php',
	'Hosting Specifico CMS':'categoria-hosting-cms.php',
	'Confronti Hosting CMS':'confronti-hosting-cms.php',
	'Hosting Personal':'hosting-personal.php',
	'Hosting Giga':'hosting-giga.php',
	'Hosting Top':'hosting-top.php',
	'Hosting OpenCart':'hosting-opencart.php',
	'Hosting Magenta':'hosting-magenta.php',
	'Hosting Magenta Plus':'hosting-magenta_plus.php',
	'Hosting Joomla':'hosting-joomla.php',
	'Hosting Wordpress':'hosting-wordpress.php',
	'Servizi Aggiuntivi':'',
	'Backup Giornaliero':'servizi-aggiuntivi-backup_giornaliero.php',
	'Statistiche AWStats':'servizi-aggiuntivi-statistiche.php',
	'Crontab':'servizi-aggiuntivi-crontab.php',
	'Email Aggiuntive':'servizi-aggiuntivi-email_10.php',
	'Database Upgrade':'servizi-aggiuntivi-db_extra.php',
	'Certificati SSL':'servizi-aggiuntivi-https_ssl_ip.php'};
	return url;
}

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    }
    else {
        cursor.x = e.clientX +
            (document.documentElement.scrollLeft ||
            document.body.scrollLeft) -
            document.documentElement.clientLeft;
        cursor.y = e.clientY +
            (document.documentElement.scrollTop ||
            document.body.scrollTop) -
            document.documentElement.clientTop;
    }
    return cursor;
}

function chiediInfo(){
	popup = document.getElementById('chiediInfo');
	popup.style.display='';
	pos = getPosition();
	popup.style.top = pos.y - popup.offsetHeight + 30;
	popup.style.left = pos.x - popup.offsetWidth - 50;
}

/* Azzero campi di un form alla prima selezione */
already_blanked=new Array();
function empty_field(e) {
	if (already_blanked[e.id] != 1) {
		document.getElementById(e.id).value = "";
		already_blanked[e.id] = 1;
	}
}
