var curIndex = 0;

function toPage(link, order, tab_url) {
		document.getElementById('scrollable').scrollTop = 0;
	
		var api = $("#scrollable").scrollable({size: 1, api: true});
		
		if (curIndex < order) {
			api.move(order - curIndex, function(){
				if (tab_url) {
					loadTab(tab_url);
				} else {
					loadTagCloud();
					link_repl();
					$("a.zoom1").fancybox({
						'zoomSpeedIn'		:	500,
						'zoomSpeedOut'		:	500
					});
                    corners();

				}
				document.title = 'Grafija';
			});
		} else if (curIndex > order) {
			api.move(-(curIndex - order), function(){
				if (tab_url) {
					loadTab(tab_url);
				} else {
					loadTagCloud();
					link_repl();
					$("a.zoom1").fancybox({
					'zoomSpeedIn'		:	500,
					'zoomSpeedOut'		:	500
    				});
                    corners();
				}
				document.title = 'Grafija';
			});
		} else if (curIndex == order) {
			if (tab_url) {
				loadTab(tab_url+'/');
			} else {
				loadTab(link+'/');
			}
			document.title = 'Grafija';
		}
		
		curIndex = order;
		window.location.hash = link;
		document.title = 'Grafija';
		
}

function loadTagCloud() {
	swfobject.embedSWF(
		"/flash/text_and_image_cloud.swf", "tag_cloud1_asdasd",
		"290", "290",
		"10", "/flash/expressInstall.swf",
		{
			cloud_data:"asd.xml",
			tcolor:"0x999999",
			tcolor2:"0x666666",
			hicolor:"0x494949",
			tspeed:"250",
			fontFace:"Times New Roman"
		},
		{
			wmode: "window", menu: "false", quality: "best"
		}
	);
}
