/** Menü rögzítése **/
(function($) {
	function setup_nav() {
		// elements
		var nav = $('#menu');
		var nav_orig_y = nav.position().top;

		// vars
		var window_y = 0;
		
		$(window).scroll(function() {
			window_y = $(window).scrollTop();
			if (window_y >= (nav_orig_y)) {
				nav.css({'position': 'fixed', 'top': 0});
				$('.fixedTop').css({'marginTop': '50px'});
				$('#up').fadeIn(500);
			} else if (window_y < (nav_orig_y)) {
				nav.css({'position': 'relative'});
				$('.fixedTop').css({'marginTop': '0'});
				$('#up').fadeOut(100);
			}
		}).trigger('scroll');
	}
	$(document).ready(function() {
		setup_nav();
	});
})(jQuery);


// Scroll
function goToByScroll(id){
	$('html,body').animate({scrollTop: $("#"+id).offset().top},1000);
}


$(document).ready(function() {
	
	/** TAB **/
	$('#tabvanilla > ul').tabs({ 
		fx: {
			height: 'toggle',
			opacity: 'toggle'
		}
	});
	
	/** Slideshow **/
	var buttons = { previous:$('#news .lof-previous'), next:$('#news .lof-next')};
	$obj = $('#news').lofJSidernews( { 
		interval: 5000,
		direction: 'opacitys',
		easing: 'easeInOutExpo',
		duration: 1200,
		auto: true,
		maxItemDisplay: 3,
		navPosition: 'horizontal',
		navigatorHeight: 32,
		navigatorWidth: 80,
		mainWidth: 700,
		buttons: buttons
	});
	
	/** prettyPhoto **/
	$("a[rel^='prettyPhoto']").prettyPhoto({
		show_title:	false,
		animation_speed: 'normal',
		slideshow: 3000,
		autoplay_slideshow: false,
		social_tools: false,
		deeplinking: false,
		hideflash: true
	});
	
	/** newsImage **/
	$('#newsImage img').delay(1000).fadeIn(2000);
	$('.preload').delay(1000).fadeOut(1000);
});


/** Kedvencekhez ad **/
function AddToFavorites() {  
	var title = document.title; var url = location.href;
	if (window.sidebar) // Firefox 
	window.sidebar.addPanel(title, url, '');  
	// Opera
	else if (window.opera && window.print) { 
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar'); // required to work in opera 7+  
		elem.click();
	}
	else if(document.all) // IE  
	window.external.AddFavorite(url, title);
}


/** Megosztás **/
function twittershare_click() {
	u=location.href;
	t=document.title;window.open('http://www.twitter.com/home/?status='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'iwiwshare','toolbar=0,status=0,location=1, width=800,height=500,scrollbars=1');
	return false;
}

function iwiwshare_click() {
	u=location.href;
	t=document.title;window.open('http://www.iwiw.hu/pages/share/share.jsp?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'iwiwshare','toolbar=0,status=0,location=1, width=650,height=600,scrollbars=1');
	return false;
}
function facebookshare_click() {
	u=location.href;
	t=document.title;window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'facebookshare','toolbar=0,status=0,location=1, width=650,height=600,scrollbars=1');
	return false;
}


