// ========== Sito: dizona.it ===========
//  IMG.ZEROUNO s.r.l. - Castel Madama - Rm - Italy
//	v. 2.0
//  2004
// ========================================

// JavaScript Document
<!--

function addObject(o, str)
{
	if (o)
	{
		var newO = document.createElement('div');
		o.appendChild(newO);
		newO.innerHTML = str;
	}
}

function addFlash(o, id, url, w, h, wmode, scheme)
{
	if (!wmode)
	{
		wmode = "Window";
	}
	if (!scheme)
	{
		scheme = "http";
	}
	var str = "";
	str += "<OBJECT codeBase=\"" + scheme + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"";
	str += " height=\"" + h + "\" width=\"" + w + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ID=\"" + id + "\" VIEWASTEXT>\r\n";
	str += " <PARAM NAME=\"Movie\" VALUE=\"" + url + "\">\r\n";
	str += " <PARAM NAME=\"Src\" VALUE=\"" + url + "\">\r\n";
	str += " <PARAM NAME=\"WMode\" VALUE=\"" + wmode + "\">\r\n";
	str += " <PARAM NAME=\"Quality\" VALUE=\"High\">\r\n";
	str += " <PARAM NAME=\"Menu\" VALUE=\"0\">\r\n";
	str += " <PARAM NAME=\"AllowScriptAccess\" VALUE=\"always\">\r\n";
	str += " <PARAM NAME=\"Scale\" VALUE=\"ShowAll\">\r\n";
	str += " <PARAM NAME=\"DeviceFont\" VALUE=\"0\">\r\n";
	str += " <embed src=\"" + url + "\" width=\"" + w + "\" height=\"" + h + "\" quality=\"high\" pluginspage=\"" + scheme + "://www.macromedia.com/go/getflashplayer\"";
	str += "  type=\"application/x-shockwave-flash\" menu=\"false\" wmode=\"" + wmode + "\" noexternaldata=\"true\" ></embed>\r\n";
	str += "</OBJECT>";
	addObject(o, str);
}

//-->

function WinPop(url,w,h,scroll,resize,center) {
	if (center) {
	var winPos = ',top='+((screen.height - h) / 2)+',left='+((screen.width - w) / 2);
	}
	var scrollArg = (scroll == false) ? '' : ',scrollbars=1';
	var resizeArg = (resize == false) ? '' : ',resizable=1';
	flyout = window.open (url,"newin"+scroll+resize+center,"width=" + w + ",height=" + h + scrollArg + resizeArg + winPos);
	flyout.resizeTo(w,h);
	flyout.focus();
}

//--------------- funzione controllo form
// N.B. Utilizzare la sintassi seguente nell' onSubmit del form:
// Per rendere i campi opzionali:
// this.nomecampo.optional = true;
// Per rendere i campi numeric:
// this.nomecampo.numeric = true;
// Per definire il min di un campo numerico:
// this.nomecampo.min = 10;
// Per definire il max di un campo numerico:
// this.nomecampo.min = 100;
// Per definire un campo e.mail ed effettuare il controllo sul formato immesso:
// this.nomecampo.mail = true;
// Per definire un campo URL ed effettuare il controllo sul formato immesso:
// this.nomecampo.url = true;



	// controllo se il campo contiene solo spazi bianchi
	function isblank(str) {
		for(var i=0; i < str.length; i++) {
			var c = str.charAt(i);
			if ( (c != '') && (c != '\n') && (c != '\t'))
				return false
		}
		return true;
	}

	// controllo se il valore del campo e.mail ha un formato corretto
	function ValidateEmail(theinput) {
		var s = theinput;
		if(s.search)
			return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi")) >= 0);
		if(s.indexOf) {
			var at_character = s.indexOf('@');
			if(at_character <= 0 || at_character + 4 > s.length)
				return false;
		}
		if(s.length < 6)
			return false;
		else
			return true;
	}	
	
	// controllo il formato corretto di un URL
	function ValidateUrl(theinput) {
		var url = /([w]{3}).([\w]{3,}).([\w]{2,})/i;
		var result = theinput.match(url);
		if(result != null)
			return true;
		else
			return false;
	}
	
	// Passo il nome del form
	function ValidateForm(form) { //v.01
		var msg = "_____________________________________________\n\n";
		msg += "    Attenzione!  Il form non sarà inviato.\n";
		msg += "_____________________________________________\n";
		msg += "Controllare i seguenti campi:\n\n";
		var err = "";
		for (var i=0; i < form.length; i++) {
			var element = form.elements[i];
			//controllo campi select
			if( ((element.type == "select-one") || (element.type == "select-multiple")) && !element.optional ) {// aggiungere se campo opzionale
				for(var j=0; j < element.options.length; j++) {
					if(element.options[j].selected) {
						if(j)
							continue;
						else
							err += "- " + element.name + "\n";
					}
							
				}
			}
			//controllo campi input e text area
			if( ((element.type == "text") || (element.type == "textarea")) && !element.optional) {
				if( (element.value == null) ||  (element.value == "") || isblank(element.value) ) {
					err += "- " + element.name + "\n"; 
					continue;
				}
			}
			//controllo formato campi e.mail 
			if(element.mail) {
				if(ValidateEmail(element.value))
					continue;
				else {
					err += "- " + element.name + ": Controllare il formato inserito.\n";
					continue;
				}
			}
		}
		if(err) {
			alert(msg + err);
			return false;
		}else
			return true;
	}
//-------------- fine controllo form	

//===================== funzione stampa =======================	

function PrintW() {
	bV = parseInt(navigator.appVersion);
	if (bV >= 4) window.print();
}
//===================== fine funzione stampa =======================	

// show-hide div
// ex: SHDiv('idDiv',true);
function CheckBrowser() {
	var browser="None";
	if( navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) {
		browser = "NS4";
		version = 4;
	}
	if( document.getElementById ) {
		browser = "NS6";
		if( navigator.userAgent.indexOf("6.01") != -1 || navigator.userAgent.indexOf("6.0") != -1 ) {
			version = 6;
		}else {
			version = 6.1;
		}
	}
	if( document.all ) {
		if( document.getElementById ) {
			version = 5;
		}else {
			version = 4;
		}
		browser = "IE";
	}
	return browser;
}
var browser = CheckBrowser();

function SHDiv(element,show){
	if(browser == "NS4") {
		if(document.layers[element]!= undefined) {
			if(show)
				document.layers[element].visibility="show";
			else
				document.layers[element].visibility="hide";
		}
	}
	if(browser == "IE") {
		if(document.all[element]!= null) {
			if(show)
				document.all[element].style.visibility="visible";
			else
				document.all[element].style.visibility="hidden";
		}
	}
	
	if(browser == "NS6") {
		if(document.getElementById(element)!= null) {
			if(show)
				document.getElementById(element).style.visibility="visible";
			else
				document.getElementById(element).style.visibility="hidden";
		}
	}
}