
/****************************************************************************

  This file is part of the GamesCast.tv Website

	GamesCast.tv coded by Steve "GreasedScotsman" Huff, 
	Copyright 2010 Steve Huff
	
	It is distributed under the terms of the 
	GNU General Public License
		
***************************************************************************/

$(document).ready(function(){

	$("#previewDialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 'auto',
		width: 214,
		position: ['left','center'],
		modal: false,
		resizable: false,
		buttons: {
			'Switch': function () { 
				var showName = $('#miniplaceholder').attr("title");
				$('#miniplaceholder').html("");
				$("#previewDialog").dialog('close');	
				updateAll(showName, nowlocal);
			},
			Cancel: function() {
				$("#previewDialog").dialog('close');
			}
		},
		close: function() {
			// do nothing
		}
	});
	
});

var dwrap = [false, false];

// fix for dialogs not getting the class-scoped dialog UI theme
function PreviewDialogTheme(dialog){
	switch (dialog){
		case 0 :
			if( !dwrap[0] ){ 
				$("div[aria-labelledby*='ui-dialog-title-previewDialog']").wrap("<div class='gctvtheme'></div>"); 
				dwrap[0] = true; 
			}

			//for overlay no good way but i dont see another
			$(".ui-widget-overlay").wrap("<div class='gctvtheme'></div>"); 
		break; 
		case 1 : 
			if( !dwrap[1] ){
				$("div[aria-labelledby*='ui-dialog-title-previewDialog']").wrap("<div class='gctvtheme'></div>"); 
				dwrap[1] = true; 
			}
		break; 
		default : 
		break; 
	}
}

function showPreview(sID) {
		$('#miniplaceholder').attr("title", sID);
		
		$.get("data/miniplayer.php", { sID: sID }, 
		function(data) {
			//alert("Preview data: \n\n"+data);
			$("#miniplaceholder").html(data);
			
			$('#previewDialog').dialog('open');
			PreviewDialogTheme(0);
		}
	);
}


// EOF
