﻿/**
 * JavaScript banner
 */
jQuery(function($){
				
	//dialog animate init
	$.LB.init();	

	//nav
	var jQ_nav = $("#js_nav"),
		jQ_navLi = $("#js_nav").find('li');
	
	jQ_navLi.hover(
		function(){
			$(this).find(".subNav").show().find('ul').addClass('hover png_bg');  
		},
		function(){
			$(this).find(".subNav").hide().find('ul').removeClass('hover png_bg');  
	});
	
	//friend link
	var jQ_frWrap = $('#js_frWrap'),
		jQ_currItem = jQ_frWrap.find('.currItem');
		jQ_currItem.click(function(){
			var self = $(this);
			jQ_frWrap.find('.itemFr').toggle();
		});
		
		$('.itemFr li', jQ_frWrap).click(function(){
			var self = $(this),
				name = self.html();
			jQ_currItem.html(name);
			jQ_frWrap.find('.itemFr').hide();
		});
		jQ_frWrap.hover(
			function(){
				 //
			},function(){
				$(this).find('.itemFr').hide();
		});
		$('.btnGo', jQ_frWrap).click(function(){
			var self = $(this),
				url = $.trim(jQ_frWrap.find('.currItem input').val()),
				re = /http:\/\/[\w-]*(\.[\w-]*)+/ig				
				if(re.test(url)) {
					window.open(url);
				}
				else return;
		});
	
	// online qq msn 
	var jQ_onlineQA = $('#js_onlineQA');
	$(window).scroll(function(){	
		if($('#js_onlineQA').is(":visible")){
			var self = $(this),
				scrollTop = self.scrollTop();
				jQ_onlineQA.stop().animate({top:scrollTop+150}, 480);
		}
	});
	jQ_onlineQA.find('.close').click(function(){
		jQ_onlineQA.hide();								  
	});
	// go top 
	var jQ_lnk_gotop = $("#js_lnk_gotop");
		goTopPos = jQ_lnk_gotop.position().top;  
	$(window).scroll(function(){
		var isFoot = ($(window).scrollTop() + $(window).height()) > $(document).height()-2 ? true : false;
		var currScrolltop = $(this).scrollTop(); 
		//if(currScrolltop > goTopPos){872 614 1487
		if(isFoot){
			jQ_lnk_gotop.fadeIn();
		}else{
			jQ_lnk_gotop.fadeOut();
		}		
	});
	jQ_lnk_gotop.click(function(){
		$('html').animate({scrollTop:0}, 480);
	});
	
	//close dialogs
	$('#dialog_btnClose , .lnkClose, .dialogWrap .btnClose').live('click', function(){
		$('.dialogWrap, #overlay01').hide();
	});
	

	//flash VerifyCode
	$(".icoCheckcode").click(function(){
		$(this).attr("src",'checknumber.php?' + Math.random());
	});
	$(".lnkChange").click(function(){
		$(".icoCheckcode").attr("src",'checknumber.php?' + Math.random());
	});
	
	//news detail images
	if($.browser.msie && $.browser.version == "6.0"){
		//solute the min-width of our news detail image in IE6 
		var jQ_newDetailImg = $('.detailInfo .dContent img');
		var imgW = jQ_newDetailImg.width();
		if(imgW>500 && jQ_newDetailImg.length > 0){
			jQ_newDetailImg.width(546);
		}
	}
	

});

