//
// JavaScript include file for all HomeTech.com files.
//

// determine if this browser can switch images
canimgswitch = 
  (((navigator.appName == "Netscape") && 
  (parseInt(navigator.appVersion) >= 3 )) || 
  ((navigator.appName == "Microsoft Internet Explorer") && 
  (parseInt(navigator.appVersion) >= 4 ))); 

// do the image switches
function imgswitch(buttonname,newimage) {
    if(canimgswitch) {
        for (i = 0 ; i < document.images.length ; i++) {
            if (document.images[i].name == buttonname) {
                document.images[i].src = newimage;
            }
        }
    }
}

// pop up a window and display a URL. Used for glossary lookups
function popUp(contentLink){
	var nameBrowser = navigator.appName;
	var verBrowser = navigator.appVersion.substring(0,1);
	if (nameBrowser == 'Microsoft Internet Explorer' && verBrowser <4)
		var popUpWindow = window.open(contentLink,'','height=600,width=400,scrollbars,resizable');
	else {
		var popUpWindow = window.open(contentLink,'popUpWindow','height=600,width=400,scrollbars,resizable');
		popUpWindow.focus();
	}
}

// function that jumps to a knowledgebase article
function jumpKBN(){
	window.location = 'http://svr10.hometech.com/activekb/questions/' + document.kbnform.kbn.value;
	return false;
}

//
// The following functions are all part of the item image display system
//

// method for imgobject below; switch to the next image, if any
function imgnext(){
	if ( this.curpic < this.pics.length - 1 ) {
		this.curpic++;
		this.update();
	}
}
// method for imgobject below; switch to the previous image, if any
function imgprev(){
	if ( this.curpic > 0 ) {
		this.curpic--;
		this.update();
	}
}
// method for imgobject below; update the screen to match new curpic (current picture) index
function imgupdate() {
	// change the picture
	s = "document." + this.handle + ".src = this.pics[this.curpic];";
	eval(s);

	// change the buttons and tooltip text appropriatly
	if (this.curpic == 0) {
		cmd1 = "document." + this.handle+"prev.src = '../pics/picblank.gif'";
		cmd2 = "document." + this.handle+"prev.title = ''";
	} else {
		cmd1 = "document." + this.handle+"prev.src = '../pics/picprev.gif'";
		cmd2 = "document." + this.handle+"prev.title = 'Previous Picture'";
	}
	eval(cmd1);
	eval(cmd2);
	if ( this.curpic >= this.pics.length - 1 ) {
		cmd1 = "document." + this.handle+"next.src = '../pics/picblank.gif'";
		cmd2 = "document." + this.handle+"next.title = ''";
	} else {
		cmd1 = "document." + this.handle+"next.src = '../pics/picnext.gif'";
		cmd2 = "document." + this.handle+"next.title = 'Next Picture'";
	}
	eval(cmd1);
	eval(cmd2);
	if ( this.curpic < this.picsbig.length && this.picsbig[this.curpic].length > 0 ) {
		cmd1 = "document." + this.handle+"big.src = '../pics/picbig.gif'";
		cmd2 = "document." + this.handle+"big.title = 'Enlarge Picture'";
	} else {
		cmd1 = "document." + this.handle+"big.src = '../pics/picblank.gif'";
		cmd2 = "document." + this.handle+"big.title = ''";
	}
	eval(cmd1);
	eval(cmd2);
}
// method for imgobject below; user clicked the magnifying glass, pop up a window with the bigger picture, if any
function imgbig(){
	if ( this.curpic < this.picsbig.length && this.picsbig[this.curpic].length > 0 ) {
		var nameBrowser = navigator.appName;
		var verBrowser = navigator.appVersion.substring(0,1);
		var baseurl = location.href.substr(0,location.href.lastIndexOf('/')+1);
		var url = "../home/picshow.html?" + baseurl + this.picsbig[this.curpic] + "&" + this.heading;
		if (nameBrowser == 'Microsoft Internet Explorer' && verBrowser <4)
			var popUpWindow = window.open(url,'height=300,width=300,scrollbars,resizable');
		else {
			var popUpWindow = window.open(url,'popUpWindow','height=300,width=300,scrollbars,resizable');
			popUpWindow.focus();
		}
	}
}
// create an image object that contains all the properties and methods we need
function imgobject(imghandle,imgheading,imgpics, imgpicsbig){
	// properties
	this.pics = imgpics;
	this.picsbig = imgpicsbig;
	this.curpic = 0;
	this.handle = imghandle;
	this.heading = escape(imgheading);

	// methods (defined above)
	this.update = imgupdate;
	this.next = imgnext;
	this.prev = imgprev;
	this.big = imgbig;

	this.update();
}
