// JavaScript Document
    function checkdate(a){
        var err=0
        //    a=document.USER_INFO.Date.value;  
        if (a.length != 10) err=1;
        d= a.substring(0, 2);// day
        c = a.substring(2, 3);// '/'
        b = a.substring(3, 5);// month
        e = a.substring(5, 6);// '/'
        f = a.substring(6, 10);// year
        if((isNaN(b))||(isNaN(f))||(isNaN(d)))
        {
        	err=1;
        }

        if (b<1 || b>12) err = 1;
        if (c != '/') err = 1;
        if (d<1 || d>31) err = 1;
        if (e != '/') err = 1;
        if (f<1960 || f>2099) err = 1;
        if (b==4 || b==6 || b==9 || b==11)
        {
            if (d==31) err=1;
        }
        if (b==2)
        {
            var g=parseInt(f/4)
            if (isNaN(g)) {
                err=1;
            }
            if (d>29) err=1;
            if (d==29 && ((f/4)!=parseInt(f/4))) err=1;
        }
        if (err==1) {
            alert('Please Enter Valid Date');
            return false;
        } else {
			return true
		}
    }

function compareDates(objStartDate,objEndDate,objCity,objMonth){
	city		= objCity.options[objCity.selectedIndex].value
	month		= objMonth.options[objMonth.selectedIndex].value
	startDate	= trim(objStartDate.value)
	endDate		= trim(objEndDate.value)

	if(!isEmpty(startDate) && isEmpty(endDate)){
		alert("Please fill in the end date.")
		objEndDate.focus()
		return false
	}

	if(!isEmpty(endDate) && isEmpty(startDate)){
		alert("Please fill in the start date.")
		objStartDate.focus()
		return false
	}

	if(!isEmpty(startDate)){
		if(!checkdate(startDate)){
			objStartDate.focus()
			return false
		}
	}
	
	if(!isEmpty(endDate)){
		if(!checkdate(endDate)){
			objEndDate.focus()
			return false
		}
	}
	
	if(city == "0"){
		alert("Please select a city.")
		objCity.focus()
		return false
	}
	
	if(!isEmpty(endDate) && !isEmpty(startDate)){
		sDD	= startDate.substring(0,2)
		sMM	= startDate.substring(3,5)
		sYY	= startDate.substring(6,10)
		
		
		eDD	= endDate.substring(0,2)
		eMM	= endDate.substring(3,5)
		eYY	= endDate.substring(6,10)
		
		stDate = new Date(sYY,sMM,sDD)
		edDate = new Date(eYY,eMM,eDD)
						
		if(edDate < stDate){
			alert("End date should be greater than the start date.")
			objEndDate.focus()
			return false
		}
	} else if(month == 0) {
		alert("Please select a month")
		objMonth.focus()
		return false
	} 

	return true
}


function isAlpha(str,allowspaces,allowquotes){


	if(str == "") return false
	if(allowspaces == "" || typeof allowspaces == "undefined") allowspaces = 'y'
	if(allowquotes == "" || typeof allowquotes == "undefined") allowquotes = 'n'
	
	str = str.toLowerCase()

	if(allowspaces == 'y'){
		for(i =0; i < str.length; i++){
			if(str.charAt(i) != " "){
				if(allowquotes == 'y'){
					if(!(str.charAt(i) >= 'a' && str.charAt(i) <= 'z') && str.charAt(i) != "'"){
						return false
					}
				} else {
					if(!(str.charAt(i) >= 'a' && str.charAt(i) <= 'z')){
						return false
					}
				}
				
			}
		}
	}

	if(allowspaces == 'n'){
		for(i =0; i < str.length; i++){
			if(allowquotes == 'y'){
				if(!(str.charAt(i) >= 'a' && str.charAt(i) <= 'z') && str.charAt(i) != "'"){
					return false
				}
			} else {
				if(!(str.charAt(i) >= 'a' && str.charAt(i) <= 'z')){
					return false
				}
			}
		}
	}
	
	return true
}
function trim(str){

	strLength = str.length
	if(strLength == 0) return str
	while(str.charAt(0) == " "){
		str = str.substring(1,strLength)
		strLength = str.length
	}
	while(str.charAt(strLength-1) == " "){
		str = str.substring(0,strLength-1)
		strLength = str.length
	}
	return str
}

function trimArea(str){
	str = escape(str)
	strLength = str.length
	if(strLength == 0) return str
	while(str.substring(0,3) == "%20" || str.substring(0,6) == "%0D%0A"){
		if(str.substring(0,3) == "%20"){
			str = str.substring(3,strLength)
			strLength = str.length
		}
		if(str.substring(0,6) == "%0D%0A"){
			str = str.substring(6,strLength)
			strLength = str.length		
		}
	}
	while(str.substring(strLength-3,strLength) == "%20" || str.substring(strLength-6,strLength) == "%0D%0A"){
	
		if(str.substring(strLength-3,strLength) == "%20"){
			str = str.substring(0,strLength-3)
			strLength = str.length
		}
		if(str.substring(strLength-6,strLength) == "%0D%0A"){
			str = str.substring(0,strLength-6)
			strLength = str.length
		}		
	}

	return unescape(str)
}

function isObject(objProbable){
	if(typeof objProbable == "object"){
	  return true
	} else {
	  return false
	}
}
function isEmpty(str){
	str = trim(str)
	if(str.length == 0){
		return true
	} else {
		return false
	}
}
function isNumeric(num,allowFloats){
	
	if(num == "") return false
	num = num.toLowerCase();

	if(allowFloats == "" || typeof allowFloats == "undefined") allowFloats = 0

	if(allowFloats == 1){
		if(num.indexOf('e') == -1){
			if(num != parseFloat(num)){
				return false
			} else {
				return true
			}
		} else {
			return false
		}
	}
	
	if(allowFloats == 0){
		
		if(num.indexOf('e') == -1){
			if(num != parseInt(num,10)){
				return false
			} else {
				return true
			}
		} else {
			return false
		}
	}
	
}
function isEmail (s)
{	
   if (isEmpty(s)) 
      // if (isEmail.arguments.length == 1) return defaultEmptyOK;
    //   else return (isEmail.arguments[1] == false);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
	var k = 1; 
	var is_present=false;
    var sLength = s.length;

	//look for @ whether it is twice present in the string or not
	while(k < sLength)
	{
		if(s.charAt(k) == "@")
		{
			if(is_present == true)
			return false;
			is_present=true;
		}
		k++
	}
	// look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    //i=sLength;
	while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least two character after the .
    if ((i >= sLength - 2) || (s.charAt(i) != "."))     {
		return false;    }
    else
	{
		i+=1;
		while(i < sLength)
		{
			var c = s.charAt(i);
			if (!(((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z"))))
			{	
				if(s.charAt(i) == ".")
				{
					var j=(sLength-1)-i;
					if (i ==(sLength-1) || j< 2 )	return false;
				}
				else
					return false;
			}
			i++
		}
		return true;
	}
		
}
function isWhitespace (s)
{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

