$(document).ready(function(){
	$('.print').click(function(){
		window.print();
		return false;
	});						   
});

$.fn.search = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};

	
function fncCloseThisModal() {
	$('.jqmWindow').hide();
	$('.dropShadow').hide();
}

function fncCloseThisModalAndGo(strURL) {
	$('.jqmWindow').hide();
	$('.dropShadow').hide();
	document.location.href = strURL;
}


function fncInvoiceMarkPaid(invID,divID) {
	$.ajax({
		type: "POST",
		url: "InvoicePaid_process.asp",
		data: "invID=" + invID,
		success: function(msg) {
			$(divID).html(msg);
			$("#iBackToList").click(function() {
				document.location = 'invoices-Admin.asp?status=issued&amp;comid=<%=comid%>';
				return false;
			});
		},
		error: function() {
			alert("failed");
		}
	});
}

function fncRoundCurrency(dblUnrounded) {
	//This rounds to two decimal places and zero pads the decimals if necessary to ensure two places are always returned
	dblRounded = (Math.round(dblUnrounded * 100))/100;
	boolSingleZero = dblRounded*10 == Math.round(dblRounded*10);
	boolDoubleZero = dblRounded == Math.round(dblRounded);
	if (boolSingleZero && !boolDoubleZero) {
		dblRounded = dblRounded + "0";
	}
	if (boolDoubleZero) {
		dblRounded = dblRounded + ".00";
	}
	return dblRounded;
}

function fncHelp(hlpID) {
	strURL = "help.asp?hlpid=" + hlpID;
	intHeight = 300;
	intWidth = 300;
	parameters = "location=0,menubar=0,height=" + intHeight + ",width=" + intWidth + ",toolbar=0,scrollbars=1,status=0,resizable=1,left=100,screenX=300,top=100,screenY=300";
	window.open(strURL,'Help',parameters);
	return false;
}

$(document).ready(function(){
	$('.help').click(function(){
		id = this.id;
		hlpid = id.replace("Help","");
		fncHelp(hlpid);
		return false;
	});
	
	$('.backbutton').click(function(){
		window.history.back();
		return false;
	});
	$("#footerlinks a:last").addClass("footerlastlink");

});
