/*function area*/
(function ($) {

	$.fn.hoverClass = function (className) {
		var _self = this;
		_self.each(function (i) {
			_self.eq(i).mouseenter(function () {
				$(this).addClass(className);
			});
			_self.eq(i).mouseleave(function () {
				$(this).removeClass(className);
			});
		});
	return _self; 
	};

	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});

	$.fn.focusChangeStyle = function (focusClass) {
		var _self = this;
		var focusClass = (focusClass==null)?'it_focus':focusClass;
		_self.focus(function(){
			$(this).addClass(focusClass);
		});
		_self.blur(function(){
			$(this).removeClass(focusClass);
		});
	return _self;
	}
	$.fn.extend({
		"foucsText": function(val){
			var _self = this;
			//var v=(val==null)?$(_self).val():val;
			var v = '请填写';
			 _self.val(v);
			_self.focus(function () {
				if(_self.val()==v){
					//_self.val("");
				}
			});
			_self.blur(function(){
			if(_self.val()==""){
				//_self.val(v);
			}
			});
			return _self;
		}
	});

})(jQuery);

/*soChange1.5*/
(function(a){a.fn.extend({soChange:function(b){b=a.extend({thumbObj:null,botPrev:null,botNext:null,thumbNowClass:"now",thumbOverEvent:true,slideTime:1000,autoChange:true,clickFalse:true,overStop:true,changeTime:5000,delayTime:300},b||{});var h=a(this);var i;var k=h.size();var e=0;var g;var c;var f;function d(){if(e!=g){if(b.thumbObj!=null){a(b.thumbObj).removeClass(b.thumbNowClass).eq(g).addClass(b.thumbNowClass)}if(b.slideTime<=0){h.eq(e).hide();h.eq(g).show()}else{h.eq(e).fadeOut(b.slideTime);h.eq(g).fadeIn(b.slideTime)}e=g;if(b.autoChange==true){clearInterval(c);c=setInterval(j,b.changeTime)}}}function j(){g=(e+1)%k;d()}h.hide().eq(0).show();if(b.thumbObj!=null){i=a(b.thumbObj);i.removeClass(b.thumbNowClass).eq(0).addClass(b.thumbNowClass);i.click(function(){g=i.index(a(this));d();if(b.clickFalse==true){return false}});if(b.thumbOverEvent==true){i.mouseenter(function(){g=i.index(a(this));f=setTimeout(d,b.delayTime)});i.mouseleave(function(){clearTimeout(f)})}}if(b.botNext!=null){a(b.botNext).click(function(){if(h.queue().length<1){j()}return false})}if(b.botPrev!=null){a(b.botPrev).click(function(){if(h.queue().length<1){g=(e+k-1)%k;d()}return false})}if(b.autoChange==true){c=setInterval(j,b.changeTime);if(b.overStop==true){h.mouseenter(function(){clearInterval(c)});h.mouseleave(function(){c=setInterval(j,b.changeTime)})}}}})})(jQuery);


/*use*/




$(function () {


	if ($('.ul_mainNav').length) {
		var li_a = $('.ul_mainNav a:not(.now)');

		window.opToZ = function (a) {
			li_a.eq(a).animate({opacity:1},500);
		}

		li_a.each(function (i) {
			li_a.eq(i).mouseenter(function () {
				timeout =setTimeout("opToZ("+i+")",200);
				//$(this).animate({opacity:1},500);
			});

			li_a.eq(i).mouseleave(function () {
				clearTimeout(timeout);
				li_a.eq(i).animate({opacity:0},500);
			});
		});


	}


	if ($('.indexMainBanner').length) {
		var c = $('.indexMainBanner');
		var ulStr = '<div class="maskL"></div><div class="maskR"></div><a class="bot_prev" href="#">prev</a><a class="bot_next" href="#">next</a>';
		c.append(ulStr);
		$('.indexMainBanner .bot_prev').click(function () {
			return false;
		});
		$('.indexMainBanner .bot_next').click(function () {
			return false;
		});
		c.ready(function () {
			c.removeClass('bannerLoad');
			$('.indexMainBanner .bannerS').cycle({ 
				fx : 'scrollHorz', 
				prev : '.indexMainBanner .bot_prev', 
				next : '.indexMainBanner .bot_next', 
				pause:  1,
				timeout : 8000 
			});
		});
	}


if ($('.serviceContBox').length) {
	$('.serviceContBox .serviceCont').soChange({
		thumbObj:'.ul_serAbs li',
		slideTime:0,
		autoChange:false
	});
}


if ($('.VIP_priceBox').length) {
	$('.VIP_priceBox .table_s1b').soChange({
		thumbObj:'.VIP_priceBox h4',
		slideTime:0,
		autoChange:false
	});
}

if ($('.ul_indexIntro').length) {
	$(".ul_indexIntro li").hoverClass("over");
}

if ($('.table_s1').length) {
	$('.table_s1 tr:even').addClass('tr_even');
}

if ($('.dl_comments').length) {
	$('.dl_comments dd:odd').addClass('dd_odd');
}
if ($('.form_cBg').length) {
	$('.form_cBg .p_item:odd').addClass('bg_brown');
}
if ($('.form_s1').length) {
	$('.form_s1 .txt').focusChangeStyle();
	$('.form_s1 .txta').focusChangeStyle();
}

if ($('.uploadFormBox').length) {
	$('.form_s1 .txt').each(function (i) {
		//$(this).foucsText();
	});
	$('.form_s1 .txta').each(function (i) {
		//$(this).foucsText();
	});
}

if ($('.h3_payForm').length) {
	$('.h3_payForm a:not(.now)').hoverClass('over');
}

if ($('.formLogin').length) {
	var dH=$(document).height();
	var wW=$(window).width();
	//alert(dH);
	$(".a_findPass").click(function () {
		$("#mask").css('height',(parseInt(dH)+1+"px"));
		$("#findPassBox").fadeIn();
		return false;
	});

	$(".a_slideClose").click(function () {
		slideHide();
		return false;
	});

	$('.btnReg').click(function () {
		regSuccessTip();
	});
	$('.a_hideClose').click(function () {
		$("#regSuccessBox").fadeOut("normal",function () {
		$("#mask").css('height',"1px");
		});
	return false;
	});

	function slideHide() {
		$("#findPassBox").fadeOut("normal",function () {
		$("#mask").css('height',"1px");
		});
	}
	function  regSuccessTip() {
		$("#mask").css('height',(parseInt(dH)+1+"px"));
		$('#regSuccessBox').fadeIn();
	}

}


if ($('#regSuccessBox').length) {
	$('.a_hideClose').click(function () {
		$("#regSuccessBox").fadeOut("normal",function () {
		$("#mask").css('height',"1px");
		});
	return false;
	});
}

if ($('#loadSuccessBox').length) {
		window.showSuccessBox = function() {
		var dH=$(document).height();
		$("#mask").css('height',(parseInt(dH)+1+"px"));
		$('.drop').hide();
		$('#loadSuccessBox').fadeIn();
	}

	$('.a_hideClose').click(function () {
		$("#loadSuccessBox").fadeOut("normal",function () {
			$('.drop').show();
			$("#mask").css('height',"1px");
		});
	return false;
	});	
}

if ($('#openRegLogin').length) {
		window.showOpenbox = function() {
		var dH=$(document).height();
		$("#mask").css('height',(parseInt(dH)+1+"px"));
		$('.drop').hide();
		$('#openRegLogin').fadeIn();
	}

	window.hideOpenbox = function () {
		$('#openRegLogin').fadeOut("300",function () {
				$('.drop').show();
				$("#mask").css('height',"1px");
		});
	}

	$('#openRegLogin .span_close').click(function () {
		location.href = head_path+'index.php/login/';
		//hideOpenbox();
	});

	$('.h2_openBox span').click(function () {
		var indx = $('.h2_openBox span').index($(this));	
		$('#openRegLogin .div_openG').hide().eq(indx).show();
	});

}







if ($('.div_floatService').length) {
	
	var lastScrollY=0;
	var scrollY,percent;
	var $scrollBox=$(".div_floatService");
	window.scrollC=function() {
		//if ($(window).scrollTop()<100) {$scrollBox.fadeOut();}else{$scrollBox.fadeIn();}

		scrollY=$(window).scrollTop();

		percent=.1*(scrollY-lastScrollY); 
		if(percent>0)percent=Math.ceil(percent); 
		else percent=Math.floor(percent);

		var  objTop=$scrollBox.css('top');
		objTop=parseInt(objTop)+parseInt(percent);
		$scrollBox.css({top:objTop+"px"});
		lastScrollY=lastScrollY+percent; 

	}


	window.setInterval("scrollC()",25);

}






if ($('.onlinebox').length) {

	var lastScrollY=0;
	var scrollY,percent;
	var $scrollBox=$(".onlinebox");
	window.scrollC=function() {
		//if ($(window).scrollTop()<100) {$scrollBox.fadeOut();}else{$scrollBox.fadeIn();}

		scrollY=$(window).scrollTop();

		percent=.1*(scrollY-lastScrollY); 
		if(percent>0)percent=Math.ceil(percent); 
		else percent=Math.floor(percent);

		var  objTop=$scrollBox.css('top');
		objTop=parseInt(objTop)+parseInt(percent);
		$scrollBox.css({top:objTop+"px"});
		lastScrollY=lastScrollY+percent; 

	}

	window.setInterval("scrollC()",25);

	$('.onlinebtn').mouseenter(function () {
		$(this).hide();
		$('.onlinebox').css({'width':'110px'});
		$('.onlineboxshow').show();
		$('.onlinebox .a_totop').hide();
	});

	$('.onlinebox .span_close').click(function () {
		$('.onlineboxshow').hide();
		$('.onlinebox').css({'width':'27px'});
		$('.onlinebtn').show();
		$('.onlinebox .a_totop').show();
	});

	$('.onlineboxshow').mouseleave(function (){
		$('.onlinebox .span_close').trigger('click');
	});

//	$('.dl_online dt').click(function () {
//		var indx = $('.dl_online dt').index($(this));
//		$('.dl_online dd').hide().eq(indx).show();
//	});


}



});




