var isNetscape = (navigator.appName == "Netscape");
var bVer=parseInt(navigator.appVersion);

NS4 = (document.layers) ? true : false;
IE4 = ((document.all) && (bVer>=4)) ? true : false;
NS6 = ((isNetscape==true) && (bVer>=5)) ? true : false;

collectObj = (IE4) ? "all." : "";
styleObj = (IE4)||(NS6) ? ".style" : "";

if (NS4||NS6) { 
	avail_width = innerWidth;
	avail_height = innerHeight;}
else {
	avail_width = document.body.clientWidth;
	avail_height = document.body.clientHeight;}

function getObj( objName )
{
	if (NS6) { var theObj = document.getElementById(objName).style;}
	else { var theObj = eval( "document." + collectObj + objName + styleObj )}

	return theObj;
}

function av (objName)	{
 getObj(objName).color = '#FFCC33'
}

function ao (objName)	{
 getObj(objName).color = '#FFFFFF'
}

function mVis (objName)
{
	var visNavObj = getObj(objName);
	visNavObj.visibility = "visible"; 
}

function mInv (objName)
{
	var visNavObj = getObj(objName);
	visNavObj.visibility = "hidden"; 
}	
	
function img_act(imgID,imgName,src_code,alt_code) {

	if (NS6) { var XImg = document[imgName];}
	else {
		if (NS4) {
			if (imgID == "") {
				var XImg = eval("document.images[imgName]") }
			else {
				var XImg = eval( "document." + imgID + ".document.images[imgName]"); }
		}
		else {
			var XImg = eval( "document.all." + imgName );
		}
	}
	XImg.src=src_code;
	XImg.alt=alt_code;
}

function ShowLargeImage() {
	window.location = "i/" + CurrPicName + "650x450.jpg";
}

function ShowDetailOverL0() {
	picURL = "i/" + CurrPicName + "650x450.jpg"
	eval("picwindow1=open('CabanaVillagePic.asp?Photo='+ picURL +'','popwindow2','dependent=yes,scrollbars=no,width=656,height=456,resizable=no,screenX=20,screenY=20')");
}

function ShowDetailOver() {
	picURL = "i/" + CurrPicName + "650x450.jpg"
	eval("picwindow1=open('http://www.cabanavillage.com/CabanaVillagePic.asp?Photo='+ picURL +'','popwindow2','dependent=yes,scrollbars=no,width=656,height=456,resizable=no,screenX=20,screenY=20')");
}

function ShowDetailOverL2() {
	picURL = "i/" + CurrPicName + "650x450.jpg"
	eval("picwindow1=open('http://www.cabanavillage.com/CabanaVillagePic.asp?Photo='+ picURL +'','popwindow2','dependent=yes,scrollbars=no,width=656,height=456,resizable=no,screenX=20,screenY=20')");
}

function upImage () {
	indexNum = indexNum + 1;
	if (indexNum >= maxPics) { indexNum = 0 }
	shufflePics();
}

function downImage () {
	indexNum = indexNum - 1;
	if (indexNum < 0) { indexNum = indexNum + maxPics }
	shufflePics();
}

function refreshImage () {
	indexNum = indexNum;
	if (indexNum < 0) { indexNum = indexNum + maxPics }
	shufflePics();
	rodentOver(0);
}

function StartRotateImage() {
	hideTimer = null;
	hideTimer = setTimeout('rotateImage()',10000);
}

function rotateImage() {
	upImage();
	rodentOver(0);
	hideTimer = null;
	hideTimer = setTimeout('rotateImage()',5000);
}

function rodentOver (picNum) {
	var tempIndex = picNum + indexNum
	if (tempIndex >= maxPics) {
		tempIndex = tempIndex - maxPics }
	if (tempIndex < 0) {
		tempIndex = tempIndex + maxPics }
	var tempName = "http://www.cabanavillage.com/i/" + PagePic[tempIndex] + ".jpg";
	var tempALT = PageAlt[tempIndex] + " photo - click to enlarge";
	img_act('','mainpic',tempName,tempALT);
	CurrPicName = PagePic[tempIndex]; 
	CurrURLName = PageURL[tempIndex];
}

function shufflePics () {
	var tempSRC;
	var smIndex;
	var tempSmImg;
	var tempALT;
	smIndex = indexNum;
	for (var i=0; i < maxNum; i++){
		tempSRC = "pic" + i;
		if (smIndex >= maxPics) { smIndex = 0}
		if (smIndex < 0) { smIndex = maxPics - 1}
		tempSmImg = "i/" + PagePic[smIndex] + "90x70.jpg";
		if (PageAlt[smIndex] == "") {
			tempALT = "enlarge photo"}
		else	{
			tempALT = PageAlt[smIndex] + " kit prices, info & more pictures"}
		smIndex = smIndex + 1;
		img_act('',tempSRC,tempSmImg,tempALT);
	}
}


function PopUpOnTop(url) {
	if (avail_width < 655) {
		eval("popwindow1=open(url,'popwindow1','dependent=yes,scrollbars=yes,width=600,height=405,resizable=yes,screenX=20,screenY=20')");}
	else	{
		if (avail_width > 800) {
			eval("popwindow1=open(url,'popwindow1','dependent=yes,scrollbars=yes,width=795,height=565,resizable=yes,screenX=20,screenY=20')");}
		else	{
			eval("popwindow1=open(url,'popwindow1','dependent=yes,scrollbars=yes,width=760,height=500,resizable=yes,screenX=20,screenY=20')");}
	}
}

function DocumentOnLoad() {
	var preloadArray = new Array();
	var tempName;
	var j = 0;
	for (i=0; i < maxPics; i++) {
		tempName = "i/" + PagePic[i] + ".jpg";
		preloadArray[j] = new Image;
        preloadArray[j++].src = tempName;
	}	
}
