$(function(){
	
	$("#lay-left-content").each(function(it, table){
		$("tr", $(table)).each(function(i, row){
			$(row).css({background: (i%2) ? 'rgb(255,255,255)' : 'rgb(211,211,211)' });
		});
	});
	
	
	//$('#add-to-fav').jFav();
	
	$(".b64").each(function(i, el){
		$(el).html(base64_decode($(el).html()));
	});
	
	//odpalenie superfisha wylacznie dla ie6
	/*/if(typeof document.body.style.maxHeight === "undefined") {
		$("#lay-top-menu ul").superfish({
			delay:       0,                            // one second delay on mouseout  
	        speed:       'fast'
		});
	}/*/	
	
	if(typeof document.body.style.maxHeight === "undefined"){
		$("#lay-top-menu .main-item").mouseenter(function(){
			$(this).addClass("sfHover");
			//supersleight.run();
		}).mouseleave(function(){
			$(this).removeClass("sfHover");
		});
	}
	
        $('.eem').click(function(){
            a_mail = this;
            $("#mail-dialog").show();
			$("#mail-dialog").dialog('open');
            $('#mail-dialog').dialog({
                modal : true,
                height : 500, 
                width  : 400,
                overlay: { 
                    opacity: 0.5, 
                    background: "black" 
                },
                open : function(){
                    $.post(
                        $(a_mail).attr('href'),
                        {}, 
                        function(data, status){
                            $("#mail-dialog").html(data);
                        }, 
                        'text');
                },
                buttons : {
                    'Wyślij' : function(p1){
                        $(p1.target).html('<img src="public/gfx/ajax-loader-small.gif"/>&nbsp;&nbsp;Wysyłanie ...');
                        
                        data = {
                            personal : $('#mail-dialog #personal').val(),
                            company : $('#mail-dialog #company').val(),
                            phone : $('#mail-dialog #phone').val(),
                            email : $('#mail-dialog #email').val(),
                            msg : $('#mail-dialog #msg').val(),
                            reciver : $('#mail-dialog #reciver').val()
                        };
                        
                        //show overlay
                        $.post(
                            "mail/index/send",
                            data,
                            function(data, status){
                                if(data['response'] == 'success') {
                                    $(p1.target).html('Wyślij');
									$("#mail-dialog").dialog("close");
                                } else if (data['response'] == 'error' && data['form'] != undefined) {
                                    $(p1.target).html('Wyślij');
                                    $("#mail-dialog").html(data['form']);
                                } else {
                                    alert('server error');
                                }
                            },
                            'json'
                        );
                    }
                }
            });
            return false;
        });
});



        
