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] = "welcome";
dirNames[1] = "treatments";
dirNames[2] = "your_skin";
dirNames[3] = "removing_hair";
dirNames[4] = "home_use_products";
dirNames[5] = "media_say";
dirNames[6] = "how_zipt_works";
dirNames[7] = "contact_us";
dirNames[8] = "links";
dirNames[9] = "client_comments";

//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/menu_' + dirNames[i] + '_up.gif"');
		eval("" + dirNames[i] + 'On = new Image()');
		eval("" + dirNames[i] + 'On.src = "/images/menu_' + dirNames[i] + '_dn.gif"');
	}
}

function findCurrent()
{
	if (loaded == true && ((isIe && major >= 4) || (isNav && major >= 3)))	
	{		
		var 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('\\');
		
		//get filename
		currentPage = currentUrl.substring(pos+1);
		var dotPos = currentPage.lastIndexOf('.');
		if (dotPos != -1)
		{
			if (currentPage.substring(dotPos,currentPage.length) == ".html" || currentPage.substring(dotPos,currentPage.length) == ".htm")
				currentPage = currentPage.substring(0,dotPos);
		}
		
		//get dir name
		currentUrl = currentUrl.substring(0,pos);
			
			pos = currentUrl.lastIndexOf('/');
		if (pos == -1)
			pos = currentUrl.lastIndexOf('\\');
		currentUrl = currentUrl.substring(pos+1);

		setCurrentDir(currentUrl);
		if (currentPage != "index" && currentPage != "")
			setActive(currentPage);
	}
}

function setCurrentDir(url)
{
	if ((isIe && major >= 4) || (isNav && major >= 3))
	{
		for (i = 1; i <= dirNames.length-1; i++)
		{
			if (url == dirNames[i])
			{
				eval('' + url + 'Off.src = "/images/menu_' + url + '_dn.gif"');
				eval('document.' + url + '.src = "/images/menu_' + url + '_dn.gif"');
				break;
			}
			if (i == dirNames.length-1)
			{
				eval('' + dirNames[0] + 'Off.src = "/images/menu_' + dirNames[0] + '_up.gif"');
				eval('document.' + url + '.src = "/images/menu_' + url + '_dn.gif"');
			}
		}		
	}
}

function setActive(marker)
// sets font style properties for current submenu item
{
	if ((isIe && major >= 4) || (isNav && major >= 3))
	{
     	if (isIe && major >= 4)
      {
				document.all["link" + marker].style.color = "#000000";
				document.all["link" + marker].style.textDecoration = "underline";
			}
			if (isNav6)
			{
				document.getElementById("link" + marker).style.color = "#000000";
				document.getElementById("link" + marker).style.textDecoration = "underline";
			}
  	}
}

// img swap code for left navigation rollovers
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;
	}
}

var submenuItem = 0;

function createSubMenuItem(itemName, itemURL)
// sample usages 	createSubMenuItem("Waxing", "waxing");
//					createSubMenuItem("Stress Management", "stress_management.htm");
//					createSubMenuItem("Packages", "packages.html");
{
	var dotPos = itemURL.lastIndexOf('.');
	var fileExt = ".html";
	if (dotPos != -1)
	{
		if (itemURL.substring(dotPos,itemURL.length) == ".html" || itemURL.substring(dotPos,itemURL.length) == ".htm")
		{
			fileExt = itemURL.substring(dotPos,itemURL.length);
			itemURL = itemURL.substring(0,dotPos);
		}
	}
	if (submenuItem == 0)
		document.write('&nbsp;<img src="/images/bullet_square.gif" alt="-" width="3" height="8" border="0"> ');
		
	document.write('<a class="submenu" href="' + itemURL + fileExt + '" ID="link' + itemURL + '">' + itemName + '</a> ');
	document.write('<img src="/images/bullet_square.gif" alt="-" width="3" height="8" border="0"> ');
	submenuItem++;  
}

function popUp(url, wwidth, wheight)
// this function pops up a very simple window of appropriate width and height
// usage: <a href="javascript:popUp('file.html');">view this here</a>
{
	if (wwidth == null)
		wwidth = 420;
	if (wheight == null)
		wheight = 400;
	
	window.open(url, "pic_window", "resizable,width=" + wwidth + ",height=" + wheight + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,top=100,left=100");
}