﻿$(document).ready(function() {
	$(".gal").each(function() {
		var tmp = 0;
			$(this).find(".pic").each(function() {
			if(tmp != 0) {
				$(this).css("margin-left","70px");
			}
			tmp++;
			if(tmp > 2) tmp=0;
		});
	});
	
	var tmp = 0;
	$(".news_small").each(function() {
		if(tmp != 0) {
			$(this).css("margin-left","35px");
		}
		tmp++;
		if(tmp > 2) tmp=0;
	});
	
	var tmp = 0;
	$(".videos").each(function() {
		if(tmp != 0) {
			$(this).css("margin-left","75px");
		}
		tmp++;
		if(tmp > 1) tmp=0;
	});
	
	$("input[name='button_ajanlat']").click(function() {
		var tmp = 0;
		$("input[class='need']").each(function() {
			if( $(this).val() == '') tmp = 1;
		});
		if(tmp == 1) alert('Kérem minden mezőt töltsön ki!');
	});

	$("input[name='button_fuvar']").click(function() {
		var tmp = 0;
		$("input[class='need']").each(function() {
			if( $(this).val() == '') tmp = 1;
		});
		if(tmp == 1) alert('Kérem minden mezőt töltsön ki!');
	});
	
	$("input[name='fuvarreg']").click(function() {
		var tmp = 0;
		$("input[class='need']").each(function() {
			if( $(this).val() == '') tmp = 1;
		});
		if(!$("input[name='agree']").attr("checked")) tmp = 1;
		if(tmp == 1) alert('Kérem minden mezőt töltsön ki!');
	});
	
	$(".video").media({width: 594});
	
	$(".gal .pic").lightbox();
	
	$(".regbutton").click(function() {
	    var error = 0;
	    $(".need").each(function() {
		if($(this).hasClass('check')) {
		    if($(this).attr("checked") == '') error = 2;
		} else {
		    if($(this).val() == '') if(error != 2) error = 1;
		}
	    });
	    if(error == 1) alert('A folytatáshoz kérem töltse ki a mezõket!');
	    else if(error == 2) alert('Kérem fogadja el a feltételeket!');
	    else $("#reg").submit();
	});
	
	$("input[name='login_username'], input[name='login_password']").click(function() {
	    $(this).val('');
	});
	
	$(".nav .up").click(function() {
	    ajax_cmd('shoutbox', 0, $(this).parent().attr("id"));
	});
	
	$(".nav .down").click(function() {
	    ajax_cmd('shoutbox', 1, $(this).parent().attr("id"));
	});
	
	$(".result").each(function() {
	    if(tmp == 0) tmp = 1;
	    else if(tmp == 1) tmp = 0;
	    if(tmp == 0) {
		$(this).css("margin-right", "0px");
	    }
	});
	
	$(".delete").click(function() {
	    var conf = confirm('Biztosan törölni szeretné?');
	    if(!conf) window.location.reload();
	});
	

});