var hovertipMouseX;
var hovertipMouseY;
function hovertipMouseUpdate(e) {
var mouse = hovertipMouseXY(e);
hovertipMouseX = mouse[0];
hovertipMouseY = mouse[1];
}
function hovertipMouseXY(e) {
if( !e ) {
if( window.event ) {
e = window.event;
} else {
return;
}
}
if( typeof( e.pageX ) == 'number' ) {
var xcoord = e.pageX;
var ycoord = e.pageY;
} else if( typeof( e.clientX ) == 'number' ) {
var xcoord = e.clientX;
var ycoord = e.clientY;
var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
( navigator.vendor == 'KDE' );
if( !badOldBrowser ) {
if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
xcoord += document.body.scrollLeft;
ycoord += document.body.scrollTop;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
xcoord += document.documentElement.scrollLeft;
ycoord += document.documentElement.scrollTop;
}
}
} else {
return;
}
return [xcoord, ycoord];
}
targetSelectById = function(el, config) {
var id;
var selector;
if (id = el.getAttribute('id')) {
selector = '*[@'+config.attribute+'=\''+id+'\']';
return jQuery(selector);
}
};
targetSelectByTargetAttribute = function(el, config) {
target_list = el.getAttribute('target');
if (target_list) {
target_ids = target_list.split(' ');
var selector = '#' + target_ids.join(',#');
return jQuery(selector);
}
};
targetSelectByPrevious = function(el, config) {
return jQuery(el.previousSibling);
}
targetSelectBySiblings = function(el, config) {
return jQuery(el).siblings();
}
clicktipPrepareWithCloseLink = function(o, config) {
return o.append("<a class='clicktip_close' title='Закрыть'>×</a>")
.find('a.clicktip_close').click(function(e) {
o.hide();
return false;
}).end(); 
};
hovertipPrepare = function(o, config) {
return o.hover(function() {
hovertipHideCancel(this);
}, function() {
hovertipHideLater(this);
}).css('position', 'absolute').each(hovertipPosition);
};
hovertipPrepareNoOp = function(o, config) {
return o;
}
hovertipPosition = function(i) {
document.body.appendChild(this);
}
hovertipIsVisible = function(el) {
return (jQuery.css(el, 'display') != 'none');
}
hovertipShowUnderMouse = function(el) {
hovertipHideCancel(el);
if (!hovertipIsVisible(el)) {
el.ht.showing = 
window.setTimeout(function() {
el.ht.tip.css({
'position':'absolute',
'top': hovertipMouseY + 'px',
'left': hovertipMouseX + 'px'})
.show();
}, el.ht.config.showDelay);
}
};
hovertipHideCancel = function(el) {
if (el.ht.hiding) {
window.clearTimeout(el.ht.hiding);
el.ht.hiding = null;
}  
};
hovertipHideLater = function(el) {
if (el.ht.showing) {
window.clearTimeout(el.ht.showing);
el.ht.showing = null;
}
if (el.ht.hiding) {
window.clearTimeout(el.ht.hiding);
el.ht.hiding = null;
}
el.ht.hiding = 
window.setTimeout(function() {
if (el.ht.hiding) {
el.ht.tip.hide();
}
}, el.ht.config.hideDelay);
};
clicktipTargetPrepare = function(o, el, config) {
return o.addClass(config.attribute + '_target')
.click(function() {
el.ht.tip.toggle();
return false;
});
};
hovertipTargetPrepare = function(o, el, config) {
return o.addClass(config.attribute + '_target')
.hover(function() {
hovertipShowUnderMouse(el);
},
function() {
hovertipHideLater(el);
});
};
jQuery.fn.hovertipActivate = function(config, targetSelect, tipPrepare, targetPrepare) {
return this.css('display', 'block')
.hide() 
.each(function() {
if (!this.ht)
this.ht = new Object();
this.ht.config = config;
var targets = targetSelect(this, config);
if (targets && targets.size()) {
if (!this.ht.targets)
this.ht.targets = targetPrepare(targets, this, config);
else
this.ht.targets.add(targetPrepare(targets, this, config));
targets.mousemove(hovertipMouseUpdate);
if (!this.ht.tip)
this.ht.tip = tipPrepare(jQuery(this), config);
}
})
;
};
function hovertipInit() {
var clicktipConfig = {'attribute':'clicktip'};
window.setTimeout(function() {
jQuery('.clicktip').hovertipActivate(clicktipConfig,
targetSelectById,
clicktipPrepareWithCloseLink,
clicktipTargetPrepare);
}, 0);
window.setTimeout(function() {
jQuery('.clicktip').hovertipActivate(clicktipConfig,
targetSelectByTargetAttribute,
clicktipPrepareWithCloseLink,
clicktipTargetPrepare);
}, 0);
var hovertipConfig = {'attribute':'hovertip',
'showDelay': 300,
'hideDelay': 700};
var hovertipSelect = 'div.hovertip';
jQuery(hovertipSelect).css('display', 'block').addClass('hovertip_wrap3').
wrap("<div class='hovertip_wrap0'><div class='hovertip_wrap1'><div class='hovertip_wrap2'>" + 
"</div></div></div>").each(function() {
var tooltip = this.parentNode.parentNode.parentNode;
if (this.getAttribute('target'))
tooltip.setAttribute('target', this.getAttribute('target'));
if (this.getAttribute('id')) {
var id = this.getAttribute('id');
this.removeAttribute('id');
tooltip.setAttribute('id', id);
}
});
hovertipSelect = 'div.hovertip_wrap0';
window.setTimeout(function() {
jQuery(hovertipSelect).hovertipActivate(hovertipConfig,
targetSelectById,
hovertipPrepare,
hovertipTargetPrepare);
}, 0);
window.setTimeout(function() {
jQuery(hovertipSelect).hovertipActivate(hovertipConfig,
targetSelectByTargetAttribute,
hovertipPrepare,
hovertipTargetPrepare);
}, 0);
var hovertipSpanSelect = 'span.hovertip';
jQuery(hovertipSpanSelect).css('display', 'block').addClass('hovertip_wrap3').
wrap("<span class='hovertip_wrap0'><span class='hovertip_wrap1'><span class='hovertip_wrap2'>" + 
"</span></span></span>").each(function() {
var tooltip = this.parentNode.parentNode.parentNode;
if (this.getAttribute('target'))
tooltip.setAttribute('target', this.getAttribute('target'));
if (this.getAttribute('id')) {
var id = this.getAttribute('id');
this.removeAttribute('id');
tooltip.setAttribute('id', id);
}
});
hovertipSpanSelect = 'span.hovertip_wrap0';
window.setTimeout(function() {
jQuery(hovertipSpanSelect)
.hovertipActivate(hovertipConfig,
targetSelectByPrevious,
hovertipPrepare,
hovertipTargetPrepare);
}, 0);
}
// INITIALIZE TOOLTIPS IN A SEPERATE THREAD
    jQuery(document).ready(function() {
      window.setTimeout(hovertipInit, 1);
    });
//ODD and OVER TABLE TRS
$(function(){
$("table tr:nth-child(even)").addClass("odd");
});
$(document).ready(
  function()
  {
  	$("tr").mouseover(function() {
  		$(this).addClass("over");
  	});
  
  	$("tr").mouseout(function() {
  		$(this).removeClass("over");
  	});
  	  }
);
//Fading in/out
$(function(){
$('#fdng').hide();
$('#readmore').toggle(function() {
$('#fdng').fadeIn('slow');
	},
	function() {
		$('#fdng').fadeOut('slow');
	}
	)
});
//Inserts    
$(document).ready(function(){
$('#m28').load('/templates/a/js/index.html');
$('#menu-228').load('/templates/a/js/index.html');
$('#mailru').load('/templates/a/js/mailru.html');
//Links
$("a[href$=pdf]").addClass("pdf");
$("a[href$=doc]").addClass("msw");
$("a[href$=xls]").addClass("excel");
});
