
//////////////////////////////////////////////////

// Open Popup 

openPopup = function(mypage,w,h,scroll,resizable,Lpos,Tpos) {
	var win = null;
	
	settings = 'height='+h+',width='+w+',top='+Tpos+',left='+Lpos+',scrollbars='+scroll+',resizable='+resizable+'';
	
	win = window.open(mypage,"popUp",settings)
	win.focus();
}

/*
 * Create email adresses
 * Used instead of mailto: for preventing spam
 */
 
sendMail = function(user,domain) {
	try {
		locationstring = "mailto:" + user + "@" + domain; 
		window.location = locationstring; 
	}
	catch(error) {
		errorMessage(error, "There was an error when trying to send mail to:\n\n"+user+"@"+domain);
		return false;
	}
}


/*
 * Resizable pop up script
 */

		function PopupPic(sPicURL) { 
     window.open( "pop.asp?"+sPicURL, "pop",  
     "resizable=1,height=200,width=200"); } 
	 
	 
	 //////////////////////////////////////////////////

// Search form field 

function ValidateSrch(objForm)
{
	if (objForm.txtSearch.value == "")
	{
		window.alert("Please type in your search request");
		objForm.txtSearch.focus();
		return false;
	}
}
//////////////////////////////////////////////////

// Form Field checker - Checkout


function Validatefrm(objForm)
{
	if (objForm.txtSurname.value == "")
	{
		window.alert("Surname is a required Field");
		objForm.txtSurname.focus();
		return false;
	}
	
		if (objForm.txtFirstname.value == "")
	{
		window.alert("First name is a required Field");
		objForm.txtFirstName.focus();
		return false;
	}
	
	if (objForm.txtAddress1.value == "")
	{
		window.alert("Address is a required Field");
		objForm.txtAddress1.focus();
		return false;
	}
	
	if (objForm.txtAddressCode.value == "")
	{
		window.alert("Postcode is a required Field");
		objForm.txtAddressCode.focus();
		return false;
	}
	
	if (objForm.txtTel.value == "")
	{
		window.alert("Telephone is a required Field");
		objForm.txtTel.focus();
		return false;
	}
	
	if (objForm.txtEmail.value == "")
	{
		window.alert("Email Address is a required Field");
		objForm.txtEmail.focus();
		return false;
	}

	if (objForm.txtEmail.value.indexOf("@", 0) == -1 || (objForm.txtEmail.value.indexOf("@", 0) != objForm.txtEmail.value.lastIndexOf("@", (objForm.txtEmail.value.length - 1))) || objForm.txtEmail.value.indexOf(".", 0) == -1)
	{
		window.alert("Email Address must be a valid Email Address");
		objForm.txtEmail.focus();
		return false;
	}

	return true;
}




//////////////////////////////////////////////////

// Form Field checker - Contact


function Validate(objForm)
{
	if (objForm.txtName.value == "")
	{
		window.alert("Name is a required Field");
		objForm.txtName.focus();
		return false;
	}
	
		if (objForm.txtSurname.value == "")
	{
		window.alert("Surname is a required Field");
		objForm.txtSurname.focus();
		return false;
	}
	
	if (objForm.txtPostcode.value == "")
	{
		window.alert("Postcode is a required Field");
		objForm.txtPostcode.focus();
		return false;
	}
	
	if (objForm.txtTelephone.value == "")
	{
		window.alert("Telephone is a required Field");
		objForm.txtTelephone.focus();
		return false;
	}
	
	if (objForm.txtEmail.value == "")
	{
		window.alert("Email Address is a required Field");
		objForm.txtEmail.focus();
		return false;
	}

	if (objForm.txtEmail.value.indexOf("@", 0) == -1 || (objForm.txtEmail.value.indexOf("@", 0) != objForm.txtEmail.value.lastIndexOf("@", (objForm.txtEmail.value.length - 1))) || objForm.txtEmail.value.indexOf(".", 0) == -1)
	{
		window.alert("Email Address must be a valid Email Address");
		objForm.txtEmail.focus();
		return false;
	}

	return true;
}


//////////////////////////////////////////////////

function searchTextNull (fld) {
     fld.value="";
}

/// Div Show Hide

function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()
//Netscape check
function showHide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]  : document[div]:0;
	if (obj.visibility == 'visible' || obj.visibility == 'show') 
{
    obj.visibility = 'hidden';
    obj.display = 'none';
}
else 
{
    obj.visibility = 'visible';
    obj.display = '';
}

}

//Shows the div
function show(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='visible'
	obj.display='';

}
//Hides the div
function hide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='hidden'
	obj.display='none';

}

