var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-23144908-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);
  })();
  
$().ready(function() {
	$("#model").autocomplete("/moduls/ajax_form.php", {
		width: 120,
		max: 15,
		selectFirst: false
	});
});
function parseScript(_source)
    {
                    var source = _source;
                    var scripts = new Array();
     
                    // Strip out tags
                    while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
                            var s = source.indexOf("<script");
                            var s_e = source.indexOf(">", s);
                            var e = source.indexOf("</script", s);
                            var e_e = source.indexOf(">", e);
     
                            // Add to scripts array
                            scripts.push(source.substring(s_e+1, e));
                            // Strip from source
                            source = source.substring(0, s) + source.substring(e_e+1);
                    }
     
                    // Loop through every script collected and eval it
                    for(var i=0; i<scripts.length; i++) {
                            try {
                                    eval(scripts[i]);
                            }
                            catch(ex) {
                                    // do what you want here when a script fails
                            }
                    }
                    // Return the cleaned source
                    return source;
    }
$(document).ready(function() {
    $('a.tTip').tinyTips('light', 'title');
    $('a.imgTip').tinyTips('yellow', '<img src="images/demo-image.jpg" /><br />Вы можете размещать изображения или любой другой контент в подсказках.');
    $('img.tTip').tinyTips('green', 'title');
    $('img.ttTip').tinyTips('grayy', 'title');
    $('img.Tip_chat').tinyTips('chat', 'title');
    $('h1.tagline').tinyTips('blue', 'tinyTips - отличный инструмент!');
});

  
		function show_new(link) {
  
        var cont = document.getElementById('body_content_new');  
        var loading_new_content = document.getElementById('loading_new_content');  
  
        cont.innerHTML = loading_new_content.innerHTML;  
  
        var http = createRequestObject();  
        if( http )   
        {  
            http.open('get', link);  
            http.onreadystatechange = function ()   
            {  
                if(http.readyState == 4)   
                {  
                    cont.innerHTML = http.responseText;  
                }  
            }  
            http.send(null);      
        }  
        else   
        {  
            document.location = link;  
        }  
    }

	function showContent_2(link) {
  
        var cont = document.getElementById('contentBody_2');  
        var loading_2 = document.getElementById('loading_2');  
  
        cont.innerHTML = loading_2.innerHTML;  
  
        var http = createRequestObject();  
        if( http )   
        {  
            http.open('get', link);  
            http.onreadystatechange = function ()   
            {  
                if(http.readyState == 4)   
                {  
                    cont.innerHTML = http.responseText;
		    $('a.tTip').tinyTips('light', 'title');
    $('a.imgTip').tinyTips('yellow', '<img src="images/demo-image.jpg" /><br />Вы можете размещать изображения или любой другой контент в подсказках.');
    $('img.tTip').tinyTips('green', 'title');
    $('img.ttTip').tinyTips('grayy', 'title');
    $('img.Tip_chat').tinyTips('chat', 'title');
    $('h1.tagline').tinyTips('blue', 'tinyTips - отличный инструмент!');
                }  
            }  
            http.send(null);      
        }  
        else   
        {  
            document.location = link;  
        }  
    }
    function showContent(link) {
  
        var cont = document.getElementById('contentBody');  
        var loading = document.getElementById('loading');  
  
        cont.innerHTML = loading.innerHTML;  
  
        var http = createRequestObject();  
        if( http )   
        {  
            http.open('get', link);  
            http.onreadystatechange = function ()   
            {  
                if(http.readyState == 4)   
                {  
                    cont.innerHTML = http.responseText;  
                }  
            }  
            http.send(null);      
        }  
        else   
        {  
            document.location = link;  
        }  
    }
  
    // создание ajax объекта  
   /* function createRequestObject()   
    {  
        try { return new XMLHttpRequest() }  
        catch(e)   
        {  
            try { return new ActiveXObject('Msxml2.XMLHTTP') }  
            catch(e)   
            {  
                try { return new ActiveXObject('Microsoft.XMLHTTP') }  
                catch(e) { return null; }  
            }  
        }  
    }*/
function createRequestObject()   
    {  
        try { return new XMLHttpRequest() }  
        catch(e)   
        {  
            try { return new ActiveXObject('Msxml2.XMLHTTP') }  
            catch(e)   
            {  
                try { return new ActiveXObject('Microsoft.XMLHTTP') }  
                catch(e) { return null; }  
            }  
        }  
    }  


/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

$(document).ready(function(){
 
	
	 $("ul.topnav li a").mouseover(function() {
	 		
		$(this).parent().find("ul.subnav").fadeIn('slow').show(); 
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").fadeOut('slow'); 
		});
		});
		 	 $("ul.topnav li ul li a").mouseover(function() {
	 		
		$(this).parent().find("ul.subnav2").fadeIn('slow').show(); 
 
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav2").fadeOut('slow'); 
			
		});
 
		});
});
//<![CDATA[
function toggleClass(el,n) {
if ( n==1 )
	var togClass = "hover";
else
	var togClass = "normal";

el.className = togClass;
}
function setCookie (name, value, expires, path, domain, secure) {
	var	curCookie = name + "=" + escape(value) +
		((expires) ? ";expires=" + expires : "") +
     		((path) ? ";path=" + path : "") +
      		((domain) ? ";domain=" + domain : "") +
      		((secure) ? ";secure" : "");
	if ((escape(value)).length <= 4000) document.cookie = curCookie+";";
}

function getCookie (name) {
	var prefix = name + "=";
  	var cookieStartIndex = document.cookie.indexOf(prefix);
  		if (cookieStartIndex == -1) 
  		return null;
  	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
  	if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
  	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}
function rememberme(value) {
	var expire_date = new Date();
	expire_date.setTime(expire_date.getTime() +2592000000)
	var exp = expire_date.toGMTString()
	setCookie ('RMM', value, exp); 	
}
function refill() {
	
	var c = getCookie('RMM');
	if (document.getElementById('key').value== '' && c != '' && c != null){
		document.getElementById('key').value=c;
	}
}
function rotation ()
{
  rotation_start();
}
function rotation_start(){
  
  go_next();
}

$(function () {
    $('.bubbleInfo').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 500;
 
        var hideDelayTimer = null;
 
        var beingShown = false;
        var shown = false;
        var trigger = $('.trigger', this);
        var info = $('.popup', this).css('opacity', 0);
 
 
        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;
 
                info.css({
                    top: -70,
                    left: -133,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }
 
            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });
 
            }, hideDelay);
 
            return false;
        });
    });
});
