
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
	return"";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(0,iTemp +1);
	break;
	}
	iTemp = iTemp-1;
	
	} //End While
	return strTemp;
	
} //End Function
	
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function checkDate(month, day, year)
{

	if(!day && !month && !year)
		return true;
	
	if (!day || !month || !year)
		return false;
	
	//alert(month+' '+day+' '+year);
		
	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;

	if (day > monthLength[month-1])
		return false;

	monthLength[1] = 28;

	var now = new Date();
	now = now.getTime(); //NN3

	var dateToCheck = new Date();
	dateToCheck.setYear(year);
	dateToCheck.setMonth(month-1);
	dateToCheck.setDate(day);
	var checkDate = dateToCheck.getTime();

	var futureDate = (now < checkDate);
	var pastDate = (now > checkDate);
	
	return checkDate;
}
var divshow=false;
var divshowid='';
var timerID = 0;

function rID( elmid ) {
    if( document.getElementById ) { return document.getElementById(elmid); }
    if( document.layers && document.layers[elmid] ) { return document.layers[elmid]; }
    if( document.all && document.all(elmid) ) { return document.all(elmid); }
    return false;
}

function HideMDiv(id) {
sub=document.getElementById('sub'+id);
   if(divshow==true && sub!=null)
    {
        sub.style.display = "none";
        divshowid='';
        divshow=false;
    }
}
function ShowMDiv(subid) {
    var divX=0,divY=0,i=0;
    var smtable;
    subel=rID('sub'+subid);
    if(divshow==true&&subid!=divshowid)
    {
        HideMDiv(divshowid);
    } 
    if(subel.innerHTML!='')
    {
    smtable=document.getElementById('smtable');
    divX=10;
    for(i=1;i<subid;i++)
    {
      td=document.getElementById('td'+i);
      divX+=td.offsetWidth+8;  
    }  
    td=document.getElementById('td'+subid);
    subel.style.left = divX + "px";
    subel.style.top = smtable.offsetHeight+divY + "px";
    //subel.style.width=(td.offsetWidth+20)+"px";
    subel.style.width="140px";
    subel.style.overflow="hidden";
    subel.style.display = "block";
    divshow=true;
    divshowid=subid;
    } 
}

function SearchFormSubmit()
{
    if(document.forms.searchform.elements.searchtext.value=='')
    {
        alert("Enter text to search.");
        return false;
    }
    else
    {
        document.forms.searchform.submit();
        return true;
    }
}





