var allHTMLTags = new Array();

function getElementByClass(theClass)
{

	var allHTMLTags=document.getElementsByTagName("*");

	for (i=0; i<allHTMLTags.length; i++)
	{
		if (allHTMLTags[i].className==theClass)
		{
			allHTMLTags[i].style.display="none";
		}
	}
}

function openMenu($id)
{

	if ( $id > 0 )
	{

		getElementByClass("contentMenu");
		document.getElementById("contentMenu_" + $id).style.display = "block";

	}

}

function sendForm(id)
{

	if ( document.getElementById("name").value.length < 2 )
	{

	    alert("Błąd: brak podpisu...");
	    return false;

	}

	if ( document.getElementById("email").value.length < 8 )
	{

	    alert("Błąd: niepoprawny adres e-mail");
	    return false;

	}

	if ( document.getElementById("text").value.length < 10 )
	{

	    alert("Błąd, wiadomość jest za krótka...");
	    return false;

	}

	input = document.createElement("input");
	input.type = "hidden";
	input.value = id;
	input.name = "message_send";
	document.getElementById(id).appendChild(input);

	document.getElementById(id).submit();

}

function addComment(formid, nid)
{

	if ( document.getElementById("comment_name").value.length < 2 )
	{

	    alert("Błąd: brak podpisu...");
	    return false;

	}

	if ( document.getElementById("comment_text").value.length < 2 )
	{

	    alert("Błąd: komentarz nie zawiera treści...");
	    return false;

	}

	input = document.createElement("input");
	input.type = "hidden";
	input.value = nid;
	input.name = "comment_add";
	document.getElementById(formid).appendChild(input);

	document.getElementById("comment_form").submit();

}

function getRemoteGallery(gid)
{

	$.getJSON("?mod=ajax&dl=gallery&gid=" + gid, function(data) {

		$.each(data[0], function(i,item){
			$(".remoteimages").append('<a href="'+ data[1][i] +'" rel="prettyPhoto[remotegallery]" style="background-image: url('+ item +');"></a>');
		});

		ppInit();

	});

}

function ppInit()
{

	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'fast',
		showTitle: false,
		hideflash: true,
		autoplay: false,
		overlay_gallery: false,
		allow_resize: false,
		social_tools: '',
		deeplinking: false,
		autoplay_slideshow: false,
		theme:'facebook'
	});

}

function ppResize()
{

	/*
	var maxHeight = 0;

	$(".column").each(function(){

		var margin = Number( $(this).css('margin-top').replace( 'px','' ) );
		maxHeight = maxHeight < $(this).height() + margin ? $(this).height() + margin : maxHeight;

	});

	$(".column").each(function(){

		$(this).height(maxHeight - Number( $(this).css('margin-top').replace( 'px','' ) ) );

	});
	*/

	if ( ($('#c-left').height() + 10) < $('#c-right').height() )
	{

		$('#c-left').css('min-height', $('#c-right').height() + 35);

	}

}

$(document).ready(function(){

	ppInit();
	ppResize();

});
