// Template.js

var onChangeArray = new Array();
function onChange() {
    for (var i = 0; i < onChangeArray.length; i++) {
        eval(onChangeArray[i]);
    }
}
function addOnChangeHandler(expr) {
    onChangeArray[onChangeArray.length] = expr;
}
var onLoadArray = new Array();
function onLoad() {
    for (var i = 0; i < onLoadArray.length; i++) {
        eval(onLoadArray[i]);
    }
}
function addOnLoadHandler(expr) {
    onLoadArray[onLoadArray.length] = expr;
}
function silentError() {
    return true;
}
function handleReSize() {
    window.location.reload();
}
function init(verbose) {
    var theAppVersion = parseInt(navigator.appVersion);
    if (theAppVersion < 5) {
         if (navigator.appName == "Netscape") {
                window.onresize = handleReSize;
         }
    }
    if (!verbose) {
        window.onerror = silentError;
    }
}

// Login.js

function launchWindow(url, name, height, width) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  return window.open(url, name, str);
}

// MediaPopup.js

function aviWin(src,title,brandImage) {
path = "/media/popup_avi.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function movWin(src,title,brandImage) {
path = "/media/popup_mov.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function rmWin(src,title,brandImage) {
path = "/media/popup_rm.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function raWin(src,title,brandImage) {
path = "/media/popup_ra.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function wavWin(src,title,brandImage) {
path = "/media/popup_wav.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function ipxWin(src,title,brandImage) {
path = "/media/popup_ipx.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=400';
brand(520,420,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function swfWin(src,title,brandImage) {
path = "/media/popup_swf.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function newWindow(url,title) {
  gallery=window.open(url, title, 'scrollbars=no,width=470,height=650,left=0,top=0')
}

function gif_jpg_Win(src,title,brandImage) {
path = "/media/popup_gif_jpg.jhtml?src=" + src + "&title=" +title;
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=310';
brand(427,347,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function slideshowWin(src,title,brandImage) {
path = "/media/popup_ss.jhtml?src=" + src + "&title=" +title + "&slidenum=1";
attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=480';
brand(680,600,brandImage);
gallery=window.open(path,"graph",attrs);
gallery.focus();
}

function brand(bSize,noBSize,brandImage) {
   if (brandImage != '') {
       path += "&brandImage="+brandImage;
       attrs += ",height="+bSize;
   } else {
       attrs += ",height="+noBSize;
   }
}

// LegacyPopup.js

function basicwrapsmall(slideshow) {
    path = "/wrappers/theater/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=270,height=392')
} 

function basicwraplarge(slideshow) {
    path = "/wrappers/theater/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=330,height=420,left=5,top=30')
} 

function nbatvwrapsmall(slideshow) {
    path = "/wrappers/nbatv/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=215,height=300')
} 

function nbatvwraplarge(slideshow) {
    path = "/wrappers/nbatv/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=310,height=400,left=5,top=30')
}

function allstarwrapsmall(slideshow) {
    path = "/wrappers/allstar2000/theater/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=270,height=370')
} 

function allstarwraplarge(slideshow) {
    path = "/wrappers/allstar2000/theater/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=330,height=420,left=5,top=30')
}

function courtsidewrap(slideshow) {
    path = "/wrappers/theater/courtside/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable=no,width=270,height=392')
} 

function usabsmall(slideshow) {
    path = "/wrappers/usab/theater/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable="no",width=270,height=392')
} 

function usablarge(slideshow) {
    path = "/wrappers/usab/theater/wrappers/" + slideshow + ".html"; 
    gallery=window.open(path,"graph",'toolbar=0,menubar=0,scrollbars=0,SCROLLING=NO,resizable="no",width=330,height=420')
}

function open_window(url) {
    var path = url;
    if( url.search(/^http:/) == -1 ) {
        path = "/popups/" + url;
    } else {
        var nbaDomain = new RegExp("/^http:\/\/www.nba.com\/([.*]*)/");
        var result = url.match(nbaDomain);
        if( result != null ) {
            path = "/popups/" + result[1];
        } else {
            path = url;
        }
    }
    mywin=window.open(path,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=yes,width=600,height=600');
}

function open_window_ex(url, title, height, width) {
    var path = url;
    if( url.search(/^http:/) == -1 ) {
        path = "/popups/" + url;
    } else {
        var nbaDomain = new RegExp("/^http:\/\/www.nba.com\/([.*]*)/");
        var result = url.match(nbaDomain);
        if( result != null ) {
            path = "/popups/" + result[1];
        } else {
            path = url;
        }
    }
    var opts = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes';
    opts += ',width=' + width;
    opts += ',height=' + height;
    mywin=window.open(path,title,opts);
}
