var cookieName='scrollPosition';
var cookieLifeTime=3600;
function st(linkes){return (document.statka.src="statka.php?linkes="+linkes)?true:false;}
$(document).ready( function() {
    $('a[name]').click(function(){return st( this.name );});
    $("a[href$=.jpg],a[href$=.jpeg],a[href$=.png],a[href$=.gif]").fancybox();
    $('a[target=popup]').fancybox({width:660,height:$(window).height()*0.8,type:'iframe'});
    $('a[rel=regisztracio]').fancybox({width:550,height:250});
    setHeight();
    var scrollToPosition=getCookie(cookieName+"_"+window.location.href);
    if (window.location.href.match(/[#]/i)){
        var hash=window.location.href.substring( window.location.href.indexOf( '#' )+1);
        if(hash)$(document).scrollTop( $("A[name="+hash+"]").position().top );
    }
    else if(scrollToPosition)$(document).scrollTop( scrollToPosition );
    $("A[href^=#top]").click(function(){$('html,body').animate({scrollTop:0},'slow');return false;});
    $("AREA[href^=#top]").click(function(){$('html,body').animate({scrollTop:0},'slow');return false;});
});
$(window).resize(setHeight());
$(window).scroll(function(){
    if(document.documentElement)setCookie(cookieName+"_"+window.location.href,document.documentElement.scrollTop,cookieLifeTime);
    else if(window.pageYOffset)setCookie(cookieName+"_"+window.location.href,window.pageYOffset,cookieLifeTime );
});
var kisebbVolt=false;
function setHeight(){
	var totalHeight=$("#container").height();
	if((totalHeight&&totalHeight<$(window).height())||kisebbVolt){
		kisebbVolt=true;
		$("#content").height($(window).height()-totalHeight+$("#content").height());
		$("#left").height($("#content").height());
	}
}
function setCookie(c_name,value,expireSeconds) {
	var exdate=new Date();
	exdate.setTime(exdate.getTime()+expireSeconds*1000);
	document.cookie=c_name+"="+escape(value)+((expireSeconds==null)?"":";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){
			c_start=c_start+c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if(c_end==-1)c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return null;
}