(function(w) {
    var counterId = 234954;

    window.onerror = function() {
        errors.push(arguments);
        errorCallback();
    };
    
    var errors = [],
        maxError = 10,
        href = w.location.href,
        ua = w.navigator.userAgent.toLowerCase(),
        rwebkit = /(webkit)[ \/]([\w.]+)/,
//            ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
        rmsie = /(msie) ([\w.]+)/,
        rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
        match = rwebkit.exec(ua) ||
//                ropera.exec(ua) ||
            rmsie.exec(ua) ||
            ua.indexOf("compatible") < 0 && rmozilla.exec(ua) || [],
        browser = match[1],
		version = (match[2] || '0');
        
    function errorCallback() {
        var yaCounter = w['yaCounter' + counterId];
        if (yaCounter && maxError) {
            var i = errors.length;
            while (i--) {                
                yaCounter.params('newJsErrors', href, browser, version, description(errors[i]));
                maxError--;
            }
            
            errors = [];
        }
    }

    function description(args) {
        return 'message: ' + args[0]
                + ', line: ' + args[2]
                + ', url: ' + args[1];
    }
    
    if (w.addEventListener) {
        w.addEventListener('load', errorCallback, false);
    }
    else if (w.attachEvent) {
        w.attachEvent('onload', errorCallback);
    }
})(window);
(function(w, d) {
    w.yandex_metrika_callbacks = w.yandex_metrika_callbacks || [];
     w.yandex_metrika_callbacks.push( function() {
        try {
            var ya_params = {},
				ua = navigator.userAgent.toLowerCase();
			if (ua.search(/(msie) ([\w.]+)/) !== -1) {
				ya_params = {'bits OS': window.navigator.userAgent.search(/(wow64)|(win64)|(x86_64)|(ia64)/i) === -1 ? '32' : '64'};
			}
			
			var toolbar = 'no';
			if (ua.search(/gtb/) !== -1) {
				toolbar = 'Google toolbar';
			}
			
			if (ua.search(/yb/) !== -1) {
				toolbar = 'Yandex toolbar';
			}
			
			if (ua.search(/mra/) !== -1) {
				toolbar = 'Mail.ru agent';
			}
			
			if (ua.search(/sputnik/) !== -1) {
				toolbar = 'Mail.ru toolbar';
			}
			ya_params.toolbar = toolbar;
			ya_params.toolbarAll = true;

            //w.yaCounter1 = new Ya.Metrika({id: 1});
            w.yaCounter234954 = new Ya.Metrika({id: 234954, enableAll: true, params: ya_params, webvisor: true});
        }
        catch(e){}
    });

    var s = d.createElement('script'),
        r = d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0];
    s.type = 'text/javascript';
    s.async = s.defer = true;
    s.src = (d.location.protocol == 'https:' ? 'https:' : 'http:') + '//mc.yandex.ru/metrika/watch.js';
    //s.src = '/js/_metrika.js?v=7';
    r.insertBefore(s, r.firstChild);
	
	if (window.jQuery) {
		jQuery(document).ready(function() {
			var el = document.getElementById('search-at-site_find');
			if (el) {
				el.onclick = function() {
					var v = document.getElementById('search-at-site_value')
					var p = {
						search_at_site: v ? v.value : ''
					};
					
					window.yaCounter234954 && yaCounter234954.params(p);
				}
			}
		});
	}
    
})(this, document);

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5259381-1']);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


(function() {

    if (window.addEventListener) {
        window.addEventListener('load', trackPrint, false);
    }
    else if (window.attachEvent) {
        window.attachEvent('onload', trackPrint);
    }
    
    function trackPrint() {
        var counterId = 893184,
            divId = 'ym-track-print' + counterId,
            div = document.createElement('div'),
            style = document.createElement('style'),
            body = document.getElementsByTagName('body')[0];

            style.media = 'print';
            style.type = 'text/css';
            var text = '#' + divId + '{display:block !important;background:url(//mc.yandex.ru/watch/' + counterId + '/) transparent center center no-repeat !important;left:50% !important;top:50% !important;width:10px !important;height:10px !important;z-index:9999 !important}';
            
            if (style.styleSheet) { // IE
                style.styleSheet.cssText = text;
            } else if (/AppleWebKit\//.exec(navigator.userAgent)) {
                style.innerText = text;
            }
            else {
                style.innerHTML = text;
            }
            
            body.appendChild(style);
             
            div.id = divId;
            div.setAttribute('style', 'position:absolute;left:-9999px;display:none');

            body.appendChild(div);
         //}
         //catch(e) {
         //}
    }
})();

