/// Browser Detection ///////////////////
	NS4	= (document.layers);
	IE4	= (document.all);
	isMac =	(navigator.appVersion.indexOf("Mac") !=	-1);
	isOpera = (navigator.userAgent.indexOf("Opera") !=	-1);
	isNS = (NS4	&& !isMac);
	isIE = (IE4	&& !isMac);

/// Geting and Seting Params Functions ///////////////////////
	function GetParam(ParamName) {
		var	StartInd=0
		var	URLtoParse	= window.document.location.href
		var	ParamLen = ParamName.length	+ 1
		var	EndInd=0
		var lwrURLtoParse

		ParamName =	ParamName.toLowerCase()
		lwrURLtoParse	= URLtoParse.toLowerCase()
		StartInd = lwrURLtoParse.indexOf(ParamName + "=")
		if (StartInd ==	-1) return ""
		EndInd = lwrURLtoParse.indexOf("&", StartInd + 1)
		if (EndInd == -1) EndInd = lwrURLtoParse.length - (StartInd + ParamLen)
		else EndInd = EndInd - (StartInd + ParamLen)
		return unescape(URLtoParse.substr(StartInd + ParamLen, EndInd))
	}

	// set the variable "ParamName" to be the first existing of:
	// 1. url parameter by that name
	// 2. definded variable by that name
	// 3. Default Value
	function resolveParam(paramName,defualtValue) {
		//alert(paramName)
		//alert(typeof(paramName))
		var tempValue
		tempValue = GetParam(paramName)
		if ((tempValue == "") && 
			(eval('typeof('+paramName+')') != "undefined")) {
			tempValue = eval(paramName)
		}
		if (tempValue == "") {
			tempValue = defualtValue
		}
		return tempValue
	}
	
	////////////////////////////////////////////
	function GetCookie(sName) {
		// cookies are separated by semicolons
		var aCookie = document.cookie.split(";");
		for (var i=0; i < aCookie.length; i++) {
			// a name/value pair (a crumb) is separated by an equal sign
			var aCrumb = aCookie[i].split("=");
			if (sName == aCrumb[0])
				return unescape(aCrumb[1]);
		}
		// a cookie with the requested name does not exist
		return null;
	}
	
	////////////////////////////////////////////
	function SetCookie(sName, sVal) {
			var exp = new Date();
			var TenYears = exp.getTime() + ( 3650 * 24 * 3600 * 1000);
			exp.setTime(TenYears);
			if (isIE) document.cookie = sName + "=" + escape(sVal) + "; domain=hotbar.com; path=/; expires=" + exp.toGMTString();
			else if (isNS) document.cookie = sName + "=" + escape(sVal) + "; path=/; expires=" + exp.toGMTString();
	}
	
	function removeParamFromURL(URL,ParamName){		
		var result
		var lwrURL = URL.toLowerCase();
		ParamNameStartPos = lwrURL.indexOf("?" + ParamName + "=");
		if (ParamNameStartPos == -1) {
			ParamNameStartPos = lwrURL.indexOf("&" + ParamName + "=");
		}
		if (ParamNameStartPos == -1) { 
			result = URL
		}
		else {
			ParamNameEndPos = lwrURL.indexOf("&",ParamNameStartPos + 1)
			if (ParamNameEndPos == -1) {
				result = URL.substr(0,ParamNameStartPos)
			}
			else {
				result = URL.substr(0,ParamNameStartPos + 1) + URL.substr(ParamNameEndPos + 1)
			}
		}
		return result
	}


/// Resolve Variables //////////////////////////////////	
	/// Generic Variables //////////////////////////////
	var BrowserType = "OTHER";
	var BrowserDir = "IE"
	if (!isOpera) {
		if (isIE) {
			BrowserType = "IE" 
		} 
		else if (isNS) {
			//BrowserType = "NS"
			BrowserType = "OTHER"
			BrowserDir = "NS"
		}
	}
	DefaultSkin = resolveParam('DefaultSkin','') //http://skins.hotbar.com/skins/xip/5555/5555hotbar.xip')
	img = resolveParam('img','')  //old version compatibility
	NextUrl = resolveParam('NextUrl',location.href)
	
	/// Page Visibility Variables
	ShowBox = resolveParam('ShowBox','true')
	UseFirstVisit = resolveParam('UseFirstVisit','false')
	license = resolveParam('license','false')
	showTour = resolveParam('showTour','false')

	/// TP1 and Special Instalation Variables
	ScriptVer = resolveParam('ScriptVer','')
	Partner = resolveParam('Partner','')
	Version = resolveParam('Version','')
	
	NsRedirAllow = resolveParam('NsRedirAllow','false')
	OtherPath = resolveParam('OtherPath','site/abouthotbar/whatis.htm')
	
	Guide = resolveParam('Guide','')  //old version compatibility
	AdditionalXips = resolveParam('AdditionalXips','')
	TourURL = resolveParam('TourURL','/install/Tour.asp?TourType=Install')
	UseNewWin = resolveParam('UseNewWin','true')
	Requestor = resolveParam('Requestor','SkinCenter')
	VirtualDir = resolveParam('VirtualDir','hotbar.com/')
	AliasDomain = resolveParam('AliasDomain','hotbar.com')
	BannerID = resolveParam('BannerID','')
	RecipientID = resolveParam('RecipientID','')
	InternalSend = resolveParam('InternalSend','false')
	ToolbarID = resolveParam('ToolbarID','0')
	
	/// Special Functions
	AlwaysInstall = resolveParam('AlwaysInstall','false')
	HandleImgParam = resolveParam('HandleImgParam','true')
	inIframe = resolveParam('inIframe','false')
	
	/// Dynamic Design FSO location (the following code must be after resolving of UseNewWin)
	FirstVisitDURL = resolveParam('FirstVisitDURL','local:\\install\\'+ BrowserDir +'\\FirstVisitDesign.asp')
	if(UseNewWin == 'true') {
		InstallDURL = resolveParam('InstallDURL','local:\\install\\'+ BrowserDir +'\\installDesignSmall.asp')
	}
	else {	
		InstallDURL = resolveParam('InstallDURL','local:\\install\\'+ BrowserDir +'\\installDesignBig.asp')
	}
	NoinstallDURL = resolveParam('NoinstallDURL','local:\\install\\'+ BrowserDir +'\\noinstallDesign.asp')
	
	var wndDownload; 
	var HbCtl;
	var CtlVer;


/// FUNCTIONS:
	// "Install if Required" Proccess
	function isWindowAlive(oWindow) {
		// Trick to test if the object does not refer 
		// to a window that was allready closed
		return (typeof(oWindow.length) == "number")
	}
	
	function InstallIfRequired(SkinUrl) {
		if(IsCtlInstalled() && (AlwaysInstall == 'false')) {
			getUI()
			return true;
		}
		else {
			InstallNow(SkinUrl)
		}
	}

	function InstallNow(SkinUrl){
		if (SkinUrl.length != 0){
			DefaultSkin == SkinUrl
		}
		if (isIE) {
			var WinURL = "http://" + AliasDomain + "/install/startInstallProcess.asp"
				+ "?DefaultSkin=" + escape(DefaultSkin)
				+ "&AdditionalXips=" + escape(AdditionalXips)
				+ "&NextUrl=" + escape(NextUrl)
				+ "&guide=" + escape(Guide)
				+ "&Requestor=" + escape(Requestor)
				+ "&BannerID=" + escape(BannerID)
				+ "&RecipientID=" + escape(RecipientID)
				+ "&BrowserType=" + escape(BrowserType)
				+ "&useNewWin=" + escape(UseNewWin)
				+ "&ScriptVer=" + escape(ScriptVer)
				+ "&ShowBox=" + escape(ShowBox)
				+ "&useFirstVisit=" + escape(UseFirstVisit)
				+ "&license=" + escape(license)
				+ "&TourURL=" + escape(TourURL)
				+ "&VirtualDir=" + escape(VirtualDir)
				+ "&AliasDomain=" + escape(AliasDomain)
				+ "&Partner=" + escape(Partner)
				+ "&ToolbarID=" + escape(ToolbarID)
				+ "&Version=" + escape(Version)
				+ "&showTour=" + escape(showTour)
				+ "&AlwaysInstall=" + escape(AlwaysInstall)
				
						
				/// pages locations 
				+ "&FirstVisitDURL=" + escape(FirstVisitDURL)		
									
				+ "&InstallDURL=" + escape(InstallDURL)
				+ "&NoinstallDURL=" + escape(NoinstallDURL)	
				+ "&inIframe=" + escape(inIframe)
							
				
				if (UseNewWin == 'true') {
					if (wndDownload && isWindowAlive(wndDownload)){
						wndDownload.focus() 
					}
					else {
						// open install window
						//wndDownload = window.open(WinURL,"","");
						//wndDownload = window.open(WinURL,"install","toolbar=no,menubar=no,location=no,status=no,directories=no,copyhistory=no,top=30,left=30,width=377,height=369,scrollbars=no,resizable=no");
						wndDownload = window.open(WinURL,"install","toolbar=no,menubar=no,location=no,status=no,directories=no,copyhistory=no,top=30,left=3000,width=377,height=369,scrollbars=no,resizable=no");
					}
				}
				else {
					location.replace (WinURL);	
				}
		}
		else {
			/// NS & Other Install
			gotoOtherSection()
		}
		return false;
	}
	
	/// Do Not Install for "OTHER" browsers
	function gotoOtherSection() {
		if (NsRedirAllow == 'true') {
			//window.open("http://hotbar.com/site/abouthotbar/whatis.htm","","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,width=220,height=200,left=40,top=100");	
			document.location.href = 'http://' + VirtualDir + OtherPath; // "site/abouthotbar/whatis.htm"
		}
	}
	
	
////// Initalizing HotBar Functionality In Page ///////////////////////////
	function DrawHbObject(){
		if (typeof(HbCtl) == 'undefined') {
			if (isNS) {
				document.write("<EMBED type='application/x-hotbar-plugin' HEIGHT='0' WIDTH='0' NAME='hb'>");
				document.write("<EMBED type='application/x-hotbar-plugin2' HEIGHT='0' WIDTH='0' NAME='hb2'>");
			}
			if (isIE) {
				document.write("<" + "OBJECT ID='hb2' WIDTH=0 HEIGHT=0 CLASSID='CLSID:75D2080B-4857-4B96-9B7D-732634FBD01F'></OBJECT>");
				document.write("<" + "OBJECT ID='hb' WIDTH=0 HEIGHT=0 CLASSID='CLSID:60B25924-C865-11D2-B0C1-000000000000'></OBJECT>");
				document.write("<" + "OBJECT ID='HbBho' width=0 height=0 CLASSID='CLSID:B195B3B3-8A05-11D3-97A4-0004ACA6948E'></OBJECT>");
				
			}
			// Don't check for other browsers
			if (BrowserType != "OTHER") {
				InstallIfRequired('')
			}
			else {
				gotoOtherSection()
			}
		}
	}

	//Check If Hotbar Is Installed and set Version variables 
	function IsCtlInstalled() {
		if(isNS) {
			if (document.hb2) {
				HbCtl = document.hb2;
				CtlVer = 2;
				return true;
			}
			if (document.hb) {
				HbCtl = document.hb;
				CtlVer = 1;
				return true;
			}
		}
		if (isIE) {
			if ("undefined" != typeof(hb2.bValid)) {
				HbCtl = document.hb2;
				CtlVer = 2;
				return true;
			}
			if ("undefined" != typeof(hb.bValid) ) {
				HbCtl = document.hb;
				CtlVer = 1;
				return true;
			}
		}
		return false;
	}

	function DrawBox() {
		if (BrowserType != "OTHER") {
			document.write("<TABLE border=0 cellpadding=0 cellspacing=0 width='99' bgcolor='#FFFFCC'><tr><td width='99' colspan='3'><a href='http://hotbar.com' target='_new'><img src='http://hotbar.com/images/exhotbar/logo.gif' width='99' height='49' alt='Powered by Hotbar.com - Your Personal Dynamic Toolbar.' border='0'></a></td></tr>");
			document.write("<tr><td colspan=3 width='99'><img src='http://hotbar.com/images/exhotbar/skincontrol.gif' width='99' height='16' alt='Skin Control' border='0'></td></tr><tr>");
			document.write("<td width='34'><A HREF='#' onclick='LastSkin(); return false;'><img src='http://hotbar.com/images/exhotbar/last.gif' width='34' height='25' alt='Last Skin' border='0'></a></td>");
			document.write("<td width='32'><A HREF='#' onclick='ClearSkin(); return false;'><img src='http://hotbar.com/images/exhotbar/clear.gif' width='32' height='25' alt='Clear Skin' border='0'></a></td>");
			document.write("<td width='33'><A HREF='#' onclick='NextSkin(); return false;'><img src='http://hotbar.com/images/exhotbar/next.gif' width='33' height='25' alt='Next Skin' border='0'></a></td>");
			document.write("</tr></table>");
		}
		else {
			// This	is not a supported platform
			document.write("<table border='0' cellpadding=0 cellspacing=0><tr><td><a href='http://hotbar.com/site/abouthotbar/whatis.htm'><img src='http://hotbar.com/images/exhotbar/winonly.gif' width='99' height='84' alt='Hotbar supports only windows systems' border='0'></a></td></tr></table>");
		}
	}

	/// copy DATA from registry to cookie
	function getUI()  {
		if (GetCookie("ui") != HbCtl.GetHbr('UserInfo','UID')) {
			SetCookie("ui",HbCtl.GetHbr('UserInfo','UID'))
		}
		var sg = HbCtl.GetSampleGroup();
		if (GetCookie("sg") != sg) SetCookie("sg",sg);
		var Partner = HbCtl.GetHbr('options','PartnerCode');
		if (GetCookie("Partner") != Partner) SetCookie("Partner",Partner);
	}

/// HB Band/Main Navigate /////////////////////////////////////////////////
	function bandShow() {
		HbCtl.ShowHbBand(true)	
	}

	function bandNavigate(URL) {
		HbCtl.NavigateHbBand(URL)
	}

	function bandNavigatePost(URL,postData) {
		HbCtl.NavigateHbBand(URL,postData)
	}

	function mainNavigate(URL) {
		HbCtl.NavigateMain(URL)
	}

	function mainNavigatePost(URL,postData) {
		HbCtl.NavigateMain(URL,postData)
	}


/// SKIN CONTROL /////////////////////////////////////////////////////
	function LoadSkin(Skin) {
		var SkinUrl
		if (BrowserType != "OTHER") {
			if (Skin.indexOf(".bmp") == -1 && Skin.indexOf(".xip") == -1) {
				SkinUrl = "http://skins.hotbar.com/skins/xip/" + Skin.substring(0,4) + "/" + Skin + ".xip";
			}
			else {
				SkinUrl = Skin
			}
			if (InstallIfRequired(SkinUrl)) {
				if ((isNS && CtlVer==1) || (isIE && CtlVer==2)) {
					HbCtl.LoadSkin(SkinUrl);
				}
				else if((isNS && CtlVer==2)) {
					HbCtl.LoadSkin(SkinUrl,"");
				}
				else {
					window.open("http://hotbar.com/site/SkinLoad.htm?img=" + SkinUrl,"","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,width=220,height=200,left=40,top=100");
				}
			}
		}
		else {
			NsRedirAllow = 'true'
			gotoOtherSection()
		}
	}

	function LoadSkinRedir(SkinUrl,RedirUrl) {
		if (BrowserType != "OTHER") {
			if (InstallIfRequired('')) {
				LoadSkin(SkinUrl);
				widndow.location = RedirUrl;
			}
		}
		else {
			gotoOtherSection()
		}
	}

	function LastSkin()	{
		if (InstallIfRequired('')) {
			if (isNS || (isIE && CtlVer==2)) {
				HbCtl.LastSkin();
			}
			else {
				HbCtl.ExInitSession("http://skins.hotbar.com/skins/xip","");
				HbCtl.GoBack();
			}
			//return false;
		}
	}

	function NextSkin()	{
		if (InstallIfRequired('')) {
			if (isNS || (isIE && CtlVer==2)) {
				HbCtl.NextSkin();
			}
			else {
				HbCtl.ExInitSession("http://skins.hotbar.com/skins/xip","");
				HbCtl.Forward();
			}
			//return false;
		}
	}

	function ClearSkin() {
		if (InstallIfRequired('')) {
			if (isNS || (isIE && CtlVer==2)) {
				HbCtl.ClearSkin();
			}
			else {
				HbCtl.Clear();
			}
			//return false;
		}
	}

	function PrivateCollection() {
		if (InstallIfRequired('')) {
			if (isNS) {
				HbCtl.ShowSkinManager();
			}
			else {
				window.location = "http://" + VirtualDir + "site/local.htm";
			}
		}
	}

	function SendSkin(xip) {
		if (BrowserType != "OTHER") {
			if (InstallIfRequired('')) {
				url="http://" + VirtualDir + "site/sendexn.htm?Img=" + xip + "&Redir=" + NextUrl + "&Guide=" + Guide + "&Requestor=" + Requestor;
				var openWindowOptions = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,left=40,top=100'
				if (isIE) window.open(url,'SendSkin',openWindowOptions + ',width=500,height=500');
				if (isNS) window.open(url,'SendSkin',openWindowOptions + ',width=550,height=560');
			}
		}
		else {
			gotoOtherSection()
		}
	}
	

	function SendSkinPrv(xip,prv) {
		if (BrowserType != "OTHER") {
			if (InstallIfRequired('')) {
				url="http://" + VirtualDir + "site/thanks-v3.htm?snd=" + xip + "&prv=" + prv;
				document.location.href = url
			}
		}
		else {
			gotoOtherSection()
		}
	}

	/////////////////////////////////////
	function onDL() {
	}

	function nohref(){
	}

/// This is the actual running code //////////////////////////////////
	DrawHbObject()
		
	if (ShowBox == 'true') {
		DrawBox();
	}

	if ((HandleImgParam == 'true') && (img != '')) {
		if (InstallIfRequired(img)) {
			LoadSkin(img)
			location.replace(removeParamFromURL(window.document.location.href,'img'))
		}
	}

