/* v20091103 */
function loadDynamic (src,type){
    var node = document.createElement(type?"link":"script");
    node = document.getElementsByTagName("head")[0].appendChild(node);

    if(type){
		node.setAttribute("rel","stylesheet");
		node.setAttribute("media","all");
    }
    node.setAttribute("type","text/"+(type?"css":"javascript"));
    node.setAttribute(type?"href":"src",src);
}

(function(){

    function combinedWindowOnload(){
		if(arguments.callee.done){return;}
		arguments.callee.done = true;
		
		if(document.getElementsByTagName){
	
		    if(!/WebKit/i.test(navigator.userAgent)){
				 // setTimeout('loadDynamic("path_to.css",1)',0);
		    }		    
			
			/* Счетчики */
			if(document.getElementById('nl_counters')){
				
				set_counters('nl_counters');
				
				window.yandex_metrika_callback = function() {
			        window.yaCounter1033083 = new Ya.Metrika(1033083);
			    };
								
			}
		
			loadDynamic("http://s.newslab.ru/jslib.axd?d=/js/pl/ga.js&amp;v20100623");		
			loadDynamic("http://s.newslab.ru/jslib.axd?d=/js/pl/jquery-1.3.2.min.js,/js/pl/jquery.metadata.js,/js/pl/jquery.thickbox.js,/js/pl/jquery.swfobject.js,/js/pl/jquery.nl_spelling.js,/js/pl/jquery.nl_b.js,/js/pl/jquery.inputplaceholder.js,/js/pl/nl_init.js,/js/pl/nl_doc.js&amp;v20100610");
	
			var _on_jQuery_load = setInterval(function(){
			    
				if (typeof(jQuery) === 'function' && typeof(newslab_init) === 'function'){
									
					newslab_init();
					clearInterval(_on_jQuery_load);
	
			    }
				
			}, 10);		
	
	    }
}

	/* for Mozilla */
	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", wl_init, false);
	}
	
	/* for Internet Explorer */
	/*@cc_on @*/
	/*@if (@_win32)
		document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
			if (this.readyState == "complete") {
				wl_init(); // call the onload handler
			}
		};
	/*@end @*/
	
	/* for Safari */
	if (/WebKit/i.test(navigator.userAgent)) { // sniff
		var _timer = setInterval(function() {
			if (/loaded|complete/.test(document.readyState)) {
				wl_init(); // call the onload handler
			}
		}, 10);
	}
	
	/* for other browsers */
	window.onload = wl_init;

    window[/*@cc_on !@*/0?'attachEvent':'addEventListener'](/*@cc_on 'on'+@*/'load',function(){

        if(/WebKit/i.test(navigator.userAgent)){
            //loadDynamic("path_to.css",1);
			
        }
        combinedWindowOnload();
    },false)
})()

function wl_init() {
		// quit if this function has already been called
		if (arguments.callee.done) {
			return;
		}		
		// flag this function so we don't do the same thing twice
		arguments.callee.done = true;
}
	
function set_counters(counters_holder_id){
	
	counters_holder = document.getElementById(counters_holder_id);
	
/* Рейтинг@Mail.ru */	
	var topmail_a = document.createElement('a');
		topmail_a.href 		= 'http://top.mail.ru/jump?from=266770';
		topmail_a.title 	= 'Рейтинг@Mail.ru';
		topmail_a.style.visibility 	= 'hidden';

	
	var topmail_img = document.createElement('img');
		topmail_img.src 		= 'http://d2.c1.b4.a0.top.mail.ru/counter?id=266770;t=210';
		topmail_img.alt 		= 'Рейтинг@Mail.ru';
		topmail_img.width 		= '0';
		topmail_img.height 	= '0';


	topmail_a.appendChild(topmail_img);	
	counters_holder.appendChild(topmail_a);
}
