$(document).ready(function() {
    
    $('#check_all').click(function() {
        var checked_status = this.checked;
        $('input#checkin').each(function() {
            this.checked = checked_status;
        });
    });
    
    $(".megye").change( function() {
        $.ajax({
            type: "POST",
            data: "id=" + $(this).val(),
            url: "oldal/varostker",
            success: function(msg){
                if (msg != ''){
                    $('.varos').removeAttr("disabled");
                    $(".varos").html(msg).show();
                }
            }
        });
    });
    
    $("#megye").change( function() {
        $("#result").html('Feldolgozás...');
        $.ajax({
            type: "POST",
            data: "id=" + $(this).val(),
            url: "profil/v",
            success: function(msg){
                if (msg != ''){
                    $('#varos').removeAttr("disabled");
                    $('.csubmit').removeAttr(('disabled'));
                    $("#varos").html(msg).show();
                    $("#result").html('');
                } else{
                    $("#result").html('<em>Nem találtam semmit</em>');
                }
            }
        });
    });
    
    $('select.platform').change(function() {
        $('select.platform option#valassz:selected').each(function () {
            $('label[for=tipus]').fadeOut('slow');
            $('select.tipus').fadeOut('slow');
        });
    });
    
    $('select.kategoria').change(function () {
        $('select.stilus').removeAttr('disabled')
        .focus()
        $('label[for=stilus]').fadeIn('slow');
        $('select.stilus').fadeIn('slow');
    });
    
    $('select.kategoria').change(function() {
        $('select.kategoria option#valassz:selected').each(function () {
            $('label[for=stilus]').fadeOut('slow');
            $('select.stilus').fadeOut('slow');
        });
    });
    $('.msg').click(function() {
        $( "#dialog:ui-dialog" ).dialog( "destroy" );
        $( "#msg-window" ).dialog({
            modal: true,
			minWidth: 400,
            show: 'bounce',
            hide: "bounce"
        });
    });
    
    $(function() {
        $( "#datepicker" ).datepicker({
            dateFormat: 'yy-mm-dd',
            changeMonth: true,
            changeYear: true,
            yearRange: '1940:2011'
        });
    });
    $(function() {
        $( ".datepicker" ).datepicker({
            dateFormat: 'yy-mm-dd',
            changeMonth: true,
            changeYear: true,
            yearRange: '1940:2011'
        });
    });
	$('div.zene a').hover(function(){
		$(this).fadeTo('slow', 1.0);
	},function(){
   		$(this).fadeTo('slow', 0.0);
	});
    $('div.program a').hover(function(){
		$(this).fadeTo('slow', 1.0);
	},function(){
   		$(this).fadeTo('slow', 0.0);
	});
    $('a.imgview').hover(function(){
		$(this).fadeTo('slow', 1.0);
	},function(){
   		$(this).fadeTo('slow', 0.0);
	});
    $('a[rel=viewimg]').fancybox({
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
    });
    
    
    $(function() {
        $('.thanks').click(function() {
            var seo = $(this).attr('rel');
            $.ajax({
               type: 'post',
               url: 'http://djsmp3.com/koszonom/' + seo,
               cache: false,
               success: function(){
            	$( "#dialog:ui-dialog" ).dialog( "destroy" );
                    $( "#thx-window" ).dialog({
                        modal: false,
                        show: 'bounce',
                        hide: "bounce"
                    });
              }
     });
    
    return false;
    	});
    });
    
});

$(function() {
    $('#hszkuldes').click(function() {
        var seo     = $(this).attr('alt');
        var szoveg  = $('textarea.hsz').val();
        var dataString = 'szoveg='+ szoveg;
        if (szoveg  == '') {
            $( "#dialog:ui-dialog" ).dialog( "destroy" );
            $( "#hsz-window" ).dialog({
                modal: false,
                show: 'bounce',
                hide: "bounce"
            });
        } else {
            $.ajax({
                type: 'post',
                url: 'http://djsmp3.com/uj-hozzaszolas/' + seo,
                data: ({hsz: szoveg}),
                dataType: 'html',
                cache: false,
                success: function(html) {
                    $('p#nincs-hsz').remove();
                    $("ul.hozzaszolasok").append(html);
                    $("ul.hozzaszolasok li:last").slideDown('700');
                    $('form.formatted').slideUp('700').remove();
                }
            });
        }
        return false;
    });
});
$(function() {
    $('.hsz-torl').click(function() {
        var id  = $(this).attr('id');
        
        $.ajax({
            type: 'post',
            url: 'http://djsmp3.com/hozzaszolas-torlese/' + id,
            cache: false,
            success: function(html) {
                $('li#k'+id).fadeOut('700').remove();
            }
        });
        return false;
    });
});
