cm=null;
hide_delay=250;
tstat=0;

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;


function switchDiv(objElement,bolVisible){
if(isNS4||isIE4){
     if(!bolVisible) {
       objElement.visibility ="hidden"
     } else {
       objElement.visibility ="visible"
     }
 } else if (isIE5 || isNS6) {
      if(!bolVisible){
         objElement.style.display = "none";

      } else {
        objElement.style.display = "";

        }

      }

return 1;
}


function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos

}



function getelementbyid(myid) {
   if (isNS4){
        objElement = document.layers[myid];
     }else if (isIE4) {
        objElement = document.all[myid];
     }else if (isIE5 || isNS6) {
             objElement = document.getElementById(myid);
     }
return(objElement);
}

function show(el,m) {

 if (cm!=null) {
 switchDiv(cm,false);
 }

 if (m!=null) {
 m=getelementbyid(m);
 m.style.left = 0+getPos(el,"Left")+"px";
 m.style.top =  getPos(el,"Top")+el.offsetHeight+0+"px";
 switchDiv(m,true);
 cm=m;
 }

}


function hidemenu() {

timer1=setTimeout("show(null,null)",hide_delay);

tstat=1;

return 1;
}

function cancelhide() {
 if (tstat==1) {
 clearTimeout(timer1);
 tstat=0;
 }
return 1;
}


var width = 960;
var style = "margin:0 -5px 0 -4px;";
$(document).ready(function(){
	$('div.box').each(function(i){
		var title = this.getAttribute('title') || "";
		this.removeAttribute('title');
		this.innerHTML = '<table cellpadding="0" cellspacing="0" style="width:100%;">\n\
	<tr>\n\
		<td style="width:5px;"><img src="/images/box/box_tl.png" alt="" /></td>\n\
		<td style="background:url(/images/box/box_t.png);color:#004b94;text-transform:uppercase;font-weight:bold; padding-left:5px;">' + unescape(title) + '</td>\n\
		<td style="width:5px;"><img src="/images/box/box_tr.png" alt="" /></td>\n\
	</tr>\n\
	<tr>\n\
		<td style="border-left:1px solid #cfcfcf; font-size:1px; line-height:1px;">&nbsp;</td>\n\
		<td><div style="'+style+'text-align:left;">' + this.innerHTML + '</div></td>\n\
		<td style="border-right:1px solid #cfcfcf; font-size:1px; line-height:1px;">&nbsp;</td>\n\
	</tr>\n\
	<tr>\n\
		<td><img src="/images/box/box_bl.png" alt="" /></td>\n\
		<td style="border-bottom:1px solid #cfcfcf; font-size:1px; line-height:1px;">&nbsp;</td>\n\
		<td><img src="/images/box/box_br.png" alt="" /></td>\n\
	</tr>\n\
</table>';
	
	});
	if(navigator.userAgent.match(/Safari/i)){
		$('#bg_adjust').css('width', '51%');
	}
	$('ul.menu > li > a > img').each(function(i){
		$(this).hover(
			function(){
				this.src = this.src.replace('.png', '_g.png');
			},
			function(){
				this.src = this.src.replace('_g.png', '.png');
			}
		);
	});
			
});

$(document).ready(function(){
	if(document.attachEvent && navigator.userAgent.match(/MSIE/i)){ // IE Fix
		style += "padding:0 5px 0 4px;";
		$('ul.menu li > ul').each(function(i){
			var w = 0;
			$(this).find('li').each(function(){
				w = Math.max(w, $(this).innerWidth());
			});
			$(this).css('width', w+'px');
		});
		
		style += "padding:0 5px 0 4px;";
		$('ul.menu li > ul').each(function(i){
			var ul = $(this);
			$(this.parentNode).hover(
				 function(){
					 ul.css('top', 'auto');
				 },
				 function(){
					 ul.css('top', '-9999px');
				 }
			 );
		});
		$('#inner_body').css('margin-top', '-8px');
	}
	if(navigator.userAgent.match(/Chrome/i)){
		$('#inner_body').css('margin-top', '-8px');
	}
	if(window.opera){
		$('#inner_body').css('margin-top', '-8px');
	}
	if(navigator.userAgent.match(/Safari/i)){
		$('#inner_body').css('margin-top', '-8px');
	}
});



$(document).ready(function(){
	var max = 0;
	$('.match_height').each(function(i){
		var h = parseInt(this.clientHeight);
		if($(this).find('.news_item').length>0){
			h=0;
			$(this).find('.news_item').each(function(){
				h+=81;
			});
			h-=5
		}
		var t = 
		h
		- (parseInt(this.style.paddingTop.replace('px',''))||0)
		- (parseInt(this.style.paddingBottom.replace('px',''))||0);
													 
		max = Math.max(max, t);
	});
	$('.match_height').each(function(i){
		var top = this.style.paddingTop || '0px';
		var bottom = this.style.paddingBottom || '0px';
		top = top.replace('px','');
		bottom = bottom.replace('px','');
		try{
		this.style.height = (max - parseInt(top) - parseInt(bottom)) + 'px';
		}catch(e){}
	});
});



function onLoaded(){
	var n = 46;
	if(navigator.userAgent.match(/Safari/i)){
		n=50
	}
	if($('#container').innerHeight() < document.documentElement.clientHeight - n && document.documentElement.clientHeight >= document.documentElement.scrollHeight){
		$('#container').css('height', (document.documentElement.clientHeight - n) + 'px');
	}
};
