
function dateNotFuture(theDateObj)
{
    var now = new Date();
    var iMonth = getMonthNum(theDateObj.value)
    var indate = new Date(theDateObj.value.substring(7,11),iMonth-1,theDateObj.value.substring(0,2));                                
    if (indate>now) {alert("Not allow Future Date.");theDateObj.select();}
    
}

function dateNotGreaterThanToday(theDateObj){
    var now = new Date();    
    var iDay = getDayNum(theDateObj.value);
    var iMonth = getMonthNum(theDateObj.value)
    var iYear = parseInt(theDateObj.value.substring(7,11));                
    var indate = new Date(iYear,iMonth-1,iDay);                   
                        
    if((indate>now) || (iDay==now.getDate() && iMonth-1==now.getMonth() && iYear==now.getFullYear())) {           
        alert("Not allow date greater or equal to today.");
        theDateObj.select();
    }
}

function getDayNum(theDate){
    var strDay = theDate.substring(0,2);
    switch(strDay){
        case '01': 
            return 1;break;
        case '02': 
            return 2;break;
        case '03': 
            return 3;break;
        case '04': 
            return 4;break;
        case '05': 
            return 5;break;
        case '06': 
            return 6;break;
        case '07': 
            return 7;break;
        case '08': 
            return 8;break;
        case '09': 
            return 9;break;
        default: 
            return parseInt(strDay);
    }
}

function getMonthNum(theDate)
{    
    var strMonth = theDate.substring(3,6);
    //alert(strMonth);
    switch(strMonth.toUpperCase())
    {
        case 'JAN':
		    return 1;break;
	    case 'FEB':
		    return 2;break;
	    case 'MAR':
		    return 3;break;
	    case 'APR':
		    return 4;break;
	    case 'MAY':
		    return 5;break;
	    case 'JUN':
		    return 6;break;
	    case 'JUL':
		    return 7;break;
	    case 'AUG':
		    return 8;break;
	    case 'SEP':
		    return 9;break;
	    case 'OCT':
		    return 10;break;
        case 'NOV':
			return 11;break;
		case 'DEC':
			return 12;break;
		default:
			//displayInValidDate();
			//objControl.select();
			return nowDate.getMonth;	
    }                
    
}

function SetCharLimitation() {
	var datacontrol;
	var charcontrol;
	var textsize;
	
	datacontrol=document.getElementById(arguments[0]);
	charcontrol=document.getElementById(arguments[1]);//display characters leave
	textsize=arguments[2];
	
  if (datacontrol.value.length > textsize) {
    datacontrol.value = datacontrol.value.substring(0, textsize);
    charcontrol.value=textsize;
  }
  else{
	charcontrol.value=parseInt(textsize)-parseInt(datacontrol.value.length);
  }	
}

function validfloat(txt, ev) {
	ev.returnValue = ((ev.keyCode>=48 && ev.keyCode<=57) || ev.keyCode==46 && txt.value.indexOf('.') == -1);
}

function validfloatByPrecision(txt, ev, precision) {  
    if (txt.value.indexOf('.') == -1) {
        ev.returnValue = (ev.keyCode>=48 && ev.keyCode<=57 || ev.keyCode==46);
    }
    else if (txt.value.indexOf('.') > -1 && txt.value.indexOf('.') == txt.value.lastIndexOf('.')) {
        if (txt.value.length - txt.value.lastIndexOf('.') - 1 != precision) {
            ev.returnValue = (ev.keyCode>=48 && ev.keyCode<=57);
        }
        else{ev.returnValue = '';}
    }
    else{ev.returnValue = '';}
}

function validnumber(ev) {
	ev.returnValue = (ev.keyCode>=48 && ev.keyCode<=57); 
}

function isInteger(num) {
    return (("" + parseInt(num)) == num);
}

function isFloat(num) {
    return ((num/num == 1 || num == 0) && num != "");
}

function formatCurrency(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}

function emptytozero(txt) {
	if (txt.value.length == 0) txt.value = "0";
}

String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
    
function addalllist(lstavail,lstselected,hidden) {
	lstselected.length = 0;
	for (var i=0;i<lstavail.length;i++) {
		lstselected.options[lstselected.length] = new Option(lstavail.options[i].text,lstavail.options[i].value);
	}
	captureanswer(lstselected,hidden);
	clearselect(lstavail,lstselected);
}

function addlist(lstavail,lstselected,hidden) {
	for (var i=0;i<lstavail.length;i++) {
		if (lstavail.options[i].selected == true) {
			var blnExist = false;
			for (var j=0;j<lstselected.length;j++) {
				if (lstselected.options[j].value == lstavail.options[i].value) blnExist = true;
			}
			if (!blnExist) lstselected.options[lstselected.length] = new Option(lstavail.options[i].text,lstavail.options[i].value);
		}
	}
	captureanswer(lstselected,hidden);
	clearselect(lstavail,lstselected);
}

function dellist(lstavail,lstselected,hidden) {
	for (var i=lstselected.length-1;i>=0;i--) {
		if (lstselected.options[i].selected == true)
			lstselected.options[i] = null;
	}
	captureanswer(lstselected,hidden);
	clearselect(lstavail,lstselected);
}

function delalllist(lstavail,lstselected,hidden) {
	lstselected.length = 0;
	captureanswer(lstselected,hidden);
	clearselect(lstavail,lstselected);
}

function clearselect(lstavail,lstselected) {
	lstavail.selectedIndex = -1;
	lstselected.selectedIndex = -1;
}

function frameredirect(url) {
	parent.location.href='../' + url;
	parent.document.getElementById('fmeMenu').style.visibility='hidden';
}

function checkall(chk)	{
	for (var i=0;i<document.forms[0].elements.length;i++) {
		if (document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf(":_") >= 0) {
			if (document.forms[0].elements[i].disabled == false)
				document.forms[0].elements[i].checked = (chk.checked == true);
		}
	}
}

//enhance checkall function by cater the obj name
function checkallById(chk)	{
	for (var i=0;i<document.forms[0].elements.length;i++) {
		if (document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].name.indexOf(":_") >= 0) {
			if (document.forms[0].elements[i].disabled == false) {
				if (document.forms[0].elements[i].name.indexOf(chk.name.substring(0, chk.name.indexOf(":_"))) >= 0)
					document.forms[0].elements[i].checked = (chk.checked == true);
			}			
		}
	}	
}

function clearall() {
	for (var i=0;i<document.forms[0].elements.length;i++) {
		if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "textarea")
			document.forms[0].elements[i].value = "";		
		else if (document.forms[0].elements[i].type == "select-one")
			document.forms[0].elements[i].selectedIndex = 0;
		else if (document.forms[0].elements[i].type == "checkbox")
			document.forms[0].elements[i].checked = false;
	}
}

function moveorder(listbox,hidden,order) {
	var selected = listbox.selectedIndex;
	if (selected >= 0) {
		var target = selected + order;
		if (target >= 0 && target < listbox.length) {
			var temptext = listbox.options[target].text;
			var tempvalue = listbox.options[target].value;
			listbox.options[target].text = listbox.options[selected].text;
			listbox.options[target].value = listbox.options[selected].value;
			listbox.options[selected].text = temptext;
			listbox.options[selected].value = tempvalue;
			listbox.options[target].selected = true;
			captureanswer(listbox,hidden);
		}
	}
}
function moveorderreport(listbox,hidden,order) {
	var selected = listbox.selectedIndex;
	if (selected >= 0) {
		var target = selected + order;
		if (target >= 0 && target < listbox.length) {
			var temptext = listbox.options[target].text;
			var tempvalue = listbox.options[target].value;
			listbox.options[target].text = listbox.options[selected].text;
			listbox.options[target].value = listbox.options[selected].value;
			listbox.options[selected].text = temptext;
			listbox.options[selected].value = tempvalue;
			listbox.options[target].selected = true;
			captureanswerreport(listbox,hidden);
		}
	}
}
function captureanswerreport(listbox,hidden) {
	var temp="";
	for (var i=0;i<listbox.length;i++) {
		temp += listbox.options[i].value + "|";
	}	
	hidden.value = temp;
}

function additem(textbox,listbox,hidden) {
	if (textbox.value.length > 0) {
		listbox.options[listbox.length] = new Option(textbox.value,textbox.value);
		textbox.value = "";
		captureanswer(listbox,hidden);
	}
}

function removeitem(listbox,hidden) {
	var selected = listbox.selectedIndex;
	if (selected >= 0) {
		listbox.options[listbox.selectedIndex] = null;
		if (selected > 0) listbox.options[selected-1].selected = true;
		captureanswer(listbox,hidden);
	}		
}

function captureanswer(listbox,hidden) {
	var temp="";
	for (var i=0;i<listbox.length;i++) {
		temp += listbox.options[i].value + "|";
	}	
	hidden.value = temp.substring(0,temp.length-1);
}
//convert to valid date(once onblur event)
//------------------------------------------------------------------------------------------------

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400. 
    
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

/*
function validdate()
		{
			var objControl=arguments[0];
			var objVal=objControl.value;
			var daysInMonth = DaysArray(12)
			var imonth;
			
			if(objVal!='')
			{
				var objDate;
				var strSplitter;
				var day,month,year;
				
				if(objVal.indexOf('/')!=-1){
					strSplitter='/';
				}else if(objVal.indexOf('-')!=-1){
					strSplitter='-';
				}else if(objVal.indexOf('.')!=-1){
					strSplitter='.';
				}else{
					//strSplitter='-';
					//alert('Invalid date.');
					objControl.select();	
					return false;
				}

				objDate=objVal.split(strSplitter);						
				
				try
				{
					day=objDate[0];
					if(isNaN(parseInt(day))){
						//alert('Invalid date.');
						objControl.select();						
						return false;
					}							
																
					month=objDate[1];																											
					if(isNaN(parseInt(month))){
						switch (month.toUpperCase()){
							case 'JAN':
							case 'JANUARY':
								month='Jan';
								imonth=1;
								break;
							case 'FEB':
							case 'FEBRUARY':
								month='Feb';
								imonth=2;
								break;
							case 'MAR':
							case 'MARCH':
								month='Mar';
								imonth=3;
								break;
							case 'APR':
							case 'APRIL':
								month='Apr';
								imonth=4;
								break;
							case 'MAY':
								month='May';
								imonth=5;
								break;
							case 'JUN':
							case 'JUNE':
								month='Jun';
								imonth=6;
								break;
							case 'JUL':
							case 'JULY':
								month='Jul';
								imonth=7;
								break;
							case 'AUG':
							case 'AUGUST':
								month='Aug';
								imonth=8;
								break;
							case 'SEP':
							case 'SEPTEMBER':
								month='Sep';
								imonth=9;
								break;
							case 'OCT':
							case 'OCTOBER':
								month='Oct';
								imonth=10;
								break;
							case 'NOV':
							case 'NOVEMBER':
								month='Nov';
								imonth=11;
								break;
							case 'DEC':
							case 'DECEMBER':
								month='Dec';
								imonth=12;
								break;
							default:return false;	
						}
					}
					else{
						if((parseInt(month,10)>=1)&&(parseInt(month,10)<=12)){
							switch(parseInt(month,10))
							{
								case 1:	
									month='Jan';
									imonth=1;
									break;
								case 2:	
									month='Feb';
									imonth=2;
									break;
								case 3:	
									month='Mar';
									imonth=3;
									break;
								case 4:	
									month='Apr';
									imonth=4;
									break;
								case 5:	
									month='May';
									imonth=5;
									break;
								case 6:	
									month='Jun';
									imonth=6;
									break;
								case 7:	
									month='Jul';
									imonth=7;
									break;
								case 8:	
									month='Aug';
									imonth=8;
									break;
								case 9:	
									month='Sep';
									imonth=9;
									break;
								case 10:	
									month='Oct';
									imonth=10;
									break;
								case 11:	
									month='Nov';
									imonth=11;
									break;
								case 12:	
									month='Dec';
									imonth=12;
									break;
							}
						}
						else{	
							//alert('Invalid date.');
							objControl.select();
							return false;
						}	
					}
					
					if (day<1 || day>31 || (imonth==2 && day>daysInFebruary(year)) || day > daysInMonth[imonth]){
						//alert('Invalid date.');
						objControl.select();						
						return false;												
					}	
						
					year=objDate[2];
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');
						objControl.select();
						return false;
					}else if(year.length > 4){
						//alert('Invalid date.');
						objControl.select();
						return false;
					}else{
						if(parseInt(year)<1000){
							year=parseInt(year)+1900;
						}
					}
					day=day.length<2?"0"+day:day;
					objControl.value=day+'-'+month+'-'+year;
					return true;								
				}catch(e){}
			}
		}
*/
		
// Add on - 20071001
// ===============================
//convert to valid date(once onblur event)
function validdate()
		{
			var objControl=arguments[0];			
			var objVal=objControl.value;
			var daysInMonth = DaysArray(12)
			var imonth;

			if(objVal!='')
			{				
				var objDate;
				var strSplitter;
				var day,month,year;

				
				
				if(objVal.indexOf('/')!=-1){
					strSplitter='/';
				}else if(objVal.indexOf('-')!=-1){
					strSplitter='-';
				}else if(objVal.indexOf('.')!=-1){
					strSplitter='.';				
				}else{
					//strSplitter='-';
					//alert('Invalid date.');					
					displayInValidDate();
					objControl.select();	
					return false;
				}
					
				objDate=objVal.split(strSplitter);						
				
				try
				{
					day=objDate[0];
					if(isNaN(parseInt(day))){
						//alert('Invalid date.');
						displayInValidDate();
						objControl.select();						
						return false;
					}
					
					year=objDate[2];
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');						
						displayInValidDate();
						objControl.select();						
						return false;
					}							
																
					month=objDate[1];																											
					if(isNaN(parseInt(month))){
						switch (month.toUpperCase()){
							case 'JAN':
							case 'JANUARY':
								month='Jan';
								imonth=1;
								break;
							case 'FEB':
							case 'FEBRUARY':
								month='Feb';
								imonth=2;
								break;
							case 'MAR':
							case 'MARCH':
								month='Mar';
								imonth=3;
								break;
							case 'APR':
							case 'APRIL':
								month='Apr';
								imonth=4;
								break;
							case 'MAY':
								month='May';
								imonth=5;
								break;
							case 'JUN':
							case 'JUNE':
								month='Jun';
								imonth=6;
								break;
							case 'JUL':
							case 'JULY':
								month='Jul';
								imonth=7;
								break;
							case 'AUG':
							case 'AUGUST':
								month='Aug';
								imonth=8;
								break;
							case 'SEP':
							case 'SEPTEMBER':
								month='Sep';
								imonth=9;
								break;
							case 'OCT':
							case 'OCTOBER':
								month='Oct';
								imonth=10;
								break;
							case 'NOV':
							case 'NOVEMBER':
								month='Nov';
								imonth=11;
								break;
							case 'DEC':
							case 'DECEMBER':
								month='Dec';
								imonth=12;
								break;
							default:
								displayInValidDate();
								objControl.select();
								return false;	
						}
					}
					else{
						if((parseInt(month,10)>=1)&&(parseInt(month,10)<=12)){
							switch(parseInt(month,10))
							{
								case 1:	
									month='Jan';
									imonth=1;
									break;
								case 2:	
									month='Feb';
									imonth=2;
									break;
								case 3:	
									month='Mar';
									imonth=3;
									break;
								case 4:	
									month='Apr';
									imonth=4;
									break;
								case 5:	
									month='May';
									imonth=5;
									break;
								case 6:	
									month='Jun';
									imonth=6;
									break;
								case 7:	
									month='Jul';
									imonth=7;
									break;
								case 8:	
									month='Aug';
									imonth=8;
									break;
								case 9:	
									month='Sep';
									imonth=9;
									break;
								case 10:	
									month='Oct';
									imonth=10;
									break;
								case 11:	
									month='Nov';
									imonth=11;
									break;
								case 12:	
									month='Dec';
									imonth=12;
									break;
							}
						}
						else{	
							//alert('Invalid date.');
							displayInValidDate();
							objControl.select();
							return false;
						}	
					}
					
					if (day<1 || day>31 || (imonth==2 && day>daysInFebruary(year)) || day > daysInMonth[imonth]){
						//alert('Invalid date.');
						displayInValidDate();
						objControl.select();						
						return false;												
					}	
						
					year=objDate[2];
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');
						//displayInValidDate();
						//objControl.select();
						//return false;						
					}else if(year.length > 4){
						//alert('Invalid date.');
						displayInValidDate();
						objControl.select();
						return false;
					}else{
					    
					    
						if(parseInt(year)<1000){
						//alert(parseInt(year, 10));
							year=parseInt(year, 10)+2000;
						}
					}
					day=day.length<2?"0"+day:day;
					objControl.value=day+'-'+month+'-'+year;
					return true;								
				}catch(e){}
			}
		}
		
		function validdateOnKeyPress()
		{
			var objControl=arguments[0];			
			//var ev=arguments[1];
			//var objVal=objControl.value + String.fromCharCode(ev.keyCode);
			var objVal=objControl.value;
			var daysInMonth = DaysArray(12)
			var imonth;

			if(objVal!='')
			{	
				var objDate;
				var strSplitter;
				var day,month,year;
							
				if(objVal.indexOf('/')!=-1){
					strSplitter='/';
				}else if(objVal.indexOf('-')!=-1){
					strSplitter='-';
				}else if(objVal.indexOf('.')!=-1){
					strSplitter='.';				
				}else{
					//strSplitter='-';
					//alert('Invalid date.');					
					//displayInValidDate();
					//objControl.select();	
					return false;
				}
					
				objDate=objVal.split(strSplitter);										
				
				try
				{
					day=objDate[0];
					if(isNaN(parseInt(day))){
						//alert('Invalid date.');
						//displayInValidDate();
						//objControl.select();						
						return false;
					}
					
					year=objDate[2];
					
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');						
						//displayInValidDate();
						//objControl.select();
						return false;
					}else if(year.length != 4){
						return false;
					}																
																
					month=objDate[1];																											
					if(isNaN(parseInt(month))){
						switch (month.toUpperCase()){
							case 'JAN':
							case 'JANUARY':
								month='Jan';
								imonth=1;
								break;
							case 'FEB':
							case 'FEBRUARY':
								month='Feb';
								imonth=2;
								break;
							case 'MAR':
							case 'MARCH':
								month='Mar';
								imonth=3;
								break;
							case 'APR':
							case 'APRIL':
								month='Apr';
								imonth=4;
								break;
							case 'MAY':
								month='May';
								imonth=5;
								break;
							case 'JUN':
							case 'JUNE':
								month='Jun';
								imonth=6;
								break;
							case 'JUL':
							case 'JULY':
								month='Jul';
								imonth=7;
								break;
							case 'AUG':
							case 'AUGUST':
								month='Aug';
								imonth=8;
								break;
							case 'SEP':
							case 'SEPTEMBER':
								month='Sep';
								imonth=9;
								break;
							case 'OCT':
							case 'OCTOBER':
								month='Oct';
								imonth=10;
								break;
							case 'NOV':
							case 'NOVEMBER':
								month='Nov';
								imonth=11;
								break;
							case 'DEC':
							case 'DECEMBER':
								month='Dec';
								imonth=12;
								break;
							default:
								//displayInValidDate();
								//objControl.select();
								return false;	
						}
					}
					else{
						if((parseInt(month,10)>=1)&&(parseInt(month,10)<=12)){
							switch(parseInt(month,10))
							{
								case 1:	
									month='Jan';
									imonth=1;
									break;
								case 2:	
									month='Feb';
									imonth=2;
									break;
								case 3:	
									month='Mar';
									imonth=3;
									break;
								case 4:	
									month='Apr';
									imonth=4;
									break;
								case 5:	
									month='May';
									imonth=5;
									break;
								case 6:	
									month='Jun';
									imonth=6;
									break;
								case 7:	
									month='Jul';
									imonth=7;
									break;
								case 8:	
									month='Aug';
									imonth=8;
									break;
								case 9:	
									month='Sep';
									imonth=9;
									break;
								case 10:	
									month='Oct';
									imonth=10;
									break;
								case 11:	
									month='Nov';
									imonth=11;
									break;
								case 12:	
									month='Dec';
									imonth=12;
									break;
							}
						}
						else{	
							//alert('Invalid date.');
							//displayInValidDate();
							//objControl.select();
							return false;
						}	
					}
					
					if (day<1 || day>31 || (imonth==2 && day>daysInFebruary(year)) || day > daysInMonth[imonth]){
						//alert('Invalid date.');
						//displayInValidDate();
						//objControl.select();						
						return false;												
					}	
						
					year=objDate[2];
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');
						//displayInValidDate();
						//objControl.select();
						return false;						
					}else if(year.length > 4){
						//alert('Invalid date.');
						//displayInValidDate();
						//objControl.select();
						return false;
					}else{
						year=parseInt(year);
						//year=parseInt(String(year).substring(0, String(year).length - 1));
						//year=year.substring(0, year.length - 1);
						//if(parseInt(year)<1000){
						//	year=parseInt(year)+1900;
						//}
					}
					day=day.length<2?"0"+day:day;
					objControl.value=day+'-'+month+'-'+year;
					return true;								
				}catch(e){}
			}
		}		
		
function validDOBdate()
		{
			var objControl=arguments[0];			
			var objVal=objControl.value;
			var daysInMonth = DaysArray(12)
			var imonth;

			if(objVal!='')
			{				
				var objDate;
				var strSplitter;
				var day,month,year;

				
				
				if(objVal.indexOf('/')!=-1){
					strSplitter='/';
				}else if(objVal.indexOf('-')!=-1){
					strSplitter='-';
				}else if(objVal.indexOf('.')!=-1){
					strSplitter='.';				
				}else{
					//strSplitter='-';
					//alert('Invalid date.');					
					displayInValidDate();
					objControl.select();	
					return false;
				}
					
				objDate=objVal.split(strSplitter);						
				
				try
				{
					day=objDate[0];
					if(isNaN(parseInt(day))){
						//alert('Invalid date.');
						displayInValidDate();
						objControl.select();						
						return false;
					}
					
					year=objDate[2];
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');						
						//displayInValidDate();
						//objControl.select();						
						//return false;

						objDate[2]='1900';
						year=objDate[2];
					}							
																
					month=objDate[1];																											
					if(isNaN(parseInt(month))){
						switch (month.toUpperCase()){
							case 'JAN':
							case 'JANUARY':
								month='Jan';
								imonth=1;
								break;
							case 'FEB':
							case 'FEBRUARY':
								month='Feb';
								imonth=2;
								break;
							case 'MAR':
							case 'MARCH':
								month='Mar';
								imonth=3;
								break;
							case 'APR':
							case 'APRIL':
								month='Apr';
								imonth=4;
								break;
							case 'MAY':
								month='May';
								imonth=5;
								break;
							case 'JUN':
							case 'JUNE':
								month='Jun';
								imonth=6;
								break;
							case 'JUL':
							case 'JULY':
								month='Jul';
								imonth=7;
								break;
							case 'AUG':
							case 'AUGUST':
								month='Aug';
								imonth=8;
								break;
							case 'SEP':
							case 'SEPTEMBER':
								month='Sep';
								imonth=9;
								break;
							case 'OCT':
							case 'OCTOBER':
								month='Oct';
								imonth=10;
								break;
							case 'NOV':
							case 'NOVEMBER':
								month='Nov';
								imonth=11;
								break;
							case 'DEC':
							case 'DECEMBER':
								month='Dec';
								imonth=12;
								break;
							default:
								displayInValidDate();
								objControl.select();
								return false;	
						}
					}
					else{
						if((parseInt(month,10)>=1)&&(parseInt(month,10)<=12)){
							switch(parseInt(month,10))
							{
								case 1:	
									month='Jan';
									imonth=1;
									break;
								case 2:	
									month='Feb';
									imonth=2;
									break;
								case 3:	
									month='Mar';
									imonth=3;
									break;
								case 4:	
									month='Apr';
									imonth=4;
									break;
								case 5:	
									month='May';
									imonth=5;
									break;
								case 6:	
									month='Jun';
									imonth=6;
									break;
								case 7:	
									month='Jul';
									imonth=7;
									break;
								case 8:	
									month='Aug';
									imonth=8;
									break;
								case 9:	
									month='Sep';
									imonth=9;
									break;
								case 10:	
									month='Oct';
									imonth=10;
									break;
								case 11:	
									month='Nov';
									imonth=11;
									break;
								case 12:	
									month='Dec';
									imonth=12;
									break;
							}
						}
						else{	
							//alert('Invalid date.');
							displayInValidDate();
							objControl.select();
							return false;
						}	
					}
					
					if (day<1 || day>31 || (imonth==2 && day>daysInFebruary(year)) || day > daysInMonth[imonth]){
						//alert('Invalid date.');
						displayInValidDate();
						objControl.select();						
						return false;												
					}	
						
					year=objDate[2];
					if(isNaN(parseInt(year))){
						//alert('Invalid date.');
						//displayInValidDate();
						//objControl.select();
						//return false;						
					}else if(year.length > 4){
						//alert('Invalid date.');
						displayInValidDate();
						objControl.select();
						return false;
					}else{
						if(parseInt(year)<1000){
							year=parseInt(year)+1900;
						}
					}
					day=day.length<2?"0"+day:day;
					objControl.value=day+'-'+month+'-'+year;
					return true;								
				}catch(e){}
			}
		}
		
function displayInValidDate(){
	alert('Valid Date Format \n 28/02/2007 \n 28.02.2007 \n 28-02-2007 \n 28-Feb-2007');
}		
		
// ===============================


//-----------------------------------------------------------------------------------------------------


// Date Picker
var nowDate = new Date();
var timeout=0,timeoutC=0,timeoutM=0,timeoutY=0;
var monthname = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var daysofmth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var daysofmthl = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
var cYear,cMonth,txt;

function getDaysOfMonth(mth,yr) {
	if (yr%4 == 0) {
		if (yr%100 == 0 && yr%400 != 0)
			return daysofmth[mth];
		return daysofmthl[mth];
	} else
		return daysofmth[mth];
}

function calMonthYear(mth,yr,incr) {
	var arr = new Array();
	if (incr == -1) {
		if (mth == 0) {
			arr[0] = 11;
			arr[1] = parseInt(yr)-1;
		}
		else {
			arr[0] = parseInt(mth)-1;
			arr[1] = parseInt(yr);
		}
	} else if (incr == 1) {
		if (mth == 11) {
			arr[0] = 0;
			arr[1] = parseInt(yr)+1;
		}
		else {
			arr[0] = parseInt(mth)+1;
			arr[1] = parseInt(yr);
		}
	}
	return arr;
}

function formatToday(dy) {
	if (dy == nowDate.getDate() && cMonth == nowDate.getMonth() && cYear == nowDate.getYear())
		return '<font color="red">' + dy + '</font>';
	else
		return dy;
}

function formatDate(dy) {
	var formatday = (dy.toString().length<2) ? "0" + dy : dy;
	return formatday + "-" + monthname[cMonth] + "-" + cYear;
}

function hideObject() {
	parent.document.getElementById('fmeCal').style.visibility = "hidden";
}

function clearObject(txt) {
	parent.document.getElementById(txt).value = "";
	hideObject();
}

function monthOut() {
	document.getElementById('divMonth').style.visibility = "hidden";
}

function yearOut() {
	document.getElementById('divYear').style.visibility = "hidden";
}

function calendarOut() {
	document.getElementById('fmeCal').style.visibility = "hidden";
}

function incYear() {
	for	(i=0; i<5; i++) {
		var ddlYear = parseInt(document.getElementById('y'+i).innerText);
		if (this.gYear == ddlYear)
			document.getElementById('y'+i).innerHTML = '<b>' + ddlYear+1 + '</b>';
		else
			document.getElementById('y'+i).innerHTML = ddlYear+1;
	}
}

function decYear() {
	for	(i=0; i<5; i++) {
		var ddlYear = parseInt(document.getElementById('y'+i).innerText);
		if (this.gYear == ddlYear)
			document.getElementById('y'+i).innerHTML = '<b>' + ddlYear-1 + '</b>';
		else
			document.getElementById('y'+i).innerHTML = ddlYear-1;
	}
}

function buildMonth() {
	var selmonth = '<div id="divMonth" style="position:absolute;visibility:hidden;left:24;top:23;" onmouseover="clearTimeout(timeoutM)">' +
		'<table width="60" class="monthyear" style="font-size:7pt" cellspacing="0" onmouseover="clearTimeout(timeout)" onmouseout="timeout=setTimeout(\'monthOut()\',200);"><tr><td width="50%" ';
	for (var i=0;i<12;i++) {
		selmonth += ' onmouseover="this.style.backgroundColor=\'#316AC5\'" onmouseout="this.style.backgroundColor=\'\'" onclick="buildCal(\'' + txt + '\',' + i + ',' + cYear + ')">';
		if (cMonth == i)	
			selmonth += '<font style="font-size:8pt"><b>' + monthname[i].toUpperCase() + '</font></b>';
		else
			selmonth += monthname[i].toUpperCase();
		if (i%2 == 0)
			selmonth += '</td><td ';
		else if (i == 11)
			selmonth += '</td></tr>';		
		else
			selmonth += '</td></tr><tr><td ';
	}
	selmonth += '</table></div>';
	return selmonth;
}

function buildYear() {
	var selyear = '<div id="divYear" style="position:absolute;visibility:hidden;left:68;top:23;" onmouseover="clearTimeout(timeoutY)">' +
		'<table width="41" class="monthyear" cellspacing="0" onmouseover="clearTimeout(timeout);" onmouseout="timeout=setTimeout(\'yearOut()\',200)">' +
		'<tr><td align="center" onmouseover="this.style.backgroundColor=\'#316AC5\'" onmouseout="clearTimeout(timeout);this.style.backgroundColor=\'\'" onmousedown="timeout=setInterval(\'decYear()\',30)" onmouseup="clearTimeout(timeout);">-</td></tr>';
	var j=0;
	for (var i=parseInt(cYear)-2;i<=parseInt(cYear)+2;i++) {
		selyear += '<tr><td id="y' + j + '" align="center" onmouseover="this.style.backgroundColor=\'#316AC5\'" onmouseout="this.style.backgroundColor=\'\'" onclick="buildCal(\'' + txt + '\',' + cMonth + ',this.innerText)">';
		if (cYear == i)	
			selyear += '<b>' + i + '</b>';
		else
			selyear += i;
		selyear += '</td></tr>';
		j++;
	}
	selyear += '<tr><td align="center" onmouseover="this.style.backgroundColor=\'#316AC5\'" onmouseout="clearTimeout(timeout);this.style.backgroundColor=\'\'" onmousedown="timeout=setInterval(\'incYear()\',30)" onmouseup="clearTimeout(timeout);">+</td></tr></table></div>';
	return selyear;
}

function showCalendar() {
	var vCode = "";
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(cMonth);
	vDate.setYear(cYear);
	var vFirstDay=vDate.getDay();
	var vLastDay=getDaysOfMonth(cMonth, cYear);
	var prev = calMonthYear(cMonth,cYear,-1);
	var next = calMonthYear(cMonth,cYear,1);
	
	// Month navigation header
	vCode += '<table id="tblMain" width="133" border="0" cellpadding="0" cellspacing="0" style="border:black 2px solid;"><tr><td>' +
		'<table width="100%" border="0" cellspacing="2" cellpadding="0"><tr>' +
		'<td><img src="..\\Images\\arrowl.gif" style="cursor:hand;" ' +
		'onmouseover="window.status=\'Previous month\';return true;" ' +
		'onmouseout="window.status=\'\';return true;" ' +
		'onclick="buildCal(\'' + txt + '\',' + prev[0] + ',' + prev[1] + ');"></td>';

	vCode += '<td width="39" class="monthyear" ' +
		'onmouseover="clearTimeout(timeoutM);window.status=\'Select month\';return true;" ' +
		'onmouseout="timeoutM=setTimeout(\'monthOut()\',300);window.status=\'\';return true;" ' +
		'onclick="document.getElementById(\'divMonth\').style.visibility=\'visible\'">&nbsp;' + 
		monthname[cMonth].toUpperCase() + ' <font class="dropdown">6</font>' + buildMonth() + '</td>';

	vCode += '<td class="monthyear" ' +
		'onmouseover="clearTimeout(timeoutY);window.status=\'Select year\';return true;" ' +
		'onmouseout="timeoutY=setTimeout(\'yearOut()\',300);window.status=\'\';return true;" ' +
		'onclick="document.getElementById(\'divYear\').style.visibility=\'visible\'">&nbsp;' + 
		cYear + ' <font class="dropdown">6</font>' + buildYear() + '</td>';

	vCode += '<td><img src="..\\Images\\arrowr.gif" style="cursor:hand" ' +
		'onmouseover="window.status=\'Next month\';return true;" ' +
		'onmouseout="window.status=\'\';return true;" ' +
		'onclick="buildCal(\'' + txt + '\',' + next[0] + ',' + next[1] + ');"></td></tr></table>';

	// Week header
	vCode += '<table width="100%" border="0" style="font-size:8pt;"><tr>' +
		'<td width="14%" align="center">S</td>' +
		'<td width="14%" align="center">M</td>' +
		'<td width="14%" align="center">T</td>' +
		'<td width="14%" align="center">W</td>' +
		'<td width="14%" align="center">T</td>' +
		'<td width="14%" align="center">F</td>' +
		'<td width="16%" align="center">S</td></tr>' +
		'<tr><td colspan="7" bgcolor="black"></td></tr>';

	// Days
	vCode = vCode + '<tr>';
	for (var i=0;i<45;i++) {
		if ((i < vFirstDay) || (i-vFirstDay >= vLastDay))
			vCode += '<td>&nbsp;</td>';
		else if (i-vFirstDay <= vLastDay) {
			vCode += '<td align="center">' + 
				'<a href="javascript:void(0);" ' + 
				'onmouseover="window.status=\'Set date to ' + formatDate(i-vFirstDay+1) + '\';return true;" ' +
				'onmouseout="window.status=\' \';return true;" ' +
				'onclick="parent.document.getElementById(\'' + txt + '\').value=\'' + formatDate(i-vFirstDay+1) + '\';hideObject();">' +
				'<font style="font-size:7pt;font-weight:bold;">' + 
				formatToday(i-vFirstDay+1) + '</font></a></td>';
		}
		if ((i+1)%7==0) {
			if (i < (vFirstDay-1) + vLastDay)
				vCode += '</tr><tr>';
			else {
				vCode += '</tr>';
				break;
			}
		}
	}

	// Close and clear button footer
	vCode += "<tr><td colspan='7' bgcolor='black'></td></tr>" +
		"<tr><td colspan='2' align='center'><a href='javascript:void(0);' onclick='hideObject();' onmouseover=\"window.status='Close calendar';return true;\" onmouseout=\"window.status='';return true;\"><font style='text-decoration:underline;'>Close</font></a></td>" +
		"<td colspan='3' align='center'><a href='javascript:void(0);' onclick=\"buildCal('" + txt + "'," + nowDate.getMonth() + "," + nowDate.getYear() + ");\" onmouseover=\"window.status='Go to default date';return true;\" onmouseout=\"window.status='';return true;\"><font style='text-decoration:underline;'>Today</font></a></td>" +
		"<td colspan='2' align='center'><a href='javascript:void(0);' onclick=\"clearObject('" + txt + "');\" onmouseover=\"window.status='Clear date';return true;\" onmouseout=\"window.status='';return true;\"><font style='text-decoration:underline;'>Clear</font></a></td></tr></table></td></tr></table>";
	return vCode;
}

function buildCal(source,mth,yr) {
	cMonth = mth;
	cYear = yr;
	txt = source;
	
	if (document.getElementById('overDiv') == null) {
		document.fmeCal.document.getElementById('overDiv').innerHTML=showCalendar();	
		document.getElementById('fmeCal').height = document.fmeCal.document.getElementById('tblMain').offsetHeight;
	}
	else {
		document.getElementById('overDiv').innerHTML=showCalendar();	
		parent.document.getElementById('fmeCal').height = document.getElementById('tblMain').offsetHeight;
	}
}

function popupCal() {
	buildCal(arguments[0],nowDate.getMonth(),nowDate.getYear());

	var obj = document.getElementById(txt);
	var objLeft = obj.offsetLeft;
	var objTop = obj.offsetTop;
	var objParent = obj.offsetParent;

	while(objParent.tagName.toUpperCase() != 'BODY') {
		objLeft += objParent.offsetLeft;
		objTop += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	objTop += obj.offsetHeight + 2;

	document.getElementById('fmeCal').style.visibility = "visible";
	document.getElementById('fmeCal').style.left = objLeft;
	document.getElementById('fmeCal').style.top = objTop;
}
//End Date Picker 	if (navigator.appVersion.indexOf('Mac') != -1)

// Add on - 20071001
// ===============================
//Define the images
imgout=new Image(12,12);
imgin=new Image(12,12);
imgout.src="images/plus.gif";
imgin.src="images/minus.gif";

//switches expand collapse icons 13 Oct 2006
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show OR hide funtion depends on if element is shown or hidden 13 Oct 2006
function shoh(id) { 
	
	if (document.getElementById) { 
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
			filter(("img"+id),'imgin');			
		} else {
			filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
				filter(("img"+id),'imgin');
			} else {
				filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}

// Start Date Validator
// Declaring valid date character, minimum year and maximum year
var dtCh= "-";
var minYear=1900;
var maxYear=9999;
var month="";

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.    
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr,blnMsg){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)	
	var pos2=dtStr.indexOf(dtCh,pos1+1)	
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)	
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)	
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}	
		
	day=parseInt(strDay)
	year=parseInt(strYr)	
	strMonth=strMonth.toLowerCase();
			
	if (strMonth == "jan"){
	month=1;
	}else if (strMonth == "feb"){
	month=2;
	}else if (strMonth == "mar"){
	month=3;
	}else if (strMonth == "apr"){
	month=4;
	}else if (strMonth == "may"){
	month=5;
	}else if (strMonth == "jun"){
	month=6;
	}else if (strMonth == "jul"){
	month=7;
	}else if (strMonth == "aug"){
	month=8;
	}else if (strMonth == "sep"){
	month=9;
	}else if (strMonth == "oct"){
	month=10;
	}else if (strMonth == "nov"){
	month=11;
	}else if (strMonth == "dec"){
	month=12;
	}
		
	if (pos1==-1 || pos2==-1){
		if (blnMsg==true){
			alert("The date format should be : dd-MMM-yyyy")			
		}
		return false
	}
	if (strMonth.length<1 || strMonth.length!=3 || month<1 || month>12){
		if (blnMsg==true){
			alert("Please enter a valid month. The date format should be : dd-MMM-yyyy")
		}
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		if (blnMsg==true){
			alert("Please enter a valid day. The date format should be : dd-MMM-yyyy")
		}
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		if (blnMsg==true){
			alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)			
		}
		return false
	}	
	if (dtStr.indexOf(dtCh,pos2+1)!=-1){
		if (blnMsg==true){
			alert("Please enter a valid date. The date format should be : dd-MMM-yyyy")						
		}
		return false
	}
return true
}

function ValidateDate(txt){			
	if (isDate(txt.value,true)==false){		
		txt.select()					
	}
 }
 
function formatdate(txt){
	if (isDate(txt.value,false)==true){	
		if (txt.value.length==10){
			txt.value= "0" + txt.value;		
		}	
	}
}
// End Date Validator

var dtCh= "-";
var month="";
var mth="";
function validdaterange(st,to){

	var pos1=st.indexOf(dtCh)	
	var pos2=st.indexOf(dtCh,pos1+1)	
	var strDay=st.substring(0,pos1)
	var strMonth=st.substring(pos1+1,pos2)	
	var strYear=st.substring(pos2+1)			

	var po1=to.indexOf(dtCh)	
	var po2=to.indexOf(dtCh,po1+1)	
	var strD=to.substring(0,po1)
	var strMth=to.substring(po1+1,po2)	
	var strYr=to.substring(po2+1)
	
	strMth=strMth.toLowerCase();
	strMonth=strMonth.toLowerCase();
			
	if (strMonth == "jan"){
	month='01';
	}else if (strMonth == "feb"){
	month='02';
	}else if (strMonth == "mar"){
	month='03';
	}else if (strMonth == "apr"){
	month='04';
	}else if (strMonth == "may"){
	month='05';
	}else if (strMonth == "jun"){
	month='06';
	}else if (strMonth == "jul"){
	month='07';
	}else if (strMonth == "aug"){
	month='08';
	}else if (strMonth == "sep"){
	month='09';
	}else if (strMonth == "oct"){
	month='10';
	}else if (strMonth == "nov"){
	month='11';
	}else if (strMonth == "dec"){
	month='12';
	}

if (strMth == "jan"){
	mth='01';
	}else if (strMth == "feb"){
	mth='02';
	}else if (strMth == "mar"){
	mth='03';
	}else if (strMth == "apr"){
	mth='04';
	}else if (strMth == "may"){
	mth='05';
	}else if (strMth == "jun"){
	mth='06';
	}else if (strMth == "jul"){
	mth='07';
	}else if (strMth == "aug"){
	mth='08';
	}else if (strMth == "sep"){
	mth='09';
	}else if (strMth == "oct"){
	mth='10';
	}else if (strMth == "nov"){
	mth='11';
	}else if (strMth == "dec"){
	mth='12';
	}
	
if ((strYear+month+strDay) > (strYr+mth+strD)){
return false;
}else{
return true;
}

}
// ===============================


function allowNonEnterKey(ev) {
	ev.returnValue = (ev.keyCode!=13); 
}

function ConvertToInteger(txt) {
	if (txt.value.length !=0){
		if (txt.value.substring(0,1)==0){	
			txt.value = 0;
		}
		else
		{		
			txt.value = parseInt(txt.value);		
		}
	}
	else
	{
		txt.value="";
	}
}

//-------------------------------
    //Detect Windows Size
//-------------------------------
function getPageSizeWithScroll(){ 
    var y;
    if(typeof(self.outerWidth)=='number') {
        y=self.innerHeight;
    } else {
        y=document.documentElement.clientHeight;
    }    
      
    if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac         
        xWithScroll = document.body.scrollWidth;     
        yWithScroll = document.body.scrollHeight;  
        if (yWithScroll>=y){
            yWithScroll=yWithScroll;            
        }else{
            yWithScroll=y;
        }     
    } 
    else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
        xWithScroll = document.body.scrollWidth;       
        yWithScroll = document.body.offsetHeight; 
        if (yWithScroll>=y){
            yWithScroll=yWithScroll;            
        } else{
            yWithScroll=y;
        }     
    } 
        
    arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
    return arrayPageSizeWithScroll; 
} 

//-----------------------------
    //div Show and Hide
//-----------------------------
function overlay() {
    
    divP = document.getElementById('divParent');                
    divC = document.getElementById('divCtrl'); 
    divB = document.getElementById('divBlack');
    
    scrollingDetector()
    if (divP.style.visibility == 'visible') {
        divP.style.visibility = 'hidden';
        divC.style.visibility = 'hidden';
        divB.style.width = 0;
        divB.style.height = 0;
        divB.style.display = 'none';
        
        var iframe = document.getElementById('iframetop');
        iframe.style.display = 'none';
        iframe.style.width = 0;
        iframe.style.height = 0;
        iframe.style.left = 0;
        iframe.style.top = 0;
    }else{
        divP.style.visibility = 'visible';
        divC.style.visibility = 'visible';        
        var arrPageSizeWithScoll = getPageSizeWithScroll();
        divB.style.width = arrPageSizeWithScoll[0];
        divB.style.height = arrPageSizeWithScoll[1]; 
        divB.style.display = 'block';
        var iframe = document.getElementById('iframetop');
        iframe.style.display = 'block';
        iframe.style.width = divB.offsetWidth-5;
        iframe.style.height = divB.offsetHeight-5;
        iframe.style.left = divB.offsetLeft;
        iframe.style.top = divB.offsetTop;
    }     
}

function startScrollingDetector(){setInterval("scrollingDetector()",50);}

function scrollingDetector()
{    
    var divP = document.getElementById('divParent');      
   	var divB = document.getElementById('divBlack');
   	var divC = document.getElementById('divCtrl'); 
	var tbC = document.getElementById('tbCtrl'); 
	
        //find screen height
        var xScreen;
        var yScreen;
        var xScreen2;
        var yScreen2;
        if(typeof(self.outerWidth)=='number') {
            xScreen=self.innerWidth;
            yScreen=self.innerHeight;
        } else {
            xScreen=document.documentElement.clientWidth;
            yScreen=document.documentElement.clientHeight;
        } 
        
        xScreen2 = document.body.scrollWidth;    
        yScreen2 = document.body.offsetHeight;  
        //screen X
        if (xScreen2>=xScreen){
            xScreen=xScreen2;            
        } else{
            xScreen=xScreen;
        }   
        //Screen Y
        if (yScreen2>=yScreen){
            yScreen=yScreen2;            
        } else{
            yScreen=yScreen;
        }     
        
        //check the scrolling height	
 	    var y;
	    if (navigator.appName == "Microsoft Internet Explorer"){
		    y = document.body.scrollTop;
	    }else {
		    y = window.pageYOffset;
	    }
    	
	    // detect tbCtrl table width
        var tbX;
        var tbY = tbC.scrollHeight; 
        if (tbC.style.width!=''){
            tbX = tbC.style.width;  
        }else if(tbC.width!=''){
            tbX = tbC.width;
        }else{
            tbX = tbC.offsetWidth;
        }
   	    //divC.style.posTop =	y;
   	    divC.style.width = tbX;
   	    divC.style.left = xScreen/2 - (tbX/2);
   	    divC.style.top = y + ((yScreen/2) - (tbY/2));
   	
   	    //Reset divBlack width and height
   	     
        var arrPageSizeWithScoll = getPageSizeWithScroll();
        divB.style.width = arrPageSizeWithScoll[0];
        divB.style.height = arrPageSizeWithScoll[1];      
}

function DisableFormItems()
    {
        var strError='';
        var FormIsValid=true;
        var intTotal=0;
        var btn=arguments[0];
        var strInitialControl='';//auto focus after error encounted

        if(FormIsValid)
            {
                if(FormIsValid)
                    {
                        //submit button
                        //__doPostBack(btn,'')

                        //disable control
                    for (var i=0;i<document.forms[0].elements.length;i++)
                        {
                            if (document.forms[0].elements[i].type == "submit"||document.forms[0].elements[i].type == "button")
                                {
                                    document.forms[0].elements[i].disabled =true;
                                } 
                        }
                    }

                    }

return FormIsValid;
}

function DisableFormItemsPostBack()
    {
        var strError='';
        var FormIsValid=true;
        var intTotal=0;
        var btn=arguments[0];
        var strInitialControl='';//auto focus after error encounted

        if(FormIsValid)
            {
                if(FormIsValid)
                    {
                        //submit button
                        __doPostBack(btn,'')

                        //disable control
                    for (var i=0;i<document.forms[0].elements.length;i++)
                        {
                            if (document.forms[0].elements[i].type == "submit"||document.forms[0].elements[i].type == "button")
                                {
                                    document.forms[0].elements[i].disabled =true;
                                } 
                        }
                    }

                    }

return FormIsValid;
}

var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function checkDate(objY,objM,objD){
	
	var day = objD.value;
	var month = objM.value;
	var year = objY.value;

    if (day==0) day='';
    if (month==0) month='';
    if (year==0) year='';

    if (day!='' && month !='' && year!='') {
 
	    if (year/4 == parseInt(year/4))
		    monthLength[1] = 29;

	    if (day > monthLength[month-1]) {
		    alert("Please select a valid Day and Month.");
		    objD.focus();
		    objD.value = '1';    
    	
		    return false;
	        }
       }
       
    }
    

