$(document).ready(function() {
    $('#menu').height($('#main').height()+5);
});


var loading='<p style="color:#87AE28;"><img src="/Theme/Wdkk/Images/loading.gif" /> Loading...</p>';
//Create URL
var curr_url=location.href;
var index = curr_url.indexOf("#");
if (index > 0){
	curr_url=curr_url.substr(0, index);
}
var index = curr_url.indexOf("?");
if (index > 0){
	curr_url=curr_url.substr(0, index);
}

/*
 * Diverse Funktionen
 */
function empty(mixed_var) {
    var key;    
    if (mixed_var === "" ||mixed_var === 0 ||mixed_var === "0" ||mixed_var === null ||mixed_var === false ||typeof mixed_var === 'undefined'){
        return true;
    } 
    if (typeof mixed_var == 'object') {
        for (key in mixed_var) {
            return false;
        }        
        return true;
    }
    return false;
}

function strpos (haystack, needle, offset) {
    var i = (haystack+'').indexOf(needle, (offset || 0));
    return i === -1 ? false : i;
}

function str_replace(search, replace, subject) {
	return subject.split(search).join(replace);
}

$(".formError").live("click",function(){	 // REMOVE BOX ON CLICK
	$(this).fadeOut(150,function(){		$(this).remove();	});
});


/**
 * Function : dump()
 * Arguments: The data - array,hash(associative array),object
 *    The level - OPTIONAL
 * Returns  : The textual representation of the array.
 * This function was inspired by the print_r function of PHP.
 * This will accept some data as the argument and return a
 * text that will be a more readable version of the
 * array/hash/object that is given.
 * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
 */
function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}


function checklength(Object, MaxLen){
    $('#kontakt_length').html((MaxLen-Object.value.length)+" Zeichen");
    return (Object.value.length <= MaxLen);
}
