//document.write("Can you <a href='javascript:openWindow(\"http://www.barkingspidertavern.com\")'>open this window</a>?")

var myform
var DIV1
var DIV2
var ON
var OFF
var TOP="top="
var LEFT="left="
var netscape4
var explorer4
var isMac
var mySwitch=false
var counter=0
var temp


isMac=navigator.appVersion
isMac=isMac.toLowerCase()
isMac=isMac.indexOf("macintosh")
if((isMac>-1)&&(navigator.appName=="Microsoft Internet Explorer")){isMac=true}
else{isMac=false}


if(document.layers){
	DIV1="document.layers['";
	DIV2="'].";
	ON="visibility='show'";
	OFF="visibility='hide'";
	netscape4=true;
	}
	
else if(document.all){
	DIV1="document.all['";
	DIV2="'].style.";
	ON="visibility='visible'";
	OFF="visibility='hidden'";
	explorer4=true;
	}	

else if(document.getElementById){
	DIV1="document.getElementById('";
	DIV2="').style.";
	ON="visibility='visible'";
	OFF="visibility='hidden'";
	}


	
//MUST POPULATE preload ARRAY FOR THIS TO WORK///////////////////////////////////////


var jpgpreload = new Array() 
var gifpreload = new Array() 

for(var a=0;a<preload.length;a++){
	gifpreload[a] = new Image() 
	gifpreload[a].src = 'images/' + preload[a] + '_on.gif'

	jpgpreload[a] = new Image() 
	jpgpreload[a].src = 'images/' + preload[a] + '_on.jpg'	
	}
	
	
	
	
//POSITION LAYERS IN RELATION TO WINDOW SIZE///////////////////////////////////////////////////////////

function leftDiv(){
for(var a=0;a<myDivs.length;a++){
	if(document.layers){theCenter=(window.innerWidth/2)-8;}
	else{theCenter=(document.body.clientWidth/2);}
	
	//position layers where they need to be when window is 770 wide or less
	//if window is wider, do the following:
	
	if(theCenter > parseInt(leftLimits[0])){
		leftPosition=theCenter+parseInt(myLefts[a]);
		eval(DIV1+myDivs[a]+DIV2+LEFT+leftPosition);
		}
		
	//just makes all pertinient layers visible
	eval(DIV1+myDivs[a]+DIV2+ON)
	}
}



function topDiv(){
if(document.layers){topPosition=(window.innerHeight/2)-8;}
else{topPosition=(document.body.clientHeight/2)}

for(var a=0;a<myDivs.length;a++){
	topPosition=topPosition+parseInt(myTops[a])
	if(topPosition<parseInt(topLimits[0])){
		topPosition=parseInt(topLimits[0])
		if(document.layers){
			topPosition=topPosition-10
			}
		}
	//alert(DIV1+myDivs[a]+DIV2+TOP+topPosition)
	eval(DIV1+myDivs[a]+DIV2+TOP+topPosition)
	eval(DIV1+myDivs[a]+DIV2+ON)
	}
}
	

	
	
	
	
	
	
//ALL ROLLOVERS REQUIRE A NAMING PROTOCOL SUFFIXING IMAGE NAMES WITH "_ON" AND "_OFF"///////////////

function rollOn(number,type){
document[preload[number]].src="images/"+preload[number]+"_on."+type
}

function rollOff(number,type){
document[preload[number]].src="images/"+preload[number]+"_off."+type
}




function rollOnDiv(number,type,layer){
if(netscape4){
        eval(DIV1+layer+DIV2+"document."+preload[number]+".src='images/"+preload[number]+"_on."+type+"'")
        }
else{
	rollOn(number,type)
    }
}

function rollOffDiv(number,type,layer){
if(netscape4){
        eval(DIV1+layer+DIV2+"document."+preload[number]+".src='images/"+preload[number]+"_off."+type+"'")
        }
else{
	rollOff(number,type)
    }
}








//DYNAMIC CONTENT IN LAYER/////////////////////////////////////////////////////////////////////////////

function writeIt(swap){
	swap = "<img src='images/" + swap + "header.jpg' border='0' name='' />"

	if(document.all){
		DIVNAME.innerHTML = swap
		}
	else if(document.layers){
		document.DIVNAME.
		document.write(swap);
		document.dcontent.
		document.close();
		}
	else if(document.getElementById){
		rng = document.createRange();
		el = document.getElementById("DIVNAME");
		rng.setStartBefore(el);
		htmlFrag = rng.createContextualFragment(swap);
		while (el.hasChildNodes())
		el.removeChild(el.lastChild);
		el.appendChild(htmlFrag);
		}
	}





//DISPLAY THE DATE////////////////////////////////////////////////////////////////////////////////////

function displayDate(){
var today=new Date()
var todaysDate
var days=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

todaysDate=days[today.getDay()]
todaysDate=todaysDate + " "
todaysDate=todaysDate + months[today.getMonth()]
todaysDate=todaysDate + " "
todaysDate=todaysDate + today.getDate()
todaysDate=todaysDate + ", "
todaysDate=todaysDate + today.getFullYear()

document.write(todaysDate)
}







//SHOW AND HIDE LAYERS//////////////////////////////////////////////////////////////////////////////


function divSwap(swap){
for(var a=0;a<myDivs.length;a++){
	eval(DIV1+myDivs[a]+DIV2+OFF)
	if(myDivs[a]==swap){
		eval(DIV1+myDivs[a]+DIV2+ON)
		}
	}
}



function setTimer(){
myTimer=setTimeout("divSwap(0)",5000)
}













//REQUIRES onUnload="closeWindow()" IN THE BODY TAG///////////////////////////////////////////////
var isClicked=false
var newWindow=null

function openWindow(swap1,swap2){
if((isClicked)&&(newWindow.closed==false)){
	newWindow.close()
	}
newWindow=window.open(swap1,'',swap2)
isClicked=true
}


function closeWindow(){
if(newWindow){
	newWindow.close()
	}
}








//clip rect(top,right,bottom,left)///////////////////////////////////////////////////////////////////////////////////////////////

var topCoord=0
var swap2


function scrollUp(swap){
if(netscape4){
	eval(DIV1+"outside"+DIV2+DIV1+"inside"+DIV2+TOP+topCoord);
	if((mySwitch)&&(topCoord>-swap)){topCoord-=2;swap2=swap;setTimeout("scrollUp(swap2)",10);}
	}
else{
	eval(DIV1+"inside"+DIV2+TOP+topCoord);
	if((mySwitch)&&(topCoord!=-swap)){topCoord-=2;swap2=swap;setTimeout("scrollUp(swap2)",10);}
	}
}


function scrollDown()
{
if(netscape4){
	eval(DIV1+"outside"+DIV2+DIV1+"inside"+DIV2+TOP+topCoord);
	if((mySwitch)&&(topCoord!=0)){topCoord+=2;setTimeout("scrollDown()",10);}
	}
else{
	eval(DIV1+"inside"+DIV2+TOP+topCoord);
	if((mySwitch)&&(topCoord!=0)){topCoord+=2;setTimeout("scrollDown()",10);}
	}
}



//<div id="up" style="position:absolute; left:560; top:50; ">
//<a HREF="#" onmouseover="mySwitch=true;scrollUp(250);" onmouseout="mySwitch=false"><img src="/images/spacer.gif" width="25" height="25" border="1" name="up"></a>
//</div>

//<div id="down" style="position:absolute; left:560; top:200; ">
//<a HREF="#" onmouseover="mySwitch=true;scrollDown();" onmouseout="mySwitch=false"><img src="/images/spacer.gif" width="25" height="25" border="1" name="down"></a>
//</div>

//<div id="outside" style="position:absolute;top:40;left:30; clip : rect(0,500,270,0);">
//<div id="inside" style="position:absolute;top:0;left:0;">

//<table border="1" cellspacing="0" cellpadding="2" width="500">

//<tr>
//<td align="" valign="top" class="text">

//CONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENTCONTENT

//</td></tr></table>

//</div></div>






/////////////////////////////////////////////////////////////////////////////////////////////////////////

function valLogin(){
if(document.summary.username.value==""){
	alert("Please fill in this field as it is required.")
	document.summary.username.focus()
	}
else if(document.summary.password.value==""){
	alert("Please fill in this field as it is required.")
	document.summary.password.focus()
	}
else{document.summary.submit()}
}








////////////////////////////////////////////////////////////////////////////////////////////////

function saveCookie(name,value,days) {	//<a href="javascript:saveCookie('favorite rockstar','David Bowie',360)" class="">saveCookie</a>
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000))
		var expires = "; expires="+date.toGMTString()
	}
	else expires = ""
	document.cookie = name+"="+value+expires+"; path=/"
}
function readCookie(name) {		//<a href="javascript:alert(readCookie('favorite rockstar'))" class="">readCookie</a>
	var nameEQ = name + "="
	var ca = document.cookie.split(';')
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length)
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
	}
	return null
}
function deleteCookie(name) {	//<a href="javascript:deleteCookie('favorite rockstar')" class="">deleteCookie</a>
	saveCookie(name,"",-1)
}



//CURRENCY////////////////////////////////////////////////////////////////////////////////////////

function currency(swap){

if(isNaN(swap.value)){
	alert("Please fill this field in using ONLY valid numerals.")
	swap.focus()
	}
else{
	for(var a = 0; a < swap.value.length; a++){
		if(swap.value.charAt(a) == "."){
			if(swap.value.length == a + 2){
				swap.value = swap.value + "0"
				}
			else if(swap.value.length > a + 3){
				swap.value = swap.value.substring(0,a + 3)
				}
			break
			}
		}
	}
}

