﻿function CheckChange(Type)
{
    if(Type=="Date")
    {
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtStartDate').disabled=false;
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtEndDate').disabled=false;
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_ddlBuildEvent').disabled=true;
    }
    if(Type=="Event")
    {
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtStartDate').disabled=true;
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtEndDate').disabled=true;
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_ddlBuildEvent').disabled=false;        
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtStartDate').value="";
        document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtEndDate').value="";

    }
}
function CheckSearchForm(elm)
{
    if(document.getElementById(elm).checked==true)
    {
        var StartDate=document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtStartDate').value;
        var EndDate=document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtEndDate').value;

        if(StartDate == '' || StartDate == null)
        {
          alert('Start date cannot be blank');
          document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtStartDate').focus();
          return false;
        }
        if(EndDate !='' || EndDate !=null)
        {
            var datDate1 = new Date(Formatddmmyyyy(StartDate));   
            var datDate2 = new Date(Formatddmmyyyy(EndDate));                

            if(datDate2 < datDate1)
            {    
                alert("End Date cannot be Less than Start Date");
                document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_txtStartDate').focus();
                return false;
            }
        }
    }
    else
    {
        if(document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_ddlBuildEvent').value=='0')
        {
          alert('Please select event');
          document.getElementById('ctl00_VlntrBfrLgnCntntPlcHldr_ddlBuildEvent').focus();
          return false;
        }
    }
    return true;
}

function Formatddmmyyyy(strdate){
	        var thedate = new Date(strdate);
	        var month = thedate.getMonth() + 1;
	        var day = thedate.getDate();
	        var year = thedate.getFullYear();
	        var s = "-";

	        if (month<=9) month="0"+month;
	        if (day<=9) day="0"+day;

	        return( month + s + day + s + year);
        }        
        
        
function FormLoading(str)
{
       try {lval.remove(); lval="";}catch(e) {lval=getBusyOverlay(str,{color:'#A9A9A9', opacity:0.5, text:'Processing...', style:'text-decoration:blink;font-weight:bold;font-size:12px;color:white'},{color:'#fff', size:128, type:'o'});} 
}

function keyCheckForShift()

{

    var keyID = event.keyCode;

    switch(keyID)

    {

        case 35:    

        case 36:

        case 37:

        case 38:

        case 39:    

        case 40:

                return true;

                break;

        default:

                return false;

                break;       

    }

}