// JavaScript Document

//去除 A 虚线
    $(document).ready(function(){                           
        $("a").bind("focus",function(){
            if(this.blur){ 
                this.blur();
             }
        });
    });	
	
$(function(){
	$(".indexTab li a").click(function(){
		var tabTitCont = $(this).parent().parent("ul");
		var tabCont = tabTitCont.attr("title");
		$("a",tabTitCont).removeAttr("class");
		$(this).attr("class","now");
		$("."+tabCont).hide();
		$("."+tabCont).eq(parseInt($(this).attr("id"))-1).show();
		return false;
	})
})	
$(function(){
	$(".indexTabB li a").click(function(){
		var tabTitCont = $(this).parent().parent("ul");
		var tabCont = tabTitCont.attr("title");
		$("a",tabTitCont).removeAttr("class");
		$(this).attr("class","nowB");
		$("."+tabCont).hide();
		$("."+tabCont).eq(parseInt($(this).attr("id"))-1).show();
		return false;
	})
})	
	
	
// 更改导航链接
	$(function(){ 
		$("#indexLogin a:last").css({"border-right":"none"});
		$("#indexZBFW li a").css({"margin-bottom":"0"});
		
		$("#footer p a:eq(0)").css({"border-right":"1px solid #fff","padding-right":"8px","margin-right":"8px"});
		$("#footer a:last").css({"padding":"0"});
		
		$("#indexQYFC img").attr("align","left");
		$("#indexQYFC a:eq(1)").css({"position":"absolute","bottom":"0","right":"2px"});
		
		$("form input[type='text'],form input[type='password']").click( function () { $(this).val(""); });

		$("#formLeft img, #formLeft .ipt-txt").css({"float":"left","margin-top":"1px"});
		$("#formLeft .ipt-txt").css({"margin-right":"8px","color":"#ccc"});
		
		$("ul#dropmenu33").remove();
	});


//leftMenuNav 当前位置
	window.onload=function()
	{
		load();
	}
 
	function load(){

		var thisHREFTotal = document.location.href
		var thisHREF = thisHREFTotal.substring(20);//20

		var $leftListA = $('.menubg a');
		$leftListA.each(function(index){
			var ahref = $(this).attr("href");
			if (thisHREF == ahref) {
				$(this).addClass("currentPosition");	
			}
		});
		
		var $navMenuA = $('#navMenu a');
		var navMenuANum = $navMenuA.length;		
		for ( i=0; i<=navMenuANum; i++) {
			j=i+1;
			$navMenuA.eq(i).attr("id", "topNav"+j);
		}

//		var pattern = /(\w+):\/\/([\w\.]+)\/([\w\/]+)\//;
//		var results = thisHREFTotal.match(pattern);
//		var results3 = RegExp.$4;
//		alert(results3);
//		var pattern = /\//;
//		var resultIndex = pattern.exec(results3);	
//		var resultsTree = results3.substring(0,resultIndex.index);
//
//
//		$navMenuA.each(function(index){										
//			if ( $(this).attr("href").indexOf(resultsTree) > -1) {
//				var idNum = $(this).attr("id").substring(6);			
//				switch(Number(idNum)){
//					case 2:$(this).css({"background-position":"-237px -33px"});					
//					break;
//					case 3:$(this).css({"background-position":"-368px -33px"});					
//					break;
//					case 4:$(this).css({"background-position":"-462px -33px"});					
//					break;
//					case 5:$(this).css({"background-position":"-556px -33px"});					
//					break;
//					case 6:$(this).css({"background-position":"-650px -33px"});
//					break;
//					case 7:$(this).css({"background-position":"-744px -33px"});					
//					break;
//					default:$(this).css({"background-position":"-143px -33px"});
//					break;
//					
//				}				
//			}
//		});	
	}


//图片向上自动滚动
(function($){
$.fn.extend({
        upScrolling:function(opt,callback){
                if(!opt) var opt={};
                var _this=this.eq(0).find("div:first");
                var lineH=_this.find("a:eq(0)").height(), 
                    line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), 
                    speed=opt.speed?parseInt(opt.speed,10):500, 
                    timer=opt.timer?parseInt(opt.timer,10):3000; 
                if(line==0) line=1;
                var upHeight=0-line*lineH;
                scrollUp=function(){
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("a:eq(0)").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                        });
                }
                _this.hover(function(){
                        clearInterval(timerID);
                },function(){
                        timerID=setInterval("scrollUp()",timer);
                }).mouseout();
        }        
})
})(jQuery);


$(function(){
	$("#upScrollingQYGC").upScrolling({line:1,speed:500,timer:3000});
})



// 图片向左滚动
//(function($){
//$.fn.extend({
//        Scroll:function(opt,callback){
//                if(!opt) var opt={};
//                var _this=this.eq(0).find("ul:first");
//                var lineW=_this.find("li:first").outerWidth(),
//                    line=opt.line?parseInt(opt.line,10):parseInt(this.outerWidth()/lineW,10), 
//                    speed=opt.speed?parseInt(opt.speed,10):500, 
//                    timer=opt.timer?parseInt(opt.timer,10):3000; 
//                if(line==0) line=1;
//                var leftWidth=0-line*lineW;
//                scrollLeft=function(){
//						_this.animate({
//                                marginLeft:leftWidth
//                        },speed,function(){
//                                for(i=1;i<=line;i++){
//                                        _this.find("li:first").appendTo(_this);
//                                }
//                                _this.css({marginLeft:0});
//                        });
//                }
//                _this.hover(function(){
//                        clearInterval(timerID);
//                },function(){
//                        timerID=setInterval("scrollLeft()",timer);
//                }).mouseout();
//        }        
//})
//})(jQuery);
//
//$(function(){
//	$("#HZXMTJScrolling").Scroll({line:1,speed:500,timer:3000});
//})

$(function(){

	var viewW=$('#HZXMTJScrolling').outerWidth();
	var scrollingUL = $('#HZXMTJScrolling ul:first');
	$('#HZXMTJScrolling a').attr("target","_blank");

	function gotoBackPage() {
		scrollingUL.find('li:gt(4)').fadeTo(200,'0.5',function(){$(this).fadeTo(800,'1')});
		scrollingUL.find('li:lt(5)').fadeTo(1000,'0',function(){$(this).appendTo(scrollingUL).fadeTo(1000,'1')});
	};
	function gotoForwardPage() {
		
//		scrollingUL.find('li:gt(4)').fadeTo(1000,'0');
//		scrollingUL.find('li:lt(5)').fadeTo(1000,'0.3',function(){
//		   var yx = scrollingUL.find('li:eq(4)');													
//		   scrollingUL.prepend(yx);
// 		});
		scrollingUL.find('li:gt(4)').fadeTo(200,'0.5',function(){$(this).fadeTo(800,'1')});
		scrollingUL.find('li:lt(5)').fadeTo(1000,'0',function(){$(this).appendTo(scrollingUL).fadeTo(1000,'1')});

	};
	
	function slide() {
		scrollingUL.find('li:gt(4)').fadeOut(1000);
		scrollingUL.find('li:lt(5)').fadeOut(1000,function(){$(this).appendTo(scrollingUL);})	
		scrollingUL.find('li:gt(4)').fadeIn(4000);
	}

	$('span#back').click(function () {
		gotoBackPage();   
	});
	$('span#forward').click(function () {
		gotoForwardPage()   
	});
	
})


//添加收藏
//$(document).ready(function() {
//    $("#addcollect").click(function() {
//        var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL'; 
//        if (document.all){
//          window.external.addFavorite('http://www.aircbd.com/','北京国门商务区');
//          }else if (window.sidebar){
//         window.sidebar.addPanel('北京国门商务区', 'http://www.aircbd.com/', "");
//       }else {
//               alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
//       }
//    });   
//});

//设置首页
//function SetHome(obj,vrl){
//        try{
//                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
//        }
//        catch(e){
//                if(window.netscape) {
//                        try {
//                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
//                        }
//                        catch (e) {
//                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
//                        }
//                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
//                        prefs.setCharPref('browser.startup.homepage',vrl);
//                 }
//        }
//}


