$(document).ready(function() {
    /*layer popup*/
    $("a.fancy").fancybox({
        'padding'               : 10,
        'overlayOpacity'        : 0.5,
        'overlayColor'          : '#f3f1ec',
        'titlePosition'         : 'inside'
    });
    $("a.video").fancybox({
        'padding'               : 10,
        'autoScale'             : false,
        'autoDimensions'        : false,
        'width'                 : 450,
        'height'                : 342,
        'overlayOpacity'        : 0.5,
        'overlayColor'          : '#f3f1ec',
        'titleShow'             : false,
        'type'                  : 'iframe',
        'scrolling'             : 'no',
        'hideOnOverlayClick'    : false,
        'titlePosition'         : 'inside'
    });
    $("a.promo").fancybox({
        'padding'               : 10,
        'autoScale'             : false,
        'autoDimensions'        : false,
        'width'                 : 440,
        'height'                : 600,
        'overlayOpacity'        : 0.5,
        'overlayColor'          : '#f3f1ec',
        'titleShow'             : false,
        'type'                  : 'iframe',
        'scrolling'             : 'no',
        'hideOnOverlayClick'    : false,
        'titlePosition'         : 'inside'
    });
    $("a.fancy").each( function() { this.href = this.href.replace( /\/(hu|de|en)\/(.*)$/, '/$2'); } );

    $("#fp_allasajanlat_job, #fp_recept_cat, #fp_recept_item").selectbox();
    $(".jquery-selectbox").width(234);
    $(".jquery-selectbox-list").width(234);
    $("a.menu01").mouseover(function() {
        $("div.submenu").fadeOut('fast');
        $("div.submenu01").fadeIn('fast');
    });
    $("a.menu02").mouseover(function() {
        $("div.submenu").fadeOut('fast');
        $("div.submenu02").fadeIn('fast');
    });
    $("a.menu03").mouseover(function() {
        $("div.submenu").fadeOut('fast');
        $("div.submenu03").fadeIn('fast');
    });
    $("a.menu04").mouseover(function() {
        $("div.submenu").fadeOut('fast');
        $("div.submenu04").fadeIn('fast');
    });
    $("a.menu05").mouseover(function() {
        $("div.submenu").fadeOut('fast');
        $("div.submenu05").fadeIn('fast');
    });
    $("#inside-header-layer, #lead").mouseover(function() {
        $("div.submenu").fadeOut('fast');
    });
    $("input.file").filestyle({ 
        image: "/gfx/btn_browse.png",
        imageheight : 26,
        imagewidth : 99,
        width : 131,
        wrappertop : 0
    });
});

function setJob(title) {
    $("#fp_allasajanlat_job").parents('.jquery-selectbox').unselectbox();
    $('#fp_allasajanlat_job').val(title);
    $("#fp_allasajanlat_job").selectbox();
    $(".jquery-selectbox").width(234);
    $(".jquery-selectbox-list").width(234);
}

var raspoutine = {
    src: '/gfx/raspoutine.swf'
        ,ratios: [6, 1.41, 9, 1.35, 15, 1.29, 21, 1.25, 22, 1.22, 27, 1.24, 29, 1.21, 34, 1.22, 41, 1.21, 45, 1.2, 46, 1.21, 59, 1.2, 68, 1.19, 69, 1.2, 96, 1.19, 97, 1.18, 102, 1.19, 103, 1.18, 107, 1.19, 108, 1.18, 112, 1.19, 114, 1.18, 116, 1.19, 120, 1.18, 121, 1.19, 1.18]
};
sIFR.activate(raspoutine);
sIFR.replace(raspoutine, {
    selector: 'h1'
    ,wmode: 'transparent'
    ,css: {
        '.sIFR-root': { 'color': '#857040' },
        'a': { 'color': '#857040', 'text-decoration': 'none' },
        'a:hover': { 'color': '#857040', 'text-decoration': 'underline' }
    }
});
sIFR.replace(raspoutine, {
    selector: 'h2'
    ,wmode: 'transparent'
    ,css: {
        '.sIFR-root': { 'color': '#857040' },
        'a': { 'color': '#857040', 'text-decoration': 'none' },
        'a:hover': { 'color': '#857040', 'text-decoration': 'underline' }
    }
});
sIFR.replace(raspoutine, {
    selector: 'h3'
    ,wmode: 'transparent'
    ,css: {
        '.sIFR-root': { 'color': '#8b0f04' },
        'a': { 'color': '#857040', 'text-decoration': 'none' },
        'a:hover': { 'color': '#857040', 'text-decoration': 'underline' }
    }
});
sIFR.replace(raspoutine, {
    selector: 'h4'
    ,wmode: 'transparent'
    ,css: {
        '.sIFR-root': { 'color': '#8b0f04' },
        'a': { 'color': '#857040', 'text-decoration': 'none' },
        'a:hover': { 'color': '#857040', 'text-decoration': 'underline' }
    }
});


function checkVideoData() {
	if ( $('#user_name').val() == '') {
		alert('Kérem adja meg a nevét!');
		return false;
	}
	if ( $('#user_email').val() == '') {
		alert('Kérem adja meg az e-mail címét!');
		return false;
	}
    
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if( reg.test($('#user_email').val()) == false ) {
		alert('Létező e-mail címet kell megadni!');
		return false;	
	}

	if ( $('#video_title').val() == '') {
		alert('Kérem adja meg a videó nevét!');
		return false;
	}
	swfu.startUpload();
	return false;
}

function voteRecipe(id) {
    $.ajax({
        type: 'GET',
        url: '/'+_lang+'/vote/recipe/'+id,
        success: function(msg){
			$('#recipe_'+id).hide();
			$('#recipe_count_'+id).html(parseInt($('#recipe_count_'+id).html())+1);
		}
    });
    return false;
}

function voteDRecipe(id) {
    $.ajax({
        type: 'GET',
        url: '/'+_lang+'/vote/drecipe/'+id,
        success: function(msg){
			$('#recipe_'+id).hide();
			$('#recipe_count_'+id).html(parseInt($('#recipe_count_'+id).html())+1);
		}
    });
    return false;
}


function vote(id) {
    $.ajax({
        type: 'GET',
        url: '/'+_lang+'/vote/'+id,
        success: function(msg){
			$('#video_'+id).hide();
			$('#video_count_'+id).html(parseInt($('#video_count_'+id).html())+1);
		}
    });
    return false;
}

function updateVote(id) {
	$('#video_'+id).hide();
	$('#video_count_'+id).html(parseInt($('#video_count_'+id).html())+1);
}


function resizeFlash(h) {
    document.getElementById("flashmenu").style.height = h + "px";
}

