function sendEmail(sUser, sDomain, sSubject)
{
	location.href = 'mailto:' + sUser + '@' + sDomain + '?subject=' + sSubject;
}

function NewWindow(mypage, myname, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=no,directories=no,status=no,location=no,toolbar=no';
	win = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function privacy() {
        priv = window.open("privacy.htm",'privacy','scrollbars=yes,resizable=yes,directories=no,width=490,height=400,status=no,location=no,toolbar=no');
}


function load(dir,foto) {
	document.getElementById("pic").src = "pict/"+dir+"/big/"+foto;
}


function generate(x, y) {
	var range = y - x + 1;
	return Math.round(Math.random() * range) + x;
	}
	function rnd_number(m){
	return generate (1,m);
}

function validate_form() {
  var validity = true; // assume valid
  var msg = "Verificare i seguenti dati:\n\n";
  if (!check_empty(document.form.Cognome.value))
  	{ validity = false; msg=msg+'Inserire Cognome\n'; }
  if (!check_empty(document.form.Indirizzo.value))
  	{ validity = false; msg=msg+'Inserire Indirizzo\n'; }
  if (!check_empty(document.form.Citta.value))
  	{ validity = false; msg=msg+'Inserire Citta\n'; }
  if (!check_empty(document.form.Provincia.value))
  	{ validity = false; msg=msg+'Inserire Provincia\n'; }
  if (!check_empty(document.form.Telefono.value))
  	{ validity = false; msg=msg+'Inserire Telefono\n'; }
  if (!check_empty(document.form.email.value) || !check_email(document.form.email.value))
  	{ validity = false; msg=msg+'EMAIL non corretta\n'; }
  if (!validity)
  	alert (msg);
  return validity;
}
function check_empty(text) {
  return (text.length > 0); // returns false if empty
}
function check_email(Email) {
  if ((Email == "")
    || (Email.indexOf ('@') == -1)
    || (Email.indexOf ('.') == -1))
      return false;
  return true;
}



// cambia testo in main
function cambiatxt(t) {
	document.getElementById("txt").innerHTML=t;
}


// expanding

// Node Functions

if(!window.Node){
	var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}
function checkNode(node, filter){
	return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}
function getChildren(node, filter){
	var result = new Array();
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		if(checkNode(children[i], filter)) result[result.length] = children[i];
	}
	return result;
}
function getChildrenByElement(node){
	return getChildren(node, "ELEMENT_NODE");
}
function getFirstChild(node, filter){
	var child;
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		child = children[i];
		if(checkNode(child, filter)) return child;
	}
	return null;
}
function getFirstChildByText(node){
	return getFirstChild(node, "TEXT_NODE");
}
function getNextSibling(node, filter){
	for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
		if(checkNode(sibling, filter)) return sibling;
	}
	return null;
}
function getNextSiblingByElement(node){
	return getNextSibling(node, "ELEMENT_NODE");
}

// Menu Functions & Properties

var activeMenu = null;

function showMenu(){
	if(activeMenu){
		activeMenu.className = "";
		getNextSiblingByElement(activeMenu).style.display = "none";
	}
	if(this == activeMenu){
		activeMenu = null;
	}else{
		this.className = "active";
		getNextSiblingByElement(this).style.display = "block";
		activeMenu = this;
	}
	return false;
}
function initMenu(){
	var menus, menu, text, a, i;
	menus = getChildrenByElement(document.getElementById("menu"));
	for(i = 0; i < menus.length; i++){
		menu = menus[i];
		text = getFirstChildByText(menu);
		a = document.createElement("a");
		menu.replaceChild(a, text);
		a.appendChild(text);
		a.href = "#";
		a.onclick = showMenu;
		a.onfocus = function(){this.blur()};
	}
}

if(document.createElement) window.onload = initMenu;

