function initNav() {

	arrNav = document.getElementsByClassName("nav2_dropdown");
	
	for (i = 0; i < arrNav.length; i++) {
		
		arrNav[i].onmouseover = function() {
			
			intRows = this.getElementsByTagName("li").length - 1;
			this.style.height = (intRows * 25) + 55 + "px";
		};
		
		arrNav[i].onmouseout = function() {
			
			this.style.height = "45px";
		};			
	}
}

function setFontSize(strFontSize) {

	new Ajax.Request('/include/font.inc.php?font=' + strFontSize, {
		method: 'get',
		onComplete: onSetFontSizeComplete
	});	
}

function onSetFontSizeComplete() {
	
	window.location.reload();
}

function printSite() {
	if(location.href.indexOf("?") == -1) {
		var url = location.href+"?print=1";
	} else {
		var url = location.href+"&print=1";
	}
	window.open(url, '_blank', 'width=650,height=600,top=50,left=100,menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes');
}

function sendMessage(intCase) {
	$('response').style.display = 'none';
	$('loading').style.display = 'block';

	arrElements = document.getElementsByTagName('span');
	
	for (i = 0; i < arrElements.length; i++) {
		if (arrElements[i].className == 'error') {
			arrElements[i].className = '';
		}
	}

	new Ajax.Request('/include/send_message.inc.php?case=' + intCase, {
		method: 'post',
		postBody: Form.serialize('frm_contact'),
		onComplete: _onSendMessageComplete
	});
}

function alterscheck(){
	new Ajax.Request('/include/alterscheck.php?alter=16', {
		onComplete: remove_alterscheck
	});
}

function remove_alterscheck(){
	document.getElementById('alterscheck_bg').style.display = "none";	
	document.getElementById('alterscheck').style.display = "none";	
}

function alterscheckForbidden(){
	document.getElementById('alterscheck_text').innerHTML = "<p style=\"color:#ff0000;\">Für Bierwerbung<br>bist Du leider noch nicht<br>alt genug.</p>";
}

function _onSendMessageComplete(objReq) {

	arr_response = objReq.responseText.evalJSON();

	if (arr_response['error'].length > 1) {
		$('response').className = 'error';

		for (i = 0; i < arr_response['error'].length - 1; i++) {
			if ($('lbl_' + arr_response['error'][i]) != null) {
				$('lbl_' + arr_response['error'][i]).className = 'error';
			}			
		}
		
		$('response').innerHTML = 'Bitte alle benötigten Felder korrekt ausfüllen.';
		$('loading').style.display = 'none';
		$('response').style.display = 'block';  			
	} else if (arr_response['error'].length == 1) {
		$('response').className = 'error';
		$('response').innerHTML = arr_response['error'][0];
		$('loading').style.display = 'none';
		$('response').style.display = 'block';	
	} else if (arr_response['success'].length!=0) {
		$('response').className = 'success';
		$('response').innerHTML = arr_response['success'][0];
		$('frm_contact').reset();	
		$('loading').style.display = 'none';
		$('response').style.display = 'block'; 							
	} else {
		$('loading').style.display = 'none';
		$('response').style.display = 'none'; 
	}
}