var previous_img;

bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

if ((bName == "Netscape" && bVer >= 3) || 
(bName == "Microsoft Internet Explorer" && bVer >= 4)) br = "n3"; 
else br = "n2";

if (br== "n3") { 
bulleton = new Image(); 
bulleton.src = "/Images/qb/qb_left_nav_blue.gif";

bulletoff = new Image(); 
bulletoff.src = "/Images/qb/t.gif";
}

function imgAct(imgName) {
    if (br == "n3") {
    document[imgName].src = eval("bulleton.src");
    }
}

function imgInact(imgName) {
    if (br == "n3") {
    document[imgName].src = eval("bulletoff.src");
    }
}

function swapImageOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "_Off.src");
document[imgName].src = previous_img;
previous_img = "";
}
}

function swapImageOn(imgName) {
if (document.images) {
previous_img = document[imgName].src;
document[imgName].src = eval(imgName + "_On.src");
}
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

// v cluk - added to fix the problem of refresh the page
//var helpFrame = document.frames['helptopic_frame'];
//if (helpFrame)
//	helpFrame.location.reload();
// ^ cluk - added to fix the problem of refresh the page
}

if (document.images) {
qb_On = new Image(); qb_On.src = "/Images/qb/tab_qb_on2.gif"; qb_Off = new Image(); qb_Off.src = "/Images/qb/tab_qb_off2.gif";
products_On = new Image(); products_On.src = "/Images/qb/tab_products_on2.gif"; products_Off = new Image(); products_Off.src = "/Images/qb/tab_products_off2.gif";
about_On = new Image(); about_On.src = "/Images/qb/tab_about_on2.gif"; about_Off = new Image(); about_Off.src = "/Images/qb/tab_about_off2.gif";
upgrades_On = new Image(); upgrades_On.src = "/Images/qb/tab_upgrades_on2.gif"; upgrades_Off = new Image(); upgrades_Off.src = "/Images/qb/tab_upgrades_off2.gif";
support_On = new Image(); support_On.src = "/Images/qb/tab_support_on2.gif"; support_Off = new Image(); support_Off.src = "/Images/qb/tab_support_off2.gif";
training_On = new Image(); training_On.src = "/Images/qb/tab_training_on2.gif"; training_Off = new Image(); training_Off.src = "/Images/qb/tab_training_off2.gif";
community_On = new Image(); community_On.src = "/Images/qb/tab_community_on2.gif"; community_Off = new Image(); community_Off.src = "/Images/qb/tab_community_off2.gif";
}

function popTour(tourFile,tourWidth,tourHeight,tourDir) {

	var tourFile = tourFile.toLowerCase();

	if ((tourWidth == null) || (tourWidth == "")) { tourWidth = 770; }
	if ((tourHeight == null) || (tourHeight == "")) { tourHeight = 510; }
	if ((tourDir == null) || (tourDir == "")) { tourDir = "/tour/quickbooks/2005/"; }

	/* Non-Toolhouse tours that require the JHTML viewer */
	if ((tourFile == "customer_mgr_1") || (tourFile == "customer_mgr_2") || (tourFile == "customer_mgr_3") || (tourFile == "customer_mgr_4") ||

	/* Legacy tours that require the JHTML viewer */
		(tourFile == "41-cor-s3s") || (tourFile == "41-ole-f1s") || (tourFile == "41-ole-f3s") || (tourFile == "bs") || (tourFile == "ccs") || (tourFile == "pos")) {
		tourWindow = "/tour/popup_tour.jhtml?tourFile="+tourFile;
		}

	/* New User Interview needs a special JHTML file to pass the priorityCode throughout the Flash file */
	else if (tourFile == "51-nui-t1") {
		tourWindow = "/tour/quickbooks/2005/51-nui-t1.jhtml";
		}

	/* Non-standard new tour that requires its own file set */
	else if (tourFile == "qb_bs") {
		tourWindow = "/tour/quickbooks/2005/qb_bs/movies/qbbs.html";
		}

	/* Oddball legacy tour that requires its own file set */
	else {
		tourWindow = tourDir+tourFile+".html";
		}

	var positionX = (screen.availWidth - tourWidth) / 2;
	var positionY = (screen.availHeight - tourHeight) / 2;

	if (tourFile.length > 0) {
		window.open(tourWindow,"QuickBooks_Tour","width=" + tourWidth + ",height=" + tourHeight + ",left=" + positionX + ",top=" + positionY + ",directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
	}

}

function popWin(URL, Width, Height, Resizable, Scrollbars) {

	if ((Width == null) || (Width == "")) { Width = 570; }
	if ((Height == null) || (Height == "")) { Height = 340; }
	if ((Resizable == null) || (Resizable == "")) { Resizable = "no"; }
	if ((Scrollbars == null) || (Scrollbars == "")) { Scrollbars = "no"; }

	var positionX = (screen.availWidth - Width) / 2;
	var positionY = (screen.availHeight - Height) / 2;

	Day = new Date();
	WindowName = Day.getTime();

	window.open(URL,WindowName,"width=" + Width + ",height=" + Height + ",left=" + positionX + ",top=" + positionY + ",channelmode=0,dependent=0,directories=0,location=0,menubar=0,resizable=" + Resizable + ",scrollbars=" + Scrollbars + ",status=0,toolbar=0");
}

function getgoing(targetPage) {
	window.location=targetPage;
}

// v cluk - added for resize the iframe for Help topic
function resizeThisFrame(frameId, x, y)
{
	var obj = document.getElementById(frameId);
	if (obj == null) 
		return;

	if (y > 0)
		obj.style.height = y + 20 + 'px';
	
	if (x > 0)
		obj.style.width = x + 20 + 'px';
}
// ^ cluk - added for resize the iframe for Help topic


// cookies
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function Show_Stuff(Click_MenuOn,Click_MenuOff)
{
	if (Click_MenuOn.style.display == "none") {
		Click_MenuOn.style.display = "";
		Click_MenuOff.style.display = "none";
	}
	else {
		Click_MenuOn.style.display = "none";
		Click_MenuOff.style.display = "";
	}
};

function checkBoxCookie(disp,opt1,opt2) {
		var isBox = readCookie('resourceBoxCookie');
		if (isBox == 1) {
			document.write('<span ID="' + disp + '" style="display:' + opt1 + '">');
		}
		else {
			document.write('<span ID="' + disp + '" style="display:' + opt2 + '">');
		}
};

function loadingStatus2( whichForm ) {
	s = document[whichForm].which;
	if ( s.options[s.selectedIndex].value != "" )  {
		window.location.href = s.options[s.selectedIndex].value;
	}
};

function loadingStatusPop( whichForm ) {
	s = document[whichForm].which;
	if ( s.options[s.selectedIndex].value != "" )  {
		popWin(s.options[s.selectedIndex].value,770,520,'no','no');
	}
};

function loadingStatusNew( whichForm ) {
	s = document.getElementById(whichForm);
	z = s.options[s.selectedIndex].value;
	alert(z);
if ( s.options[s.selectedIndex].value != "" )  {
_hbLink(hbxStrip(s.options[s.selectedIndex].text), whichForm, "10, 150, 150, 20");
s[s.length] = new Option('Loading...', s[s.selectedIndex].value);
s[s.length-1].selected=1;
window.location.href = s.options[s.selectedIndex].value;
}
}

function hbxStrip(a)
{
     a = a.split("|").join("");
     a = a.split("&").join("");
     a = a.split("'").join("");
     a = a.split("#").join("");
     a = a.split("$").join("");
     a = a.split("%").join("");
     a = a.split("^").join("");
     a = a.split("*").join("");
     a = a.split(":").join("");
     a = a.split("!").join("");
     a = a.split("<").join("");
     a = a.split(">").join("");
     a = a.split("~").join("");
     a = a.split(";").join("");
     a = a.split(" ").join("+");
     return a;
};

// ------------------ new dropdown menu select ----------------------  
function changeLocation(menuObj) {
	var i = menuObj.selectedIndex;
	if(i > 0) {
		window.location = menuObj.options[i].value;
	}
}
