$(function() {
	// Dialog
	$(".modal").colorbox({ overlayClose:false, opacity:0.4, maxWidth:850, initialWidth:80, initialHeight:80 });
	
	// global loading spinner
	$('#status').hide()
		.ajaxStart(function() { $(this).show(); })
		.ajaxStop(function() { $(this).hide(); });
});

submitForm = function(div,url,formName){
	var dataString = $("#"+formName).serialize();
	$("#"+div).fadeTo('slow',0.5);
	$.ajax({  
		type: "POST", url: url, data: dataString,  
		error: function(msg,msg2,errorMsg){
			$("#"+div).fadeTo('slow',1.0);
			alert('error returned in call to '+url+': '+errorMsg);
		},
		success: function(msg) {
			$("#"+div).html(msg);
			$("#"+div).fadeTo('slow',1.0);
		}
	});  
	return false;
}
submitFormModal = function(url,formName,evalFunctions){
	var dataString = $("#"+formName).serialize();
	$.ajax({  
		type: "POST", url: url, data: dataString,  
		error: function(msg,msg2,errorMsg){
			alert('error returned in call to '+url+': '+errorMsg);
		},
		success: function(msg) {
			$.colorbox.close();
			eval(evalFunctions);
		}
	});  
	return false;
}
loadContent = function(div,url){
	//alert('loading div ('+div+') with url ('+url+')');
	$("#"+div).fadeTo('slow',0.5);
	$("#"+div).load(url, function(response) {
		//alert('performing load of "'+url+'" into div "'+div+'"...\nRESPONSE: '+response);
		$("#"+div).fadeTo('slow',1.0);
		$(".modal").colorbox({ overlayClose:false, opacity:0.4, maxWidth:850, initialWidth:80, initialHeight:80 }); // Create needed dialogs
	});
}
// Style
updateStyles = function(){
	$(".modal").colorbox({ overlayClose:false, opacity:0.4, maxWidth:850, initialWidth:80, initialHeight:80 }); // Create needed dialogs
	$(".inlinemodal").colorbox({ inline:true, overlayClose:false, opacity:0.4, maxWidth:850, initialWidth:80, initialHeight:80 }); // Create needed dialogs
}
/*
fadeIn = function(div) {
	if($(div).fade){ $(div).fade({ duration: 0.3, from: 0.0, to: 1 }); }
	$('shipmentsBox').show();
}
*/