﻿/* Varibales */
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );

var is_gecko = (agt.indexOf('gecko') != -1);
var is_opera = (agt.indexOf("opera") != -1);
var hoverBtns = new Array();

/* Preload Menu Images */

pre1 = new Image(); 
pre1.src = "/com/css/menu/mdrop-bg.jpg"; 
pre2 = new Image(); 
pre2.src = "/com/css/menu/mdrop-bgi.jpg"; 
pre3 = new Image(); 
pre3.src = "/com/css/menu/mdrop-over.jpg"; 


/* Set Focuses and Searches */

var topSB = null;
var msf = "Enter Event, Artist or Team";
var mqf = "By City or Zip Code";
var nle = "Email Address";
var focusElements = new Array();

function setHFI(t, tfoc, funct) {
    if(typeof(t.hasFocus) == "undefined") {
        t.tfoc = tfoc;
        t.funct = funct;
        if (typeof(t.vfoc) == "undefined") t.vfoc = 0;
        t.onblur = function(){setHFB(t)};
        focusElements.push(t.id);
    }
    t.hasFocus = true;
    if(t.value == tfoc[t.vfoc]) t.value = "";
}

function setHFB(t) {
    if (t.value == "") t.value = t.tfoc[t.vfoc];
    t.hasFocus = false;
}

/* Main Search */

var autocomplete = false;

function doSearch() {
   if(!autocomplete) {
       var a = topSB; //document.getElementById("stbinput")
       if(a.value == "" || a.value == msf) return false;
       document.location.href = "http://www.ticketseating.com/find-tickets/" + cleanInputData(a.value) + "/";
   }
   return false;   
}


function itemSelected(ev){
    autocomplete = true;
    var index=$find("AutoCompleteEx")._selectIndex;
    var aci = $find("AutoCompleteEx").get_completionList().childNodes[index];
    var dd=aci._value;
    $find("AutoCompleteEx").get_element().value = aci._display;
    document.location.href=dd;
    return false;
}

function onClientPopulated(sender,e){
    var comletionList=$find("AutoCompleteEx").get_completionList();
    for(i=0;i<comletionList.childNodes.length;i++){    
        var _v = eval(comletionList.childNodes[i]._value);
        var iname = _v[0];
        var ibname = _v[1];
        var iurl= _v[2];
        comletionList.childNodes[i]._value=iurl;
        comletionList.childNodes[i]._display=iname;
        comletionList.childNodes[i].innerHTML=ibname;
    } 
}

/* Auto Complete --^ End */

function QSearch() {

try{
    var dti = document.getElementById('qsDrop');
    var dt = dti.value;
    var se = document.getElementById('qsLoc');

   if(se.value != mqf && se.value != "") {       
         if(dt == "0") dt = dti.item(1).value; 
         var sloc = null;
         var re = /[a-zA-Z]/;
         var reTest = re.test(se.value);
         if (!reTest) sloc = "http://www.ticketseating.com/find-tickets/--zip-" + cleanInputData(se.value) + "--for-date-" + cleanInputData(dt) + "/";
         else sloc = "http://www.ticketseating.com/find-tickets/" + cleanInputData(se.value) + "--for-date-" + cleanInputData(dt) + "/";
         document.location.href = sloc;         
    }else{
        alert("Please Enter All Search Values.");
    }
    
}catch(e){}
    
    return false;
}

function NLSubmit() {
    $get('tsRSB_nlbtn').click(); 
    return false;  
}

function NLClick() {
    document.getElementById("nls").innerHTML = "<b style=\"font-size:7pt;\">Validating Email...</b>"
}


/* Capture Keys  ------------------------------------------------- */

function captureEvent() {
    if(event.keyCode==13) {
        for(i=0; i<focusElements.length; i++) {
            var elem = document.getElementById(focusElements[i]);
            if(typeof(elem.hasFocus) != "undefined") {
                if(elem.funct != "") {
                    if(elem.hasFocus == 1) eval(elem.funct)();
                }
            }
        }
        return false;
    } 
}

/* Toggle ----------------*/

function setToggle(i,o, dtype) {
    if(is_ie && dtype == "table-row-group") {
        document.getElementById(i).style.display = "block";
    }else{
        document.getElementById(i).style.display = dtype;
    }
    document.getElementById(o).style.display = "none";
    return false;
}


function ShowConfig(id) {

    var el = document.getElementById("config_" + id);
    if(el != null) {
        var ae = getElementsByClass("vdinfo", document.getElementById("vdtd"), "div");
        for(i=0;i<ae.length;i++) {
            ae[i].style.display = "none";
        }

        el.style.display = "block";
    }
    
}

function ShowDiv(id, type, remove) {

    if(type == 0 && remove != null) {
        for(i=0;i<remove.length;i++) {
            document.getElementById(remove[i]).style.display = "none";
        }
    }

    var el = document.getElementById(id);
    if(type == 0) el.style.display = "block";
    else el.style.display = "none";
    return false;   
}

function openWin(url, w, h) {
    window.open(url, "VenueImage", "status=0,toolbar=0,scrollbars=0,width=" + w + ",height=" + h);
    return false;
}

/* Do OnLoad  ------------------------------------------------- */
/* Menu Fixes  ------------------------------------------------- */

tsHover = function() {     
    var tsME = document.getElementById("TSMenu").getElementsByTagName("li");     
    for (var i=0; i<tsME.length; i++) {         
        tsME[i].onmouseover=function() {this.className+=" over";}         
        tsME[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" over\\b"), "");}     
    } 
} 


function tsIDHover() {    
    for(i=0;i<hoverBtns.length;i++){
        var mel = document.getElementById(hoverBtns[i][0]);
        var mfr = document.getElementById(hoverBtns[i][0] + "_fr");
        
        if(is_ie6){
            mfr.style.height = hoverBtns[i][1];
        }else{
            mfr.style.height = "0px";
        }

        var tsHB = mel.getElementsByTagName("li");     
        for (var i=0; i<tsHB.length; i++) {         
            tsHB[i].onmouseover=function() {this.className+=" over";}         
            tsHB[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" over\\b"), "");}     
        }  
       
   }
} 

function doOL() {tsHover();tsIDHover();}
if(window.attachEvent) window.attachEvent("onload", doOL);