﻿
try{document.domain="abchina.com";
}catch(e){}
var url = window.location.href;
 var urls = url.split("/");
 var base="";
 var domains = urls[2].split(".");
 if(url.toLowerCase().indexOf('trs.web.abc')>-1)
 {}
 else
 {      
    if (domains.length==4) 
    {
       if (!isNaN(domains[0])&&!isNaN(domains[1])&&!isNaN(domains[2])&&!isNaN(domains[3]))
       {}
    }    
    else
    {
       for(i=3;i<urls.length;i++)
       {
           base = base+"/" + urls[i];        
       }   
       document.write("<base href='http://www.abchina.com" + base + "'/>");
    }
 }
 //----------------以下为公共部分-------------
function showsubmenu(sid) {
    var whichEl = document.getElementById("submenu" + sid);

    if (whichEl.style.display == "none") {
        whichEl.style.display = "";
        document.getElementById("menutop" + sid).className = "topOff";
    }
    else {
        whichEl.style.display = "none";
        document.getElementById("menutop" + sid).className = "topOn";
    }
}
//首页tag切换效果
function showShortcutContent(tabobj, num) {

    
    i=num-1;
    //alert($(tabobj).attr("class"));
    $(tabobj).parent().children("h5").removeClass();
    $(tabobj).removeClass().addClass("On01");
    $(tabobj).parent().nextAll().css("display","none");
    $(tabobj).parent().nextAll().eq(i).css("display","block");
}
//获取首页日期
function getDate(id) {
    var myDate = new Date();
    var dYear = myDate.getFullYear().toString();   //获取完整的年份(4位,1970-????)
    var dMonth = myDate.getMonth().toString();      //获取当前月份(0-11,0代表1月)
    var dDay = myDate.getDate().toString();       //获取当前日(1-31)
    
    dMonth = parseInt(dMonth) + 1;
    
    if ((dMonth.toString().length) < 2) {
        dMonth = "0" + dMonth;
    } 
    if (dDay.length < 2) {
        dDay = "0" + dDay;
    } 
    var str = dYear + "." + dMonth + "." + dDay +"";
    document.getElementById(id).innerHTML = str;
}
//导航栏鼠标点击效果
function MMClick(id)
{
	window.location.href=$("#"+id).find("a").attr("href");
}
//导航栏鼠标划过效果切换Start
function MMOver(id,menuid) {
        	if(id==menuid){
        	}else{
        	$("#Menu_"+id).removeClass().addClass('Menu_hover');
        	}
   
}
function MMOut(id,menuid) {
    if (id == menuid) {
             
    }else
    {
         switch (id)
    {
        case '0':
        	$("#Menu_"+id).removeClass().addClass('Menu_off');
            break;
        case '8':
        	$('#Menu_'+id).removeClass().addClass('Menu_off');
            break;
        default:
         	$('#Menu_'+id).removeClass().addClass('Menu_off');
            break;
            
    }
    }
  }
  

//导航栏鼠标划过效果切换End

/* id:导航栏menu的id */
function showMenu(id) {
		
	//alert(str);
    switch (id)
    {
        case '0':
        	$(".Menu-center").css("display","none");
        	$("#Menu"+id).css("display","block");
        	$("#Menu_"+id).removeClass().addClass('Menu_on');
            break;
        case '8':
	        $(".Menu-center").css("display","none");
        	$("#Menu"+id).css("display","block");
        	$('#Menu_'+id).removeClass().addClass('Menu_on');
            break;
        default:
        	$(".Menu-center").css("display","none");
        	$("#Menu"+id).css("display","block");
        	$('#Menu_'+id).removeClass().addClass('Menu_on');
            break;
            
    }
}

/* 获取用户状态所需函数 Start*/
        // utility function to retrieve an expiration data in proper format;
        function getExpDate(days, hours, minutes) {
            var expDate = new Date();
            if (typeof (days) == "number" && typeof (hours) == "number" && typeof (hours) == "number") {
                expDate.setDate(expDate.getDate() + parseInt(days));
                expDate.setHours(expDate.getHours() + parseInt(hours));
                expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
                return expDate.toGMTString();
            }
        }

        //utility function called by getCookie()
        function getCookieVal(offset) {
            var endstr = document.cookie.indexOf(";", offset);
            if (endstr == -1) {
                endstr = document.cookie.length;
            }
            return unescape(document.cookie.substring(offset, endstr));
        }

        // primary function to retrieve cookie by name
        function getCookie(name) {
            var arg = name + "=";
            var alen = arg.length;
            var clen = document.cookie.length;
            var i = 0;
            while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg) {
                    return getCookieVal(j);
                }
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
            }
            return;
        }

        // store cookie value with optional details as needed
        function setCookie(name, value, expires, path, domain, secure) {
            document.cookie = name + "=" + escape(value) +
                    ((expires) ? "; expires=" + expires : "") +
                    ((path) ? "; path=" + path : "") +
                    ((domain) ? "; domain=" + domain : "") +
                    ((secure) ? "; secure" : "");
        }

        // remove the cookie by setting ancient expiration date
        function deleteCookie(name, path, domain) {
            if (getCookie(name)) {
                document.cookie = name + "=" +
                        ((path) ? "; path=" + path : "") +
                        ((domain) ? "; domain=" + domain : "") +
                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
            }
        } 
/* 获取用户状态所需函数 End */

/* 调整字体大中小 Start */
function doZoom(id,size){
  document.getElementById(id).style.fontSize=size;
 }
/* 调整字体大中小 End */





//加入收藏
function AddFavorite(url)
{
if (document.all)
{ 
window.external.addFavorite(url,'Agricultural Bank of China'); 
}else if (window.sidebar)
{ window.sidebar.addPanel('Agricultural Bank of China', url, ""); }
} 

//复制链接
function copySss(url)  { 
var clipBoardContent=url;
window.clipboardData.setData("Text",clipBoardContent);
if (clipboardData.getData("Text") != clipBoardContent){
window.alert("URL Copy Failure!"); 
}else{
window.alert("URL Copy Successful!");}
}






//弹出框口
function OpenWindow(url,width,height,top,left)
{
	window.open(url,"cssrain","left="+left+",top="+top+",width="+width+",height="+height+"","resize=auto");
}


//提点建议部分
$(function() {
    $('a').click(function(e) {
        if (this.className == "ModuleDialog") {
            e.preventDefault();
            var $this = $(this);
            var horizontalPadding = 30;
            var verticalPadding = 30;
            $('<iframe frameborder="0" id="externalSite" class="externalSite" src="' + this.href + '" />').dialog({
                title: ($this.attr('title')) ? $this.attr('title') : '提点建议',
                autoOpen: true,
                width: 550,
                height: 380,
                modal: true,
                resizable: false,
                autoResize: true,
                overlay: {
                    opacity: 0.5,
                    background: "black"
                }
            }).width(550 - horizontalPadding).height(380 - verticalPadding);
        }
    });
});   


        $(function() {
$.fn.extend({
	"followDiv":function(str){
		var _self = this;
		var pos; //层的绝对定位位置
		switch(str){
			case("leftbottom")://右下角
				pos={"left":"10px","bottom":"10px"};
				break;

			case("rightbottom")://右下角
				pos={"right":"10px","bottom":"10px"};
				break;
			default :   //默认为右下角
				pos={"right":"10px","bottom":"10px"};
				break;
		}
		/*FF和IE7可以通过position:fixed来定位，*/
		_self.css({"position":"fixed","z-index":"9999"}).css(pos);
		/*ie6需要动态设置距顶端高度top.*/
		if($.browser.msie && $.browser.version == 6) {
		
				_self.css('position','absolute');						
				$(window).scroll(function(){
					var topIE6;
					if(str=="rightbottom"||str=="leftbottom"){
						topIE6=$(window).scrollTop() + $(window).height() - _self.outerHeight();
					}else if(str=="lefttop"||str=="righttop"){
						topIE6=$(window).scrollTop();
					}else{
						topIE6=$(window).scrollTop() + $(window).height() - _self.outerHeight();
					}
					//alert($(_self).offset().top);
					$(_self).css( 'top' , topIE6);
				});
		}
		return _self;  //返回this，使方法可链。
	}
});
});

 //获取iframe子页面的方法，需调用才能实现 (<body onload="doShow()">)
    function iframeResize(frameId, frameName) {
        var dyniframe = null;
        var indexwin = null;
        if (document.getElementById) {
            if (!frameId) {
                frameId = frameId;
                frameName = frameName;
            }
			
            dyniframe = document.getElementById(frameId);
            indexwin = window;
            if (dyniframe) {
                var contentHeight, win = indexwin.frames[frameName];
                if (win.innerHeight && win.scrollMaxY) {
                    contentHeight = win.innerHeight + win.scrollMaxY;
                } else if (win.document.body.scrollHeight > win.document.body.offsetHeight) { // all but Explorer Mac   
                    contentHeight = win.document.body.scrollHeight;
                } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari   
                    contentHeight = win.document.body.offsetHeight;   
                }
                dyniframe.height = (!contentHeight || contentHeight < 100) ? 100 : contentHeight;
				//alert(dyniframe.height);
            }
        }
    }

//弹出窗口根据内容重设窗口大小
//id：内容部分最外围的id值
    	function reSize(id)
    	{
			window.resizeTo($("#"+id).width()+10,$("#"+id).height()+80);
    	}


//处理错误信息
function doNothing(){ return true; } 
window.onerror = doNothing;







function dmSelect(name,value,data){ 
				BussSelect("buss"+name.substring(4),'');
				var dtop = $("#" + name).offset().top;   //获取控件top、left位置和width、height 
				// var dtop = $("#" + name).offsetParent()?($("#" + name).offset().top+$("#" + name).offsetParent().offset().top):$("#" + name).offset().top;
				 var ptop = $("#" + name).offsetParent().offset().top;
				 //alert(dtop-$("#" + name).offsetParent().offset().top);
				 var sTop=dtop-ptop+22;
				 var dleft = $("#" + name).offset().left; 
				 var pleft = $("#" + name).offsetParent().offset().left
				 var sLeft = dleft - pleft ;
				 var height = $("#" + name).height();
				 var _sWidth=180;
				 var width = $("#" + name).width();
				 var option_open = false;      //标记是否打开下拉option 
				 var child_default_html = "<div style='text-align:left;padding-left:5px;padding-right:5px;height:18px;line-height:18px; vertical-align:middle'>Please Select Service First</div>";				 


				 function __dropheight(l){var h;if(l>10 || l<1){h = 10 * 18;}else{h = l * 18; }return h;}  //计算下拉option显示高度 
				 var div_html = "<div id='_li_"+name+"' style='position:absolute;width:100%;float:left;background-color:#F4F4F4;border-top: 1px #479C8E solid;line-height:18px;padding:0 0 10px 0;z-index:9999999;margin-top:-1px;;display:none;top:"+sTop+"px;left:"+(sLeft)+"px;height:"+__dropheight(data.length)+"px;'>"; 
				 //for循环填充option 
				 for(var i = 0;i < data.length; i++)
					 {
					 div_html += "<div id='li_serv_"+i+"' style='text-align:left;padding-left:5px;padding-right:5px;height:18px;line-height:18px; vertical-align:middle' value='" + data[i][1] + "'>" + data[i][0] + "</div>";
					 if(i==0)
						 {
						 _sWidth = data[i][0].length*7;
						 }else{
							if(data[i][0].length*7>_sWidth)
							 {
								_sWidth = data[i][0].length*7;
							}
						 }
						 //alert(data[i][0].length);
						// alert("id:_li_"+name+"--"+data[i][0]+":"+data[i][0].length);
					 } 
				 div_html += "</div>"; 
				 $("#" + name).after(div_html);  //添加到input控件后面 
				 function __open_option(){$("div[id^='_li_']").hide();$("#_li_" + name).show();option_open=true;}  //显示下拉option 
				 function __hide_option(){
					 $("#_li_" + name).hide();
					 option_open=false;
					 $(document).unbind("click",__hide_option);
					 $(".Active").attr("class","Normal");
				 }  //隐藏下拉option 
						$("#_li_"+name).css("width",(_sWidth<180)?180:_sWidth);
						//alert(_sWidth);
				 $("#" + name).click(function(event){if(option_open){__hide_option();}else{__open_option();$(this).attr("class","Active");$(document).bind("click",__hide_option)}event.stopPropagation();}); 
				 $("#_li_" + name + " > div").hover(function(){$(this).css({"background-color":"#7DC0B4","height":"18px","vertical-align":"middle","line-height":"18px"});},function(){$(this).css({"background-color":"","height":"18px","vertical-align":"middle","line-height":"18px"});}) 
				 .click(function(){
				 //$("#" + name).val($(this).html());
				 $(".Active").attr("class","Normal");
				 $(".Waiting").attr("class","Normal");
				 for(var i=1;i<7;i++)
				 {
				 	$("#serv"+i).text("Select Service...");
					//$("#_li_buss"+i).remove();
				 }

				 $(".hidValue").attr("value",'');
				 $("#" + value).val($(this).attr("value"));
				 $("div[id^='_li_buss']").html(child_default_html);
				 $("div[id^='_li_buss']").css("width","180px");
				// $("#"+name).attr("class","Active");
				 var dmValue=$("#" + value).val();
				 //window.location=$("#" + value).val();
				 $("#"+name).html($(this).html());
				 $("#buss"+name.substring(4)).attr("class","Waiting");   
				 BussSelect("buss"+name.substring(4),BussOptions[dmValue.substring(0,1)][dmValue.substring(1)]);
				 }); 
			}; 
			
			
			function BussSelect(name,data){ 
				 var bnum=name.substring(4);
				 
				 var dtop = $("#" + name).offset().top;   //获取控件top、left位置和width、height 
				 var ptop = $("#" + name).offsetParent().offset().top;
				 var sTop=dtop-ptop+22;
				 var dleft = $("#" + name).offset().left; 
				 var pleft = $("#" + name).offsetParent().offset().left
				 var sLeft = dleft - pleft ;
				 var height = $("#" + name).height(); 
				 var _bWidth = 180;
				 var width = $("#" + name).width();
				 var option_open = false;      //标记是否打开下拉option 
				 function __dropheight(l){var h;if(l>10 || l<1){h = 10 * 18;}else{h = l * 18; }return h;}  //计算下拉option显示高度 
				 var div_html; 
				 //for循环填充option 
				 
				 var default_html;
				default_html = "<div style='text-align:left;padding-left:5px;padding-right:5px;height:18px;line-height:18px; vertical-align:middle'>Please Select Service First</div>";				 
				 
				 
				 if(!$("#hf_dselect"+bnum).val())
				 {
				 	$("#_li_buss"+i).remove();
					div_html = "<div id='_li_"+name+"' style='position:absolute;width:300px;float:left;background-color:#F4F4F4;border-top: 1px #479C8E solid;line-height:18px;padding:0 0 10px 0;z-index:9999999;margin-top:-1px;;display:none;top:"+sTop+"px;left:"+(sLeft)+"px;'>"
					div_html += "<div style='text-align:left;padding-left:5px;padding-right:5px;height:18px;line-height:18px; vertical-align:middle'>Please Select Service First</div>";				 
				 }else{
				 div_html = "<div id='_li_"+name+"' style='position:absolute;width:180px;float:left;background-color:#F4F4F4;border-top: 1px #479C8E solid;line-height:18px;padding:0 0 10px 0;z-index:9999999;margin-top:-1px;;display:none;top:"+sTop+"px;left:"+(sLeft)+"px;'>"
				 for(var i = 0;i < data.length; i++)
					 {
					 div_html += "<div style='text-align:left;padding-left:5px;padding-right:5px;height:18px;line-height:18px; vertical-align:middle' value='" + data[i][1] + "'>" + data[i][0] + "</div>";
					 if(i==0)
						 {
						 _bWidth = data[i][0].length*7;
						 }else{
							if(data[i][0].length*7>_bWidth)
							 {
								_bWidth = data[i][0].length*7;
							}
						 }
					 } 
				 }
				 div_html += "</div>"; 
				 $("#" + name).after(div_html);  //添加到input控件后面 
				 function __open_option(){
				 $("div[id^='_li_']").hide();
				 
				 	if(!$("#hf_dselect"+bnum).val())
				 	{
				 		$("#_li_buss"+i).html(default_html);
				 	}
				 $("#_li_" + name).show();
				 option_open=true;
				 }  //显示下拉option 
				 function __hide_option(){
					 $("#_li_" + name).hide();
					 option_open=false;
					 if(!$("#hf_dselect"+bnum).val())
					 {
						 $("#"+name).attr("class","Normal");
					 }else
					 {
						 $("#"+name).attr("class","Waiting");
					 }
					 $(document).unbind("click",__hide_option);
				 }  //隐藏下拉option
				//	alert(name);
				 $("#_li_"+name).css("width",(_bWidth<180)?180:_bWidth);	
				 $("#" + name).click(function(event){if(option_open){__hide_option();}else{__open_option();$(this).attr("class","Active");$(document).bind("click",__hide_option)}event.stopPropagation();}); 
				 $("#_li_" + name + " > div").hover(function(){$(this).css({"background-color":"#7DC0B4","height":"18px","vertical-align":"middle","line-height":"18px"});},function(){$(this).css({"background-color":"","height":"18px","vertical-align":"middle","line-height":"18px"});}) 
				 .click(function(){
				 //$("#" + name).val($(this).html());
				 if(!$(this).attr("value") || $(this).attr("value")=='')
				 {
				 
				 }else{
				 window.location=$(this).attr("value");
				 }
				 }); 
			};



function GoUri(id,formid)
{
	var str = $("#"+id).val();
	$("#"+formid).attr("action",str);
}
















/*=========================================TRS JavasCript=============================*/ 
//通过TRS 频道号获取MenuId 若有  
//ChanId为 通过置标获取到的 栏目号（唯一）
// 使用范例: getMenuIdByChannel(<TRS_CHANNEL ID='OWNER' FIELD='')
function getMenuIdByChannel(ChanId){
	var MenuId = "1";
	var ChannelIds = "29;56;85;95;148;158;225";
	var ChannelArray = new Array();
	ChannelArray = ChannelIds.split(";");
	//alert(ChannelArray[0]);
	for(i=1;i<9;i++){
		if(ChannelArray[i-1]==ChanId){
			MenuId = i+1;	
		}
	}
	return MenuId;
  }
// TRS 翻页JS 代码 
/*	参数
	nCurrentPage 当前页
	nCountPage   总页数
	sPageName    文件名
	sPageEXT     后缀名
	使用范例：getNav(${PAGE_INDEX},"${PAGE_COUNT}","${PAGE_NAME}","${PAGE_EXT}"); 
*/
function getNav(nCurrentPage,nCountPage,sPageName,sPageEXT)
{ 
	var currentPage = nCurrentPage;
	var prevPage = currentPage-1;
	var nextPage = currentPage+1;
	var countPage = nCountPage;
	var pageLast = nCountPage-1;
	//document.write("<span class='huang12_h'>共"+countPage+"页"+RECORD_COUNT+"条记录&nbsp;&nbsp;</span>");
	document.write("<div id='pager2' class='scott'>");
	//set prevPage
	if(countPage>1&&currentPage!=0&&currentPage!=1)
		document.write("<a href=\""+sPageName+"_" + prevPage + "."+sPageEXT+"\" class='disabled'>&lt;</a>&nbsp;");
	else if(countPage>1&&currentPage!=0&&currentPage==1)
		document.write("<a href=\""+sPageName+"."+sPageEXT+"\" class='disabled'>&lt;</a>&nbsp;");
	else
		document.write("<a href=\"#\" class='disabled'>&lt;</a>&nbsp;");
	//循环
	var num = 6;
	for(var i=0+(currentPage-1-(currentPage-1)%num) ; i<=(num+(currentPage-1-(currentPage-1)%num))&&(i<countPage) ; i++){
		if(currentPage==i)
			document.write("<span class='current'>"+(i+1)+"</span>");
		else if(i==0)
			document.write("<a href=\""+sPageName+"."+sPageEXT+"\" class='current'>"+(i+1)+"</a>");
		else
			document.write("<a href=\""+sPageName+"_" + i + "."+sPageEXT+"\" class='current'>"+(i+1)+"</a>");
	}
	//最后一页
	
	//document.write("...<a href=\""+sPageName+"_" + pageLast + "."+sPageEXT+"\" class='current'>"+nCountPage+"</a>");
	
	//设置下一页代码 
	if(countPage>1&&currentPage!=(countPage-1)){
		document.write("&nbsp;<a href=\""+sPageName+"_" + nextPage + "."+sPageEXT+"\" class='disabled'>&gt;</a>");
	}
	else{
		document.write("&nbsp;<a href=\"#\" class='disabled'>&gt;</a>");
	}
	//document.write(" <select id='toPage' class='CommanSelect'> <option value='1'>1</option><option value='2'>2</option><option value='3'>1003</option></select>");                                   
	document.write("</div>");
}

//下拉框跳转
function ABC_jMenu(selObj){
		var newhref= selObj.options[selObj.selectedIndex].value;
		selObj.selectedIndex=0;
		window.location=newhref;
	   }
	   
	   
function ABC_jMenu_blank(selObj){
		var newhref= selObj.options[selObj.selectedIndex].value;
		selObj.selectedIndex=0;
		window.open(newhref);
	   }
