function asAviWin(src,title,brandImage,brandImageLink) 
{
	asSelectTemplate('RM');
	path += "&src=" + src + "&title=" +title;
	attrs = 'toolbar=0,menubar=0,scrollbars=0,scrolling=no,resizable="no",width=355';
	asBrand(462,462,brandImage,brandImageLink);
	gallery=window.open(path,asNewWinName(),attrs);
	gallery.focus();
}

var jsPath = 'http://www.nba.com/popups/';
function asSelectTemplate(clipType)
{
	//create a string in the form of jsPath/vidPopup_browser_clipType.html
	path = jsPath + 'vidPopup_';
	if((clipType == 'RA') || (clipType=='RM'))
	{
		path+= 'rn.html'
	}else
	{
		path+= 'ms.html'
	}
	path+= '?clipType=' + clipType;
}

function asBrand(bSize,noBSize,brandImage,brandImageLink) {
   if (brandImage != '') {
       path += "&brandImage="+brandImage;
       if (brandImageLink != '') {
	   		path += "&brandImageLink="+brandImageLink;
       }
       attrs += ",height="+bSize;
   } 
   else {
       attrs += ",height="+noBSize;
   }
}
//Reason: Real player on ie will explode if re-opened in same window
function asNewWinName()
{
	return('vidWin' +(new Date).valueOf());
}

//Generic Open-Window function
function open_window_ex(url, title, height, width, options) {
    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 = '';
	if(options == null || options == "null")
		opts = 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=yes, resizable=yes';
    else
		opts = options;
		
	opts += ',width=' + width;
    opts += ',height=' + height;
    mywin=window.open(path,title,opts);
}
