var bg_div  = "bg_layer";
var content_div = "content_layer";
var BTN_URL = "http://www.telvi.de/global/module/gmap/_portal/gfx/btn";

document.write('<div id="bg_layer" class="overLay" style="display:none;"></div><div id="content_layer" class="overLay" style="display:none;"></div>');
document.write('<link rel="stylesheet" type="text/css" href="'+absolute_path+'/global/gmap/css/api.css">');
document.write('<link rel="stylesheet" type="text/css" href="http://www.telvi.de/global/module/gmap/_portal/css/api.css">');
document.write('<link rel="stylesheet" type="text/css" href="http://www.telvi.de/global/module/gmap/_portal/css/ovl.css">');
document.write('<script type="text/javascript" language="javascript" src="http://www.telvi.de/global/module/gmap/_portal/js/fnc.ovl.js"></script>');

function checkLogin(){
	var must = $$("input.must");
	var attn = "";
	var str_post = "";
	
	for(var i=0;i<must.length;i++){
		if(must[i].value == ""){
			attn+= must[i].name + " ist leer!\n";
		} else {
			str_post+= must[i].name+"="+must[i].value;
			if(i<must.length-1){
				str_post+= "&";
			}
		}
	}
	
	if(attn != ""){
		alert(attn);
	} else {
		//alert(str_post);
		
	new Ajax.Request(absolute_path+'/plugins/telvicenter/ajax/subscribe.php?act=login',
		{
			method:'post',
			postBody:str_post,
			onSuccess: function(t){
				var re = t.responseText.split("|");
				
					if(re[0]=="ERROR"){
						alert(re[1]);
					} else if(re[0]=="SUCCESS"){
						getLoggedRating(vid_id);
						$("userArea").innerHTML = re[1];
						$("comment_btn").style.visibility = "visible";
					}
					
			},
			onFailure: function(t){
				alert(t.responseText);
			}
		});	
	}
}

function doLogout(){
	var c = confirm("wirklich ausloggen?");
	if(c==true){
	
		new Ajax.Request(absolute_path+'/plugins/telvicenter/ajax/subscribe.php?act=logout',
			{
				onSuccess: function(t){
					getLoggedRating(vid_id);
					$("userArea").innerHTML = t.responseText;
					$("comment_btn").style.visibility = "hidden";
				},
				onFailure: function(t){
					alert(t.responseText);
				}
			});
	}
}

function showTelviCenter(act){
	
	$(bg_div).setStyle({zIndex: '60'});
	$(content_div).setStyle({zIndex: '61'});
	
	var tpl = "";
		tpl +='<table border="0" cellpadding="0" cellspacing="0" width="700" height="500" class="tableOverlay">';
		tpl +='<tr><td class=overlay_specialHeader>Question Life User Center</td></tr>';
		tpl +='<tr><td class=overlay_specialContent><iframe src="'+absolute_path+'/global/gmap/mp.php?show='+act+'" width="700" height="500" frameborder="0"></iframe></td></tr></table>';
	
	divHTML(tpl);
}
