
cGUI = function() {

	this.init = function(result) {
		if (!result) result = 'yes';
		this.container = '';
		this.loaded = '';
		this.queueing = false;
		//$.historyInit(pageload);
		
//		alert(typeof GUI.loaded);
	};

	
	this.load = function(url, target, source, callback, reurl, history) {
		if (!target) target = 'content_box';
		if (!source) source = 'content_box';
		if (!callback) callback = 'void(0);';
		if (!reurl) reurl = 'yes';
		if (!history) history = 'yes';
//		reurl = 'no';
/*		if (GUI.loading == true) {
			setTimeout(function(){
				GUI.load(url, target, source, callback, reurl);
			}, 250);
			return;
		}*/
		GUI.loading = true;

		if (url.indexOf(window.location.hostname) != -1) {
			url = (url.substr(url.indexOf(window.location.hostname) + window.location.hostname.length));
		}

		if (history != 'no') {
			url = url.replace(/^.*#/, '');
			$.historyLoad(url);
			return;
		}

		if (reurl == 'yes') url = '/ajax' + url + '/' + source;
		if (target == 'content') {
			$('#' + target).css({position: 'relative'});
			$('#' + target).append('<div class="loadingContent" style="position: absolute; top: 0px; left: 0px; background: #333; width: ' + $('#' + target).width() + 'px; height: ' + $('#' + target).height() + 'px;"></div>');
			$('.loadingContent').css({opacity: 0.1, cursor: 'wait', zIndex: 1000});
		};
		$.post(url, function(data){
				GUI.loading = false;
				if (reurl == 'yes') {
					$('#' + target).html(data);
				} else {
					$('#' + target).html($(data).find('#' + source).html());
				}
				if (typeof GUI.searchHighlight != 'undefined') GUI.searchHighlight();
				GUI.postLoad();
				eval(callback);
				GUI.loaded = url;
//				alert(GUI.loaded);
		});
	};

	this.open = function(url) {
		window.location.replace(url);
	};

	this.postLoad = function(){

		
	};

    this.loadFlash= function(url, div, width, height){
        if (!url) url = '/swf/header_705x150.swf';
        if (!div) div = 'flash_box';
        if (!width) width = '705';
        if (!height) height = '150';

		var so = new SWFObject(url, 'flash', width, height, '9.0.124', '#FFF');
			so.useExpressInstall(JS_LIBS_URL + 'libs/swfobject1_5/expressinstall.swf');
//			so.addParam('allowScriptAccess', 'always');
//			so.addParam('allowFullScreen', 'true');
			so.addParam('menu', 'false');
		so.addParam('wmode', 'transparent');
//		so.addParam('wmode', 'opaque');
		so.setAttribute('xiRedirectUrl', 'http://www.proknihovnu.cz/');
		//so.addVariable("lang", 'cs');
			so.write(div);
	};
};

	

cGUI.prototype.resize = function(height, width, target) {
	if (!width) width = $(target).width();
	if (!height) height = $(target).height();
	$(target).animate(
		{
			"height": height + "px",
			"width": width + 'px'
		}
	);
};

var GUI = new cGUI();

$(function(){
	GUI.init('no');
	GUI.hash_test = '';
	GUI.loading = false;
    
});