	 function isBlank(strValue)
	 {
		 for(var i = 0; i < strValue.length; i++)
		 {
			 var c = strValue.charAt(i);
			 if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
		 }
		 return true; 
	 }
	function matchExpression(expression,inputString)
	{
		if(inputString.search(expression)==-1)
		{
			return false;
		}
		else
		{
			return true;
		}
	}	
	function isValidEmail(inputString)
	{
		var expression = /^([a-zA-Z0-9]{1}[-a-zA-Z0-9_\.]*)@([-a-zA-Z0-9]+)([\.][a-zA-Z]+){1,3}$/;
		if (isBlank(inputString))
		{
			return false;
		}	
		return matchExpression(expression,inputString);
	}
	
	function isValidUserName(inputString)
	{
		var expression = /^[a-zA-Z0-9]$/;
		return matchExpression(expression,inputString);
	}
	
	 function isValidString(strVal) 
	 {
		 var regex = /^[_]*[a-zA-Z_]+[a-zA-Z0-9_]+$/; 
		 if (isBlank(strVal))
		 {
			return false;
		 }		
		 return matchExpression(regex,strVal);
	 }


	 function IsAlphaNumeric(strVal) 
	 {
		 var regex = /^[a-zA-Z]+[0-9]+[a-zA-Z0-9]*$/; 
		 if (isBlank(strVal))
		 {
			return false;
		 }		
		 return matchExpression(regex,strVal);
	 }

	function IsAlpha(strVal) 
	 {
		var regex = /^[a-zA-Z]*$/; 
		if (isBlank(strVal))
		{
			return false;
		}		
		return matchExpression(regex,strVal);
		
	 }
	function IsNumber(strVal) 
	{
		var regex = /^[0-9]*$/; 
		if (isBlank(strVal))
		{
			return false;
		}		
		return matchExpression(regex,strVal);
		 
	 }
	function IsNotAlphaNumeric(strVal) 
	 {
		 var regex = /^[^a-zA-Z0-9]*$/; 
		 if (isBlank(strVal))
		 {
			return false;
		 }		
		 return matchExpression(regex,strVal);
	 }
	 
    
	 function IsValidPhone(strVal) 
	 {
		 var regex = /[0-9]{10,}/; 
		 if (isBlank(strVal))
		 {
			return false;
		 }		
		 return matchExpression(regex,strVal);
	 }

	
	 function LTrim(str)
	 {
		 if(str==null)
		{
			return str;
		}
		for(var i=0;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i++);
		return str.substring(i,str.length);
	 }

	
	 function RTrim(str)
	 {
		 if(str==null)
		{
			return str;
		}
		for(var i=str.length-1;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i--);
		return str.substring(0,i+1);
	 }

	
	 function Trim(str)
	 {
		 return LTrim(RTrim(str));
	 }


	 function stripHTMLTags(str) 
	 {
		 var mystr=""; 
		 var chr=""; 
		 var skip=false; 
		 var skipcancel=false; 
		 for (x=0; x<str.length; x++) 
		 {
			 if (skipcancel==true)
			 {
				 skip=false;
			 } 
			 chr=str.charAt(x); 
			 if (chr=="<")
			 {
				 skip=true;skipcancel=false;
			 } 
			 else if (chr==">" && skip==true)
			 {
				 skipcancel=true;
			 } 
			 if (skip==false) 
			 {
				 mystr=mystr+chr; 
			 }
		 }
		 return mystr; 
	 } 

	
	 function isValidNumber(numval) 
	 {
		 if (isBlank(numval))
		 {
			 return false;
		 }
		 var myRegExp = new RegExp("^[/+|/-]?[0-9]*[/.]?[0-9]*$"); 
		 return myRegExp.test(numval); 
	 }

	 function isValidDate(d) 
	 {
		 //var strDatestyle = "US"; //United States date style 
		 var strDatestyle = "EU";  //European date style 
		 var strDate; 
		 var strDateArray; 
		 var strDay; 
		 var strMonth; 
		 var strYear; 
		 var intDay; 
		 var intMonth; 
		 var intYear; 
		 var booFound = false; 
		 var strSeparatorArray = new Array("-"," ","/","."); 
		 var intElementNr; 
		 var err = 0; 
		 var strMonthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); 
		 strDate = d; 
		 if (strDate.length < 1) 
		 {
			 return false; 
		 }
		 
		 if (strDate.toLowerCase()=="today" || strDate.toLowerCase()=="now")
		 {
			 return true;
		 }
		 
		 for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) 
		 {
			 if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
			 {
				 strDateArray = strDate.split(strSeparatorArray[intElementNr]); 
				 if (strDateArray.length != 3) 
				 {
					 err = 1; 
					 return false; 
				 }
				 else 
				 {
					 strDay = strDateArray[0]; 
					 strMonth = strDateArray[1]; 
					 strYear = strDateArray[2]; 
				 }
				 booFound = true; 
			 }
		 }

		 if (booFound == false) 
		 {
			 if (strDate.length>5) 
			 {
				 strDay = strDate.substr(0, 2); 
				 strMonth = strDate.substr(2, 2); 
				 strYear = strDate.substr(4); 
			 }
			 else 
			 {
				 return false; 
			 }
		 }

		 // verify year part   2 or 4 digits 
		 if (strYear.length != 2 && strYear.length != 4) 
		 {
			 return false;
		 }

		 if (isNaN(strYear))
		 {
			 return false;
		 }
		 
		 // US style (swap month and day) 
		 if (strDatestyle == "US") 
		 {
			 strTemp = strDay; 
			 strDay = strMonth; 
			 strMonth = strTemp; 
		 }

		 // verify 1 or 2 digit integer day 
		 if (strDay.length<1 || strDay.length>2) 
		 {
			 return false;
		 }
		 
		 if (isNaN(strDay))
		 {
			 return false;
		 }
		 
		 // month may be digits of characters, hence following check 
		 intMonth = parseInt(strMonth, 10); 
		 if (isNaN(intMonth)) 
		 {
			 for (i = 0;i<12;i++) 
			 {
				 if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) 
				 {
					 intMonth = i+1; 
					 strMonth = strMonthArray[i]; 
					 i = 12; 
				 }
			 }
			 if (isNaN(intMonth)) 
			 {
				 err = 3; 
				 return false; 
			 }
		 }

		 intDay=parseInt(strDay,10); 
		 intYear = parseInt(strYear, 10); 

		 if (intMonth>12 || intMonth<1) 
		 {
			 err = 5; 
			 return false; 
		 }

		 // day in month check 
		 if (intDay < 1 || intDay > 31)
		 {
			 return false;
		 }
		 
		 if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30)) 
		 {
			 return false; 
		 }

		 if (intMonth == 2) 
		 {
			 if (LeapYear(intYear)) 
			 {
				 if (intDay > 29) 
				 {
					 return false;
				 }
			 }
			 else 
			 {
				 if (intDay > 28) 
				 {
					 return false;
				 }
			 }
		 }

		 if (intYear<=99)
		 {
		      intYear=intYear+2000;
	     }
		 return intDay+"/"+intMonth+"/"+intYear; 
	 }

	 function isValidDateTime(strDateTime) 
	 {
		 var dt = Trim(strDateTime); 
		 var intMatch; 
		 var intDateOnly = false; 
		 if (strDateTime.toLowerCase()=="today" || strDateTime.toLowerCase()=="now")
		 {
			 return true;
		 }
		 
		 intMatch=dt.indexOf(":"); 
		 if (intMatch < 0) 
		 {
			 intDateOnly = true; 
			 intMatch=dt.length; 
		 }
		 else 
		 {
			 intMatch=dt.indexOf(" "); 
		 }
		 
		 if (intMatch < 0) 
		 {
			 return false;
		 }
		 
		 // check date 
		 if (!isValidDate(dt.substr(0,intMatch)))
		 {
			 return false;
		 }
		 
		 // check time 
		 if (!intDateOnly) 
		 {
			 if (!isValidTime(dt.substr(intMatch+1,dt.length-intMatch)))
			 {
				 return false;
			 }
		 }
		 return true; 
	 }

	
	 function LeapYear(intYear) 
	 {
		 if (intYear % 100 == 0) 
		 {
			 if (intYear % 400 == 0) 
			 {
				 return true; 
			 }
		 }
		 else 
		 {
			 if ((intYear % 4) == 0) 
			 { 
				 return true; 
			 }
		 }
		 return false; 
	 }

	
	 function NewWindow(url, title, w, h, scroll, resize) 
	 {
		 alert("c");
		 if (scroll==true || scroll=='yes') 
		 {
			 scroll='yes'; 
		 }
		 else 
		 {
			 scroll='no'; 
		 }
		 if (resize==true || resize=='yes') 
		 {
			 resize=', resizable'; 
		 }
		 else 
		 {
			 resize=''; 
		 }
		 var winl = (screen.width - w) / 2; 
		 var wint = (screen.height - h) / 2; 
		
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+resize;
		//win = window.open(url, title, winprops);
		win = window.open(url, title);
	 }


	 function fnSetFocus()
	 {
		var arr = new Array();
		arr = document.getElementsByTagName("input");
		var i =0;
		for (i =0 ; i <= arr.length; i++)
		{
			if (arr[i].type == "text")
			{
				arr[i].focus();
				break; 
			}
		}
	 }	

//Ask Anna functions
function y2k(number)

{

   return(number < 1000) ? number + 1900 : number;

}
function checkDate(day,month, year)

{

   // checks if date passed is valid

   // will accept dates in following format:

   // isDate(dd,mm,ccyy), or

   // isDate(dd,mm) - which defaults to the current year, or

   // isDate(dd) - which defaults to the current month and year.

   // Note, if passed the month must be between 1 and 12, and the

   // year in ccyy format.

   if(day=="" || month=="" || year==""){

   	  return 0;

   }   

   

   var today = new Date();

   year =((!year) ? y2k(today.getYear()) : year);

   month =((!month) ? today.getMonth() : month - 1);

   if(!day)

    return 0;

    

   var test = new Date(year, month, day);   

   var diff = today.getTime() - test.getTime();



   if((y2k(test.getYear()) == year) &&(month == test.getMonth()) &&(day == test.getDate()) && diff>0)

   {  

      return 1;

   }

   else 

   {

      //errorMessage += "Invalid date\n";

      return 0;

   }

} 

function checkAge(liMonth, liYear) {

	var ldToday = new Date();

	var liAge;

	liAge = ldToday.getFullYear() - liYear;

	if ( liMonth >= ldToday.getMonth()+1 ) {

		liAge = liAge - 1;

	}

	return liAge;

}

function resolveFocus(focussableObject){

	if(!focusInUse){

		focussableObject.focus();

		focusInUse=true;

	}

}
function validateEmail(email){	

	if(email=="")

		return 0;

	var at='@';

	var dot='.';	

	if (email.indexOf(at)==-1){

		return 0;

	}



	if ((email.indexOf(at)==-1) || (email.indexOf(at)==0) || (email.indexOf(at)==email.length)){

	   return 0;



	}

	if ((email.indexOf(dot)==-1) || (email.indexOf(dot)==0) || (email.indexOf(dot)==email.length)){

		return 0;

	}	

	//check to see if the first letter of email is a number

	//if its a number flag an error

	var numbers="0123456789";

	var strChar = email.charAt(0);

	if(numbers.indexOf(strChar) != -1) {

		return 0;

	 }

	var spchar="*'\"!^`;&><#";

	for(i=0;i<email.length;i++){

		var strChar=email.charAt(i);

		if(spchar.indexOf(strChar)!=-1) {

			return 0;

		}

	}

	return 1;

}

function trimAndFill(trimmableObject){

	if(trimmableObject.value == null || trimmableObject.value=="") return "";

	

	var val = Trim(trimmableObject.value);

	trimmableObject.value = val;

	return val;

}

