//////////////////////////////////////
platform_client = navigator.platform;
var obj_global;
var code_global;
var isIE = false;
// global request and XML document objects
var req;
var version = "";

if (platform_client == "Win32") {
	if (navigator.appVersion.indexOf("4.")!=-1) {
		var version = "IE7";
	}
}
//////////////////////////////////////
function changebg() {
	intro_m = document.getElementById('intro');
	intro_m.style.display = "none";

	head = document.getElementById('header');
	head.style.display = "";
	
	bod = document.getElementById('body1');
	bod.style.display = "";
}
//#############################################
/**###################################################################################**/
/**###################################################################################**/
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) { 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

	document.write(str);
}

function AC_FL_RunContent() {
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
	
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent() {
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/**###################################################################################**/
/**###################################################################################**/

//////////////////////////////////////
platform_client = navigator.platform;
var obj_global;
var code_global;
var isIE = false;
// global request and XML document objects
var req;
//////////////////////////////////////
//#############################################
function update(obj) {
	ff = document.getElementsByTagName("form");
	for (i = 0; i < ff.length; i++) {
		if (ff[i].id == obj) {
			obj = ff[i];
		}
	}
	obj.submit();
}

function openWindow(url, name, width, height, params, position) {
	if (position == "center") {
		l = (screen.width - width) / 2;
		t = (screen.height - height) / 2;
		params = params + ",top="+t+",left="+l+",";
	}
	params = "width="+width+",height="+height+","+params;
	popupWin = window.open(url, name, params)
}

//#############################################
///////////////////////////////////////////////////////////
function maxchar(obj,maxchr) {
	var chr_div = document.getElementById("chr");
	
	var original_txt_div = document.getElementById("original_txt");
	var txt_o_length = original_txt_div.innerText.length;
	var txt_length = obj.innerText.length;
	
	chr_div.innerHTML = "[" + txt_length + " / " + txt_o_length + "]";
	if (txt_length >= txt_o_length) {
		
		event.cancelBubble=true;
		event.returnValue=true;
		event.keyCode=0;

	}
}
//#############################################
function isValidEmail(email) {
	if (! allValidChars(email)) {  // check to make sure all characters are valid
		return false;
	}
	
	if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
		return false;
	} else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
		return false;
	} else if (email.indexOf("@") == email.length) {  // @ must not be the last character
		return false;
	} else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		return false;
	} else if (email.indexOf(".") == email.length) {  // . must not be the last character
		return false;
	}
	
	return true;
}
//#############################################
function allValidChars(email) {
	var parsed = true;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
	for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
			continue;
		parsed = false;
		break;
	}
	return parsed;
}
//#############################################
function mailto(domain,user) {
	document.location.href = "mailto:" + user + "@" + domain; 
}
//#############################################
function openpan_m0(sizem,obj,element) {
	sizem = sizem*1;
	for (var i=1; i < sizem; i++) {
		var n = "m"+i;
		var na = "am"+i;
		if (n != obj && document.getElementById(n) != null)
			document.getElementById(n).style.display = "none";
			document.getElementById(na).className = "menu";	
	}
	
	var na = "a"+obj;
	document.getElementById(na).className = "menu1";
	
	ff = document.getElementsByTagName(element);
	for (i = 0; i < ff.length; i++) {
		if (ff[i].id == obj) {
			if (ff[i].style.display == "") {
				ff[i].style.display = "none";
			} else 
			if (ff[i].style.display == "none") {
				ff[i].style.display = "";
			}
		}
	}
}
//#############################################
function openpan(o) {
	var id_i = "i"+o;
	i = document.getElementById(id_i);
	isrc = i.src.split("/");
	isrc1 = "i/"+isrc[isrc.length-1];
	
	if (isrc1 == "i/arrow.gif") {
		i.src = "i/arrow1.gif";
	} else {
		i.src = "i/arrow.gif";	
	}
	
	obj = document.getElementById(o);
	if (obj.style.display == "none") {
		obj.style.display = "";
	} else {
		obj.style.display = "none";	
	}
}
//################################################
//################################################
function checkform_prenotaprova(){
	var errors="";
	var ritorno="";
	if (document.form.dtprova.selectedIndex==0)
		{
		errors+="- Selezionare una tra quelle disponibili. \n";
		if (ritorno==""){
			ritorno="dtprova";
		}
       }
	if (document.form.nome.value=="")
		{
		errors+="- Inserire il nome. \n";
		if (ritorno==""){
			ritorno="nome";
		}
       }
	if (document.form.cognome.value=="")
		{
		errors+="- Inserire il cognome. \n";
		if (ritorno==""){
			ritorno="cognome";
		}
       }
	if (document.form.email.value=="") {
		errors+="- Inserire l\' email.\n";
		if (ritorno==""){
			ritorno="email";
			}
		}
	if (document.form.email.value!="") {
			txt=document.form.email.value;
			if (txt.indexOf("@")==-1){
			errors+="Attenzione l'indirizzo email non č valido\n";
			if (ritorno==""){
				ritorno="email";
				}
			}else
			{
			txt1=txt.split("@");
			if (txt1[1].indexOf(".")==-1){
			errors+="Attenzione l'indirizzo email non č valido \n";
			if (ritorno==""){
				ritorno="email";
				}
			}
			}
	}
	if (document.form.p[0].checked==false && document.form.p[1].checked==false)
		{
		errors+="- Selezionare il consenso alla privacy. \n";
       }


	if (errors!="") {
		alert('Attenzione! :\n'+errors);
		if (ritorno!=""){
			document.form.elements[ritorno].focus();
		}
		return false;
	}
return true;
}
/////////////////////////////////////////
function checkform_rivenditore(){
	var errors="";
	var ritorno="";
	if (document.form.nome.value=="")
		{
		errors+="- Inserire il nome. \n";
		if (ritorno==""){
			ritorno="nome";
		}
       }
	if (document.form.cognome.value=="")
		{
		errors+="- Inserire il cognome. \n";
		if (ritorno==""){
			ritorno="cognome";
		}
       }
	if (document.form.societa.value=="")
		{
		errors+="- Inserire la societā. \n";
		if (ritorno==""){
			ritorno="societa";
		}
       }
	if (document.form.indirizzo.value=="")
		{
		errors+="- Inserire l\' indirizzo. \n";
		if (ritorno==""){
			ritorno="indirizzo";
		}
       }
	if (document.form.cap.value=="")
		{
		errors+="- Inserire il cap. \n";
		if (ritorno==""){
			ritorno="cap";
		}
       }
	if (document.form.citta.value=="")
		{
		errors+="- Inserire la cittā. \n";
		if (ritorno==""){
			ritorno="citta";
		}
       }
	if (document.form.prov.value=="")
		{
		errors+="- Inserire la provincia. \n";
		if (ritorno==""){
			ritorno="prov";
		}
       }
	if (document.form.nazione.value=="")
		{
		errors+="- Inserire la nazione. \n";
		if (ritorno==""){
			ritorno="nazione";
		}
       }
	if (document.form.email.value=="") {
		errors+="- Inserire l\' email\n";
		if (ritorno==""){
			ritorno="email";
			}
		}
	if (document.form.email.value!="") {
			txt=document.form.email.value;
			if (txt.indexOf("@")==-1){
			errors+="Attenzione l'indirizzo email non č valido\n";
			if (ritorno==""){
				ritorno="email";
				}
			}else
			{
			txt1=txt.split("@");
			if (txt1[1].indexOf(".")==-1){
			errors+="Attenzione l'indirizzo email non č valido \n";
			if (ritorno==""){
				ritorno="email";
				}
			}
			}
	}
	if (document.form.telefono.value=="")
		{
		errors+="- Inserire il telefono. \n";
		if (ritorno==""){
			ritorno="telefono";
		}
       }
	if (document.form.p[0].checked==false && document.form.p[1].checked==false)
		{
		errors+="- Selezionare il consenso alla privacy. \n";
       }


	if (errors!="") {
		alert('Attenzione! :\n'+errors);
		if (ritorno!=""){
			document.form.elements[ritorno].focus();
		}
		return false;
	}
return true;
}
