$(function () {
	$(window).bind("resize", function(){dement();});
	dement();
	if ($('.menu').length) {
		$('.menu a').hover(
			function(){
				jMenu($(this).attr('id').split('m_')[1]);
			},
			function(){
				jMenuClose($(this).attr('id').split('m_')[1]);
			}
		);
		menubg();
		$(window).bind("resize", function() {menubg();});
	}
	if ($('.inner_menu').length) {
		$('.inner_menu > li:not(.mbg)').each(function(){
			var hght = $(this).height();
			$('.bg', this).css('height',hght);
			if ($.browser.msie && $.browser.version == 6) {		
				$('.bg', this).css('top','-' + (hght - 15));
				$(this).css('height',hght);
			}			
		});
	}
	if ($('.index').length) {
		var sw = $(window).width();
		var wd = null;
		if(sw <= 1024) {
			wd = 1;			
		} else if((sw > 1024)&&(sw <= 1280)) {
			wd = 2;			
		} else if((sw > 1280)&&(sw <= 1440)) {
			wd = 3;			
		} else if((sw > 1440)&&(sw <= 1680)) {
			wd = 4;			
		} else if((sw > 1680)&&(sw <= 1920)) {
			wd = 5;			
		} else {
			wd = 6;			
		}
		$('body').css('background', 'url(/web/themes/default/img/bg/bg' + wd +'.jpg) no-repeat center top');
	}
	
	if ($('#err404').length) {
		var sw = $(window).width();
		
		var wd = null;
		if(sw <= 1024) {
			wd = 1;			
		} else if((sw > 1024)&&(sw <= 1280)) {
			wd = 2;			
		} else if((sw > 1280)&&(sw <= 1440)) {
			wd = 3;			
		} else if((sw > 1440)&&(sw <= 1680)) {
			wd = 4;			
		} else if((sw > 1680)&&(sw <= 1920)) {
			wd = 5;			
		} else {
			wd = 6;			
		}
		$('#err404').css('background', 'url(/web/themes/default/img/bg/bg404_' + wd +'.jpg) no-repeat center top');		

	}
});
function dement() {
	if ($('#left').length) {
		var h = $('#left .header').height() + $('#left .inner_menu').height();
		if(($('#container').height() - h) < 162) {
			$('.the_content').css('height', h);
		}
	}
};
function menubg() {
	if ($('.menu2_text').length) {
		var wdth = $('#wrapper').width() - 298;
		$('.index_menu2').css('width', wdth);
		
		$('.index_menu2').each(function(){
			var hght = $('.menu2_text',this).height();
			
			if ($.browser.msie && $.browser.version == 7) {		
			   $('.menu2_bg', this).css('height',hght);
			   $('.menu2_bg', this).css('background','transparent url(/web/themes/default/img/bg_60.png) repeat 0 0');
			} else {
				$('.menu2_bg', this).css('height',hght);
			}
		});

	}	
}

function jMenu(id){
     if(typeof idClose != 'undefined' && idClose==id){
          clearTimeout(tempTim);
     }
     if($('#m_ul_'+id).css('visibility')!='visible'){
        $('#m_'+id).addClass('cur');
		$('#m_ul_'+id).css('visibility','visible');
		$('#m_ul_'+id).css('z-index','10');
		idOpen=id;
     }
     return false;
}

function jMenu2(id){
     if($('#m_ul_'+id).css('visibility')=='visible'){
          $('#m_ul_'+id).css('visibility','hidden');
		  $('#m_ul_'+id).css('z-index','1');
          $('#m_'+id).removeClass('cur');
     }
     return false;
}

function jMenuClose(id){
     tempTim=setTimeout('jMenu2('+id+')', 120);
     idClose=id;
}



// =fixing png for IE. now you should only add class "png" to show the transparent *.png image in IE6
function PNG(element){
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
	var src;
	if (element.tagName=='IMG'){
			if (/\.png$/.test(element.src)){
				src = element.src;
				element.src = "/web/themes/default/img/t.gif"; // = 1*1px  transparent image and path for it
			}
		}
		else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if(src){
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
	if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}