var agt=navigator.userAgent.toLowerCase();
var major = parseInt(navigator.appVersion);
var isNav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
var isIe   = (agt.indexOf("msie") != -1);
var isNav6 = isNav && (agt.indexOf('netscape 6') != -1 || agt.indexOf('gecko') != -1)

var loaded = false;

// directory names and partial image names
var dirNames = new Array();
dirNames[0] = "about_us";
dirNames[1] = "personnel";
dirNames[2] = "web_work";
dirNames[3] = "contact_us";

//image preloader
var supportsImageChanges = false;
if ((isNav && major >= 3) || (isIe && major >= 4))
	supportsImageChanges = true;
	
if (supportsImageChanges == true)
{
	for (i = 0; i < dirNames.length; i++)
	{
		eval("" + dirNames[i] + 'Off = new Image()');
		eval("" + dirNames[i] + 'Off.src = "images/button_' + dirNames[i] + '_up.gif"');
		eval("" + dirNames[i] + 'On = new Image()');
		eval("" + dirNames[i] + 'On.src = "images/button_' + dirNames[i] + '_dn.gif"');
	}
}

var itemName = null;

function navOver(link)
{
	if (supportsImageChanges == true)
	{
		if (itemName != null)
			eval('document.' + itemName + '.src = ' + itemName + 'Off.src');
		itemName = link;
		eval('document.' + itemName + '.src = ' + itemName + 'On.src');
	}
}

function navOut()
{
	if (supportsImageChanges == true)
	{
		if (itemName != null)
			eval('document.' + itemName + '.src = ' + itemName + 'Off.src');
		itemName = null;
	}
}

// pull filename out of url string 
// runs on page load; calls setCurrent
function findCurrent()
{
  if (loaded == true && ((isIe && major >= 4) || (isNav && major >= 3)))	
  {
    currentUrl = self.location.pathname;
    if (currentUrl.substring(2, 3) == ':' || currentUrl.substring(2, 3) == '|')
      currentUrl = currentUrl.substring(3);
    pos = currentUrl.lastIndexOf('/');
    if (pos == -1)
      pos = currentUrl.lastIndexOf('\\');
    currentUrl = currentUrl.substring(pos + 1);
	
	if (currentUrl == "")
		currentUrl = "index.html";
		
    // remove file extension
    pos = currentUrl.lastIndexOf('.');
    currentUrl = currentUrl.substring(0,pos);
		if (currentUrl == "index")
			currentUrl = "about_us";
		if (currentUrl == "needinfo" || currentUrl =="thanks")
			currentUrl = "contact_us";
		
  	setCurrent(currentUrl);
  }
}

function setCurrent(url)
{
	if ((isIe && major >= 4) || (isNav && major >= 3))
	{
		for (i = 0; i <= dirNames.length-1; i++)
		{
			if (url == dirNames[i])
			{
				eval('' + url + 'Off.src = "images/button_' + url + '_dn.gif"');
				eval('document.' + url + '.src = "images/button_' + url + '_dn.gif"');
				break;
			}
			if (i == dirNames.length-1)
			{
				eval('' + dirNames[0] + 'Off.src = "images/button_' + dirNames[0] + '_up.gif"');
				eval('document.' + url + '.src = "images/button_' + url + '_dn.gif"');
			}
		}		
	}
}

//	This function creates a pop-up window sized just right for an image, 
//  using the image's name, width, height and description as parameters. 

function openPicWindow(pic, picWidth, picHeight, picDesc)
{
	picName = pic;
	winWidth = picWidth + 50;
	winHeight = picHeight + 100;
	NewWin = window.open("", "pic_window", "resizable,width="+ winWidth + ",height="+ winHeight);
	
	NewWin.document.open();
	NewWin.document.write('<html><head><title>Darcsyde Productions - Web Developement - ' + picDesc + '<\/title><\/head><link href="styleguide.css" rel="stylesheet" type="text/css"><body bgcolor="#FFFFCC" background="images\/cream.gif"><center><img src="images\/'+ pic +'" vspace=7 width=' + picWidth +' height=' + picHeight + ' alt=' + picDesc +'><br><form><input type=image src="images\/close.gif" alt="close" width=50 height=23 border=0 name="image" onClick="window.close()"><\/form><\/center><\/body><\/html>');
	NewWin.document.close();
}