function resizeLeftPanel ()
{
	var parent=document.getElementById('centralpanel');
	var central = getElementsByClassName('boxcontent','div',parent);
	centralheight = central[0].clientHeight;
	var divs=getElementsByClassName('boxfooter','div',parent);
	centralheight += divs[0].clientHeight;
	var parent=document.getElementById('leftpanel');
	var left = getElementsByClassName('boxcontent','div',parent);
	leftheight = left[0].clientHeight;
	
	if( leftheight > centralheight )
		central[0].style.height = leftheight - divs[0].clientHeight + "px";
	if( leftheight < centralheight )
		left[0].style.height = centralheight + "px";
}

function getElementsByClassName(className, tag, elm)
{
	var testClass = new RegExp("(^|s)" + className + "(s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i ];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

var position = 0;
var selectedId = "pict_1";
function defilDiapo( diapoDivId, pictureTarget )
{
	linkId = "pict_" + pictureTarget;
	to = 610 * ( pictureTarget - 1 );
	new Effect.ScrollHorizontal( diapoDivId, {from: position, to: to, duration:1, transition: Effect.Transitions.exponential});
	if( $( selectedId )!= undefined )
	{
		str = $( selectedId ).className;
		$( selectedId ).className = str.replace(/selected/i, "");
	}
	
	if( $( linkId ) != undefined )
		$( linkId ).className += ( $( linkId ).className == "" ) ? "selected": " selected";
		
	position = to;
	selectedId = linkId;
}

var formstatus = "close";
function postul( formId, imgId, imgActive )
{
	switch( formstatus )
	{
		case "close" :
		default :
			new Effect.Appear(formId);
			$( imgId ).inisrc = $( imgId ).src;
			$( imgId ).src = imgActive;
			formstatus = "open";
			break;
		case "open" :
			new Effect.Fade(formId);
			$( imgId ).src = $( imgId ).inisrc;
			$( imgId ).inisrc = "";
			formstatus = "close";
			break;
	}
}

var ddOpened;
function openDropDown( menuId )
{
	if( ddOpened != "" && $( ddOpened ) != undefined )
	{
		new Effect.BlindUp(ddOpened,{queue:{scope:'myscope', position:'end'}});
	}
	if( ddOpened != menuId && $( menuId ) != undefined )
	{
		new Effect.BlindDown(menuId,{queue:{scope:'myscope', position:'end'}});
		ddOpened = menuId;
		return true;
	}
	ddOpened = "";
}

function displayMsgPopup()
{
	new Effect.Appear( 'msg_popup', {duration:0.1} );
}

function hideMsgPopup()
{
	new Effect.Fade( 'msg_popup', {duration:1} );
}
var template;
function showmedia( tpl, media_id, gal_id )
{
	template = tpl;
	$( 'zoommedia' ).innerHTML = "";
	Effect.Appear('medialayer',{ to:0.4 });
	Effect.Appear('zoommedia',{ to:1.0 });
	ajaxRequest(tpl, 'template=showmedia&mid='+media_id+'&gid='+gal_id, 'zoommedia');
}

function hidemedia()
{
	Effect.Fade('zoommedia');
	Effect.Fade('medialayer');
}

function changemedia( media_id, gal_id )
{
	ajaxRequest(template, 'template=showmedia&mid='+media_id+'&gid='+gal_id, 'zoommedia');
}

function ajaxRequest( tpl, params, boxId, loader, methodSend )
{
	if( loader == true ) loadAjax();
	if( methodSend == undefined ) methodSend = "get";
	var request = new Ajax.Updater( boxId, tpl, { method: methodSend, parameters: params, evalScripts: true } ); 
}