
var pageSizer = function(){
	var viewport = dojo.html.getViewport();
	dojo.byId("mainWrapper").style.height = viewport.height - 160;
	dojo.widget.byId("mainTabContainer").onResized();
};



function gotoAlbum(album, offset){
	var albumTab = dojo.widget.byId("album" + album);
	if(offset == null) offset = 0;

	if(albumTab == null){
		dojo.io.bind ({
    		url: 'data/rpc.php?album=' + album,
    		mimetype: "text/plain",
	        load: function(result, data){
//	        	dojo.debug("result: " + result + " - " + data);
	        	var tab = dojo.widget.createWidget("ContentPane", 
	        				{href: 'thumbs.php?album='+album + '&offset=' + offset, 
	        				label: data, 
	        				widgetId: "album" + album, 
        					refreshOnShow: false,	        			
							cacheContent: true,						
	        				closable: true});
	        	dojo.widget.byId("mainTabContainer").addChild(tab);
	        	dojo.widget.byId("mainTabContainer").selectChild(tab);	        	
	        			
	        }
     	});
     	return;
	}
	albumTab.setUrl('thumbs.php?album='+album + '&offset=' + offset);
	dojo.widget.byId("mainTabContainer").selectChild(albumTab)
}

function gotoImage(image, album){
	var pane = dojo.widget.byId("imageWidget");
	if(pane != null){
		pane.setUrl("image.php?image=" + image);
		return;
	}
	
	dojo.io.bind ({
    		url: 'data/rpc.php?album=' + album,
    		mimetype: "text/plain",
	        load: function(result, data){	
        		var div=document.createElement("div");        		        		
				div.style.position="absolute";

				var offset = dojo.html.getScroll().offset;
				var viewport = dojo.html.getViewport();
				
				var width= 750;
				if(viewport.width < width){
					width = viewport.width;
				}
//				dojo.debug("x: " + offset.x + " " + width  + " " + ( (viewport.width-width)/2 ));
			 	div.style.left= (viewport.width-width)/2  ;
			 	div.style.width= width;
				
		
			 	div.style.top= offset.y + 5;
			 	div.style.height = viewport.height-6;
																
				div.innerHTML="Initial <i>dummy</i> <b>div</b> contents";
//				dojo.debug(div.style.width + " - " + div.style.height);
	        	var options = { widgetId : 'imageWidget',
	        					title: data,
								constrainToContainer: false,
								refreshOnShow: true,
								cacheContent: true,
								resizable: true,	
								displayCloseAction: true,
							 	displayMaximizeAction: "true",
	        					executeScripts: "true",
	        					templateCssPath: "FloatingPane.css"
	        					};
				document.body.appendChild(div);
      			dlgProg = dojo.widget.createWidget("dojo:FloatingPane", options, div);
				dlgProg.setUrl("image.php?image=" + image);				
	        	dlgProg.show();											      	
	        }
	   });
	        
	
}


function gotoGroup(group){
	var groupTab = dojo.widget.byId("group" + group);

	if(groupTab == null){
		dojo.io.bind ({
    		url: 'data/rpc.php?group=' + group,
    		mimetype: "text/plain",
	        load: function(result, data){
//	        	dojo.debug("result: " + result + " - " + data);
	        	var tab = dojo.widget.createWidget("ContentPane", 
	        				{	href: 'albums.php?group='+group, 
	        					label: data, 
	        					widgetId: "group" + group, 
	        					closable: true, 
	        					refreshOnShow: false, 
	        					cacheContent: true});
	        	dojo.widget.byId("mainTabContainer").addChild(tab);
	        	dojo.widget.byId("mainTabContainer").selectChild(tab);	        	
	        			
	        }
     	});
     	return;
	}
			
	dojo.widget.byId("mainTabContainer").selectChild(groupTab)
}
