// JavaScript Document
//产品中公共内容

//产品类型导航
function ProductNav(productId,current_productnav){
 var p628="" ;
 var p607="" ;
 var p606="" ;
 var p605="";
 var p510=""; 
 var a100=""; 
 if(productId=="p628"){
	 p628 =  "id=\"fn-select\"";
 }
 if(productId=="p607"){
	 p607 =  "id=\"fn-select\"";
 }
 if(productId=="p606"){
	 p606 =  "id=\"fn-select\"";
 }
  if(productId=="p605"){
	 p605 =  "id=\"fn-select\"";
 }
  if(productId=="p510"){
	 p510 =  "id=\"fn-select\"";
 }
 if(productId=="a100"){
	 a100 =  "id=\"fn-select\"";
 }
   document.write("<ul>");
   document.write("<li "+p628+"><a href=\"p628_"+current_productnav+".html\"><img src=\"../images/daohang.png\" width=\"25\" height=\"25\" alt=\"Music icon\">P628</a></li>");
   document.write("<li "+p607+"><a href=\"p607_"+current_productnav+".html\"><img src=\"../images/daohang.png\" width=\"25\" height=\"25\" alt=\"Homescreen icon\">P607</a></li>");
   document.write("<li "+p606+"><a href=\"p606_"+current_productnav+".html\"><img src=\"../images/daohang.png\" width=\"25\" height=\"25\" alt=\"Homescreen icon\">P606</a></li>");
   document.write("<li "+p605+"><a href=\"p605_"+current_productnav+".html\"><img src=\"../images/daohang.png\" width=\"25\" height=\"25\" alt=\"Safari icon\">p605</a></li>");
   document.write("<li "+p510+"><a href=\"p510_"+current_productnav+".html\"><img src=\"../images/daohang.png\" width=\"25\" height=\"25\" alt=\"Introduction icon\">p510</a></li>");
   document.write("<li "+a100+"><a href=\"a100_"+current_productnav+".html\"><img src=\"../images/daohang.png\" width=\"25\" height=\"25\" alt=\"Maps icon\">A100</a></li>");
   document.write("</ul>");
}

//单个产品模块导航
function PublicNav(productId,productnav){
 var feature="" ;
 var gallery="" ;
 var designer="" ;
 var configures="";
 var technic=""; 
 if(productnav=="feature"){
	 feature =  "id='checked'";
 }
 if(productnav=="gallery"){
	 gallery =  "id='checked'";
 }
  if(productnav=="designer"){
	 designer =  "id='checked'";
 }
  if(productnav=="configures"){
	 configures =  "id='checked'";
 }
  if(productnav=="technic"){
	 technic =  "id='checked'";
 }
document.write("<div id=\"productheader\">");
  document.write("<h2><a href=\"#\"  style=\"background-image:url(images/"+productId+"/title_"+productId+".png)\">"+productId+"</a></h2>");
  document.write("<!--<a class=\"buynow\" href=\"#\">立刻订购 iPod touch</a>-->");
  document.write("<ul class=\"productnav\">");
    document.write("<li "+feature+"><a href=\"javascript:GoLink('feature')\">功能</a></li>");
    document.write("<li "+gallery+"><a href=\"javascript:GoLink('gallery')\">图库</a></li>");
    document.write("<li "+designer+"><a href=\"javascript:GoLink('designer')\">设计</a></li>");
    document.write("<li "+configures+"><a href=\"javascript:GoLink('configures')\">标准配置</a></li>");
    document.write("<li "+technic+"><a href=\"javascript:GoLink('technic')\">技术规格</a></li>");
  document.write("</ul>");
document.write("</div>");
}


/*跳转链接*/
function GoLink(productnav){
  var current_product=document.getElementById("current_product").value;
  if(productnav=="designer"){
	  window.location.href="product_designer.html?current_product="+current_product;
  }else{
    window.location.href=current_product+"_"+productnav+".html?current_product="+current_product;
  }  
}

/*取滚动条高度*/
function getScrollTop()
{
    var scrollTop=0;
    if(document.documentElement&&document.documentElement.scrollTop)
    {
        scrollTop=document.documentElement.scrollTop;
    }
    else if(document.body)
    {
        scrollTop=document.body.scrollTop;
    }
    return scrollTop;
}


/**
 功能：配件中鼠标放在小图上显示大图的功能
*/
//document.write("<div id='showpostdetail' class='dv'></div>");
function showdetail(eve,w,wHeight){
	var objPos = mousePosition(eve);
	var x=objPos.x;
	//var y=objPos.y;	
	//var x=650;
	var y=getScrollTop()+200;	
	//alert(x+"-"+y);
	document.getElementById("showpostdetail").innerHTML=document.getElementById(w).innerHTML + "<br>";
	document.getElementById("showpostdetail").style.visibility="visible";
	document.getElementById("showpostdetail").style.display="block";
	//document.getElementById("showpostdetail").style.position="relative";
	//document.getElementById("showpostdetail").style.zIndex="999";
//alert(document.getElementById("showpostdetail").style.left);
//首先判断浏览器的版本
	   var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        if (window.ActiveXObject)
            Sys.ie = ua.match(/msie ([\d.]+)/)[1]
        else if (document.getBoxObjectFor)
            Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
        else if (window.MessageEvent && !document.getBoxObjectFor)
            Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
        else if (window.opera)
            Sys.opera = ua.match(/opera.([\d.]+)/)[1]
        else if (window.openDatabase)
            Sys.safari = ua.match(/version\/([\d.]+)/)[1];
        
        if(parseInt(Sys.ie)<7){
			x=x;
		}else{
			x=x-100;
		}

	document.getElementById("showpostdetail").style.left=(x)+"px";
	var screenHeight = window.screen.availHeight;//770
	var realy;
    y=y-96;
	if(y+wHeight>screenHeight){//超过了下面
		realy=y-wHeight;
	}else{
		realy=y;
	}
	document.getElementById("showpostdetail").style.top=realy+"px";
}
function hidedetail(){
	document.getElementById("showpostdetail").style.innerHTML=""
	document.getElementById("showpostdetail").style.visibility="hidden";
	document.getElementById("showpostdetail").style.display="None";
}

/**
 功能：获取鼠标坐标值
*/
function mousePosition(ev) {
 if(ev.pageX || ev.pageY){
    return {x:ev.pageX, y:ev.pageY};
 }
 //下面返回的是IE的坐标值
 return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop-document.body.clientTop
 };
}

/*实现esc键时，关闭小功能窗口效果,目前仅firefox下可用*/
 var etarget = document.body; 
    document.onclick = function (event) 
    {  event = event || window.event; 
        etarget = event.target || event.srcElement; 
    } 
    document.onkeyup = function ( event  ) 
    { 
        event = event || window.event; 
        var srElement = event.target || event.srcElement; 
       // alert( etarget.tagName ); 
	   if(event.keyCode==27){
		   closeWindow();
	   }
    }; 