﻿// JavaScript Document

//存储在没有选定新频道之前的当前频道
var default_channel=null;

//漫游频道信息时，进行频道切换所存储的上一个选定频道
var before_channel=null;

//当前选中的频道对象
//var current_channel=null;

//整个的频道容器
var channel_container=null;

//设置子级频道内容的外层容器,初始化时指定
var child_channel_container=null;

//用于频道状态判断的内部边界线
//var channel_innerborderline=null;

//用于频道状态判断的边界线
var channel_borderline=null;

//子级频道内容数组
var array_channel=null;


function fn_Init(defaultchannel)
{
	//默认情况下，before_channel就是default_channel,这是在不保留当前已选中栏目的前提下,在保留的情况下则不要下面这句,直接用第二句
	//before_channel=default_channel;
	//alert(defaultchannel);	
	//alert(default_channel);	
	//alert(default_channel.title);	
	
	default_channel=document.getElementById(defaultchannel);
	//current_channel=default_channel;
	//alert(default_channel.title);	

    //alert(document.aspnetForm.getElementsByTagName("DPCChannelContainer"))

	//初始化频道容器对象
	//channel_container=document.aspnetForm.getElementsByTagName("DPCChannelContainer")
	channel_container=document.getElementById("DPCChannelContainer");
	//alert(channel_container);
	
	
	//初始化子频道容器对象
	//channel_container=document.aspnetForm.getElementsByTagName("DPCChildChannelContainer")
	child_channel_container=document.getElementById("DPCChildChannelContainer");
	//alert(child_channel_container.id);
	
	//初始化频道边界线对象,如下也可以采用计算鼠标坐标位置是否越出指定区域来进行判断
	//alert(document.getElementsByName("innerborderline").length);
	//找出所有边界点，并循环进行边界设置,这里可以通过再加一行，行高要超过5px的方式进行划界。但考虑到页面的排版布局，还是将下边界
	//放在具体的内容区间里。
	
	//alert(channel_borderline.length);
	channel_borderline=document.getElementsByName("borderline");	
	for(var i=0;i<channel_borderline.length;i++)
	{
		channel_borderline.item(i).onmouseover=function(){fn_SetCurrentChannel(default_channel);};
	}

    //alert(document.getElementsByName("innerborderline").item(0).title);
	//alert(document.getElementsByName("innerborderline").item(1).title);
										   
	//channel_innerborderline=document.getElementsById("innerborderline");	
	//channel_innerborderline.onmouseover=function(){fn_SetCurrentChannel(default_channel);};//alert("in");
	//channel_innerborderline.onmouseout=function(){fn_SetCurrentChannel(default_channel);};//alert("out");
	
	//初始化频道边界线对象
	//channel_borderline=document.getElementById("borderline");	
	//channel_borderline.onmouseover=function(){fn_SetCurrentChannel(default_channel);};
	
	//channel_container.onmouseover=function(){alert("int");};
	//channel_container.onmouseout=function(){alert("out");fn_SetCurrentChannel(default_channel)};
	
	//初始化子级频道内容
	array_channel=new Array();
	
	//格式化字符串
	var str= null;
	
	//关于本社
	str="";
	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    str += "              <tr> ";
    str += "                <td width=\"120\"></td>";
    //str += "                <td width=\"345\" align=\"left\" class=\"menu2l\"><span class=\"gray\"><a href=\"about_profile.aspx\">出版社简介</a>　|</span>　<a href=\"about_development.aspx\" class=\"menu2l\">发展历程</a>　<span class=\"gray\"><span class=\"menu2l\">|<span class=\"gray\"></span></span>　<a href=\"about_framework.aspx\">组织机构</a>　|</span>　<span class=\"gray\"><a href=\"about_sellcontact.aspx\">各地经销商</a></span></td>";
    str += "                <td width=\"345\" align=\"left\" class=\"menu2l\"><span class=\"gray\"><a href=\"about_profile.aspx\">出版社简介</a>　<span class=\"gray\"><span class=\"menu2l\">|<span class=\"gray\"></span></span>　<a href=\"about_framework.aspx\">组织机构</a>　|</span>　<span class=\"gray\"><a href=\"about_sellcontact.aspx\">各地经销商</a></span></td>";
    str += "                <td width=\"485\"></td>";
    str += "              </tr>";
    str += "            </table>";	
	array_channel[0]=str;
	
	//新闻动态
//	str="";
//	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
//    str += "              <tr> ";
//    str += "                <td width=\"159\">&nbsp;</td>";
//    str += "                <td width=\"366\" align=\"center\" class=\"menu2l\"><a href=\"newslist.aspx\" class=\"menu2l\">社内新闻</a>　|　<a href=\"newslist.aspx\" class=\"menu2l\">业界新闻</a>　|　<a href=\"newslist.aspx\">学术动态</a>　</td>";
//    str += "                <td width=\"425\">&nbsp;</td>";
//    str += "              </tr>";
//    str += "            </table>";    
    
	array_channel[1]=fn_GetNewsCategory();
	
	//网上书城
	str="";
	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	//str += "<tr> ";
	//str += "<td align=\"left\"> ";
	//str += "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
    str += "              <tr> ";
    str += "                <td></td>";
    //str += "                <td width=\"550\" align=\"center\" class=\"menu2l\"><a href=\"mainpage.aspx\" class=\"menu2l\">首 页</a>　<span class=\"gray\">|　<a href=\"booklist.aspx?CName=NewBook\" class=\"menu2l\">新书上架</a>　<span class=\"gray\">|　<a href=\"booklist.aspx?CName=SpecialOffer\" class=\"menu2l\">特价书籍</a>　|　<a href=\"booklist.aspx?CName=HotSell\">畅销书籍</a>　|　<a href=\"booklist.aspx?CName=ImportantBook\">重点书目</a>　|　<a href=\"booklist.aspx\">图书分类</a>　|　<a href=\"download.aspx\">书目下载</a></span></td>";
    str += "                <td width=\"550\" align=\"center\" class=\"menu2l\"><a href=\"mainpage.aspx\" class=\"menu2l\">首 页</a>　<span class=\"gray\">|　<a href=\"booklist.aspx?CName=NewBook\" class=\"menu2l\">新书上架</a>　<span class=\"gray\">|　<a href=\"booklist.aspx?CName=HotSell\">畅销书籍</a>　|　<a href=\"booklist.aspx?CName=ImportantBook\">重点书目</a>　|　<a href=\"booklist.aspx\">图书列表</a>　|　<a href=\"download.aspx\">书目下载</a></span></td>";
    //str += "                <td width=\"550\" align=\"center\" class=\"menu2l\"><a href=\"mainpage.aspx\" class=\"menu2l\">首 页</a>　<span class=\"gray\">|　<a href=\"booklist.aspx?CName=NewBook\" class=\"menu2l\">新书上架</a>　<span class=\"gray\">|　<a href=\"booklist.aspx?CName=SpecialOffer\" class=\"menu2l\">特价书籍</a>　|　<a href=\"booklist.aspx?CName=ImportantBook\">重点书目</a>　|　<a href=\"booklist.aspx\">图书分类</a>　|　<a href=\"download.aspx\">书目下载</a></span></td>";
    str += "                <td></td>";
    str += "              </tr>";
    //str += "            </table>";
    //str += "</td> ";
    //str += "</tr> ";	
    str += "            </table>";
	array_channel[2]=str;
	
	//购书帮助
	str="";
	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    str += "              <tr> ";
    str += "                <td width=\"56\" class=\"menu2l\"></td>";
    str += "                <td width=\"882\" align=\"right\" class=\"menu2l\"><a href=\"help_flow.aspx\">购物流程</a>　<span class=\"gray\"><span class=\"gray\">|</span>　<a href=\"help_manner.aspx\" class=\"menu2l\">送货方式及费率</a>　<span class=\"gray\">|</span>　<a href=\"help_pay.aspx\">付款方式</a><span class=\"gray\">　|　<a href=\"help_deal.aspx\">交易条款</a></span>　<span class=\"gray\">|</span>　<span class=\"gray\"><a href=\"help_trans.aspx\">运输说明</a>　|　<a href=\"help_security.aspx\">保密安全</a>　|　<a href=\"help_worktime.aspx\">工作时间</a>　|　</span><a href=\"help_afterservice.aspx\" class=\"menu2l\">售后服务</a><span class=\"gray\">　|　<a href=\"help_copyright.aspx\">版权声明</a>　|　<a href=\"help_faq.aspx\">常见问题</a>　</span></td>";
    str += "                <td width=\"12\" class=\"menu2l\"></td>";
    str += "              </tr>";
    str += "            </table>";
	array_channel[3]=str;
	
	//读者服务
	str="";
	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    str += "              <tr> ";
    str += "                <td width=\"525\"></td>";
    str += "                <td width=\"252\" align=\"left\" class=\"menu2l\">　<a href=\"service_confirm.aspx\" class=\"menu2l\">汇款确认</a>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"service_wanttobuy.aspx\">求购书籍</a>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"service_faq.aspx\">常见问题</a></span>　</span></td>";
    str += "                <td width=\"173\"></td>";
    str += "              </tr>";
    str += "            </table>";
	array_channel[4]=str;

	//联系我们
	str="";
	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    str += "              <tr> ";
    str += "                <td width=\"442\">&nbsp;</td>";
    str += "                <td width=\"620\" align=\"RIGHT\" class=\"menu2l\">　<a href=\"contact_leaveword.aspx\" class=\"menu2l\">网站留言</a>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"contact_manner.aspx\">求购书籍</a>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"contact_manner.aspx\">联系方式</a></span>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"contact_buy.aspx\">购书联系</a>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"contact_tougao.aspx\">投稿联系</a>　<span class=\"gray\"><span class=\"menu2l\">|</span>　<a href=\"contact_sellcontact.aspx\">各地经销商</a></td>";
    //str += "                <td width=\"610\" align=\"center\" class=\"menu2l\"><a href=\"contact_leaveword.aspx\" class=\"menu2l\">网站留言</a>　|　<a href=\"contact_manner.aspx\">求购书籍</a>　|　<a href=\"contact_manner.aspx\">联系方式</a>　|　<a href=\"contact_buy.aspx\">购书联系</a>　|　<a href=\"contact_tougao.aspx\">投稿联系</a>　|　<a href=\"contact_sellcontact.aspx\">各地经销商</a></td>";
    str += "                <td width=\"0\">&nbsp;</td>";
    str += "              </tr>";
    str += "            </table>";
	array_channel[5]=str;
	
	//原版
//	str="";
//	str += "<table width=\"950\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
//    str += "              <tr> ";
//    str += "                <td width=\"752\">&nbsp;</td>";
//    str += "                <td width=\"300\" align=\"center\" class=\"menu2l\"><a href=\"contact_leaveword.aspx\" class=\"menu2l\">网站留言</a><span class=\"gray\">　|　<a href=\"#\"></a></span><span class=\"gray\"><a href=\"contact_wanttobuyk.aspx\">求购书籍</a>　|　<a href=\"contact_manner.aspx\">联系方式</a>　</span></td>";
//    str += "                <td width=\"10\">&nbsp;</td>";
//    str += "              </tr>";
//    str += "            </table>";
//	array_channel[5]=str;
	
	
	//对导航栏进行动态设置
	var DPCTabRows=document.getElementById("DPCTab").rows;
	var len=document.getElementById("DPCTab").rows.length;
	
	for(var i=0;i<len;i++)
	{
	    for(var j=0;j<DPCTabRows[i].cells.length;j++)
		{	
		    if(DPCTabRows[i].cells[j].getAttribute("TGS")=="stronger")
		    {
		        DPCTabRows[i].cells[j].onmouseover=function(){this.style.cursor='pointer';fn_SetCurrentChannel(this);};    
		    }			
		}
	}
	
	
	
	//首页
	str="";
	array_channel[6]=str;
	//alert(default_channel.id);
	fn_SetCurrentChannel(default_channel);
	//alert(default_channel.title+"2");
}

//设置当前导航栏中被选中的栏目的样式
function fn_SetCurrentChannel(current_channel)
{    
	if(before_channel!=null)
	{		
		//如果之前的所选中的是当前默认的栏目时则不改变其样式
		if(current_channel.id!=before_channel.id)
		{			    
		    if(before_channel.id!=default_channel.id)
	        {       
                before_channel.background="";
		        before_channel.className="TGS_Menu";                     
	        }
	        
	        before_channel=current_channel;
	
	        if(current_channel.id!=default_channel.id)
	        {
	            //alert("over_change");
                current_channel.background="images/menu_trbg.jpg";
                current_channel.className="menured";                
//                current_channel.onmouseover=function(){current_channel.style.cursor='pointer';fn_SetCurrentChannel(current_channel);};
//                current_channel.onmouseout=function(){current_channel.style.cursor='default';};	
	        } 	       
		}				
	}
	else
	{
	    //alert("null_set");
	    before_channel=current_channel;		   
        current_channel.background="images/menu_trbg.jpg";
        current_channel.className="menured";
//	    current_channel.onmouseover=function(){current_channel.style.cursor='pointer';};
//        current_channel.onmouseout=function(){current_channel.style.cursor='default';};	
	}	
	//current_channel.onmouseover=function(){current_channel.style.cursor='pointer';};
    //current_channel.onmouseout=function(){current_channel.style.cursor='default';};	   
    fn_SetChildChannel(current_channel.title);
}

//function fn_SetCurrentChannelStyle(current_channel)
//{
//    before_channel=current_channel;
//	
//	if(current_channel.id!=default_channel.id)
//	{
//        current_channel.background="images/menu_trbg.jpg";
//        current_channel.className="menured";
//	}
//   
//}

//设置子级频道内容
function fn_SetChildChannel(channeltitle)
{    
	if(child_channel_container!=null)
	{
		switch(channeltitle)
		{
			case "关于本社":
			child_channel_container.innerHTML=array_channel[0];
			break;
			
			case "新闻动态":
			child_channel_container.innerHTML=array_channel[1];
			break;
			
			case "网上书城":
			child_channel_container.innerHTML=array_channel[2];
			break;
			
			case "购书帮助":
			child_channel_container.innerHTML=array_channel[3];
			break;
			
			case "读者服务":
			child_channel_container.innerHTML=array_channel[4];
			break;
			
			case "联系我们":
			child_channel_container.innerHTML=array_channel[5];
			break;		
			
			case "首页":
			child_channel_container.innerHTML=array_channel[6];
			break;		
			
			default:
			child_channel_container.innerHTML=array_channel[6];
			break;
		}
	}	
}

//在没有选定新频道，而只是漫游频道信息状态下，恢复设置到当前导航栏的状态
function fn_RecoverySets(channel)
{	
	//fn_SetCurrentChannel(default_channel);	
}

//class="orange"