(function($) {
  $.fn.mask = function(){
  	this.each(function(){
  		var img = {
  			src: $(this).attr('src'),
  			bg: 'url('+this.src+')',
  			style: $(this).attr('style'),
  			width: $(this).width(),
  			height: $(this).height(),
  			alt:   $(this).attr('alt')
  		};
  		var div = $(this).wrap('<div>').parent().addClass('img');
  		div.attr({style: img.style, title: img.alt}).css({backgroundImage:img.bg, width: img.width, height: img.height});
                div.bind('contextmenu',function(){return false;});
  		div.find('img').remove();
  	});
  };
})(jQuery);

function addItem()
{
    var itemaddForm = dijit.byId("item");
    dojo.connect(itemaddForm, "onsubmit", function(e) {
        e.preventDefault();
        e.stopPropagation();
        if (itemaddForm.validate()) {
            itemaddForm.submit();
        }
    });    
}

function addHint()
{
    var hintaddForm = dijit.byId("hint");
    dojo.connect(hintaddForm, "onsubmit", function(e) {
    	alert('bla');
        e.preventDefault();
        e.stopPropagation();
        if (hintaddForm.validate()) {
            hintaddForm.submit();
        }
    });    
}

function checkCat()
{
	var catSelect = dijit.byId("cat_idselect").item;
	if(catSelect.value < 0) {
		new dijit.Tooltip({
		     connectId: ["cat_idselect"],
		     label: "Выбрать можно категории, помеченные зведочками!",
		     position: 'below',
		     delay: 1000
		  });
	}
}

$(window).bind('load',function(){$('img').mask();});
