loadjs=
{  
    type: {js: "js", css: "css", csstxt: "csstxt"},
	myload: function (){
		var scripts = { 
			DTabs: { src: '/templates/js/dtabs.js', type: this.type.js	},
			DModal: { src: '/templates/js/dmodal.js', type: this.type.js	},
			jquery: { src: '/templates/js/Jquery/jquery.min.js', type: this.type.js	},
			jquery_fancybox: { src: '/templates/js/Jquery/fancybox/jquery.fancybox-1.3.1.js', type: this.type.js	},
			jquery_fancybox_css: { src: '/templates/js/Jquery/fancybox/jquery.fancybox-1.3.1.css', type: this.type.css	},
			jquery_ui_core: { src: '/templates/js/Jquery/ui/jquery.ui.core.min.js', type: this.type.js	},
			jquery_ui_widget: { src: '/templates/js/Jquery/ui/jquery.ui.widget.min.js', type: this.type.js	},
			jquery_ui_mouse: { src: '/templates/js/Jquery/ui/jquery.ui.mouse.min.js', type: this.type.js	},
			jquery_ui_sortable: { src: '/templates/js/Jquery/ui/jquery.ui.sortable.min.js', type: this.type.js	},
			jquery_autocomplete: { src: '/templates/js/Jquery/jquery-autocomplete/jquery.autocomplete.pack.js', type: this.type.js	},
			jquery_autocomplete_css: { src: '/templates/js/Jquery/jquery-autocomplete/jquery.autocomplete.css', type: this.type.css 	},
			niftycube: { src: '/templates/js/NiftyCube/niftycube.js', type: this.type.js	}, 
			swfobject: { src: '/templates/js/swfobject.js', type: this.type.js	}
		};
		
		for( var i = 0; i < arguments.length; i++ ) {
			if(scripts[arguments[i]]){
				this.load (scripts[arguments[i]]['src'], scripts[arguments[i]]['type']); 
			}
		}
		//this.sleep(200); // Zaderjka chtob uspela obnovitsya DOM (inache mojet glyuchit pri vyzove vnov zagrujennyh klassov)
		
	},
    load: function (url_, type_)
    {   
		if (typeof(type_) == "undefined")
        {
            type_ = loadjs.type.js;
        }   
		
		if( type_ == loadjs.type.js ){  // faily javascript
			$.ajax({
			  url: url_,
			  dataType: 'script',
			  async: false
			});
			return 1;
		}
		
		
        var is_exist=false;   
        var tag = type_ == loadjs.type.js ? "script" : type_ == loadjs.type.css ? "link" : "style";
        var objects=document.getElementsByTagName(tag); 
        var src = type_ == loadjs.type.js ? "src" : "href";   
        for(var i=0; i < objects.length; i++)
        {   
            var elem=objects[i];     
            if(elem.getAttribute(src) == url_)
            {
                is_exist=true;
            }
        }
        if(is_exist)
        {
            return;
        }   
       var type = type_ == loadjs.type.js ? "text/javascript" :    "text/css";
       var _elem=document.createElement(tag);   
        
        _elem.setAttribute("type", type);
        _elem.setAttribute(src, url_);   
        
        if (type_ == loadjs.type.css)
        {
            _elem.setAttribute("rel", "Stylesheet");
        }   
        if (type_ == loadjs.type.csstxt)
        {
            if (typeof(_elem.styleSheet) != "undefined")
            {
                _elem.styleSheet.cssText = url_;
            }   
            else if (typeof(_elem.innerText) != "undefined")
            {
                _elem.innerText = url_;
            }
            else
            {
                _elem.innerHTML = url_;
            }
        }
        //document.getElementsByTagName("head")[0].appendChild(_elem);  
		window.onload = function(){
	        document.getElementsByTagName("body")[0].appendChild(_elem);
		}
    },
	sleep: function(milliseconds) {
	  var start = new Date().getTime();
	  for (var i = 0; i < 1e7; i++) {
    	if ((new Date().getTime() - start) > milliseconds){
      	break;
    }
  }
}


};
