function Fensterweite ()
{
    if (window.innerWidth) return window.innerWidth;
    else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
    else return 0;
}

function openPopup(html)
{
    jQuery("#popBox").html(html);
    var popBoxWidth = jQuery("#popBox").width();
	
	if(jQuery.support.opacity) { jQuery("#popHG").fadeIn("fast"); }
	else { jQuery("#popHG").show(); } /* IE */
	
    jQuery("#popBox").fadeIn("fast");
    var leftPoint = (Fensterweite()-popBoxWidth)/2;
    jQuery("#popBox").css("left",leftPoint);
}

function readyMsg(text, type)
{
    /*var color = 'green';
    if(type == 'ERROR') color = 'red';
    jQuery("#readyMsg").css("background-color",color);*/
    var popBoxWidth = jQuery("#readyMsg").width();
	
	if(jQuery.support.opacity) { jQuery("#popHG").fadeIn("fast"); }
	else { jQuery("#popHG").show(); } /* IE */
	
    jQuery("#readyInfo").html(text);
    jQuery("#readyMsg").fadeIn("slow");
    var leftPoint = (Fensterweite()-popBoxWidth)/2;
    jQuery("#readyMsg").css("left",leftPoint);

    setTimeout(function() { jQuery("#readyMsg").fadeOut("slow"); jQuery("#popHG").fadeOut("slow"); }, 2500);
}

jQuery(document).ready(function()
{
    //schließen der Usersuche
    jQuery("a.fclose").livequery("click",function()
	{
		jQuery("#divlayer").hide();
		jQuery("#divlayer").html("&#160;");
	});

    //Popup schließen
    jQuery(".closepopup").livequery('click',function()
    {
		
		if(jQuery.support.opacity) { jQuery("#popHG").fadeOut("fast"); }
		else { jQuery("#popHG").hide(); } /* IE */
		
        jQuery("#popBox").fadeOut("fast");
    });

    jQuery(document).pngFix();

	jQuery("#buttonEinaus").toggle(
		function(){ jQuery("#einaus").show(); },
		function(){ jQuery("#einaus").hide(); }
	);

	jQuery("#glow").hover(
		function () { jQuery("#letter").css("background-position","top"); },
		function () { jQuery("#letter").css("background-position","-200px"); }
	);
	jQuery("#letter").hover(
		function () { jQuery("#letter").css("background-position","top"); },
		function () { jQuery("#letter").css("background-position","-200px"); }
	);

    jQuery(".userJS").livequery('mouseenter',function()
	{   
		var thisId = jQuery(this).attr("id");

		jQuery("#"+thisId).addClass("selected");
		var thisList = jQuery(this).parents(".listOF").attr("id");
		//alert(thisList);

		jQuery("div#"+thisList+" .listName").each(function()
		{
			if(jQuery(this).children(".userJS").hasClass("selected"))
			{
				jQuery(this).find("span").fadeIn("fast");
				jQuery(this).find("p").slideDown('fast');
				jQuery(this).find(".userJS").removeClass("selected");
				jQuery(this).find(".userJS").addClass("open");
			}
			else
			{
				if(jQuery(this).children(".userJS").hasClass("open"))
				{
					jQuery(this).find("span").fadeOut("fast");
					jQuery(this).find("p").slideUp('fast');
					jQuery(this).find(".userJS").removeClass("open");
				}
			}
		}); // div#"+thisList+" .listName").each(function
		jQuery("div#"+thisList).prev().html('&nbsp;').hide();
		jQuery("div#"+thisList).prev().html('<img src="' + jQuery("#imgurl" + this.id.substr(6) ).val() + '" alt="Profilbild" />');
		jQuery("div#"+thisList).prev().fadeIn('fast');

	}); // mouseenter

});