/*
Author: William La Morte &copy; copyright 2000
Email: wlm@xiio.com
http://www.xiio.com
There are no requirements for using this API. I only ask that you leave this comment intact.
This API was written to assist with my own works as well assist other developers with their work.
If you improve or enhance this script, please place your name and date below this comment. Report bugs or questions/comments to author
*/

/*
Improved by:
Date:
*/

function OpenWin(url,width,height) {
	newWindow = window.open(url,"NewWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width="+width+",height="+height)
}


//handle browser resizing problem for navigator 4
if(!window.orig_width) {
  window.onresize = reset_layers;
  window.orig_width = window.innerWidth;
  window.orig_height = window.innerHeight;
}

function reset_layers() {
    if (window.innerWidth != orig_width || window.innerHeight != orig_height) {
      location.reload();
    }
}

//declare globals to build object reference
var whichDom = "", styleObj = ""
var isNav4, isNav6, isIE
var isBrand = navigator.appName
var agt = navigator.userAgent.toLowerCase()
var navVer = parseInt(navigator.appVersion)

//these variables are handy for determining which styles to load
isNav4 = (isBrand == "Netscape" && navVer < 5) ? true : false
isNav6 = (isBrand == "Netscape" && navVer >= 5) ? true : false
isNav46 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >= parseFloat(4.6)) && (parseFloat(navigator.appVersion) < parseFloat(4.7))) ? true : false
isNav47 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >= parseFloat(4.7))) ? true : false
isIE = ((agt.indexOf("msie") != -1) && (parseInt(navVer) >= 4)) ? true : false



//load a style sheet depending on users browser
/*
if (isNav4)	{
	document.write('<link="stylesheet" href="style.css">')
} else if (isNav6)	{
	document.write('<link="stylesheet" href="style.css">')
} else	{
	document.write('<link="stylesheet" href="style.css">')
}
*/

//construct object reference
if(isNav6)  {
  whichDom = '.getElementById("'
  styleObj = '").style'
} else if (isNav4)  {
  whichDom = '["'
  styleObj = '"]'
} else {
  whichDom = ".all."
  styleObj = ".style"
}

function preloadHome() {
//Preload the navigation images
//preload images
image1= new Image();
image1.src = "images/ecenter.gif";
image1on = new Image();
image1on.src = "images/ecenter1.gif";
image1alt = new Image();
image1alt.src = "images/hometext.gif";
image1alton = new Image();
image1alton.src = "images/ecentertext.gif";

image2= new Image();
image2.src = "images/services.gif";
image2on = new Image();
image2on.src = "images/services1.gif";
image2alt = new Image();
image2alt.src = "images/hometext.gif";
image2alton = new Image();
image2alton.src = "images/servicetext.gif";

image3= new Image();
image3.src = "images/company.gif";
image3on = new Image();
image3on.src = "images/company1.gif";
image3alt = new Image();
image3alt.src = "images/hometext.gif";
image3alton = new Image();
image3alton.src = "images/companylist.gif";

image4= new Image();
image4.src = "images/subecent.gif";
image4on = new Image();
image4on.src = "images/subecent1.gif";

image5= new Image();
image5.src = "images/subservices.gif";
image5on = new Image();
image5on.src = "images/subservices1.gif";

image6= new Image();
image6.src = "images/thetour.gif";
image6on = new Image();
image6on.src = "images/thetour1.gif";

image7= new Image();
image7.src = "images/demo.gif";
image7on = new Image();
image7on.src = "images/demo1.gif";

image8= new Image();
image8.src = "images/contact.gif";
image8on = new Image();
image8on.src = "images/contact1.gif";

image9= new Image();
image9.src = "images/subsupport.gif";
image9on = new Image();
image9on.src = "images/subsupport1.gif";

image10= new Image();
image10.src = "images/subpartners.gif";
image10on = new Image();
image10on.src = "images/subpartners1.gif";

image11= new Image();
image11.src = "images/subjobs.gif";
image11on = new Image();
image11on.src = "images/subjobs1.gif";

image12= new Image();
image12.src = "images/subnews.gif";
image12on = new Image();
image12on.src = "images/subnews1.gif";

//End loading
}

function preloadSub() {
//Preload the navigation images
//preload images
image1= new Image();
image1.src = "images/tours.gif";
image1on = new Image();
image1on.src = "images/tours1.gif";

image2= new Image();
image2.src = "images/travelinfo.gif";
image2on = new Image();
image2on.src = "images/travelinfo1.gif";

image3= new Image();
image3.src = "images/testimonials.gif";
image3on = new Image();
image3on.src = "images/testimonials1.gif";

image4= new Image();
image4.src = "images/vtour.gif";
image4on = new Image();
image4on.src = "images/vtour1.gif";

image5= new Image();
image5.src = "images/faq.gif";
image5on = new Image();
image5on.src = "images/faq1.gif";

image6= new Image();
image6.src = "images/calendar.gif";
image6on = new Image();
image6on.src = "images/calendar1.gif";

image7= new Image();
image7.src = "images/home.gif";
image7on = new Image();
image7on.src = "images/home1.gif";

image8= new Image();
image8.src = "images/leftbutton.gif";
image8on = new Image();
image8on.src = "images/leftbutton1.gif";

image9= new Image();
image9.src = "images/rightbutton.gif";
image9on = new Image();
image9on.src = "images/rightbutton1.gif";

//End loading
}

//Set imageStay to nothing
imageStay = ""

// Check to make sure browser is not too old to display Javascript stuff
if (navigator.appVersion.indexOf("2.") != -1){
        check = false;
        }
if ((navigator.appVersion.indexOf("3.") != -1) && (navigator.appName.indexOf("Explorer") != -1)){
        check = false;
        }
else {
        check = true;
        }

//UPDATE TOTAL TO RESERVATION FORM
function UpdateTotal(thisfield) {
	val = 400 * eval(thisfield.options[thisfield.selectedIndex].text);
	//val = '$' + val;
	return(val);
}

//DISPLAY SHIRT SIZE SELECT FIELDS DEPENDING ON NUMBER OF SHIRTS SELECTED
function showShirtSize() {
	var ssnumb = document.forms['go'].elements['cycling_shirt_quantity'].value;
	var ssArray = ssList.split(",");
	for (i=0;i<ssArray.length;i++) {
		if (isNav6) {
			document.getElementById(ssArray[i]).style.display = "none";
		}
		else {
			document.all[ssArray[i]].style.display = "none";
		}
	}
	for (i=0;i<ssnumb;i++) {
		if (isNav6) {
			document.getElementById(ssArray[i]).style.display = "block";
		}
		else {
			document.all[ssArray[i]].style.display = "block";
		}
	}
}

//load image when mouseover
function imageon(name){
        if (imageStay != name){
                document[name].src = eval(name + "on.src");
//                document["altimg"].src = eval(name + "alton.src");
        }
}

//load image when mouseoff
function imageoff(name){
        if (imageStay != name){
                document[name].src = eval(name + ".src");
//                document["altimg"].src = eval(name + "alt.src");
        }
}

function on(name){
        if (check == true){
        imageon(name);
        }
}
function off(name){
        if (check == true){
        imageoff(name);
        }
}

function buttonOn(name) {
	document.images[name].src = "images/button-on.gif"
}

function buttonOff(name) {
	document.images[name].src = "images/button-off.gif"
}		

function rightButtonOn(name) {
	document.images[name].src = "images/rightbutton1.gif"
}

function rightButtonOff(name) {
	document.images[name].src = "images/rightbutton.gif"
}		

//keep the image there when clicked even if mousedoff
function stay(name){
        if (check == true){
        document[name].src = eval(name + "stay.src");
        if (imageStay != name){
                if (imageStay != ""){
                        document[imageStay].src = eval(imageStay + ".src");
                }
        }
        imageStay = name
        }
}

//API object reference
function theObject(obj) {
var theObj
	if (typeof obj == "string")
		theObj = eval("document" + whichDom + obj + styleObj)
	else
		theObj = obj
		return theObj
}

function moveObjTo(obj, x, y) {
var theObj = theObject(obj)
	if (isNav4) {
		theObj.moveTo(x,y)
	} else if (isIE) {
		theObj.pixelLeft = x
		theObj.pixelTop = y
	} else	{//nav6
		theObj.left = x +"px"
		theObj.top = y +"px"
	}
}



//nav6 returns string values for positionable elements ie. left "100px"
//must parse string values and convert to number values
function moveObjBy(obj, deltaX, deltaY) {
var theObj = theObject(obj)
  if (isNav4) {
    theObj.moveBy(deltaX, deltaY)
  } else if (document.all) {
    theObj.pixelLeft += deltaX
    theObj.pixelTop += deltaY
  } else  {
    var theLeft = getObjLeft(theObj)
    var theTop = getObjTop(theObj)
    setObjLeft(theObj, parseInt(theLeft)+deltaX)
    setObjTop(theObj, parseInt(theTop)+deltaY)
  }
}



function show(obj) {
var theObj = theObject(obj)
	lastObj = theObject(lastItem)
	lastObj.visibility = "hidden"
	theObj.visibility = "visible"
	
	lastItem = theObject(obj)
}

function hide(obj) {
var theObj = theObject(obj)
	theObj.visibility = "hidden"
}

//nav4 reads and returns value of "show" but also reads "visible"
//nav4 reads and returns value of "hide" but also reads "hidden"
//test???
function getObjVisibility(obj)	{
var theObj = theObject(obj)
	if (theObj.visibility == "" || theObj.visibility == null)	{
		return "visible"
	} else	{
		return theObj.visibility
	}
}
