<!--Menu principale

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		menu_01_over = newImage("../inc/img/menu/menu_01-over.gif");
		menu_01_down = newImage("../inc/img/menu/menu_01-down.gif");
		menu_02_menu_01_over = newImage("../inc/img/menu/menu_02-menu_01_over.gif");
		menu_02_menu_01_down = newImage("../inc/img/menu/menu_02-menu_01_down.gif");
		menu_03_menu_01_over = newImage("../inc/img/menu/menu_03-menu_01_over.gif");
		menu_03_menu_01_down = newImage("../inc/img/menu/menu_03-menu_01_down.gif");
		menu_04_menu_01_over = newImage("../inc/img/menu/menu_04-menu_01_over.gif");
		menu_04_menu_01_down = newImage("../inc/img/menu/menu_04-menu_01_down.gif");
		menu_05_menu_01_over = newImage("../inc/img/menu/menu_05-menu_01_over.gif");
		menu_05_menu_01_down = newImage("../inc/img/menu/menu_05-menu_01_down.gif");
		preloadFlag = true;
	}
}

// -->

function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.0
  document.MM_returnValue = true;
  if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/s/gi,"") + ")$","i");
  for (var i = 0; i<form.elements.length; i++) {
    field = form.elements[i];
    if (field.type.toUpperCase() != 'FILE') continue;
    if (field.value == '') {
      if (requireUpload) {alert('File mancante!');document.MM_returnValue = false;field.focus();break;}
    } else {
      if(extensions != '' && !re.test(field.value)) {
        alert('Questo tipo di file non è valido.\nLe estensioni valide sono: ' + extensions + '.\nScegli un altro file e riprova.');
        document.MM_returnValue = false;field.focus();break;
      }
    document.PU_uploadForm = form;
    re = new RegExp(".(gif|jpg|png|bmp|jpeg)$","i");
    if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {
      checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
    } } }
}
function showHelp() {
	var newWindow;
	var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=700,height=500,top=100,left=200';
	newWindow = window.open('../servizi/help.asp', 'Guida_in_Linea', props);
}
function openEditor(url) {
	var newWindow;
	var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=600,height=450,top=100,left=200;help: No';
	//var props ="font-family:Verdana; font-size:12; dialogWidth:60em; dialogHeight:45em;help: No;";
	newWindow = window.open(url, 'Editor', props);
	//newWindow = window.showModelessDialog (url,"", props);
	//if (newWindow != null) location.reload(true);
}
function fileupload(objtext,url)	{
	var arr = showModalDialog(url,"","font-family:Verdana; font-size:12; dialogWidth:45em; dialogHeight:24em;help: No;" );
	if (arr != null) objtext.value=arr;	
}
function foreColor()	{
	var arr = showModalDialog("../servizi/selcolor.asp","","font-family:Verdana; font-size:12; dialogWidth:45em; dialogHeight:24em;help: No;" );
	if (arr != null) wizard.ColorBody.value=arr;	
}
function button_prev()	{
	var step= document.wizard.Step.value;
	step --;
	document.wizard.action = "wizard.asp?type=upd&page=" + step;
    document.wizard.submit();
}
function doIt(theForm){
  var SiteTemplate = new Array('Pagina Personale','Sito Standard','Sito Aziendale','Sito Personalizzato');
  var pagerType = new Array('text', 'text', 'text', 'alpha');
  var arrayPos;
  var theSelect = theForm.sitetype

  var theDiv = document.getElementById('dynArea');
  var theDivDesc = document.getElementById('dynDesc');

 if(theSelect.value != -1){
    for(i=0;i<SiteTemplate.length;i++){
       if(SiteTemplate[i] == theSelect[theSelect.selectedIndex].text)
             arrayPos = i;
     }
     if(pagerType[arrayPos] == 'alpha'){
        theDiv.innerHTML = '<textarea cols=30 rows=10 name=pages></textarea>';
		theForm.siteTemplate.disabled = true;
		theDivDesc.innerHTML = 'Descrizione della prestazione:<br>'}
     else{
        theDiv.innerHTML = '<input type=textbox readonly="true" name=pages value="'+theSelect.value+'">';
		theForm.siteTemplate.disabled = false;
		theDivDesc.innerHTML = 'Numero di pagine presenti nel pacchetto:'}
 }
 else
   theDiv.innerHTML = ''
}

function validateEmail(email)
{
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }
      return true;
    }
return false;
}

function checkform(){
	var objValue = document.wizard.siteTemplate;
	var  strError = ""; 
	 for (i=0; i<objValue.length; i++){
            if (objValue[i].checked) break;
      }
      if (i >= objValue.length){
            if(!strError || strError.length ==0) 
              { 
              strError =  "Occore selezionare un modello di sito!";
              }//if                                                               
              alert(strError); 
              return false;   
     }
	objValue = document.wizard.sitetype; 
	if(objValue.selectedIndex == "0") 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = " Occorre selezionare la tipologia di sito richiesto! "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
	 
	 return true;
}
function checkpages(){
 var objValue = document.wizard.PageSelector;
 var  strError = ""; 
	 if (objValue.length == undefined){
	 	if (!objValue.checked) {
	 	strError =  "Occore selezionare un elemento!";
		alert(strError); 
        return false;
		}
	 }
	 for (i=0; i<objValue.length; i++){
            if (objValue[i].checked) break;
      }
      if (i >= objValue.length){
            if(!strError || strError.length ==0) 
              { 
              strError =  "Occore selezionare un elemento!";
              }//if                                                               
              alert(strError); 
              return false;   
     }
 return true;
}

function checkRegister(){
 var objValue = document.frmRegister.Nome;
 var  strError = ""; 
	if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError ="Campo Obbligatorio: Nome"; 
              }//if 
              alert(strError); 
              return false; 
           }//if
 objValue = document.frmRegister.Cognome;  
   if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError ="Campo Obbligatorio: Cognome"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
 objValue = document.frmRegister.Mail;  
   if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError ="Campo Obbligatorio: E-Mail"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
 	if(!validateEmail(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = "L' indirizzo E-Mail non è valido "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if
 objValue = document.frmRegister.Tel; 
 	if(objValue.value.length < 6) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = "Campo Obbligatorio: Telefono"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
 var charpos = objValue.value.search("[^0-9]"); 
      if(objValue.value.length > 0 &&  charpos >= 0) 
      { 
        if(!strError || strError.length ==0) 
        { 
          strError = "Il numero di telefono non è valido"; 
        }//if               
        alert(strError); 
        return false; 
      }//if  
 objValue = document.frmRegister.Username;  
   if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError ="Campo Obbligatorio: UserName"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
 objValue = document.frmRegister.privacy; 
 
 if (!objValue.checked) {
	 	strError =  "Manca il consenso ai dati personali";
		alert(strError); 
        return false;
		}
 return true;
}
