var j = jQuery.noConflict();
var $ = j;

j(document).ready(function(){
	j.fn.createDialog.defaults = {
		progress: true,
		center: true,
		opacity: 0.7,
		bg: '#000'
	}
	j("#clickme").createDialog({
		addr: 'dialog.htm',
		opacity: 0.9
	});

	

	/*j("#pollingBtn").createDialog({
		addr: 'index.php',
		bg: '#000000',
		form: '#pollingForm'
	});*/

	/*j(".actionItem").createDialog({
		addr: 'index.php',
		bg: '#000000',
		process: processActionItem
	});*/
	j(".actionItem").click(function(){
		//alert(j(this).attr("aId"));
		var id = j(this).attr("aId");
		var img = j(this).attr("aImg");
		//openCenteredWindow('index.php?actId=' + id, '', 800, 539, 0, 0, '', 'popupWindow');
		openCenteredWindow('popup.php?url=' + img, '', 800, 539, 0, 0, '', 'popupWindow');
	});
	/*j("#pollingBtn").click(function(){
		var query = j("#pollingForm").formSerialize();
		alert(query);
	});*/
	
});

function processActionItem(opts, obj)
{
	//alert($(obj).attr("aId"));
	opts.addr = "index.php?actId=" + $(obj).attr("aId");
	return opts;
}


$(function(){
	//$("#container").minmax();
	/*$("#container").resize(function(){
		$(this).minmax();
	});*/
	adjustColHeights();

	$.fn.createDialog.defaults = {
       		progress: true,
       		center: true,
	       	opacity: 0.7,
	       	bg: '#FFF'
       }
	

	//$("#pollingBtn").click(function(){
		//$("#pollingForm").submit();
		
	//});

	$('#jqmDialog').jqm({ajax: getPollingData, trigger: '#pollingBtn'});	
	
});

function adjustColHeights()
{
	var contentHeight = $("#content").height();
	var colLeftHeight = $("#colLeft").height();
	var colRightHeight = $("#colRight").height();
	if(colLeftHeight > contentHeight)
		$("#content").height(colLeftHeight);
	else if(colRightHeight > contentHeight && colRightHeight > colLeftHeight)
		$("#content").height(colRightHeight);
	//alert(contentHeight + ":" + colLeftHeight + ":" + colRightHeight);
}

function getPollingData()
{
	var data = $("#pollingForm").formSerialize();
	//alert(data);
	return "index.php?" + data;
}

