﻿/*
$(document).pngFix();ie6 png fix
$(this).lightBox();jq lightbox
$(this).fxFile(70);input type="file"
$(this).fxSlide(5, 300, 'v');slide can be vertical'v' or horizontal'h'
$(this).fxCss(target); clone target's css
$(this).mousewheel(function(e, delta){}); mousewheel event
$(this).bgiframe();
getUrlVars()["id"];
getAjaxVars(e)["me"];
--------jq effect
$(this).effect('blind');
blind bounce clip drop explode fade fold highlight pulsate scale shake slide transfer puff
--------jq easing 
$(this).animate({left:''}, 500, 'easeInQuad', callback);
easeInQuad	easeOutQuad	easeInOutQuad	easeInCubic	easeOutCubic	easeInOutCubic	easeInQuart	easeOutQuart	easeInOutQuart	easeInQuint	easeOutQuint	easeInOutQuint	easeInSine	easeOutSine	easeInOutSine	easeInExpo	easeOutExpo	easeInOutExpo	easeInCirc	easeOutCirc	easeInOutCirc	easeInElastic	easeOutElastic	easeInOutElastic	easeInBack	easeOutBack	easeInOutBack	easeInBounce	easeOutBounce	easeInOutBounce
--------share
anteaterAddBookmark("FaceBook");
anteaterAddBookmark("Twitter");
anteaterAddBookmark("Plurk");
--------outside event
clickoutside, dblclickoutside, focusoutside, bluroutside, mousemoveoutside, mousedownoutside, mouseupoutside, mouseoveroutside, mouseoutoutside, keydownoutside, keypressoutside, keyupoutside, changeoutside, selectoutside, submitoutside
--------own selector
$.extend($.expr[':'], {  
    over100pixels: function(a) {  
        return $(a).height() > 100;  
    }  
}); 
*/

var reBanner;
var reBannerId;
var maxreBanner;
var indexTimer;
var indexFadeTime;
var indexLeftNum;
var indexVotePage;
var indexVoteId;
var indexVoteMax;
var accId=0;
$(document).ready(function(){
	/*$(document).mousedown(function(e){
		if(e.which == 3){
			document.title = e.which;
			e.preventDefault();
			return false;
		}
	});*/
	if( $.browser.version == '6.0' && $.browser.msie ){ 
		$('#BG').bgiframe();
		$(document).pngFix();
	};
	$('#Menu > div').hover(function(){
		$(this).children('div').show();
	}, function(){
		$(this).children('div').hide();
	}).children('div').children('a').css({backgroundPosition:'0 0'}).hover(function(){
		$(this).animate({backgroundPosition:'(-165px 0)'}, 300);
	}, function(){
		$(this).animate({backgroundPosition:'(0 0)'}, 300);
	});

	if(id('indexBanner')){
		if(navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)){
			$('#Flash').remove();
			$('#nonFlash').show();
		} else {
			$('#nonFlash').remove();
			$('#Flash').show();
		}
		reBannerId = 0;
		indexTimer = 3000;
		indexFadeTime = 500;
		maxreBanner = $('#reBanner >div').length;
		$('#reBannerPage a').eq(0).addClass('ON');
		$('#reBanner >div').hide().eq(0).show();
		reBanner = setInterval(indexBannerRepeat, indexTimer);
		$('#indexSlide div.aItem a').hover(function(){
			clearInterval(reBanner);
			var _index =  $('#indexSlide div.aItem a').index(this);
			$(this).addClass('ON').children('span').css({width:'100%', height:'120px'});
			$('#bikeBanner').css({height:'443px', overflow:'visible'}).children('div').hide().eq(_index).show().css({left:"-50%", opacity:0}).animate({left:"0%", opacity:1}, 500);
			$('#reBanner').hide();
		}, function(){
			$(this).removeClass().children('span').css({width:'90px', height:'108px'});
			//$('#bikeBanner > div').hide().parent().hide();
		});	
		$('#indexSlide').fxSlide2(8, 300, 'h');
		$('#indexLeftSlide').fxSlide2(3, 300, 'v', 't1');
		/*$('#indexLeftMenu').hover(function(){
			$(this).animate({left:'0px'}, 300);
			$('#indexLeftBtn').css({backgroundPosition:'left top'});
		}, function(){
			$(this).animate({left:'-239px'}, 500);
			$('#indexLeftBtn').css({backgroundPosition:'right top'});
		});*/
		indexLeftNum=1;
		$('#indexBItab > div.btn > a').hide().eq(0).show();
		
		indexVotePage = $('#indexVoteList div.indexVoteLeft > div.voteList').length;
		if( indexVotePage > 5){
			indexVoteId = 0;
			indexVoteMax = Math.floor(indexVotePage/5);
			$('#indexVoteList div.indexVoteLeft > div.voteList:gt(4)').hide();

			//$('#indexVotePage').append('<a href="javascript:;" onclick="indexVotePrev(this);">＜</a>');
			//$('#indexVotePage').append('<a href="javascript:;" onclick="indexVoteMini(this);">《</a>');
			for(var i=0;i < (indexVoteMax+1);i++){
				$('#indexVotePage').append('<a href="javascript:;" onclick="indexVoteNum(this, '+i+')">'+(i+1)+'</a>');
			}
			//$('#indexVotePage').append('<a href="javascript:;" onclick="indexVoteMini(this);">》</a>');
			//$('#indexVotePage').append('<a href="javascript:;" onclick="indexVoteNext(this);">＞</a>');
			
		};
	};
	if( id('scooterBanner') ){
		reBannerId = 0;
		indexTimer = 3000;
		maxreBanner = $('#scooterBannerImg >div').length;
		scooterBanner(null, 0);
		setInterval(function(){
			reBannerId++;
			scooterBanner(null, reBannerId%maxreBanner);
		}, indexTimer);
	}
	if(id('motorinWbtn')){
		motorinHot($('#motorinWbtn'));
		setTimeout(function(){motorinHot($('#motorinWbtn'));}, 2000);
	}
	if( id('cfTopCont')){
		if(getUrlVars()["open"] == 1 ||getUrlVars()["open"] == '1'){
			$('#cfTopCont > div').fxSlide2(5, 500, 'h').hide().eq(1).show();
			$('#cfTopTab > a').removeClass('ON').eq(1).addClass('ON');
		} else {
			$('#cfTopCont > div').fxSlide2(5, 500, 'h').hide().eq(0).show();
		}
		if(getUrlVars()["id"] >= -1 && getUrlVars()["id"]){
			var _this = $('#cfTopCont > div.cfTopSlide').eq(getUrlVars()["open"]).find('div.aItem img').eq(getUrlVars()["id"]);
			var _swf = _this.attr('swf');
			WEB_SITE_HREF = _this.attr('site');
			$('#cfVideoFlash > *').remove();
			$('<object style="height:395px; width:695px">'+
			'<param name="movie" value="'+_swf+'">'+
			'<param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always">'+
			'<embed src="'+_swf+'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="695" height="395">'+
			'</object>').appendTo('#cfVideoFlash');
			$('#cfVideoTitle').text(_this.next().text());
			_this = _swf = null;
		}
		if( getUrlVars()["site"] && getUrlVars()["swf"]){
			$('#cfVideoFlash > *').remove();
			WEB_SITE_HREF = getUrlVars()["site"];
			$('<object style="height:395px; width:695px">'+
			'<param name="movie" value="'+getUrlVars()["swf"]+'">'+
			'<param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always">'+
			'<embed src="'+getUrlVars()["swf"]+'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="695" height="395">'+
			'</object>').appendTo('#cfVideoFlash');
		}
		
	}
	if( id('companysociCont') ){
		$('#companysociCont div.csbImg a').lightBox();
	}
	if( id('dealerTD1') ){
		$('#dealerTD1 tr').live('mouseover mouseout', function(e){
			if(e.type =='mouseover'){
				$(this).children('td').css({backgroundColor:'#CCCCCC'});
			} else if(e.type =='mouseout') {
				$(this).children('td').css({backgroundColor:''});
			};
		});
	}
	if( id('companyinfoBanner') ){
		$('#companyinfoBanner > img.img').hide().eq(0).show();
	};
//	if( id('pageLeftEnd2') ){
//		$('#pageLeftEnd2 .pLeftSubH').click(function(e){
//			if( $(this).next().css('display')=='none' ){
//				$(this).next().show();
//			} else {
//				$(this).next().hide();
//			}
//		}).disableTextSelect();
//	}
	if( id('accDetailPop') ){
		accX1 = accY1 = accpX1 = accpY1 =0;
		$('#accessDSlide').fxSlide2(5, 500, 'h');
		$('#accessLB1').lightBox();
	}
	 
});

$(window).load(function(){

});

function akmPop(DOM, NUM){
	$('#accessBikeMapPopUp').css({left:'0px'}).find('div.pCon > div').hide().eq(NUM).show();
}
function closeAccMapPop(DOM){
	$('#accessBikeMapPopUp').css({left:'100%'});
}
function toInAc4(NUM){
	$('#toMapac4 p').eq(NUM).css({left:'-146px'});
}
function toOutAc4(NUM){
	$('#toMapac4 p').eq(NUM).css({left:'0px'});
}
function toInAc3(NUM){
	$('#toMapac3 p').eq(NUM).css({bottom:'0px', top:'auto'});
}
function toOutAc3(NUM){
	$('#toMapac3 p').eq(NUM).css({top:'0px', bottom:'auto'});
}
function accessBar(DOM, NUM){
	$('#accessBarSelect div.absEach').eq(accId).stop().animate({width:'49px'}, 300).children('div').stop().animate({width:'49px'}, 300).prev().show();
	$(DOM).hide().parent().stop().animate({width:'495px'}, 300).children('div').stop().animate({width:'495px'}, 300);
	accId = NUM;
}
function accessTxtT(DOM){
	if($(DOM).css('left') == '523px' ){
		$(DOM).animate({left:'680px'}, 300, function(){
			//$(this).css({background:'url(images/arrow-8.gif) left center no-repeat'});
		});
	} else {
		$(DOM).animate({left:'523px'}, 300, function(){
			//$(this).css({background:'none'});
		});
	}
}
function accessDimg(DOM, NUM){
	$('#accessDSlide div.aItem a').removeClass('ON');
	$(DOM).addClass('ON').blur();
	$('#accessDImg1 >div').hide().eq(NUM).fadeIn(500);
}
var accpX1;
var accpY1;
var accX1;
var accY1;
function accDp1(DOM, STR){
	if( STR == '-'){
		accpX1+=494;	
	} else {
		accpX1-=494;
	}
	$(DOM).parent().children('div.accPop360').css({backgroundPosition:accpX1+'px 0'});
}
function accD1(DOM, STR){
	if( STR == '-'){
		accX1+=300;	
	} else if(STR == '+') {
		accX1-=300;
	} else {
		accY1 = -STR*220;
	}
	accSpin1();
}
function accSpin1(){
	$('#spinD1').css({backgroundPosition:accX1+'px '+accY1+'px'});
}
function voteDivToList(DOM){
	$('#indexVoteDiv, #indexVoteHis').hide();
	$('#indexVoteList').show();
}
function voteListToDiv(DOM){
	$('#indexVoteHis, #indexVoteList').hide();
	$('#indexVoteDiv').show();
}
function voteHisToList(DOM){
	$('#indexVoteHis, #indexVoteDiv').hide();
	$('#indexVoteList').show();
}
function voteHis(DOM, TITLE, LIST, IMG){
	$('#indexVoteHis').show();
	$('#indexVoteList').hide();
	$('#indexVoteHis > div.indexVoteT>span').text(TITLE);
	$('#indexVoteHis div.indexVoteLeft > *').remove();
	for (var i=0;i<LIST.length;i++){
		$('#indexVoteHis div.indexVoteLeft').append('<div class="voteQuest"><img src="'+LIST[i].img+'" alt="" /><b>'+LIST[i].name+'</b><em><i style="width:'+LIST[i].num+'%"></i></em><span>'+LIST[i].vote+'票</span></div>');	
	}
	$('#indexVoteHis div.indexVoteRight').html('<img src="'+IMG+'" alt="" />');	
}
function indexVoteNum(DOM, NUM){
	indexVoteId = NUM;
	indexVoteNumCal();
}
function indexVoteMini(){
	indexVoteId =0;
	indexVoteNumCal();
}
function indexVoteMax(){
	indexVoteId =indexVoteMax;
	indexVoteNumCal();
}
function indexVoteNext(DOM){
	indexVoteId++;
	indexVoteNumCal();
}
function indexVotePrev(DOM){
	indexVoteId--;
	indexVoteNumCal();
}
function indexVoteNumCal(){
	if( indexVoteId >= indexVoteMax ){
		indexVoteId = indexVoteMax;
	} else if(indexVoteId < 0){
		indexVoteId = 0;
	};
	$('#indexVoteList div.indexVoteLeft > div.voteList').hide().slice(indexVoteId*5, (indexVoteId+1)*5).show();
}
function popWin(DOM){
	$('#BG').css({display:'block', height: $(document).height() +'px'});
	$('#DOT').css({overflow:'visible'}).children('div').hide();
	$(DOM).show();
	if($(window).height() > $(DOM).height()){
		$('#DOT').css({top: ($(window).height() - $(DOM).height())/2 + $(window).scrollTop() +'px'});
	} else {
		$('#DOT').css({top:'0px'});
	}
}
function recallWin(){
	$('#BG').hide();
	$('#DOT').css({overflow:'hidden'});
}
function sociTab(DOM, NUM){
	$(DOM).parent().children('a').removeClass('ON').eq(NUM).addClass('ON');
	$('#companysociCont > div').hide().eq(NUM).show();
	$('#companysociBanner > div.img > img').hide().eq(NUM).fadeIn(300);
}
function philoTab(DOM, NUM){
	$(DOM).parent().children('a').removeClass('ON').eq(NUM).addClass('ON');
	$('#companyphiloCont > div').hide().eq(NUM).show();
}
function parentNode(DOM, CHILDREN, CLASSNAME){
	$(DOM).parent().children(CHILDREN).removeClass(CLASSNAME);
	$(DOM).addClass(CLASSNAME);
}
function locateName(DOM){
	parentNode(DOM, 'a', 'ON');
	//popWin('#dealerPop');
}
function locator(DOM){
	$('#locatorName > a').removeClass('ON').eq($(DOM).children('option').index($(DOM).children('option:selected'))-1).addClass('ON');
//	alert($(DOM).children('option').index($(DOM).children('option:selected')));
}
function companyinfoTab(DOM, NUM){
	$('#companyinfoCont > div').hide().eq(NUM).show();
	$(DOM).parent().children('a').removeClass('ON').eq(NUM).addClass('ON');
	$('#companyinfoBanner > img.img').hide().eq(NUM).fadeIn(300);
}
function cfTab(DOM, NUM){
	$('#cfTopCont > div').hide().eq(NUM).show();
	$(DOM).parent().children('a').removeClass('ON').eq(NUM).addClass('ON');
	var _this = $('#cfTopCont > div.cfTopSlide').eq(NUM).find('div.aItem img').eq(0);
	var _swf = _this.attr('swf');
	WEB_SITE_HREF = _this.attr('site');
	$('#cfVideoFlash > *').remove();
	$('<object style="height:395px; width:695px">'+
	'<param name="movie" value="'+_swf+'">'+
	'<param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always">'+
	'<embed src="'+_swf+'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="695" height="395">'+
	'</object>').appendTo('#cfVideoFlash');
	$('#cfVideoTitle').text(_this.next().text());
	_this = _swf = null;	
}
function cfFlash(DOM, SRC, LINK){
	WEB_SITE_HREF = $(DOM).attr('site');
	$('#cfVideoFlash > *').remove();
	$('<object style="height:395px; width:695px">'+
	'<param name="movie" value="'+$(DOM).attr('swf')+'">'+
	'<param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always">'+
	'<embed src="'+$(DOM).attr('swf')+'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="695" height="395">'+
	'</object>').appendTo('#cfVideoFlash');
	$('#cfVideoTitle').text($(DOM).next().text());

}
function indexLeft(DOM){
	indexLeftNum++;
	if(indexLeftNum%2 == 0){
		$('#indexLeftMenu').animate({left:'0px'}, 300);
		$(DOM).css({backgroundPosition:'left top'});
	} else {
		$('#indexLeftMenu').animate({left:'-239px'}, 500);
		$(DOM).css({backgroundPosition:'right top'});
	}
	$(DOM).blur();
}
function motorinHot(DOM){
	if( $(DOM).parent().css('overflow') == 'hidden' ){
		$(DOM).css({backgroundPosition:'left bottom'}).parent().css({overflow:'visible'}).children('div').hide().slideDown(300);
	} else {
		$(DOM).css({backgroundPosition:'left top'}).parent().children('div').slideUp(300, function(){$(this).parent().css({overflow:'hidden'})});
	}
}
function scooterBanner(DOM, NUM){
	$('#scooterBannerPage a').removeClass().eq(NUM).addClass('ON');
	$('#scooterBannerImg > div').hide().eq(NUM).fadeIn(300);
}
function indexTab(DOM, NUM){
	$(DOM).parent().children('a').removeClass('ON');
	$(DOM).addClass('ON').blur().parent().next().children('a').hide().eq(NUM).show();
	$('#indexBIcon > div').hide().eq(NUM).show();
}
function Opendiv(){
	indexFoot($('#indexFootIn'));
}
function indexFoot(DOM){
	if( $('#indexFootIn').css('display') == 'none' ){
		$('#indexFootIn').slideDown(300);
		$(DOM).children('a').css({backgroundPosition:'left bottom'});
	} else {
		$('#indexFootIn').slideUp(300);
		$(DOM).children('a').css({backgroundPosition:'left top'});
	}
}
function indexBannerRepeat(){
	reBannerId++;
	$('#reBannerPage').find('a').removeClass().eq(reBannerId%maxreBanner).addClass('ON');
	$('#reBanner >div').hide().eq(reBannerId%maxreBanner).fadeIn(indexFadeTime);
}
function indexBanner(DOM, NUM){
	$(DOM).parent().parent().find('a').removeClass().eq(NUM).addClass('ON');
	reBannerId = NUM;
	$('#reBanner').show();
	$('#reBanner >div').hide().eq(reBannerId).fadeIn(indexFadeTime);
	$('#bikeBanner > div').hide().parent().css({height:'0px', overflow:'hidden'});
	clearInterval(reBanner);
	reBanner = setInterval(indexBannerRepeat, indexTimer);
}
function mOver1(DOM){
	$(this).css({backgroundPosition:'(0px 0px)'}).animate({backgroundPosition:'(-200px 0px)'}, 500);
}
function mOut1(DOM){
	$(this).animate({backgroundPosition:'(0px 0px)'}, 500);
}
function id(STR){
	return document.getElementById(STR);
}
jQuery.fn.extend({
	fxSlide2: function (showAtOnce, animateSpeed, fxDirect, SORT){
		$(this).each(function(){
			if (!fxDirect) {
				alert('fxSlide error (showAtOnce『1,2,3』, animateSpeed『10,100,1000』, fxDirect『"h" or "v"』)');
			};
			var _this = $(this);
			var itemNum = $('.aItem > div', _this).length;
			
			var maxId = itemNum - showAtOnce;
			var itemWidth;
			var cId = 0;
			
			if(fxDirect == 'h'){
				itemWidth = $('.aItem > div', _this).outerWidth(true);
				$('.aItem', _this).css({width : itemWidth * itemWidth + 10 + "px"});
			} else if(fxDirect == 'v') {
				itemWidth = $('.aItem > div', _this).outerHeight(true);
				$('.aItem', _this).css({height : itemWidth * itemWidth + 10 + "px"});
			};
			var slideWidth = itemNum * itemWidth;
			
			if (itemNum <= showAtOnce){
				$('.aLeft > a', _this).remove();
				$('.aRight > a', _this).remove();
			} else {
				/*_this.mousewheel(function(e, delta){
					if(delta > 0){
						cId--;
					} else if (delta < 0){
						cId++;
					};
					sliding (cId);
					return false;
				});*/
			};
			$('.aLeft > a', _this).click(function () {
				cId --;
				sliding (cId);
				$(this).blur();
				return false;
			});
			$('.aRight > a', _this).click(function () {
				cId ++;
				sliding (cId);
				$(this).blur();
				return false;
			});
			function sliding (SID, NUM){
				if(cId >= maxId && maxId > 0) {
					$('.aRight > a', _this).hide();
					$('.aLeft > a', _this).show();
					cId = maxId;
				} else if(cId <= 0) {
					$('.aRight > a', _this).show();
					$('.aLeft > a', _this).hide();
					cId = 0;
				} else {
					$('.aRight > a, .aLeft > a', _this).show();
				};
				if (fxDirect == 'h') $('.aItem', _this).stop().animate( { marginLeft: - itemWidth * cId + "px" }, animateSpeed);
				if (fxDirect == 'v') $('.aItem', _this).stop().animate( { marginTop: - itemWidth * cId + "px" }, animateSpeed);
				if( NUM != 1){
					$('.aItem > div', _this).eq(cId).children('div').each(function(i){
						$(this).css({position:'relative', top:'150px', left:'150px', opacity:0}).delay(i*50).animate({left:'0px', top:'0px', opacity:1}, 500, function(){$(this).css({position:'static'});});
					});
				}
				$('#indexPage > a').removeClass().eq(cId).addClass('on');
				if( SORT == 't1'){
					$('#indexLeftBtn').one('click', function(){
						setTimeout(function(){
							cId = maxId;
							sliding()
						}, 500);
						
					});
				};
				
			};
			sliding(cId, 1);
			$('#indexPage > a').click(function(){
				cId = $('#indexPage > a').index(this);
				sliding();
				return false;
			});
			
		});
		return this;
	}, 	fxSlide3: function (showAtOnce, animateSpeed, fxDirect){
		$(this).each(function(){
			if (!fxDirect) {
				alert('fxSlide error (showAtOnce『1,2,3』, animateSpeed『10,100,1000』, fxDirect『"h" or "v"』)');
				return false;
			};
			var _this = $(this);
			var itemNum = $('.aItem > div', _this).length;
			
			var maxId = itemNum - showAtOnce;
			var itemWidth;
			var cId = 0;
			
			if(fxDirect == 'h'){
				itemWidth = $('.aItem > div', _this).outerWidth(true);
				$('.aItem', _this).css({width : itemWidth * itemWidth + 10 + "px"});
			} else if(fxDirect == 'v') {
				itemWidth = $('.aItem > div', _this).outerHeight(true);
				$('.aItem', _this).css({height : itemWidth * itemWidth + 10 + "px"});
			};
			var slideWidth = itemNum * itemWidth;
			
			if (itemNum <= showAtOnce){
				$('.aLeft > a', _this).remove();
				$('.aRight > a', _this).remove();
			} else {
				/*_this.mousewheel(function(e, delta){
					if(delta > 0){
						cId--;
					} else if (delta < 0){
						cId++;
					};
					sliding (cId);
					return false;
				});*/
			};
			$('.aLeft > a', _this).click(function () {
				cId --;
				sliding (cId);
				$(this).blur();
				return false;
			});
			$('.aRight > a', _this).click(function () {
				cId ++;
				sliding (cId);
				$(this).blur();
				return false;
			});
			function sliding (SID, NUM){
				if(cId >= maxId && maxId > 0) {
					$('.aRight > a', _this).hide();
					$('.aLeft > a', _this).show();
					cId = maxId;
				} else if(cId <= 0) {
					$('.aRight > a', _this).show();
					$('.aLeft > a', _this).hide();
					cId = 0;
				} else {
					$('.aRight > a, .aLeft > a', _this).show();
				};
				if (fxDirect == 'h') $('.aItem', _this).stop().animate( { marginLeft: - itemWidth * cId + "px" }, animateSpeed);
				if (fxDirect == 'v') $('.aItem', _this).stop().animate( { marginTop: - itemWidth * cId + "px" }, animateSpeed);
				$('#indexPage > a').removeClass().eq(cId).addClass('on');
			};
			sliding(cId, 1);
			$('#indexPage > a').click(function(){
				cId = $('#indexPage > a').index(this);
				sliding();
				return false;
			});
		});
	}, fxScroll: function(){
		$(this).each(function(){
			var thisBar = $('div.aBar', this);
			var thisBody = $('div.scrollBody', this);
			var thisBarDiv = thisBar.children('div'); 
			var miniSpace = thisBarDiv.height() / 2;
			var maxSpace = thisBar.height() - miniSpace;
			var trueMax = maxSpace-miniSpace;
			var heightDiff;
			if(($(this).height()) < thisBody.height()){
				//thisBar.hide().slideDown(500);
				heightDiff = thisBody.height() - $(this).height();
			} else {
				thisBar.hide();
			};
			//var pressX;
			var pressY;
			thisBar.mousedown(function(de){
				pressY = thisBar.offset().top;
				scrolling(de);
				$('body').bind('mousemove', scrolling);
				return false;
			});
			$('body').mouseup(function(){
				$('body').unbind('mousemove', scrolling);
			});
			var moveY;
			var moveAmount;
			var convert;
			function scrolling (e){
				moveY = e.pageY;
				if((moveY - pressY) > maxSpace){
					moveAmount = maxSpace;
				} else if((moveY - pressY) < miniSpace){
					moveAmount = miniSpace;
				} else {
					moveAmount = (moveY - pressY);
				};
				thisBarDiv.css({top:moveAmount-miniSpace+'px'});
				convert = (moveAmount-miniSpace) / trueMax * heightDiff;
				thisBody.css({top:-convert+'px'});
				//document.title='moveY/'+moveY+'/moveAmount/'+moveAmount+'/miniSpace/'+miniSpace +'/maxSpace/'+maxSpace+'/heightDiff/'+heightDiff+'/pressY/'+ pressY;
				return false;
			};
		});
		return this;
	}, disableTextSelect : function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
    }
});

function fxCirSlide(DOM) {
	var _this = $(DOM);
	var _thisAR = $('.htmlArray', _this);
    var maxDivision = $('.tvcfCenter > div', _this).length;
	var cHigher = 100;//current target higher X axis
	var smallCwidth = 200;
	var bigCwidth = 300;
    var radiusX = 200;
    var radiusY = 80;
    var cPI = Math.PI * 2 / 4;
    var xPI = Math.PI * 2 / maxDivision;
    var dId = 0;
	var cArray = new Array();
    $('.tvcfCenter > div', _this).each(function(i) {
        var seta = xPI * i + cPI;
        var tY = Math.floor((Math.sin(seta)) * radiusY);
        var tX = Math.floor((Math.cos(seta)) * radiusX);
        var opa = Math.floor((tY + (radiusY + (radiusY*0.1))) / (radiusY*2) * 1000) / 1000;
		var cObj;
        if (i != 0) {
			cObj = {
				ty: tY,
				tx: tX,
				wid: smallCwidth,
				zin:Math.floor(tY),
				opa:opa,
				ord:i
			};/*
            $('<b ty="' + tY + '" tx="' + tX + '" wid="' + smallCwidth + '" zin="' + Math.floor(tY) + '" opa="' + opa + '"></b>').appendTo(_thisAR);*/
            $(this).css({ zIndex: Math.floor(tY), top: tY + 'px', left: tX + 'px' });
            $('img', this).css({ width: smallCwidth + 'px' });
            $('a', this).css({ left: -(smallCwidth/ 2) + 'px', opacity: opa });
        } else {
			cObj = {
				ty: tY-cHigher,
				tx: tX,
				wid: bigCwidth,
				zin:Math.floor(tY),
				opa:opa,
				ord:i
			};/*
            $('<b ty="' + (tY - 100) + '" tx="' + tX + '" wid="' + bigCwidth + '" zin="' + Math.floor(tY) + '" opa="' + opa + '"></b>').appendTo(_thisAR);**/
            //$(this).css({zIndex:Math.floor(tY), top:tY - 100 +'px', left:tX+'px', width:'222px'});
            $(this).css({ zIndex: Math.floor(tY), top: tY - 100 + 'px', left: tX + 'px' });
            $('img', this).css({ width: bigCwidth + 'px' });
            $('a', this).css({ width: -(bigCwidth/2) + '0px', opacity: opa });
        };
		cArray.push(cObj);
    });
	$('.aNum i', _this).text( cArray[0].ord + 1 + ' / '+ maxDivision);
    $('.aLeft', _this).click(function() {
        //$('.htmlArray b:last-child').prependTo(_thisAR);
		cArray.unshift( cArray.pop() );
        run3D();
        $(this).blur();
        return false;
    });
    $('.aRight', _this).click(function() {
        //$('.htmlArray b:first-child').appendTo(_thisAR);
		cArray.push( cArray.shift() );
        run3D();
        $(this).blur();
        return false;
    });
    $(_this).mousewheel(function(e, delta) {
        if (delta > 0) {
            //$('b:last-child', _thisAR).prependTo(_thisAR);
			cArray.unshift( cArray.pop() );
        } else {
            //$('b:first-child', _thisAR).appendTo(_thisAR);
			cArray.push( cArray.shift() );
        };
        run3D();
        return false;
    });
    function run3D() {
        $('.tvcfCenter > div', _this).each(function(j) {/*
            $(this).stop().animate({
                top: $('.htmlArray b').eq(j).attr('ty') + 'px',
                left: $('.htmlArray b').eq(j).attr('tx') + 'px'
            }, 300).css({ zIndex: $('b', _thisAR).eq(j).attr('zin') });
            $('img', this).stop().animate({ width: $('b', _thisAR).eq(j).attr('wid') + 'px' }, 200);
            $('a', this).stop().animate({ left: -($('b', _thisAR).eq(j).attr('wid') / 2) + 'px', opacity: $('b', _thisAR).eq(j).attr('opa') }, 200);*/
            $(this).stop().animate({
                top: cArray[j].ty + 'px',
                left: cArray[j].tx + 'px'
            }, 300).css({ zIndex: cArray[j].zin });
            $('img', this).stop().animate({ width: cArray[j].wid + 'px' }, 200);
            $('a', this).stop().animate({ left: -( cArray[j].wid / 2) + 'px', opacity: cArray[j].opa }, 200);
        });
		$('.aNum i', _this).text( cArray[0].ord + 1 + ' / '+ maxDivision);
    };
	
};

var WEB_SITE_HREF="";
var WEB_SITE_TITLE="";
var FAVORITES="Favorites";
var FACEBOOK="FaceBook";
var GOOGLE="Google";
var PLURK="Plurk";
var SINA="Sina";
var TWITTER="Twitter";
var QQ="QQ";
var HAPPY="Happy";
var SO="So";
var REN = "Ren";
var ICON_IMAGE_PATH="images/anteaterBookmark/";
var FILE_NAME_EXTENSION=".png";
var bookmarkList=[FAVORITES,SINA,QQ,HAPPY,SO,REN,FACEBOOK,GOOGLE,PLURK,TWITTER];
function getBookmarkList(){return bookmarkList;}
function getBookmarkListIcon(){var _array=bookmarkList.concat();for(var i=0;i<_array.length;i++){_array[i]=ICON_IMAGE_PATH+_array[i]+FILE_NAME_EXTENSION;};return _array;};
function anteaterAddBookmark(pType){
	var _locationHref=(WEB_SITE_HREF=="")?window.location.href:WEB_SITE_HREF;
	_locationHref=encodeURIComponent(_locationHref);var _title=(WEB_SITE_TITLE=="")?document.title:WEB_SITE_TITLE;
	_title=encodeURIComponent(_title);var _href;
	switch(pType){
	case FAVORITES:
		anteaterAddFavorites();
		return;
		break;
	case SINA:
		_href="http://v.t.sina.com.cn/share/share.php?url="+_locationHref+"&title="+_title;
		break;
	case QQ:
		_href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+_locationHref+"&title="+_title;
		break;
	case HAPPY:
		_href="http://www.kaixin001.com/repaste/share.php??rurl="+_locationHref+"&rtitle="+_title;
		break;
	case SO:
		_href="http://t.sohu.com/third/post.jsp?url="+_locationHref+"&title="+_title;
		break;
	case REN:
		_href = "http://share.renren.com/share/buttonshare.do?link="+_locationHref+"&title="+_title;
		break;
		
	case FACEBOOK:
		_href="http://www.facebook.com/sharer.php?u="+_locationHref+"&title="+_title;
		break;
	case GOOGLE:
		_href="http://www.google.com/bookmarks/mark?op=add&bkmk="+_locationHref+"&title="+_title;
		break;
	case PLURK:
		_href="http://www.plurk.com/?qualifier=shares&status=".concat(_locationHref).concat(' ').concat('(').concat(_title).concat(')');
		break;
	case TWITTER:
		_href="http://twitter.com/home/?status="+_title+" "+_locationHref;
		break;
	};
	window.open(_href,"_blank");return false;
};
function anteaterAddFavorites(){var _title=(WEB_SITE_TITLE=="")?document.title:WEB_SITE_TITLE;var _locationHref=(WEB_SITE_HREF=="")?window.location.href:WEB_SITE_HREF;if(window.sidebar&&window.sidebar.addPanel){window.sidebar.addPanel(_title,_locationHref,'');}else if(window.external){window.external.AddFavorite(_locationHref,_title);}else if(document.layers){window.alert('Please click OK then press Ctrl+D to create a bookmark');}else{window.alert('Please use your browsers\' bookmarking facility to create a bookmark');}};

