function showPopUp(divId,divId1){
	var $elem = $("#"+divId);
	if($elem.length > 0){
		showFadedLayer();
		$elem.css("position","fixed")
			.css("left",$(window).width() / 2 - $elem.width() / 2)
			.css("top",$(window).height() / 2 - $elem.height() / 2)
			.css("visibility","visible")
			.show();
	}
}

function showFadedLayer(width, height){
	$("#fadedLayer").css("width",$(window).width())
	.css("height",$(window).height())
	.show();
}

function hideFadedLayer(){
	$("#fadedLayer").hide();
}

function getInnerSize(){ // Function to get visible screen width and height
	var gInnerWidth;
	var gInnerHeight;
	
	if (typeof window.innerWidth != 'undefined'){ // Standards compliant browsers
		gInnerWidth = window.innerWidth,
		gInnerHeight = window.innerHeight
	}else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){ // IE6
		gInnerWidth = document.documentElement.clientWidth,
		gInnerHeight = document.documentElement.clientHeight
	}else{ // Older versions of IE
		gInnerWidth = document.getElementsByTagName('body')[0].clientWidth,
		gInnerHeight = document.getElementsByTagName('body')[0].clientHeight
	}
	return [gInnerWidth,gInnerHeight];
}

function getInnerPageSize(){  // Function to get actual screen width and height
	var gInnerPageWidth;
	var gInnerPageHeight;
	if(self.scrollHeight){ // Standards compliant browsers
		gInnerPageWidth = self.scrollHeight;
		gInnerPageHeight = self.scrollHeight;
	}else if(document.documentElement && document.documentElement.scrollHeight){ // IE6
		gInnerPageWidth = document.documentElement.scrollWidth;
		gInnerPageHeight = document.documentElement.scrollHeight;
	}else if(document.body){ // Older versions of IE
		gInnerPageWidth = document.body.scrollHeight;
		gInnerPageHeight = document.body.scrollHeight;
	}
	return [gInnerPageWidth,gInnerPageHeight];
}

var to;
function saveterms(userId){
	docObj = document;
	locObj = docObj.getElementById('checkterms');
	if(locObj.checked == false){
		document.getElementById('infoDiv').innerHTML = "<div class=\"left infoDivs agbInfoDiv\"><p style=\"color:red\">Um 123POI nutzen zu k&ouml;nnen, musst Du die AGBs und<br />die Datenschutzbestimmung akzeptieren.</p></div>";
		fadeDivSingle("infoDiv");
		to = setTimeout("fadeDivSingle('infoDiv')", 3000);
	    return false;
	}else{
		var ajaxVar = new jsonVars();
		ajaxVar.vars['action'] = "runFunction";
		ajaxVar.vars['func'] = "saveterms";	
		ajaxVar.vars['nosplit'] = 1;	
		ajaxVar.vars['user_id'] = userId;
		ajaxVar.vars['location'] = 1;
		ajaxVar.gotoFunction = 'termsSaved';
		ajaxVar.JsonPostSQL();	
	}
}

function termsSaved(){
	clearTimeout(to);
	document.getElementById('infoDiv').innerHTML = "<div class=\"left infoDivs agbInfoDiv\"><p>Daten werden gespeichert</p></div>";
	fadeDivSingle("infoDiv");
	to = setTimeout("fadeDivAfter2()", 3000);	
}


function fadeDivAfter2(){
	fadeDivSingle('infoDiv');
	docObj = document;
	showHideDivHome('nologinDivId',false);
	hideFadedLayer();
}

function closeAgbLayer(){
	docObj = document;
	locObj = docObj.getElementById('checkterms');
	if(locObj.checked == false){
		document.forms['userlogin'].submit();
	    return false;
	}else{
		showHideDivHome('nologinDivId',false);
		hideFadedLayer();
	}
}

function showHideDivHome(id,status){
	var divObj=document.getElementById(id);
	if(divObj){
		if(status){
			divObj.style.visibility="visible";
			divObj.style.display="block";
		}else{
			divObj.style.visibility="hidden";
			divObj.style.display="none";
		}
	}
}
