
/**
 *
 */
appSendLogin = function() {
	document.getElementById('key').value= MD5(document.getElementById('key').value + MD5(document.getElementById('loginform-password').value));
	document.getElementById('loginform-password').value = '';
	document.getElementById('key').form.submit();
}

appInsertPopupShortcut = function(inst_id, param){
		if(tinyMCE){
			var aTag = null;
			var inst = tinyMCE.getInstanceById(inst_id);
			var selection = inst.getSel();
			if ((aTag = tinyMCE.getParentElement(tinyMCE.selectedElement, "a")) != null){
				aTag.setAttribute("href", "#");
				aTag.setAttribute("onclick", "metaToggle(null,'" +param+ "'); return false;");
			}else{
				var text;
				if(selection.createRange && (selection.createRange!='undefined')){
					text = selection.createRange().htmlText;
				}else{
					text = selection;
				}
				tinyMCE.execCommand("mceInsertContent", false, "<a href=\"#\" onclick=\"metaToggle(null,'" +param+ "'); return false;\">" + text + "</a>");
			}
			tinyMCE.triggerNodeChange();
		}
	}

var page_meta_content;

metaToggle = function(key, param){
	/*
	$('#page-meta-content').hide('slow');
	$.get(WWW_ROOTURL + 'service/item.php?cip='+param,null, function(data){ 
		if(obj = document.getElementById('page-meta-content')){
			$('#page-meta-content').hide();
			obj.innerHTML = '';
			if(key!=page_meta_content){
				obj.innerHTML = data;
				//obj.style.padding = '12px';
				page_meta_content = key;
				$('#page-meta-content').show('slow');
			}else{
				//obj.style.padding = '0px';
				page_meta_content = null;
			}
		} 
	});
	*/
	
	$('#page-meta-content').hide();
	$('#page-meta-content .page-meta-content-inner .page-meta-content-body').hide();
	$('#page-overlay').hide();
	$('#page-overlay').css({'height':$(document).height(),'width':$(document).width()}).show();
	//$('#page-meta-content').center({'vertical':false}).fadeIn();
	$('#page-meta-content').center({'vertical':false}).css('top', $(document).scrollTop()+100).fadeIn();
	$.get(WWW_ROOTURL + 'service/item.php?cip='+param,null, function(data){ 
		$('#page-meta-content .page-meta-content-inner .page-meta-content-body').html(data).fadeIn();
	});
}

itemToggle = function(id, param){
	$('#'+id).hide('slow');
	$.get(WWW_ROOTURL + 'service/item.php?cip='+param,null, function(data){ 
		if(obj = document.getElementById(id)){
			obj.innerHTML = data;
			$('#'+id).show('slow');
			setTimeout("scrollToItem('" +id+ "')", 250);
		} 
	});
}

scrollToItem = function(id){
	if(obj = document.getElementById(id)){
		var p = obj.offsetTop;
		var pElement = obj.offsetParent; 
		while (pElement != null){
			p += pElement.offsetTop;
			pElement = pElement.offsetParent;
		}
		var opo  = window.pageYOffset;
		window.scrollTo(10, p);
		if(opo!=window.pageYOffset){
			setTimeout("scrollToItem('" +id+ "')", 10);
		}
	}
}

votePopup = function(options) {
	if (options.target=='') {
		options.target = TANTER_ANKER;
	}
	$('#votepopup').hide();
	$('#votepopup .votepopup-inner .votepopup-body').hide();
	$('#page-overlay').hide();
	$('#page-overlay').css({'height':$(document).height(),'width':$(document).width()}).show();
	$('#votepopup').center({'vertical':false}).css('top', $(document).scrollTop()+100).fadeIn();
	$.get(WWW_ROOTURL + 'at/index.php?do=visit&mode=vote',options, function(data){ 
		$('#votepopup .votepopup-inner .votepopup-body').html(data).fadeIn();
	});
}

votePopupClose = function() {
	$('#page-overlay, #votepopup').hide();
	$('#votepopup .votepopup-inner .votepopup-body').html('');
}

votePopupCheck = function() {
	if ($("#atVoteForm input[name='bewertung']:checked").length>0) {
		return true;
	} 
	return false;
}

