
$(document).ready(function () {
		
	// tool tip
	$("#recalculate").hover(function () {
		$(this).append("<span class=\"toolTip\">Change loan options and recalculate</span>");
	}, function () {
		$(this).find("span:last").remove();
	});
	
	$("#save").hover(function () {
		$(this).append("<span class=\"toolTip\">Save loan information to your Business Victoria Account</span>");
	}, function () {
		$(this).find("span:last").remove();
	});
	
	$("#print").hover(function () {
		$(this).append("<span class=\"toolTip\">Print or save loan information as a PDF</span>");
	}, function () {
		$(this).find("span:last").remove();
	});
	
	$("#back").hover(function () {
		$(this).append("<span class=\"toolTip\">Return to the previous screen</span>");
	}, function () {
		$(this).find("span:last").remove();
	});
	
	$("#compareproductstop").hover(function () {
		$(this).append("<span class=\"toolTip\">To compare loans, select two or more options and click Compare</span>");
	}, function () {
		$(this).find("span:last").remove();
	});
	
	$("#compareproductsdown").hover(function () {
		$(this).append("<span class=\"toolTip\">To compare loans, select two or more options and click Compare</span>");
	}, function () {
		$(this).find("span:last").remove();
	});
	

$.tablesorter.addParser({ 
        // set a unique id 
        id: 'percentsorter', 
        is: function(s) { 
            // return false so this parser is not auto detected 
            return false; 
        }, 
        format: function(s) { 
            // format your data for normalization
            var data=s.replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace('%','');
            
            if (data == '-')
            {
            	data = '100';
            }  
            return data; 
        }, 
        // set type, either numeric or text 
        type: 'numeric' 
    }); 
    
$.tablesorter.addParser({
          id: 'datesorter',
          is: function(s) {
				return false;
  		  },
  		format: function(s) {
			var day  = s.substring(0,2);
			s = s.replace(' ','');
			var month = s.substring(3,5);
			var year = s.substring(6,10);
			var time = s.substring(11).replace(':','');
    		return year+month+day+time;
  			},
  		type: 'numeric'
});      

	$("#tablesorter").tablesorter({
        sortList: [[$("#sortColumn").val(),0]]
    }); 
    
    $("#tablesorter1").tablesorter();
    $("#tablesorter2").tablesorter();
    $("#tablesorter3").tablesorter();
	$("#tablesorter4").tablesorter();
    
		    

	// Landing page
	$("#amountToBorrow").focus();
	
	$("#amountToBorrow").keypress(function (e)
	{
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
	    //display error message
	    $("#errmsg").html("Digits Only").show().fadeOut("slow");
	    return false;
	  }
	});

	$("#ongoingCreditAmount").keypress(function (e)
	{
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
	    //display error message
	    $("#errmsg").html("Digits Only").show().fadeOut("slow");
	    return false;
	  }
	});	 
	
	$("#loanTerm").keypress(function (e)
	{
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
	    //display error message
	    $("#errmsg").html("Digits Only").show().fadeOut("slow");
	    return false;
	  }
	});	
	
	$("#startDateDay").keypress(function (e)
	{
		return validNumber(e);
	});

	$("#startDateMonth").keypress(function (e)
	{
		return validNumber(e);
	});

	$("#startDateYear").keypress(function (e)
	{
		return validNumber(e);
	});

	$("#endDateDay").keypress(function (e)
	{
		return validNumber(e);
	});

	$("#endDateMonth").keypress(function (e)
	{
		return validNumber(e);
	});

	$("#endDateYear").keypress(function (e)
	{
		return validNumber(e);
	});

	
	
	$("#upfront").click(function () {
	//$("#accessNeed2").click(function () {
	$("#accessNeedError").hide();
	$("#loanTermError").hide();
		$("#term").show();
		$("#termspace").show();
		$(".remainingquestions").show();
		$("#ongoing").hide();
		$("#ongoingspace").hide();
		
	});
	$("#atcall").click(function () {
	//$("#accessNeed1").click(function () {
	
		$("#accessNeedError").hide();
		$("#loanTermError").hide();
		$("#term").hide();
		$("#termspace").hide();
		$("#ongoing").show();
		$("#ongoingspace").show();
		$(".remainingquestions").show();
		
	});	
	
	$("#frmuserreq").validate({rules:{amountToBorrow:{digits:true},ongoingCreditAmount:{digits:true}, loanTerm:{digits:true}}});

	 
	 $("#amountToBorrow").change(function(){
	 	validateAmountToBorrow();
	 
	 });

	 $("#ongoingCreditAmount").change(function(){
		 validateOngoingCreditAmount();

	});
	
	 $("#loanTerm").change(function(){
	 	validateLoanTerm();
	 
	 });	 
	
	$("#fixed").click(function () {
	 $("#interestRateTypeError").hide();
	 });	

	$("#variable").click(function () {
		 $("#interestRateTypeError").hide();
	 });
	 
	$("#donotcare").click(function () {
		$("#interestRateTypeError").hide();
	 });


	$("#residential").click(function () {
	 $("#securityTypeError").hide();
	 });	

	$("#nonResidential").click(function () {
		 $("#securityTypeError").hide();
	 });
	 
	$("#unsecured").click(function () {
		$("#securityTypeError").hide();
	 });
	 	 
	 
	// Submit landing page
	$("#gonextpage").click(function () {
		//$("#frmuserreq").submit();
				
		var amountToBorrowValid = validateAmountToBorrow();
		var ongoingCreditAmountValid = validateOngoingCreditAmount();
		var loanTermValid = validateLoanTerm();
		
			if (amountToBorrowValid && ongoingCreditAmountValid )
			{
				$("#frmuserreq").submit();
				return;
			}
		
			if (  amountToBorrowValid && loanTermValid)
			{
				$("#frmuserreq").submit();
				return;
			}
		
		
	});
	
	
	// submit loan option page for product comparison
	$("#compareproductstop").click(function () {
	    
	    var selector_checked = $("input[@id=products]:checked").length;
	     var selector= $("input[@id=products]").length;
	    if ( selector_checked <= 1  )
	    {
	    	blfalert('You need to select at least 2 loans to compare.');
	    }	
	    else if (selector_checked == selector) 
	    {
	    	blfalert("You have selected all displayed products which are already compared and displayed on screen.");
	    }
	    else
	    {
	    	$("#frmloanoptions").submit();
	    }	

	});
	$("#compareproductsdown").click(function () {
		var selector_checked = $("input[@id=products]:checked").length; 
	    if ( selector_checked <= 1  )
	    {
	    	blfalert('You need to select atleast 2 loans to compare.');
	    }	
	    else
	    {
	    	$("#frmloanoptions").submit();
	    }	
	});
	
	// submit for re-calculate
	
	$("#frmrecalculate").validate({rules:{amountToBorrow:{digits:true},ongoingCreditAmount:{digits:true}, loanTerm:{digits:true}}});
	$("#recalculate").click(function () {

		var productType = $("#productTypeRecommended").text();
		productType = jQuery.trim(productType);
		var amountToBorrowValid = validateAmountToBorrow();
		
		if ( productType == '1' ||  productType == '3' )
		{	
			var ongoingCreditAmountValid = validateOngoingCreditAmount();
			if (  amountToBorrowValid && ongoingCreditAmountValid )
			{
				$("#frmrecalculate").submit();
			}
		}
		if ( productType == '2' )
		{
			var loanTermValid = validateLoanTerm();
			if (  amountToBorrowValid && 	loanTermValid )
			{
				$("#frmrecalculate").submit();
			}
		}

		
	});
	
	// Loan option page
	$("#showlender").click(function () {
		totalavgmonthlycost();
		$("input[@name='sortColumnName']").val("showlender");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showloan").click(function () {
		totalavgmonthlycost();
		$("input[@name='sortColumnName']").val("showloan");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#shownotes").click(function () {
		totalavgmonthlycost();
		$("input[@name='sortColumnName']").val("shownotes");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showpropertytype").click(function () {
		totalavgmonthlycost();
		$("input[@name='sortColumnName']").val("showpropertytype");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showtotalavgmonthlycost").click(function () {
		totalavgmonthlycost();
		$("input[@name='sortColumnName']").val("showtotalavgmonthlycost");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showlowestlinefee").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").show();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showlowestlinefee");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showlowestfixedinterestrate").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").show();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showlowestfixedinterestrate");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showlowestvariableinterestrate").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").show();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showlowestvariableinterestrate");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showlowestupfrontfee").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").show();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showlowestupfrontfee");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showlowestservicefee").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").show();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showlowestservicefee");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showlowestexitfee").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").show();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showlowestexitfee");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showtotalavgmonthlycostvar").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").show();
		$("#totalavgmonthlycostfixed").hide();
		$("input[@name='sortColumnName']").val("showtotalavgmonthlycostvar");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	$("#showtotalavgmonthlycostfixed").click(function () {
		$("#totalavgmonthlycost").hide();
		$("#lowestupfrontfee").hide();
		$("#lowestlinefee").hide();
		$("#lowestexitfee").hide();
		$("#lowestservicefee").hide();
		$("#lowestfixedinterestrate").hide();
		$("#lowestvariableinterestrate").hide();
		$("#totalavgmonthlycostvar").hide();
		$("#totalavgmonthlycostfixed").show();
		$("input[@name='sortColumnName']").val("showtotalavgmonthlycostfixed");
		$("input[@name='sortOrder']").val(reverseValue($("input[@name='sortOrder']").val()));
	});
	
	$("#frmsysrecreport").submit(function() {
	
		return validateFormFields('systemRecommendedXls.html');
    });
	
	$("#frmuserinforeport").submit(function() {
		return validateFormFields('userInformationXls.html');
    });
    $("#frmloadproducts").submit(function(){
    	var fileName = document.getElementById('productfile').value;
    	if (fileName.length == 0) 
    	{
			blfalert("Please select a Loan Product file for import.");
	   		return false;
    	}
    	else
    	{
    		return true;
    	}
    }); 
	
});
function reverseValue(value) {
	var frm = document.getElementById("frmloanoptions");
	var reValue = false;
	if (frm.lastSortColumnName.value == frm.sortColumnName.value) {
		if (reValue == "false") {
			reValue = "true";
		}
		else {
			reValue = "false";
		}
		
		
	} else {
		reValue = "true";
	}
	frm.lastSortColumnName.value = frm.sortColumnName.value;
	return reValue;
}
function printLoanOption(state) {
	var frm = document.getElementById("frmloanoptions");
	var url = "printreport.html";
	url = url + "?sortOrder=" + frm.sortOrder.value;
	url = url + "&sortColumnName=" + frm.sortColumnName.value;
	url = url + "&pageId=" + frm.reportType.value;
	url = url + "&state="+state;
	window.open(url);
}
function totalavgmonthlycost() {
	if ($("#interestRateType").val() == "donotcare") {
		$("#totalavgmonthlycostfixed").show();
	} else {
		$("#totalavgmonthlycost").show();
	}
	$("#lowestupfrontfee").hide();
	$("#lowestlinefee").hide();
	$("#lowestexitfee").hide();
	$("#lowestservicefee").hide();
	$("#lowestfixedinterestrate").hide();
	$("#lowestvariableinterestrate").hide();
	$("#totalavgmonthlycostvar").hide();
}

function saveReport(){
	var frm = document.getElementById("frmloanoptions");
	var reportType = frm.reportType.value;
	var url= "save.html?pageId=" + reportType;
	url = url + "&sortOrder=" + frm.sortOrder.value;
	url = url + "&sortColumnName=" + frm.sortColumnName.value;
	window.location = url;
} 

function validateAmountToBorrow()
{
 	var amtToBorrow = $("#amountToBorrow").val();	 
 	var ongoingCreditAmount = $("#ongoingCreditAmount").val();
 	var accNeed =$("input[@name='accessNeed']:checked").val();	
 	amtToBorrow = parseInt(amtToBorrow);
 	ongoingCreditAmount =  parseInt(ongoingCreditAmount);
	 if ( amtToBorrow <= 0 || amtToBorrow > 99999999)
	 {
		 $("#amountToBorrowError").text("Please enter the loan amount between 1 and 99,999,999");
		 $("#amountToBorrowError").addClass("errors");
		 $("#amountToBorrowError").show();
		 return false;
	 }
	 else if (accNeed == 'atcall')
	 {
		 
		 if ( amtToBorrow < ongoingCreditAmount )
		 {
		 	$("#amountToBorrowError").text("Please enter the loan amount that is greater than or equal to the avg amount needed");
		 	$("#amountToBorrowError").addClass("errors");
		 	$("#amountToBorrowError").show();
		 	 return false;
		 }
		 
		 else
		 {
			 $("#amountToBorrowError").hide();
			
			 if ( ongoingCreditAmount > 0 )
			 {
			 	 $("#ongoingCreditAmountError").hide();
			 }
			
			  return true;
		 }
		 
	 }
	 else 
	 {
	 	return true;
	 }
	 
}

function validateOngoingCreditAmount()
{
	 var ongoingCreditAmount = $("#ongoingCreditAmount").val();	 
	 var amtToBorrow = $("#amountToBorrow").val();	 
	 amtToBorrow = parseInt(amtToBorrow);
	 ongoingCreditAmount =  parseInt(ongoingCreditAmount);
	 //alert ( ' inside validateOngoingCreditAmount ' + ongoingCreditAmount);
	 if ( ongoingCreditAmount <= 0 || ongoingCreditAmount > amtToBorrow)
	 {
		 $("#ongoingCreditAmountError").text("Please enter the avg amount needed between 1 and the loan amount");
		 $("#ongoingCreditAmountError").addClass("errors");
		 $("#ongoingCreditAmountError").show();
		 if ( ongoingCreditAmount == 0 && amtToBorrow > 0 )
		 {
		 	$("#amountToBorrowError").hide();
		 }
		 return false;
	 }
	 else
	 {
			 $("#ongoingCreditAmountError").hide();
			 $("#amountToBorrowError").hide();
			 return true;

	 }
}

function validateLoanTerm()
{
	 var loanTerm = $("#loanTerm").val();
	 loanTerm = parseInt(loanTerm);
	 if ( loanTerm <= 0 || loanTerm > 30 )
	 {
	  	$("#loanTermError").text("Please enter the loan term between 1 and 30");
		$("#loanTermError").addClass("errors");
		$("#loanTermError").show();
		return false;
	 }
	 else	 
	 {
		 $("#loanTermError").hide();
		  return true;
	 }	
}

	function functionSetStartDate(formobj){
		var date=formobj.startDate.value;
		if (date.length==10)
		{
			formobj.startDateDay.value=date.substring(0,2);
			formobj.startDateMonth.value=date.substring(3,5);
			formobj.startDateYear.value=date.substring(6);
		}
	}
	function functionSetEndDate(formobj){
		var date=formobj.endDate.value;
		if (date.length==10)
		{
			formobj.endDateDay.value=date.substring(0,2);
			formobj.endDateMonth.value=date.substring(3,5);
			formobj.endDateYear.value=date.substring(6);
		}
	}
	
	function  validNumber(e) 
	{
	  if ( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
	    return false;
	  }
	}
	
	function checkMonth(dateMonth,whichDate)
	{
		var dmth = document.getElementById(dateMonth).value;
		if (dmth.length == 0)
		{
			document.getElementById(dateMonth).focus();
			blfalert("Invalid " + whichDate + ".");
			return false;
		}

		if ((dmth < 1) || (dmth > 12)) 
		{
			blfalert("Month : " + dmth + " should be between 1 and 12");
			document.getElementById(dateMonth).focus();
			return false;
		}
		return true;
		
		
	}
	
	function checkDay(dateDay,whichDate)
	{
		var dday = document.getElementById(dateDay).value;
		if (dday.length == 0)
		{
			blfalert("Invalid " + whichDate + ".");
			document.getElementById(dateDay).focus();
			return false;
		}
		if ((dday < 1) || (dday > 31)) 
		{
			blfalert("Date : " + dday  + " should be between 1 and 31");
			document.getElementById(dateDay).focus();
			return false;
		}
		return true;
	}
	
	function checkYear(dateYear,whichDate)
	{
		var dyear = document.getElementById(dateYear).value;
		if (dyear.length == 0)
		{
			blfalert("Invalid " + whichDate + ".");
			document.getElementById(dateYear).focus();
			return false;
		}
		if ((dyear == 0) || (dyear.length < 4)) 
		{
			blfalert("Year : " + dyear + " should be 4 digit. e.g 2008");
			document.getElementById(dateYear).focus();
			return false;
		}
		return true;
		
	}
	
	function validateFormFields(reportXlsUrl)
	{
		var sdate = document.getElementById('startDateDay').value+'/'+document.getElementById('startDateMonth').value+'/'+document.getElementById('startDateYear').value;
		var edate = document.getElementById('endDateDay').value+'/'+document.getElementById('endDateMonth').value+'/'+document.getElementById('endDateYear').value;
		
		// check if dates are not empty
		if (!emptyDate())
		{
			return false;
		}
				
		// check if dates are valid
		if (!validateDates(sdate,edate))
		{
			return false;
		}
		
		if (!compareDates(sdate,edate))
		{
			return false;
		}
		
		document.getElementById('startDate').value =sdate;
		document.getElementById('endDate').value =edate;
		
      	if ($("input[@name='format']:checked").val() == "screen") 
      	{
        	return true;
      	}
      	else 
      	{
      		var params = "startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&resultType="+$("input[@name='resultType']:checked").val()+"&productType="+$("#productType").val();
      		window.open(reportXlsUrl+"?"+params);
      		return false;
      	}
	
	}
	
	function validateDates(sdate,edate)
	{
		var tempStartDate =new Date();
		tempStartDate.setYear(parseInt(document.getElementById('startDateYear').value,10));
		tempStartDate.setMonth(parseInt(document.getElementById('startDateMonth').value,10)-1);
		var tempStartMth = parseInt(document.getElementById('startDateMonth').value,10)-1;
		
		tempStartDate.setDate(parseInt(document.getElementById('startDateDay').value,10));

		if (tempStartMth != tempStartDate.getMonth())
		{
			blfalert('Invalid From date.');
			document.getElementById('startDateDay').focus();
			return false;
		}

		var tempEndDate =new Date();
		tempEndDate.setYear(parseInt(document.getElementById('endDateYear').value,10));
		tempEndDate.setMonth(parseInt(document.getElementById('endDateMonth').value,10)-1);
		var tempEndMth = parseInt(document.getElementById('endDateMonth').value,10)-1;
		tempEndDate.setDate(parseInt(document.getElementById('endDateDay').value,10));
		if (tempEndMth != tempEndDate.getMonth())
		{
			blfalert('Invalid To date.');
			document.getElementById('endDateDay').focus();
			return false;
		}
		return true;
	}
	
	function compareDates(sdate,edate)
	{
		var dateCompareMessage='To date should be greater than From date.';
		if (document.getElementById('endDateYear').value < document.getElementById('startDateYear').value)
		{
			blfalert(dateCompareMessage);
			return false;
		}
		else if (document.getElementById('endDateYear').value == document.getElementById('startDateYear').value)
		{
			if (document.getElementById('endDateMonth').value < document.getElementById('startDateMonth').value)
			{
				blfalert(dateCompareMessage);
				return false;
			}
			else if (document.getElementById('endDateMonth').value == document.getElementById('startDateMonth').value)
			{
				if (document.getElementById('endDateDay').value < document.getElementById('startDateDay').value)
				{
					blfalert(dateCompareMessage);
					return false;
				}
			}
		}
		return true;
	}
	
	
	function emptyDate()
	{
		// Validate from date
		if (!checkDay('startDateDay','From date')) 
		{
			return false;
		}
		if (!checkMonth('startDateMonth','From date'))
		{
			return false;
		}
		if (!checkYear('startDateYear','From date'))
		{
			return false;
		}

		// Validate to date
		if (!checkDay('endDateDay','To date')) 
		{
			return false;
		}
		if (!checkMonth('endDateMonth','To date'))
		{
			return false;
		}
		if (!checkYear('endDateYear','To date'))
		{
			return false;
		}	
		return true;
	}
	
	
	function clearReportValues()
	{
		document.getElementById('startDateDay').value ='';
		document.getElementById('startDateMonth').value ='';
		document.getElementById('startDateYear').value ='';
		document.getElementById('startDate').value ='';
		document.getElementById('endDateDay').value ='';
		document.getElementById('endDateMonth').value ='';
		document.getElementById('endDateYear').value ='';
		document.getElementById('endDate').value ='';

	}
	
	function blfalert(message)
	{
		$.prompt("\n" + message,{
      	buttons:{Ok:true},
      	prefix:'cleanblue'
		});
		return;
	}