// Javcript Document for www.brightonbeachclub.co.uk

// Function for Gallery
function PopupPic(sPicURL) {
     window.open( "popup.htm?"+sPicURL, "",  
     "resizable=1,HEIGHT=200,WIDTH=200");
   }

// DropDown Menu Script
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed
	
	var ie5=document.all
	var ns6=document.getElementById&&!document.all
	
	function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
	totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
	parentEl=parentEl.offsetParent;
	}
	return totaloffset;
	}
	
	function showhide(obj, e, visible, hidden){
	if (ie5||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	obj.visibility=visible
	else if (e.type=="click")
	obj.visibility=hidden
	}
	
	function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
	var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
	var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
	dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
	if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	}
	return edgeoffset
	}
	
	function dropdownmenu(obj, e, dropmenuID){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	if (typeof dropmenuobj!="undefined") //hide previous menu
	dropmenuobj.style.visibility="hidden"
	clearhidemenu()
	if (ie5||ns6){
	obj.onmouseout=delayhidemenu
	dropmenuobj=document.getElementById(dropmenuID)
	if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
	dropmenuobj.onmouseover=clearhidemenu
	dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
	showhide(dropmenuobj.style, e, "visible", "hidden")
	dropmenuobj.x=getposOffset(obj, "left")
	dropmenuobj.y=getposOffset(obj, "top")
	dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
	}
	
	function clickreturnvalue(){
	if ((ie5||ns6) && !enableanchorlink) return false
	else return true
	}
	
	function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
	}
	
	function dynamichide(e){
	if (ie5&&!dropmenuobj.contains(e.toElement))
	delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	delayhidemenu()
	}
	
	function delayhidemenu(){
	delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
	}
	
	function clearhidemenu(){
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
	}
	
// image rotator

// funtions for image roator

function create() {
        this.width = ''
        this.height = ''
        this.src = ''
        this.border = ''
}
imageRot = new Array()
for(var i=1; i<=12; i++) { imageRot[i] = new create() }

imageRot[1].width = "754"
imageRot[1].height = "180"
imageRot[1].src = "images/banner_images/banner1.jpg"
imageRot[1].border = "0"

imageRot[2].width = "754"
imageRot[2].height = "180"
imageRot[2].src = "images/banner_images/banner2.jpg"
imageRot[2].border = "0"

imageRot[3].width = "754"
imageRot[3].height = "180"
imageRot[3].src = "images/banner_images/banner3.jpg"
imageRot[3].border = "0"

imageRot[4].width = "754"
imageRot[4].height = "180"
imageRot[4].src = "images/banner_images/banner4.jpg"
imageRot[4].border = "0"

imageRot[5].width = "754"
imageRot[5].height = "180"
imageRot[5].src = "images/banner_images/banner5.jpg"
imageRot[5].border = "0"

imageRot[6].width = "754"
imageRot[6].height = "180"
imageRot[6].src = "images/banner_images/banner6.jpg"
imageRot[6].border = "0"

imageRot[7].width = "754"
imageRot[7].height = "180"
imageRot[7].src = "images/banner_images/banner7.jpg"
imageRot[7].border = "0"

imageRot[8].width = "754"
imageRot[8].height = "180"
imageRot[8].src = "images/banner_images/banner8.jpg"
imageRot[8].border = "0"

imageRot[9].width = "754"
imageRot[9].height = "180"
imageRot[9].src = "images/banner_images/banner9.jpg"
imageRot[9].border = "0"

imageRot[10].width = "754"
imageRot[10].height = "180"
imageRot[10].src = "images/banner_images/banner10.jpg"
imageRot[10].border = "0"

imageRot[11].width = "754"
imageRot[11].height = "180"
imageRot[11].src = "images/banner_images/banner11.jpg"
imageRot[11].border = "0"

imageRot[12].width = "754"
imageRot[12].height = "180"
imageRot[12].src = "images/banner_images/banner12.jpg"
imageRot[12].border = "0"


var n = Math.random() + ''
n = parseInt(n.charAt(12))
if(n >12) {
        n = n - 12
}
else if(n==0) {
        n = n + 12
}
n += ""

var image = imageRot[n]
var ad = ""


ad += '<img src="' + image.src + '" width="' + image.width
ad += '" height="' + image.height + '" alt="Welcome to the Brighton Beach Homepage" border="' + image.border
ad += '">'


// validate the mailform

function isBlank(inp){
	if (inp=="")
		return true;
	else
		return false;
}
function isEmail(inp){
	var reCheckEmail = new RegExp("^[a-zA-Z0-9\-_.]+[@][a-zA-Z0-9\-_\]+([.][a-zA-Z0-9]+)+$");
	return reCheckEmail.test(inp);
}


function validateEmailForm(){

	// test for blank fields
		
	if (isBlank(document.conForm.textName.value)){
		alert ("Please specify your Name!");
		return false;
		}

		if (!isEmail(document.conForm.textEmail.value)){
		alert ("The Email Address is not a valid email address!");
		return false;
		}
	
	return true;
} 




