function moreinfo() {
	var moreinfo = document.getElementById('moreinfo');
	moreinfo.setStyle('display', 'none');
	var moreinfo_btn = document.getElement('.cont .grey');
	moreinfo_btn.set('html', '<a href="#">mehr infos &raquo;</a>');
	moreinfo_btn.addEvent('click', function(event){
	event.preventDefault();
	if(moreinfo.getStyle('display') == 'none') {
		moreinfo.setStyle('display', 'block');	
	} else
	moreinfo.setStyle('display', 'none');
});

}

window.onload = function(){
	if($('moreinfo')) moreinfo();
	if(typeof(initCastomForms)=='function')	initCastomForms();
}

function comment_reply(reply_to) {
	var formElement = $(document).getElement('.comments-form');
	if (!formElement) return;
	formElement.getElement('.comments-replyBox-postername').set('html', $('comment_'+reply_to+'-postername').get('html'));
	formElement.getElement('.comments-replyBox').set('style', {'display' : ''});
	formElement.getElement('input[name=reply_to]').set('value', reply_to);
}

function fbconnect_onlogin() {
	// reload
	window.location.href = unescape(window.location.href);
}

function fbconnect_onloginRegister() {
	window.location.href = unescape(window.location.href);
}

function fb_logout(url) {
	FB.ensureInit(function(url) { 
		FB.Connect.logoutAndRedirect(url); 
	}.bind(null, url)); 
}

function prepareLoginMask(lusername, lpassword) {
	$('input_username').set('value', lusername);
	$('input_password').set({'type': 'text', 'value': lpassword});
	
	addEmptyEvents('input_username', lusername);
	addEmptyEvents('input_password', lpassword, 'password');
}

function addEmptyEvents(eid, val, type) {
	var element = $(eid);
	if (!$defined(type)) type='text';
	
	element.addEvent('focus', emptyOnFocus.bindWithEvent(element, type));
	element.addEvent('blur', fillOnBlur.bindWithEvent(element, [type, val]));
}

function emptyOnFocus(event, type) {
	$(this).set('value', '');
	
	if (type != 'text') {
		$(this).set('type', type);
	}

	return true;
}

function fillOnBlur(event, type, val) {
	if ($(this).get('value') != '') return true;

	$(this).set('value', val);
	if (type != 'text') {
		$(this).set('type', 'text');
	}

	return true;
}

function CountLeft(field, count, max) {
	// if the length of the string in the input field is greater than the max value, trim it 
	if (field.value.length > max)
		field.value = field.value.substring(0, max);
	else
	// calculate the remaining characters  
	count.value = max - field.value.length;
}
