﻿function btv() {
    var kwds = document.getElementById("kwds").value;
    kwds = kwds.replace(/^\s*|\s*$/g, "");
    if (kwds == "") {
        document.getElementById("kwds").value = "";
        document.getElementById("kwds").focus();
        return (false);
    }
    return (true);
}
function loading() {
    return "<div style='display:block; text-align:center; background-color:white;'><img src='/images/site/tl_wait.gif' /></div>";
}
function loadingsm() {
    return "<div style='display:block; text-align:center; width:100%;'><img src='/images/site/wait_trans.gif' /></div>";
   }
function formatItem(row) {
	var kwdsval = $("#kwds").val();
	var pattern = new RegExp(kwdsval, 'i');
	var result = row[0].replace(pattern, "<u>" + kwdsval + "</u><b>");
	return "<div id=\"indiv\" style=\"color: rgb(29, 81, 136);font-family:Arial,Helvetica,Sans-Serif;;font-size: 16px\" onclick= \"location.href=\'/resultsgeneral.aspx?kwds=" + encodeURIComponent(row[0].replace("'", "")) + "&sb=1\';\"  >" + result + "</b></div>";
}
function goevs(d, data) {
    $("#" + d).html("<div id=\"loading_box\" style=\"width:548px;text-align:center;\"><img src=\"/images/site/tl_wait.gif\" /><br />loading...</div>").load("/tix/ajax.aspx?at=ev&" + data);
}
function gup(name) {
    name = name.replace(/[[]/, "\[").replace(/[]]/, "\]");
    var regexS = "[\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null) { return ""; }
    else { return results[1]; }
}
function goalert(fname, email, zip, cid) {
    document.getElementById('tlalmsg').innerHTML = loading();
    var f = document.getElementById(fname).value.replace(">", "").replace("<", "");
    var e = document.getElementById(email).value.replace(">", "").replace("<", "");
    var z = document.getElementById(zip).value.replace(">", "").replace("<", "");
    var c = document.getElementById(cid)[document.getElementById(cid).selectedIndex].value;
    var cn = document.getElementById(cid).options[document.getElementById(cid).selectedIndex].text;
    $.ajax({
        type: "POST",
        url: "/tix/ajax.aspx",
        data: "at=tlal&fname=" + f + "&email=" + e + "&zip=" + z + "&cid=" + c + "&ctry=" + cn,
        dataType: "html",
        success: function(data) {
            $("div#tlalmsg").html(data);
            if (data.toString().toUpperCase().indexOf("THANKS") > -1 || data.toString().toUpperCase().indexOf("JOIN") > -1 || data.toString().toUpperCase().indexOf("ALREADY") > -1) {
                document.getElementById(fname).value = "";
                document.getElementById(email).value = "";
                document.getElementById(zip).value = "";
                $("div#tlalmsg").css({ padding: "5px" });
                if (document.getElementById("TL_Alert_Wrapper_Tall")) {
                    $("div#TL_Alert_Wrapper_Tall").slideUp("slow").hide();
                }
                else{
                    $("div#TL_Alert_Wrapper_Wide").slideUp("slow").hide();
                }
            }
        },
        error: function(xhr, err) { alert("Error: " + err); }
    });
}
function goalertsimple(fname, email) {
	document.getElementById('tlalmsg').innerHTML = loading();
	var f = document.getElementById(fname).value.replace(">", "").replace("<", "");
	var e = document.getElementById(email).value.replace(">", "").replace("<", "");
	$.ajax({
		type: "POST",
		url: "/tix/ajax.aspx",
		data: "at=tlals&fname=" + f + "&email=" + e,
		dataType: "html",
		success: function (data) {
      		$("div#tlalmsg").html(data);
			if (data.toString().toUpperCase().indexOf("THANKS") > -1 || data.toString().toUpperCase().indexOf("JOIN") > -1 || data.toString().toUpperCase().indexOf("ALREADY") > -1) {
      			document.getElementById(fname).value = "";
      			document.getElementById(email).value = "";
      			$("div#tlalmsg").css({ padding: "5px" });
      			if (document.getElementById("TL_Alert_Wrapper_Small")) {
      				$("div#TL_Alert_Wrapper_Small").slideUp("slow").hide();
      			}
      		}
		},
		error: function (xhr, err) { alert("Error: " + err); }
	});
}
function goalert2(fname, email, zip, cid, ctry, mem) {
    $.ajax({
        type: "POST",
        url: "/tix/ajax.aspx",
        data: "at=tlal&fname=" + fname + "&email=" + email + "&zip=" + zip + "&cid=" + cid + "&ctry=" + ctry + "&mem=" + mem,
        dataType: "html",
        success: function(data) {
            $("div#tlalmsg2").html(data);
            if (data.toString().toUpperCase().indexOf("THANKS") > -1 || data.toString().toUpperCase().indexOf("JOIN") > -1 || data.toString().toUpperCase().indexOf("ALREADY") > -1) {
                $("#TL_Alert_Wrapper_Big").slideUp("slow").hide();
            }
        },
        error: function (xhr, err) {
            alert("Error: " + err);
            $('#intro_error').html('<br /><b style="color:red;">There has been an error, please try again!</b><br /><br />');
        }
    });
}
//for sweepstakes form (http://www.ticketliquidator.com/sweepstakes.aspx)
function goalert3(fname, email, zip, cid, ctry, mem, sport, concert, theater) {
    $.ajax({
        type: "POST",
        url: "/tix/ajax.aspx",
        data: "at=tlal&fname=" + fname + "&email=" + email + "&zip=" + zip + "&cid=" + cid + "&ctry=" + ctry + "&mem=" + mem + "&sport=" + (sport ? "true" : "false") + "&concert=" + (concert ? "true" : "false") + "&theater=" + (theater ? "true" : "false"),
        dataType: "html",
        success: function (data) {
            if (data.toString().indexOf("Thanks") > -1 || data.toString().indexOf("already") > -1) {
                $("div#tlalmsg2").html('<table id="frmS"><tbody><tr><td class="f">&nbsp;<!-- success thanks --></td><td class="s">Thanks! We\'ve received your Sweepstakes entry.</td></tr></tbody></table>');
                $("#TL_Alert_Wrapper_Sweeps").slideUp("slow").hide();
            }
            else { $("div#tlalmsg2").html(data); } //error message
        },
        error: function (xhr, err) {
            alert("Error: " + err);
            $('div#tlalmsg2').html('<br /><b style="color:red;">There has been an error, please try again!</b><br /><br />');
        }
    });
}
function signupBigTipster(mem) {
    document.getElementById('tlalmsg2').innerHTML = loading();
    $('#intro_error').html('');
    var f = document.getElementById('tltpst_fname').value;
    var e = document.getElementById('tltpst_email').value;
    var z = document.getElementById('tltpst_zip').value;
    var c = document.getElementById('tltpst_country')[document.getElementById('tltpst_country').selectedIndex].value;
    var cn = document.getElementById('tltpst_country').options[document.getElementById('tltpst_country').selectedIndex].text;
    goalert2(f, e, z, c, cn, mem);
}
function signupTipsterSweeps(mem) {
    document.getElementById('tlalmsg2').innerHTML = loading();
    var f = document.getElementById('tlal_fname').value;
    var e = document.getElementById('tlal_email').value;
    var z = document.getElementById('tlal_zip').value;
	var c = 217;
    var cn = 'United States of America';
    var p1 = document.getElementById('tlal_sports').checked;
    var p2 = document.getElementById('tlal_concerts').checked;
    var p3 = document.getElementById('tlal_theater').checked;
    goalert3(f, e, z, c, cn, mem, p1, p2, p3);
}
function gosuggests(cat, loc) {
    var c = document.getElementById(cat)[document.getElementById(cat).selectedIndex];
    var l = document.getElementById(loc)[document.getElementById(loc).selectedIndex];
    if (c.value == "0" && l.value == "0") { document.getElementById("tlsmsg").innerHTML = "<table id='frmE' style='width:130px; margin-left:10px;'><tr><td class='f'>&nbsp;</td><td class='s' align='left'>Please select a category and location.</td></tr></table>"; return; }
    else if (c.value == "0" && l.value != "0") { document.getElementById("tlsmsg").innerHTML = "<table id='frmE' style='width:130px; margin-left:10px;'><tr><td class='f'>&nbsp;</td><td class='s' align='left'>Please select a category.</td></tr></table>"; return; }
    else if (c.value != "0" && l.value == "0") { document.getElementById("tlsmsg").innerHTML = "<table id='frmE' style='width:130px; margin-left:10px;'><tr><td class='f'>&nbsp;</td><td class='s' align='left'>Please select a location.</td></tr></table>"; return; }
    else {
        document.getElementById("tlsmsg").innerHTML = "";
        var url = "/resultsgeneral.aspx?kwds=&pcatid=" + c.value + "&city=" + l.innerHTML + "&ICID=tlsuggests";
        window.location = url;
    }
      }
/*Gift Center*/
function updateCityUSLbl(cid) {
	if (cid == 217) {
		$('#cityForUSlbl').show();
		$('#cityForUSimg').show();
	}
	else {
		$('#cityForUSlbl').hide();
		$('#cityForUSimg').hide();
	}
}
function loadAdvSearch() {
    var dates = $("#dtstart, #dtend").datepicker({
        constrainInput: true,
        minDate: 0,
        maxDate: "+1y",
        changeMonth: true,
        changeYear: true,
        showOn: "both",
        buttonImage: "/images/site/calendar_icon.gif",
        buttonText: "",
        prevText: "",
        nextText: "",
        hideIfNoPrevNext: true,
        buttonImageOnly: true,
        onSelect: function (selectedDate) {
            var option = this.id == "dtstart" ? "minDate" : "maxDate",
                instance = $(this).data("datepicker");
            var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }
    });
	$("#dtstart").datepicker("option", "defaultDate", 0);
    $("#dtstart").datepicker("option", "buttonText", "Select Start Date");
    $("#dtend").datepicker("option", "defaultDate", "+2w");
    $("#dtend").datepicker("option", "buttonText", "Select End Date");
    $("#statereq").val("no");
    $("#zipreq").val("no");
}
function populateStates(ctryID) {
    if (ctryID && ctryID > 0) {
        document.getElementById('stateSelect').innerHTML = loadingsm();
        document.getElementById('citySelect').innerHTML = "";
        $("#zipreq").val("no");
        $.ajax({
            type: "POST",
            url: "/tix/ajax.aspx",
            data: "at=state&cid=" + ctryID,
            dataType: "html",
            success: function (data) {
                if (data.length > 0) {
                    $("#stateSelect").html("<select id=\"state\" name=\"state\">" + data + "<\/select>");
                    $("#state").change(function () { populateCities($('#country').val(), $(this).val()); });
                    $("#statereq").val("yes");
                }
                else {
                    $("#stateSelect").html("");
                    populateCities($('#country').val(), -1);
                    $("#statereq").val("no");
                }
            },
            error: function (xhr, err) {
                alert("Error: " + err);
                $('#stateSelect').html('<b style="color:red;">There has been an error, please try again!</b>');
            }
        });
    }
}

function populateCities(ctryID, stateID) {
    if (ctryID && ctryID > 0 && stateID && (stateID == -1 || stateID > 0)) {
        document.getElementById('citySelect').innerHTML = loadingsm();
        $.ajax({
            type: "POST",
            url: "/tix/ajax.aspx",
            data: "at=city&cid=" + ctryID + "&sid=" + stateID,
            dataType: "html",
            success: function (data) {
                if (data.length > 0) {
                    if (ctryID != 217) {
                    	document.getElementById('citySelect').style.display = 'block';
                        $("#citySelect").html("<br /><select id=\"city\" name=\"city\">" + data + "<\/select>");
                    }
                    else {
                        $("#citySelect").html("<select id=\"city\" name=\"city\">" + data + "<\/select>");
                    }
                    $("#zipreq").val("yes");
                }
                else {
                    $("#citySelect").html("");
                    $("#zipreq").val("no");
                }
            },
            error: function (xhr, err) {
                alert("Error: " + err);
                $('#citySelect').html('<b style="color:red;">There has been an error, please try again!</b>');
            }
        });
    }
}
function addToFavorites() {
    if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1 || navigator.userAgent.toLowerCase().indexOf('safari') > -1) {
        alert("Please press Ctrl D to bookmark this page.");
    }
    else {
        var pageUrl = location.href;
        if (pageUrl.indexOf('?') != -1) {
            if (pageUrl.indexOf('utm_source') < 0) {
                pageUrl += "&utm_source=bookmark&utm_nooveride=1";
            }
        }
        else {
            pageUrl += "?utm_source=bookmark&utm_nooveride=1";
        }
        if (document.all) {
            window.external.AddFavorite(pageUrl, document.title);
        }
        else if (window.sidebar) {
            window.sidebar.addPanel(document.title, pageUrl, "");
        }
    }
    
}
function mailpage() {
    var subject = "Check out " + document.title.replace(/&nbsp;/g, " ");
    var body = "I thought you might be interested in " + document.title
        + ". You can view the tickets at: " + location.href + ((location.href.indexOf('?') > -1) ? "&" : "?") + "utm_source=email&utm_medium=emailThis";
    location.href = "mailto:?subject=" + escape(subject) + "&body=" + escape(body);
}
function mailDefaultPage() {
    var subject = "Check out " + document.title.replace(/&nbsp;/g, " ");
    var body = "I thought you might be interested in this page from TicketLiquidator. You can view it at: " 
        + location.href + ((location.href.indexOf('?') > -1) ? "&" : "?") + "utm_source=email&utm_medium=emailThis";
    location.href = "mailto:?subject=" + escape(subject) + "&body=" + escape(body);
}
function GetValueFromQuerystring(name) {
    var tmp = (location.search.substring(1));
    var i = tmp.toUpperCase().indexOf(name.toUpperCase() + "=");
    if (i >= 0) {
        tmp = tmp.substring(name.length + i + 1);
        i = tmp.indexOf("&");
        return unescape(tmp.substring(0, (i >= 0) ? i : tmp.length));
    }
    return ("");
}
function makeGuid() {
    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
    var guid_length = 5;
    var guid = '';
    for (var i = 0; i < guid_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        guid += chars.substring(rnum, rnum + 1);
    }
    return guid;
}
function b(es, q, sid) {
    return "https://secure.ticketliquidator.com/Checkout.aspx?e=" + es + "&treq=" + q + "&SessionID=" + sid;
}
function b2(es, q, sid, xtra) {
    return tl_mrt_domain + "/Login/Checkout/?e=" + es + "&treq=" + q + "&SessionID=" + sid + xtra;
}
function b3(h, es, q, sid, xtra, mid) {
    return "https://" + h + ".ticketliquidator.com/Checkout.aspx?e=" + es + "&treq=" + q + "&SessionID=" + sid + "&mid=" + mid + xtra;
}
function buyTickets(buyObj) {
    window.location = b2(buyObj.tgSds, buyObj.buyQty, makeGuid(), c2.added + "&h=" + buyObj.tgMark);
}
//for cannonicalized section names
function buyTixSecFunc(buyObj) {
	var u;
    if (buyObj.mid) {
        u = b3(c2.subdomain, buyObj.tgSds, buyObj.buyQty, makeGuid(), c2.added, encodeURIComponent(buyObj.mid));
    }
    else {
        u = b2(buyObj.tgSds, buyObj.buyQty, makeGuid(), c2.added);
    }
    window.location = u;
}
function AppendToPurchaseUrl(inUrl) {
    var outUrl = inUrl;
    return outUrl;
}
function SubmitPurchaseLinkForGiftCard(idNum, qstring) {
    var guidToAdd = makeGuid();
    var QSSession = GetValueFromQuerystring("SessionId");
    if (QSSession != "") { guidToAdd = QSSession; }
    var purchaseUrl = b(qstring, "1", guidToAdd);
    location.href = purchaseUrl;
}
function buy(idNum, qstring) {
    var guidToAdd = makeGuid();
    var QSSession = GetValueFromQuerystring("SessionId");
    if (QSSession != "") { guidToAdd = QSSession; }
    var requestSelect = document.getElementById(idNum);
    var ticketsRequested = requestSelect.options[requestSelect.selectedIndex].innerHTML;
    var purchaseUrl = b(qstring, ticketsRequested, guidToAdd);
    location.href = purchaseUrl;
}
function ToShowToHide(show, hide) {
    document.getElementById(show).style.display = 'block';
    document.getElementById(hide).style.display = 'none';
    window.scrollTo(0, 0);
}
function toggle(id) {
    $(id).toggle();
    return false;
}
var comments = new Array(
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;The tickets arrived exactly when they were supposed to and I really appreciated the extra info (weather, restaurants, directions). I will definitely be buying tickets from you guys in the future and recommending your services to others!!!&nbsp;<br />-Brigitte Z.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;What a pleasure to order from your site. From being secure to user-friendly, this made for easy ordering. My compliments to you!&nbsp;<br />- Lynn</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;I just wanted to take the time to extend my sincerest forms of gratitude to your company for the exemplar service your have provided me. This is the first time I have purchased tickets from TicketLiquidator and the experience has been nothing but excellent.&nbsp;<br />- Amy M.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;I thank you very much for a great experience and the helpful info you sent a few days before the game, and I am looking forward to doing business with your company in the future.&nbsp;<br />- Eric G.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;I was hesitant to purchase from you, but you have all gone the extra mile to make this experience quick and pleasant. Our tickets arrived quickly and the follow-up email with directions and dining suggestions and the weather was a very nice touch. I will recommend you to everyone looking for tickets. Thanks.&nbsp;<br />- Wanda</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;Delivery was extremely quick. And follow-up was very nice! I'd recommend this site to any one looking for great deals on any event!&nbsp;<br />- Anonymous</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;I can't tell you how pleased I am with Ticketliquator ! I have used your site three times and each time, received super fast, professional service. Seats have always been exactly as advertised on the site. I will continue to use Ticketliquidator as my first choice for premium tickets and recommend it highly!&nbsp;<br />- Christina M.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;I just received an e-mail from Molly Duncan detailing directions, weather forecast, and restaurant options associated with our tickets to the Fiesta Bowl. What a nice touch!&nbsp;<br />- Richard</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;Very accurate and good quality service. Thank you very much.&nbsp;<br />- Anonymous</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;Thank you so much for great tickets for a really great game. I enjoyed it soooo much.&nbsp;<br />- Jennifer</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;The tickets arrived in ample time for the game and were exactly as stated and the seats were great. It was my first time at a home Redskins game and the experience was exceptional. I will continue to use and recommend ticket liquidator to my friends. Thanks again.&nbsp <br />- Reilly</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;I just used Ticket Liquidator for the first time and will definitely be using it again. I'll also recommend it to my friends. The process was easy and the tickets arrived quickly. I liked the extra touches afterwards - the maps and dining tips, etc. Thanks for the great service!!!&nbsp;<br />- Karen L.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;Thanks for the most amazing night of my life. My tickets were cheaper than anyone else's and they came quickly to me. The added bonus of the extra tickets made me look like the coolest guy there as I took all of my friends with me. Thanks again!!!&nbsp;<br />- Brian H.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;We had great seats and a wonderful time! Thank you!&nbsp;<br />- Diana</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;This service is great!!!Ordering the tickets was easy and they were delivered so quickly.&nbsp;<br />- Kim T.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;All I can say, You guys rock!!!!!!!!!! You made my 6 year old a happy little dude. I found the pricing to be fair and reasonable. The tickets were prompt and the little extra care given about dining around that area, weather and all other pertinent info was really cool as I had moved to the area recently and had no clue on how to get there, or where to eat. Keep up the good work.&nbsp;<br />- David C.</p>",
    "<p><img src='/images/site/tl-openquote-22x18.gif' />&nbsp;The customer service was wonderful! The company you directed me to for ordering tickets was fantastic. I needed my ticket on time and they made sure it got to me!! This was a great experience for me and I will use you again. I highly recommend you guys! You got me to the people who got me a ticket when nobody else could!! Sold out was all I heard. You came through for me!! You are very professional and run a well-managed operation. Many thanks!&nbsp;<br />- Marlene D.</p>"
);
var newwindow;
function poptastic(url, h, w) { newwindow = window.open(url, 'name', 'height=' + h + ',width=' + w); }

// mbox test
/*
case 1 = old design
case 2 = new design
case 3 = new design + dropdown
case 4 = new design + dropdown + geo
*/
var concertlistTest;
var sportsTest;
var theaterTest;
var defaultTest;

function isSet(variable) {
    return (typeof (variable) != 'undefined'); 
}
function defaultPageLoading() {
    return "<div style='min-height:400px;width:600px;text-align:center;margin-top:15px;background:url(/images/site/tl_wait.gif) no-repeat 50% 0;'></div>"; 
}
function defaultPageTest(p, city) {
    //----- start setup
    var page = p.toLowerCase();
    var testvar = page + "Test";
    var ddSp = "city_select_inner_" + page;
    var dv = page + "DefaultInfo";
    if (isSet(testvar) && document.getElementById(dv) != null) {
        var test = eval(testvar);
        //------end
        if (test == '2' || test == '3' || test == '4') {
            $("#" + dv).show();
            $("#" + dv + "Browse").show();
            if (test == '3' || test == '4') {
                var dd = 'city_select';
                if (test == '4' && city != null) {
                    var d = document.getElementById(dd).options; for (var i = 0; i < d.length; i++) { if (d[i].value.toLowerCase() == city) { d[i].selected = true; break; } }
                }
                // if selected, get city
                if (document.getElementById(dd)) { var v = document.getElementById(dd)[document.getElementById(dd).selectedIndex].value; if (v != "") { gocity(dd, p); } }

                $('#' + ddSp).show();
            } //end if 3|4

        } //end if 2|3|4
        // case 1 or fall through
        else { $('#' + dv + "Old").show(); }
        if (document.getElementById("dp_loading")) { $("#dp_loading").hide(); }
    } //end isSet
}
function gocity(id, f) {
    if (document.getElementById(id) && document.getElementById(f + "DefaultInfoCity")) {
        var v = document.getElementById(id)[document.getElementById(id).selectedIndex].value;
        if (v == "default") {
            $("div#" + f + "DefaultInfo").show();
            $("div#" + f + "DefaultInfoCity").hide();
            return;
        }
        $.ajax({
            url: "/tix/ajax.aspx",
            data: "at=def&city=" + v + "&f=" + f,
            dataType: "html",
            success: function(data) {
                $("div#" + f + "DefaultInfoCity").html("<div style='vertical-align:top;'>" + data + "</div>").show();
                $("div#" + f + "DefaultInfo").hide();
            },
            error: function(xhr, err) { alert("Error: " + err); }
        });
    }
}
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) { endstr = document.cookie.length; }

    return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal(j);

        i = document.cookie.indexOf(" ", i) + 1;

        if (i == 0) break;
    }
    return null;
}
function CancelUpdate() {
    var confirmed = confirm("Do you really want to cancel your updates?\r\nClick OK to cancel any unsaved changes and return to the TicketLiquidator home page.\r\nClick Cancel to continue editing your preferences.");
    if (confirmed) {
        window.location = "/default.aspx";
    }
}
//-------------------------------- browser class
var Browser = {
    init: function(nav, win) {
        //'private' members
        this.navigator = nav;
        this.nindow = win;
        ///public
        this.Name = this.searchString(this.dataBrowser) || "An unknown browser";
        this.Version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";

    },
    Version: function(nav, win) {
        Browser.init(nav, win);
    	return (Browser.Name + Browser.Version).toLowerCase();
    },
    searchString: function(data) {
    	for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    	return '';
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return -1;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [{
        string: this.navigator.userAgent,
        subString: "Chrome",
        identity: "Chrome"
        }, {
        string: this.navigator.vendor,
        subString: "Apple",
        identity: "Safari",
        versionSearch: "Version"
        }, {
        prop: this.window.opera,
        identity: "Opera"
        }, {
        string: this.navigator.vendor,
        subString: "KDE",
        identity: "Konqueror"
        }, {
        string: this.navigator.userAgent,
        subString: "Firefox",
        identity: "Firefox"
        }, {
        string: this.navigator.userAgent,
        subString: "Netscape",
        identity: "Netscape"
        }, {
        string: this.navigator.userAgent,
        subString: "MSIE",
        identity: "IE",
        versionSearch: "MSIE"
	    }, {
        string: this.navigator.userAgent,
        subString: "Mozilla",
        identity: "Netscape",
        versionSearch: "Mozilla"
    }],
    dataOS: [{
        string: this.navigator.platform,
        subString: "Win",
        identity: "Windows"
        }, {
        string: navigator.platform,
        subString: "Mac",
        identity: "Mac"
        }, {
        string: this.navigator.userAgent,
        subString: "iPhone",
        identity: "iPhone/iPod"
        }, {
        string: this.navigator.platform,
        subString: "Linux",
        identity: "Linux"
	}]
};
//------------------Venue Maps
//Control
function TLfilterHTML(criteria) {
    ssc.tt("TL Filter-Start: width=" + $("#ssc_filterDiv").width());
    var selList = '<table class="ssc_filterTbl" border="0" cellpadding="0" cellspacing="0">',
    i,
    px,
    qtyIntro = '<span class="ssc_qtyAsk">How many tickets would you like?</span>',
    priceIntro = '<span class="ssc_priceAsk">What\'s your price range?</span>',
    qtyFollow = "";

    selList += '<tr><td style="padding-bottom:5px;"><b id="ssc_narrow">Narrow Your Search</b>';

	//build "show All" link    
    if (criteria.reqQty || criteria.minPrice || criteria.maxPrice || criteria.selectedMapSections) {
        selList += '<a id="ssc_resetBtn" onClick="$(\'#ssc_reqQtySel\').attr(\'selectedIndex\', 0); '
        + '$(\'#ssc_maxPriceSel\').attr(\'selectedIndex\', 0); '
        + '$(\'#ssc_minPriceSel\').attr(\'selectedIndex\', 0); '
        + 'ssc.setMapOptions(\'clearSectionSelect=*\'); ' 
        + ((typeof ssc.vfsClose == "function") ? 'ssc.vfsClose(); ' : '') //Nick
        + 'ssc.criteriaChanged(\'MinPrice=0&MaxPrice=0&ReqQty=0\');">'
		+ 'Show all tickets for this event</a>';
    }

    selList += '</td></tr><tr><td style="padding-left:5px;">';
    selList += qtyIntro + ' <select size="1" id="ssc_reqQtySel" onchange="ssc.criteriaChanged(\'ReqQty=\'+this.value)">'
        + '<option value="0"' + ((criteria.reqQty == 0) ? " selected" : "") + '>Select your quantity</option>';
    for (i = 1; i <= criteria.hiQty; i++) {
    	if (i == criteria.hiQty - 1 && i != criteria.hiQtyNxt) { continue; }
    	selList += '<option class="ssc_qtyValues" value="' + i + '" ' + ((criteria.reqQty == i) ? "selected" : "") + '>' + i + '</option>';
    }
    
	selList += '</select>' + qtyFollow + '</td></tr><tr><td style="padding-left:5px;">';

    // build min and max price combos
    if (criteria.minPrice != 0 || criteria.maxPrice != 0) {
    }
    // Build No minimum (top ) entry
    selList += priceIntro + '&nbsp;' + '<select size="1" id="ssc_minPriceSel" onchange="ssc.criteriaChanged(\'MinPrice=\' + this.value);">\n'
        + '<option value="0" ' + ((criteria.minPrice == 0) ? "selected" : "") + '>No minimum</option>\n';
    for (px = 1; px < criteria.okPricePoints.length; px++) {
        if (criteria.loPricePoints[px] && (criteria.okPricePoints[px] < criteria.maxPrice || criteria.maxPrice == 0)) {
        	selList += '<option class="ssc_priceValues" value="' + criteria.okPricePoints[px] + '" '
                + ((criteria.minPrice == criteria.okPricePoints[px]) ? "selected" : "")
                + '>' + criteria.currencySymbol + criteria.okPricePoints[px] + '</option>\n';
        }
    }
    selList += '</select>';

    // build Max price combo
    selList += '&nbsp;to&nbsp;' + '<select size="1" id="ssc_maxPriceSel" onchange="ssc.criteriaChanged(\'MaxPrice=\'+ this.value);">\n'
        + '<option value="0" ' + ((criteria.maxPrice == 0) ? "selected" : "") + '>No maximum</option>\n';

    for (px = 1; px < criteria.okPricePoints.length; px++) {
        if (criteria.hiPricePoints[px] && criteria.okPricePoints[px] > criteria.minPrice) {
        	selList += '<option class="ssc_priceValues" value="' + criteria.okPricePoints[px] + '" '
                + ((criteria.maxPrice == criteria.okPricePoints[px]) ? "selected" : "")
                + '>' + criteria.currencySymbol + criteria.okPricePoints[px] + '</option>\n';
        }
    }
    selList += '</select></td></tr></table>';
    ssc.tt(" TLFilter-End.");
    return selList;
}
tlHeaderRowHTML = function (criteria) {
    return '<table class="ssc_lhTable" cellspacing="0" cellpadding="0">' +
	'<tr valign="bottom">' +
    '<td class="ssc_lhSec" onclick="ssc.sortTgList(\'sec\');" title="' + criteria.dText.secSrtH1 + '">Section' + criteria.columnSortArrows['SEC'] + '</td>' +
	'<td class="ssc_lhRow" onclick="ssc.sortTgList(\'row\')">Row' + criteria.columnSortArrows['ROW'] + '</td>' +
	'<td class="ssc_lhQty" onclick="ssc.sortTgList(\'qty\')">Quantity' + criteria.columnSortArrows['QTY'] + '</td>' +
	'<td class="ssc_lhPri" onclick="ssc.sortTgList(\'price\')">Price (each)' + criteria.columnSortArrows['PRICE'] + '</td>' +
	'<td class="ssc_lhBuy"></td></tr>' +
	'</table>';
};
tlListRowHTML = function (criteria, tgIndex, tg) {
	var buyQty;
	var dispQty;
	var qP1Class = "";
	var showNotes = tg.tgNotes != "";
	var rowSpan = ' rowspan="' + (showNotes ? 2 : 1) + '"';
	dispQty = (tg.tgQty + " left");
	if (criteria.reqQty <= 0 || tg.tgCritGroup >= 2) {
		buyQty = /1|3/.test(tg.tgQty) ? 1 : 2;
	} else {
		dispQty = criteria.reqQty;
		if (tg.tgCritGroup == 1) {
			qP1Class = "Plus1";
			dispQty++;
		}
		buyQty = dispQty;
	}
	return '<table class="ssc_lrTable" cellpadding="0" cellspacing="0">' +
           "<tr>" +
            (criteria.tgMarks[0] ? // just check for first (hdr/dflt) mark being defined (array is set to [] if style not present.
             '<td class="ssc_lrMark"' + rowSpan + ">" + (Number(tg.tgMark) ? (criteria.tgMarks[Number(tg.tgMark)] || criteria.tgMarks[1] || criteria.tgMarks[0]) : "") + "</td>"
            :
            "") +
	        '<td class="ssc_lrSec">' +
	        ((criteria.showStdSectionNames && tg.tgOnMap && tg.mapSectionLevel) ? tg.mapSectionLevel + " " + tg.mapSectionNumber : tg.tgUserSec) +
	        "</td>" +
		    '<td class="ssc_lrRow">' + tg.tgUserRow + "</td>" +
		    '<td class="ssc_lrQty"' + qP1Class + '">' + dispQty + "</td>" +
		    '<td class="ssc_lrPri">' + criteria.currencySymbol + tg.tgPrice + "</td>" +
		    '<td class="ssc_lrBuy"' + rowSpan + ">" +
			'<input type="button" class="ssc_lrBuyBtn" onclick="ssc.buyClicked(' + tgIndex + "," + buyQty + ')" id="ssc_BB_' + tgIndex + '" value="Buy"></td>' +
		    "</tr>" +
            ((showNotes) ? "<tr>" + '<td class="ssc_lrNotes" colspan="4"><b>Seller\'s Note</b>: ' + tg.tgNotes + "</td></tr>" : "") +
            "</table>";
};
function getMapGroupLabelsTL(criteria) {
    var lbls = [];
    lbls[0] = {};
    lbls[0].type = "#tkts";
    lbls[0].pattern = ["No tickets available in this section", "Ticket available at {low} in this section", "Tickets available from {low} and up in this section"];
    lbls[0].fontSize = '16';
    lbls[0].index = -1;
    return lbls;
}
function proSport(p, c, g) {
    if ((p == 1) && (c == 63 || c == 65 || c == 66 || c == 68) && (g == 16 || g == 32 || g == 30 || g == 19)) { return true; }
    else { return false; }
}
function collegeSport(p, c, g) {
    if ((p == 1) && (c == 65 || c == 66) && (g == 17)) { return true; }
    else { return false; }
}
function hasErr(ah) {
    var x = ["MfS", "MfE", "MnF", "MnI", "MfX", "Mot"];
    for (var i = 0; i < x.length; i++) {
        if (ah.indexOf(x[i]) > -1) { return true; }
    }
    return false;
}
function getMapType(o) {
    switch (o.mapStatus) {
        case 2:
            //real interactive map is displayed
            $('#li_map_help').show();
            if (o.vfsImageSet != '') { $('#sv1').show(); }
            else { $('#sv1').hide(); }
            break;
        case 1:
            //map has been dumbed down to zoom-pan because TG hit rate is below threshold
            $('#li_map_help').hide();
            //show VFS as a bullet point since the interactive help is hidden
            if (o.vfsImageSet != '') { $('#sv2').show(); }
            break;
        default:
            //plain static map is displayed; value can be any range of negative numbers
            flashMapUrl = '';
            $('#li_map_help').hide();
            break;
    }
    if (hasErr(ssc.actionHistory)) {
        $('#li_map_help').hide();
        $('#sv1').hide();
        $('#sv2').hide();
    }
}
//------------------TL Alert Signup
function dft(id, str) {
    if (document.getElementById(id).value == str) {
        document.getElementById(id).value = "";
        document.getElementById(id).style.color = "#000";
    }
}
function blr(obj, orig) {
    var x = $.trim(obj.value);
    if (x == "" || x == orig) {
        obj.value = orig;
        obj.style.color = "#666";
    }
    else {
        obj.style.color = "#000";
    }
}
//------------------Widget Makers
//STRING FIXER
String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
};

function Fixer(term) {
    return term.trim()
        // blankspace
        .replace(/ /g, "-")
        // double quote "
        .replace(/\"/g, "")
        // forward slash /
        .replace(/\//g, " ")
        // backslash \
        .replace(/\\/g, "")
        //colon :
        .replace(/\:/g, " ")
        //comma ,
        .replace(/\,/g, " ")
        // question mark ?
        .replace(/\?/g, "")
        // period .
        .replace(/\./g, "")
        // apostrophe '
        .replace(/\'/g, "")
        // semi colon
        .replace(/\;/g, "")
        // ampersand &
        .replace(/\&/g, "")
        // 5 hyphens -----
        .replace(/-----/g, "-")
        // 4 hyphens -----
        .replace(/----/g, "-")
        // 3 hyphens -----
        .replace(/---/g, "-")
        // 2 hyphens -----
        .replace(/--/g, "-")
        // open parenthesis
        .replace(/\(/g, "")
        // close parenthesis
        .replace(/\)/g, "")
        // exclamation point !
        .replace(/\!/g, "")
        // at @
        .replace(/\@/g, "")
        // octothorpe #
        .replace(/\#/g, "")
        //dollar sign $
        .replace(/\$/g, "")
        // percent sign %
        .replace(/\%/g, "")
        // carat ^
        .replace(/\^/g, "")
        // asterisk *
        .replace(/\*/g, "")
        //plus sign +
        .replace(/\+/g, "")
        //equals sign =
        .replace(/\=/g, "")
        // back tick `
        .replace(/\`/g, "")
        // tilde ~
        .replace(/\~/g, "")
        // close tag >
        .replace(/\>/g, "")
        // open tag <
        .replace(/\</g, "")
        // underscore _
        .replace(/\_/g, " ")
        //open bracket [
        .replace(/\[/g, "")
        //close bracket [
        .replace(/\]/g, "")
        //open brace {
        .replace(/{/g, "")
        //close brace {
        .replace(/\}/g, "")
        // pipe
        .replace(/\|/g, "");
}
//COLOR PICKER
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
/* SOURCE FILE: AnchorPosition.js */
function getAnchorPosition(anchorname) {
    // This function will return an Object with x and y properties
    var coordinates = new Object();
    var x, y;
    // Browser capability sniffing
    var use_gebi = false, use_css = false, use_layers = false;
    if (document.getElementById) { use_gebi = true; }
    else if (document.all) { use_css = true; }
    else if (document.layers) { use_layers = true; }

    // Logic to find position
    if (use_gebi) {
        var o = document.getElementById(anchorname);
        x = AnchorPosition_getPageOffsetLeft(o);
        y = AnchorPosition_getPageOffsetTop(o);
    }
    else if (use_css) {
        x = AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
        y = AnchorPosition_getPageOffsetTop(document.all[anchorname]);
    }
    else if (use_layers) {
        var found = 0;
        for (var i = 0; i < document.anchors.length; i++) {
            if (document.anchors[i].name == anchorname) { found = 1; break; }
        }
        if (found == 0) {
            coordinates.x = 0; coordinates.y = 0; return coordinates;
        }
        x = document.anchors[i].x;
        y = document.anchors[i].y;
    }
    else {
        coordinates.x = 0; coordinates.y = 0; return coordinates;
    }
    coordinates.x = x;
    coordinates.y = y;
    return coordinates;
}
function getAnchorWindowPosition(anchorname) {
    var coordinates = getAnchorPosition(anchorname); var x = 0; var y = 0; if (document.getElementById) { if (isNaN(window.screenX)) { x = coordinates.x - document.body.scrollLeft + window.screenLeft; y = coordinates.y - document.body.scrollTop + window.screenTop; } else { x = coordinates.x + window.screenX + (window.outerWidth - window.innerWidth) - window.pageXOffset; y = coordinates.y + window.screenY + (window.outerHeight - 24 - window.innerHeight) - window.pageYOffset; } } else if (document.all) { x = coordinates.x - document.body.scrollLeft + window.screenLeft; y = coordinates.y - document.body.scrollTop + window.screenTop; } else if (document.layers) { x = coordinates.x + window.screenX + (window.outerWidth - window.innerWidth) - window.pageXOffset; y = coordinates.y + window.screenY + (window.outerHeight - 24 - window.innerHeight) - window.pageYOffset; } coordinates.x = x; coordinates.y = y; return coordinates; 
}
function AnchorPosition_getPageOffsetLeft(el) {
    var ol = el.offsetLeft; while ((el = el.offsetParent) != null) { ol += el.offsetLeft; } return ol; 
}
function AnchorPosition_getWindowOffsetLeft(el) {
    return AnchorPosition_getPageOffsetLeft(el) - document.body.scrollLeft; 
}
function AnchorPosition_getPageOffsetTop(el) {
    var ot = el.offsetTop; while ((el = el.offsetParent) != null) { ot += el.offsetTop; } return ot; 
}
function AnchorPosition_getWindowOffsetTop(el) {
    return AnchorPosition_getPageOffsetTop(el) - document.body.scrollTop; 
}
/* SOURCE FILE: PopupWindow.js */
function PopupWindow_getXYPosition(anchorname) {
    var coordinates; if (this.type == "WINDOW") { coordinates = getAnchorWindowPosition(anchorname); } else { coordinates = getAnchorPosition(anchorname); } this.x = coordinates.x; this.y = coordinates.y; 
}
function PopupWindow_setSize(width, height) {
    this.width = width; this.height = height; 
}
function PopupWindow_populate(contents) {
    this.contents = contents; this.populated = false;
}
function PopupWindow_setUrl(url) {
    this.url = url;
}
function PopupWindow_setWindowProperties(props) {
    this.windowProperties = props;
}
function PopupWindow_refresh() {
    if (this.divName != null) {
        if (this.use_gebi) {
            document.getElementById(this.divName).innerHTML = this.contents;
        }
        else if (this.use_css) {
            document.all[this.divName].innerHTML = this.contents;
        }
        else if (this.use_layers) {
            var d = document.layers[this.divName];
            d.document.open();
            d.document.writeln(this.contents);
            d.document.close();
        }
    }
    else {
        if (this.popupWindow != null && !this.popupWindow.closed) {
            if (this.url != "") {
                this.popupWindow.location.href = this.url;
            }
            else {
                this.popupWindow.document.open();
                this.popupWindow.document.writeln(this.contents);
                this.popupWindow.document.close();
            }
            this.popupWindow.focus();
        }
    }
}
function PopupWindow_showPopup(anchorname) {
    this.getXYPosition(anchorname);
    this.x += this.offsetX - 150;
    this.y += this.offsetY - 204;
    if (!this.populated && (this.contents != "")) {
        this.populated = true;
        this.refresh();
    }
    if (this.divName != null) {
        // Show the DIV object
        if (this.use_gebi) {
            document.getElementById(this.divName).style.left = this.x + "px";
            document.getElementById(this.divName).style.top = this.y + "px";
            document.getElementById(this.divName).style.visibility = "visible";
        }
        else if (this.use_css) {
            document.all[this.divName].style.left = this.x;
            document.all[this.divName].style.top = this.y;
            document.all[this.divName].style.visibility = "visible";
        }
        else if (this.use_layers) {
            document.layers[this.divName].left = this.x;
            document.layers[this.divName].top = this.y;
            document.layers[this.divName].visibility = "visible";
        }
    }
    else {
        if (this.popupWindow == null || this.popupWindow.closed) {
            // If the popup window will go off-screen, move it so it doesn't
            if (this.x < 0) { this.x = 0; }
            if (this.y < 0) { this.y = 0; }
            if (screen && screen.availHeight) {
                if ((this.y + this.height) > screen.availHeight) {
                    this.y = screen.availHeight - this.height;
                }
            }
            if (screen && screen.availWidth) {
                if ((this.x + this.width) > screen.availWidth) {
                    this.x = screen.availWidth - this.width;
                }
            }
            var avoidAboutBlank = window.opera || (document.layers && !navigator.mimeTypes['*']) || navigator.vendor == 'KDE' || (document.childNodes && !document.all && !navigator.taintEnabled);
            this.popupWindow = window.open(avoidAboutBlank ? "" : "about:blank", "window_" + anchorname, this.windowProperties + ",width=" + this.width + ",height=" + this.height + ",screenX=" + this.x + ",left=" + this.x + ",screenY=" + this.y + ",top=" + this.y + "");
        }
        this.refresh();
    }
}
function PopupWindow_hidePopup() {
    if (this.divName != null) {
        if (this.use_gebi) {
            document.getElementById(this.divName).style.visibility = "hidden";
        }
        else if (this.use_css) {
            document.all[this.divName].style.visibility = "hidden";
        }
        else if (this.use_layers) {
            document.layers[this.divName].visibility = "hidden";
        }
    }
    else {
        if (this.popupWindow && !this.popupWindow.closed) {
            this.popupWindow.close();
            this.popupWindow = null;
        }
    }
}
function PopupWindow_isClicked(e) {
    if (this.divName != null) {
    	var t;
    	if (this.use_layers) {
            var clickX = e.pageX;
            var clickY = e.pageY;
    		t = document.layers[this.divName];
    		if ((clickX > t.left) && (clickX < t.left + t.clip.width) && (clickY > t.top) && (clickY < t.top + t.clip.height)) {
                return true;
            }
            else { return false; }
        }
        else if (document.all) {
    		t = window.event.srcElement;
    		while (t.parentElement != null) {
                if (t.id == this.divName) { return true; }
                t = t.parentElement;
            }
            return false;
        }
        else if (this.use_gebi && e) {
    		t = e.originalTarget;
    		while (t.parentNode != null) {
                if (t.id == this.divName) { return true; }
                t = t.parentNode;
            }
            return false;
        }
        return false;
    }
    return false;
}
function PopupWindow_hideIfNotClicked(e) {
    if (this.autoHideEnabled) { this.hidePopup(); } 
}
function PopupWindow_autoHide() {
    this.autoHideEnabled = true;
}
function PopupWindow_hidePopupWindows(e) {
    for (var i = 0; i < popupWindowObjects.length; i++) {
        if (popupWindowObjects[i] != null) {
            var p = popupWindowObjects[i]; p.hideIfNotClicked(e);
        }
    }
}
function PopupWindow_attachListener() {
    if (document.layers) {
        document.captureEvents(Event.MOUSEUP);
    }
    window.popupWindowOldEventListener = document.onmouseup;
    if (window.popupWindowOldEventListener != null) {
        document.onmouseup = new Function("window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();");
    }
    else {
        document.onmouseup = PopupWindow_hidePopupWindows;
    }
}
function PopupWindow() {
    if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
    if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
    if (!window.listenerAttached) {
        window.listenerAttached = true;
        PopupWindow_attachListener();
    }
    this.index = popupWindowIndex++;
    popupWindowObjects[this.index] = this;
    this.divName = null;
    this.popupWindow = null;
    this.width = 0;
    this.height = 0;
    this.populated = false;
    this.visible = false;
    this.autoHideEnabled = false;

    this.contents = "";
    this.url = "";
    this.windowProperties = "toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
    if (arguments.length > 0) {
        this.type = "DIV";
        this.divName = arguments[0];
    }
    else {
        this.type = "WINDOW";
    }
    this.use_gebi = false;
    this.use_css = false;
    this.use_layers = false;
    if (document.getElementById) { this.use_gebi = true; }
    else if (document.all) { this.use_css = true; }
    else if (document.layers) { this.use_layers = true; }
    else { this.type = "WINDOW"; }
    this.offsetX = 0;
    this.offsetY = 0;
    // Method mappings
    this.getXYPosition = PopupWindow_getXYPosition;
    this.populate = PopupWindow_populate;
    this.setUrl = PopupWindow_setUrl;
    this.setWindowProperties = PopupWindow_setWindowProperties;
    this.refresh = PopupWindow_refresh;
    this.showPopup = PopupWindow_showPopup;
    this.hidePopup = PopupWindow_hidePopup;
    this.setSize = PopupWindow_setSize;
    this.isClicked = PopupWindow_isClicked;
    this.autoHide = PopupWindow_autoHide;
    this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
}
/* SOURCE FILE: ColorPicker2.js */
ColorPicker_targetInput = null;
ColorPicker_dontHide = false;
function ColorPicker_writeDiv() {
    document.writeln("<div id=\"colorPickerDiv\" style=\"position:absolute;visibility:hidden;\"></div>"); 
}
function ColorPicker_show(anchorname) {
    this.showPopup(anchorname); 
}
function ColorPicker_pickColor(color, obj) {
    obj.hidePopup(); pickColor(color);
}
function ColorPicker_select(inputobj, linkname) {
    if (inputobj.type != "text" && inputobj.type != "hidden" && inputobj.type != "textarea") {
        alert("colorpicker.select: Input object passed is not a valid form input object");
        window.ColorPicker_targetInput = null; return;
    }
    window.ColorPicker_targetInput = inputobj; this.show(linkname); 
}
function ColorPicker_highlightColor(c) {
    var thedoc = (arguments.length > 1) ? arguments[1] : window.document;
    var d = thedoc.getElementById("colorPickerSelectedColor");
    d.style.backgroundColor = c;
    d = thedoc.getElementById("colorPickerSelectedColorValue");
    d.innerHTML = c; 
}
function ColorPicker() {
    var windowMode = false;
	var divname;
	if (arguments.length == 0) {
		divname = "colorPickerDiv";
	} else if (arguments[0] == "window") {
		divname = '';
		windowMode = true; }
    else {
		divname = arguments[0];
	}
	var cp;
	if (divname != "") {
		cp = new PopupWindow(divname);
	} else {
		cp = new PopupWindow();
		cp.setSize(225, 250); }
    cp.currentValue = "#FFFFFF";
    cp.writeDiv = ColorPicker_writeDiv;
    cp.highlightColor = ColorPicker_highlightColor;
    cp.show = ColorPicker_show;
    cp.select = ColorPicker_select;
    var colors = new Array(
        "#000000", "#000033", "#000066", "#000099", "#0000CC", "#0000FF", "#330000", "#330033", "#330066", "#330099", "#3300CC",
        "#3300FF", "#660000", "#660033", "#660066", "#660099", "#6600CC", "#6600FF", "#990000", "#990033", "#990066", "#990099",
        "#9900CC", "#9900FF", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#FF0000", "#FF0033", "#FF0066",
        "#FF0099", "#FF00CC", "#FF00FF", "#003300", "#003333", "#003366", "#003399", "#0033CC", "#0033FF", "#333300", "#333333",
        "#333366", "#333399", "#3333CC", "#3333FF", "#663300", "#663333", "#663366", "#663399", "#6633CC", "#6633FF", "#993300",
        "#993333", "#993366", "#993399", "#9933CC", "#9933FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF",
        "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#006600", "#006633", "#006666", "#006699", "#0066CC",
        "#0066FF", "#336600", "#336633", "#336666", "#336699", "#3366CC", "#3366FF", "#666600", "#666633", "#666666", "#666699",
        "#6666CC", "#6666FF", "#996600", "#996633", "#996666", "#996699", "#9966CC", "#9966FF", "#CC6600", "#CC6633", "#CC6666",
        "#CC6699", "#CC66CC", "#CC66FF", "#FF6600", "#FF6633", "#FF6666", "#FF6699", "#FF66CC", "#FF66FF", "#009900", "#009933",
        "#009966", "#009999", "#0099CC", "#0099FF", "#339900", "#339933", "#339966", "#339999", "#3399CC", "#3399FF", "#669900",
        "#669933", "#669966", "#669999", "#6699CC", "#6699FF", "#999900", "#999933", "#999966", "#999999", "#9999CC", "#9999FF",
        "#CC9900", "#CC9933", "#CC9966", "#CC9999", "#CC99CC", "#CC99FF", "#FF9900", "#FF9933", "#FF9966", "#FF9999", "#FF99CC",
        "#FF99FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#33CC00", "#33CC33", "#33CC66", "#33CC99",
        "#33CCCC", "#33CCFF", "#66CC00", "#66CC33", "#66CC66", "#66CC99", "#66CCCC", "#66CCFF", "#99CC00", "#99CC33", "#99CC66",
        "#99CC99", "#99CCCC", "#99CCFF", "#CCCC00", "#CCCC33", "#CCCC66", "#CCCC99", "#CCCCCC", "#CCCCFF", "#FFCC00", "#FFCC33",
        "#FFCC66", "#FFCC99", "#FFCCCC", "#FFCCFF", "#00FF00", "#00FF33", "#00FF66", "#00FF99", "#00FFCC", "#00FFFF", "#33FF00",
        "#33FF33", "#33FF66", "#33FF99", "#33FFCC", "#33FFFF", "#66FF00", "#66FF33", "#66FF66", "#66FF99", "#66FFCC", "#66FFFF",
        "#99FF00", "#99FF33", "#99FF66", "#99FF99", "#99FFCC", "#99FFFF", "#CCFF00", "#CCFF33", "#CCFF66", "#CCFF99", "#CCFFCC",
        "#CCFFFF", "#FFFF00", "#FFFF33", "#FFFF66", "#FFFF99", "#FFFFCC", "#FFFFFF"
    );
    var total = colors.length;
    var width = 18;
    var cp_contents = "";
    var windowRef = (windowMode) ? "window.opener." : "";
    if (windowMode) {
        cp_contents += "<html><head><title>Select Color</title></head>";
        cp_contents += '<body style="margin:0;"><center>';
    }
    cp_contents += '<table border="1" cellspacing="1" cellpadding="0">';
    var use_highlight = (document.getElementById || document.all) ? true : false;
    for (var i = 0; i < total; i++) {
        if ((i % width) == 0) { cp_contents += "<tr>"; }
        if (use_highlight) {
            var mo = 'onMouseOver="' + windowRef + 'ColorPicker_highlightColor(\'' + colors[i] + '\',window.document)"';
        }
        else { mo = ""; } 
        cp_contents += '<td style="background-color:' + colors[i] + ';">'
            + '<a href="#" onClick="' + windowRef
            + 'ColorPicker_pickColor(\'' + colors[i] + '\',' + windowRef
            + 'window.popupWindowObjects[' + cp.index + ']);return false;" '
            + mo + ' style="text-decoration:none;">&nbsp;&nbsp;&nbsp;</a></td>';
        if (((i + 1) >= total) || (((i + 1) % width) == 0)) {
            cp_contents += "</tr>";
        }
    }
    if (document.getElementById) {
        var width1 = Math.floor(width / 2);
        var width2 = width1;
        cp_contents += "<tr><td colspan='" + width1
            + "' style='background-color:#ffffff;' id='colorPickerSelectedColor'>&nbsp;</td><td colspan='"
            + width2 + "' align='center' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>";
    }
    cp_contents += "</table>";
    if (windowMode) {
        cp_contents += "</center></body></html>";
    }
    cp.populate(cp_contents + "\n");
    cp.offsetY = 25;
    cp.autoHide(); 
    return cp;
}
//OLD - BOX
function validateNumericInput() {
    var inputString = document.getElementById('txtNumSuggestions').value;
    var regx = /^\d+$/;

    if (inputString.search(regx) == -1 || parseInt(inputString) > 25 || parseInt(inputString) < 1) {
        alert('Number of suggestions must be a numeric value between 1 and 25.');
        document.getElementById('txtNumSuggestions').value = '10';
    }
    else { updateBoxSnippet(); }
}
//functional stuff
function tn_SubmitSearch() {
    var SearchPhrase = document.getElementById('txtTNSearchPhrase').value;
    if (SearchPhrase == '') return;
    if (document.getElementById("targetBlank").selectedIndex == 0) { window.open('http://ticketliquidator.com/tix/' + Fixer(SearchPhrase) + '-tickets.aspx?kbid=' + document.getElementById("txtkbid").value.trim()); }
    else { window.location = 'http://ticketliquidator.com/tix/' + Fixer(SearchPhrase) + '-tickets.aspx?kbid=' + document.getElementById("txtkbid").value.trim(); }
}
function pickColor(color, otherInput) {

    if (otherInput)
        ColorPicker_targetInput = otherInput;
    ColorPicker_targetInput.value = color;
    document.getElementById(ColorPicker_targetInput.id + "_picker").style.backgroundColor = color;
    updateBoxSnippet();
}
function updateBoxSnippet() {
    widget = CreateWidget();
    document.getElementById("dvOutput").innerHTML = widget.html;
    document.getElementById("txtCodeBox").value = widget.PrintCode();
    if (document.getElementById("drpSugType").selectedIndex == 1) { widget.GetTopEvents(); }
    else { eval(widget.javascript); }
    return false;
}
function tn_fill_top_events() {
    eval(widget.topeventsJs);
}
function onCategoryChange() {
    document.getElementById('childcategory').style.display = "none";
    document.getElementById('childcategory1').style.display = "none";
    document.getElementById('childcategory2').style.display = "none";
    document.getElementById('childcategory3').style.display = "none";
    var parent = document.getElementById('selCategory');
    document.getElementById('childcategory' + parent[parent.selectedIndex].value).style.display = "inline";
}
function onVersionChange() {
    var dispType = '';
    if (document.getElementById('drpImages').selectedIndex == 0) {
        //enhanced version
        dispType = 'none';
        document.getElementById('imgExample').src = 'http://site_01504_012.ticketsoftware.net/images/TLWidgetEnhanced.jpg';
    }
    else {
        document.getElementById('imgExample').src = 'http://site_01504_012.ticketsoftware.net/images/TLWidgetStandard.jpg';
    }
    document.getElementById('trButtonText').style.display = dispType;
    document.getElementById('trHeadline').style.display = dispType;
    document.getElementById('trHeadlineoption').style.display = dispType;
    document.getElementById('trDivider1').style.display = dispType;
    document.getElementById('trBgColor').style.display = dispType;
    document.getElementById('trHeadlineTitle').style.display = dispType;
}
//widget builder
var tnserviceUrl = "http://tickettransaction.com/";
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$|'/g, "");
};

function Widget() {
    this.html = "";
    this.javascript = "";
    this.topeventsJs = "";
    this.topEventsParams = "";
    this.usesTopEvents = false;
}
Widget.prototype.GetTopEvents = function() {
    var dynamScript = document.createElement('script');
    dynamScript.type = 'text/javascript';
    dynamScript.src = tnserviceUrl + "?bid=1&tid=top_sellers&javaarray=true" + this.topEventsParams;
    document.getElementsByTagName('head')[0].appendChild(dynamScript);
};
Widget.prototype.PrintCode = function() {
    var rtnval = "<!-- TL Search box start -->\n";
    rtnval += this.html;
    rtnval += "\n<script type='text/javascript'>\n" + this.javascript + "\n</" + "script>";
    if (this.usesTopEvents) {
        rtnval += "\n<script type='text/javascript' defer='defer' src='" + tnserviceUrl + "?bid=1&tid=top_sellers&javaarray=true" + this.topEventsParams + "' ></";
        rtnval += "script>";
    }
    rtnval += "\n<!-- TL Search box end -->";
    return rtnval;
};

function CreateWidget() {
    //<!-- TL Search box start -->\n
    var rtnval = new Widget();
    var kbid = document.getElementById("txtkbid").value.trim();
    var images = document.getElementById('drpImages').selectedIndex == 0;
    var imgId = (images) ? 114 : 113;
	var htmls;
	if (getSelectedVal("selAffType1") == "myapp1") {
		htmls = new Array("<img style='display:none;' src='https://www.myaffiliateprogram.com/u/tndaffil/se.asp?e=" + imgId + "&id=" + kbid + "' />\n");
	} else {
		htmls = new Array("");
	}

	htmls.push("<script type='text/javascript' src='http://www.ticketnetwork.com/scripts/retail/scriptsretail-stringutils.js'></script>\n");
    htmls.push("<div class='tn_searchbox' style='text-align:center;padding:0px 0px 5px 0px;");
    var tempVar = document.getElementById("mainWidth").value.trim();

    //widget width
    if (tempVar != "") { htmls.push("width:" + tempVar + "px;"); }

    //background color
    if (!images) {
        tempVar = document.getElementById("mainBGColor").value.trim();
        if (tempVar != "") { htmls.push("background-color:" + tempVar + ";"); }
    }
    else { htmls.push("background-color:#FFFFFF;"); }


    //border
    if (document.getElementById("showBorder").selectedIndex == 0) {
        tempVar = document.getElementById("borderWidth").value.trim();
    	if (tempVar != "") { htmls.push("border:" + tempVar + "px solid;"); }
        else { htmls.push("border:4px solid;"); }
        tempVar = document.getElementById("borderColor").value.trim();
        if (tempVar != "") { htmls.push("border-color:" + tempVar + ";"); }
    }
    htmls.push("'>\n");

    //text & links
    var textColor = document.getElementById("nonLinkTextColor").value.trim();
    if (textColor != "") { textColor = "color:" + textColor + ";"; }

    var linkColor = document.getElementById("linkColor").value.trim();
    if (linkColor != "") { linkColor = "color:" + linkColor + ";"; }

    //header
    if (images) {
        htmls.push("<table cellpadding='0' cellspacing='0' style='text-align:center;width:100%;'><tr><td height='47' style='background-color:#e8edf3;border-bottom:1px solid #1d5188;'>\n");
        htmls.push("<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td height='47' align='left'><img src='http://site_01504_012.ticketsoftware.net/images/tlwidgetheaderleft.jpg' /></td>\n");
        htmls.push("<td height='47' align='right'><img src='http://site_01504_012.ticketsoftware.net/images/tlwidgetheaderright.jpg' /></td></tr></table></td></tr>\n");
        htmls.push("<tr><td style='text-align:center;'>");
    }
    //headline
    else if (document.getElementById("showHeadline").selectedIndex == 0) {
        htmls.push("<span style='" + textColor + "font-family:Verdana,Arial;font-size:17px;padding:5px;width:100%;font-weight:bold;line-height:30px;'>");
        htmls.push(document.getElementById("headlineText").value + "</span><br />\n");
    }

    //divider 1 
    if (document.getElementById("showDivider1").selectedIndex == 0 && !images) {
        htmls.push("<hr style='width:90%;height:3px;");
        tempVar = document.getElementById("dividerColor").value.trim();
        if (tempVar != "") { htmls.push("background-color:" + tempVar + ";color:" + tempVar + ";border:0;margin:5px auto;"); }
        htmls.push("' />\n");
    }

    //search intro
    if (document.getElementById("showSearchIntro").selectedIndex == 0) {
        if (images) {
            htmls.push("<table style='margin-top:6px;width:100%;text-align:center;'><tr><td style='width:20%'>&nbsp;</td>\n");
            htmls.push("<td style='" + textColor + "font-family:Arial,Verdana;font-size:14px;width:60%;font-weight:bold;'>");
            htmls.push(document.getElementById("searchIntroText").value + "</td>\n");
            htmls.push("<td style='width:20%'>&nbsp;</td></tr></table><br />\n");
        }
        else {
            htmls.push("<span style='" + textColor + "font-family:Arial,Verdana;font-size:11px;padding:2px 10px 5px 10px;width:100%;font-weight:bold;'>");
            htmls.push(document.getElementById("searchIntroText").value + "</span><br />\n");
        }
    }
    htmls.push("<table style='margin:0 auto;'><tr><td><input style='background-color:#ffffff;border:1px solid #7f9db9;");

    tempVar = document.getElementById("searchBoxWidth").value.trim();
    if (tempVar != "") { htmls.push("width:" + tempVar + "px;"); }
    htmls.push("' id='txtTNSearchPhrase' type='text' /></td>\n");

    if (document.getElementById("boxAndButtonSameLine").selectedIndex == 1) {
        htmls.push("</tr><tr><td>");
    }
    else { htmls.push("<td style='padding-left:10px;'>"); }
    if (images) { htmls.push("<img onclick='tn_SubmitSearch()' style='cursor:pointer;' src='http://site_01504_012.ticketsoftware.net/images/tlwidgetgo.jpg' />"); }
    else { htmls.push("\<input type='button' onclick='tn_SubmitSearch()' value='" + document.getElementById("searchButtonText").value.replace(/'/g, "") + "' />\n"); }
    htmls.push("</td></tr></table>\n");
    //divider 2
    if (document.getElementById("showDivider2").selectedIndex == 0) {
        htmls.push("<hr style='width:90%;height:3px;");
        tempVar = document.getElementById("dividerColor").value.trim();
        if (tempVar != "") { htmls.push("background-color:" + tempVar + ";color:" + tempVar + ";border:0;margin:5px auto;"); }
        htmls.push("' />\n");
    }
    var target = document.getElementById("targetBlank").selectedIndex == 0 ? "_blank" : "_self";
    var baseUrl = "http://www.ticketliquidator.com/tix/";
	var baseUrlCj = "http://www.jdoqocy.com/click";
	var baseUrlCjForLoop = "http://www.jdoqocy.com/click";
	var baseUrlEncode = "http://www.ticketliquidator.com/resultsgeneral.aspx?kwds=";
	var baseUrlEncodeForLoop = "http://www.ticketliquidator.com/tix/";
	var tmpIdPid;
	var tmpIdAid;
	var tmpIdSid;
	var finalUrlEncode;
	var utmParasAndStr;
	if (document.getElementById("showSuggestions").selectedIndex == 0) {
        htmls.push("<span style='" + textColor + "font-family:Arial,Verdana;font-size:11px;padding:2px 10px 5px 10px;width:100%;font-weight:bold;'>");
		htmls.push(document.getElementById("suggestionIntroText").value + "</span><br />\n");
		var linkStyle = "font-family:Verdana,Arial;font-size:11px;";
        tempVar = document.getElementById("linkColor").value.trim();
        if (tempVar != "") { linkStyle += "color:" + tempVar + ";"; }

        //if manual suggestions            
        if (document.getElementById("drpSugType").selectedIndex == 0) {
            for (var x = 1; x <= 10; x++) {
                var term = document.getElementById("suggestion" + x).value.trim();
                if (term != "") {
                    //if not custom url, we generate url
                    if (!document.getElementById("chkSug" + x + "Url").checked) {

                        if (getSelectedVal("selAffType1") == "cj1") {
                        	tmpIdPid = parseInt(document.getElementById("txtpid1").value.trim());
                        	if (isNaN(tmpIdPid) == true) { tmpIdPid = ""; }
                            baseUrlCjForLoop += "-" + tmpIdPid;
                        	tmpIdAid = parseInt(document.getElementById("txtaid1").value.trim());
                        	if (isNaN(tmpIdAid) == true) { tmpIdAid = ""; }
                            baseUrlCjForLoop += "-" + tmpIdAid;
                        	tmpIdSid = parseInt(document.getElementById("txtsid1").value.trim());
                        	if (isNaN(tmpIdSid) == true) {tmpIdSid = ""; }
                            baseUrlCjForLoop += "?sid=" + tmpIdSid + "&url=";
                        	finalUrlEncode = baseUrlCjForLoop + encodeURI(baseUrlEncodeForLoop + Fixer(term) + "-tickets.aspx?utm_source=CJID&utm_medium=" + tmpIdPid);
                        	htmls.push("<a style='" + linkStyle + "' target='" + target + "' href='" + finalUrlEncode + "'" + ">" + term + "</a><br />\n");
                            baseUrlCjForLoop = "http://www.jdoqocy.com/click";
                        	baseUrlEncodeForLoop = "http://www.ticketliquidator.com/tix/";
                        }
                        else {
                        	utmParasAndStr = "&utm_source=kbid&utm_medium=" + kbid;
                        	htmls.push("<a style='" + linkStyle + "' target='" + target + "' href='" + baseUrl + Fixer(term) + "-tickets.aspx?img=" + imgId + "&kbid=" + kbid + utmParasAndStr + "'>" + term + "</a><br />\n");
                            utmParasAndStr = "";
                        }
                    }
                    else {
                        var custUrl = document.getElementById("txtSug" + x + "Url").value.trim();
                        if (getSelectedVal("selAffType1") == "cj1") {
                        	tmpIdPid = parseInt(document.getElementById("txtpid1").value.trim());
                        	if (isNaN(tmpIdPid) == true) { tmpIdPid = ""; }
                            baseUrlCjForLoop += "-" + tmpIdPid;
                        	tmpIdAid = parseInt(document.getElementById("txtaid1").value.trim());
                        	if (isNaN(tmpIdAid) == true) { tmpIdAid = ""; }
                            baseUrlCjForLoop += "-" + tmpIdAid;
                        	tmpIdSid = parseInt(document.getElementById("txtsid1").value.trim());
                        	if (isNaN(tmpIdSid) == true) { tmpIdSid = ""; }
                            baseUrlCjForLoop += "?sid=" + tmpIdSid + "&url=";
                        	finalUrlEncode = baseUrlCjForLoop + encodeURI(custUrl + "?utm_source=CJID&utm_medium=" + tmpIdPid);
                        	htmls.push("<a style='" + linkStyle + "' target='" + target + "' href='" + finalUrlEncode + "'>" + term + "</a><br />\n");
                            baseUrlCjForLoop = "http://www.jdoqocy.com/click";
                        	baseUrlEncodeForLoop = "http://www.ticketliquidator.com/tix/";
                        }
                        else {
                        	utmParasAndStr = "&utm_source=kbid&utm_medium=" + kbid;
                        	htmls.push("<a style='" + linkStyle + "' target='" + target + "' href='" + custUrl + "?img=" + imgId + "&kbid=" + kbid + utmParasAndStr + "'>" + term + "</a><br />\n");
                        }
                    }
                }
            }
        }
        //automatic suggestions
        else {
            rtnval.usesTopEvents = true;
            htmls.push("<div id='tn_dv_suggestions'></div>\n");

            var otherKeywords = "";
            rtnval.topEventsParams += "&listsize=";
            tempVar = document.getElementById("txtNumSuggestions").value.trim();
            if (!isNaN(tempVar + 0)) { rtnval.topEventsParams += tempVar; }

            tempVar = document.getElementById("selCategory");
            if (tempVar.options[tempVar.selectedIndex].value != '') {
                rtnval.topEventsParams += "&pcatid=" + tempVar.options[tempVar.selectedIndex].value;
                otherKeywords += "-" + tempVar.options[tempVar.selectedIndex].text;
                tempVar = document.getElementById("childcategory" + tempVar.options[tempVar.selectedIndex].value);

                if (tempVar.options[tempVar.selectedIndex].value != '') {
                    rtnval.topEventsParams += "&ccatid=" + tempVar.options[tempVar.selectedIndex].value;
                    otherKeywords += "-" + Fixer(tempVar.options[tempVar.selectedIndex].text);
                }
            }
            tempVar = document.getElementById("selCountry");
            if (tempVar.options[tempVar.selectedIndex].value != '') {
                rtnval.topEventsParams += "&countryid=" + tempVar.options[tempVar.selectedIndex].value;
                if (tempVar.options[tempVar.selectedIndex].value != "217") {
                    otherKeywords += "-in-" + tempVar.options[tempVar.selectedIndex].text;
                }
            }
            tempVar = document.getElementById("selState");
            if (tempVar.options[tempVar.selectedIndex].value != '') {
                rtnval.topEventsParams += "&stprvid=" + tempVar.options[tempVar.selectedIndex].value;
                otherKeywords += "-in-" + tempVar.options[tempVar.selectedIndex].text;
            }
            tempVar = document.getElementById("txtCity").value.trim();
            if (tempVar != '') {
                rtnval.topEventsParams += "&city=" + tempVar;
                otherKeywords += "-in-" + tempVar;
            }
            otherKeywords = Fixer(otherKeywords);
            rtnval.topeventsJs += "var tn_dv_suggestions = new Array();\n";
            rtnval.topeventsJs += "for(var tn_counter=0; tn_counter < tn_top_performers.length; tn_counter++)\n";
            if (getSelectedVal("selAffType1") == "cj1") {

                var baseUrlCjForTop = "http://www.jdoqocy.com/click";
            	tmpIdPid = parseInt(document.getElementById("txtpid1").value.trim());
            	if (isNaN(tmpIdPid) == true) { tmpIdPid = ""; }
                baseUrlCjForTop += "-" + tmpIdPid;
            	tmpIdAid = parseInt(document.getElementById("txtaid1").value.trim());
            	if (isNaN(tmpIdAid) == true) { tmpIdAid = ""; }
                baseUrlCjForTop += "-" + tmpIdAid;
            	tmpIdSid = parseInt(document.getElementById("txtsid1").value.trim());
            	if (isNaN(tmpIdSid) == true) { tmpIdSid = ""; }
                baseUrlCjForTop += "?sid=" + tmpIdSid + "&url=";

                rtnval.topeventsJs += "tn_dv_suggestions.push(\"<a style='" + linkStyle + "' target='" + target + "' href='" + baseUrlCjForTop + baseUrl + "\" + Fixer(tn_top_performers[tn_counter]) +\"" + otherKeywords + "-tickets.aspx" + "?utm_source=CJID&utm_medium=" + tmpIdPid + "'>" + " \"+tn_top_performers[tn_counter] +\"</a><br />\");\n";
            }
            else {
            	utmParasAndStr = "&utm_source=kbid&utm_medium=" + kbid;
            	rtnval.topeventsJs += "tn_dv_suggestions.push(\"<a style='" + linkStyle + "' target='" + target + "' href='" + baseUrl + "\" + Fixer(tn_top_performers[tn_counter]) +\"" + otherKeywords + "-tickets.aspx?img=" + imgId + "&kbid=" + kbid + utmParasAndStr + "'>" + " \"+tn_top_performers[tn_counter] +\"</a><br />\");\n";
            }
            rtnval.topeventsJs += "document.getElementById('tn_dv_suggestions').innerHTML=tn_dv_suggestions.join('');";
            rtnval.javascript += "function tn_fill_top_events() \n{\n" + rtnval.topeventsJs + "\n}\n";
        }
    }
    if (images) {
        if (getSelectedVal("selAffType1") == "cj1") {

            baseUrlCjForLoop = "http://www.jdoqocy.com/click";
        	baseForImageNew = "http://www.ticketliquidator.com/default.aspx";
        	tmpIdPid = parseInt(document.getElementById("txtpid1").value.trim());
        	if (isNaN(tmpIdPid) == true) { tmpIdPid = ""; }
            baseUrlCjForLoop += "-" + tmpIdPid;
        	tmpIdAid = parseInt(document.getElementById("txtaid1").value.trim());
        	if (isNaN(tmpIdAid) == true) { tmpIdAid = ""; }
            baseUrlCjForLoop += "-" + tmpIdAid;
        	tmpIdSid = parseInt(document.getElementById("txtsid1").value.trim());
        	if (isNaN(tmpIdSid) == true) { tmpIdSid = ""; }
            baseUrlCjForLoop += "?sid=" + tmpIdSid + "&url=";
        	finalUrlEncode = baseUrlCjForLoop + encodeURI(baseForImageNew + "?utm_source=CJID&utm_medium=" + tmpIdPid);
        	htmls.push("</td></tr><tr><td align='center'><br /><a href='" + finalUrlEncode + "'><img src='http://site_01504_012.ticketsoftware.net/images/tlwidgetfoot.jpg' border='0' /></a></td></tr></table>");
        }
        else {
        	utmParasAndStr = "&utm_source=kbid&utm_medium=" + kbid;
        	htmls.push("</td></tr><tr><td align='center'><br /><a href='http://www.ticketliquidator.com/default.aspx?img=" + imgId + "&kbid=" + kbid + utmParasAndStr + "'><img src='http://site_01504_012.ticketsoftware.net/images/tlwidgetfoot.jpg' border='0' /></a></td></tr></table>");
        }
    }
    htmls.push("</div>\n");
    rtnval.html = htmls.join("");
    rtnval.javascript += "function tn_SubmitSearch()\n{\nvar SearchPhrase = document.getElementById('txtTNSearchPhrase').value;\n";

    if (getSelectedVal("selAffType1") == "cj1") {
    	tmpIdPid = parseInt(document.getElementById("txtpid1").value.trim());
    	if (isNaN(tmpIdPid) == true) { tmpIdPid = ""; }
        baseUrlCj += "-" + tmpIdPid;
    	tmpIdAid = parseInt(document.getElementById("txtaid1").value.trim());
    	if (isNaN(tmpIdAid) == true) { tmpIdAid = ""; }
        baseUrlCj += "-" + tmpIdAid;
    	tmpIdSid = parseInt(document.getElementById("txtsid1").value.trim());
    	if (isNaN(tmpIdSid) == true) {
            baseUrlCj += "?&url=";
         }
        else {
            baseUrlCj += "?sid=" + tmpIdSid;
            baseUrlCj += "&url=";
        }       
        if (target == "_blank") { rtnval.javascript += "if(SearchPhrase != '') window.open('" + baseUrlCj + "' + encodeURI ( '" + baseUrlEncode + "'+Fixer(SearchPhrase ) +'" + "&utm_source=CJID&utm_medium=" + tmpIdPid + "'));\n}\n\n"; }
        else { rtnval.javascript += "if(SearchPhrase != '') window.location='" + baseUrlCj + "' + encodeURI ( '" + baseUrlEncode + "'+Fixer(SearchPhrase ) +'" + "&utm_source=CJID&utm_medium=" + tmpIdPid + "');\n}\n\n"; }
    }
    else {
    	utmParasAndStr = "&utm_source=kbid&utm_medium=" + kbid;
    	if (target == "_blank") { rtnval.javascript += "if(SearchPhrase != '') window.open('" + baseUrl + "'+Fixer(SearchPhrase ) +'-tickets.aspx?img=" + imgId + "&kbid=" + kbid + utmParasAndStr + "');\n}\n\n"; }
        else { rtnval.javascript += "if(SearchPhrase != '') window.location='" + baseUrl + "'+Fixer(SearchPhrase ) +'-tickets.aspx?img=" + imgId + "&kbid=" + kbid + utmParasAndStr + "';\n}\n\n"; }
    }
    rtnval.javascript += "function tn_KeyDownHandler(e) \n{ \nif (e == null) e = window.event;\nif (e.keyCode == 13) tn_SubmitSearch();\n}\n\ndocument.getElementById('txtTNSearchPhrase').onkeypress=tn_KeyDownHandler;\n";

    return rtnval;
}
//NEW - LIST
function updateListSnippet() {
    var mxRslts = parseInt(document.getElementById('txtMxRslts').value, 10);
    if (mxRslts == NaN || mxRslts > 100 || mxRslts < 0) { mxRslts = 100; }
    document.getElementById('txtMxRslts').value = mxRslts;
    var url = widgetUrl + 'widget2.aspx?'
        + (document.getElementById("rdoSearch").checked ? 'kwds=' + escape(document.getElementById('txtSearch').value) : '')
        + (document.getElementById("rdoPerformer").checked ? 'pid=' + getSelectedVal("selPerf") : '')
        + (document.getElementById("rdoVenue").checked ? 'venid=' + getSelectedVal("selVen") : '')
        + "&style=" + getSelectedVal("selStyle") + "&mxrslts=" + mxRslts;

    document.getElementById("tn_results_container").innerHTML = "";
    if (getSelectedVal("selStyle") > 0) {
        document.styleSheets[document.styleSheets.length - 1].disabled = true;
    }
    var code = '<script type="text/javascript">\nfunction TN_SetWidgetOptions() { '
        + createOptionsJs() + '}\n</' + 'script>\n' + '<script type="text/javascript" src="' + url + '"><' + '/script>';
    if (getSelectedVal("selAffType") == "cj") {
        code += '\n<img src="http://www.awltovhc.com/image-' + document.getElementById("txtpid").value + '-' + document.getElementById("txtaid").value + '" height"1" width="1" />';
    }
    document.getElementById('txtCode').value = code;
    document.getElementById('txtCode').onchange();
    dynamLoadJs(url + '&refresh=true');
}
function checkContents() {
    $("#tn_results_info").html("");
    if (document.getElementById("tn_results_container").innerHTML == '<table class="tn_results" cellpadding="2" cellspacing="0"><tbody></tbody></table>') {
        $("#tn_results_info").html("There were no events matching your criteria.");
    }
}
function getSelectedVal(selId) {
    var indx = document.getElementById(selId).selectedIndex;
    return document.getElementById(selId).options[indx].value;
}
function dynamLoadJs(jsFile) {
    var dynamScript = document.createElement('script');
    dynamScript.type = 'text/javascript';
    dynamScript.src = jsFile;
    document.getElementsByTagName('head')[0].appendChild(dynamScript);
}
function TN_SetWidgetOptions() {
    eval(createOptionsJs());
}
function createOptionsJs() {
    var trackingParams = "";
    var extraParams = "";
	var affType = getSelectedVal("selAffType");
    var affType1 = getSelectedVal("selAffType1");
    if (affType == "myapp") {
        //KowaBunga
        document.getElementById("tblCjOptions").style.display = "none";
        document.getElementById("tblMyApp").style.display = "";
        var kbid = parseInt(document.getElementById("txtkbidlist").value);
        if (kbid) {
            trackingParams = "&utm_source=kbid&utm_medium=" + kbid + "&kbid=" + kbid;
        }
        extraParams = "TN_Widget.CreateCustomUrl = function(row){"
        + "return this.tixUrl + \"?evtid=\" + row[6];};";
    }
    else if (affType == "cj") {
        //Commission Junction
        //(11:01 AM) Ian Hough: http://www.jdoqocy.com/click-PID-AID?url=encoded_url
        document.getElementById("tblCjOptions").style.display = "";
        document.getElementById("tblMyApp").style.display = "none";
        var baseCJUrl = "http://www.jdoqocy.com/click";
    	var tmpId = parseInt(document.getElementById("txtpid").value.trim());
        if (tmpId) { baseCJUrl += "-" + tmpId; }
        tmpId = parseInt(document.getElementById("txtaid").value.trim());
        if (tmpId) { baseCJUrl += "-" + tmpId; }
        baseCJUrl += "?sid=" + escape(document.getElementById("txtsid").value.trim()) + "&url=";
        extraParams = "TN_Widget.CreateCustomUrl = function(row){"
        + "return \"" + baseCJUrl + "\" + escape( this.tixUrl + \"?evtid=\" + row[6]);};";
    }
    if (affType1 == "myapp1") {
        document.getElementById("tblCjOptions1").style.display = "none";
        document.getElementById("tblMyApp1").style.display = "";
    }
    else if (affType1 == "cj1") {
        document.getElementById("tblCjOptions1").style.display = "";
        document.getElementById("tblMyApp1").style.display = "none";
    }    
    return "TN_Widget.newWindow = " + getSelectedVal("targetBlankList") + "; "
    + "TN_Widget.trackingParams = '" + trackingParams + "'; "
    + "TN_Widget.custLink = true; "
    + "TN_Widget.tixUrl = 'http://www.ticketliquidator.com/tix/tickets.aspx'; "
    + extraParams;
}
function changeBoxFast() {
    var affType1 = getSelectedVal("selAffType1");
}
function changeResultType(resultType) {
    document.getElementById("explsearch").style.display = "none";
    document.getElementById("expperformer").style.display = "none";
    document.getElementById("expvenue").style.display = "none";

    document.getElementById("trperformer").style.display = (resultType == "performer" ? "" : "none");
    document.getElementById("trsearch").style.display = (resultType == "search" ? "" : "none");
    document.getElementById("trvenue").style.display = (resultType == "venue" ? "" : "none");

    if (!vensLoaded && resultType == "venue") {
        vensLoaded = true;
        dynamLoadJs(widgetUrl + "populateVens.aspx");
    }
    else if (!perfsLoaded && resultType == "performer") {
        perfsLoaded = true;
        dynamLoadJs(widgetUrl + "populatePerfs.aspx");
    }
}
function perfCallback() {
    var html = document.getElementById("dvPerfDrop").innerHTML;
    //fix for IE
    html = html.replace(window.location.toString().replace(/[&]/g, "&amp;"), "");
    //fix for opera
    html = html.replace("&nbsp;", "");
    //normal browsers
    html = html.replace("<a href=\"#\" onclick=\"return showNote('expperformer');\">?</a>", "");
    //ie
    html = html.replace("<A onclick=\"return showNote('expperformer');\" href=\"#\">?</A>", "");
    //normal browsers
    html = html.replace("style=\"width: 142px;\"", "class=\"affSearchDropDown\"");
    //ie
    html = html.replace("style=\"WIDTH: 142px\"", "class=\"affSearchDropDown\"");
    html = html.replace("updateSnippet", "updateListSnippet");
    document.getElementById("dvPerfDrop").innerHTML = html;
    document.getElementById("selPerf").style.width = "130px";
}
function venueCallback() {
    var html = document.getElementById("dvVenDrop").innerHTML;
    //fix for IE
    html = html.replace(window.location.toString().replace(/[&]/g, "&amp;"), "");
    //fix for opera
    html = html.replace("&nbsp;", "");
    //normal browsers
    html = html.replace("<a href=\"#\" onclick=\"return showNote('expvenue');\">?</a>", "");
    //ie
    html = html.replace("<A onclick=\"return showNote('expvenue');\" href=\"#\">?</A>", "");
    //normal browsers
    html = html.replace("style=\"width: 142px;\"", "class=\"affSearchDropDown\"");
    //ie
    html = html.replace("style=\"WIDTH: 142px\"", "class=\"affSearchDropDown\"");
    html = html.replace("updateSnippet", "updateListSnippet");
    document.getElementById("dvVenDrop").innerHTML = html;
    document.getElementById("selVen").style.width = "130px";
}
function tn_KeyDownHandler(e) {
    if (e == null) e = window.event;
    if (e.keyCode == 13) { tn_SubmitSearch(); }
}
function ShowWidget(type) {
    if (type == 'box') {
        $('#listTable').hide();
        $('#boxTable').show();
        updateBoxSnippet();
        onVersionChange();
        document.getElementById('txtTNSearchPhrase').onkeypress = tn_KeyDownHandler;
        $('#boxTab').hide();
        $('#listTab').show();
        $('#DeepTable').hide();
        $('#deepTab').show();
    }
    else if (type == 'list') {
        $('#boxTable').hide();
        $('#listTable').show();
        updateListSnippet();
        $('#boxTab').show();
        $('#listTab').hide();
        $('#DeepTable').hide();
        $('#deepTab').show();
    }
    else if (type == 'Deep') {
        $('#boxTable').hide();
        $('#listTable').hide();
        $('#boxTab').show();
        $('#listTab').show();
        $('#deepTab').hide();
        $('#DeepTable').show();
    }
}

/////----USA MAP
function ShowCities(doc, stName) {
    var states = doc.getElementsByTagName("state");

        for (i = 0; i < states.length; i++) {
            if (states[i].getAttribute("name") == stName) {
                var content = '<a class="state" href="' + states[i].getAttribute("url") + '">' + stName + '</a><br />';
                for (j = 0; j < states[i].childNodes.length; j++) {
                    if (states[i].childNodes[j].nodeName == "city") {
                        content += '<a class="city" href="' + states[i].childNodes[j].getAttribute("url") + '"><span class="anchor">' + states[i].childNodes[j].getAttribute("name") + '</span></a>';
                    }
                }

                $('#info')
				.css({ 'position': 'absolute', 'display': 'block' })
				.offset({ left: (tempX - 3), top: (tempY - 3) })
				.html(content)
				.show();
                return false;
            }
        }
}
function HideInfo() { $('#info').hide(); }
function KeepShowing() { $('#info').show(); }
function loadXMLDoc(url) {
	// code for IE7+, Firefox, Chrome, Opera, Safari
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}
	// code for IE6, IE5
	else {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
	return xmlhttp.responseXML.documentElement;
}
function getMouseXY(e) {
    if (navigator.appName == 'Microsoft Internet Explorer') {

		// grab the x-y pos.s if browser is IE

	    e = e || window.event;

	    if (e.pageX || e.pageY) {
	        tempX = e.pageX;
	        tempY = e.pageY;
	    }
	    else {
	        var de = document.documentElement;
	        var b = document.body;
	        tempX = e.clientX +
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
	        tempY = e.clientY +
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
	    }
	}
	else {
		// grab the x-y pos.s if browser is NS
		        tempX = e.pageX;
	    		tempY = e.pageY;
	}
	// catch possible negative values in NS4
	if (tempX < 0) { tempX = 0; }
	if (tempY < 0) { tempY = 0; }
    	return true;



}
/**
* @author Dan Blaisdell
*/
(function ($) {
	$.fn.extend({
		_offset: $.fn.offset,

		offset: function (newOffset) {
			return newOffset ? this.setXY(newOffset) : this._offset();
		},

		setXY: function (newOffset) {
			return this.each(function () {
				var el = this;

				var hide = false;

				if ($(el).css('display') == 'none') {
					hide = true;
					$(el).show();
				}

				var style_pos = $(el).css('position');

				// default to relative
				if (style_pos == 'static') {
					$(el).css('position', 'relative');
					style_pos = 'relative';
				}

				var offset = $(el).offset();

				if (offset) {
					var delta = {
						left: parseInt($(el).css('left'), 10),
						top: parseInt($(el).css('top'), 10)
					};

					// in case of 'auto'
					if (isNaN(delta.left))
						delta.left = (style_pos == 'relative') ? 0 : el.offsetLeft;
					if (isNaN(delta.top))
						delta.top = (style_pos == 'relative') ? 0 : el.offsetTop;

					if (newOffset.left || newOffset.left === 0)
						$(el).css('left', newOffset.left - offset.left + delta.left + 'px');

					if (newOffset.top || newOffset.top === 0)
						$(el).css('top', newOffset.top - offset.top + delta.top + 'px');
				}
				if (hide) $(el).hide();
			});
		}
	});
});
