var itemStatus = false;
var tabService = false;

 $(document).ready(function() {

     var options = {
                minWidth: 200,
				arrowSrc: '/img/arrow_gray_light.png',
				offsetLeft : -1,
				offsetTop: 3,
				copyClassAttr: true,
                onClick: function(e,menuItem){
                    var link = $(this).find('a').attr('href');
                    if(link)
                        window.location.href=link;
                },
                onClose: function(){
					/*
                    $("#navigation_top li.profile_menu>img").each(function(){
                        rollsrc = $(this).attr("src");
                        rollON = rollsrc.replace("_on.png",".png");
                        $(this).attr("src",rollON);
                        $(this).removeClass("selected");
                    });
				*/
                }
    };


	var iWOffsetlogin = $('#advuseroptions').width();
	var profiloptions = {
        minWidth: 160,
		arrowSrc: '/img/arrow_gray_light.png',
		offsetLeft : -(150-iWOffsetlogin),
		offsetTop: 14,
		copyClassAttr: true,
        onClick: function(e,menuItem){
              var link = $(this).find('a').attr('href');
              if(link)
                   window.location.href=link;
        }
    }


	// nawigacja rozwijana na warstwie
	$('#navigation_top').menu(options);
	$('.submenu').menu(options);
	$('#advuseroptions').menu(profiloptions);

		

     // glosowanie gwiazdkami
     $('ul.stars li').mouseover(function(){
           setVoteStar(this, 'hover');
     })
     $('ul.stars li').mouseout(function(){
           clearVoteStar(this);
     })
     $('ul.stars li').click(function(){
           setVoteStar(this, 'selected');
           sendVote(this);
     })

});


jQuery.create = function() {

    if (arguments.length == 0) return [];
    var args = arguments[0] || {},
    elem = null, elements = null;
    var siblings = null;
    // In case someone passes in a null object,
    // assume that they want an empty string.

    if (args == null) args = "";

    if (args.constructor == String) {

            if (arguments.length > 1) {

                    var attributes = arguments[1];

                    if (attributes.constructor == String) {
                        elem = document.createTextNode(args);
                        elements = [];
                        elements.push(elem);
                        siblings = jQuery.create.apply(null, Array.prototype.slice.call(arguments, 1));
                        elements = elements.concat(siblings);
                        return elements;
                    }
                    else {
                        elem = document.createElement(args);
                        // Set element attributes.
                        
                        for (var attr in attributes)
                                
                                jQuery(elem).attr(attr, attributes[attr]); // Add children of this element.
                                var children = arguments[2];

                                //alert(arguments[2]);
                                
                                children = jQuery.create.apply(null, children);
                                jQuery(elem).append(children); // If there are more siblings, render those too.

                                
                                if (arguments.length > 3) {
                                    siblings = jQuery.create.apply(null, Array.prototype.slice.call(arguments, 3));
                                    return [elem].concat(siblings);
                                }
                                
                                return elem;
                        }
            }
            else return document.createTextNode(args);
   }
   else {
            elements = [];
            elements.push(args);
            siblings = jQuery.create.apply(null, (Array.prototype.slice.call(arguments, 1)));
            elements = elements.concat(siblings);
            return elements;
   }
}