// JavaScript Document

//取得對象
function $(id){
	return document.getElementById(id);	
}

//IE6 BUG,PNG图片纠证
function currentPNG(){
   for(var i=0; i<document.images.length; i++)
      {
     var img = document.images[i]
     var imgName = img.src.toUpperCase()
     if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
        {
       var imgID = (img.id) ? "id='" + img.id + "' " : ""
       var imgClass = (img.className) ? "class='" + img.className + "' " : ""
       var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
       var imgStyle = "display:inline-block;" + img.style.cssText
       if (img.align == "left") imgStyle = "float:left;" + imgStyle
       if (img.align == "right") imgStyle = "float:right;" + imgStyle
       if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle      
       var strNewHTML = "<span " + imgID + imgClass + imgTitle
       + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
       + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
       img.outerHTML = strNewHTML
       i = i-1
        }
      }
}

function isLoadCurrentPNG(){
	 if(navigator.appName == "Microsoft Internet Explorer"&&parseFloat(navigator.appVersion.split("MSIE")[1])<7)
	 {
		 currentPNG();
		 return true;
	 }
	 else
	 {
		return false;	 
	 }
}

//show and hidden sub_nav,currId=當前navid,point=指針狀態
function showHiddenNav(currId,point){
	if(point=="over")
	{
		$(currId).className="sub_nav sub_nav_show";
	}
	else
	{
		$(currId).className="sub_nav";
	}
}

//滾動top
function initTopScroll(){
	var cWidth=document.documentElement.clientWidth;
	var cHeight=document.documentElement.clientHeight;
	$("go_top").style.left=Math.floor((cWidth-1000)/2+957)+"px";
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		$("go_top").style.top=Math.floor(cHeight-250)+parseInt(document.documentElement.scrollTop)+"px";
		window.onscroll=function(){
			$("go_top").style.top=Math.floor(cHeight-250)+parseInt(document.documentElement.scrollTop)+"px";		
		}
	}
	else
	{
		$("go_top").style.position="fixed";	
		$("go_top").style.top=Math.floor(cHeight-250)+"px";
	}
}

//產品列表,listId為要隱藏或顯示層的ID,liId為要更換背景的li的id,aId為當前改變a,aImg為a中的圖片
function showOrHiddenList(num){
	var listId="list_item_"+num;
	var liId="list_li_"+num;
	var aId="list_li_a_"+num;
	var aImg="li_a_img_"+num;
	if($(listId).className=="pro_list_item")
	{
		$(listId).className="pro_list_item pro_list_item_h";
		$(liId).className="li_bg_no_active";
		$(aId).style.color="#474747";
		$(aImg).src="images/left_gray_item.gif";
		$(aId).onmouseover=function(){
			$(aId).style.color="#B9020B";		
		}
		$(aId).onmouseout=function(){
			$(aId).style.color="#474747";		
		}
	}
	else
	{
		$(listId).className="pro_list_item";
		$(liId).className="li_bg_active";
		$(aId).style.color="#B9020B";
		$(aImg).src="images/left_red_item.gif";
		$(aId).onmouseover=function(){
			$(aId).style.color="#B9020B";		
		}
		$(aId).onmouseout=function(){
			$(aId).style.color="#B9020B";		
		}
	}
}

