function toggleObject(target) {
  targetLayer = (document.getElementById) ? document.getElementById(target).style : eval("document." + target);
  targetLayer.display = (targetLayer.display == "none")? "" : "none";
}

function displayObject(target, flag) {
  targetLayer = (document.getElementById) ? document.getElementById(target).style : eval("document." + target);
  targetLayer.display = (flag)? "" : "none";
}

// Trim whitespace from left and right sides of s.
function trim(s) {
    return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

//check empty 
function haveValue(s){    
    return ( s == "" || trim(s).length == 0 )?false:true;
}

function getRadioCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}	

function validDateFormat(date, month, year){					  	
 	 	 		
	var endMonth = Calendar_get_daysofmonth(month, year);
			
	if(date > endMonth)		
		return false;
	else
		return true;	
}

function Calendar_get_daysofmonth(monthNo, p_year) {
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	// newFunction
	DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	// Leap year Month days..
	lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return DOMonth[monthNo-1];
	
		return lDOMonth[monthNo-1];
	} else
		return DOMonth[monthNo-1];
}
function isValidDateInterval(strD1, strD2){

	// DD/MM/YYYY	
	var date1 = new Date( strD1.substring(6,10), strD1.substring(3,5)-1, strD1.substring(0,2));
	var date2 = new Date( strD2.substring(6,10), strD2.substring(3,5)-1, strD2.substring(0,2));
    if(date1 <= date2)
      return true;
    else
      return false;

}

function dateDiff(strD1, strD2) {
  date1 = new Date();
  date2 = new Date();
  diff  = new Date();
  currdate = new Date();
  date1temp = new Date(strD1.substring(6,10), strD1.substring(3,5)-1, strD1.substring(0,2));
  date1.setTime(date1temp.getTime());

  //date2temp = new Date(strD2.substring(6,10), strD2.substring(3,5)-1, strD2.substring(0,2));
  //date2.setTime(date2temp.getTime());


// sets difference date to difference of first date and second date

  //diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

var date3 = new Date();

diff.setTime(date3.getTime() - date1.getTime());

  timediff = diff.getTime();


  days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
  timediff -= days * (1000 * 60 * 60 * 24);

  //dateform.difference.value =  days + " days" ;
  var a = new Number(days);
  if(a<=90)
  {
    return true;
  }
  else
  { 
    return false;
  }

}
//check int
	function check_int(keypressed){
		var key;
			key = window.event.keyCode;    
			if(!(((key>47)&&(key<58))||(key==13))){
					window.event.keyCode = 0;
			}  
	}
	
//add old calenda 20071012	
	var carlWin=0;
	function carl(obj1)
	{
	  if(carlWin)
	  {
	    if(!carlWin.closed) carlWin.close();
	  }
	  window.param1 = obj1;
	  carlWin = open('inc/calendar.jsp', 'carlWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width=250,height=250,left=250, top=250,screenX=250,screenY=250');
	}  	
