/**
 * LICENSE
 *
 * This source file is subject to the EWS Software License that is bundled
 * with this package in the file LICENSE.txt.
 * If you did not receive a copy of the license please send us an email
 * so we can send you a copy immediately.
 * Permission to copy and distribute verbatim copies of this source
 * are not granted.
 *
 * @copyright 	Copyright (c) 2008-2009 entrance web studio
 * @license	EWS Software License
 */

/**
 * hauer.js - global javascript functions for hauer-labels.at
 *
 * @module				prder 		
 * @copyright 		Christoph Lukas Lindtner, entrance web studio
 *
 * @dependencies	Prototype 1.6, jQuery
 */
 
/** 
 * Shows a content by id or url
 *
 * @param int id
 * @return void
 */
function requestContent ( url , id ) {
	var body = $ ( "body" );
	jQuery ( body ).hide ();
	
	$ ( "loader" ).show ();
	
	var data = null;
	if ( id != undefined )
		data = { "cid" : id };
	
	shell.wait ();
	jQuery ( body ).load ( url , data , onLoadContent );
}


/**
 * Invokes if content has been loaded.
 *
 * @param String data
 * @param String textStatus
 * @param XMLHttpRequest request
 * @return void
 */
function onLoadContent ( data , textStatus , request ) {
	shell.resume ();
	$ ( "loader" ).hide ();
	
	var body = $ ( "body" );
	jQuery ( body ).show ();
	
	if ( textStatus != "success" )
		jAlert ( "Verbindung wurde unterbrochen!" , "Transport Fehler" );
}

/**
 * Search
 *
 * @param Event e 
 * @return void
 */
function searchContent ( value , url ) {
	var body = $ ( "body" );
	jQuery ( body ).hide ();
	
	$ ( "loader" ).show ();
	
	shell.wait ();
	jQuery ( body ).load ( url , { "q" : String ( value ) } , onLoadContent );
}
