// Support Script (776)
function AddToValidateArray(strElementName)
{
    var strName = strElementName

    if (!document.ValidateArray) 
    {
        document.ValidateArray = new Array
    }

    document.ValidateArray[document.ValidateArray.length] = strName
}

// Support Script (650)
function ValidateEMail()
{
   var msg = "";
   var val = this.getText();
   var msgInvalid = "Inserisci il tuo indirizzo e-mail correttamente\n(esempio: clienti@planethair.it)";

  	var theLen = StripChars(" ",val).length
	  if (theLen == 0)	
		  if (!this.Required) return ""		
		  else return "Required field.  " + msgInvalid

   if (val.indexOf("@",0) < 0) 
   {
      msg = msgInvalid 
   }
   return msg;
}

// Support Script (800)
function StripChars(theFilter,theString)
{
	var strOut,i,curChar

	strOut = ""
	for (i=0;i < theString.length; i++)
	{		
		curChar = theString.charAt(i)
		if (theFilter.indexOf(curChar) < 0)	// if it's not in the filter, send it thru
			strOut += curChar		
	}	
	return strOut
}

function AllInRange(x,y,theString)
{
	var i, curChar
	
	for (i=0; i < theString.length; i++)
	{
		curChar = theString.charAt(i)
		if (curChar < x || curChar > y) //the char is not in range
			return false
	}
	return true
}


function reformat (s)
{
    var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) 
           resultString += arg;
       else 
       {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function Trim(theString)
{
 var i,firstNonWhite

 if (StripChars(" \n\r\t",theString).length == 0 ) return ""

	i = -1
	while (1)
	{
		i++
		if (theString.charAt(i) != " ")
			break	
	}
	firstNonWhite = i
	//Count the spaces at the end
	i = theString.length
	while (1)
	{
		i--
		if (theString.charAt(i) != " ")
			break	
	}	

	return theString.substring(firstNonWhite,i + 1)

}
// Support Script (770)
function Validate(stopOnFailure)
{
	var ErrorMsg = "";
	var i
	var msg
	var tofocus = true;
	var ErrorMsg = "";
	
	// Go through the Validate Array that may or may not exist
	// and call the Validate function for all elements that have one.
	if (document.ValidateArray)
	{
		for (i = 0; i < document.ValidateArray.length; i ++)
		{
			msg = eval( document.ValidateArray[i] + ".Validate()")
			if (msg != "")
			{
				ErrorMsg += "\n\n" + document.ValidateArray[i] + ":  " + msg;
				if (tofocus) 
				{
					eval(document.ValidateArray[i] + ".focus()")
					tofocus = false;
				}
				
				if (stopOnFailure == "1") return ErrorMsg;
			}
  	}
  }
	return ErrorMsg;
}

function document_onLoad() {
if (String(PasswordCookie.getValue("eStoreUserName"))!="null")
  Iscritto.setText(PasswordCookie.getValue("eStoreUserName"));
Iscritto.Validate = ValidateEMail;
Iscritto.Required = Number("1");
AddToValidateArray("Iscritto")
 }
function Form1_onSubmit() {
errorMsg = Validate("0"); // don't stop on first error

if (errorMsg != "")
    alert("The form could not be submitted:" + errorMsg);

return (errorMsg == ""); // false prevents form submission
 }
function _Form1_onSubmit() { if (Form1) return Form1.onSubmit(); }
function Moda_onClick() {
var options="";
options+="status="+(("0"=="1")?"yes":"no")
options+=",directories="+(("0"=="1")?"yes":"no")
options+=",location="+(("0"=="1")?"yes":"no")
options+=",toolbar="+(("0"=="1")?"yes":"no")
options+=",menubar="+(("0"=="1")?"yes":"no")
options+=",scrollbars="+(("1"=="1")?"yes":"no")
options+=",resizable="+(("1"=="1")?"yes":"no")

if (parseInt("365")  > 0) options+=",width="+"365"
if (parseInt("450") > 0) options+=",height="+"450"

if (parseInt("10") >= 0)
{
	options+=",top="+"10"
	options+=",screenY="+"10"
}
if (parseInt("10") >= 0)
{
	options+=",left="+"10"
	options+=",screenX="+"10"
}

page = "";
if (page.length == 0) page = "news.asp";

window.open(page,"NewWindow",options);
 }
function _Moda_onClick() { if (Moda) return Moda.onClick(); }
function Check1__onClick() {
alert("Deselezionandola casella non siamo autorizzati ad utilizzare i Tuoi dati personali, per aderire al Servizio la casella deve essere selezionata.");
window.close()
 }
function _Check1__onClick() { if (Check1) return Check1.onClick(); }
function iscrivo__onClick() {
PasswordCookie.setValue("eStoreUserName",Iscritto.getText());
 }
function _iscrivo__onClick() { if (iscrivo) return iscrivo.onClick(); }

