// POPUP-Klasse

// Ajax_Initialisierung
document.write('<script type="text/javascript" src="/js/ajax.js"></script>');

function site_popup()
{
	this.wrap_id = "u_cms_pop"; 
	this.popup_id = "u_cms_up";
	this.header_id = "u_cms_popup_close";
	this.content_id = "u_cms_popup_content";
	this.opened = false;

	this.getFensterweite = function() 
	{
	  if (window.innerWidth) 
	  {
		return window.innerWidth;
	  } 
	  else if (document.body && document.body.offsetWidth) 
	  {
		return document.body.offsetWidth;
	  } 
	  else 
	  {
		return 0;
	  }
	}

	this.getFensterhoehe = function() 
	{
	  if (window.innerHeight) 
	  {
		return window.innerHeight;
	  } 
	  else if (document.body && document.body.offsetHeight) 
	  {
		return document.body.offsetHeight;
	  } 
	  else 
	  {
		return 0;
	  }
	}
	
	// Popup-Settings
	this.setPopupsettings = function()
	{
		fbreite = this.getFensterweite();
		fhoehe = this.getFensterhoehe();
		//maxhoehe = parseInt(fhoehe) - 20 - 60;
		////console.log("fbreite = " + fbreite + " & fhoehe = " + fhoehe + " => maxhoehe = " + maxhoehe);	
		if(document.getElementById("u_cms_popup_content"))
		{
			switch(arguments[0])
			{
				case "stats":
						document.getElementById(this.popup_id).style.marginTop = "50px";
						document.getElementById(this.popup_id).style.width = "700px";
						//document.getElementById(this.popup_id).style.height = "400px";
					break;
				
				case "forum":
						document.getElementById(this.popup_id).style.marginTop = "50px";
						document.getElementById(this.popup_id).style.width = "700px";
						document.getElementById(this.content_id).style.overflow = "auto";
					break;
				
					default:
						document.getElementById(this.popup_id).style.marginTop = "100px";
						document.getElementById(this.popup_id).style.width = "700px";
						document.getElementById(this.popup_id).style.height = "300px";
						
			}
		}
		/**/
	}
	
	// Icon Header setzen
	this.setPopupIcon = function(icon)
	{
		if(document.getElementById("u_cms_popup_title"))
		{
			document.getElementById("u_cms_popup_title").style.backgroundImage = "url(" + icon + ")";
		}
	}
	
	// Titel setzen
	this.setPopupTitle = function(title)
	{
		if(document.getElementById("u_cms_popup_title"))
			document.getElementById("u_cms_popup_title").innerHTML = title;
	}
	
	// Popup anzeigen
	this.showPopup = function()
	{
		if(this.opened == false)
		{
			if(document.getElementById(this.wrap_id) && document.getElementById(this.popup_id))
			{
				document.getElementById(this.wrap_id).style.display = 'inline';
				document.getElementById("mybody").className = "hidden";
				this.opened = true;
			}
		}
	}
	
		
	// Popup ausblenden
	this.hidePopup = function()
	{
		if(this.opened == true)
		{			
			if(document.getElementById(this.wrap_id) && document.getElementById(this.popup_id))
			{
				document.getElementById(this.wrap_id).style.display = 'none';
				document.getElementById("mybody").className = "";
				this.opened = false;
			}
		}
	}
	
	// Content setzen
	this.setContent = function(content)
	{
		if(document.getElementById(this.content_id))
		{
			document.getElementById(this.content_id).innerHTML = content;
		}
	}
	
	// Content leeren
	this.clearContent = function()
	{
		if(document.getElementById(this.content_id))
		{
			document.getElementById(this.content_id).innerHTML = "";
		}
	}
	
	// Loader setzen
	this.setLoader = function()
	{
		var loader = "<div style='text-align:center; margin-top: 10px; margin-bottom:10px;'><img src='/images/popuploader.gif'></div>";
		this.setContent(loader);
	}
	
}
