// Messo in un file 21/1/2003
//<script Language="JavaScript">
//<!--


function textCounter(field, countfield, maxlimit) 
	{
	/*
	* The input parameters are: the field name;
	* field that holds the number of characters remaining;
	* the max. numb. of characters.
	*/ 
		if (field.value.length > maxlimit) 	// if the current length is more than allowed
			field.value =field.value.substring(0, maxlimit); // don't allow further input
		else
			countfield.value = maxlimit - field.value.length; // set the display field to remaining number
	}
	
	
function clearField(textField)
	{
		var tv = textField.value.toString();
		var defValue = "<%=strRetypeEmail%>";
		if(tv.toLowerCase()==defValue.toLowerCase())   { textField.select();	}
	}


function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1){ return""; }
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){ return "";}
	else { return TRIM_VALUE;}
} //End Function

function RTrim(VALUE)
{
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
	if(v_length < 0){return"";}

var iTemp = v_length -1;

while(iTemp > -1)
	{ 
		if(VALUE.charAt(iTemp) == w_space){ }
		else { 
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
		iTemp = iTemp-1;
	} //End While
return strTemp;

} //End Function

function LTrim(VALUE)
{
var w_space = String.fromCharCode(32);
	if(v_length < 1){return"";}

var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length)
{
	if(VALUE.charAt(iTemp) == w_space) { }
	else {
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		 }
	iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function PwdReqValidator(theForm)
{
	
  if (theForm.email.value == "")  {
    alert("Please enter the email you used in the affiliate form.");
    theForm.email.focus(); return (false); }
  
  return (true);
}

function ReqValidator(theForm)
{
//if (theForm.NoTerms.value == "Person")		{			per ora su questo sito ci sono solo PERSONE che si possono affiliare
		if (theForm.Name.value == "")  {
	    alert("Please enter your name in the \"Name and Surname\" field.");
	    theForm.Name.focus(); return (false);  }
	  
	  if (theForm.city.value == "") { 
  		alert("Plese insert the CITY where you live");
  		theForm.city.focus();  return (false);  }
  
		if (theForm.Country.value == "") { 
			alert("Plese insert the COUNTRY where you live");
			theForm.Country.focus();  return (false);  }	
	  
		if (theForm.email.value == "")  {
			alert("Please enter a value for the \"E-mail\" field.");
			theForm.email.focus(); return (false); }
  
 	var e1 = Trim(theForm.email.value.toLowerCase());
	var e2 = Trim(theForm.email2.value.toLowerCase());
  
  	if (!(e1 == e2))  {
    	alert("Please check e-mail: you retyped a different address in the \"CONFIRM EMAIL\" field.\r\nIf you wish to specify an alternative e-mail, use the \"ALTERNATIVE EMAIL\" field");
    	theForm.email.focus(); return (false);  }
  
  	if (theForm.password.value == "")  {
			alert("Please choose a password to enter the affiliate area.");
			theForm.password.focus(); return (false); }
		if (theForm.password.value.length < 6)  {
			alert("Password must be at least 6 characters long\r\nPlease choose another password.");
			theForm.password.focus(); return (false); } 
   
   
   	if (theForm.hceck.value == "")  {
    	alert("Please enter the correct result of the operation");
    	theForm.hceck.focus(); return (false); }
    if (!(Trim(theForm.hceck.value) == "27")) {
	    alert("Please enter the correct result of the specified operation. \r\nThis is a form to prevent spam.");
	    theForm.hceck.focus(); return (false); }
   
 	 	if (!theForm.terms.checked) { 
  		alert("In order to submit your affiliate request, you have to accept our Terms and Conditions.\r\nPlease select the checkbox below our Terms and Conditions in order to proceed");
  		theForm.terms.focus();  return (false);  }
  
  	
  return (true);
}


function ContactReqValidator(theForm)
	{
	  if (theForm.Name.value == "")  {
	    alert("Please enter your name and surname in the \"Name\" field.");
	    theForm.Name.focus(); return (false);  }
	  
	  if (theForm.email.value == "")  {
	    alert("Please enter a value for the \"E-mail\" field.");
	    theForm.email.focus(); return (false); }
		
		var e1 = Trim(theForm.email.value.toLowerCase());
		var e2 = Trim(theForm.email2.value.toLowerCase());
		
	  if (!(e1 == e2))  {
	    alert("Please check e-mail: you retyped a different address.\r\nIf you wish to specify an alternative e-mail, use the \"Comments - Questions\" field");
	    theForm.email2.focus();theForm.email2.select(); return (false);  }
	  
	  if (theForm.comments.value.length < 4)  {
	    alert("Please enter your question or issue in the \"Comments\" field.");
	    theForm.comments.focus(); return (false); }
	  
	  if (theForm.hceck2.value == "") {
	    alert("Please enter the correct result of the specified operation. \r\nThis is a form to prevent spam.");
	    theForm.hceck2.focus(); return (false); }
	  if (!(Trim(theForm.hceck2.value) == "12")) {
	    alert("Please enter the correct result of the specified operation. \r\nThis is a form to prevent spam.");
	    theForm.hceck2.focus(); return (false); }
	
	  return (true);
	}
	
function opentermsPopup()
	{
		var	new_window = window.open("terms.htm", "Termsandconditions", 'toolbar=0,scrollbars=1,width=650,height=580,location=0,statusbar=0,menubar=0')
	}
function OpenNewWindow(pagina)
	{
		var	new_window = window.open(pagina, "ServInfo", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=380,height=300')
	}

//-->
//</script>
