	// Scarlet Mist Javascript code
// The code here which I wrote is dedicated to the world with love.
// If it doesn't work, I don't know who wrote it




function jump_to(obj) {
alert("hello");
if (document.all(obj)) {
if (document.all('jump_last')) 
 document.all('jump_last').focus();
jump_obj(obj);
};
return false;
};
function jump_obj(obj){
if (document.all(obj)) 
 document.all(obj).focus();
return false;
};  
 



function openup(o){
window.open("http://"+o)
return false} 


//JavaScript:alert(document.cookie.split(';').join('\n'))
var shownfaq = false


// Select the CSS for right width
var width = screen.width;
var res =(((!(640-width))*1)+((!(800-width))*2)+((!(1024-width))*3)+((!(1152-width))*4)+((!(1280-width))*5)+((!(1600-width))*6));
res=Math.floor(res) // for macs
//alert(res)
if (width>1600){res='4'} // some people have got big ones.
 if(!(res)) {res = '1'};
 if (res=='1') {cssfile='scarlet800.css';} // nobody uses 640. do they?
 if (res=='2') {cssfile='scarlet800.css';}
 if (res=='3') {cssfile='scarlet1024.css';}
 if (res!='1' && res!='2' && res!='3') {cssfile='scarlet1024.css';}


cssfile="scarletmist.css";

document.write ("<link rel='stylesheet' type='text/css' href='" + cssfile + "'>");


function DrawTableTop(){
var width = screen.width;
var res =(((!(640-width))*1)+((!(800-width))*2)+((!(1024-width))*3)+((!(1152-width))*4)+((!(1280-width))*5)+((!(1600-width))*6));
//document.write (res)
if (res=="1"){
 document.write ("<table width='770' border='0'><tr><td colspan='2' align='center'>" + tswitch()+ "</td></tr><tr>")
 document.write("<td width='14'>&nbsp;<td>") 
}
else if (res=="2") {
 document.write ("<table width='770' border='0'><tr><td colspan='2' align='center'>" + tswitch()+ "</td></tr><tr>")
 document.write("<td width='14'>&nbsp;<td>")
}
else if (res=="3") {

 document.write ("<table width='970' border='0'><tr><td colspan='2' align='center'>" + tswitch()+ "</td></tr><tr>")
 document.write("<td width='100'>&nbsp;<td>")

 }
 else {
 document.write ("<table width='1200' border='0'><tr><td colspan='2' align='center'>" + tswitch()+ "</td></tr><tr>")
 document.write("<td width='215'>&nbsp;<td>")
}
}










function tswitch(){
return "<a href='http://www.ticketswitch.com/cgi-bin/web_finder.buy/scarlet?crypto_block=U---9yw1_B3K60cdOh48zBX3O7ZWfF6JmaItW0XmmrXGND8-Y' title='powered by Ticketswitch'><img src='gifs/newscarletmistlogo.gif'  alt='Scarlet Mist logo' style='border:none' /></a>";
}



















// Cookie functions weren't written by me but look ok
function setCookie(NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function expireCookie(name)
{
	var today = new Date();
	var expiry = new Date(today.getTime() - ( 28 * 24 * 60 * 60 * 1000) ); // less 28 days
	var value = "dummy";
	
	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();

	//alert("expiring cookie : " + name)
}

function getCookie(name) 
{ // use: getCookie("name");

	var theCookies = top.document.cookie;
	var index = theCookies.indexOf(name + "=");
	if (index == -1) return null;
	index = theCookies.indexOf("=", index) + 1;
	var endstr = theCookies.indexOf(";", index);
	if (endstr == -1) endstr = theCookies.length;
	return unescape(theCookies.substring(index, endstr));
}


// Functions for the Bonus Messages when people are searching lots of times
function divide ( numerator, denominator ) {
    var remainder = numerator % denominator;
    var quotient = ( numerator - remainder ) / denominator;
return quotient
}
function dobp2(q,a) // FAQ with different page layout
{
re = /APOSTROPHE/g; 
q=q.replace(re,"'") // what a kludge, hope noone ever sees this code.
a=a.replace(re,"'")
newWindow = window.open("newWin", "", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=600,height=450,left=70,top=170")
newWindow.document.write("<html><head><link rel='stylesheet' type='text/css' href='scarletmist.css'><title>")
newWindow.document.write( "Scarlet Mist" )
newWindow.document.write("</title></head><body><table border='0' cellpadding='15' width='100%'><tr><td>&nbsp;</td><td bgcolor='99CCCC'><h2>")
newWindow.document.write( q )
newWindow.document.write( "</h2></td></tr><tr><td><img src='gifs/circular_trip3.gif'></td><td>" + a + "</td></th></table>")
newWindow.document.write ("<p align='right'><input   type='submit' value='Close this Window' onclick='Javascript:window.close()'>&nbsp;&nbsp;</p>&nbsp;<br>")
newWindow.document.write("<\/BODY><\/HTML>")
newWindow.document.close()
return false
}

function dobonus(){
// does the Bonus Messages for people who've looked lots of times.
// Trigger is an obscure mouseover so they won't know whats hit them.

var numbuys
var mess1 = "Keep looking. Ticket <b>are</b> coming through the mist. Try whenever you can"
var mess2 = "Please be realistic. You may not be able to get a ticket. Look at what else is going on. There is plenty of other stuff to choose from."
var mess3 = "Make sure that you enter your email address and phone number very very carefully. There will be no second chances"
var tit1="Keep looking"
var tit2="Join us"
var tit3="Scarlet Mist is unique"
var t=new Date()
var hournow= t.getHours()
var timemess = ""
switch (divide(hournow,6))
{
case 0:
 timemess="There are not so many tickets around in the night.";
 break;
 case 1:
 timemess = "Maybe today ....";
 break;
 case 2:
 timemess = "The Afternoon is when most people are seeking. We are here at all times. Try looking at 3 o'clock in the morning.";
 break; 
 case 3:
 timemess = "Good evening from Scarlet Mist.";
 break;
 default:
 timemess="Tomorrow is another day.";
 }
if (shownfaq==false) {
numbuys=getCookie("numbuys")
if       ((numbuys %   223)  == 0)    { dobp2(tit1,mess1)}
else {if ((numbuys %   139)  == 0)    { dobp2(tit2,mess2)}
else {if ((numbuys %   447)  == 0)    { dobp2(tit1,mess1 + "<br>" + timemess)}
else {if ((numbuys %   31)  == 0)    { dobp2(tit2,mess2 + "<br>" + timemess)}
else {if ((numbuys %   349) == 0)    { dobp2(tit3,mess3)}
else {if ((numbuys %   481) == 0)    { dobp2(tit3,mess3 + "<br>" + timemess)}
}}}}}
}
shownfaq=true

}






//
// Functions for the FAQ
//
function doit(q,a,hite4win) // good name for that function, says it all
{
re = /APOSTROPHE/g; 
q=q.replace(re,"'") // what a kludge, hope noone ever sees this code.
a=a.replace(re,"'")
newWindow = window.open("newWin", "", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=600,height=" + hite4win + ",left=70,top=170")
newWindow.document.write("<head><link rel='stylesheet' type='text/css' href='scarlet800.css'><title>Scarlet Mist Information Point</title></head><body><table border='0' width='580'>")
newWindow.document.write("<tr><td width='10'>&nbsp;</td><td align='center'></td></tr><tr><td width='10'>&nbsp;</td><td><h2>")
newWindow.document.write(q + "</h2>" + a )
newWindow.document.write("<br>&nbsp;<br>&nbsp;<br><div align='right'><a href='' onclick='javascript:window.close()'>--&nbspClose window&nbsp;--</a></div></td></tr></table></body></html>")
newWindow.document.close()
return false
}
function newfaq(q,a,hite4win){
var re
var q2
var numargs=newfaq.arguments.length
if (numargs==2) {hite4win=350} // set default height for window
re = /'/g; 
q2=q.replace(re,"APOSTROPHE") // but they'll understand what I'm going through.
a=a.replace(re,"APOSTROPHE")
document.write("<a href='faq' onclick='return doit(")
document.write('"')
document.write(q2)
document.write('","')
document.write(a )
document.write('"')
document.write("," + hite4win + ")'>" + q + "</a><br>")
}

var ToldHimOnce=false
function myvalidate(){
var x = Form1.youremail.value
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
if ((Form1.youremail.value=="") && (ToldHimOnce==false)){
alert("You forgot your email address. If you press SEND MESSAGE again, you can write to us anonymously.")
ToldHimOnce=true // 1st time through it validates email address. 2nd time it passes anything
return false}
if(!ToldHimOnce) {
if   (!filter.test(x))    { 
 alert('Incorrect email address. Leave the box blank if you prefer.');
 return false}}
if (Form1.subject.value=="0"){
alert("Please choose a Subject")
return false} 
if (Form1.yourname.value==""){
alert("Forgot your name man")
return false}
if (Form1.blab.value==""){
alert("Forgot to say anything") // do i really need this test? yes.
return false}
}

