if(typeof abcdm==="undefined"){abcdm={};}
if(typeof abcdm.abc==="undefined"){abcdm.abc={};}
if(typeof abcdm.abc.com==="undefined") {abcdm.abc.com={};}
if(typeof abcdm.abc.com.utils==="undefined") {abcdm.abc.com.utils={};}
abcdm.abc.com.utils.lightfep = {
	_openWindows: {},
	newWindow: function(url, windowName, windowWidth, windowHeight, windowScrollable, windowResizeable, left, top, restrictOneWindow){
		var popupWidth = windowWidth || 1000;
		var popupHeight = windowHeight || 675;
		var ifScrollBar = windowScrollable || 0;
		var windowLeftPosition = left || 0;
		var windowTopPosition = top || 0;
		var isResizeable = windowResizeable || 0;
		var win = null;
		
		var winObj = this._openWindows[windowName];
		var windowExists = function(windowName) {
			if (typeof winObj == "undefined" || winObj == null || winObj.closed || !winObj.location) {
				//alert("window does not exist");
				return false;
			}
			//alert("window already exists");
			return true;
		};

		if((typeof(screen.availHeight) != "undefined" && screen.availHeight < popupHeight+49) || (typeof(screen.availWidth) != "undefined" && screen.availWidth < popupWidth+10)){
			    ifScrollBar = 1;
		}
		var popupParams = "height=" + popupHeight + ",width=" + popupWidth + ",toolbar=0,scrollbars=" + ifScrollBar + ",location=0,statusbar=0,menubar=0,resizable=" + isResizeable + ",top=" + windowTopPosition + ",left=" + windowLeftPosition;

		
		if(typeof restrictOneWindow != "undefined" && restrictOneWindow == true) {
			var openWindow = windowExists();
			if (openWindow) {
				//alert("focus window");
				this._openWindows[windowName].focus();
				this._openWindows[windowName].location.href = url;
			} else {
				//alert("open new window");
				if(url) win = window.open(url, windowName, popupParams);
				this._openWindows[windowName] = win;
			}
			
		}
		else{
			if(url) win = window.open(url, windowName, popupParams);
		}
	},
	launch:function(show, video, collectionitem, collectionvideo) { burl = 'http://fep.abc.go.com/fep/player'; burl += '?src=abccomjs'; if(show != null) burl += ('&show=' + show); if(video != null) burl += ('&episode=' + video); if(collectionitem != null) burl += ('&collectionitem=' + collectionitem); if(collectionvideo != null) burl += ('&video=' + collectionvideo); if(location.search.substring(1) != '') burl = burl + "&" + location.search.substring(1); rr = abcdm.abc.com.utils.lightfep.newWindow(burl,'player_window',1000,675,1,1,(screen.availWidth/2)-500,(screen.availHeight/2)-337.5,true); if(rr != null) { try { rr.focus(); } catch(e) {}}; return rr;}
};