String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}

	if (str.indexOf(" ")!=-1){
		return false
	}

 	return true					
}


function chkContactForm(){
	var msg = "";

	var msg = "";
	pObj = document.forms['contactForm'];
	if (pObj.inputTitle.value.trim() == "") {
		msg = "\nPlease enter your title." + msg;
		pObj.inputTitle.focus();
	}
	if (pObj.inputFname.value.trim() == "") {
		msg = "\nPlease enter your first name." + msg;
		pObj.inputFname.focus();
	}
	if (pObj.inputLname.value.trim() == "") {
		msg = "\nPlease enter your last name." + msg;
		pObj.inputLname.focus();
	}
	if (pObj.inputAddress.value.trim() == "") {
		msg = "\nPlease enter your address." + msg;
		pObj.inputAddress.focus();
	}
	if (pObj.inputTown.value.trim() == "") {
		msg = "\nPlease enter your town." + msg;
		pObj.inputTown.focus();
	}
	if (pObj.inputCounty.value.trim() == "") {
		msg = "\nPlease enter your county." + msg;
		pObj.inputCounty.focus();
	}
	if (pObj.inputTitle.value.trim() == "") {
		msg = "\nPlease enter your postal code." + msg;
		pObj.inputPcode.focus();
	}	
	if (pObj.inputCountry.value.trim() == "") {
		msg = "\nPlease enter your country." + msg;
		pObj.inputCountry.focus();
	}	
	if (pObj.inputComments.value.trim() == "") {
		msg = "\nPlease enter your comments." + msg;
		pObj.inputComments.focus();
	}	
	if (pObj.inputEmail.value.trim() == "") {
		msg = "Please Enter your Email address"
		pObj.inputEmail.focus()
	}
	if (echeck(pObj.inputEmail.value)==false){
		pObj.inputEmail.value=""
		pObj.inputEmail.focus()
		msg = "Invalid email address"
	}			

	if (msg == "") {
		return true;
	} else {
		alert(msg);
		return false;
	}		
}

function chkNewsForm(){
	var msg = "";

	var msg = "";
	pObj = document.forms['newsForm'];
	
	if (pObj.inputTitle.value.trim() == "") {
		msg = "\nPlease enter your title." + msg;
		pObj.inputTitle.focus();
	}
	if (pObj.inputFname.value.trim() == "") {
		msg = "\nPlease enter your first name." + msg;
		pObj.inputFname.focus();
	}
	if (pObj.inputLname.value.trim() == "") {
		msg = "\nPlease enter your last name." + msg;
		pObj.inputLname.focus();
	}
	//if (pObj.inputAddress.value.trim() == "") {
	//	msg = "\nPlease enter your address." + msg;
//		pObj.inputAddress.focus();
	//}
	//if (pObj.inputTown.value.trim() == "") {
	//	msg = "\nPlease enter your town." + msg;
	//	pObj.inputTown.focus();
	//}
	//if (pObj.inputCounty.value.trim() == "") {
	//	msg = "\nPlease enter your county." + msg;
	//	pObj.inputCounty.focus();
	//}
	//if (pObj.inputPcode.value.trim() == "") {
	//	msg = "\nPlease enter your postal code." + msg;
	//	pObj.inputPcode.focus();
	//}	
	//if (pObj.inputCountry.value.trim() == "") {
	//	msg = "\nPlease enter your country." + msg;
//		pObj.inputCountry.focus();
	//}	
	if (pObj.inputEmail.value.trim() == "") {
		msg = "Please Enter your Email address"
		pObj.inputEmail.focus()
	}
	if (echeck(pObj.inputEmail.value)==false){
		pObj.inputEmail.value=""
		pObj.inputEmail.focus()
		msg = "Invalid email address"
	}			

	if (msg == "") {
		return true;
	} else {
		alert(msg);
		return false;
	}		
}

function chkSearchForm(){
	var msg = "";

	var msg = "";
	pObj = document.forms['searchForm'];
	if (pObj.inputSearch.value.trim() == "") {
		msg = "\nPlease enter your search." + msg;
		pObj.inputSearch.focus();
	}	

	if (msg == "") {
		return true;
	} else {
		alert(msg);
		return false;
	}		
}

function getRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}
function showObj(obj)
{
	if (bTypeNs) {
		var pObj = (NN4) ? document[obj] : document.getElementById(obj).style;
	} else {
		var pObj = document.all[obj].style;
	}
	pObj.visibility = VISIBLE;
}

function hideObj(obj)
{
	if (bTypeNs) {
		var pObj = (NN4) ? document[obj] : document.getElementById(obj).style;
	} else {
		var pObj = document.all[obj].style;
	}
	pObj.visibility = HIDDEN;
}

function moveObj(obj,oLeft,oTop)
{
	if (bTypeNs) {
		var pObj = (NN4) ? document[obj] : document.getElementById(obj).style;
	} else {
		var pObj = document.all[obj].style;
	}
	pObj.left = oLeft;
	pObj.top = oTop;
}

// determine browser version
var bTypeNs = (navigator.appName=="Netscape" && parseInt(navigator.appVersion) >= 4);
var NN4 = false;
var NN6 = false;
var IE4 = false;
if (bTypeNs) {
	if (parseInt(navigator.appVersion) < 5) {
		NN4 = true;
	} else {
		NN6 = true;
	}
} else {IE4 = true;}

// determine platform
var isMac = navigator.appVersion.indexOf('Mac') > 0 ? 1 : 0 ;

// setup defaults
var HIDDEN = (NN4) ? 'hide' : 'hidden';
var VISIBLE = (NN4) ? 'show' : 'visible';
var navVersion = parseInt(navigator.appVersion);
