$(document).ready(function(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li span").click(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	
	$("#reg_form").validate({});
	//$.mask.definitions['!']='[237]';
	$.mask.definitions['d']='[0123456789 ]';
	$('#reg_phone').mask('+36 99 / 999 - 999d', {
		placeholder: '_ '
	});
	
	$("a[rel=galeria]").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
	});
	$("a[rel=galeria2]").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
	});
	$("a[rel=blog]").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
	});
	
	$("#slider").easySlider({
		controlsBefore:	'<p id="controls">',
		controlsAfter:	'</p>',
		auto: true, 
		continuous: true,
	});
	$("#slider2").easySlider({
		controlsBefore:	'<p id="controls2">',
		controlsAfter:	'</p>',
		auto: true,
		continuous: true,
		prevId: 'prevBtn2',
		nextId: 'nextBtn2'	
	});	

	$('.log').click(function() {
		$('#login_form').slideToggle("slow");
		return false;
	});
	
});

Cufon.DOM.ready(function() {        
	Cufon.replace ('h1', {hover:true, fontFamily: 'Optus'});
	Cufon.replace ('.alcim', {fontFamily: 'Optus'});
});

baseurl = "http://hucap.hu";

function reply_to(id,com_id) {
	$("#reply_to").html('<a href="" onclick="return no_reply();" title="Válaszírás visszavonása"><img src="./images/com_ans_delete.png" alt="mégsem" style="padding-right: 10px;"/></a>Válasz ' + $("#comm_"+id).find('td span').html() + ' ' + $("#comm_"+id).find('td span').next('span').html() + '-kor született  ('+ com_id +'. számú) bejegyzésére');
	$("input[name=c_reply]").attr('value',id);
	magassag =( $("#hozzaszolok").offset().top - 10);
	$('html, body').animate({scrollTop: magassag }, 500); 
	return false;
}

function no_reply() {
	$("#reply_to").html("");
	$("input[name=c_reply]").attr('value',0);
	return false;
}

function go2top() {
	$('html, body').animate({scrollTop: 0 }, 500); 
	return false;
}

function ajax(mylist,where) {

	$('#'+where).html('<p style="text-align: center;"><img src="'+baseurl+'/images/ajax-loader.gif" /></p>');
	$.ajax({
		type: "POST",
		url: baseurl+"/index.php",
		datatype: "html",
		data: mylist,
		success: function(data){
			$('#'+where).html(data);
			$('html, body').animate({scrollTop: $('#art').offset().top }, 500);
			window.fbAsyncInit = function() {
				FB.init({status: true, cookie: true, xfbml: true});
			};
			var tmp = document.getElementById('fb-root');
	        if(tmp != null)
	        {
	        	var e = document.createElement('script'); e.async = true;
	        	e.src = document.location.protocol + '//connect.facebook.net/hu_HU/all.js';
	        	document.getElementById('fb-root').appendChild(e);
	        }
		}
	});
	return false;
}

