/*
Dveloped By:	Rama Krishna V.V.S
Developed On:	
Modified By:
Modified On:
Version:		1.0

//General Validator functions for UK-NZ Jobs
//Accepts only from a-z and A-Z */
function checkAlpha(txt)

{		
	if ((event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode  >= 95 && event.keyCode <= 122) || event.keyCode == 32|| event.keyCode == 46)
	
	event.returnValue=true;

	else

	event.returnValue=false;
}
//Allows numbers and alphabits and some other characters
function checkAlphaNumeric(txt)

{		
	if ((event.keyCode >= 48 && event.keyCode <= 57) ||(event.keyCode >= 65 && event.keyCode <= 90) 
		|| (event.keyCode  >= 95 && event.keyCode <= 122) || event.keyCode == 32|| 
		event.keyCode == 8|| event.keyCode == 45)
	
	event.returnValue=true;

	else

	event.returnValue=false;
}
//Allows only alphabits and numbers

function checkAlphaNumericOnly(txt)
{	

	if ((event.keyCode >= 48 && event.keyCode <= 57) ||(event.keyCode >= 65 && event.keyCode <= 90) 
		|| (event.keyCode  >= 97 && event.keyCode <= 122)|| 
		event.keyCode == 8|| event.keyCode == 9)
		
	event.returnValue=true;

	else

	event.returnValue=false;
}
//Accepts only numbers
function checkNumber(txt)
{
if (event.keyCode < 48 || event.keyCode > 57) 
	event.returnValue = false;
}

function checkDigit(txt)
{
if (event.keyCode < 45 || event.keyCode > 57) 
	event.returnValue = false;
}

//It allows all numbers and dot.
function checkCost(txt)
{
if ((event.keyCode >= 48 && event.keyCode <= 57) ||event.keyCode == 8||event.keyCode == 46)
	
	event.returnValue=true;

	else

	event.returnValue=false;
}

function checkMemo(txt)
{	
	if ((event.keyCode > 32 && event.keyCode < 42) || (event.keyCode > 57 && 
	event.keyCode < 65) || (event.keyCode==92||event.keyCode==8 || 
	event.keyCode==39||event.keyCode==96||event.keyCode==126)) 
	event.returnValue = false;
}
//Check the Date Format
function checkDate(txt)
{

if ((event.keyCode >= 48 && event.keyCode <= 57) ||event.keyCode == 8||event.keyCode == 45)
	
	event.returnValue=true;

	else

	event.returnValue=false;

}
//This function is called in PresentDate Function
function MMDDYY(start){ 
		return start.replace(/(\d+)\/(\d+)\/(\d+)/, "$2\/$1\/$3") 
	}

//This funtion is called in Present Date Function
function suycDateDiff( start, end, interval, rounding ) {
	
    var iOut = 0;
  
    // Create 2 error messages, 1 for each argument. 
    var startMsg = "Check the Start Date and End Date\n"
        startMsg += "must be a valid date format.\n\n"
        startMsg += "Please try again." ;
		
    var intervalMsg = "Sorry the dateAdd function only accepts\n"
        intervalMsg += "d, h, m OR s intervals.\n\n"
        intervalMsg += "Please try again." ;

    var bufferA = Date.parse( start ) ;
   
    var bufferB = Date.parse( end ) ;
    	
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        alert( startMsg ) ;
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        alert( intervalMsg ) ;
        return null ;
    }
    
    var number =parseInt(bufferB)-parseInt(bufferA) ;
   
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error. 		
        alert(intervalMsg) ;
        return null ;
    }
    
    return iOut ;
}
//This function is used to get the difference between two Dates based on interval like Months,Days,Minutes,Sec
function presentDate(startDate1,endDate1,interval,control) {
    var ierr = 1 ;
    var diff;
   // Verify whether the user wants to return only whole
   // intervals or intervals rounded to the nearest number 
   // of interval.
  // var roundDays = f.chkWholeDays.checked ;
   
   // Verify that the user entered something in the
   // Start Date input box.
   startDate=MMDDYY(startDate1);
   endDate=MMDDYY(endDate1);
    if(startDate != '') {
        if(!isNaN(Date.parse(startDate.substring(0,21)))) {
            var s = new Date(Date.parse(startDate.substring(0,21))) ;
            ierr = 0 ;
        }
    }
    
    // Verify that the user entered something in the
   // Ending Date input box.
    if(endDate != '' && ierr != 1) {
        if(!isNaN(Date.parse(endDate.substring(0,21)))) {
            var e = new Date(Date.parse(endDate.substring(0,21))) ;
            
            // call the dateDiff function.
            var temp = suycDateDiff( s, e, interval,1) ;
            
        }else{
            ierr = 1;
        }
    }else{
        ierr = 1;
    }
   
    // update the tellTime field with our new value.
    if ( temp != null && ierr != 1 ){
     control.value=Math.abs(temp).toString();
    } ;
   return temp;
}

function maximize()
{
	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
}
function validate_date(day,month,year)
{
	// since jan equals one and not zero, hence thirteen elements in the array.  
	var no_of_days_in_month = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
	
	if (month >= 1 && month <= 12 && day >=  1 && day <= 31 && year >= 0)
	{ 
	
		//Handling february, special case. 
		if (month == 2)
		{
			if ( (year%4==0 && year%100 != 0) || year%400 == 0 )
				no_of_days_in_month[month]=29
		}

		if (day >= 1 && day <= no_of_days_in_month[month])
		{
			return true;
		} 
		else
		{
			return false;
		}

	}
	else
	{
		return false;
	}

}
function checkemail1(emailadd)
{
	var result = false;
  	var theStr = new String(emailadd);
  	var index = theStr.indexOf("@");
  	if (index > 0)
  	{
    	var pindex = theStr.indexOf(".",index);
    	if ((pindex > index+1) && (theStr.length > pindex+2))
		result = true;
  	}
  		
  	return result;
}
//  End -->
