// JavaScript Document
function $(id){
	return document.getElementById(id)
}		

function change_tc(n){
	for(i=1;i<=2;i++){
		$("tc_"+i).style.background="url(img/tc_bgs.gif) no-repeat center"	
		$("tc_div_"+i).style.display="none"
	}	
	$("tc_"+n).style.background="url(img/tc_bg.gif) no-repeat center"
	$("tc_div_"+n).style.display="block"

}

function change_ca(n){
	for(i=1;i<=2;i++){
		$("ca_div_"+i).style.display="none"
		$("cas_div_"+i).style.display="none"
		$("ca_"+i).style.textDecoration="none"
	}	
	$("ca_div_"+n).style.display="block"
	$("cas_div_"+n).style.display="block"
	$("ca_"+n).style.textDecoration="underline"

}

function change_sj(n){
	for(i=1;i<=2;i++){
		$("sj_div_"+i).style.display="none"
		$("sj_"+i).style.textDecoration="none"
	}	
	$("sj_div_"+n).style.display="block"
	$("sj_"+n).style.textDecoration="underline"

}
function isemail(str){
	   var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	   return reg.test(str);
	}
	function istell(str){
	   var reg = /^([0-9]+)+-+([0-9]+)$/;
	   return reg.test(str);
	}
	function istele(str){
	   var reg = /^1([3|5|8])+([0-9])+([0-9])+([0-9])+([0-9])+([0-9])+([0-9])+([0-9])+([0-9])+([0-9])$/;
	   return reg.test(str);
	}
		
	function isqq(str){
	   var reg = /^([0-9]+)$/;
	   return reg.test(str);
	}
	
function marquee(i, direction)
{
	var obj = document.getElementById("marquee" + i);
	var obj1 = document.getElementById("marquee" + i + "_1");
	var obj2 = document.getElementById("marquee" + i + "_2");

	if (direction == "up")
	{
		if (obj2.offsetTop - obj.scrollTop <= 0)
		{
			obj.scrollTop -= (obj1.offsetHeight + 20);
		}
		else
		{
			var tmp = obj.scrollTop;
			obj.scrollTop++;
			if (obj.scrollTop == tmp)
			{
				obj.scrollTop = 1;
			}
		}
	}
	else
	{
		if (obj2.offsetWidth - obj.scrollLeft <= 0)
		{
			obj.scrollLeft -= obj1.offsetWidth;
		}
		else
		{
			obj.scrollLeft++;
		}
	}
}

function marquees(i, direction)
{
	var obj = document.getElementById("marquees" + i);
	var obj1 = document.getElementById("marquees" + i + "_1");
	var obj2 = document.getElementById("marquees" + i + "_2");

	if (direction == "up")
	{
		if (obj2.offsetTop - obj.scrollTop <= 0)
		{
			obj.scrollTop -= (obj1.offsetHeight + 20);
		}
		else
		{
			var tmp = obj.scrollTop;
			obj.scrollTop++;
			if (obj.scrollTop == tmp)
			{
				obj.scrollTop = 1;
			}
		}
	}
	else
	{
		if (obj2.offsetWidth - obj.scrollLeft <= 0)
		{
			obj.scrollLeft -= obj1.offsetWidth;
		}
		else
		{
			obj.scrollLeft++;
		}
	}
}

/******°´±ÈÀýËõ·ÅÍ¼Æ¬******/
function DrawImage(ImgD,imgwidth,imgheight){
var flag=false;  
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= imgwidth/imgheight){ 
   if(image.width>imgwidth){
    ImgD.width=imgwidth; 
    ImgD.height=(image.height*imgwidth)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
  else{ 
   if(image.height>imgheight){
    ImgD.height=imgheight; 
    ImgD.width=(image.width*imgheight)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  } 
 }
}

function change_hg(){
		if(document.getElementById('hg').clientHeight<645) 
		document.getElementById('left_nav').style.height=625+"px"	
	}
