$(document).ready(function(){

	//set the height
	var maxHeight = 533;
	var minHeight = 200;
	
	$('img.resize')
		//mouseOver effect
		.click(function(){
			if($(this).attr("class") == "resize"){
                $(this).css("top",$(this).position().top-30 +'px');
                $(this).css("left",$(this).position().left +'px');
				$(this).stop().animate({
					height: (maxHeight) +'px',
					left: Math.random()*200 +'px'
				},100,function() {
   					 // Animation complete.
					$(this).attr("src",$(this).attr("alt"));
 				});
				$(this).addClass("on");
			} else {
                $(this).css("top","auto");
                $(this).css("left","auto");
				$(this).stop().animate({
					height: (minHeight) +'px'
                },100);
				$(this).removeClass("on");
			} 
		});
});
$(function(){
	fullHeight = $('#main_article .scroll').innerHeight();
	fullHeight2 = $('#right .obal1').innerHeight();
	if (fullHeight > 307) {
		$('<br/><br/>').appendTo('#fulltext .content');
		$('#main_article .scroll').css("height","307px");
		$('#more').toggle(openText,closeText);
		$('#main_article').mousewheel(mainMouseWheel);
	} else {
    	$("#more").remove();
	}
	if (fullHeight2 > 217) {
		$('#more2').toggle(openText2,closeText2);
		$('<br/><br/>').appendTo('#right .obal2');
		$('#right .obal1').css("height","217px");
		$('#right').mousewheel(rightMouseWheel);
	} else {
    	$("#more2").remove();
	}
	$("#home,#mainmenu").mouseover(function(){$.scrollTo(0,500)});
	$('#keywords').focus(function(){this.value = "";});
});
function openText(){
		//$("#main_article").addClass("wide");
	//fullHeight = $('#main_article .scroll').innerHeight();
		$('#main_article').unbind('mousewheel');
		//$("#right").hide();
		//$('#main_article .scroll').css("height","auto");
		//fullHeight = $('#main_article .scroll').innerHeight();
    		$("#main_article .scroll").animate({"height": fullHeight}, "slow", 'linear', function() {
    			$("#more").addClass("open");
    			$("#more span").text("Méně");
			$('#main_article .scroll').css("height","auto");
			$('#main_article .scroll').css("overflow","visible");
  		});
}
function closeText(){
		
		//$("#right").show();
if(jQuery.url.segment(2) == 'c' || jQuery.url.segment(3) == '' ){
		
}
			$('#main_article .scroll').css("overflow","hidden");
//$("#main_article").removeClass("wide");
	fullHeight = $('#main_article .scroll').innerHeight();
    		  $("#main_article .scroll").animate({"height": 357}, "slow", 'linear', function() {
    		  	$("#more").removeClass("open");
    			$("#more span").text("Více");
			$('#main_article').mousewheel(mainMouseWheel);
  		});
}
function openText2(){
		$('#right').unbind('mousewheel');
    		  $("#right .obal1").animate({"height": fullHeight2}, "slow", 'linear', function() {
    		 	 //$("#more2").html("x");
                $("#more2").addClass("open");
    			$("#more2 span").text("Méně");
			$('#right .obal1').css("height","auto");
  		});
}
function closeText2(){
    		  $("#right .obal1").animate({"height": 317}, "slow", 'linear', function() {
    			  //$("#more2").html("+");
    		  	$("#more2").removeClass("open");
    			$("#more2 span").text("Více");
			$('#right').mousewheel(rightMouseWheel);
  		});
}
function rightMouseWheel(event, delta){
	if (delta < 0){
		$('#more2').trigger("click");
	}
}
function mainMouseWheel(event, delta){
	if (delta < 0){
		$('#more').trigger("click");
	}
}
