$(document).ready(function(){
	var subHeight = $('.subContent .right').height();
	if(subHeight > 500){
		$('.subContent .left').height(subHeight-25)
	}else{
		$('.subContent .left').height(500)
	}
	
	$('#da').click(function(){ $('.text').css({ fontSize: "16px",  lineHeight: "24px" });  return false;});
	$('#zhong').click(function(){ $('.text').css({ fontSize: "14px", lineHeight: "22px" });  return false;});
	$('#xiao').click(function(){ 
	    $('.text').css("fontSize","12px"); 
	    return false;
	});
	
	$('.jobTableList tr:odd').addClass('specalt');
	$('.jobTableList tr:even').addClass('spec');
	
	
	var labelText = $(".search label").remove().text();
	$('.search input.text').val(labelText)
	.focus(function(){
		if (this.value == labelText){
			$(this).val("");
		};		
	}).blur(function(){
		if (this.value == ""){
			$(this).val(labelText)
		};
	});
	$('.newsBox ol li:odd').addClass('odd');
	
	$('.govLink').each(function () {
		var distance = $(this).find('li').length*22+5
		var time = 300;
		var hideDelay = 500;
		var hideDelayTimer = null;
		var beingShown = false;
		var shown = false;
		var trigger = $('h2', this);
		var info = $('.linkBox', this);
		
		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;
				info.css({
					height:0,
					marginTop:0,
					display: 'block'
				}).animate({
					marginTop:-distance/1.4,
					height: '+=' + 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({
					marginTop:-10,
					height: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});
				
			}, hideDelay);
			
			return false;
		});
	});
	$('.dian').each(function () {
		var distance = -10
		var time = 200;
		var hideDelay = 100;
		var hideDelayTimer = null;
		var beingShown = false;
		var shown = false;
		var trigger = $('.em', this);
		var info = $('.pop', this);
		
		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;
				info.css({
					marginTop:-25,
					display: 'block'
				}).animate({
					marginTop: '+=' + 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({
					marginTop:-25,
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});
				
			}, hideDelay);
			
			return false;
		});
	});
	
});


function MoveOnMenu(){
	var url = document.URL;
	var nav = document.getElementById("nav");
	var childIndex=0;
	if(nav!=null && url.indexOf("bottle")==-1){
		//if(url.indexOf("")>-1) childIndex=0;
		if(url.indexOf("about")>-1) childIndex=1;
		if(url.indexOf("news")>-1) childIndex=2;
		if(url.indexOf("investor")>-1) childIndex=3;
		if(url.indexOf("service")>-1) childIndex=4;
		if(url.indexOf("job")>-1) childIndex=5;
		var nodes = nav.childNodes;
		var moveOn = nodes[childIndex].childNodes[0];
		moveOn.className = "hover";
	}
}

window.onload = MoveOnMenu;

function Search(siteUrl){
    if(document.all('keyword').value!='' && document.all('keyword').value!='Search...')
    {
        aspnetForm.action = siteUrl + "/search/";
        return true;
    }
    else{return false;}
}

//colName 图片name属性值
//maxW    不超过此宽度
//maxH    不超过此高度
function AdjustPhoto(colName,maxW,maxH)
{
	var width,height;
	if(colName==""){
	    var objPhoto = document.getElementsByTagName("IMG");
	}
	else{
	    var objPhoto = document.getElementsByName(colName);
    }
    
	if(objPhoto!=null){
		for(var i=0;i<objPhoto.length;i++){
			width = objPhoto[i].width;
			height = objPhoto[i].height;
			//alert(objPhoto[i].style.width);
			if(width>maxW && height>maxH){
				var k=1;
				for(var n=0;n<100;n++){
					k=k+0.05;
					width = width / k;
					height = height / k;
					//document.writeln("width:" + width + "height:" + height);
					if(width<maxW) break;
				}
				objPhoto[i].width = width;
				objPhoto[i].height = height;
			}
		}
	}
}

AdjustPhoto("",600,400);