﻿// JScript 文件
//if(top!=self)top.location.href=self.location.href;
var lastService=null,_IsReadService=false;
function SelectService(o,id){
    if(lastService!=id){
        if(_IsReadService)return;
        jQuery(o).parent().find("li").each(function(){
            jQuery(this).removeClass("serbMli");
        });
        jQuery(o).addClass("serbMli");
        
        var tempContentDiv=jQuery("#serlist #serlistContent");
        var tempP=jQuery("#serlist p");
        
        var tempDiv=tempContentDiv.find("#serlistContent_"+id);
        var hidetempDiv=tempContentDiv.find("#serlistContent_"+lastService);
        if(tempDiv.is("div")){
            tempDiv.show();
            tempContentDiv.show();
            
            hidetempDiv.hide();
            tempP.hide();
            lastService=id;
        }else{
            tempP.show();
            tempContentDiv.hide();
            hidetempDiv.hide();
            tempDiv=document.createElement("div");
            tempDiv.id="serlistContent_"+id;
            tempContentDiv.append(tempDiv);
            /*临时*/
            if(1001==id){
                tempP.hide();
                jQuery(tempDiv).html("<table style=\"width:100%;\" cellspacing=\"0\"><tr><th align=\"center\">客服编号</th><th align=\"center\" style=\"width:100px;\">值班时间</th><th align=\"center\" style=\"width:105px;\">QQ</th><th scope=\"col\" style=\"width:105px;\">电话</th></tr><tr>"+
                    "<td align=\"center\">"+
                    "<img src=\"http://img.2q5q.com/images/OnlineBright.jpg\" style=\"border-width:0px;\" />"+
                    " <span>通宵客服097</span>"+
                    "</td><td align=\"center\">"+
                    "<img src=\"http://img.2q5q.com/images/servicetime.jpg\" style=\"border-width:0px;\" />"+
                    " <span>00:00-24:00</span>"+
                    "</td><td align=\"center\">"+
                    "<img src=\"http://img.2q5q.com/images/serviceqq_act.jpg\" style=\"border-width:0px;\" />"+
                    " QQ:<span>100972858</span>"+
                    "</td><td align=\"center\">"+
                    "<img src=\"http://img.2q5q.com/images/servicetelicon.jpg\" style=\"border-width:0px;\" />"+
                    " <span>0595-36102858</span>"+
                    "</td></tr></table>");
                tempContentDiv.show();
                lastService=id;
                return;
            }
            /*****/
            _IsReadService=true;
            jQuery.get("servicelist.aspx",{ID:id,temp:Math.random()},function(xml){
                tempP.hide();
                //xml=xml.replace(/(.|\n)+?(<table(.|\n)+?<\/table>)(.|\n)+/,"$2");
                jQuery(tempDiv).html(xml);
                tempContentDiv.show();
                var tempTable = tempContentDiv.find("table");
                if(jQuery.browser.msie&&tempTable.height()>tempContentDiv.height()){
                    if("6.0"==jQuery.browser.version)
                        tempTable.width(tempTable.width()-20);
                }
                lastService=id;
                _IsReadService=false;
            });
        }
    }
}

var lastTradeID=0,ScrollTime=null;
function SelectTrade(o,id){
    if(lastTradeID!=id){
        jQuery(o).parent().find("li").each(function(){
            jQuery(this).removeClass("trade-focus");
        });
        jQuery(o).addClass("trade-focus");
        jQuery("div.trade_"+id).show();
        jQuery("div.trade_"+lastTradeID).hide();
        
        //jQuery("div.trade_"+id+" table")
        var tempST=jQuery("div.trade_"+id+" table.t2");
        if(tempST.height()>jQuery("div.trade_"+id).parent().height()){
            ScrollTradeTable(jQuery("div.trade_"+id+" table.t2"),2000);
        }else{
            clearTimeout(ScrollTime);
            ScrollTime=null;
        }
    }
    lastTradeID=id;
}
jQuery(document).ready(function(){
    //jQuery("div.new-trade ul li:nth-child(1)").trigger("click");
//    var trade1 = new ppRoll({
//					speed:60, 		//速度
//					demo:"demo",	//外框架div
//					demo1:"demo1",	//滚动主体div
//					demo2:"demo2",	//复制的div
//					objStr:"ppRoll",	//创建的对象名
//					width:"192px",	//外框架demo的宽度
//					height:"360px",	//外框架demo的高度
//					direction:"top"	//滚动方向，可选值：top、down、left、right
//					});
    //载入网吧查询的省份地区
    if(jQuery("#Province").is("select")){
        new PCAS("Province","City","County");
    }
});

function ScrollTradeTable(JQot,t){
    if(null!=ScrollTime)clearTimeout(ScrollTime);
    JQot.parent().mouseover(function(){
        clearTimeout(ScrollTime);//clearInterval
        ScrollTime=null;
    }).mouseout(function(){
        if(null==ScrollTime)ScrollTime = setTimeout(function(){ScrollTable(JQot,t);},t);
    });
    
    ScrollTime = setTimeout(function(){
        ScrollTable(JQot,t)
        },t);

}//setInterval

function ScrollTable(JQot,t){
    if(null!=ScrollTime)clearTimeout(ScrollTime);
    JQot.animate({marginTop:"-"+JQot.find("tr:first")[0].offsetHeight+"px"},500,function(){
        jQuery(this).css({marginTop:"0px"}).find("tr:first").appendTo(this);
        ScrollTime = setTimeout(function(){ScrollTable(JQot,t);},t);
    });
}