function hilite(name,over) {
//	var serverPath='http://douglas-groz/casitascopes/';
	var serverPath='http://www.casitascopes.com/';
//	var serverPath='http://www.kaleidoscopescape.com/';
	if(window.document.images) 
		if (over)
			window.document.images[name].src =  serverPath + name + '_sel.gif';
		else
			window.document.images[name].src =  serverPath + name + '.gif';
}

function popup(vwName,vwTitle,vwX,vwY) {
	var WindowName='KaleidoViewer';
//	var serverPath='http://douglas-groz/casitascopes/';
	var serverPath='http://www.casitascopes.com/';
//	var serverPath='http://www.kaleidoscopescape.com/';
	if (!WM_acceptsCookies()) {
		var vwRes='_hr';
	} else {
		var vwRes=WM_readCookie('vwRes');
	}
	if (vwRes) {
		var ViewerWindow=window.open('', WindowName, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=460,left = 150,top = 50');
		ViewerWindow.document.write('<html><head><title>' + vwTitle + ' Video</title>');
		ViewerWindow.document.write('<meta name="rnpagelayout" content="embedded">');
		ViewerWindow.document.write('<meta name="rnserverpath" content="' + serverPath + '">');
		ViewerWindow.document.write('<meta name="rnmediafile" content="scopes/videos/' + vwName + vwRes + '.rm">');
		ViewerWindow.document.write('<meta name="rnmetafile" content="scopes/videos/' + vwName + vwRes + '.rpm">');
		ViewerWindow.document.write('<link rel="stylesheet" type="text/css" href="' + serverPath + 'popup.css">');
		ViewerWindow.document.write('</head>');
		ViewerWindow.document.write('<body><div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="340">');
		ViewerWindow.document.write('<tr><td height="340" valign="middle" align="center" background="' + serverPath + 'images/window.gif">');
		ViewerWindow.document.write('<object ID="' + vwName + '" CLASSID="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" HEIGHT="' + vwY + '" WIDTH="' + vwX + '">');
		ViewerWindow.document.write('<param name="controls" value="ImageWindow">');
		ViewerWindow.document.write('<param name="console" value="Clip1">');
		ViewerWindow.document.write('<param name="autostart" value="true">');
		ViewerWindow.document.write('<param name="src" value="' + serverPath + 'scopes/videos/' + vwName + vwRes + '.rpm">');
		ViewerWindow.document.write('<embed SRC="' + serverPath + 'scopes/videos/' + vwName + vwRes + '.rpm" type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ImageWindow" HEIGHT="' + vwY + '" WIDTH="' + vwX + '" AUTOSTART="true">');
		ViewerWindow.document.write('</object></td></tr>');
		ViewerWindow.document.write('<tr><td height="60" valign="middle" align="center"><p align="center">');
		ViewerWindow.document.write('<object ID="video1" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="40" WIDTH="275">');
		ViewerWindow.document.write('<param name="controls" value="ControlPanel">');
		ViewerWindow.document.write('<param name="console" value="Clip1">');
		ViewerWindow.document.write('<embed type="audio/x-pn-realaudio-plugin" CONSOLE="Clip1" CONTROLS="ControlPanel" HEIGHT="40" WIDTH="275" AUTOSTART="true">');
		ViewerWindow.document.write('</object></td></tr></table>');
		ViewerWindow.document.write('<p><a HREF="http://www.real.com/products/player" target="_blank"><img SRC="http://www.real.com/pics/rnlogos/realplayerg2.jpg" BORDER=0></a></center>');
		ViewerWindow.document.write('</center></div></body></html>');
		ViewerWindow.document.close();
		ViewerWindow.focus();
	} else {
		WM_setCookie('vwName',vwName,1);
		WM_setCookie('vwTitle',vwTitle,1);
		WM_setCookie('vwX',vwX,1);
		WM_setCookie('vwY',vwY,1);
		setISP();
	}
}

function checkCookies() {
//	var serverPath='http://douglas-groz/casitascopes/';
	var serverPath='http://www.casitascopes.com/';
	if (!WM_acceptsCookies()) {
		var CookieWarning=window.open(serverPath + 'cookiewarn.htm', 'CookieWarning', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=310,height=250,left=150,top=100');
		CookieWarning.focus();
	}
}

function setISP() {
//	var serverPath='http://douglas-groz/casitascopes/';
	var serverPath='http://www.casitascopes.com/';
	var ISPWindow=window.open(serverPath + 'setisp.htm', 'SetISP', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250,left=150,top=100');
	ISPWindow.focus();
}

function handleResSubmit(buttonState) {
	var vwRes='_lr';
	if (buttonState===true) vwRes='_hr';
	var vwName=WM_readCookie('vwName');
	var vwTitle=WM_readCookie('vwTitle');
	var vwX=WM_readCookie('vwX');
	var vwY=WM_readCookie('vwY');
	WM_killCookie('vwName');
	WM_killCookie('vwTitle');
	WM_killCookie('vwX');
	WM_killCookie('vwY');
	WM_setCookie('vwRes',vwRes,24);
	popup(vwName,vwTitle,vwX,vwY);
	self.close();
}

function handleGuestSubmit() {
	var guestfield = new Array();
	guestfield[1]=document.addentry.guest1.value;
	guestfield[2]='';
	guestfield[3]=document.addentry.guest3.value;
	guestfield[4]=document.addentry.guest4.value;
	guestfield[5]=document.addentry.guest5.value;
	guestfield[6]=document.addentry.guest6.value;
	if (guestfield[1]=='') {
		alert("Please provide your name");
		document.addentry.guest1.focus();
		return false;
	}
	if (guestfield[6]=='') {
		alert("Please provide your comments");
		document.addentry.guest6.focus();
		return false;
	}
	for(i=1; i<7 ; i++) {
		j=guestfield[i].length;
		j=j-3;
		for(k=0; k<j+1 ; k++) {
			var tester=guestfield[i].substring(k,k+4);
			tester=tester.toLowerCase();
			if (tester=='http') {
				killSpammers();
				return false;
			}
			if (tester=='href') {
				killSpammers();
				return false;
			}
			var tester2=tester.substring(0,3);
			if (tester2=='www') {
				killSpammers();
				return false;
			}
		}
	}
	document.addentry.action='http://www.casitascopes.com/cgi-bin/gstbk.pl';
	return true;
}

function killSpammers() {
	alert("Do not post web links in this guestbook!");
	document.addentry.reset();
	document.addentry.guest1.focus();
}

/*
}function handleGuestSubmit() {
	var guestname=document.addentry.realname.value;
	var guestcomments=document.addentry.comments.value;
	if (guestname=='') {
		alert("Please provide your name");
		document.addentry.realname.focus();
		return false;
	}
	if (guestcomments=='') {
		alert("Please provide your comments");
		document.addentry.comments.focus();
		return false;
	}
	return true;
}
*/

/*
WM_setCookie(), WM_readCookie(), WM_killCookie()
A set of functions that eases the pain of using cookies.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: nadav@wired.com
*/


// This next little bit of code tests whether the user accepts cookies.
function WM_acceptsCookies() {
    document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
    if(document.cookie.indexOf('WM_acceptsCookies=yes') != -1) {
	WM_killCookie('WM_acceptsCookies'); 
	return true; // If it succeeds, set variable
    } else {
	return false;
    }
}


function WM_setCookie (name, value, hours) {
	var not_NN2 = (navigator && navigator.appName 
		       && (navigator.appName == 'Netscape') 
		       && navigator.appVersion 
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) { // NN2 cannot handle Dates, so skip this part
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?('; expires=' + numHours):'') + '; path=/'; // Set the cookie, adding any parameters that were specified.
} // WM_setCookie


function WM_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false;
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
} // WM_readCookie

function WM_killCookie(name) {
  var theValue = WM_readCookie(name); // We need the value to kill the cookie
  if(theValue) {
      document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT; path=/'; // set an already-expired cookie
  }
} // WM_killCookie
