// THIS PAGE INCLUDES CUSTOM FUNCTIONS FOR THE CLIENT
// fix console error on IE
if(typeof(console) != "object") {var console = new Object(); console.log = function() {} };


function params(qp) { try{r=unescape(location.search.match(new RegExp(qp+"=+([^&]*)"))[1]);}catch(e){r='';} return r; }


function writeYear() {
	RightNow = new Date();
	var TheYear = RightNow.getYear()
	
	if (TheYear >= 100 && TheYear <= 1999)
	{TheYear=TheYear + 1900}
	else
	{TheYear=TheYear}
	document.write(TheYear)
}

function customHandler(desc,page,line,chr)  {		// Display Errors in status	 
	window.status = "JAVASCRIPT ERROR : " + desc + " : PAGE=" + page + " : LINE=" + line;
	return true;
}
//window.onerror=customHandler;


function confirmCancel(confirmWhat)	{
	return confirm("Are you sure you want to " + confirmWhat + "?");
}

function doMail(theLink, key){

    //Get the HREF tag. This includes the anti-spam 'key'
    var before = theLink.getAttribute('href');

    //If the anti-spam key is not found in the link, exit the function without doing anything
    //If the link is clicked more than once, this prevents the Javascript from throwing an error
    if(before.indexOf(key) == -1) return false;

    //Our new variable "addy" is a combination of the text that
    //comes BEFORE the key [0] and AFTER the key [1]
    var addy = before.split(key)[0] + before.split(key)[1];

    //Substitute the original link with the new link ("addy")
    theLink.href = addy;

}

// <a href="mailto:someone@-remove-somewhere.com" onclick="doMail(this, '-remove-')">email

AddDefaultHook = function(obj, button) {
	default_click(obj, $(button));
}


default_click = function(curObj, buttonObj) {
	curObj.onkeypress = function(e) {
		e = window.event || e;
		if (e.keyCode == 13) {
			if (e.preventDefault)
				e.preventDefault();
				
			e.returnValue=false;
			e.cancel = true;
			if (buttonObj.click) {
				buttonObj.click();
			}
			else {
				$(buttonObj).click();
			}
			
			
		}
	}
}
