onerror=unhandledException;

try
{
	var bSecure = false;
	var strURL = window.location.href.toString().toLowerCase(); 
	var strPage = window.location.pathname.toString().toLowerCase();
	strPage = strPage.substring(strPage.lastIndexOf("/")+1);
	if(SECUREPAGES.indexOf("|"+strPage+"|")>-1){bSecure=true;}
	if(bSecure&&strURL.indexOf("http://")==0)
	{
		 window.location.href=strURL.replace("http://","https://");
	}  
	else if(!bSecure&&strURL.indexOf("https://")==0)
	{
		 window.location.href=strURL.replace("https://","http://");
	}
}
catch(ex){/**/}
/* END SECURE/NON-SECURE PAGE HANDLING */


/* BEGIN AFFILIATE TRACKING */
	document.cookie = 'TCAffReferrer=' + document.referrer + '; path=/';
/* END AFFILIATE TRACKING */

/* BEGIN LIVE CHAT */
function loadLiveChat() {/**/}
/* END LIVE CHAT */

/* BEGIN UPDATE CART QTY */
function updateCartQtyDisplay()
{
    try { returnObj("spanCartItemQty").obj.innerHTML = (readCookie("CartItemQty") == "" || readCookie("CartItemQty") == null) ? "0" : readCookie("CartItemQty"); } catch (ex) { /*carry on*/ }
    try { returnObj("shopping_cart_items_inner").obj.innerHTML = (readCookie("CartItemQty") == "" || readCookie("CartItemQty") == null) ? "0" : readCookie("CartItemQty"); } catch (ex) { /*carry on*/ }
}
/* END UPDATE CART QTY */

/* BEGIN OBJECT FUNCTIONS */
function getObj(name)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}

function returnObj(name)
{
	try
	{
		if (document.getElementById)
		{
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
		}
		else if (document.all)
		{
			this.obj = document.all[name];
			this.style = document.all[name].style;
		}
		else if (document.layers)
		{
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
		return this;
	}
	catch(err)
	{
		return false;
	} 
}
/* END OBJECT FUNCTIONS */



/* BEGIN DISPLAY FUNCTIONS */
function showHide(id, method)
{
	if(method == "hide")
	{
		returnObj(id).style.display="none";
	}
	else/*show*/
	{
		returnObj(id).style.display="";
	}
}

var lastModal = 0;

function showHideModal() {
	var method = (arguments[0]) ? arguments[0] : "show";
	var message = (arguments[1]) ? arguments[1] : "Processing";
	var isClosable = (arguments[2]) ? arguments[2] : "false";
	var hideTimer = (arguments[3]) ? arguments[3] : 0;
	var hideModal = (arguments[4]) ? arguments[4] : lastModal;
	var onHide = (arguments[5]) ? arguments[5] : "";

	if (method == "hide") {
	    if (hideModal == lastModal) {
	        returnObj("divModalBG").style.display = "none";
	        returnObj("divModalMsg").style.display = "none";
	        returnObj("divModalMsg_wrapper").style.display = "none";

	        if (window["onHide_" + hideModal]) {
	            window["onHide_" + hideModal]();
	        }
	    }
	}
	else /*show*/
	{
	    lastModal++;
	    var tempHideModal = lastModal;

		returnObj("divModalBG").style.height = returnObj("divMain").obj.offsetHeight + "px";
		returnObj("divModalBG").style.display = "block";
		returnObj("divModalMsg").obj.innerHTML = ((isClosable == "true") ? "<a id=\"modalClose\">x</a>" : "") + message;
		returnObj("divModalMsg").style.display = "block";
		returnObj("divModalMsg_wrapper").style.display = "block";
		window.scrollTo(0, 0);
		if (hideTimer > 0) {
		    setTimeout(function () { showHideModal("hide", "", "", 0, tempHideModal); }, hideTimer);
		}

		if (onHide != "") {
		    window["onHide_" + tempHideModal] = Function(onHide);
        }
	}
}

function showHideModalBG(method)
{
	if(method=="hide")
	{ 
		returnObj("divModalBG").style.display="none";
	}
	else /*show*/
	{
		returnObj("divModalBG").style.height=returnObj("divMain").obj.offsetHeight + "px";
		returnObj("divModalBG").style.display="block";
	}
}
 /* FOLLOWING FOR MOUSEOVER DIV */
function myMouseOut(e) 
{ 
	try
	{
		if (!e) var e = window.event;
		var tg = (window.event) ? e.srcElement : e.target;
		if (tg.nodeName != 'DIV') return;
		var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
		while (reltg != tg && reltg.nodeName != 'BODY')
			reltg= reltg.parentNode;
		if (reltg!= tg){
		 returnObj('divEventPop').style.display = "none";
		}
	 }
	 catch(ex){ /* carry on, people moving mouse way too fast */ }
}
/* END DISPLAY FUNCTIONS */



/* BEGIN COOKIE FUNCTIONS */
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);
}
/* END COOKIE FUNCTIONS */



/* BEGIN EVENT FUNCTIONS */
function enterKeyClick(e,btnID)
{
	try
	{ 
		if(!e){var e = window.event;}
		if(e.keyCode){code = e.keyCode;}
		else if(e.which){code = e.which;}
		e.cancelBubble = true;
		if (e.stopPropagation){e.stopPropagation();}
		if(code==13)
		{
			returnObj(btnID).obj.click();
		}
		return false;
	}
	catch(ex){/*carry on*/}
}
/* END EVENT FUNCTIONS */



/* BEGIN HIDDEN INPUT FUNCTIONS */
function updateHiddenText(id,hid){returnObj(hid).obj.value=returnObj(id).obj.value;}
function updateHiddenSelect(id,hid){returnObj(hid).obj.value=returnObj(id).obj.options[returnObj(id).obj.options.selectedIndex].value;}
/* END HIDDEN INPUT FUNCTIONS*/

/* BEGIN STRING FUNCTIONS */
function InStr(strSearched, strSearchFor)
{
	for (i=0; i < (Len(strSearched)-Len(strSearchFor)+1); i++)
	{
		if (strSearchFor == Mid(strSearched, i, Len(strSearchFor)))
		{
			return i;
		}
	}
	return -1;
}

function Mid(str, start, len)
{
	if (start < 0 || len < 0) {return ""};
	var iEnd, iLen = String(str).length;
	if (start + len > iLen)
	{ 
		iEnd = iLen;
	}        
	else
	{ 
		iEnd = start + len;
	}
	return String(str).substring(start,iEnd);
}

function Left(str, n)
{
	if (n <= 0)
	{
		return "";
	}
	else if (n > String(str).length)
	{ 
		return str;
	}
	else
	{ 
		return String(str).substring(0,n);
	}
}

function Right(str, n)
{
	if (n <= 0)
	{ 
		return "";
	}
	else if (n > String(str).length)
	{ 
		return str;
	} 
	else
	{
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}

function Len(str)
{
	return String(str).length; 
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function Trim(str)
{
	return str.replace(/^\s+/, "").replace(/\s+$/, "");
}

function StringBuilder(value)
{
	this.strings = new Array("");
	this.append(value);
}

/* Appends the given value to the end of this instance. */

StringBuilder.prototype.append = function (value)
{
	if (value)
	{
		this.strings.push(value);
	}
}

/* Clears the string buffer */

StringBuilder.prototype.clear = function ()
{
	this.strings.length = 1;
}

/* Converts this instance to a String. */

StringBuilder.prototype.toString = function ()
{
	return this.strings.join("");
} 

function getPageName()
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	sPage = sPage.substring(0, sPage.length - 5);
	return sPage; 
 }
/* END STRING FUNCTIONS */


/* BEGIN SEARCH FUNCTION */
function goSearch(searchTerm) {
    var q = trim(searchTerm).replace("'", "").replace("&", "%26");
    if (q != "search by team, artist or venue" && q != "") {
	    location.href = "/search.html?q=" + q;
	}
}
/* END SEARCH FUNCTION */

/* BEGIN ERROR FUNCTIONS */
function getDebugInfo()
{
	var strInfo = "<b>DEBUG INFO:</b><br />";
	try
	{  
		try{strInfo = strInfo + "<b>page:</b> " + location.href + "<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>URL:</b> " + document.URL + "<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>title:</b> " + document.title + "<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>referrer:</b> " + document.referrer + "<br />";}catch(ex){/**/}
		
		try{strInfo = strInfo + "<b>platform:</b> "+navigator.platform+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>appCodeName:</b> "+navigator.appCodeName+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>appName:</b> "+navigator.appName+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>appVersion:</b> "+navigator.appVersion+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>appMinorVersion:</b> "+navigator.appMinorVersion+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>userAgent:</b> "+navigator.userAgent+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>browserLanguage:</b> "+navigator.browserLanguage+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>systemLanguage:</b> "+navigator.systemLanguage+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>userLanguage:</b> "+navigator.userLanguage+"<br />";}catch(ex){/**/}
		try{strInfo = strInfo + "<b>cpuClass:</b> "+navigator.cpuClass+"<br />";}catch(ex){/**/}
	}
	catch(exx){strInfo=strInfo+"...couldn't retrieve all debug info<br />";}
	strInfo = strInfo + "<hr />";
	strInfo = strInfo + getCookieInfo() + getFormInfo(); 
	return strInfo; 
}

function getExceptionInfo(ex)
{
	var strException = "<b>JAVASCRIPT EXCEPTION:</b><br />";
	try
	{  
		try{strException = strException + "<b>name:</b>" + ex.name + "<br /><b>message:</b>" + ex.message + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>description:</b>" + ex.description + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>number:</b>" + ex.number + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>fileName:</b>" + ex.fileName + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>lineNumber:</b>" + ex.lineNumber + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>stack:</b>" + ex.stack + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>toSource:</b>" + escape(ex.toSource) + "<br />";}catch(e){/**/}
		try{strException = strException + "<b>toString:</b>" + ex.toString() + "<br />";}catch(e){/**/}
	}
	catch(exx){strException=strException+"...couldn't retrieve all exception info<br />";} 
	return strException;
}

function unhandledException(msg,url,line) {
    if (msg.indexOf("rfhelper32.js ") < 0){
	    var strInfo = "<b>Message:</b> "+msg+"<br /><b>URL:</b> "+url+"<br /><b>Line Number:</b> "+line + "<hr />";
	    var eventInfo = "";
	    try {eventInfo = windowAlert(arguments[0]);}catch(ex){/**/}
	    var strParams = "strErrorMsg=" + strInfo.replace("&", "%26") + getDebugInfo().replace("&", "%26")+ eventInfo + "<br /><hr />" +stackTrace(arguments.callee)+"&strSubject=JS_UNHANDLED-EXCEPTION&bIsHtmlMsg=true";
	    ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);
    }
}
function windowAlert(errorEvent)
{
	var windowInfo = "";
	try {windowInfo = windowInfo + "<b>EventType: </b>" + errorEvent.type != 'undefined' ? errorEvent.type+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventTarget: </b>" + errorEvent.target != 'undefined' ? errorEvent.target+ "<br />": '' } catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventCurTarget: </b>" + errorEvent.currentTarget !='undefined' ? errorEvent.currentTarget+ "<br />": '' } catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventTimeStamp: </b>" + errorEvent.timeStamp != 'undefined' ? errorEvent.timeStamp+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventButton: </b>" + errorEvent.button != 'undefined' ? errorEvent.button+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventRelatedTarget: </b>" + errorEvent.relatedTarget != 'undefined' ? errorEvent.relatedTarget+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventAlt: </b>" + errorEvent.altKey != 'undefined' ? errorEvent.altKey+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventCtrl: </b>" + errorEvent.ctrlKey != 'undefined' ? errorEvent.ctrlKey+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventShift: </b>" + errorEvent.shiftKey != 'undefined' ? errorEvent.shiftKey+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventBubbles: </b>" + errorEvent.bubbles != 'undefined' ? errorEvent.bubbles+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventCancelable: </b>" + errorEvent.cancelable != 'undefined' ? errorEvent.cancelable+ "<br />": ''} catch(e){/**/}
	try {windowInfo = windowInfo + "<b>EventMetaKey: </b>" + errorEvent.metaKey != 'undefined' ? errorEvent.metaKey + "<br />": ''} catch(e){/**/}
	return windowInfo;
}
function getFormInfo()
{
	var strInfo = "<b>FORM FIELDS:</b><br />";
	for(n in document.forms[0].elements)
	{
		try
		{
			switch(document.forms[0].elements[n].type)
			{
				case "text":
				case "hidden":
					if(document.forms[0].elements[n].id.toString().toUpperCase().indexOf("CVV")==-1) // do not log CVV info
					{
						if(document.forms[0].elements[n].id.toString().indexOf("txtCCNu")!=-1) // do not log CCNumber info
						{
							var masked = returnObj(document.forms[0].elements[n].id).obj.value.substr(returnObj(document.forms[0].elements[n].id).obj.value.length-4, returnObj(document.forms[0].elements[n].id).obj.value.length);
							if (masked != "")
							{
								strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> XXXXXXXXXXXX" + masked + "<br />";
							}
							else
							{
								strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> Saved CC Info used.<br />";
							}
						}
						else
						{
							strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + returnObj(document.forms[0].elements[n].id).obj.value + "<br />";
						}
					}
					break;
				case "radio":
					strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + returnObj(document.forms[0].elements[n].id).obj.value + " [" + returnObj(document.forms[0].elements[n].id).obj.checked + "]<br />";
					break;
				case "checkbox":
					strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + " [" + returnObj(document.forms[0].elements[n].id).obj.checked + "]<br />";
					break;
				case "select-one":
					strInfo = strInfo + "<b>" + document.forms[0].elements[n].id + ":</b> " + returnObj(document.forms[0].elements[n].id).obj.options[returnObj(document.forms[0].elements[n].id).obj.selectedIndex].text + "<br />";
					break;
			}
		}
		catch(ex){/*carry on*/}
	}
	return strInfo + "<hr />"; 
}

function getCookieInfo()
{
	var strInfo = "<b>COOKIE VALUES:</b><br />";
	var strCookies = document.cookie.split(";");   
	for(n in strCookies)
	{
		strInfo = strInfo + escape(strCookies[n]) + "<br />";
	}
	return strInfo + "<hr />"; 
}

//function printStackTrace() 
//{
//    var callstack = [];
//    var isCallstackPopulated = false;
//    try 
//    {
//        i.dont.exist+=0; //doesn't exist- that's the point
//    } 
//    catch(e) 
//    {
//        if (e.stack) 
//        { //Firefox
//            var lines = e.stack.split('\n');
//            for (var i=0, len=lines.length; i<len; i++) 
//            {
//                if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) 
//                {
//                    callstack.push(lines[i]);
//                }
//            }
//            //Remove call to printStackTrace()
//            callstack.shift();
//            isCallstackPopulated = true;
//        }
//        else if (window.opera && e.message) 
//        { //Opera
//            var lines = e.message.split('\n');
//            for (var i=0, len=lines.length; i<len; i++) 
//            {
//                if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) 
//                {
//                    var entry = lines[i];
//                    //Append next line also since it has the file info
//                    if (lines[i+1]) 
//                    {
//                        entry += ' at ' + lines[i+1];
//                        i++;
//                    }
//                    callstack.push(entry);
//                }
//            }
//            //Remove call to printStackTrace()
//            callstack.shift();
//            isCallstackPopulated = true;
//        }
//    }
//    if (!isCallstackPopulated) 
//    { //IE and Safari
//        var currentFunction = arguments.callee.caller;
//        while (currentFunction) 
//        {
//            var fn = currentFunction.toString();
//            var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf('')) || 'anonymous';
//            callstack.push(fname);
//            currentFunction = currentFunction.caller;
//        }
//    }
//    return callstack.join('\n\n');
//}

	function stackTrace(startingPoint)
	{
		var stackTraceMessage = "<b>STACK TRACE:</b> <br>\n";
		var nextCaller = startingPoint;
		while(nextCaller)
		{
			stackTraceMessage += getSignature(nextCaller) + "<br>\n";
			nextCaller = nextCaller.caller;
		}
		stackTraceMessage += "<br>\n\n";
		
		// return message
		return stackTraceMessage; 
	}
	
	function getSignature(theFunction)
	{
		var signature = getFunctionName(theFunction);
		signature += "(";
		for(var x=0; x<theFunction.arguments.length; x++)
		{
			// trim long arguments
			var nextArgument = theFunction.arguments[x];
			if(nextArgument.length > 30)
				nextArgument = nextArgument.substring(0, 30) + "...";
			
			// apend the next argument to the signature
			signature += "'" + nextArgument + "'"; 
			
			// comma seperator
			if(x < theFunction.arguments.length - 1)
				signature += ", ";
		}
		signature += ")";
		return signature;
	}
	
	function getFunctionName(theFunction)
	{
		// mozilla makes it easy. I love mozilla.
		if(theFunction.name)
		{
			return theFunction.name;
		}
		
		// try to parse the function name from the defintion
		var definition = theFunction.toString();
		var name = definition.substring(definition.indexOf('function') + 8,definition.indexOf('('));
		if(name)
			return name;

		// sometimes there won't be a function name 
		// like for dynamic functions
		return "anonymous";
	}

/* END ERROR FUNCTIONS */

/* BEGIN PAGE LOGGING */
function LogPageRequest()
{
	try
   { 
		getClick2C_ID();
		var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogPageRequest";
		var strParams = "RefURL="+URLencode(document.referrer)+"&ReqURL="+URLencode(document.URL);

		var strYahoo = "search.yahoo.com/";
		var strGoogle = ".google.com/search?";
		var strMSN = "search.msn.com";
		var strLive = "search.live.com";
				
		// ignore no referrar; Yahoo/Overture PPC; Google PPC
		if (document.referrer != ''&&window.location.href.indexOf("s_kwcid=")<0&&window.location.href.indexOf("ovcrn=")<0&&window.location.href.indexOf("gclid=")<0&&(document.referrer.indexOf(strYahoo) > 0 || document.referrer.indexOf(strGoogle) > 0 || document.referrer.indexOf(strMSN) > 0 || document.referrer.indexOf(strLive) > 0))
	   {
			strParams = strParams+"&SERef=TRUE";
		}
		else
		{
			strParams = strParams+"&SERef=FALSE";
		}

		ajaxPost(strParams,strServiceURL);
	}
   catch(e) {}
}

function URLencode(sStr)
{
	return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27');
}

/* END PAGE LOGGING */

/* BEGIN Click2 TRACKING DETECTION */
function getClick2C_ID()
{
   var strC2CampaignID = parseQueryString('BrCg'); 
   var strC2RecipientID = parseQueryString('BrRc');
   var strC2CustomerID = parseQueryString('BrCs'); 
  
   if(readCookie('c2cid')!='' && readCookie('c2cid')!=null) //cookie exists
   {
		if (strC2CampaignID != false) // it is in the querystring // 
		{
			if (readCookie('c2cid')!= strC2CampaignID)
			{
				eraseCookie('c2cid');
				createCookie('c2cid', strC2CampaignID);
			}
			else if (readCookie('c2rid')!= strC2RecipientID)
			{
				eraseCookie('c2rid'); 
				createCookie('c2rid', strC2RecipientID); 
			}
			else if (readCookie('c2custID')!=strC2CustomerID)
			{ 
				eraseCookie('c2custID');  
				createCookie('c2custID', strC2CustomerID);               
			} 
		 }
   }
   else
   {
		if(strC2CampaignID != false) //c2cid is in the qs
		{
			createCookie('c2cid', strC2CampaignID);
			createCookie('c2rid', strC2RecipientID); 
			createCookie('c2custID', strC2CustomerID);  
		}
   }     
}
/* END Click2 TRACKING DETECTION */


/* BEGIN EMAIL FORM FUNCTIONS */
function submitEmailForm(id)
{
	var strFormData = "";
	var n;
	var bPost = true;
	 
	var strInputs = returnObj("hidEF_"+id+"_text").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(1,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.value) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}
	
	strInputs = returnObj("hidEF_"+id+"_textarea").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(1,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.value) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}

	strInputs = returnObj("hidEF_"+id+"_select").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(2,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.options[returnObj(strInputs[n]).obj.selectedIndex].value) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}
	
	strInputs = returnObj("hidEF_"+id+"_checkbox").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(4,strInputs[n]))
			{
				strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.checked) + "::";
			}
			else
			{
				bPost = false;
			}
		}
	}

	strInputs = returnObj("hidEF_"+id+"_radio").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			if(validateEmailForm(3,strInputs[n]))
			{
				var rdos = getElementsByAttribute(document.documentElement,"input","name",strInputs[n]);
				for(var x = 0; x < rdos.length; x++)
				{
					if(rdos[x].checked)
					{
						strFormData = strFormData + strInputs[n] + "=" + escape(rdos[x].value) + "::";
					} 
				}
			}
			else
			{
				bPost = false;
			}
		}
	}
	
	strInputs = returnObj("hidEF_"+id+"_hidden").obj.value.split("|");
	if(strInputs.length>0&&strInputs[0]!="")
	{
		for(n in strInputs)
		{
			strFormData = strFormData + strInputs[n] + "=" + escape(returnObj(strInputs[n]).obj.value) + "::";
		}
	}
		
	if(bPost)
	{ 
		var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/EmailForm";
		var strParams = "ID="+id+"&FormData="+strFormData;

		ajaxPost(strParams,strServiceURL,"confirmEmailForm");
	}
	else
	{
		alert("There was a problem with your request!\n\nPlease fill out the form completely and try again.\n\n");
	}
}

function confirmEmailForm(xml)
{
	var bActiveX=true;
	if (document.implementation && document.implementation.createDocument)
	{
		bActiveX=false;
		xmlDoc = document.implementation.createDocument("", "", null);
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(xml,"text/xml");
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML(xml);
	}
	else
	{
		alert("Your browser is having problems with our website!\n\nPlease call us to resolve this issue.");
		return;
	}

	switch(xmlDoc.getElementsByTagName("EmailForm")[0].getAttribute("Status"))
	{
		case "0":
			returnObj("divEF_"+xmlDoc.getElementsByTagName("EmailForm")[0].getAttribute("ID")).style.display="none";
			returnObj("divEFC_"+xmlDoc.getElementsByTagName("EmailForm")[0].getAttribute("ID")).style.display="";
			break;
		default:
			alert("There was a problem with your request!\n\nPlease fill out the form completely and try again or call 1-800-521-9616 to speak with a representative.\n\n");
			break;
	}
}

function validateEmailForm(nType,id)
{
	switch(nType)
	{
		case 1: /* text, textarea */
			if(returnObj("validator-"+id))
			{
				if(returnObj(id).obj.value.search(returnObj("validator-"+id).obj.value)!=-1)
				{ 
					returnObj("validator-"+id+"-msg").style.display="none";
					return true;
				}
				else
				{
					returnObj("validator-"+id+"-msg").style.display="";
					return false;
				}
			}
			else
			{
				return true;
			}
			break;
		case 2: /* dropdown */
			if(returnObj("validator-"+id))
			{
				if(returnObj(id).obj.options[returnObj(id).obj.selectedIndex].value.search(returnObj("validator-"+id).obj.value)!=-1)
				{
					returnObj("validator-"+id+"-msg").style.display="none";
					return true;
				}
				else
				{
					returnObj("validator-"+id+"-msg").style.display="";
					return false;
				}
			}
			else
			{
				return true;
			}
			break;
		case 3: /* radio */
			/* only validates that something was selected */
			if(returnObj("validator-"+id))
			{
				var rdos = getElementsByAttribute(document.documentElement,"input","name",id);
				for(var x = 0; x < rdos.length; x++)
				{
					if(rdos[x].checked)
					{
						returnObj("validator-"+id+"-msg").style.display="none";
						return true;
					}
				}
				returnObj("validator-"+id+"-msg").style.display="";
				return false;
			}
			else
			{
				return true;
			}
			break;
		case 4: /* checkbox */
			/* only validates that the checkbox is selected */
			if(returnObj("validator-"+id))
			{
				if(returnObj(id).obj.checked)
				{
					returnObj("validator-"+id+"-msg").style.display="none";
					return true;
				}
				else
				{
					returnObj("validator-"+id+"-msg").style.display="";
					return false;
				}
			}
			else
			{
				return true;
			}
			break;
	}
	return true;
}

/* END EMAIL FORM FUNCTIONS */


/* BEGIN QUERYSTRING DETECTIION */
function parseQueryString( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
	return false;
  else
	return results[1];
} 

/* END QUERYSTRING DETECTION */

/* BEGIN ELEMENT FUNCTIONS */
function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue)
{
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		/*oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);*/
		oAttribute = oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}

document.getElementsByClassName = function(cl)
{
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++)
	{
		var classes = elem[i].className;
		if (myclass.test(classes)){retnode.push(elem[i]);}
	}
	return retnode;
}
/* END ELEMENT FUNCTIONS */


/* BEGIN POPUP FUNCTIONS */
function exitPop()
{
	try
	{
		switch(arguments[0])
		{
			case 0:
				window.onbeforeunload = null;
				break;
			case 1: /* newsletter signup */
				/* cmCreateConversionEventTag("Exit Checkout Try","2","Pop Up");
				window.open(location.protocol+"//"+location.hostname+"/email-updates.html?nst=2","emailupdates", "height=300, width=425, toolbar=no, location=no, resizeable=no, status=no, scrollbars=no, menubar=no");
				*/break;
		}
	}
	catch(ex){/*alert(ex.message);*/}
}
/* END POPUP FUNCTIONS */





/*temp place for sub menu and subheader functions*/
$(document).ready(function () {
    /*set up cachable variable for menu*/
    var submenu = $("#submenu");

    if (readCookie("lastShoppingPage") == null || readCookie("lastShoppingPage") == "") {
        createCookie("lastShoppingPage", "http://" + location.hostname + "/", 0);
    }

    $("#modalClose").live("click", function () {
        showHideModal("hide");
    });

    //show menu
    $("#tabMore").mouseenter(function (e) {
        submenu.show();
    });


    /*hide menu on mouse out*/
    submenu.mouseleave(function (e) {
        submenu.fadeOut();
    });

    /*add phone number*/
    var soldOutPhone = $('#divSoldOut .b').text();
    function updateSubHeadPhone() {
        $('#subhead_phone').text(soldOutPhone);
    }


    /*search with subheader*/
    var subsearch = $('#sub_search');
    $("#subhead_submit").click(function subSearch() {
        var subSearchString = subsearch.val();
        location.href = '/search.html?q=' + subSearchString;
    });

    /*allow user to just press enter*/
    subsearch.keydown(function (event) {
        var subSearchString = $('#sub_search').val();
        if (event.keyCode === 13) {
            $('#q').val(subSearchString);
            location.href = '/search.html?q=' + subSearchString;
        }
    });

    /*fire functions on doc. ready*/
    //updateSubHead();
    updateSubHeadPhone();
});


/*write content into TC guarantee modal*/
function writeModalContent(pageID, failPath, showTab) {
    var modalContentURL = "/ws/tcws.asmx/GetCMSContentBlockHTML?";
    var modalContentParams = "pPageID=" + pageID + "&pPageType=" + 1;
    
    showHideModal("show", guarantee_btn_modalContent);
    var modalNavTabItem = $('#modalLeftNav li');

    modalNavTabItem.removeClass('selectedModalNavTab');
    $(showTab).addClass('selectedModalNavTab');

    $.ajax({
        url: modalContentURL + modalContentParams,
        dataType: "xml",
        success: function (data) {
            $(data).each(function () {
                var modalString = $(this).text();
                $('#tcGuaranteeModal_inner').html(modalString);
            });
        },
        error: function () {
            window.open = failPath;
        }
    });
}


/*content skeleton*/
var modalLeftNav =
'<ul id="modalLeftNav">' +
    '<li id="modal_contactUsTab">Contact Us</li>' +
    '<li id="modal_guaranteeTab">Guarantee</li>' +
    '<li id="modal_faqTab">FAQ</li>' +
    '<li id="modal_buyTab">Buying Tickets</li>' +
'</ul>';

var guarantee_btn_modalContent =
'<a id="modalClose">x</a>' +
'<div id="tcGuaranteeModal_wrapper">' +
    modalLeftNav +
    '<div id="tcGuaranteeModal_inner"></div>' +
'</div>' +
'<div class="clearfixer"></div>';


/*in-page triggers*/
$("#guarantee").live("click", function() {
    writeModalContent(24, "/helpful-links/guarantee.html", "#modal_guaranteeTab");
});

$("#foot_guarantee").live("click", function () {
    writeModalContent(24, "/helpful-links/guarantee.html", "#modal_guaranteeTab");
});


/*event page triggers*/
$("#bvBox_buy").live("click", function () {
    writeModalContent(199778, "/helpful-links/faq.html", "#modal_buyTab");
});

$("#bvBox_faq").live("click", function () {
    writeModalContent(22, "/helpful-links/faq.html", "#modal_faqTab");
});

$("#bvBox_contact").live("click", function () {
    writeModalContent(21, "/helpful-links/contact-us.html", "#modal_contactUsTab");
});



/*in-modal triggers*/
$("#modal_guaranteeTab").live("click", function() {
    writeModalContent(24, "/helpful-links/guarantee.html", "#modal_guaranteeTab");
});

$("#modal_faqTab").live("click", function () {
    writeModalContent(22, "/helpful-links/faq.html", "#modal_faqTab");
});

$("#modal_aboutUsTab").live("click", function () {
    writeModalContent(23, "/helpful-links/guarantee.html", "#modal_aboutUsTab");
});

$("#modal_contactUsTab").live("click", function () {
    writeModalContent(21, "/helpful-links/contact-us.html", "#modal_contactUsTab");
});

$("#modal_buyTab").live("click", function () {
    writeModalContent(199778, "/helpful-links/contact-us.html", "#modal_buyTab");
});


/*cms accordion*/
$(document).ready(function () {
    //move this to config.js when ready
    var accordionIsEnabled = "true";
    if (accordionIsEnabled == "true") {
        var $extendedAccordionContent = $('.cms_accordian_group_content_extended');
        var $accordionContentGroup = $('.cms_accordian_content_group');
        var $accordionGroupHeader = $('.cms_accordian_group_header');

        $extendedAccordionContent.first().show();
        $accordionContentGroup.first().addClass('cms_selected_accordian_group');

        $accordionGroupHeader.click(function () {
            $extendedAccordionContent.hide();
            $accordionContentGroup.removeClass('cms_selected_accordian_group');
            $(this).parent().addClass('cms_selected_accordian_group');
            $(this).siblings().last().animate({
                height: 'toggle',
                opacity: 'toggle'
            }, "fast");
        });
    }
});/*allows use of containsExact*/
$.extend($.expr[':'], {
    containsExact: function (a, i, m) {
        return $.trim(a.innerHTML.toLowerCase()) === m[3].toLowerCase();
    }
});

$(document).ready(function () {
    if (window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase() == "CHECKOUT.HTML") {
        if (window.location.search == "?cv=s") {
            cartView("LOGIN");
        }
        else {
            cartView("ITEMS");
        }

        $('.continue_shopping').live("click", function () {
            cmCreateConversionEventTag("Continue Shopping", "2", "Cart");
            window.location.href = readCookie("lastShoppingPage");
        });

        $('.back_button').live("click", function () {
            cmCreateConversionEventTag("Back Button", "2", "Cart");
            cartView("ITEMSBACK");
        });

        $('.modify_order').live("click", function () {
            cmCreateConversionEventTag("Modify Order", "2", "Cart");
            cartView("ITEMSBACK");
        });

        $('#cart_proceed').live("click", function () {
            cartView("LOGIN");
        });

        $('#login_proceed').click(function () {
            continueConnect();
        });

        /*expand and contract terms and conditions text area*/
        $('#toc_contract').hide();

        $('#toc_expand').click(function () {
            $('.terms_and_conditions').animate({ height: '100%' });
            $('#toc_expand').hide();
            $('#toc_contract').show();
        });

        $('#toc_contract').click(function () {
            $('.terms_and_conditions').animate({ height: '120px' });
            $('#toc_contract').hide();
            $('#toc_expand').show();
        });

        $('#divCartContactInfo .formLabel').append('<span class="red">*</span>');
        $('.newCardLabel').append('<span class="red">*</span>');
    }

    var cvvLink = "<span>What's this?</span>";
    var cvvText1 = '<div class="cvvText"><div class="cardType_lable">Visa, Mastercard and Discover</div> use a 3 digit number which is located on the back of your card.</div>';
    var cvvImage1 = '<img src="/site-images/global/refresh_images/visaCVV.jpg" /><div class="clear_fixer"></div>';
    var cvvText2 = '<div class="cvvText"><div class="cardType_lable">American Express</div> uses a 4 digit number which is located on the front of your card.<span id="cvvCloser">close</span></div>';
    var cvvImage2 = '<img src="/site-images/global/refresh_images/amexCVV.jpg" />';
    var $cvvExplainer = $('#cvvExplainer');

    var cvvExplainer1 = '<div id="cvvExplainer"><h6>Finding your CVV number</h6>' + cvvText1 + cvvImage1 + '<br />' + cvvText2 + cvvImage2 + '</div>';
    /*
    var cvvExplainer2 = '<div id="cvvExplainer">' + cvvText2 + cvvImage2 + '</div>';
    */

    function hideCVVExp() {
        $('#cvvExplainer').fadeOut();
        $('#cvvExplainer').remove();
    }

    $('.cvv_whatsthis').html(cvvLink);

    $('.cvv_whatsthis').click(function () {
        hideCVVExp();
        $(this).append(cvvExplainer1);
    });

    $('#cvvExplainer').live('click', function () {
        hideCVVExp();
    });

    $('.tblCC .cvv_input').focus(function () {
        hideCVVExp();
        $(this).siblings().first().append(cvvExplainer1);
        var destination = $('#payment_tos_wrapper').offset().top;
        $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination - 40 }, 0);
    });


    $('.newCardData .cvv_input').focus(function () {
        hideCVVExp();
        $(this).siblings().first().append(cvvExplainer1);
    });

    $('.cvv_input').blur(function () {
        hideCVVExp();
    });


    /*jump exp. date to current month*/
    var date = new Date();
    var m = date.getMonth() + 1;
    $("#selectCCMonth option").removeAttr("selected");
    $("#selectCCMonth option:containsExact('" + m + "')").attr('selected', 'selected');

});

var cartProgressIndex = 2;
function updateCartProgressBar(){
	var direction = (arguments[0]) ? arguments[0] : ">";
	if(direction == ">"){
		$("#moving_arrow").animate({
			backgroundPositionX: '+=176px'
		});
		$('#linum'+cartProgressIndex).addClass('activated_li');
		cartProgressIndex++;
	}
	else{
		cartProgressIndex--;
		$("#moving_arrow").animate({
			backgroundPositionX: '-=176px'
		});
		$('#linum'+cartProgressIndex).removeClass('activated_li');
		
	}

}

function cartView() {
    window.scrollTo(0, 0);

	var direction = (arguments[1]) ? arguments[1] : ">";
	switch (arguments[0]) {
        case "ITEMSBACK":
	        updateCartProgressBar("<");
	        updateCartProgressBar("<");

	        $('#divCartContactInfo').hide();
	        $('#payment_tos_wrapper').hide();
	        $('#login_wrapper').hide();
	        $('#divTicketDisclosure').hide();
	        $('#divCartSummary').hide();

	        $('#cart_head').show();
	        $('#divCartDetails_Items').show();
	        $('#divCartDetails_Notifications').show();
	        $('#divCartDetails_Charges').show();
	        break;

	    case "ITEMS":
	        $('#divCartContactInfo').hide();
	        $('#payment_tos_wrapper').hide();
	        $('#login_wrapper').hide();
	        $('#divTicketDisclosure').hide();
	        $('#divCartSummary').hide();

	        $('#cart_head').show();
	        $('#divCartDetails_Items').show();
	        $('#divCartDetails_Notifications').show();
	        $('#divCartDetails_Charges').show();
	        break;

		case "LOGIN":
			/* duped hides from ITEMS, for page refresh login scenario */
			$('#divCartContactInfo').hide();
			$('#payment_tos_wrapper').hide();
			$('#login_wrapper').hide();
			$('#divTicketDisclosure').hide();
			$('#divCartSummary').hide();

			try { showHideModal("hide"); } catch (ex) { /**/ }
			updateCartProgressBar(direction);
			var bSkipLogin = false;
			try {
				if (readCookie("CustomerID") > 0 && readCookie("CustomerEmail") != "") {
					bSkipLogin = true;
					cartView("SUBMIT");
				}
			} catch (ex) { /**/ }

			if(direction==">"){
				// hide ITEMS view
				$('#cart_head').hide();
				$('#divCartDetails_Items').hide();
				$('#divCartDetails_Notifications').hide();
				$('#divCartDetails_Charges').hide();
			}
			else{
				// hide SUBMIT view
				$('#divCartContactInfo').hide();
				$('#payment_tos_wrapper').hide();
				$('#divTicketDisclosure').hide();
			}

			if (!bSkipLogin) {
				try {
					if (readCookie("CustomerID") > 0 && readCookie("CustomerEmail") != "") {
						returnObj("txtLoginEmail").obj.value = readCookie("CustomerEmail");
						returnObj("divAccountLogin").style.display = "";
						returnObj("spanPassLater").style.display = "";
						returnObj("rdoReturnCustomer").obj.checked = true;
						returnObj("divNewAccount").style.display = "none";
						returnObj("divJoinEmail").style.display = "none";
					}
					$('#login_wrapper').fadeIn(); 
				}
				catch (ex) { /**/ }
			}
			break;

		case "SUBMIT":
			updateCartProgressBar(direction);
			$('#login_wrapper').hide();
			returnObj("divAccountLogout").style.display = "";
			returnObj("tdLoggedIn").obj.innerHTML = "<span style=\"color:#008800;\">" + readCookie("CustomerEmail") + "</span>";
			$('#divCartContactInfo').fadeIn();
			$('#payment_tos_wrapper').fadeIn();
			$('#divTicketDisclosure').fadeIn();
			$('#divCartSummary').fadeIn();
			break;
	}
}

if(!returnObj("jsAccountInfo"))
{
	document.write("<scr"+"ipt type=\"text/javascript\" id=\"jsAccountInfo\" src=\"/js/accountInfo.js\"></scr"+"ipt>");
}

function openCheckout() {
	window.location.href = "https://" + location.hostname + "/checkout.html";
}

function openCart()
{
	var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/GetShoppingCart";

	var nBrokerID = readCookie("BrokerID");
	var strSessionID = readCookie("SessionGUID");
	var nShippingType = readCookie("ShippingType");
	var nCustomerID = readCookie("CustomerID");
	var strDiscountCode = readCookie("DiscountCode");
	var strGiftCardNum = readCookie("GiftCardNum");
	var strGiftCardAmt = readCookie("GiftCardAmt");
	var bTransform = "true";
	var nTransformType = 0;
	if(window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase()=="CHECKOUT.HTML")
	{
			nTransformType = 1;
	} 

	var strParams = "BrokerID="+nBrokerID+"&SessionID="+strSessionID+"&ShippingType="+nShippingType+"&CustomerID="+nCustomerID+"&DiscountCode="+strDiscountCode+"&GiftCardNum="+strGiftCardNum+"&GiftCardAmt="+strGiftCardAmt+"&Transform="+bTransform+"&TransformType="+nTransformType+"&UpdateErrors=";
	ajaxPost(strParams,strServiceURL,"renderCart");  
}

function updateCart(strInputField) {
    showHideModal("show", "<h3 class=\"modal_header\">Updating Your Cart</h3><hr /><img src=\"/site-images/global/ajax-preloader.gif\" alt=\"\" />");

	var strItemID = strInputField.substring(strInputField.indexOf("qty")+3,strInputField.length);
	var strItemQty = returnObj(strInputField).obj.options[returnObj(strInputField).obj.selectedIndex].value;
	   
	var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/UpdateShoppingCart";

	var nBrokerID = readCookie("BrokerID");
	var strSessionID = readCookie("SessionGUID");
	var nShippingType = readCookie("ShippingType");
	var nCustomerID = readCookie("CustomerID");
	var strDiscountCode = readCookie("DiscountCode");
	var strGiftCardNum = readCookie("GiftCardNum");
	var strGiftCardAmt = readCookie("GiftCardAmt");
	var bTransform = true;
	var nTransformType = 0;
	if(window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase()=="CHECKOUT.HTML")
	{
			nTransformType = 1;
	} 
		
	createCookie("iid"+strItemID,strItemQty,0);
		
	var strParams = "BrokerID="+nBrokerID+"&SessionID="+strSessionID+"&ItemID="+strItemID+"&ItemQty="+strItemQty+"&ShippingType="+nShippingType+"&CustomerID="+nCustomerID+"&DiscountCode="+strDiscountCode+"&GiftCardNum="+strGiftCardNum+"&GiftCardAmt="+strGiftCardAmt+"&Transform="+bTransform+"&TransformType="+nTransformType;
	ajaxPost(strParams,strServiceURL,"renderCart");           
}

function updateCartShipping(strInputField)
{
    showHideModal("show", "<h3 class=\"modal_header\">Updating Your Cart</h3><hr /><img src=\"/site-images/global/ajax-preloader.gif\" alt=\"\" />");

	var strShippingType = returnObj(strInputField).obj.options[returnObj(strInputField).obj.selectedIndex].value;
	createCookie("ShippingType",strShippingType,0);
	openCart();            
}

function removeFromCart(strInputField)
{
    showHideModal("show", "<h3 class=\"modal_header\">Updating Your Cart</h3><hr /><img src=\"/site-images/global/ajax-preloader.gif\" alt=\"\" />");

    var strItemID = strInputField.substring(strInputField.indexOf("qty") + 3, strInputField.length);
	var strItemQty = 0;
	   
	var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/UpdateShoppingCart";

	var nBrokerID = readCookie("BrokerID");
	var strSessionID = readCookie("SessionGUID");
	var nShippingType = readCookie("ShippingType");
	var nCustomerID = readCookie("CustomerID");
	var strDiscountCode = readCookie("DiscountCode");
	var strGiftCardNum = readCookie("GiftCardNum");
	var strGiftCardAmt = readCookie("GiftCardAmt");
	var bTransform = true;
	var nTransformType = 0;
	if(window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase()=="CHECKOUT.HTML")
	{
			nTransformType = 1;
	} 

	eraseCookie("iid"+strItemID);
	   
	var strParams = "BrokerID="+nBrokerID+"&SessionID="+strSessionID+"&ItemID="+strItemID+"&ItemQty="+strItemQty+"&ShippingType="+nShippingType+"&CustomerID="+nCustomerID+"&DiscountCode="+strDiscountCode+"&GiftCardNum="+strGiftCardNum+"&GiftCardAmt="+strGiftCardAmt+"&Transform="+bTransform+"&TransformType="+nTransformType;
	ajaxPost(strParams,strServiceURL,"renderCart");     
}



function renderCart(xml)
{
	// CoreMetrics - log cart view
	cmCreatePageviewTag('cart','1','','','-_--_--_--_--_--_--_--_--_--_--_--_--_--_-');
	
	var bActiveX=true;
	var bCheckout=false;
	
	if(window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase()=="CHECKOUT.HTML")
	{
		bCheckout=true;
	}
	
	if (document.implementation && document.implementation.createDocument)
	{
		bActiveX=false;
		xmlDoc = document.implementation.createDocument("", "", null);
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(xml,"text/xml");
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML(xml);
	}
	else
	{
		alert("Your browser is having problems with our website!\n\nPlease call us to resolve this issue.");
		return;
	}

	if(bCheckout){nodeRightColumn = getElementsByAttribute(xmlDoc,"div","id","divCartRightColumn");}
	nodeItems = getElementsByAttribute(xmlDoc, "div", "id", "divCart_Items");
	nodeSummary = getElementsByAttribute(xmlDoc, "div", "id", "divCartSummary");
	nodeCharges = getElementsByAttribute(xmlDoc, "div", "id", "divCartDetails_ChargesInner");
	nodeNotifications = getElementsByAttribute(xmlDoc, "div", "id", "divCart_Notifications");
	if (!bCheckout) { nodeFooter = getElementsByAttribute(xmlDoc, "div", "id", "divCart_Footer"); }

	/* set the cart qty cookie */
	nodeItemsSelected=getElementsByAttribute(nodeItems[0],"option","selected","selected");
	var nCartItemQty = 0;
	for(n in nodeItemsSelected)
	{
		nCartItemQty += Number(nodeItemsSelected[n].getAttribute("value"));
	}
	createCookie("CartItemQty",nCartItemQty,0)
	try{returnObj("spanCartItemQty").obj.innerHTML=nCartItemQty}catch(ex){/*carry on*/}

	try
	{  
		if (nCartItemQty > 0)
		{        
			// CoreMetrics Shop5 Tag
			nodeCMShop5=getElementsByAttribute(xmlDoc,"input","id","hidCMShop5");
			
			if(nodeCMShop5[0].getAttribute("value")!="")
			{
				var strCartItems = nodeCMShop5[0].getAttribute("value").split("|");
				var bShop5 = false;
				for(n in strCartItems)
				{
					var strItemDetails = strCartItems[n].split("::");
					cmCreateShopAction5Tag(strItemDetails[0],strItemDetails[1],strItemDetails[2],strItemDetails[3],strItemDetails[4],strItemDetails[5]);
					bShop5 = true;
				}
				if(bShop5)
				{
					cmDisplayShop5s();
				}
			}
			
			nodeAmtDue=getElementsByAttribute(xmlDoc,"input","id","hidAmtDue");
			nodeGiftCardAmt=getElementsByAttribute(xmlDoc,"input","id","hidGiftCardAmt");
			
			try
			{
				nodeChargeType=getElementsByAttribute(xmlDoc,"input","id","hidChargeType");
				createCookie("AmtDue",nodeAmtDue[0].getAttribute("value"),0);
				createCookie("GiftCardAmt",nodeGiftCardAmt[0].getAttribute("value"),0);
			}
			catch(ec){/**/}
		}
		if(bCheckout)
		{
			try
			{
				if(Number(nodeChargeType[0].getAttribute("value"))==2)
				{
					/* don't show payment method fields*/
					returnObj("divCartPaymentInfo").style.display="none";
				}
				else 
				{
					returnObj("divCartPaymentInfo").style.display="";
				}
			}
			catch(ex){/*Carrie On*/}
		}
	}
	catch(ex)
	{
		try
		{
			var strErrorLog = getDebugInfo()+getExceptionInfo(ex)+"XML:<textarea cols=\"80\" rows=\"20\">" + escape(xml.toString()) + "</textarea><hr />";
			var strParams = "strErrorMsg="+strErrorLog+"&strSubject=JS_Exception [cart.js renderCart]&bIsHtmlMsg=true";
			ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError");
		}catch(e){/**/}
	}

	if (bCheckout) {
		if (bActiveX) {
		    if (nodeRightColumn[0] != null) { returnObj("secondary_content").obj.innerHTML = nodeRightColumn[0].xml; }
		    returnObj("divCartDetails_Items").obj.innerHTML = nodeItems[0].xml;
		    returnObj("divCartSummary").obj.innerHTML = nodeSummary[0].xml;
			returnObj("divCartDetails_Charges").obj.innerHTML = nodeCharges[0].xml;
			returnObj("divCartDetails_Notifications").obj.innerHTML = nodeNotifications[0].xml;
		}
        else
        {
			var serializer = new XMLSerializer();
			if (nodeRightColumn[0] != null) { returnObj("secondary_content").obj.innerHTML = serializer.serializeToString(nodeRightColumn[0]); }
			returnObj("divCartDetails_Items").obj.innerHTML = serializer.serializeToString(nodeItems[0]);
			returnObj("divCartSummary").obj.innerHTML = serializer.serializeToString(nodeSummary[0]);
            returnObj("divCartDetails_Charges").obj.innerHTML = serializer.serializeToString(nodeCharges[0]);
            returnObj("divCartDetails_Notifications").obj.innerHTML = serializer.serializeToString(nodeNotifications[0]);
        }

		if (nCartItemQty == 0) {
			returnObj("divCartContactInfo").style.display = "none";
			try { returnObj("divCartRightColumn").style.display = "none"; } catch (ex) { /**/ }
			returnObj("divCartPaymentInfo").style.display = "none";
			returnObj("divCartTOS").style.display = "none";
		}
	}
    else 
    {
	    showHideModal("hide");
		window.location.href = "https://" + location.hostname + "/checkout.html";
    }
    showHideModal("hide");
}

function applyChargeCredit() {
	var strApplyCode = returnObj("txtApplyChargeCredit").obj.value;
	if(strApplyCode==""){return false;}

	showHideModal("show", "<h3 class=\"modal_header\">Updating Your Cart</h3><hr /><img src=\"/site-images/global/ajax-preloader.gif\" alt=\"\" />");

	/*all gift cards use prefix 4780 or 5454*/
	if(strApplyCode.indexOf("4780")==0||strApplyCode.indexOf("5454")==0)
	{
		/*gift card*/
		createCookie("GiftCardNum",strApplyCode,0);
		var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/GetGiftCardBalance";
		var nBrokerID = readCookie("BrokerID");
		var strSessionID = readCookie("SessionGUID");
		var nShippingType = readCookie("ShippingType");
		var nCustomerID = readCookie("CustomerID");
		var strDiscountCode = readCookie("DiscountCode");
		var strGiftCardNum = readCookie("GiftCardNum");
		var bTransform = "true";
		var nTransformType = 0;
		var bApply = "true"; 
		if(window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase()=="CHECKOUT.HTML")
		{
			 nTransformType = 1;
		} 
		var strParams = "BrokerID="+nBrokerID+"&SessionID="+strSessionID+"&ShippingType="+nShippingType+"&CustomerID="+nCustomerID+"&DiscountCode="+strDiscountCode+"&GiftCardNum="+strGiftCardNum+"&Transform="+bTransform+"&TransformType="+nTransformType+"&Apply="+bApply;
		ajaxPost(strParams,strServiceURL,"renderCart");
	}
	else
	{
		/*discount code*/
		createCookie("DiscountCode",strApplyCode,0);
		openCart();
	}
}

function removeChargeCredit(type) {

    showHideModal("show", "<h3 class=\"modal_header\">Updating Your Cart</h3><hr /><img src=\"/site-images/global/ajax-preloader.gif\" alt=\"\" />");

	switch(type)
	{
		case "DC": /*discount code*/
			createCookie("DiscountCode","",0);
			break;
		case "GC": /*gift card*/
			createCookie("GiftCardNum","",0);
			createCookie("GiftCardAmt","",0);
			break;
	}
	openCart();
}

function showModalPop(strType)
{
	switch(strType)
	{
		case "TRUSTUS":
			showHideModalBG("show");
			showHide("divTrustUsWindowWrapper","show");
			returnObj("divTrustUsWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divTrustUsWindow").obj.offsetWidth/2)+"px";
			returnObj("aTrustUsHeader").obj.focus(); /*ff,safari*/
			returnObj("divTrustUsWindow").obj.focus(); /*ie*/
			break;
		case "GUARANTEE":
			showHideModalBG("show");
			showHide("divGuaranteeWindowWrapper","show");
			returnObj("divGuaranteeWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divGuaranteeWindow").obj.offsetWidth/2)+"px";
			returnObj("aGuaranteeHeader").obj.focus(); /*ff,safari*/
			returnObj("divGuaranteeWindow").obj.focus(); /*ie*/
			break;
		case "LOGIN":
				try { showHideModal("hide"); } catch (ex) {/**/}
				
				/* push logged in users straight to the checkout page*/
				var bSkipLogin = false;
				try
				{
					if(readCookie("CustomerID")>0&&readCookie("CustomerEmail")!="")
					{
						bSkipLogin = true;
						/*closeModalPop('CART');*/
						/*window.location="https://"+location.hostname+"/checkout.html";*/
						
						/* todo: show payment info */
					}
				}catch(ex){/**/}

				if(!bSkipLogin)
				{
					/*showHideModalBG("show");*/
					/*showHide("divPopLoginWindowWrapper","show");*/
					try
					{
						if(readCookie("CustomerID")>0&&readCookie("CustomerEmail")!="")
						{
							returnObj("txtLoginEmail").obj.value=readCookie("CustomerEmail");
							returnObj("divAccountLogin").style.display="";
							returnObj("spanPassLater").style.display="";
							//returnObj("selectAccountType").obj.options[1].selected=true;
							returnObj("rdoReturnCustomer").obj.checked=true;
							returnObj("divNewAccount").style.display="none";
							returnObj("divJoinEmail").style.display="none";
						}
					}
					catch(ex){/**/}
					
					/*
					if(window.location.pathname.toString().substring(window.location.pathname.toString().lastIndexOf('/') + 1).toUpperCase()=="CHECKOUT.HTML")
					{
						returnObj("imgBtnClose").style.display="none";
					}
					else
					{
						returnObj("imgBtnClose").style.display="";
					}
					*/
					/*returnObj("divPopLoginWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divPopLoginWindow").obj.offsetWidth/2)+"px";*/
					/*returnObj("aPopLoginHeader").obj.focus();*/ /*ff,safari*/
					/*returnObj("divPopLoginWindow").obj.focus();*/ /*ie*/
				}
			break;
		   
		case "TOS":
			showHideModalBG("show");
			showHide("divTOSWindowWrapper","show");
			returnObj("divTOSWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divTOSWindow").obj.offsetWidth/2)+"px";
			returnObj("aTOSHeader").obj.focus(); /*ff,safari*/
			returnObj("divTOSWindow").obj.focus(); /*ie*/
			break;
        case "CURRENCYCONVERSION":
            showHideModal("show", "<h3 class=\"modal_header\">Currency Converter</h3><hr /><iframe id=\"currency_converter\" width=\"100%\" height=\"180px\" frameborder=\"no\" src=\"" + "https://www.google.com/finance/converter?from=USD&to=EUR&a=" + returnObj("spanAmtDue").obj.innerHTML.toString().replace("$", "").replace(",", "") + "\"></iframe>", "true");
            break;
		case "PRIVPOL":
			showHideModalBG("show");
			showHide("divPrivacyPolicyWindowWrapper","show");
			returnObj("divPrivacyPolicyWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divPrivacyPolicyWindow").obj.offsetWidth/2)+"px";
			returnObj("aPrivacyPolicyHeader").obj.focus(); /*ff,safari*/
			returnObj("divPrivacyPolicyWindow").obj.focus(); /*ie*/
			break;
		case "FAQ":
			showHideModalBG("show");
			showHide("divFAQWindowWrapper","show");
			returnObj("divFAQWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divFAQWindow").obj.offsetWidth/2)+"px";
			returnObj("aFAQHeader").obj.focus(); /*ff,safari*/
			returnObj("divFAQWindow").obj.focus(); /*ie*/
			break;            
		case "CARTEXPIRATION":
			showHideModalBG("show");
			showHide("divCartExpirationWindowWrapper","show");
			returnObj("divCartExpirationWindow").style.left=(returnObj("divMain").obj.offsetLeft+(returnObj("divMain").obj.offsetWidth/2))-(returnObj("divCartExpirationWindow").obj.offsetWidth/2)+"px";
			returnObj("aCartExpirationHeader").obj.focus(); /*ff,safari*/
			returnObj("divCartExpirationWindow").obj.focus(); /*ie*/
			break;            
					
	}
	cmCreatePageElementTag(strType,"Modal PopUps");
}
function closeModalPop(strType)
{
	switch(strType)
	{
		case "TRUSTUS":
			showHide("divTrustUsWindowWrapper","hide");
			break;
		case "GUARANTEE":
			showHide("divGuaranteeWindowWrapper","hide");
			break;
		case "LOGIN":
			/*reset to register*/
			showHideConnect("REGISTER");
			returnObj("rdoNewCustomer").obj.checked=true;
			
			showHide("divPopLoginWindowWrapper","hide");
			break;  
		case "TOS":
			showHide("divTOSWindowWrapper","hide");
			break;
		case "CURRENCYCONVERSION":
			showHide("divCurrencyConversionWindowWrapper","hide");
			break;
		case "PRIVPOL":
			showHide("divPrivacyPolicyWindowWrapper", "hide");
			break;
		case "FAQ":
			showHide("divFAQWindowWrapper", "hide");
			break;            
		case "IPHONE":
			showHide("divIPhoneAlertWindowWrapper", "hide");
			break;            
		case "CARTEXPIRATION":
			showHide("divCartExpirationWindowWrapper", "hide");
			break;            
	} 
	showHideModalBG("hide");          
}


/*clear out state value for international addresses*/

$('#selectBillingCountry').live('change', function () {
    if ($(this).val() !== 1 || $(this).val() !== 2) {
        $('#hidBillingState').val(0);
    }
});






$(document).ready(function () {
    /* add icons for each saved card */
    $('.savedPayType').each(function (index) {
        if ($(this).text() == "VISA") {
            $(this).html('<img class="cardImg_noFade" id="cardType_mastercard" src="/site-images/Global/card_types/card_type_visa.png" alt="visa" />');
        }
        else if ($(this).text() == "MC") {
            $(this).html('<img class="cardImg_noFade" id="cardType_mastercard" src="/site-images/Global/card_types/card_type_mc.png" alt="mastercard" />');
        }
        else if ($(this).text() == "DISCOVER") {
            $(this).html('<img class="cardImg_noFade" id="cardType_mastercard" src="/site-images/Global/card_types/card_type_disc.png" alt="discover" />');
        }
        else if ($(this).text() == "AMEX") {
            $(this).html('<img class="cardImg_noFade" id="cardType_mastercard" src="/site-images/Global/card_types/card_type_amex.png" alt="american express" />');
        }
    });


    var cardTypes =
    '<img class="cardImg" id="cardType_amex" src="/site-images/Global/card_types/card_type_amex.png" alt="american express" />'
    + '<img class="cardImg" id="cardType_discover" src="/site-images/Global/card_types/card_type_disc.png" alt="discover" />'
    + '<img class="cardImg" id="cardType_mastercard" src="/site-images/Global/card_types/card_type_mc.png" alt="mastercard" />'
    + '<img class="cardImg" id="cardType_visa" src="/site-images/Global/card_types/card_type_visa.png" alt="visa" />';
    $('.cardReplacer').html(cardTypes);


    var $cardImg = $('.cardImg');
    var $visaImg = $('#cardType_visa');
    var $mcImg = $('#cardType_mastercard');
    var $discImg = $('#cardType_discover');
    var $amexImg = $('#cardType_amex');
    var $billZipCode = $('#txtBillingPostalCode');
    var $shipZipCode = $('#txtDeliveryPostalCode');
    var $cardName = $('#txtCCName');

    /*click to select?*/
    /*
    $cardImg.click(function () {
    $cardImg.addClass('faded');
    $(this).removeClass('faded');
    $cardImg.removeClass('selectedCardType');
    $(this).addClass('selectedCardType');
    });
    */

    var $txtCCNumber = $('#txtCCNumber');

    $txtCCNumber.keyup(function (event) {
        var text = $txtCCNumber.val();


        //visa
        if (text.charAt(0) === "4") {
            $cardImg.addClass('faded');
            $cardImg.removeClass('selectedCardType');
            $visaImg.addClass('selectedCardType');
            $visaImg.removeClass('faded');
        }

        //mc
        else if (text.charAt(0) === "5") {
            $cardImg.addClass('faded');
            $cardImg.removeClass('selectedCardType');
            $mcImg.addClass('selectedCardType');
            $mcImg.removeClass('faded');
        }

        //amex
        else if (text.charAt(0) === "3") {
            $cardImg.addClass('faded');
            $cardImg.removeClass('selectedCardType');
            $amexImg.addClass('selectedCardType');
            $amexImg.removeClass('faded');
        }

        //discover
        else if (text.charAt(0) === "6") {
            $cardImg.addClass('faded');
            $cardImg.removeClass('selectedCardType');
            $discImg.addClass('selectedCardType');
            $discImg.removeClass('faded');
        }

        //reset when value cleared
        else if (text.charAt(0) === "") {
            $cardImg.removeClass('selectedCardType');
            $cardImg.removeClass('faded');
        }

        //handle anything else
        else {
            $cardImg.removeClass('selectedCardType');
            $cardImg.removeClass('faded');
        }

    });


    $txtCCNumber.blur(function (event) {
        //amex 15 chars
        //others 16 chars

        if ($amexImg.hasClass('selectedCardType')) {
            if ($txtCCNumber.val().length != 15) {
                $('.lengthwarning').remove();
                $(this).parent().append('<span class="red small lengthwarning">American Express card numbers contain 15 digits</span>');
            }
            else {
                $('.lengthwarning').remove();
            }
        }

        else if ($discImg.hasClass('selectedCardType')) {
            if ($txtCCNumber.val().length != 16) {
                $('.lengthwarning').remove();
                $(this).parent().append('<span class="red small lengthwarning">Discover card numbers contain 16 digits</span>');
            }
            else {
                $('.lengthwarning').remove();
            }
        }

        else if ($mcImg.hasClass('selectedCardType')) {
            if ($txtCCNumber.val().length != 16) {
                $('.lengthwarning').remove();
                $(this).parent().append('<span class="red small lengthwarning">MasterCard numbers contain 16 digits</span>');
            }
            else {
                $('.lengthwarning').remove();
            }
        }

        else if ($visaImg.hasClass('selectedCardType')) {
            if ($txtCCNumber.val().length != 16) {
                $('.lengthwarning').remove();
                $(this).parent().append('<span class="red small lengthwarning">Visa card numbers contain 16 digits</span>');
            }
            else {
                $('.lengthwarning').remove();
            }
        }

        else {
            $('.lengthwarning').remove();
        }
    });



    /* temp chopping zip codes, need to internationalize*/
    /*live validate zip codes*/

    /*
    $billZipCode.blur(function (event) {
    if ($billZipCode.val().length != 5) {
    $('.zipwarning').remove();
    $(this).parent().append('<span class="red small zipwarning">must be 5 digits</span>');
    }
    else {
    $('.zipwarning').remove();
    }
    });

    $shipZipCode.blur(function (event) {
    if ($shipZipCode.val().length != 5) {
    $('.zipwarning').remove();
    $(this).parent().append('<span class="red small zipwarning">must be 5 digits</span>');
    }
    else {
    $('.zipwarning').remove();
    }
    });
    */
    
    
    /* verify a name has been entered */
    $cardName.blur(function (event) {
        if ($cardName.val().length == 0) {
            $('.ccnamewarning').remove();
            $(this).parent().append('<span class="red small ccnamewarning">please enter the name on the card</span>');
        }
        else {
            $('.ccnamewarning').remove();
        }
    });

});


/*
send login when user hits enter
hijack event, trigger click
*/
$('#txtLoginPassword').live('keydown', function (event) {
    if (event.keyCode == '13') {
        event.preventDefault();
    }
});
$('#txtLoginPassword').live('keyup', function (event) {
    if (event.keyCode == '13') {
        $('#login_proceed').trigger('click');
    }
});

function LogNewsLetter(EmailAddress,nBrokerID,strCB)
{
    var strCbSignups = '';
    var cbsSignups = '';
    returnObj("divSuccess").style.display=""; //added to show success label // 
    try{
        if (strCB.length > 0)
        {
			if(strCB=="EXITCHECKOUT")
			{
				cmCreateConversionEventTag("EXIT CHECKOUT","2","Newsletter Signup");
			}
			else
			{
				var cbsArray = new Array();
				cbsArray = strCB.split("|");
				for (var cb in cbsArray)
				{
				if(returnObj(cbsArray[cb]).obj.checked)
				   {
					   cbsSignups = cbsSignups + cbsArray[cb] + "|";
				   }
				}
				strCbSignups = cbsSignups.substring(0, cbsSignups.length - 1);
			}
        }
    }
    catch (ex){}
    
    
    var strParams = "EmailAddress="+EmailAddress+"&nBrokerID="+nBrokerID+"&strCB="+strCbSignups;
    var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogNewsLetter";
    ajaxPost(strParams,strServiceURL,"fnNada");

}
function fnNada()
{
	xml = arguments[0];

	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(xml,"text/xml");
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML(xml);
	}
	else
	{
		alert("Your browser is having problems with our website!\n\nPlease call us to resolve this issue.");
		return;
	}

	var strEmailAddress = xmlDoc.getElementsByTagName("LogNewsLetter")[0].getAttribute("EmailAddress");
	var strCustomerID = xmlDoc.getElementsByTagName("LogNewsLetter")[0].getAttribute("CustomerID");

	if(xmlDoc.getElementsByTagName("LogNewsLetter")[0].getAttribute("NewCustomer")=="true")
	{
		cmCreateRegistrationTag(strCustomerID, strEmailAddress, null, null, null, null, "Newsletter", "true");
	}

	var Newsletters = xmlDoc.getElementsByTagName("Newsletter");
	for(var n = 0; n < Newsletters.length; n++)
	{
		cmCreateConversionEventTag(Newsletters[n].getAttribute("name"),"2","Newsletter Signup");
	}

	try
	{
		setTimeout("returnObj('divSuccess').style.display='none'", 2000);
	}catch(ex){/*carry on*/}
}
/* END FIREFOX AJAX */

/*START VALIDATION*/





/* ========== Email Signup with ReCaptcha ============ */

function newsletterSignup() /* ARGS(nBrokerID,txtEmailID,strCB) */
{
	nBrokerID = arguments[0];
	txtEmailID = arguments[1];
	strCB = arguments[2];
	args = new Array();
	for(n=0; n<arguments.length; n++)
	{
		args[n] = arguments[n];
	}

	if(validateField(txtEmailID,'show','divBlankEmail','divBadEmail', '')&&validateEmail(txtEmailID,'divBlankEmail','divBadEmail'))
	{
		var strParams = "RemoteIP="+readCookie("IPAddress")+"&Challenge="+returnObj("recaptcha_challenge_field").obj.value+"&Response="+returnObj("recaptcha_response_field").obj.value;
		var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/ReCaptcha";
		ajaxPost(strParams,strServiceURL,"newsletterSignup_ReCaptcha",args);
	}
}

function newsletterSignup_ReCaptcha() /* ARGS(xml,array[nBrokerID,txtEmailID,strCB]) */
{
	xml = arguments[0];
	nBrokerID = arguments[1][0];
	txtEmailID = arguments[1][1];
	strCB = arguments[1][2];

	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(xml,"text/xml");
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML(xml);
	}
	else
	{
		alert("Your browser is having problems with our website!\n\nPlease call us to resolve this issue.");
		return;
	}

	Recaptcha.reload();

    switch(xmlDoc.getElementsByTagName("ReCaptcha")[0].getAttribute("StatusCode"))
    {
        case "0":
			LogNewsLetter(document.getElementById(txtEmailID).value,nBrokerID,strCB);
			returnObj(txtEmailID).obj.value="";
			// reset the form
			bEmailSignupExpanded=false;
			returnObj('divNewsletterContainer').style.position='relative';
			returnObj('divReCaptcha').style.display='none';
			returnObj('spanEmailLabel').style.display='none';
			returnObj(txtEmailID).style.width="98%";
			returnObj('btnCancelEmailSignUp').style.display='none';
			returnObj('divNewsletterWrapper').style.height=returnObj('divNewsletterContainer').obj.offsetHeight+'px';
			returnObj('divNewsletterContainer').style.marginLeft='0px';
            break;
        default:
			alert("The words entered into the verification box were incorrect!\n\nPlease try again or call 1-800-521-9616 to speak with a representative.");
            break;
    }
}

//  JScript File//
        //generic validatator for email address field //
        //div1 Set for Error Message//
        function validateField(id,action,div1,div2,alert) 
        {
              if(document.getElementById(id).value=="")
              {
                        if(action == "alert")
                        {
                            alert(alert);
                        }
                        else if(action == "show")
                        {
                            document.getElementById(div1).style.display="";
                            document.getElementById(div2).style.display="none";
                            if(document.getElementById("divSuccess") != null) 
                            {
                                document.getElementById("divSuccess").style.display="none";
                            }
                        }
                        else if(action == "")
                        {
                            alert("You didnt specify a method like alert or show")
                        }
                        else
                        {
                            alert("Dont know that method, make sure you have the method defined");
                        }    
                        document.getElementById(id).focus();
                        return false;
              }

             document.getElementById(div1).style.display="none";
             document.getElementById(div2).style.display="none";
             return true;
        }
        function validateForm(id, action, div)
        {
            if (Trim(returnObj(id).obj.value)=="")
            {
                if (action == "show")
                {
                    returnObj(div).style.display=""; 
                    return false; 
                }
            }
            else
            {
                if (returnObj(div).style.display == "")
                {
                    returnObj(div).style.display = "none";
                }            
                return true; 
            }
        }
                
// JScript File //
function validateEmail(id,div1,div2)
{
     var emailPat = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
     var emailid=document.getElementById(id).value;
     var matchArray = emailid.match(emailPat);
     if (matchArray == null)
    {
        returnObj(div2).style.display="";
        returnObj(div1).style.display="none";
        if(document.getElementById("divSuccess") != null) 
        {
            document.getElementById("divSuccess").style.display="none";
        }      
         document.getElementById(id).focus();
         return false;
    }
    else
    {
         if (returnObj(div1).style.display=="") returnObj(div1).style.display = "none";
         if (returnObj(div2).style.display=="") returnObj(div2).style.display = "none"; 
        return true; 
    }
}
function validateCurrency(id, div1)
{
    var currencyRegEx = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
    var gcAmountid = Trim(returnObj(id).obj.value);
    var matchArray = gcAmountid.match(currencyRegEx);
    if (matchArray == null)
    {
        returnObj(div1).style.display = "";
        returnObj(id).focus();
        return false;    
    }
    else
    {
        if (returnObj(div1).style.display == "")
        {
            returnObj(div1).style.display = "none";
        }
        return true; 
    }

}
function validateInteger(id, div1)
{
    var integerRegEx = /^\d+$/; 
    if (returnObj(id).obj.value != "")
   {  
        var intQty = returnObj(id).obj.value; 
        var matchArray = intQty.match(integerRegEx);
        if (matchArray == null)
        {
            returnObj(div1).style.display = ""; 
            returnObj(id).focus(); 
            return false;
        }
        else
        {
            if (returnObj(div1).style.display == "")
            {
                returnObj(div1).style.display = "none"; 
            }
            return true; 
        }
    }
    else 
    {
            returnObj(div1).style.display ="";
            return false;
    }  
}
function validateGC(gcNum, div1) {
    var gcRegEx = /^\d{16}/; 
   if (returnObj(gcNum).obj.value != "")
   {
        if (returnObj('txtGCBalance').style.display == "")
        {
            returnObj('txtGCBalance').style.display = "none";
        }
        var gc_Number = returnObj(gcNum).obj.value;
        var matchArray = gc_Number.match(gcRegEx); 
        if (matchArray == null)
        {
            returnObj(div1).style.display = ""; 
            returnObj(gcNum).focus(); 
            return false;
        }
        else
        {
            if (returnObj(div1).style.display =="")
            {
                returnObj(div1).style.display = "none";  
            }
            return true; 
        }
    }
   else
   {         
        returnObj(div1).style.display = ""; 
        return false; 
    }
} 

function ajaxPost() /* ARGS=(strParams,strServiceURL,strCallbackFunction) */
{
	strParams = arguments[0];
	strServiceURL = arguments[1];
	strCallbackFunction = arguments[2];
	args = new Array();
	if(arguments.length==4)
	{
		for(n=0; n<arguments[3].length; n++)
		{
			args[n] = arguments[3][n];
		}
	}

    var xmlHttp;
    var xmlHttpTimeout = 5000;
    try
    {
        /* Firefox, Opera 8.0+, Safari */
        xmlHttp=new XMLHttpRequest();
        /* override DOM methods for these pain in the arse browsers */
        XPathForFireFox();
    }
    catch (e)
    {
        /* Internet Explorer */
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                /*alert("Your browser does not support AJAX!");*/
                return "";
            }
        }
    }

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4&&xmlHttp.status==200)
        {
            window.clearTimeout(timeoutAjax);
            /* determine what function will handle the output */
            if(strCallbackFunction!=null)
            {
				var fn = strCallbackFunction;
				if(args.length>0) 
				{
					window[fn](xmlHttp.responseText,args);
				}
				else
				{
					window[fn](xmlHttp.responseText);
				}
            }
        } 
    }

    xmlHttp.open("POST",strServiceURL,true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   if (!(navigator.appVersion.indexOf("MSIE") > 0 && (navigator.appVersion.indexOf("Windows NT 5.0") > 0 || navigator.appVersion.indexOf("Windows NT 4") > 0)))
   { 
        xmlHttp.setRequestHeader("Content-Length", strParams.length);
        xmlHttp.setRequestHeader("Connection", "close");
    }
   
    var timeoutAjax = window.setTimeout(function(){if (callInProgress(xmlHttp) ){xmlHttp.abort();}},xmlHttpTimeout);
    xmlHttp.send(strParams);
}

/* this enables 'selectSingleNode' & 'selectNodes' XPath methods for AJAX for FireFox */
function XPathForFireFox()
{
    if (!window.ActiveXObject)
    {

        /* this solution came from a lot of debugging, finally the 'getting started' article on http://developer.mozilla.org/en/docs/AJAX helped. */
       XMLDocument.prototype.selectSingleNode = function(sXPath)
        {
            return this.getElementsByTagName(Right(sXPath,Len(sXPath) - sXPath.lastIndexOf("/") - 1)).item(0).firstChild.data;
        }
        
        /* the following protoypes haven't been tested, because they're not needed yet */
	    Element.prototype.selectNodes = function(sXPath)
	    {
		    var oEvaluator = new XPathEvaluator();
		    var oResult = oEvaluator.evaluate(sXPath, this, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
		    var aNodes = new Array();
		    if (oResult != null)
		    {
			    var oElement = oResult.iterateNext();
			    while(oElement)
			    {
				    aNodes.push(oElement);
				    oElement = oResult.iterateNext();
			    }
		    }
		    return aNodes;
	    }
	    
	    Element.prototype.selectSingleNode = function(sXPath)
	    {
		    var oEvaluator = new XPathEvaluator();
		      /* FIRST_ORDERED_NODE_TYPE returns the first match to the xpath. */
		    var oResult = oEvaluator.evaluate(sXPath, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
		    if (oResult != null)
		    {
			    return oResult.singleNodeValue;
		    }
		    else
		    {
			    return null;
		    }              
	    }

    }
}

function callInProgress(xmlhttp)
{
    switch (xmlhttp.readyState)
    {
        case 1, 2, 3:
            return true;
            break;
        default: /* Case 4 and 0 */
            return false;
            break;
    }
}

// <script>

// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Distribute this code, any part or any modified version of it.
//     Instead, you can link to the homepage of this code:
//     http://www.php-development.ru/javascripts/smart-forms.php.
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as a part of another product provided that
//     its main use is not creating javascript menus.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind, either
// expressed or implied, including, but not limited to, the implied warranties
// of merchantability and fitness for a particular purpose. You expressly
// acknowledge and agree that use of this code is at your own risk.

// If you find my script useful, you can support my site in the following ways:
// 1. Vote for the script at HotScripts.com (you can do it on my site)
// 2. Link to the homepage of this script or to the homepage of my site:
//    http://www.php-development.ru/javascripts/smart-forms.php
//    http://www.php-development.ru/
//    You will get 50% commission on all orders made by your referrals.
//    More information can be found here:
//    http://www.php-development.ru/affiliates.php


// ----- Popup Control ---------------------------------------------------------

function at_display(x)
{
  win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- Show Aux -----

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  var top  = (c["at_position"] == "y") ? p.offsetHeight : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth : 0;

  for (; p; p = p.offsetParent)
  {
	top  += p.offsetTop;
	left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Show -----

function at_show()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}

// ----- Hide -----

function at_hide()
{
  c = document.getElementById(this["at_child"]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 111);
}

// ----- Click -----

function at_click()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id);
  else c.style.visibility = "hidden";

  return false;
}

// ----- Attach -----

// PARAMETERS:
// parent   - id of visible html element
// child    - id of invisible html element that will be dropdowned
// showtype - "click" = you should click the parent to show/hide the child
//            "hover" = you should place the mouse over the parent to show
//                      the child
// position - "x" = the child is displayed to the right of the parent
//            "y" = the child is displayed below the parent
// cursor   - Omit to use default cursor or check any CSS manual for possible
//            values of this field

function at_attach(parent, child, showtype, position, cursor)
{
  p = document.getElementById(parent);

	// if statement added by Buster, to prevent JS Errors
	if(  c = document.getElementById(child))
	{
	  p["at_parent"]     = p.id;
	  c["at_parent"]     = p.id;
	  p["at_child"]      = c.id;
	  c["at_child"]      = c.id;
	  p["at_position"]   = position;
	  c["at_position"]   = position;

	  c.style.position   = "absolute";
	  c.style.visibility = "hidden";

	  if (cursor != undefined) p.style.cursor = cursor;

	  switch (showtype)
	  {
		case "click":
		  p.onclick     = at_click;
		  p.onmouseout  = at_hide;
		  c.onmouseover = at_show;
		  c.onmouseout  = at_hide;
		  break;
		case "hover":
		  p.onmouseover = at_show;
		  p.onmouseout  = at_hide;
		  c.onmouseover = at_show;
		  c.onmouseout  = at_hide;
		  break;
	  }
	}
}

// ----- Show Aux SEE ALL-----

function at_show_aux_SEEALL(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  var top  = (c["at_position"] == "y") ? p.offsetHeight : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth : 0;
  
  var tabWidth = p.offsetWidth;

  for (; p; p = p.offsetParent)
  {
	top  += p.offsetTop;
	left += p.offsetLeft;
  }
  
  //left = left-c.offsetWidth+tabWidth;
  if(left<0)
   {
		left = 0;
   }

  c.style.position   = "absolute";
  c.style.top        = top-(c["at_offset"]) +'px'; //PT made offset a variable //
  //c.style.right       = 50+'px';
  c.style.visibility = "visible";
  c.style.zIndex    = 999999;
}

/*
function at_show_aux_SEEALL(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  var top  = (c["at_position"] == "y") ? p.offsetHeight : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth : 0;


   var tabWidth = p.offsetWidth;

   top  += p.offsetTop;

	c.style.position   = "relative";
	c.style.left       = 0+'px';
	
   //left = c.offsetLeft-c.offsetWidth+tabWidth; // GOOD FOR OLD SYS
   
   var tbl = document.getElementById('tblTabNav');
   alert('left: ' + tbl.offsetLeft);
   alert('top: ' + tbl.offsetTop);
   alert('width: ' + tbl.offsetWidth);
   alert('height: ' + tbl.offsetHeight);
   
   top = tbl.offsetHeight;
   
   left = c.offsetLeft-c.offsetWidth+tabWidth+tbl.offsetLeft;
   //left = left-c.offsetWidth+tabWidth;

   if(left<0)
   {
		left = 0;
   }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}
*/


// ----- Show -----

function at_show_SEEALL()
{
  //showHideSelects("hide");
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  at_show_aux_SEEALL(p.id, c.id);
 
  if (c.style.overflow = "hidden")c.style.overflow = "auto";
  else c.style.overflow = "hidden";
  clearTimeout(c["at_timeout"]);
}

// ----- Hide -----

function at_hide_SEEALL()
{
  //showHideSelects();
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child"]);
  
  c.style.overflow = "hidden";
  
  
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 111);
   
}

// ----- Click -----

function at_click_SEEALL()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux_SEEALL(p.id, c.id);
  else c.style.visibility = "hidden";
  
  if (c.style.overflow == "hidden") c.style.overflow = "auto";
  else c.style.overflow = "hidden"; 

  return false;
}

// ----- Attach -----

// PARAMETERS:
// parent   - id of visible html element
// child    - id of invisible html element that will be dropdowned
// showtype - "click" = you should click the parent to show/hide the child
//            "hover" = you should place the mouse over the parent to show
//                      the child
// position - "x" = the child is displayed to the right of the parent
//            "y" = the child is displayed below the parent
// cursor   - Omit to use default cursor or check any CSS manual for possible
//            values of this field
// offset   - added by PT to have customer vertical offset for positioning. 
//            a positive value move the element towards the top of the page

function at_attach_SEEALL(parent, child, showtype, position, offset, cursor)
{
  p = document.getElementById(parent);

	// if statement added by Buster, to prevent JS Errors
	if(  c = document.getElementById(child))
	{
	  p["at_parent"]     = p.id;
	  c["at_parent"]     = p.id;
	  p["at_child"]      = c.id;
	  c["at_child"]      = c.id;
	  p["at_position"]   = position;
	  c["at_position"]   = position;
	  c["at_offset"]     = offset;

	  c.style.position   = "absolute";
	  c.style.visibility = "hidden";
	  if (cursor != undefined) p.style.cursor = cursor;

	  switch (showtype)
	  {
		case "click":
		  p.onclick     = at_click_SEEALL;
		  p.onmouseout  = at_hide_SEEALL;
		  c.onmouseover = at_show_SEEALL;
		  c.onmouseout  = at_hide_SEEALL;
		  c.style.overflow = "hidden";
		  break;
		case "hover":
		  p.onmouseover = at_show_SEEALL;
		  p.onmouseout  = myMouseOut;
		  c.onmouseover = at_show_SEEALL;
		  c.onmouseout  = at_hide_SEEALL;
		  break;
	  }
	}
}


/*set rotator speed in miliseconds*/
var homeRotatorSpeed = 6200;

$("document").ready(function () {
    $("#feature_0").show();
    $("#featureLink_0").addClass("hotEventsLinksSelected");

    var rpIndex = 1;

    $(".hotEventsLinks").click(function () {
        clearInterval(rpInterval);
        $(".hotEventsLinks").removeClass("hotEventsLinksSelected");
        $(this).addClass("hotEventsLinksSelected");
        $(".feature").hide();
        $("#feature_" + $(this).attr("id").substring($(this).attr("id").indexOf("_") + 1)).show();
    });

    var rpInterval = setInterval(function () {

        var activeFeature = $("#feature_" + rpIndex);
        var activeLink = $("#featureLink_" + rpIndex);

        $(".hotEventsLinks").removeClass("hotEventsLinksSelected");

        $(".feature").hide();

        if (activeFeature.length > 0) {
            activeFeature.show();
            activeLink.addClass("hotEventsLinksSelected");
            rpIndex++;
        }
        else {
            $("#feature_0").show();
            $("#featureLink_0").addClass("hotEventsLinksSelected");
            rpIndex = 1;
        }
    }, homeRotatorSpeed);
});/*!
 * jQuery UI 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI
 */
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=
this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,
"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":
"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,
outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,
"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&
a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&
c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*!
 * jQuery UI Widget 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)try{b(d).triggerHandler("remove")}catch(e){}k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){try{b(this).triggerHandler("remove")}catch(d){}});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=
function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):
d;if(e&&d.charAt(0)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=
b.extend(true,{},this.options,this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
;/*!
 * jQuery UI Mouse 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Mouse
 *
 * Depends:
 *	jquery.ui.widget.js
 */
(function(b){var d=false;b(document).mouseup(function(){d=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
this.widgetName)},_mouseDown:function(a){if(!d){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,f=a.which==1,g=typeof this.options.cancel=="string"&&a.target.nodeName?b(a.target).closest(this.options.cancel).length:false;if(!f||g||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=
this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}true===b.data(a.target,this.widgetName+".preventClickEvent")&&b.removeData(a.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(e){return c._mouseMove(e)};this._mouseUpDelegate=function(e){return c._mouseUp(e)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return d=true}},_mouseMove:function(a){if(b.browser.msie&&
!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=
false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
;/*
 * jQuery UI Position 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Position
 */
(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
;/*
 * jQuery UI Autocomplete 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Autocomplete
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	jquery.ui.position.js
 */
(function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g=
false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!=
a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)};
this.menu=d("<ul></ul>").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&&
a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");
d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&
b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source=
this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)!==false)return this._search(a)},_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)},_response:function(a){if(!this.options.disabled&&a&&a.length){a=this._normalize(a);this._suggest(a);this._trigger("open")}else this.close();
this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this.menu.element.hide();this.menu.deactivate();this._trigger("close",a)}},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){if(a.length&&a[0].label&&a[0].value)return a;return d.map(a,function(b){if(typeof b==="string")return{label:b,value:b};return d.extend({label:b.label||
b.value,value:b.value||b.label},b)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();b.show();this._resizeMenu();b.position(d.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next(new d.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(a,b){var g=this;
d.each(b,function(c,f){g._renderItem(a,f)})},_renderItem:function(a,b){return d("<li></li>").data("item.autocomplete",b).append(d("<a></a>").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
"\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery);
(function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
-1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");
this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b,
this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[d.fn.prop?"prop":"attr"]("scrollHeight")},select:function(e){this._trigger("selected",e,{item:this.active})}})})(jQuery);
;/*
 * jQuery UI Tabs 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 */
(function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&&
e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=
d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]||
(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected=
this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));
this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+
g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",
function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};
this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected=
-1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";
d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=
d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b,
e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);
j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove();
if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(h){return h!=b}),function(h){return h>=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null,
this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this},
load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c,
"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},
url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.16"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k<a.anchors.length?k:0)},b);j&&j.stopPropagation()});e=a._unrotate||(a._unrotate=!e?function(j){j.clientX&&
a.rotate(null)}:function(){t=c.selected;h()});if(b){this.element.bind("tabsshow",h);this.anchors.bind(c.event+".tabs",e);h()}else{clearTimeout(a.rotation);this.element.unbind("tabsshow",h);this.anchors.unbind(c.event+".tabs",e);delete this._rotate;delete this._unrotate}return this}})})(jQuery);
;/* set up autocomplete */

function updateAutocomplete(data) {
    killSearchResultsBox();
    $('#header_SearchBox_pnlSearchBox').append('<div id="livesearch_results"><h5>Results</h5></div>');    
    var resultNum = 0;
    if (data.Phrases.length == 0) {
        killSearchResultsBox();
    }
    else {
        $.each(data.Phrases, function () {
            $('#livesearch_results').append('<div class="livesearch_resultItem" id="livesearch_resultItem' + resultNum + '">' + this + '</div>');
            resultNum++;
        });
    }
}

function getSearchData() {
    var $searchString = $('#q').val();
    $.ajax({
        url: "/data/search/autocomplete/" + encodeURIComponent($.trim($searchString)),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        cache: false,        
        success: function (data) {
            updateAutocomplete(data);
        },
        error: function (xhr, ajaxOptions, thrownError) {
        //if this breaks do nothing, search will run as normal
        }
    });
}

function killSearchResultsBox() {
    var currentSelection = -1;
    $('#livesearch_results').remove();
}

$(document).ready(function () {
    $("#q").autocomplete({ disabled: true });

    var $searchInput = $('#q');

    if (autocompleteIsEnabled == "true") {
        $('#q').keyup(function (event) {
            var $searchString = $('#q').val();
            if (event.keyCode == 40) {
                $('#q').blur();
                if ($('.selected_livesearch_resultItem').length < 1) {
                    $('#q').blur();
                    $('.livesearch_resultItem').first().addClass('selected_livesearch_resultItem');
                }
            }
            else if ($searchString.length >= 2) {
                inputTimer();
            }
            else {
                killSearchResultsBox();
            }
        });
    }
    var searchStringTimer;
    function updateTimer() { searchStringTimer = setTimeout("getSearchData()", autocompleteTimeToFire); }

    function inputTimer() {
        clearTimeout(searchStringTimer);
        updateTimer();
    }
});

$('.livesearch_resultItem').live('mouseover', function () {
    $('.livesearch_resultItem').removeClass('selected_livesearch_resultItem');
    $(this).addClass('selected_livesearch_resultItem');
    $('#q').val($(this).text());
});

$('.livesearch_resultItem').live('click', function () {
    $('#q').val($(this).text());
    $('#btnSearch').trigger('click');
});

$(document.documentElement).keyup(function (event) {
    if ($('#livesearch_results').length == 1) {        
        event.preventDefault();
        if (event.keyCode == 40) {
            $('#q').blur();
            if ($('.selected_livesearch_resultItem').length < 1) {
                $('#q').blur();
                $('.livesearch_resultItem').first().addClass('selected_livesearch_resultItem');
                $('selected_livesearch_resultItem').focus();
                $('#q').val($('.selected_livesearch_resultItem').text());
            }
            else {                
                event.preventDefault();
                navigate('down');
            }
        }
        else if (event.keyCode == 38) {            
            event.preventDefault();
            navigate('up');
        }
        else if (event.keyCode == 13) {
            $('#q').val($('.selected_livesearch_resultItem').text());
            $('#btnSearch').click();
        }
    }
});

var currentSelection = -1;
function navigate(direction) {
    if ($(".selected_livesearch_resultItem").size() == 0) {
        currentSelection = 0;
    }

    //if at top, return to textbox
    if (direction == 'up' && currentSelection == 0) {
        killSearchResultsBox();
        $("#q").focus();
    }

    if (direction == 'up' && currentSelection != -1) {
        if (currentSelection != 0) {
            currentSelection--;
        }
    }
    else if (direction == 'down') {
        currentSelection++;
    }
    setSelected(currentSelection);
}

function setSelected(menuitem) {
    $(".livesearch_resultItem").removeClass("selected_livesearch_resultItem");
    $(".livesearch_resultItem").eq(menuitem).addClass("selected_livesearch_resultItem");
}



/*universal*/
$(document.documentElement).keydown(function (event) {
    if (event.keyCode == 40) {
        event.preventDefault();
    } else if (event.keyCode == 38) {
        event.preventDefault();
    }
});


$('#livesearch_results').live('mouseleave', function () {    
     killSearchResultsBox();
});



 /*sub search*/
 function updateAutocompleteSub(subdata) {
     killSearchResultsBox();
     $('#sub_header2').append('<div id="livesearch_results" class="livesearch_resultsSub"><h5>Results</h5></div>');
     var resultNum = 0;
     if (subdata.Phrases.length == 0) {
         killSearchResultsBox();
     }
     else {
         $.each(subdata.Phrases, function () {
             $('.livesearch_resultsSub').append('<div class="livesearch_resultItem livesearch_resultItemSub" id="livesearch_resultItem' + resultNum + '">' + this + '</div>');
             resultNum++;
         });
     }
 }

 function getSearchDataSub() {
     var $searchString = $('#sub_search').val();
     $.ajax({
         url: "/data/search/autocomplete/" + $.trim($searchString),
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         cache: false,
         success: function (subdata) {
             updateAutocompleteSub(subdata);
         },
         error: function (xhr, ajaxOptions, thrownError) {
             //if this breaks do nothing, search will run as normal
         }
     });
 }


 $(document).ready(function () {
     $("#sub_search").autocomplete({ disabled: true });

     var $searchInput = $('#sub_search');

     if (autocompleteIsEnabled == "true") {
         $('#sub_search').keyup(function (event) {
             var $searchString = $('#sub_search').val();
             if (event.keyCode == 40) {
                 $('#sub_search').blur();
                 if ($('.selected_livesearch_resultItem').length < 1) {
                     $('#sub_search').blur();
                     $('.livesearch_resultItem').first().addClass('selected_livesearch_resultItem');
                 }
             }
             else if ($searchString.length >= 2) {
                 inputTimerSub();
             }
             else {
                 killSearchResultsBox();
             }
         });
     }

     

     var searchStringTimerSub;
     function updateTimerSub() { searchStringTimer = setTimeout("getSearchDataSub()", autocompleteTimeToFire); }

     function inputTimerSub() {
         clearTimeout(searchStringTimerSub);
         updateTimerSub();
     }
 });


 $(document.documentElement).keyup(function (event) {
     if ($('.livesearch_resultsSub').length == 1) {
         event.preventDefault();
         if (event.keyCode == 40) {
             //$('#q').blur();
             if ($('.selected_livesearch_resultItem').length < 1) {
                 //$('#q').blur();
                 $('.livesearch_resultItem').first().addClass('selected_livesearch_resultItem');
                 $('selected_livesearch_resultItem').focus();
                 $('#q').val($('.selected_livesearch_resultItem').text());
             }
             else {
                 event.preventDefault();
                 navigateSub('down');
             }
         }
         else if (event.keyCode == 38) {
             event.preventDefault();
             navigateSub('up');
         }
         else if (event.keyCode == 13) {
             $('#q').val($('.selected_livesearch_resultItem').text());
             $('#btnSearch').click();
         }
     }
 });

 var currentSelectionSub = -1;
 function navigateSub(direction) {
     if ($(".selected_livesearch_resultItem").size() == 0) {
         currentSelectionSub = 0;
     }

     //if at top, return to textbox
     if (direction == 'up' && currentSelectionSub == 0) {
         killSearchResultsBox();
         $("#sub_search").focus();
     }

     if (direction == 'up' && currentSelectionSub != -1) {
         if (currentSelectionSub != 0) {
             currentSelectionSub--;
         }
     }
     else if (direction == 'down') {
         currentSelectionSub++;
     }
     setSelectedSub(currentSelectionSub);
 }

 function setSelectedSub(menuitemSub) {
     $(".livesearch_resultItem").removeClass("selected_livesearch_resultItem");
     $(".livesearch_resultItem").eq(menuitemSub).addClass("selected_livesearch_resultItem");
 }



