//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'	
	}
	

	
	
	
//CURRENCY//////////////////////////////////////////////////////////////////////////////////////////

function currency(amount){
amount = "" + amount
temp = ""
flag = false
newValue = ""

for(var a=0;a<amount.length;a++){
	if(flag){
		temp = temp + amount.charAt(a)
		}
	if(amount.charAt(a)=="."){
		flag = true
		}
	}

if(temp==""){
	newValue = amount + ".00"
	}
else if(temp.length==1){
	newValue = amount + "0"
	}
else if(temp.length==2){
	newValue = amount
	}
else{
	newValue = amount.substring(0,(amount.length-(temp.length-2)))	
	}
	
return newValue
	
}

function taxable(){
	oldTot = document.form.transactionamount.value
	if(document.form.state.selectedIndex == 0){
		alert("Select a State")
		document.form.state.focus()
		flag = true
		}
	else if(document.form.state.selectedIndex == 36){
		taxTot = parseFloat(oldTot) * 0.07
		newTot = parseFloat(oldTot) + taxTot
		document.form.transactionamount.value = currency(newTot)
		flag = false
		
		var newString = document.form.orderstring.value
		var regexp = /~N~/g
		document.form.orderstring.value = newString.replace(regexp,"~Y~")
		}
	else{
		document.form.transactionamount.value = currency(oldTot)
		flag = false
		}
	if(!flag){	
		
		var lastChance
		if(document.form.state.selectedIndex == 36){
			lastChance = "Your total for this transaction is " + document.form.transactionamount.value + ". \n (Ohio residents are charged an additional 7% tax.)"
			}
		else{
			lastChance = "Your total for this transaction is " + document.form.transactionamount.value + "."
			}
		
		
		if(confirm(lastChance)){
			document.form.submit()
			}
		else{
			location = "order.asp"
			}
		
		
		}
}
	
	
	
	
	
	
	
	
	
	
	
//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)
    }
}
















//DISPLAY THE DATE////////////////////////////////////////////////////////////////////////////////////

function displayDate(){
var today=new Date()
var todaysDate = "&nbsp;&nbsp;&nbsp;"
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()
	}
}




var isClicked2=false
var newWindow2=null

function openWindow2(swap1,swap2){
if((isClicked2)&&(newWindow2.closed==false)){
	newWindow2.close()
	}
newWindow2=window.open(swap1,'',swap2)
isClicked2=true
}


function closeWindow2(){
if(newWindow2){
	newWindow2.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)
}





