/**
 * Jump among pages
 */
var currentPage = 1;
var moving = false;
function jumpToPage(offset, i){
	if(i==currentPage || moving){
		return;
	}
	
	if($('list'+i)){
		$('list'+i).setStyle({
			backgroundColor: '#00a8e9'
		});
	}
	
	if($('list'+currentPage)){
		$('list'+currentPage).setStyle({
			backgroundColor: ''
		});			
	}
		
	
	moving = true;
	new Effect.Move('paging', { x: 0, y: offset*(currentPage-i), afterFinish: function(){
		moving = false;
	}});
	currentPage = i;
}


function activateCurrentPage(){
	currentPage = 1;
	if($('list'+currentPage)){
		$('list'+currentPage).setStyle({
			backgroundColor: '#00a8e9'
		});		
	}
}


/**
 * Opens the CEDE window
 */
function openWindow(f, w, h){
	var params = '';
	var params = 'left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2)+',width='+w+',height='+h+',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
	window.open(f,'win', params);
}

/**
 * Does the ajax call to retrieve content.
 * @param url
 * @return
 */
function doAjax(url){
	$('content').update("<div id='sloading'><img src='/starticketinside/static/images/loading.gif' width='300' height='95' border='0' /></div>");
	new Ajax.Request(url,
			{
			method:'post',
			onSuccess: function(transport){
					var response = transport.responseText || "Server not available. Try again!";
				$('content').update(response);
			},
			onFailure: function(){ 
				if(!$('content').empty()){
					$('content').update('');
				}
			}
		});		   	
}



function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}