/*********************************************************************
*This document contains approximate all those functions that is used
*for validation for fields and some customized javascript functions
*
*	Author: Ajay Kumar
*	Dated:  16-04-2008
*
**********************************************************************/

// Check for date that entered date should not be less than current date
function checkdate(dt)
{
	var dtArr = new Array();
	var dat = new Date();
	var curDate = dat.getDate();
	var curMonth = dat.getMonth()+1;
	var curYear = dat.getFullYear();

	if(curDate < 10) curDate = "0"+curDate;
	if(curMonth < 10) curMonth = "0"+curMonth;
	
	dtArr = dt.split('/');

//changes make for peaking the current year inspite of 1908 when the data is in 08 or 8 by keshav on 10/18/2008
	var xdt_ch = dtArr;
 
	 if (xdt_ch.length == 3)
	 {
	 if(xdt_ch[2].length == 2)
		 dtArr[2] = '20'+xdt_ch[2];
	}	 
//changes ends	

	var fd = curYear+''+curMonth+''+curDate;
	var sd = dtArr[2]+dtArr[0]+dtArr[1];
	
	//alert(curYear+" -- "+curMonth+" -- "+curDate+" -- "+fd);

	if(sd >= fd)
		return true;
	else
		return false;

	/*if(dtArr[2] >= curYear){
		if((dtArr[0] == curMonth && dtArr[1] >= curDate) || (dtArr[0] > curMonth))
			return true;
		else
			return false;
	}else
		return false;*/
}

//This is used to trim the string values
function trim(val)
{
	var l = val.length;
	for(var i=0; i<=l; i++){
		if(val.charAt(0) == " "){
			len = l-(i+1);
			val = val.substr(1,len);
		}else
			break;
	}
	return val;
}


//This Function is used to check and compare dates that first date always should be smaller and same.
//Here, first argument should be smaller than second argument
function compareDate(fDate, sDate)
{
	var dtArr = new Array();
	var dtArr1 = new Array();
	
	dtArr = sDate.split('/');
	dtArr1 = fDate.split('/');

	var fd = dtArr1[2]+dtArr1[0]+dtArr1[1];
	var sd = dtArr[2]+dtArr[0]+dtArr[1];
	
	if(sd > fd)
		return true;
	else
		return false;
	
	/*if(dtArr[2] >= dtArr1[2]){
		if((dtArr[0] == dtArr1[0] && dtArr[1] >= dtArr1[1]) || (dtArr[0] > dtArr1[0]))
			return true;
		else
			return false;
	}else
		return false;*/

}
