
/*START DATE PICKER */
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var daysInMonthl = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
   
function getDaysOfMonth(currYear, currMonth) {	
	if((currYear % 4) == 0) {
		if ((currYear % 100) == 0 && (currYear % 400) != 0)
			return daysInMonth[currMonth];
	
		return daysInMonthl[currMonth];
	} 
	else
		return daysInMonth[currMonth];
}

function SetUpDays(parent, cboYear, cboMonth, cboDay){
	try{					  
		var year = eval(parent + "." + cboYear + ".value");
		var month = eval(parent + "." + cboMonth + ".value") - 1;
		var objDay = eval(parent + "." + cboDay);
	
		if(year < 1 || month < 0)
			return;
				
	  var selectedDay = objDay.value			    
		objDay.innerHTML = "";
		
		var oOption = document.createElement("OPTION");
		oOption.value = "-1";
		oOption.text = "--";
		objDay.add(oOption);
	
		for(var i = 1; i <= getDaysOfMonth(year, month); i++){
			var oOption = document.createElement("OPTION");
			oOption.value = (i < 10? "0" + i : i);
			oOption.text = (i < 10? "0" + i : i);			  
			objDay.add(oOption);							
			  
			if(oOption.value == selectedDay)
				oOption.selected = true;			  
		}				
	}
	catch(Exception){}		
}
/*END DATE PICKER */
/*Begin Grid*/
function NextPage(CurrentPage, TotalPages, objGotoPage, objForm){
	try{
		var newPg = prompt("Enter the page number to browse to.", CurrentPage);
		    
		if (newPg == null) 
			return;
		          
		if(isNaN(newPg)){ 
			alert("Invalid page");
			return;
		}
		          
		if(newPg > TotalPages){ 
			alert("Invalid page");
			return;
		}
		        
		if (newPg < 1){
			alert("Invalid page");
			return;
		}		        
		
		try{
		  objGotoPage.value = newPg;		     
		  objForm.submit();								
		}
		catch(Exception){}
	}
	catch(Exception){}
}

function Toggle(o, p){
	if(o.style["display"] == null){
		o.style["display"] = '';
		p.innerHTML = p.innerHTML.replace('up.gif', 'down.gif');
	}
	else if(o.style["display"] == ''){
		o.style["display"] = 'none';
		p.innerHTML = p.innerHTML.replace('down.gif', 'up.gif')
	}
	else{
		o.style["display"] = '';
		p.innerHTML = p.innerHTML.replace('up.gif', 'down.gif')
	}
}
/*END Grid*/

function ShowDialog(url){
	window.showModelessDialog(url, "dialogHeight: 600px; dialogWidth: 600px;  dialogLeft: 291px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
}

function OpenWindow(url, heading){
	window.open(url, heading, "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=675,height=600,top=1,left=1");
}

function OpenWindow2(url){
	window.open(url, "", "height=550,width=750,status=yes,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes");
}

function ResetIndex(){
	try{		
		parent.menu.document.location = "../MainMenu/Index.aspx";
	}
	catch(Exception){		
	}
}

function ResetIndex2(){
	try{		
		parent.menu.document.location = "MainMenu/Index.aspx";
	}
	catch(Exception){		
	}
}

function ResetIndexToBlank(){
	try{		
		parent.menu.document.location.href = "Clean.htm"
	}
	catch(Exception){		
	}
}

function ConfirmSave(){
	window.close();
}	

/*BEGIN VALIDATER FOR Dropdown List*/
function DDLCustomValidator_ClientValidate(s, e){
	try{				
		if(e.Value < 1)
			e.IsValid = false;
			else
				e.IsValid = true;
	}
	catch(Exception){
		e.IsValid = false;
	}
}
/*END VALIDATER FOR Dropdown List*/

/*BEGIN VALIDATER FOR DatePicker*/
function DatePickerCustomValidator_ClientValidate(s, e){
	try{		
		var strParent = s.id.substring(0, s.id.length - 10)
		var lblError = document.all[strParent + "lblError"];
		var cboYear = document.all[strParent + "cboYear"];
		var cboMonth = document.all[strParent + "cboMonth"];
		var cboDay = document.all[strParent + "cboDay"];
		
		if(cboDay == null)
			cboDay = cboMonth;
					
		if(window.event.srcElement.id.substring(0,3) == 'btn'){  								 
			if(cboYear.selectedIndex > 0 && cboMonth.selectedIndex > 0 && cboDay.selectedIndex > 0){
				e.IsValid = true;
				lblError.style.visibility = 'hidden';
			}
			else{
				e.IsValid = false;							
				lblError.style.visibility = '';
			}
		
		}
		else{
			if(window.event.srcElement.selectedIndex < 1 && (cboYear.selectedIndex > 0 || cboMonth.selectedIndex > 0 || cboDay.selectedIndex > 0)){				
				e.IsValid = false;					
				lblError.style.visibility = '';						
			}
			else if(cboYear.selectedIndex > 0 && cboMonth.selectedIndex > 0 && cboDay.selectedIndex > 0){
				e.IsValid = true;	
				lblError.style.visibility = 'hidden';
			}
			else if(cboYear.selectedIndex == 0 && cboMonth.selectedIndex == 0 && cboDay.selectedIndex == 0){
				e.IsValid = true;	
				lblError.style.visibility = 'hidden';
			}
		}		
	}
	catch(Exception){	
		e.IsValid = false;
	}	
}

function DatePickerCustomValidator_ClientMandatory(s, e){
	try{		
		var strParent = s.id.substring(0, s.id.length - 10)
		var lblError = document.all[strParent + "lblError"];
		var cboYear = document.all[strParent + "cboYear"];
		var cboMonth = document.all[strParent + "cboMonth"];
		var cboDay = document.all[strParent + "cboDay"];
			
		if(cboDay == null)
			cboDay = cboMonth;
			
		if(window.event.srcElement.id.substring(0,3) == 'btn'){			
			
									
			if(cboYear.selectedIndex < 1 || cboMonth.selectedIndex < 1 || cboDay.selectedIndex < 1){
				e.IsValid = false;
				lblError.style.visibility = '';
			}
			else{
				e.IsValid = true;
				lblError.style.visibility = 'hidden';
			}
		}
		else{
			if(window.event.srcElement.selectedIndex < 1){				
				e.IsValid = false;
				lblError.style.visibility = '';
			}
			else if(cboYear.selectedIndex > 0 && cboMonth.selectedIndex > 0 && cboDay.selectedIndex > 0){
				e.IsValid = true;	
				lblError.style.visibility = 'hidden';
			}
		}			
			
	}
	catch(Exception){	
		e.IsValid = false;
	}	
}
/*END VALIDATER FOR DatePicker*/
