var __page__ = '';
var price_hide = false;
$(document).ready(function() {
	__page__ = $('#__current_page__').val();
	var konfigurator = new Array('konfigurator', 'wydruk_oprawa', 'rama_passe', 'akcesoria', 'sklep', 'blejtrama', 'fotoboard', 'banner', 'fototapeta');
	var i =0;
	for(i=0;i<konfigurator.length;i++) {
		if(__page__ == konfigurator[i])
			__page__ = 'konfigurator';
	}
	
	$('#menu_glowne a').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	}).each(function() {
		var img = $(this).find('img');
		if(img.attr('alt') == __page__) {
			img.attr('src', img.attr('src').replace('.png', '_hv.png'));
		}
	});
	
	if(price_hide == true) {
		$('.cena_box').hide();
	}
});
function loading() {
	$('.black_bg').css({width: $(document).width()+'px', height: $(document).height()+'px'});
	var sh = $(document).height() / 2 - 100;
	$('#loading_spacerun').css({ height: sh+'px'});
	$('.black_bg').css('opacity', 0.8);
	$('.black_bg').fadeIn(200);
	$('#loading').fadeIn(200);
}

function loading_close() {
	$('.black_bg').fadeOut(200);
	$('#loading').fadeOut(200);
}

function do_logout() {
	loading();
	$.ajax({url: 'conn.php?go=do_logout', success: function(data) {
		loading_close();
		document.location += '';
	}
	});
	
}

function get_session_id() {
	return $('#PHPSESSID').val();
}

function debug() {
	var c = '';
	var i = 0;
	for(i=0;i<arguments.length;i++) {
		c += arguments[i];
		if(i+1 < arguments.length)
			c += '; ';
	}
	if(typeof(console) != 'undefined')
		console.log(c);
}

jQuery.fn.ForceNumericOnly = function()
{
    return this.each(function()
    {
        $(this).keydown(function(e)
        {
            var key = e.charCode || e.keyCode || 0;
            return (
                key == 8 || 
                key == 9 ||
                key == 46 ||
				/*key == 188 ||
				key == 190 ||
				key == 144 ||
				key == 110 ||*/
                (key >= 37 && key <= 40) ||
                (key >= 48 && key <= 57) ||
                (key >= 96 && key <= 105));
        })
		
		/*$(this).keyup(function() {
			$(this).val($(this).val().replace(',', '.'));
		});*/
    })
};

jQuery.fn.blink = function() {
	this.fadeOut(200, function() {
		$(this).fadeIn(200, function() {
			$(this).fadeOut(200, function() {
				$(this).fadeIn(200);
			});
		});
	});
	return this;
}

jQuery.fn.swapWith = function(to) {
    return this.each(function() {
        var copy_to = $(to).clone(true);
        var copy_from = $(this).clone(true);
        $(to).replaceWith(copy_from);
        $(this).replaceWith(copy_to);
    });
};

