﻿/* 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);


/* Focus Text */
msf = "Enter Event, Artist or Team";
msv = "Enter Venue, Stadium or Field";
mqf = "By City or Zip Code";

var focusElements = new Array();
var hoverBtns = new Array();

/* Set Focuses */

function setHFI(t, tfoc, funct) {
    if(typeof(t.hasFocus) == "undefined") {
        t.tfoc = tfoc;
        if (typeof(t.vfoc) == "undefined") t.vfoc = 0;
        t.funct = funct;
        t.onblur = function(){setHFB(t.id)};
        focusElements.push(t.id);
    }
    t.hasFocus = true;
    if(t.value == tfoc[t.vfoc]) t.value = "";
}

function setHFB(t) {
    var a = document.getElementById(t);
    if (a.value == "") a.value = a.tfoc[a.vfoc];
    a.hasFocus = false;
}

function setHFVar(id, fid, txt, funct){
    var t = document.getElementById(id);
    t.value = txt;
    t.vfoc = fid;
    if(funct != ""){eval(funct)(fid);}
}


/* 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.hasFocus == 1) eval(elem.funct)();
            }
        }
        return false;
    } 
}



/* Quick Searches  ------------------------------------------------- */

function QSearch() {

    if($get('qsLoc').value != mqf && $get('qsLoc').value != "") {
        var dt = $get('qsDrop').value;
        var se = $get('qsLoc').value;
        if(dt == "0") dt = $get('qsDrop').item(1).value; 
        
        var sloc = null;
        var re = /[a-zA-Z]/;
        var reTest = re.test(se);
        if (!reTest)
            sloc = "http://www.stubpass.com/search/?z=" + cleanInputData(se) + "&d=" + cleanInputData(dt);
        else
            sloc = "http://www.stubpass.com/search/?c=" + cleanInputData(se) + "&d=" + cleanInputData(dt);
            
        document.location.href = sloc;
            
    }else{
        alert("Please Enter All Search Values.");
    }
    
    return false;
}


/* Extend View More  ------------------------------------------------- */

function eView(t, limit, show, a) {
    if(a == "View More") {
        for(i=show;i<limit;i++) {
            document.getElementById(t+i).style.display = "block";
            document.getElementById(t+"Toggle").innerHTML = "View Less"
        }
    }else{
        for(i=show;i<limit;i++) {
            document.getElementById(t+i).style.display = "none";
            document.getElementById(t+"Toggle").innerHTML = "View More"
        }
    }
}


/* Search Box  ------------------------------------------------- */

function doSearch() {
    var a = document.getElementById("sIBox")
    var url = "http://www.stubpass.com/search/";
    if(a.value == "") return false;
    
    if(a.vfoc == 1) {
        url += "?v=" + cleanInputData(a.value);
    }else{
        url += "?s=" + cleanInputData(a.value);
    }
    
    document.location.href = url;
    return false;
}

function doSVC(id) {
    document.getElementById("sEvt").className = "dw";
    document.getElementById("sVen").className = "dw";
    
    if(id == 0) 
        document.getElementById("sEvt").className = "up";
    else
        document.getElementById("sVen").className = "up";
}


/* 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";
}


/* Do OnLoad  ------------------------------------------------- */
/* Menu Fixes  ------------------------------------------------- */

spHover = function() {     
    var spME = document.getElementById("SPMenu").getElementsByTagName("li");     
    for (var i=0; i<spME.length; i++) {         
        spME[i].onmouseover=function() {this.className+=" over";}         
        spME[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" over\\b"), "");}     
    } 
} 

function spIDHover() {    
    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 spHB = mel.getElementsByTagName("li");     
        for (var i=0; i<spHB.length; i++) {         
            spHB[i].onmouseover=function() {this.className+=" over";}         
            spHB[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" over\\b"), "");}     
        }  
       
   }
} 

function doOL() {
    spHover();
    spIDHover();
}

if(window.attachEvent) window.attachEvent("onload", doOL);