var $ = jQuery.noConflict();
$(document).ready(function() {

	
});

function startAjax(result_display, data){
	$('#loading_image').show();
	$.ajax({
		type: "POST",
		url: "/ajax/ajax.php",
		data: data,
		cache: false,
		timeout: 5000,
		error: function(response) {
			displayErrorMessage();
		},
		success: function(response){
			setTimeout("finishAjax('"+result_display+"', '"+escape(response)+"')", 600);
		}
    });	
}

function finishAjax(id, response){
  $('#loading_image').hide();
  $(id).html(unescape(response));
  $(id).show();
}


function decision(message, url){
	if(confirm(message)) location.href = url;
}

function displayErrorMessage(){
	$("#loading_image").hide();
	alert("Requested data could not be loaded, please try again.\n\nIf the problem continues, please contact us with details of what you were attempting to do.");
}

function gotoPageLink(pageLink){
	if(pageLink!=""){
		$target = $('a[@name=' + pageLink +']');
		if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body').animate({scrollTop: targetOffset}, 1000);
			return false;
		}
	}
}

function validateDate(form_value) {
    var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
    if (form_value.match(RegExPattern)== null) {
        return true; 
    } else {
        return false; 
    } 
}

function isNumeric(form_value){ 
    if(form_value.match(/^\d+$/) == null){
        return true; 
    }else{
		return false; 
	}
}
