function fix(id,min,max){
	if(document.getElementById("fake")&&document.getElementById(id)){
		if(window.navigator.userAgent.indexOf("MSIE")<0)return;
			var ss=document.getElementById("fake").offsetWidth;
			document.getElementById(id).style.width=((ss>min)?((ss<max)?"100%":max+"px"):min+"px");
		}
}

function fixPage(id,footer,min,max){
	if(document.getElementById("fake")&&document.getElementById(id)){
		if(window.navigator.userAgent.indexOf("MSIE")<0)return;
			var ss=document.getElementById("fake").offsetWidth;
			document.getElementById(id).style.width=((ss>min)?((ss<max)?"100%":max+"px"):min+"px");
			document.getElementById(footer).style.width=((ss>min)?((ss<max)?"100%":max+"px"):min+"px");
		}
}

function mshover() { 
	if (document.all&&document.getElementById("nav")){
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) { 
			node = navRoot.childNodes[i];
			//alert(node.nodeName);
			if (node.nodeName=="TD") {
				node.onmouseover=function() {
					this.className+=" over"; 
				}	
				node.onmouseout=function() { 
					this.className=this.className.replace
					(" over", ""); 
				}		
			} 
		}
	}
}


var currentElement = 'null';
function bigHaha(link){
	ActiveElement = document.getElementById("active");
	overElement = document.getElementById(link);
	boxWidth = parseInt(overElement.firstChild.offsetWidth);
	if(currentElement != link && currentElement != 'null'){
		document.getElementById(currentElement).style.background = 'none';
	}
	ActiveElement.style.background = 'none';
	
	if(boxWidth < 85){
		overElement.style.background = 'transparent url(/img/right_link_ani.gif?' + Math.random() + ') no-repeat scroll 3px 0';
	}
	else if(boxWidth < 110){
		overElement.style.background = 'transparent url(/img/right_link_update_small.gif?' + Math.random() + ') no-repeat scroll 3px 0';
	}
	else{
		overElement.style.background = 'transparent url(/img/right_link_update_ani.gif?' + Math.random() + ') no-repeat scroll 3px 0';	
	}
	currentElement = link;	
}

function actual(){
	if(document.getElementById("subnavigation") && document.getElementById("active")){
		navList = document.getElementById("subnavigation");
		curElem = document.getElementById("active");
		boxWidth = parseInt(curElem.firstChild.offsetWidth);
		if(boxWidth < 85){
			curElem.style.background = 'transparent url(/img/right_link_ani.gif?' + Math.random() + ') no-repeat scroll 3px 0';
		}
		else if(boxWidth < 110){
			curElem.style.background = 'transparent url(/img/right_link_update_small.gif?' + Math.random() + ') no-repeat scroll 3px 0';
		}
		else{
			curElem.style.background = 'transparent url(/img/right_link_update_ani.gif?' + Math.random() + ') no-repeat scroll 3px 0';	
		}
		for (i=0; i<navList.childNodes.length; i++){
			nodeList = navList.childNodes[i];
			for (a=0; a<nodeList.childNodes.length; a++){
				palm = 	nodeList.childNodes[a];
				if(palm.nodeName=="A"){
					palm.style.background = 'none';
				}	
				$(".big_menu_school  li span a").css("background", "none");
			}
		}
	}
}

function secondLeve(){
	navList = document.getElementById("subnavigation");
	curElem = document.getElementById("active");
	boxWidth = parseInt(curElem.firstChild.offsetWidth);
		if(boxWidth < 85){
			curElem.style.background = 'transparent url(/img/right_link_anist.gif) no-repeat scroll 3px 0px';
		}
		else if(boxWidth < 110){
			curElem.style.background = 'transparent url(/img/right_link_update_smallst.gif) no-repeat scroll 3px 0px';
		}
		else{
			curElem.style.background = 'transparent url(/img/right_link_update_anist.gif) no-repeat scroll 3px 0px';	
		}
}

function SubMenuHover(){
	if(document.getElementById("subnavigationOld")){
		navList = document.getElementById("subnavigationOld");
		ActiveElement = document.getElementById("active");
		for (i=0; i<navList.childNodes.length; i++){
			nodeList = navList.childNodes[i];
			for (a=0; a<nodeList.childNodes.length; a++){
				palm = 	nodeList.childNodes[a];
				palm.style.background = 'none';
				if(palm.nodeName=="A"){
					palm.onmouseover=function(){
						
						ActiveElement.style.background = 'none';	
						this.style.background = 'transparent url(/img/right_link_ani.gif?' + Math.random() + ') no-repeat scroll 0pt';			
					}
					palm.onmouseout=function(){
						if(navList.className == 'big_menu'){
							ActiveElement.style.background = 'transparent url(/img/right_link_update.gif) no-repeat scroll 0pt';	
						}
						else{
				
							ActiveElement.style.background = 'transparent url(/img/right_link_ani.gif?' + Math.random() + ') no-repeat scroll 0pt';
						}				
					}
				}
			}
		}
	}
} 

function lightItem(item){
	picture = document.getElementById(item);
	if(item == 'pic0'){
		if(picture.src.indexOf("over") < 1){
			picture.src = "/img/nav_about_over.gif";
	}	else{
			picture.src = "/img/nav_about.gif";
		}
	}
	else if(item == 'pic1'){
		if(picture.src.indexOf("over") < 1){
			picture.src = "/img/nav_fond_over.gif";
		}	else{
		picture.src = "/img/nav_fond.gif";
		}
	}
	else if(item == 'pic2'){
		if(picture.src.indexOf("over") < 1){
			picture.src = "/img/nav_school_over.gif";
		}	else{
			picture.src = "/img/nav_school.gif";
		}
	}
}

function fixWidth(id,min){
	//alert(window.navigator.userAgent);
	if(window.navigator.userAgent.indexOf("MSIE")<0)return;
	document.getElementById(id).style.width=((window.innerWidth||document.body.clientWidth)>min)?"100%":min+"px";
}

function menuFix(){
	if(document.getElementById('table_sdk')){
		var itemWidth = parseInt(document.getElementById('table_sdk').offsetWidth);
		document.getElementById('ittab0').style.width = itemWidth + "px";
		document.getElementById('ittab1').style.width = itemWidth + "px";
//		document.getElementById('ittab2').style.width = itemWidth + "px";
	}
}

function showVacance(link,id){
	if(document.getElementById(id).style.display != "block"){
		document.getElementById(id).style.display = "block";
		document.getElementById(link).style.backgroundPosition = "0 -26px";	
	}
	else{
		document.getElementById(id).style.display = "none";	
		document.getElementById(link).style.backgroundPosition = "0 0";
	}
		//
}

$(document).ready(function(){
	jQuery.each(jQuery.browser, function(i) {
    	if($.browser.msie){
    		//$("div.subMenu a:first-child")
			//	.css("background", "none");
			$(".borderTop dl dt:first-child")
				.css({ color:"#A02626", fontSize:"24px", paddingBottom:"10px" });
		}
    });
});


//Сначала был init...
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if (_timer) {
		clearInterval(_timer);
		_timer = null;
	}
	// insert
	fix('root',1004,1162);
	fixPage('share','footer',1004,1280);
	mshover();
	menuFix();
	actual();
	// end
};
/* for Mozilla */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init(); // call the onload handler
		}
	}, 50);
}


/* for other browsers */
window.onload = init;
