function TN_SetWidgetOptions() { TN_Widget.newWindow = true; TN_Widget.trackingParams = ''; TN_Widget.custLink = true; TN_Widget.tixUrl = 'http://www.ticketnetwork.com/tix/'; TN_Widget.CreateCustomUrl = function(row){return "http://www.tkqlhce.com/click-1634854-10793961?sid=&url=" + escape( this.tixUrl +  row[7] + "-tickets-"+ row[6] + ".aspx");};}

  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,"");             
        }

function go_event_search(phrase, the_domain){
	final_url = escape('http://www.ticketnetwork.com/ticket/'+ Fixer(phrase) +'-events.aspx'+'?utm_source=CJ+Affiliate&utm_medium=Widget&sid=' + the_domain + ':more tickets for' + Fixer(phrase));
	lnk = 'http://www.tkqlhce.com/click-1634854-10796449?sid=&url=' + final_url;
	location.href(lnk);
	return false;
}
		

$(document).ready(function() {

	$.fn.go_ticket_event = function(){
		lnk = $(this).parents("tr").children("td.tn_results_tickets_text").children("a").attr("href");
		location.href(lnk);
	}

	$("div.vevent").click(function(){
		lnk = $(this).children("div.event_buy").children("a").attr("href");
		location.href(lnk);
	});
	
	$("td.tn_results_event_text").click(function(){$(this).go_ticket_event();});
	$("td.tn_results_venue_text").click(function(){$(this).go_ticket_event();});
	$("td.tn_results_datetime_text").click(function(){$(this).go_ticket_event();});
	if(typeof sidstr == "undefined"){sidstr="";}
	$("td.tn_results_tickets_text a").each(function(){
		iurl = $(this).attr("href").replace("sid=&","sid=" + sidstr + "&");
		$(this).attr("href",iurl);
	});
});
