function ShowToolTip(src,pText) 
{
		src.title = pText;
		return;
}	

function f_chk_null(as_nam)
{
	val1=as_nam;	
	
	//if (val1 != null) ls_nval = as_nam.value;else ls_nval =ac_getval(as_nam);
	
	for(var ci=0;ci<val1.length;ci++) if (val1.substring(ci,ci+1) != ' ') break;
	if (ci>=val1.length)
		return false;
	return true;
}

//Check for Invalid Characters
function checkchars(e)
{
	var key='';
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if(e.keyCode == 13)
		return true;
	
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1) 	
	{	
		return false;  // Not a valid key
	}					
	return true;
}

//check for numbers
function checkNumber(e)
{
	var key='';
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if(e.keyCode == 13)
		return true;
	
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1) 	
	{	
		return false;  // Not a valid key
	}					
	return true;
}
function checkcurrency(e)
{
	var key='';
	var strCheck = '.0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if(e.keyCode == 13)
		return true;
	
	key = String.fromCharCode(whichCode);  // Get key value from key code
	
	if (strCheck.indexOf(key) == -1) 	
	{	
		return false;  // Not a valid key
	}					
	return true;
}

function f_trim(as_val)
{
	while ( as_val.substring(0,1) == ' ' ) as_val = as_val.substring(1, as_val.length);
	while ( as_val.substring(as_val.length - 1, as_val.length) == ' ' )as_val = as_val.substring(0, as_val.length - 1);
	return (as_val);
}

function f_ChkValidEmail(as_name) 
{
	js_val = as_name;
	vs_error='N';
	
	if(f_chk_null(js_val) == false )
		return false;

	if ((js_val != '') && (js_val != null))
	 {
		for (var i =0; i < js_val.length; i++) 
		if (!(js_val.substring(i,i+1) >= "a"  && js_val.substring(i,i+1) <= "z"))	
		if (!(js_val.substring(i,i+1) >= "A"  && js_val.substring(i,i+1) <= "Z"))	
		if (!(js_val.substring(i,i+1) >= "0"  && js_val.substring(i,i+1) <= "9"))	
		if (!(js_val.substring(i,i+1) == "."  || js_val.substring(i,i+1) == "@" || js_val.substring(i,i+1) == "-" || js_val.substring(i,i+1) == "_" || js_val.substring(i,i+1) == "%" ))
		{
			return false;
		}
			
		//-----------------------
		mailctr=0;
		for (var i =0; i < js_val.length; i++) 
		{
			if (js_val.substring(i,i+1) == '@' ) mailctr = mailctr + 1;
		}
			
		if (mailctr>1)
		{
			 vs_error='Y';
			 return false;
		}
		//------------------------
			
		if (js_val.length <5 )
			vs_error='Y';

		if (js_val.indexOf('@') == -1) vs_error='Y';
		if (js_val.indexOf('.') == -1) vs_error='Y';

		js_first=js_val.substring(0,1);
		js_last=js_val.substring(js_val.length-1);
		if (js_first=='@' || js_last=='@' || js_first=='.' || js_last=='.') 
		{
			vs_error='Y';
		}

		jl_pos = js_val.indexOf('@');
		js_next = js_val.substring(jl_pos+1,jl_pos+2);
		js_prev = js_val.substring(jl_pos-1,jl_pos);
		if ((js_next == '.') || (js_prev == '.'))
		{
			vs_error='Y';
		}

		if (vs_error == 'Y') 
		{
			js_err= 'Invalid ' ;			
			return false;
		}
			
	}
	return true;
}

//Validation For Phone Number
function IsValidPhone(varPhNo)
{
	var val1;

	if(f_chk_null(varPhNo) == false )
		return false;
		
	val1=varPhNo;	
	
	for(var ci=0;ci<val1.length;ci++)
	{
	 if (isNaN(val1.substring(ci,ci+1))) break;
	}

	if (ci>=val1.length)
		return true;
	else
		return false;
}

function f_makeArray(n){
	this.length = n;
	for( var ai = 1; ai<=n; ai++) this[ai] = 0;
	return this;
}


//Validation for Date
function IsValid_date(as_date)
{
	
	ls_months = new f_makeArray(12);
	
	ls_months [1] = 'JAN';ls_months [2] = 'FEB'; ls_months [3] = 'MAR'; ls_months [4] = 'APR'; ls_months [5] = 'MAY'; ls_months [6] = 'JUN'; ls_months [7] = 'JUL'; ls_months [8] = 'AUG'; ls_months [9] = 'SEP'; ls_months [10] = 'OCT'; ls_months [11] = 'NOV'; ls_months [12] = 'DEC'; 

	li_err=1;

	as_date = f_trim(as_date);
	
	//Validation for spaces
	if (as_date.indexOf(' ',1) > 0)	return (' must not contain spaces');

	//Validation for Seperator
	ll_pos1 = as_date.indexOf ('/',1);
	if (ll_pos1 > 0) ll_pos2 = as_date.indexOf('/', ll_pos1+1);
	if (ll_pos1 < 0 || ll_pos2 < 0)
	{
		ll_pos1 = as_date.indexOf ('-',1);
		if (ll_pos1 > 0) ll_pos2 = as_date.indexOf('-', ll_pos1+1);
	}
	
	if (ll_pos1 < 0 || ll_pos2 < 0) return ' is not a valid date';

	ls_val = as_date.substring ( 0, ll_pos1);
	while ( ls_val.substring(0,1) == '0' ) ls_val = ls_val.substring(1, ls_val.length);

	ll_day = parseInt(ls_val,10);

	ls_val = as_date.substring ( ll_pos1+1, ll_pos2);
	while ( ls_val.substring(0,1) == '0' ) ls_val = ls_val.substring(1, ls_val.length);

	ll_mon_t = ls_val;
	ls_val = as_date.substring ( ll_pos2+1, as_date.length);
	
	ll_year = parseInt(ls_val,10);
	ll_year=Math.abs(ll_year);
	
	if (ll_year < 50) ll_year += 2000; else if (ll_year < 100) ll_year += 1900;
		
	if ( isNaN(ll_day) || isNaN(ll_year)) return ' is not a valid date';
	if (ll_year < 1900 || ll_year > 2079){ return  ' - Year should be in the range 1900 - 2079';}
	if ( parseInt(ll_mon_t,10) != ll_mon_t){
		ls_mon = ll_mon_t.toUpperCase();
		for(var di=1;di<=12;di++) if (ls_mon == ls_months[di]) {ll_mon = di; break;}
		if (di > 12) return ' is not a valid date';
	}
	else { ll_mon = ll_mon_t;}
	if (ll_mon > 12 || ll_mon <1 || ll_day > 31 || ll_day < 1) return ' is not a valid date';
	if ((ll_mon == 1 || ll_mon == 3 || ll_mon == 5 || ll_mon == 7 || ll_mon == 8 || ll_mon == 10 || ll_mon == 12) && ll_day > 31) li_err = -1;
	if ((ll_mon == 4 || ll_mon == 6 || ll_mon == 9 || ll_mon == 11) && ll_day > 30) li_err= -1;
	if (ll_mon == 2){
		if ( (  ll_year % 4 == 0  &&  ll_year % 100 != 0 ) || ( ll_year % 400 == 0 ) ){
			if (ll_day > 29)li_err = -1;
		}
		else{
			if (ll_day > 28)li_err = -1;
		}
	}
	if (li_err == -1) return ' is not a valid date'; 
	else {
		//ls_final_date = ll_day + '-'+ ls_months[ll_mon] + '-' + ll_year;
		//return ls_final_date;
		return true;
	}
}

function IsValidCC(optCCNo)
{
	if(isNaN(optCCNo) == true)
		return false;
	else
		return true;
}