// ----------------------------------------------------------------------------------
// -     COPYRIGHT - Gary Flaxmer and FanZone.co.uk 2008.  All rights reserved.     -
// ----------------------------------------------------------------------------------

// set the target for all 'rel' links
$(document).ready(function() {
    $("a[@rel]").attr("target", "blank");
});

function trim(pText) {
    return pText.replace(/^\s{1,}/, '').replace(/\s{1,}$/, '');
}

function gotoValue(pURL) {
    if (trim(pURL) != '') { location.href = pURL }
}

function gotoURL(url) {
    location.href = url;
}

var isPostCode = /^[a-z]{1,2}[0-9]\d{0,1}[a-z]?\s?\d[a-z]{2}$/i;
var isEmailAddress = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
var isNumeric = /^\d+$/;
var is2DecPlaces = /^\d+\.\d{2}$/;
var isCurrency = /^\d{1,3}(,\d{3})*\.\d{2}$/;
var isAlpha = /^\D+$/;
var isPhoneNo =  /^\d{10,11}$/;
var isMobileNo =  /^\d{11}$/;
var isAlphaNumeric = /^\w*$/;
var isIllegalCharacter= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
var isEven = /[02468]/;
var isDateFormat = /\d\d\D\d\d\D\d\d\d\d/;
var isBuildingNo = /^\d+\D+$|^\d+/;

function isValid(pattern, str){
 switch (typeof str){
  case "string":
   return pattern.test(str)
  case "object":
   return pattern.test(str.value)
  default:
   return false;
 }
}


function clearSearch(pListName)
{
   document.forms[0].reset();
   var objListName=document.getElementById(pListName);
   if(objListName != null)
        objListName.className = 'lstOff';
}

function resetForm(){
    try{
        if(confirm('Clear the form, by removing all the data you have entered\n\nAre you sure?'))
            document.forms[0].reset();
    }
    catch(e)
    {
    }
    return false;
}

function back(){
    history.back();    
    return false;
}