//<![CDATA[

// Copyright 2007 Intuit
// Author: Matthew Gisonno
// Last Revision: 01/24/2007

/* This is logic for IE6 only and will cache the background images for CSS rollover effects, other browsers are already smart */
(function(){

	/*Use Object Detection to detect IE6*/
	var  m = document.uniqueID /*IE*/
	&& document.compatMode  /*>=IE6*/
	&& !window.XMLHttpRequest /*<=IE6*/
	&& document.execCommand ;
	
	try{
		if(!!m){
			m("BackgroundImageCache", false, true) /* = IE6 only */ 
		}
		
	}catch(oh){};
})();

$(document).ready(function(){
	$("a.tabClick").mouseover(function(){
		$(this).css("backgroundPosition","right top");
		$(this).parent("li").css("backgroundPosition","left top");
		$("li#currenttabnav").css("backgroundPosition","left top");
		$("li#currenttabnav").children("a").css("backgroundPosition","right top");
	});
	
	$("a.tabClick").mouseout(function(){
		$(this).css("backgroundPosition","right bottom");
		$(this).parent("li").css("backgroundPosition","left bottom");
		$("li#currenttabnav").css("backgroundPosition","left top");
		$("li#currenttabnav").children("a").css("backgroundPosition","right top");
	});
	
	$("a.tabClick").parent("li").mouseover(function(){
		$(this).css("backgroundPosition","left top").css("cursor","pointer");
		$(this).children("a").css("backgroundPosition","right top").css("color","#000");
		$("li#currenttabnav").css("backgroundPosition","left top");
		$("li#currenttabnav").children("a").css("backgroundPosition","right top").css("color","#000");
	});
	
	$("a.tabClick").parent("li").mouseout(function(){
		$(this).css("backgroundPosition","left bottom").css("cursor","pointer");
		$(this).children("a").css("backgroundPosition","right bottom").css("color","#fff");
		$("li#currenttabnav").css("backgroundPosition","left top");
		$("li#currenttabnav").children("a").css("backgroundPosition","right top").css("color","#000");
	});
});

/* Function for opening popup windows */
function OpenT(name,childX,childY) {
	popupWin = window.open(name,'open_window',',status=0,resizable=0,scrollbars=0,width=' + childX + ',height=' + childY);
}

/* This sets a cookie when a link is clicked in the left navigation, breadcrumb and tabs.  Used to persist where you just clicked. */
function set_cookie(Name) {
document.cookie = "accountant.intuit.com=" + Name + '; path=/';
}


/* Bookmark the current page with the current pages document title and URL */
function bookmark(){
if (document.all)
window.external.AddFavorite(self.location, document.title);
else if (window.sidebar)
window.sidebar.addPanel(document.title, document.location, "")
}

/* Tooltip function for testdrive page */
function tooltip() {
if (document.getElementById('tooltip').style.display == "none")
	{
		document.getElementById('tooltip').style.display = "";
		document.getElementById('symbol').innerHTML = "<img src=\"/images/icons/minus.gif\" class=\"showstate\" onclick=\"tooltip();\" border=\"0\" />";
	}
else
	{
		document.getElementById('tooltip').style.display = "none";
		document.getElementById('symbol').innerHTML = "<img src=\"/images/icons/plus.gif\" class=\"showstate\" onclick=\"tooltip();\" border=\"0\" />";
	}
}


function pageSwitch(id){
var div = document.getElementById("page"+id);
if(div.style.display == "none")
	{
	div.style.display = "block";
	}
else
	{
	div.style.display = "none";
	}
}

function writeSEMPhone(){
document.write(SEMPhone)
}

//Functions for creating QB.com Links in XML files so they process on the client side, since XML process after the server side code has been ran.
function qbLink(qbURL,qbURLText) {
if (qbURL.indexOf("?") > 0)
	{
	document.write("<a href=\"" + qbURL + "&priorityCode=" + QBpCode + "\"" + ">" + qbURLText + "</a>")
	}
else
	{
	document.write("<a href=\"" + qbURL + "?priorityCode=" + QBpCode + "\"" + ">" + qbURLText + "</a>")
	}
}

function qbImageLink(qbURL,IMGLink,IMGAlt,Width,Height) {
if (qbURL.indexOf("?") > 0)
	{
	document.write("<a href=\"" + qbURL + "&priorityCode=" + QBpCode + "\"" + ">" + "<img src=\"" + IMGLink + "\"" + " alt=\"" + IMGAlt + "\"" + " width=\"" + Width + "\"" + " height=\"" + Height + "\"" + " />" + "</a>")
	}
else
	{
	document.write("<a href=\"" + qbURL + "?priorityCode=" + QBpCode + "\"" + ">" + "<img src=\"" + IMGLink + "\"" + " alt=\"" + IMGAlt + "\"" + " width=\"" + Width + "\"" + " height=\"" + Height + "\"" + " />" + "</a>")
	}
}

function qbButtonLink (qbURL,qbURLText,buttonClass) {
if (qbURL.indexOf("?") > 0)
	{
	document.write("<a href=\"" + qbURL + "&priorityCode=" + QBpCode + "\"" + " class=\"" + buttonClass + "\"" + ">" + qbURLText + "</a>")
	}
else
	{
	document.write("<a href=\"" + qbURL + "?priorityCode=" + QBpCode + "\"" + " class=\"" + buttonClass + "\"" + ">" + qbURLText + "</a>")
	}
}

//Functions for opening and shutting the Buy button popup for QB.com ECommerce
function openBuy() {
if (self.location.search == "?lid=openbutton")
	{
	document.getElementById("overlay").style.display = "block";
	document.getElementById("qbBuyBox").style.display = "block";
	document.body.style.overflow = "hidden";
	}
}
function closeBuy() {
if (self.location.search == "?lid=closebutton")
	{
	document.getElementById("overlay").style.display = "none";
	document.getElementById("qbBuyBox").style.display = "none";
	document.body.style.overflow = "visible";
	}
}

/* This is for the colleagues > advisorycouncil05 app page  */
function validateForm(theForm){ if (theForm._fid_6.value == "") { alert("Please enter a value for the \" First Name\" field."); theForm._fid_6.focus(); return (false); } if (theForm._fid_7.value == "") { alert("Please enter a value for the \"Last Name\" field."); theForm._fid_7.focus(); return (false); } if (theForm._fid_8.value == "") { alert("Please enter a value for the \"Firm Name\" field."); theForm._fid_8.focus(); return (false); } if (theForm._fid_9.value == "") { alert("Please enter a value for the \"Street Address\" field."); theForm._fid_9.focus(); return (false); } if (theForm._fid_10.value == "") { alert("Please enter a value for the \"City\" field."); theForm._fid_10.focus(); return (false); } if (theForm._fid_11.value == "") { alert("Please enter a value for the \"State\" field."); theForm._fid_11.focus(); return (false); } if (theForm._fid_12.value == "") { alert("Please enter a value for the \"Zip Code\" field."); theForm._fid_12.focus(); return (false); } if (theForm._fid_13.value == "") { alert("Please enter a value for the \"Work Phone\" field."); theForm._fid_13.focus(); return (false); }
if (theForm._fid_14.value == "") { alert("Please enter a value for the \"E-mail address\" field."); theForm._fid_14.focus(); return (false); } 
}

/*This is a function to allow you to make multiple selections within a form field*/
function multiQuickBase(id)
{
	// Create an Array to store the values
	var selectedOptions = new Array();
	// Loop through the selected elements and pass them to the Array
	for(var i=0;i<document.getElementById('multiquick' + id).options.length;i++)
		// If the item is selected...
		if(document.getElementById('multiquick' + id).options[i].selected)
			{
			// ...Lets pass it to the Array
			selectedOptions[selectedOptions.length] = " " + document.getElementById('multiquick' + id).options[i].value;
			}
	// Pass Array value to hidden text box for submit to QuickBase
	document.getElementById('multiquicktemp' + id).value = selectedOptions;
}

/*This is a function to allow you to limit the number of multiple selections within a form field*/
function multiCheckNum(id)
{
   // Initialize the counter
   var Counter = 0;
   // Loop through the select box to see how many are selected
   for (i=0; i<document.getElementById('multiquick' + id).options.length; i++)
   {
      // If an element is selected, increment the counter
      if (document.getElementById('multiquick' + id).options[i].selected == true)
	  {
         Counter++;
      }
   }
   // If the counter is greater than 3, display an alert message.
   if (Counter > 3)
   {
      alert("You have selected more than 3 values.  Please un-select the extra item(s) by holding the Ctrl key and clicking the un-wanted item(s).");
      return false;
   }
}

//]]>
