document.write("<script type=\"text/javascript\" src=\"http://www.vividseats.com/v2/javascript/yui-dom-event.js\"></script><script type=\"text/javascript\" src=\"http://www.vividseats.com/v2/javascript/datasource-min.js\"></script><script type=\"text/javascript\" src=\"http://www.vividseats.com/v2/javascript/connection-min.js\"></script><script type=\"text/javascript\" src=\"http://www.vividseats.com/v2/javascript/autocomplete-min.js\"></script>");
function submitSearch() {
	document.getElementById("topsearchform").submit();
}

function loadFaceBook() {
	var fburl = 'ht' + 'tp' + '://' + 'www' + '.' + 'facebook' + '.com' + '/pages/Vivid-Seats-Ltd/90003322212';
	obtrk('/outgoing/fbhomebutton/');
	window.open(fburl,'fbwin','location=1,status=1,scrollbars=1');
}

function viewTix(productionId) {
	var buyUrl = 'http://www.vividseats.com/shop/viewTickets.shtml';
	window.location = buyUrl + '?productionId=' + productionId;
}

function sellTix(productionId) {
	var sellUrl = 'https://www.vividseats.com/sell/v2/setProductions.shtml';
	window.location = sellUrl + '?productionId=' + productionId;
}

function staticTix(productionId) {
	var buyUrl = 'http://www.vividseats.com/shop/viewTicketsStatic.shtml';
	window.location = buyUrl + '?productionId=' + productionId;
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function initAutocomplete() {
    // Use an XHRDataSource
    var oDS = new YAHOO.util.XHRDataSource("/shop/autocomplete.shtml");
    // Set the responseType
    oDS.responseType = YAHOO.util.XHRDataSource.TYPE_XML;
    // Define the schema of the delimited results
    oDS.responseSchema = {   
    resultNode : "suggestion", // Name of the node for each result   
    fields : [   
        { key: "keyword" }
    ],    
	  metaNode : "Suggestions"
	};  


    // Instantiate the AutoComplete
    var oAC = new YAHOO.widget.AutoComplete("topsearchtextbox", "yacContainer", oDS);
    oAC.maxResultsDisplayed = 30;
	oAC.minQueryLength = 3;
	oAC.queryDelay = 0;
	oAC.autoHighlight = false;
	oAC.allowBrowserAutocomplete = false;  
	oAC.useIFrame = false; 


	var myHandler = function(sType, aArgs) { 
		var myAC = aArgs[0]; // reference back to the AC instance 
		var elLI = aArgs[1]; // reference to the selected LI element
		var oData = aArgs[2];
		 
		// update hidden form field with the selected item's ID 
		window.location = "http://www.vividseats.com/shop/search.shtml?keyword=" + elLI.innerHTML;
	};

	oAC.itemSelectEvent.subscribe(myHandler);

    return {
        oDS: oDS,
        oAC: oAC
    };
}
