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("zprivacy.asp",'privacy','scrollbars=yes,resizable=yes,directories=no,width=490,height=400,status=no,location=no,toolbar=no');
}

function cambia_pic(immagine) {
	document.big.src = "pict/hi/"+immagine+".jpg";
}

function pic1() {
	if($('#det-01-1')) $('#det-01-1').show();
	if($('#det-01-2')) $('#det-01-2').hide();
	if($('#det-01-3')) $('#det-01-3').hide();
	if($('#det-01-4')) $('#det-01-4').hide();
	if($('#det-01-5')) $('#det-01-5').hide();
}
function pic2() {
	if($('#det-01-1')) $('#det-01-1').hide();
	if($('#det-01-2')) $('#det-01-2').show();
	if($('#det-01-3')) $('#det-01-3').hide();
	if($('#det-01-4')) $('#det-01-4').hide();
	if($('#det-01-5')) $('#det-01-5').hide();
}
function pic3() {
	if($('#det-01-1')) $('#det-01-1').hide();
	if($('#det-01-2')) $('#det-01-2').hide();
	if($('#det-01-3')) $('#det-01-3').show();
	if($('#det-01-4')) $('#det-01-4').hide();
	if($('#det-01-5')) $('#det-01-5').hide();
}
function pic4() {
	if($('#det-01-1')) $('#det-01-1').hide();
	if($('#det-01-2')) $('#det-01-2').hide();
	if($('#det-01-3')) $('#det-01-3').hide();
	if($('#det-01-4')) $('#det-01-4').show();
	if($('#det-01-5')) $('#det-01-5').hide();
}
function pic5() {
	if($('#det-01-1')) $('#det-01-1').hide();
	if($('#det-01-2')) $('#det-01-2').hide();
	if($('#det-01-3')) $('#det-01-3').hide();
	if($('#det-01-4')) $('#det-01-4').hide();
	if($('#det-01-5')) $('#det-01-5').show();
}

function cont() {
		p1 = "zcont";
		p2 = "atti";
		window.location = p1 + p2 + ".asp";
}


function validate_form() {
  var validity = true; // assume valid
  var msg = "Please verify following fields :\n\n";
  if (!check_empty(document.form.Email.value) || !checkEmail(document.form.Email.value))
  	{ validity = false; msg=msg+'Insert valid Email\n'; }
  if (!check_accetto())
  	{ validity = false; msg=msg+'Accept privacy conditions\n'; }
  if (!validity)
  	alert (msg);
  return validity;
}


function validate_form_log() {
  var validity = true; // assume valid
  var msg = "Please verify following fields :\n\n";
  if (!check_empty(document.formlog.email.value) || !checkEmail(document.formlog.email.value))
  	{ validity = false; msg=msg+'Insert valid EMAIL\n'; }
  if (!check_empty(document.formlog.pass.value))
  	{ validity = false; msg=msg+'Insert PASSWORD\n'; }
  if (!validity)
  	alert (msg);
  return validity;
}
function validate_form_rec() {
  var validity = true; // assume valid
  var msg = "Please verify following fields :\n\n";
  if (!check_empty(document.formrec.email.value) || !checkEmail(document.form.email.value))
  	{ validity = false; msg=msg+'Insert valid EMAIL\n'; }
  if (!validity)
  	alert (msg);
  return validity;
}

function check_empty(text) {
  return (text.length > 0); // returns false if empty
}
function checkEmail(toCheck) {
	if (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/.test(toCheck)) return true; else return false;
}
function check_accetto() {
	if (!document.form.accetto.checked)
		return false;
	return true;
}

function RunFla(var1,var2,var3,var4)
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+var3+'" height="'+var4+'">\n');
    document.write('<param name="movie" value="'+var1+'">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="wmode" value="transparent">\n');
	document.write('<param name="bgcolor" value="'+var2+'">\n');
	document.write('<embed src="'+var1+'" quality="high" bgcolor="'+var2+'" width="'+var3+'" height="'+var4+'" name="lay" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n');
    document.write('</object>\n');
}


function euroval(s) {
	var strTot = replaceChars( FormatNumber(s,2,false,false,false) ,".",",");
	if (strTot.indexOf(",") > 0) {
		//strTot += "0";
	} else {
		strTot += ",00";
	}
	return strTot;
}

function replaceChars(entry,what,withs) {
	temp = "" + entry; // temporary holder

	while (temp.indexOf(what)>-1) {
		pos= temp.indexOf(what);
		temp = "" + (temp.substring(0, pos) + withs + 
		temp.substring((pos + what.length), temp.length));
	}
	return temp;
}


function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
    if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}
