// JavaScript Document
var fnStock = function(){
	var stock = hq_str_sh600770.split(",");
	var _$ = function(o){return document.getElementById(o);}
	var formatFloat = function(src, pos){ 
		return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos); 
	} 
	var extent = formatFloat((stock[3]-stock[2]),2);
	var extentPer = formatFloat(((stock[3]-stock[2])/stock[2])*100,2)+"%";
	_$("stock_h").innerHTML = stock[0]+"(600770.SH)";
	_$("stock_price").innerHTML = stock[3];
	_$("stock_date").innerHTML = stock[30]+"&nbsp;"+stock[31];
	_$("stock_today").innerHTML = stock[1];
	_$("stock_yesterday").innerHTML = stock[2];
	_$("stock_turnover").innerHTML = formatFloat(stock[8]/10000,2) + " 万股";
	_$("stock_amount").innerHTML = formatFloat(stock[9]/10000,2) + " 万元";
	_$("stock_crest").innerHTML = stock[4];
	_$("stock_trough").innerHTML = stock[5];
	if(extent<0){
		//alert("green")
		_$("stock_extent").innerHTML = extent+"("+extentPer+")";
		_$("stock_extent").setAttribute("class","green");
		_$("stock_extent").setAttribute("className","green");
	}
	if(extent==0){
		//alert("null")
		_$("stock_extent").innerHTML = extent+"("+extentPer+")";
		_$("stock_extent").removeAttribute("class");
		_$("stock_extent").removeAttribute("className");
	}if(extent>0){
		//alert("red")
		_$("stock_extent").innerHTML = "+"+extent+"(+"+extentPer+")";
		_$("stock_extent").setAttribute("class","red");
		_$("stock_extent").setAttribute("className","red");
	}
}

var imgTab1 = function(){
	$("#tabbox .tab_1").hover(function(){
		var n = $("#tabbox .tab_1").index($(this));
		$(this).animate({"margin-top":"0","height":"120px"},300)
		$(this).find(".c0 a").animate({"font-size":"30"},300)
		$(this).find(".c1").slideDown(300)
		
		$("#img dd").eq(n).delay(200).fadeIn(300).siblings("dd").fadeOut(300);
	},function(){
		$(this).animate({"margin-top":"60px","height":"60px"},300)
		$(this).find(".c0 a").animate({"font-size":"18"},300)
		$(this).find(".c1").slideUp(300)
		$("#img dd").fadeOut(300);
	})
}


var imgTab = function(){
	$("#tabbox .tab_1").hover(function(){
		var n = $("#tabbox .tab_1").index($(this));
		$(this).animate({"margin-top":"0","height":"120px"},300)
		$(this).find("div:eq(0)").fadeOut(50);
		$(this).find("div:eq(1)").hide();		
		$(this).find("div:eq(1)").animate({"top":"0"},100)
		$(this).find("div:eq(1)").fadeIn(300);

		
		$("#img dd").eq(n).delay(200).fadeIn(300).siblings("dd").fadeOut(300);
	},function(){
		$(this).animate({"margin-top":"60px","height":"60px"},300)
		
		$(this).find("div:eq(1)").fadeOut(100);
		$(this).find("div:eq(1)").animate({"top":"60"},50,function(){
			$(this).siblings("div").fadeIn(100);
		})
		
		$("#img dd").fadeOut(300);
	})
}

var menu = function(){
	$("#menu dd").mouseover(function(){
		//$(this).find("div").show();
		if($(this).find("span")){
			$(this).find("span").show();
		}
	})
	$("#menu dd").mouseout(function(){
		//$(this).find("div").hide();
		if($(this).find("span")){
			$(this).find("span").hide();
		}
	})
}
var friendLink=function(o,p){
	var a=0,Go,Stop,tag = $(o),b,c;
		//b=tag.find(p).width();
	var auto = function(){
		//alert(b)
		b=tag.find(p).width();
		c=tag.scrollLeft()
		Go = setTimeout(auto,20);
		if(c<b){
			tag.scrollLeft(a);
			a+=1;
		}else{
			a=0;
			tag.scrollLeft(a);
		}
		Go();
	}
	tag.find("a").hover(function(){
		clearTimeout(Go);
	},function(){
		auto();
	})
	auto();
}



var cover = function(){
	var url=document.location.href;
	var url_1 = url.split("?");
	if(url_1[1]){
		var arg = url_1[1].split("=");
		//alert(arg[1])
		if(arg[0]=="pw" && arg[1]=="zongyi"){
			//alert(1)
			$("#cover").show();
			$("html").keydown(function(event){
				//$("#a").html("key:"+event.which);
				if(event.which==13){
					$(".cover1").fadeIn(300,function(){
						$(".cover0").hide();
					}).delay(18000).animate({"top":"-1000px"},8000,function(){$("#cover").remove()});
					$("#flashbox").delay(15000).show(300,function(){
						$(this).delay(15000).fadeOut(3000,function(){$("#flashbox").remove();})
					})
				}
			});
		}
	}else{
		/*$("#cover").show();
		$(".cover0").hide();
		$(".cover1").fadeIn().delay(3000).animate({"top":"-1000px"},1000,function(){$("#cover").remove()});
		$("#flashbox").remove();*/
		$("#cover").remove();
		$("#flashbox").remove();
	}
}
