///////////////////////////////////////////////////////////////////////////////////////
//                                   AS_Scripts                                      //
//   © Copyright 1999-2002 ACTIVE STUDIO eBusiness Solutions - All rights reserved!  //
//              http://www.activestudio.com - info@activestudio.com                  //
///////////////////////////////////////////////////////////////////////////////////////


//Menu
var blnLoadCheck = false;
var intItems = 7;

function preloadImages()
{
        if (document.images) {

                for (var i=0; i<intItems; i++ )
                {
                	eval('im'+i+'=new Image()');
                        eval('im'+i+'.src="images/menu/item'+i+'over.gif"');
                }
                blnLoadCheck = true;
                changeImages(intSelectedItem, 1);
        }
}

function changeImages(aintItem, blnState)
{
        if (document.images && (blnLoadCheck == true))
        {
                if (blnState)
                {
                        document.images['menu'+aintItem].src = 'images/menu/item'+aintItem+'over.gif';
                }
                else
                {
                  if (intSelectedItem != aintItem)
                  {
                        document.images['menu'+aintItem].src = 'images/menu/item'+aintItem+'.gif';
                  }
                }
        }
}
//End Menu

	var layer_names = new Array ("solutionslayer");

	function show_layer (layer)
	{
	   if (navigator.appName == 'Netscape' && document.layers != null)
	   {
	     document.layers[layer].visibility = 'show';
	   }
	   else if (document.all != null) //IE
	   {
	     document.all[layer].style.visibility = 'visible';
	   }
	   else if (document.getElementById) //NS7
	   {
		 document.getElementById(layer).style.visibility = "visible"; 
	   }
	   hide_other_layers (layer);
	}

	function hide_other_layers (layer)
	{
	  var layerArray;
	  for (i=0; i<layer_names.length; i++)
	  {
	     if (layer_names[i] == layer)
		   continue;
	     if (navigator.appName == "Netscape" && document.layers != null)
	     {
		   document.layers[layer_names[i]].visibility = "hide";
	     }
	     else if (document.all != null) //IE
	     {
		   document.all[layer_names[i]].style.visibility = "hidden";
	     }
	     else if (document.getElementById) //NS7
	     {
		   document.getElementById(layer_names[i]).style.visibility = "hidden"; 
	     }
	  }
	}

var iTimerID
function hideSubLayer(){
   iTimerID = window.setTimeout("hide_other_layers()", 1000);
}

function clearHideSubLayer(){
   if (iTimerID != undefined) {
     window.clearTimeout(iTimerID)
   }
}


function isValidEmail(s) {
	rex=true;
	if (window.RegExp) {
		st="a";
		ex=new RegExp(st);
		if (st.match(ex)) {
			r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			b=(!r1.test(s)&&r2.test(s));
		} 
		else {
			rex=false;
		}
	} else {
		rex=false;
	  }
	if(!rex) 
		b=(s.indexOf("@")>0&&s.indexOf(".")>0&&s!="");
	return (b);
}

function checkInfo(theForm) {
        switch (theForm.name) {

          case "subscribe":

                if(!isValidEmail(theForm.email.value)) {
			alert("Prego, inserire un indirizzo email del tipo id@dominio.xxx o id@dominio.xx.xxx");
                        with (theForm.email) {
                                focus();
                                select();
                        }
                return;
                }
                theForm.submit();
                break;

          case "submit":

            if (theForm.fullname.value == "") {
                    alert("Inserire un valore per il campo \"Nome e Cognome\"");
                    with (theForm.fullname) {
                            focus();
                            select();
                    }
                    return false;
            }
            break;


            if (theForm.email.value == "") {
                    alert("Inserire un valore per il campo \"E-mail\"");
                    with (theForm.email) {
                            focus();
                            select();
                    }
                    return false;
            }
            break;
 
            if(!isValidEmail(theForm.email.value)) {
                    alert("Prego, inserire un indirizzo email del tipo id@dominio.xxx o id@dominio.xx.xxx");
                    with (theForm.email) {
                            focus();
                            select();
                    }
                    return false;
            }
            break;
 
            if (theForm.message.value == "") {
                    alert("Inserire un valore per il campo \"Informazioni\"");
                    with (theForm.message) {
                            focus();
                            select();
                    }
                    return false;
            }

        }//end switch
  }


//Popup window
var popupWin
function openWindow(astrURL) {
  var strFeatures
  switch (astrURL) {
   case "company.htm" :
       strFeatures = "top=0,left=0,width=400,height=308";
           break;
   case "vision.htm" :
       strFeatures = "top=0,left=0,width=400,height=322";
           break;
   case "products.htm" :
       strFeatures = "top=0,left=0,width=520,height=580,scrollbars=yes";
           break;
   case "services.htm" :
       strFeatures = "top=0,left=0,width=400,height=432";
           break;
   case "process.htm" :
       strFeatures = "top=0,left=0,width=400,height=534";
           break;
   case "contacts.htm" :
       strFeatures = "top=0,left=0,width=300,height=235";
           break;
   case "news.htm" :
       strFeatures = "top=0,left=0,width=178,height=236,scrollbars=yes";
       break;
   case "portfolio.htm" :
       strFeatures = "top=0,left=0,width=650,height=533,scrollbars=yes";
       break;
   }
  if (typeof(popupWin) != "undefined")
    popupWin.close();
  Popup = null;
  popupWin = window.open(astrURL,"Popup",strFeatures);
  popupWin.focus();
}
