var speech='on';
var anyfnd='no';

today=new Date();
var todaydate = new Date(today.getYear() + 1900,today.getMonth()+1,today.getDate());
var parkopens = new Date(2011,4,15); // EDIT THIS AS NECESSARY!
var opendate = "Fish Creek opens on Friday April 15th, 2011";
var difference = parkopens.getTime() - todaydate.getTime();
    var daysDifference = Math.floor(difference/1000/60/60/24);
    difference -= daysDifference*1000*60*60*24
    var hoursDifference = Math.floor(difference/1000/60/60);
    difference -= hoursDifference*1000*60*60
    var minutesDifference = Math.floor(difference/1000/60);
    difference -= minutesDifference*1000*60
    var secondsDifference = Math.floor(difference/1000);
var daystillopen=daysDifference;
if (daystillopen > 0) { openmessage='fish creek opens in '+daystillopen+ 'days'; }
else if (daystillopen == 0) { openmessage='fish creek opens today'; }
else { openmessage='fish creek is already open'; }
var closemessage = 'fish creek closes on Sunday October 31';

var maxtalk = 500. // frequency of random chatter
var talkmessage = new Array(700);
var saidtext = new Array(700);
for (y=0;y<700; y++) { talkmessage[y]=""; saidtext[y]="";}
talkmessage[0] = 'Watch your spelling.';
talkmessage[1] = 'when are you going camping?.';
talkmessage[2] = 'did you pack your bathing suit?.';
talkmessage[3] = 'do not forget to bring your kids! \\_Laugh.';
talkmessage[4] = 'time to book your site.';
talkmessage[5] = 'let me help you with that.';
talkmessage[6] = 'wow! the kids are having a blast on the water right now.';
talkmessage[7] = 'nice! I just heard someone do a yoo hoo.';
talkmessage[8] = 'nice typing.';
talkmessage[9] = 'its hot here today.';
talkmessage[10] = 'darn. it just started to rain.';
talkmessage[11] = 'i hope you can spell better than the last camper \\_Laugh.';
talkmessage[12] = 'you should be here right now.';
talkmessage[13] = 'we are expecting a great sunset tonight.';
talkmessage[14] = '\\_Oh.';
talkmessage[15] = '\\_Sniff.';
talkmessage[16] = '\\_Yawn.';
talkmessage[17] = 'did you enter the pizza contest yet?.';
talkmessage[18] = 'boy, the summer booked up fast.';
talkmessage[19] = 'so much sun, here on Square Pond.';
talkmessage[20] = 'i am going for a boat ride soon, so hurry.';
talkmessage[21] = 'did I answer your question?.';
talkmessage[22] = 'you a cute.';
talkmessage[23] = 'you missed the full moon.';
talkmessage[24] = 'better get back to work \\_Laugh';
talkmessage[25] = 'let us ponder life, on square pond.';
talkmessage[26] = 'the sunshine is shimmering on square pond.';
talkmessage[27] = 'the kids sure are having fun here today.';
talkmessage[28] = 'there was lots of yoo who ing going on last night.';
talkmessage[29] = 'cool! there are kids dressed as clowns waterskiing on first pond right now.';
talkmessage[30] = 'hey! I just saw someone driving past over 15 miles per hour. tisk tisk.';

var maxsay = 43.
var saymessage = new Array(40);
var saidit = new Array(40);
var saidstring = new Array(40);
var mp3 = new Array(40);
for (y=0;y<maxsay; y++) { saidit[y]=''; saidstring[y]='';}
saidstring[0] = 'hell'; saymessage[0] = 'hello there';
saidstring[1] = 'site'; saymessage[1] = '\\_Oh let me show you, this camp sight';
saidstring[2] = 'woo'; saymessage[2] = 'Wood you be mine \\_Laugh';
saidstring[3] = 'reser'; saymessage[3] = '\\_Wow . Another reservation questions. My favorite! \\_Laugh';
saidstring[4] = 'fish'; saymessage[4] = 'Here fishy fishy \\_Laugh';
saidstring[5] = 'rai'; saymessage[5] = 'It might be raiing right now! \\_Laugh';
saidstring[6] = 'weath'; saymessage[6] = 'The weather is unpredictable, here in the adirondacks \\_Laugh';
saidstring[7] = 'blow'; saymessage[7] = 'The wind is blowing strongly \\_Yawn';
saidstring[8] = 'sex'; saymessage[8] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[9] = 'fuc'; saymessage[9] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[10] = 'shit'; saymessage[10] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[11] = 'bitc'; saymessage[11] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[12] = 'boob'; saymessage[12] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[13] = 'breast'; saymessage[13] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[14] = 'nude'; saymessage[14] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[15] = 'nake'; saymessage[15] = 'tisk tisk. you are very naughty \\_Whistler \\_Whistle_01 \\_Whistle_02';
saidstring[16] = 'fart'; saymessage[16] = 'oh brother, you have got to be kidding. \\_Raspberry . Happy now?';
saidstring[17] = 'whist'; saymessage[17] = 'Here you go \\_Whistle \\_Whistle_01 \\_Whistle_02';
saidstring[18] = 'yoo'; saymessage[18] = 'you hoo. . you hoo'; mp3[18]= "yoohoo10";
saidstring[19] = 'boa'; saymessage[19] = 'bring you boat, take me for a ride \\_Laugh'; mp3[19]="waterskiing1";
saidstring[20] = 'ope'; saymessage[20] = openmessage;
saidstring[20] = 'clos'; saymessage[21] = closemessage;
saidstring[22] = 'ten'; saymessage[22] = 'we have lots of sights, for your tent \\_Laugh';
saidstring[23] = 'dump'; saymessage[23] = 'we have a great dump station \\_Laugh';
saidstring[24] = 'hook'; saymessage[24] = 'sorry, there are no hook ups, at fish creek';
saidstring[25] = 'bear'; saymessage[25] = 'bears, what bears? I didnt see any bears \\_Whistle_02';
saidstring[26] = 'sing'; saymessage[26] = 'Just for you \\_Whistle \\_Whistle_01 \\_Whistle_02 doe ray me fa so latta doe \\_Laugh . How about I do a rap \\_Sniff \\_Sniff \\_Raspberry \\_Raspberry \\_Hiccup \\_Hiccup \\_Hiccup \\_Sniff \\_Sniff \\_Raspberry \\_Raspberry \\_Hiccup \\_Hiccup \\_Raspberry \\_Hiccup \\_Hiccup gonna go down 2 fish creek, i say gonna go down 2 fish creek \\_Sniff \\_Sniff \\_Hiccup \\_Hiccup \\_Hiccup \\_Raspberry \\_Raspberry \\_Hiccup \\_Hiccup \\_Raspberry \\_Hiccup \\_Hiccup ';
saidstring[27] = 'avai'; saymessage[27] = 'Oops. Sorry! You will have to check with Reserve America, regarding sight availability. sorry.';
saidstring[28] = 'vacan'; saymessage[28] = 'Oops. Sorry! You will have to check with Reserve America, regarding sight vacancies. sorry.';
saidstring[29] = 'prett'; saymessage[29] = 'Well well, thank you very much \\_Laugh';
saidstring[30] = 'kiss'; saymessage[30] = 'Now no nead to get all mushy on me. Ok. Here you go \\_Kiss \\_Laugh';
saidstring[31] = 'ice'; saymessage[31] = '\\_Mmm I just love ice cream \\_Whistle_02';
saidstring[32] = 'pup'; saymessage[32] = '\\_Oh do bring your puppy \\_Laugh';
saidstring[33] = 'dog'; saymessage[33] = '\\_Oh do bring your puppy \\_Laugh';
saidstring[34] = 'pet'; saymessage[34] = '\\_Oh do bring your puppy \\_Laugh';
saidstring[35] = 'squa'; saymessage[35] = 'square pond is my favorite pond';
saidstring[36] = 'ponder'; saymessage[36] = 'ponder life on square pond';
saidstring[37] = 'fee'; saymessage[37] = 'only 22 dollars per night for any sight \\_Laugh';
saidstring[38] = 'cost'; saymessage[38] = 'only 22 dollars per night for any sight \\_Laugh';
saidstring[39] = 'much'; saymessage[39] = 'only 22 dollars per night for any sight \\_Laugh';
saidstring[40] = 'buy'; saymessage[40] = 'better head to the trading post to buy your supplies';
saidstring[41] = 'elect'; saymessage[41] = 'there are no electric sites at fish creek';
saidstring[42] = 'hydr'; saymessage[42] = 'there are no electric sites at fish creek';
saidstring[43] = ''; saymessage[43] = '';
saidstring[44] = ''; saymessage[44] = '';
saidstring[45] = ''; saymessage[45] = '';
saidstring[46] = ''; saymessage[46] = '';
saidstring[47] = ''; saymessage[47] = '';
saidstring[48] = ''; saymessage[48] = '';
saidstring[49] = ''; saymessage[49] = '';
saidstring[50] = ''; saymessage[50] = '';


/*** Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
     Visit http://www.dynamicdrive.com/ for full source code ***/

function handleEnter (field, event, talktext) {
        HideContent('movieframe');
        var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
        if (keyCode == 35) { return false; }   // ignore #
        if (keyCode == 13) { return false; }   // ignore #
        var str = document.question.question.value;
        var talkback="yes";
        for (y=0;y<maxsay; y++) {
           if (str.match(saidstring[y]) && !saidit[y]) {
              if (saidstring[y] == 'yoo') { sayyoo(saymessage[y]) } else { sayit(saymessage[y]); }
              saidit[y]="yes";
              talkback="no";
              playmp3("http://fishcreekpond.com/mp3/"+mp3[y]+".mp3");
           }
        }

        if ($talkback == 'yes') {talktoyou();}
        if (keyCode == 13) {
                var i;
                for (i = 0; i < field.form.elements.length; i++)
                        if (field == field.form.elements[i])
                                break;
                i = (i + 1) % field.form.elements.length;
                show_status('Ignore the ENTER key');
                return false;
        }
        else
        return true;
}

function playmovie(movie) {
// <![CDATA[
// create the qtobject and write it to the page, this includes plugin detection
// be sure to add 15px to the height to allow for the controls
	var myQTObject = new QTObject("/askrj/images/moviethumb.jpg", "movieimage", "320", "196");
	myQTObject.addParam("href", "http://fishcreekpond.com/askrj/movies/" + movie + ".m4v");
	myQTObject.addParam("target", "myself");
	myQTObject.addParam("controller", "false");
	myQTObject.write("fullanswer");
// ]]>
}

function playvimeo(movie) {
        document.getElementById('movieframe').style.display = 'block';
        document.getElementById('movieframe').innerHTML = "<object width=600 height=338><param name=allowfullscreen value=true /><param name=allowscriptaccess value=always /><param name=movie value=http://vimeo.com/moogaloop.swf?clip_id="+movie+"&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1 /><embed src=http://vimeo.com/moogaloop.swf?clip_id="+movie+"&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1 type=application/x-shockwave-flash allowfullscreen=true allowscriptaccess=always width=600 height=338></embed></object><p><p><center><a href=javascript:HideContent(\'movieframe\');>close video</a></center>";
}

function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }

function getAbsPos(elt,which) {
   iPos = 0;
   while (elt != null) {
   iPos += elt["offset" + which];
   elt = elt.offsetParent;
   }
   return iPos;
}


function MovePin(x,y,adj) {
    var pinheight = 32;
    var pinwidth = 23;
    var xpos = parseInt(x);
    var ypos = parseInt(y);
    var ieadjust = parseInt(adj);
    document.getElementById('mappinmarker').style.right = 144 - xpos;
    document.getElementById('mappinmarker').style.top = 3 + ypos + ieadjust;
}

function speechon(text) {
    speech='on';
    if (text != 'sh') { sayit('i will speak'); }
    document.getElementById('speechonoff').innerHTML = '<a href=javascript:speechoff()><img src=/askrj/images/speech2011on.gif border=0></a>';
}

function speechoff(text) {
    speech='off';
    stopSpeech();
    if (text != 'sh') { sayText('i will be quiet',1,1,2); }
    document.getElementById('speechonoff').innerHTML = '<a class=speechonoff href=javascript:speechon()><img src=/askrj/images/speech2011off.gif border=0></a>';
}

function sayit(text) { if (speech == 'on') { sayText(text,1,1,2); } }

function sayyoo(text) {
    if (speech == 'on') {
// txt,voice,lang,engline,effect,efflevel
       sayText('ok. Lets listen and see if we can here a yoo who',1,1,2);
//     sayText('ok. I will demonstrate a yoo who. listen for the echo. Hopefully someone will yoo who back.',1,1,2);
//     sayText('yoooooo whoooooo. . yoooo whoooooo',1,1,2,'T',1);
//     sayText('yoooooo whoooooo. . yoooo whoooooo',7,1,4,'T',1);
//     sayText('yoooooo whoooooo. . yoooo whoooooo',5,1,4,'T',1);
//     sayText('yoooooo whoooooo. . yoooo whoooooo',13,1,4,'T',1);
//     sayText('too bad no kids yoo whood. \\_Laugh',1,1,2);
    }
}

function sayrandom() {
   if (speech == 'on') {
       var mess = ['\\_Ouch',
                   'Yup! Ask a question silly',
                   '\\_Whistle \\_Whistle_01 \\_Whistle_02',
                   '\\_Yawn',
                   ' I just Can\'t wait until it warms up!',
                   'I think I will L O L \\_Laugh',
                   'Fetch me a baby cone please \\_Laugh',
                   'I am pondering life, on square pond',
                   'Be sure to enter the pizza contest, here on the site',
                   '',
                   '',
                   'Fish Creek has 324 sites that are right on the water. Wow!',
                   'Let me hear your best you who \\_Laugh',
                   'You should be camping, not clicking on that darn mouse \\_Laugh',
                   'I hope to get out water skiing tomorrow. how about you',
                   'Hey! I was just about to start a campfire, and make some smores',
		   '25 cents for the showers! do not forget your quarters!',
		   'ok. here is a list of the best sites. don\'t tell anybody! \\_Shhh . error error error \\_Laugh',
                   'Darn! You just missed getting the last sight! That is rather unfortunate',
                   'Oh my! You just missed the ice cream truck. again \\_Laugh',
                   '\\_Mmm I just had 2 baby cones \\_Raspberry_01',
                   'Why are you not here camping yet? Hurry down now'];
       mess[9] = openmessage;
       mess[10] = opendate;
       var rand=Math.floor(Math.random()*22);
       var text = mess[rand];
       sayText(text,1,1,2);
//     sayText(text,1,1,2,'D',1);
//     sayAIResponse("sing me a song",2,1,2,,'P',-1);    // explore this more
   }
}

function talktoyou() {
   if (speech == 'on') {
       var rand=Math.floor(Math.random()*maxtalk);
       var talktext = talkmessage[rand];
       if (saidtext[rand] == "") { sayText(talktext,1,1,2); }
       saidtext[rand] = "yes";
   }
}

function showaccuweather() {
   var accuweather = 'not working';
   document.getElementById("bgphoto").style.display = "block";
   document.getElementById("bgphoto").innerHTML=accuweather;
}

function show_browser(text) {
//  document.getElementById('browser').innerHTML = text;       // uncomment to show browser
}
function show_iebug() {
    document.getElementById('browser').innerHTML = "<font color=red><B>WARNING!</b></font> Functionality is limited for users of Internet Explorer.<br>Due to limitions in Explorer long text displays cannot be displayed.<br>As such some of the informations screens to the right will be incomplete.<br>Best to use any other browser instead of such as:<br>Firefox, Safari, Opera, Netscape...<p>Sorry I do not have time to deal with all the issues in programing for Internet Explorer and all its bugs.</font></b>";
}
function show_status( status_text ) {
    document.getElementById('status').innerHTML = status_text;
}
function show_title( title_text ) {
    document.getElementById('suggestionstitle').innerHTML = title_text;
}
function show_movie( movie_code ) {
    document.getElementById('fullanswer').innerHTML = movie_code;
}

function editwindow(topicid) {
   window.open('/askrj/edtopic.php?topicid=' + topicid,null,'resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=600,height=600');
}

function clearbox() {
	document.question.question.value = '';
        var rnd=Math.floor(Math.random()*9);
        var clearmess = ['ask away','type away','yup, go ahead','i am ready','go for it','\\_Laugh02','there, start fresh','\\_Yawn','there. I cleaned that box out for you'];
        sayit(clearmess[rnd]);
        HideContent('suggestions');
        HideContent('movieframe');
}

function updaterecord( p_script_url ) {
      // create new script element, set its relative URL, and load it
      document.getElementById('status').innerHTML = 'updating...';
      var headID = document.getElementsByTagName("head")[0];
      var newScript = document.createElement('script');
      newScript.type = 'text/javascript';
      newScript.src = p_script_url;
      headID.appendChild(newScript);
      document.getElementById('status').innerHTML = 'updated';
}

function show(txt) {
document.getElementById("fullanswer").style.display = "block";
document.getElementById("fullanswer").innerHTML=txt;
}

function showphoto(txt) {
document.getElementById("bgphoto").style.display = "block";
document.getElementById("bgphoto").innerHTML=txt;
}

function showphoto1(txt,alt) {
document.getElementById("bgphoto").style.display = "block";
document.getElementById("bgphoto").innerHTML="<img src="+txt+" width=600 title="+alt+" hspace=4 border=0>";
}

function showmovie(txt) {
document.getElementById("movieframe").style.display = "block";
//document.getElementById("movieframe").innerHTML=txt;
}

function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}

function showphotonav(txt) {
  if (txt != '') {
     document.getElementById("photonav").style.display = "block";
     document.getElementById("photonav").innerHTML=txt;
  }
}

function playmp3( url ){   
  document.getElementById("sound").innerHTML="<embed src='"+url+"' hidden=true autostart=true loop=false>";
}


function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

