
jQuery.fn.fadeIn = function(speed, callback) { 
    return this.animate({opacity: 'show'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeOut = function(speed, callback) { 
    return this.animate({opacity: 'hide'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 

var regions = new Array();

function loadRegions(select_src, select_dst, dependencies)
{
	var id 		= select_src[select_src.selectedIndex].value;
	
	if (id != 'choose')
	{
		var data 	= "/libs/js/regions/"+id+".js";

	 	regions = new Array();
		$.getScript(data, function()
		{
	     	var options = '<option value="choose">Bitte wählen</option>';
	     	if (regions.length > 0)
	     	{
				for (var key in regions) 
		   		{
		     		options += '<option value="' + key + '">' + regions[key] + '</option>';
		   		}
		   		$("select#"+select_dst).html(options);
		   		$("select#"+select_dst).show();
	   			$("."+select_dst).show();
	     	}
	     	else
	     	{
	       		$("select#"+select_dst).html('');
	       		$("select#"+select_dst).hide();
	    		$("."+select_dst).hide();
	     	}
		});
	}
	else
	{
   		$("select#"+select_dst).html('');
   		$("select#"+select_dst).hide();
		$("."+select_dst).hide();
	}
	
	for (var key in dependencies)
	{
		$("select#"+dependencies[key]).html('');
   		$("select#"+dependencies[key]).hide();
   		$("."+dependencies[key]).hide();
	}
}

function loadOptions(funcname, select_src, select_dst)
{
	var id 		= document.getElementById(select_src)[document.getElementById(select_src).selectedIndex].value;
	if (id != 'choose')
	{
		$("select#"+select_dst).load("ajax", {func: funcname, selected: id}, function()
		{
	   		$("select#"+select_dst).show();
   			$("."+select_dst).show();
		});
	}
	else
	{
   		$("select#"+select_dst).html('');
   		$("select#"+select_dst).hide();
		$("."+select_dst).hide();
	}
	
}

function hideOptionsOn(cond, select_src, select_dst)
{
	var id 		= document.getElementById(select_src)[document.getElementById(select_src).selectedIndex].value;
	if (id != cond)
	{
   		$("select#"+select_dst).show();
		$("."+select_dst).show();
	}
	else
	{
   		$("select#"+select_dst).hide();
		$("."+select_dst).hide();
	}
}

function hideInputOn(cond, select_src, dst)
{
	var id 		= document.getElementById(select_src)[document.getElementById(select_src).selectedIndex].value;
	if (id == cond)
	{
   		$("#"+dst).show();
	}
	else
	{
   		$("#"+dst).hide();
	}
}

function changeOnValue(select_src, key_src, select_dst, key_dst)
{
	var id = document.getElementById(select_src)[document.getElementById(select_src).selectedIndex].value;
	
	if (id == key_src)
	{
		$("select#"+select_dst).val(key_dst);
	}
}

function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
function preworkSubmittedData(formData, jqForm, options)
{
	//showRequest(formData, jqForm, options);
}

function workSubmittedData(formData, jqForm, options) 
{
	//showRequest(formData, jqForm, options);
	$(".tabs").tabs().show();
	showInputExamples();
	$('#loading_in_progress').hide();
	return true;
}

function showInputExamples()
{
	$("input,textarea").labelify({labelledClass: "embedded_default_text"});
}

var submit = true;

function submitMe(me)
{
	$('input,textarea', $(me).parents('form')).each(function()
			{
		        	if ($(this).val() == $(this).attr('title'))
		        	{
		        		$(this).val('');
		        	}
			} );
	me.form.submit();
	return false;
}


function submitFormBlock(me, block)
{
	dst = $(me).parents('form').parents('div').attr("id");
	if (dst === undefined)
	{
		submitFormBlockDefault(me, block);
	}
	else
	{
		submitFormBlockThis(me, block);
	}
}

function submitFormBlockDefault(me, block)
{
	$('#default_dialog form input,textarea').each(function()
	{
        	if ($(this).val() == $(this).attr('title'))
        	{
        		$(this).val('');
        	}
	} );
	url = location.href.split(/\?|#/)[0];
	
	dst = $('#default_dialog form').parents('div').attr("id");
	if (dst === undefined)
	{
		dst = 'default_dialog';
	}

	$('#default_dialog form').ajaxSubmit({ 
        target:        '#'+dst,   // target element(s) to be updated with server response 
        // other available options: 
        url:       url+'?block='+block,
        beforeSubmit:	preworkSubmittedData,// override for form's 'action' attribute 
        success:	workSubmittedData// override for form's 'action' attribute 
        //type:      'get'        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    });

	return false;
}


function submitFormBlockThis(me, block)
{
	$('input,textarea', $(me).parents('form')).each(function()
	{
        	if ($(this).val() == $(this).attr('title'))
        	{
        		$(this).val('');
        	}
	} );
	url = location.href.split(/\?|#/)[0];
	
	dst = $(me).parents('form').parents('div').attr("id");
	if (dst === undefined)
	{
		dst = 'default_dialog';
	}

	$(me).parents('form').ajaxSubmit({ 
        target:        '#'+dst,   // target element(s) to be updated with server response 
        // other available options: 
        url:       url+'?block='+block,
        beforeSubmit:	preworkSubmittedData,// override for form's 'action' attribute 
        success:	workSubmittedData// override for form's 'action' attribute 
        //type:      'get'        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    });

	return false;
}

var current_dialog = new Array();

function loadUrl(url, dst)
{
	$("#"+dst).load(url);
	return false;
}

function loadBlock(block, dst)
{
	var argv = loadBlock.arguments;
	var argc = argv.length;

	url = location.href.split(/\?|#/)[0];
	//$("#"+dst).load(url+'?block='+block);
	
	for (var i = 0; i < argc; i+=2)
	{
		$("#"+argv[i+1]).load(url+"?block="+argv[i]);
	}

	return false;
}

var current_title = new Array();
var current_dialog_width = 600;


function setTitle(title, w)
{
	current_title.push(title);
	if (w !== undefined)
	{
		current_dialog_width = w;
	}
	else
	{
		current_dialog_width = 600;
	}
}























var update_blocks = new Array();
var update_callbacks = new Array();
var dialogs = new Array();

function openDialog(block, dynamic_id)
{
	/*
	$('#loading_in_progress').dialog(
	{
		modal: true,
		autoOpen: false,
		width: 200,
		height: 50,
	});
	
	$('#loading_in_progress').dialog("open");
	*/
	
	$('#loading_in_progress').center().show();
	
	//$("body").animate({opacity: 0.5});
	//$("body").fadeTo(300, 0.5);

	if (dynamic_id === undefined)
	{
		dynamic_id = 0;
	}
	
	var container = block.split(/\?|#|&/)[0];
	dialogs.push(container);
	
	$('#'+container).remove();
	$('body').append('<div id="'+container+'"></div>');
	
	var url = location.href.split(/\?|#/)[0];
	$('#'+container).load(url+"?block="+block, {edit_id: dynamic_id}, function()
	{
		var d_title  = $('div:first-child', this).attr('title');
		var d_width  = parseInt($('div:first-child', this).css('width'));
		var d_height = parseInt($('div:first-child', this).css('height'));
		$(".tabs").tabs().show();
		$('#'+container).attr('title', d_title);
		$('#'+container).show();
		
		$('#'+container).dialog(
		{
			modal: true,
			autoOpen: false,
			width: d_width+40,
			height: d_height+65,
			open: function(event, ui) 
			{
				//$("body").animate({opacity: 1.0},0);
				//$("body").fadeTo(0, 1.0);

				
				
			$('#loading_in_progress').hide();
				
				//$('#loading_in_progress').dialog("close");
				$('#'+container).css('minHeight', 0);
				$("span.ui-dialog-title").text(d_title);
			},
			close: function(event, ui) 
			{
				if (dialogs.length > 0)
				{
					while ((current_dialog != container) && (dialogs.length != 0))
					{
						current_dialog = dialogs.pop();
					}
				
					if (dialogs.length != 0)
					{
						while ((current_dialog == container) && (dialogs.length > 0))
						{
							last_dialog = dialogs.pop();
						}
						dialogs.push(last_dialog);
					}

					if (next_dialog = dialogs.pop())
					{
						var next_title  = $('#'+next_dialog+' div:first-child').attr('title');
						//alert("Nächster Titel:"+next_title);
						$("span.ui-dialog-title").text(next_title);
						dialogs.push(next_dialog);
					}
					else
					{
						$("span.ui-dialog-title").text('');
					}
					
					//alert("Container to close:"+container);
					if (update_blocks[container])
					{
						while (update_blocks[container].length > 0)
						{
							var src = update_blocks[container].pop();
							var dst = update_blocks[container].pop();
							//alert('Update '+src+' > '+dst);
							$("+"+dst).css('background-color', '#FFFFFF');
							$("#"+dst).fadeTo(300, 0.5);
							$("#"+dst).prepend($('#reloading_in_progress').html());
							
							$("#"+dst).load(url+"?block="+src+"&override_url_interpretation=1", function()
							{
								$(this).fadeTo(0, 1.0);
							});
						}
					}
					
					if (update_callbacks[container])
					{
						while (update_callbacks[container].length > 0)
						{
							var cb = update_callbacks[container].pop();
							eval(cb+'()');
						}
					}
					
					$('#'+container).remove();
				}
			}
		});
		$('#'+container).dialog('open');
		showInputExamples();
	});
	
}

var show_progressbar = true;

function hideProgressBar()
{
	show_progressbar = false;
}

function submitDialog(me, block, container)
{
	$('input,textarea', $(me).parents('form')).each(function()
			{
		        	if ($(this).val() == $(this).attr('title'))
		        	{
		        		$(this).val('');
		        	}
			} );
	url = location.href.split(/\?|#/)[0];
	
	if (container === undefined)
	{
		container = block.split(/\?|#|&/)[0];
	}
	
	if (show_progressbar)
	{
		$('#'+container).html($('#loading_in_progress').html());
	}

	//$('#dialog_container form').ajaxSubmit
	$(me).parents('form').ajaxSubmit({ 
        target:        '#'+container,   // target element(s) to be updated with server response 
        // other available options: 
        url:       url+'?block='+block,
        beforeSubmit:	preworkSubmittedData,// override for form's 'action' attribute 
        success:	workSubmittedData// override for form's 'action' attribute 
    });

	return false;
}

function closeDialog()
{
	if (block = dialogs.pop())
	{
		dialogs.push(block);
		//alert("Schliesse: "+block);
		$('#'+block).dialog("close");
	}
}

function setUpdateBlocks(block)
{
	var argv = setUpdateBlocks.arguments;
	var argc = argv.length;
	var url = location.href.split(/\?|#/)[0];
	
	update_blocks[block] = new Array();
	for (var i = 1; i < argc; i++)
	{
		//alert(argv[i]);
		update_blocks[block].push(argv[i]);
	}
}

function setUpdateCallbacks(block)
{
	var argv = setUpdateCallbacks.arguments;
	var argc = argv.length;
	var url = location.href.split(/\?|#/)[0];
	update_callbacks[block] = new Array();
	for (var i = 1; i < argc; i++)
	{
		//alert(argv[i]);
		update_callbacks[block].push(argv[i]);
	}
}
function showInfoBox(id)
{
	//$("#"+id).slideDown(1000).animate({opacity: 1.0}, 1000).slideUp(1000);
	var info_title = $('#'+id).attr('title');
	$('#'+id).dialog({
		modal: true,
		autoOpen: false,
		width: 300,
		open: function(event, ui) 
		{
			$('#'+id).css('minHeight', 0);
			$("span.ui-dialog-title").text(info_title);
		} 
	});
	closeDialog();
	//closeCurrentDialog();

	$('#'+id).show();
	$('#'+id).dialog('open');

	return false;
}

function closeInfoBox(id)
{
	$("#"+id).dialog("close");
}

var last_submit_object 		= null;
var last_submit_parameters 	= '';

function submitDialogWithConfirm(me, block, confirm_var, dstoverride)
{
	if (confirm_var === undefined)
	{
		confirm_var = 'delete';
	}
	last_submit_object 		= me;
	last_submit_parameters 	= block+'&'+confirm_var+'=1';
	openDialog('delete_sure');
	
	/*
	$('#sure').dialog({
		modal: true,
		autoOpen: false,
		width: 300,
		close: function(event, ui) {
		
		},
		buttons: {
			"OK": function() {
				submitDialog(me, block+'&'+confirm_var+'=1');
				$(this).dialog("close");
			},
			"Cancel": function() { 
				$(this).dialog("close");
			} 

		}
	});

	$('#sure').dialog('open');
	*/
}

function submitDialogConfirmed()
{
	closeDialog();
	submitDialog(last_submit_object, last_submit_parameters);
}

/*
var update_blocks = new Array();

function openDialog(block, dynamic_id)
{
	if (dynamic_id === undefined)
	{
		dynamic_id = 0;
	}
	
	$('#dialog_container').remove();
	$('body').append('<div id="dialog_container">Hier</div>');
	
	var url = location.href.split(/\?|#/)[0];
	$('#dialog_container').load(url+"?block="+block, {edit_id: dynamic_id}, function()
	{
		var d_title  = $('div:first-child', this).attr('title');
		var d_width  = parseInt($('div:first-child', this).css('width'));
		var d_height = parseInt($('div:first-child', this).css('height'));

		$(".tabs").tabs().show();
		$('#dialog_container').show();
		
		$('#dialog_container').dialog(
		{
			modal: true,
			autoOpen: false,
			width: d_width+55,
			height: d_height+55,
			open: function(event, ui) 
			{
				$('#dialog_container').css('minHeight', 0);
				$("span.ui-dialog-title").text(d_title);
			},
			close: function(event, ui) 
			{
				$("span.ui-dialog-title").text('');
				while (update_blocks.length > 0)
				{
					var src = update_blocks.pop();
					var dst = update_blocks.pop();
					$("#"+dst).load(url+"?block="+src+"&override_url_interpretation=1");
					$('#dialog_container').remove();
				}
			}
		});
		$('#dialog_container').dialog('open');
	});
	
}

function submitDialog(me, block)
{
	$('input,textarea', $(me).parents('form')).each(function()
			{
		        	if ($(this).val() == $(this).attr('title'))
		        	{
		        		$(this).val('');
		        	}
			} );
	url = location.href.split(/\?|#/)[0];
	
	dst = 'dialog_container';

	//$('#dialog_container form').ajaxSubmit
	$(me).parents('form').ajaxSubmit({ 
        target:        '#'+dst,   // target element(s) to be updated with server response 
        // other available options: 
        url:       url+'?block='+block,
        beforeSubmit:	preworkSubmittedData,// override for form's 'action' attribute 
        success:	workSubmittedData// override for form's 'action' attribute 
    });

	return false;
}

function closeDialog()
{
	$("#dialog_container").dialog("close");
}

function setUpdateBlocks()
{
	var argv = setUpdateBlocks.arguments;
	var argc = argv.length;
	var url = location.href.split(/\?|#/)[0];
	
	for (var i = 0; i < argc; i++)
	{
		update_blocks.push(argv[i])
	}
}

function showInfoBox(id)
{
	//$("#"+id).slideDown(1000).animate({opacity: 1.0}, 1000).slideUp(1000);
	var info_title = $('#'+id).attr('title');
	$('#'+id).dialog({
		modal: true,
		autoOpen: false,
		width: 300,
		open: function(event, ui) 
		{
			$('#'+id).css('minHeight', 0);
			$("span.ui-dialog-title").text(info_title);
		} 
	});
	//closeCurrentDialog();
	closeDialog();

	$('#'+id).show();
	$('#'+id).dialog('open');

	return false;
}

function closeInfoBox(id)
{
	$("#"+id).dialog("close");
}
*/






















function openFormDialog(block_or_div, update_div, update_src, dynamic_id)
{
	if (dynamic_id === undefined)
	{
		dynamic_id = 0;
	}
	var argv = openFormDialog.arguments;
	var argc = argv.length;

	$("#save_success").hide();

	current_dialog.push('default_dialog');
	
	url = location.href.split(/\?|#/)[0];

	if (current_title.length > 0)
	{
		title = current_title.pop();
		//$("span.ui-dialog-title").text(title);
		$("#default_dialog").attr('title', title);
	}
	
	$('#default_dialog').load(url+"?block="+block_or_div, {edit_id: dynamic_id}, function()
	{
		$(".tabs").tabs().show();
		$(".star").rating();
		
		$('#default_dialog').show();
		$('#default_dialog').dialog(
		{
			modal: true,
			autoOpen: false,
			width: 'auto',
			height: 'auto',
			open: function(event, ui) 
			{
				$(".star").rating();
				$("span.ui-dialog-title").text(title);
				$("#default_dialog").attr('title', title);
			},
			close: function(event, ui) 
			{
				if (update_div != '')
				{
					url = location.href.split(/\?|#/)[0];
					$("#"+update_div).load(url+"?block="+update_src+"&override_url_interpretation=1");
					
				  
					for (var i = 4; i < argc; i+=2)
					{
						$("#"+argv[i]).load(url+"?block="+argv[i+1]+"&override_url_interpretation=1");
					}
				}
				closeCurrentDialog();
				$("#default_dialog").html('');
				$("#default_dialog").attr('title', '');
			}
		});
		/*
		if (title !== undefined)
		{
			$("span.ui-dialog-title").text('Edit this');
		}
		*/
		$('#default_dialog').dialog('open');
		showInputExamples();
	});
	

	
	return false;
}

function openFormDialogFromDiv(contentid, dst, src)
{
	$(".tabs").tabs().show();
	current_dialog.push(contentid);
	$("#save_success").hide();
	$('#'+contentid).show();
	$('#'+contentid).dialog({
		modal: true,
		autoOpen: false,
		width: current_dialog_width,
		close: function(event, ui) {
			url = location.href.split(/\?|#/)[0];
			$("#"+dst).load(url+"?block="+src);
			closeCurrentDialog();

		}
	});

	$('#'+contentid).dialog('open');
	showInputExamples();
	
	return false;
}

function openDialogFromDiv(contentid)
{
	//$('#'+contentid).show();
	//current_dialog.push(contentid);
	
	$('#'+contentid).dialog({
		modal: true,
		autoOpen: false,
		width: current_dialog_width,
		close: function(event, ui) {
		//closeCurrentDialog();
		}
	});
	

	$('#'+contentid).dialog('open');
	return false;
}

/*
 * 	old
 
function openFormDialog(contentid, dst, src)
{
	$(".tabs").tabs().show();
	current_dialog = contentid;
	$("#save_success").hide();
	$('#'+contentid).show();
	$('#'+contentid).dialog({
		modal: true,
		autoOpen: false,
		width: 600,
		close: function(event, ui) {
			url = location.href.split(/\?|#/)[0];
			$("#"+dst).load(url+"?block="+src);
		}
	});

	$('#'+contentid).dialog('open');
	showInputExamples();
	
	return false;
}
*/
/*
function submitFormBlockWithConfirm(me, block, hidden_confirm)
{
	
	$('#sure').dialog({
		modal: true,
		autoOpen: false,
		width: 300,
		close: function(event, ui) {
			submitFormBlock(me, block);
		},
		buttons: {
			"OK": function() { 
				$('#'+hidden_confirm).value = 1;
				$(this).dialog("close");
			},
			"Cancel": function() { 
				$('#'+hidden_confirm).value = 0;
				$(this).dialog("close");
				
			} 

		}
	});

	$('#sure').dialog('open');
}
*/

function OLDsubmitFormBlockWithConfirm(me, block, confirm_var, dstoverride)
{
	if (confirm_var === undefined)
	{
		confirm_var = 'delete';
	}
	
	$('#sure').dialog({
		modal: true,
		autoOpen: false,
		width: 300,
		close: function(event, ui) {
		
		},
		buttons: {
			"OK": function() {
				submitFormBlock(me, block+'&'+confirm_var+'=1');
				$(this).dialog("close");
			},
			"Cancel": function() { 
				$(this).dialog("close");
			} 

		}
	});

	$('#sure').dialog('open');
}

function openDynamicFormDialog(contentid, page, block, subid, dst, src)
{
	$('#'+contentid).load("./"+page+"?block="+block, {edit_id: subid}, function(){
		openFormDialog(contentid, dst, src)
	});
}

function openDynamicFormDialogWithTitle(title, contentid, page, block, subid, dst)
{
	$('#'+contentid).attr('title', title);
	$('#'+contentid).load("./"+page+"?block="+block, {edit_id: subid}, function(){
		openFormDialog(contentid, dst, block)
		$('#'+contentid).attr('title', '');
	});
}

// sollte ersetzt werden mit obigen Funktionen
function openDefaultDialog(title, block, w, h)
{
	if (current_title.length > 0)
	{
		title = current_title.pop();
	}
	contentid = 'default_dialog';
	url = location.href.split(/\?|#/)[0];
	$("#"+contentid).attr('title', title)
	$("#"+contentid).load(url+"?block="+block);
	$('#'+contentid).show();
	
	current_dialog.push(contentid);
	
	$('#'+contentid).dialog({
		modal: true,
		autoOpen: false,
		width: w,
		height: h,
		open: function (event, ui)
		{
			$("span.ui-dialog-title").text(title);
			$("#default_dialog").attr('title', title);
		},
		close: function(event, ui) {
			$("#"+contentid).html('');
			$("span.ui-dialog-title").text('');
			$("#default_dialog").attr('title', '');
			closeCurrentDialog();
		}
	});

	$('#'+contentid).dialog('open');
	
	return false;
}
function closeCurrentDialog()
{
	if (d = current_dialog.pop())
	{
		$("#"+d).dialog("close");
	}
}

function swapFade(old_div, new_div)
{
	$("#"+old_div).hide();
	$("#"+new_div).show();
}

function selectTab(tab_id, idx)
{
	$('#'+tab_id).tabs('select', idx);
}

function makeBold(me, off)
{
	$("a."+off).removeClass("bold");
	$(me).addClass("bold");
}

function toggleBold(me, off)
{
	if (off !== undefined)
	{
		$("a."+off).removeClass("bold");
	}
	
	if ($(me).hasClass("bold"))
	{
		$(me).removeClass("bold");
	}
	else
	{
		$(me).addClass("bold");
	}
	
}


function gmLoad()
{
	/*
	if (gm_script_code !== undefined)
	{
		document.body.appendChild(gm_script_code);
	}
	*/
	if (gm_script_exec !== undefined)
	{
		document.body.appendChild(gm_script_exec);
	}
	
	$(window).unload( function () { GUnload(); } );
}

function changePreviewImage(me, dst)
{
	$("#"+dst).attr("src", $(me).attr("src"));
}




var auto_dialog = '';

$(document).ready(function() 
{
	$("select.loadoptions").change(function()
	{
		$.getJSON("./ajax", {func: $(this).attr('title'), id: $(this).val() }, function(j)
		{
			var options = '';
			for (var i = 0; i < j.length; i++) 
			{
				options += '<option value="' + j[i].name + '">' + j[i].optionDisplay + '</option>';
			}
			alert(options);
			$(this).html(options);
	    });
	});

	showInputExamples();
	$(".tabs").tabs().show();

	
	
	$(".location_chooser_next").click(function()
	{
				alert('EY');
				//alert($(this).parents('div').attr('id'));
				//$(this).next('div').show();

	});
			

	$(".category_more").click(function()
	{
		$(this).hide()
		$('.'+$(this).attr("id")).show();
	});

	$("#current_network").mouseover(function()
	{
		$(".network_chooser").show();
		$("#current_network").addClass("border");
		$("#current_network_top").addClass("network_chooser");
	}).mouseout(function()
	{
		$("#current_network_top").removeClass("network_chooser");
		$(".network_chooser").hide();
		$("#current_network").removeClass("border");
	});

	
	$(".topnavicontainer").mouseover(function()
	{
		$(".topnavimenu").hide();
		$(".topnavimenu", this).show();
	});
	
	$("#header_navi").mouseout(function()
	{
		$(".topnavimenu").hide();
	});
	
	$(".datepicker").datepicker({	dateFormat:'dd.mm.yy', 
									dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
									dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
									firstDay: 1,
									monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
									monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'],
									buttonImageOnly: true,
									minDate: '+1d', 
									maxDate: '+1y +1m' 
									           });

	/*
	if(typeof gmInitialize == 'function') 
	{
		gmInitialize();
		$(window).unload( function () { GUnload(); } );
		if (gm_display_people) gmDrawPeople();
		if (gm_display_places) gmDrawPlaces();
	} 
	*/

	if (gm_script !== undefined)
	{
		document.body.appendChild(gm_script);
	}
	
	if (auto_dialog != '')
	{
		openDialog(auto_dialog);
	}
	
});














/*
function openDialog(contentid)
{
	current_dialog = contentid;
	$('#'+contentid).dialog({
		modal: true,
		autoOpen: false,
		width: 600,
		buttons: {
			"OK": function() {
				$(this).dialog("close"); 
			} 
		}
	});

	$('#'+contentid).dialog('open');

	return false;
}
*/

/*
function swapVisibility(elem, c1, c2, name1, name2)
{
	if ($("#"+c1).is(':hidden'))
	{
		$("#"+c1).show();
		$("#"+c2).hide();
		$("#"+elem).html(name1);
	}
	else
	{
		$("#"+c1).hide();
		$("#"+c2).show();
		$("#"+elem).html(name2);
	}
	return false;
}
*/

/*
function reloadAndJump(anchor)
{
	location.href=location.href.split(/\?|#/)[0] + '#' + anchor;   
	location.reload(true);
	return false;
}
*/

