// JavaScript Document
String.prototype.empty=function(){
var textstr=this; 
if(textstr==''){
return true;
}
return false;
}


String.prototype.trim=function(){
return this.replace(/^\s+/,'').replace(/\s+$/,'');
/*this.replace(/\s+$/,'');
return this;*/
}

function handleSessionExpiration(resp)
{
		
	/************* Code for checking whether the session has expired **************************************/
	resp=resp.split('[!!||||||!!]');
	if(resp[0]=='SESS_EXPIRED'){ // check if the session has expired
		alert('Due to inactivity the present session has expired.\nPlease login again.');
		location.replace(resp[1]);
		return;	
	}
	else if(resp[0]=='LOGIN_REQUIRED'){ // check if the session has expired
		location.replace(resp[1]);
		return;	
	}

	return resp[0];
	/******************************************************************************************************/
}

function validateDate(month, day, year)
{
	month=parseInt(month,10)
	day=parseInt(day,10)
	if(year<=0)
		return false;
	else if (month<1 || month>12)
		return false;
	else if (day < 1)
		return false;
	else
	{
		if(month==2)
		{
			if(year % 4 == 0 && year % 100 !=0 || $ear % 400 == 0)
			{
				if(day>29)
					return false;
			}
			else
			{
				if(day>28)
					return false;
			}
		}
		else if (month==1 && month==3 && month==5 && month==7 && month==8 && month==10 && month==12 && day >31)
			return false;
		else if(day>30)
			return false
	}
	return true;
}
	
function dateCompare(date1, date2)
{
	var dd1,dd2,mm1,mm2,yy1,yy2;
	dd1=date1.getDate();
	dd2=date2.getDate();
	mm1=date1.getMonth()+1;
	mm2=date2.getMonth()+1;
	
	if(dd1<10)	
		dd1='0'+dd1;
	if(dd2<10)	
		dd2='0'+dd2;
	if(mm1<10)	
		mm1='0'+mm1;
	if(mm2<10)	
		mm2='0'+mm2;
	yy1=date1.getFullYear();
	yy2=date2.getFullYear();
	dt1=parseInt(yy1+""+mm1+""+dd1,10)
	dt2=parseInt(yy2+""+mm2+""+dd2,10)

	if(dt1==dt2)
		return 0;
	else if (dt1>dt2)
		return 1;
	return -1;
}

function processAJAXResponse(resp)
{
	resp=resp.split('[!!||||||!!]');
	if(resp.length==2)
	{
		alert("Your session has expired.")
		window.location.href=resp[1];
	}
}
