

menu_1 = new Image();
menu_1.src = ROOT + 'inc/img/ajax-loader.gif';

menu_2 = new Image();
menu_2.src = ROOT + 'inc/img/html/lo.gif';

menu_3 = new Image();
menu_3.src = ROOT + 'inc/img/html/ro.gif';

function ladebalken(on) {
	var grafik = '<img style="" src="'+menu_1.src+'" alt="load">';

	if(on)
	{
		$('#ajax_load').css('background','url(' + menu_1.src + ') right center no-repeat');
	}
	else
	{
		$('#ajax_load').css('background','none');
	}

}


var aktuelle_url = false;





function ajax_refresh(get) {

	var ajaxcontent = '#ajaxcontent';


	if(userID || aktuelle_url == false) {
		$('#ajax_load').css('background','url(' + menu_1.src + ') right center no-repeat');
		//$(ajaxcontent).fadeTo(500, 0.33, function () {
			url = aktuelle_url;
			$.ajax({
				dataType: 'html',
				async: false,
				//url: url,
				data: 'ajax&' + get,
				beforeSend: function(){

				},
				success: function(data){
					//alert(this.url)
					$(ajaxcontent).html(data);
				},
				complete: function() {
					//$(ajaxcontent).fadeTo(500, 1, function() {
	   					//this.style.removeAttribute('filter');
					//});
					setTimeout("$('#ajax_load').css('background','none');", 50);
				}
			});
		//});
	}else{

		$('#ajax_load').css('background','url(' + menu_1.src + ') right center no-repeat');
		$(ajaxcontent).fadeTo(200, 0.1, function () {

		//});
			url = aktuelle_url;
			$.ajax({
				dataType: 'html',
				async: false,
				url: url,
				data: 'ajax&' + get,
				beforeSend: function(){

				},
				success: function(data){
					//alert(this.url)
					$(ajaxcontent).html(data);
				},
				complete: function() {
					$(ajaxcontent).fadeTo(400, 1, function() {

						if(jQuery.browser.msie) {
							// Nur im IE
	   						this.style.removeAttribute('filter');
						}

					});
					setTimeout("$('#ajax_load').css('background','none');", 50);
				}
			});
		});
	}
}


function _ajax_refresh(get, url) {
	var ajaxcontent = '#content';


	aktuelle_url = url;

	$('.ajax-load').css('display','block').fadeTo(150, 1);

	$(ajaxcontent).fadeTo(200, 0.1, function () {
		$.ajax({
			dataType: 'html',
			async: false,
			url:url,
			data: 'ajaxbody&' + get,
			beforeSend: function(){
				//$("#ajaxcontent").fadeOut("slow");
				//$('#ajax_load').css('background','url(' + menu_1.src + ') right center no-repeat');

			},
			success: function(data){
				$(ajaxcontent).html(data);
			},
			complete: function() {
				$(ajaxcontent).fadeTo(300, 1, function() {

					if(jQuery.browser.msie) {
   						this.style.removeAttribute('filter');
					}


				});

				//$('.ajax-load').fadeTo(150, 0);
				setTimeout("$('.ajax-load').fadeTo(300, 0);", 100);


			}
		});
	});

	return false;
}



	// PageLoad function
	// This function is called when:
	// 1. after calling $.historyInit();
	// 2. after calling $.historyLoad();
	// 3. after pushing "Go Back" button of a browser
	function pageload(hash) {
		// alert("pageload: " + hash);
		// hash doesn't contain the first # character.
		if(hash) {
			// restore ajax loaded state
			if($.browser.msie) {
				// jquery's $.load() function does't work when hash include special characters like aao.
				//hash = encodeURIComponent(hash);
			}
			_ajax_refresh(false, hash);
			//$("#load").load(hash + ".html");
		} else {
			// start page
			//$("#load").empty();
		}
	}


$(document).ready(function() {

	//$.history.init(pageload);

	//$('.ajax-load').css('background','url(' + menu_1.src + ') right center no-repeat');

	$.historyInit(pageload, http_root);

	if(!userID) {

	    $("a").click(function () {
	    	if(this.href) {
	    		//var regexp = new RegExp('^([http://|http://www.]+)([a-zA-Z0-9_\\.]*)' + DOMAIN + '(.*)/$', 'gi');
	    		var regexp = new RegExp('^([http://www.]+)' + DOMAIN + '(.*)/$', 'gi');
	    		var erg = regexp.exec(this.href);
	    		if(erg) {
	    			//  class="remote"
	    			//$(this).addClass('remote');

	    			//$.history.init(callback);

	    			// neu
	    			//$.history.load(this.href.substring(http_root.length - 1, this.href.length).replace(/^.*#/, ''));
	    			//$.history.load(this.href.replace(/^.*#/, ''));
        			//return false;

					var hash = this.href;
					hash = hash.replace(/^.*#/, '');
					// moves to a new page.
					// pageload is called at once.
					// hash don't contain "#", "?"
					$.historyLoad(hash);
					return false;


        			// alt
	    			_ajax_refresh(false, this.href);
	    			//alert(8);
	    			return false;
	    		}
	    	}
		});

	}


     $(".banner").flashembed({
		src:  ROOT + 'inc/swf/marseo_banner_02.swf',
        width: 979,
        height: 248,
		wmode: 'transparent'
	});


	if($('.header').html() == false) {
		$.ajax({
			type: 'GET',
			async: false,
			url: ROOT + 'webdesign-glossar',
			data: 'ajax_header',
			success: function(data){
				//alert(data);//
				$('.header').html(data);
			}
		});
	}




	$("#openaz").bind('mouseover', function(e){
    	try {
        	$(".az").css("color", "#FF9900");
        	$("#az").css("display", "inline");

    	} catch(e) {
			// nichts
		}
	});

	$("#az span").bind('mouseover', function(e){
    	try {
			uli = $(this).children()[1];
        	$(uli).css("display", "block");
        	$(uli).hover(function(){
            	$(this).css("display", "block");
        	}, function(){
            	$(this).css("display", "none");
        	});
    	} catch(e) {
			// nichts
		}
	});


	$("#az").bind('mouseout', function(e){
    	$("#az span span").css("display", "none");
    	$("#az").css("display", "none");
    	//setTimeout('$("#az").css("display", "none");', 1000);
    	$(".az").css("color", "#ccc");
    	//return false;
	});


});


/*
$(function() {
    $('a.remote').remote('#content', function() {
        if (window.console && window.console.info) {
            console.info('content loaded');
        }
    });
    $('a.history:eq(0)').history(function() {
        $('#show-hide').hide();
    });
    $('a.history:eq(1)').history(function() {
        $('#show-hide').show();
    });

    $.ajaxHistory.initialize();
});
*/




function navi_auf(id)
{
	if(jQuery.browser.msie && jQuery.browser.version < 7) {
		$("#href" + id).css("color","#fff");
		$("#li" + id).css("background","url(" + ROOT + "inc/img/html/transparent.png)");
		return false;
	}

	$("#navi" + id).css("display","block");
	$(".li" + id).css("background","url(" + ROOT + "inc/img/html/transparent.png)");
	$("#li" + id).css("background","url(" + ROOT + "inc/img/html/transparent.png)");
	$("#eckelo" + id).css("background","url(" + ROOT + "inc/img/html/lo.gif) left top no-repeat");
	$("#eckero" + id).css("background","url(" + ROOT + "inc/img/html/ro.gif) right top no-repeat");
	$("#href" + id).css("color","#fff");
}

function navi_zu(id)
{
	$("#navi" + id).css("display","none");
	$(".li" + id).css("background","#fff");
	$("#li" + id).css("background","#fff");
	$("#eckelo" + id).css("background","none");
	$("#eckero" + id).css("background","none");
	$("#href" + id).css("color","#3399CC");
}

function email(k,v)
{
	var name = k;
	var domain = v;
	var param = '';
	if(name == 'waschkawitz') {
	 param = '?cc=support@marseo.de&body=Sehr geehrter Herr Waschkawitz,'+escape("\n\n\n\n")+'Mit freundlichen '+escape("Grüßen,\n\n")+'&subject=Anfrage';
	}

	document.write('<a title="'+k+'@'+v+'" h');
	document.write('r');
	document.write('e');
	document.write('f');
	document.write('="');
	document.write('m');
	document.write('a');
	document.write('i');
	document.write('l');
	document.write('t');
	document.write('o');
	document.write(':');
	document.write(name);
	document.write('@');
	document.write(domain+param);
	document.write('">');
	document.write(name);
	document.write('@');
	document.write(domain);
	document.write('</a>');

}
