//this Javascript file will be in use from 22/8/05


//checks amount of characters entered into textarea
//and displays how many characters left to enter

function textCounter(field, countfield, maxlimit) 
{
if (field.value.length > maxlimit) // if too long...trim it!

	{
	field.value = field.value.substring(0, maxlimit)
	alert ("Sorry, any characters beyond this will be deleted!")
	}
// otherwise, update 'characters left' counter
else 
	{
	countfield.value = maxlimit - field.value.length;
	}
}


//checks that a '@' is in the email string
//and that there is more than one character between the '@' sign and the dot which is after the '@' sign
//and that there isn't more than 4 characters in the email address suffix
//and that there isn't less than 2 characters in the email address suffix

function getcode(form1,opt)
{
    if (form1.phone_country_code != null && form1.country != null)
        form1.phone_country_code.value=form1.country[form1.country.selectedIndex].id;
}

function emailvalidation(entered)
{
	with (entered)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;

	if (entered.value!="") 
		{
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
			{			
				alert("Please check the email")
				return false;
			} 
				
			else 
			{
				return true;
			}
		}
	}
}
function emailvalidation_pl(entered)
{
	with (entered)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;

	if (entered.value!="") 
		{
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
			{			
				alert("Prosze zweryfikowac email")
				return false;
			} 
				
			else 
			{
				return true;
			}
		}
	}
}

function emailvalidation_pt(entered)
{
	with (entered)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;

	if (entered.value!="") 
		{
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
			{			
				alert("Por favor confirme o seu email")
				return false;
			} 
				
			else 
			{
				return true;
			}
		}
	}
}

//checks a character and allows only spaces, letters of the English alphabet, numbers, or cerain characters to pass as valid input. 

 function IsAlphaNumeric()
   {
	//alert(event.keyCode)
	
	  if( event.keyCode<10 ||  (event.keyCode>10  & event.keyCode<13) ||  (event.keyCode>13  & event.keyCode<32) || (event.keyCode==35) || (event.keyCode==37) || (event.keyCode==47) || (event.keyCode>59 & event.keyCode<63) || (event.keyCode>125 & event.keyCode<128)  || (event.keyCode>255 & event.keyCode<1488) || event.keyCode>1514)  
	   
	   {
	    alert("This type of character is not allowed")
	   
		event.keyCode=0
	   }   
   }

//checks a string and allows only spaces, letters of the English alphabet, numbers, or cerain characters to pass as valid input. 

function IsAlphaNumericString(a)
{
	var s
	var i
	for (i=0;i<a.length-1;i++)
	{
	s = a.charCodeAt(i)


	//alert(a.charCodeAt(i))
	if(s<10 || (s>10 & s<13) || (s>13 & s<32) || (s==35) || (s==37) || s==47 || (s>59 & s<63) || (s>125 & s<128)  || (s>255 & s<1488) || s>1514)  
	   
	   {
	    alert("This type of character is not allowed")	   
		return false;
	   }
	}
}	

function trimString (str) 
{
 // str = this != window? this : str;
  //alert (str)
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

//Created 28/6/06 for allowing English characters, numbers and a limited number of characters
//This is added to the span within the Form.
 function IsEnglish()
   {
	  //alert(event.keyCode)
	  if(event.keyCode<10 ||  (event.keyCode>10  & event.keyCode<13) ||  (event.keyCode>13  & event.keyCode<32) || (event.keyCode==35) || (event.keyCode==37) || (event.keyCode==47) || (event.keyCode>59 & event.keyCode<63) || (event.keyCode>90 & event.keyCode<95) || event.keyCode>122)  
	   
	   {
	    
	    alert("This type of character is not allowed")
	   
		event.keyCode=10
	   }   
   }

//Created 28/6/06 for allowing English characters, numbers and a limited number of characters

function IsEnglishForJavaScript(a)
{
	var s
	var i
	for (i=0;i<a.length-1;i++)
	{
	s = a.charCodeAt(i)
	
	//alert(a.charCodeAt(i))
			
	if(s<10 || (s>10 & s<13) || (s>13 & s<32) || (s==35) || (s==37) || (s==47) || (s>59 & s<63) || (s>90 & s<95) || s>122)  
	   
	   {
	    alert("This type of character is not allowed")	   
		return false;
	   }
	}
}	

function NoSpacesForJavaScript(a)
{
	var s
	var i
	for (i=0;i<a.length-1;i++)
	{
	s = a.charCodeAt(i)
	
	//alert(a.charCodeAt(i))
			
	if(s==32)  
	   
	   {
	    alert("No spaces are allowed here")	   
		return false;
	   }
	}
}


 function IsEnglish_NoSpaces()
   {
	  //alert(event.keyCode)
	  if(event.keyCode<10 ||  (event.keyCode>10  & event.keyCode<13) ||  (event.keyCode>13  & event.keyCode<33) || (event.keyCode==35) || (event.keyCode==37) || (event.keyCode==47) || (event.keyCode>59 & event.keyCode<63) || (event.keyCode>90 & event.keyCode<95) || event.keyCode>122)  
	   
	   {
	    
	    alert("This type of character is not allowed")
	   
		event.keyCode=10
	   }   
   }
