/*
Scripts were created by PartyNation.tv Developers.

If you'd like to use them, please ask us.
info@partynation.tv
*/

function swsDynamicLoadPopup( url )
{
	return "Du hast " + url + " angefordert.";
}

function indicateBeginLoading()
{
	$("loadingIcon").show();
}

function indicateEndLoading()
{
	$("loadingIcon").hide();
}

function showBBCode() {
 fenster = window.open("/view2/templates/bbcodehelp.htm", "BB-Code", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes");
 fenster.focus();
}

function showBBCodePreview( formElement )
{
	var bbcode = formElement.value;
	
	indicateBeginLoading();
	
	new Ajax.Request('/index.php',
	{
		method:'post',
		parameters: { a: 'bbcodepreview_make', c: bbcode },
		onSuccess: function(transport)
		{
			indicateEndLoading();
			var response = transport.responseText || "<h1>Konnte Preview nicht holen</h1>";
			$("bbcodepreviewhtml").innerHTML = response;
			$("bbcodepreview").show();
		},
		onFailure: function(){ indicateEndLoading(); alert('Konnte Preview nicht holen.'); }
	});
}

function directLogin( frm )
{
	var senddata = $("inlineloginform").serialize(true);
	
	$("inllogform").hide();
	$("inllogstatus").show();
		
	new Ajax.Request('/index.php?a=login_inlinelogin',
	{
		method: 'post',
		parameters: senddata,
		onSuccess: function(transport)
		{
			if( transport.responseText == "succ" )
			{
				window.location.reload();
				return;
			}
			else
			{
				$("loginerror").innerHTML = "Mit diesen Daten kann PN.tv nichts anfangen";
				$("loginerror").show();
			}
			
			$("inllogform").show();
			$("inllogstatus").hide();
		},
		onFailure: function()
		{
			alert("Login failed");
			$("inllogform").show();
			$("inllogstatus").hide();
		}
	});
	
	return false;
}

function onBodyLoad()
{
	//initLightbox();
}

function onBodyUnload()
{
	if( self.GUnload )
	{
		GUnload();
	}
}

/* Tab-Switching functionality */
function toggleSidebarTab( group, tab )
{
	$(group).getElementsBySelector(".tabpage").invoke("hide");
	$(group).getElementsBySelector(".tabbutton").invoke( "removeClassName", "active" );
	
	$(tab).show();
	$(tab+"button").addClassName("active");	
}

/* Select / deselect everything */
function selAllImages()
{
	$$("*.imageselbox").each( function(s) { s.checked = true; } );
	$("selallbutton").onclick = deselAllImages;
}
function deselAllImages()
{
	$$("*.imageselbox").each( function(s) { s.checked = false; } );
	$("selallbutton").onclick = selAllImages;
}
