// <?php !! This fools phpdocumentor into parsing this file
/**
* @version $Id: kk.javascript.js 100 2011-04-13 12:40:49Z Kurt Klier $
* @package Joomla
* @copyright Copyright (C) 2006 Kurt Klier. All rights reserved.
*/

var access_array = new Array();
access_array[0] = 'Public';
access_array[1] = 'Registered';
access_array[2] = 'Special';
access_array[3] = 'Override Public'; // neu seit 2011-04-13
		
/* Admin-Funktionen */
function sort( criteria, old_crit ){
	var form = document.adminForm;
	var order = form.sort_order.value;
	if( old_crit == criteria ){
		if( order=='ASC' ){
			order = 'DESC';
		}else{
			order = 'ASC';
		}
		form.sort_order.value = order;
	}else{
		// beim Wechsel des Kriteriums immer aufsteigend sortieren
		form.sort_order.value = 'ASC';
	}

	form.sort_criteria.value = criteria;
	form.submit();
}

function handleEnter( field, event ){
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if( keyCode==13 ){
		var form = document.adminForm;
		form.submit();
	}else{
		return true;
	}
}

// Die divs an die Fenstergroesse anpassen
function setModuleDivs(){
	var divs = document.getElementsByTagName("div");
	for( i = 0; i < divs.length; i++ ){
		var screen = divs[i];
		if( screen.className == "module_screen" ){
			var parent = screen.parentNode;
			if( parent == null )
				continue;
			var screen_height = parent.offsetHeight;
			var screen_width 	= parent.offsetWidth;
			
			var screen_child = screen.firstChild;
			while( screen_child != null ){
				switch( screen_child.className ){
					case "module_titlefixed":
						var header_container = screen_child;
						break;
					case "module_content_titlefixed":
						var module_content = screen_child;
						break;
					default:
						break;
				}
				screen_child = screen_child.nextSibling;
			}
			
			if( header_container==null || module_content==null ){
				continue;
			}

			var header_container_height = header_container.offsetHeight;
			var maxHeight 					= screen_height-header_container_height;
			
			module_content.style.height = maxHeight+"px";

			screen.style.overflow = "hidden";
			if( module_content.offsetHeight > maxHeight ){
				module_content.style.height = (maxHeight - (module_content.offsetHeight - maxHeight)) + 'px';
			}
			if( module_content.offsetWidth > screen_width ){
				module_content.style.width = (screen_width - (module_content.offsetWidth - screen_width)) + 'px';
			}
		}
	}
}

/* wird derzeit nicht benutzt
function setModuleFixedDivs( mod_id ){
	var div_fixed = document.getElementById( 'module_content_titlefixed_'+mod_id );
	if( div_fixed == null )
		return;
	var div_title = document.getElementById( 'module_titlefixed_'+mod_id );
	if( div_title == null )
		return;
	var screen = div_fixed.parentNode;
	if( screen == null || screen.className != "module_screen" )
		return;
	var parent = screen.parentNode;
	if( parent == null )
		return;

	var screen_height = parent.offsetHeight;
	var screen_width 	= parent.offsetWidth;
	var header_container_height = div_title.offsetHeight;
	var maxHeight 	= screen_height-header_container_height;
	
	div_fixed.style.height = maxHeight+"px";

	screen.style.overflow = "hidden";
	
	if( div_fixed.offsetHeight > maxHeight ){
		div_fixed.style.height = (maxHeight - (div_fixed.offsetHeight - maxHeight)) + 'px';
	}
	if( div_fixed.offsetWidth > screen_width ){
		div_fixed.style.width = (screen_width - (div_fixed.offsetWidth - screen_width)) + 'px';
	}
	alert( screen_height );
	screen.style.height = screen_height+'px';
}
*/

function setKeywordDivs(){
	var screen 				= document.getElementById("keyword_screen");
	if( screen==null )
		return;
	var header_container = document.getElementById("keyword_header_container");
	if( header_container==null )
		return;
	var keyword_content 	= document.getElementById("keyword_content");
	if( keyword_content==null )
		return
	var content_container = document.getElementById("keyword_content_container");
	if( content_container==null )
		return;
	var parent = screen.parentNode;
	if( parent==null )
		return;
	var grandparent = parent.parentNode;
	if( grandparent==null )
		return;
	
	var keyword_padding	 	= screen.offsetHeight - content_container.offsetHeight;
	var grandparent_height	= grandparent.offsetHeight;
	//var screen_height 		= screen.offsetHeight;
	//var screen_width 			= screen.offsetWidth;
	var header_container_height = header_container.offsetHeight;
	var newHeight = grandparent_height-header_container_height-keyword_padding;
	
	keyword_content.style.height = newHeight+"px";
}
	
function kk_replaceEntities( str ){
	str = str.toLowerCase();
	str = str.replace(/ä/,"ae");
	str = str.replace(/ö/,"oe");
	str = str.replace(/ü/,"ue");
	str = str.replace(/ß/,"ss");
	str = str.replace(/á/,"a");
	str = str.replace(/é/,"e");
	str = str.replace(/í/,"i");
	str = str.replace(/ó/,"o");
	str = str.replace(/ú/,"u");
	str = str.replace(/à/,"a");
	str = str.replace(/è/,"e");
	str = str.replace(/ì/,"i");
	str = str.replace(/ò/,"o");
	str = str.replace(/ù/,"u");
	str = str.replace(/â/,"a");
	str = str.replace(/ê/,"e");
	str = str.replace(/î/,"i");
	str = str.replace(/ô/,"o");
	str = str.replace(/û/,"u");
	str = str.replace(/ã/,"a");
	str = str.replace(/ñ/,"n");
	str = str.replace(/õ/,"o");
	str = str.replace(/æ/,"ae");
	str = str.replace(/ø/,"o");
	str = str.replace(/ç/,"c");
	str = str.replace(/å/,"a");
	str = str.replace(/å/,"a");
	
	return str;
}
