/*encode: utf-8*/
var Module=Module||{};

var module=function(moduleId){
	this.elmId=moduleId;
	return this;
};
/**
标签页的页面结构说明?
* 将id(例如: 'm_sample_01') 添加到div.md ?
* 在div.md_hd 中添加ul.mh_tabs，并添加id+'_tabs' (例如: 'm_sample_01_tabs')
* 在div.md_bd 中添加和标签一样多的div，并给它们添加id，id 命名?div.md 中的id+'_content_x'(例如: 'm_sample_01_content_1' ~ ) 其中x 是这些div 的序号，? 开始。除了第一个，其他几个都添加style="display: none;" 属?
添加脚本?
* (new module('m_sample_01')).initTabs();
*/
module.prototype.initTabs=function(){
		this.tabsId=this.elmId+'_tabs';
		this.contentIdPreText=this.elmId+'_content_';
		(new Module.Tabs(this.tabsId, this.contentIdPreText)).init();
	};
module.prototype.initTabsHover=function(){
		this.tabsId=this.elmId+'_tabs';
		this.contentIdPreText=this.elmId+'_content_';
		(new Module.Tabs(this.tabsId, this.contentIdPreText)).initHover();
	};

Module.Tabs=function(nodeId, contentIdPreText){
	if((!nodeId)||(!(Dom.$id(nodeId)))){return null;}
	var selfObj=this;
	this.elmId=nodeId;
	this.contentIdPreText=contentIdPreText;
	this.eTabBox=Dom.$id(nodeId);
	this.eTabs=this.eTabBox.getElementsByTagName('li');//eTab -> li tag
	this.tabNum=this.eTabs.length;
	this.curTabIndex=0;
	this.targetTabIndex=0;
	this.content=[];
	var i,j,k;

	this.changeContent=function(curIndex, targetIndex){
		this.content[curIndex].style['display']='none';
		this.content[targetIndex].style['display']='';
	};

	this.chgTab=function(){
try{
		if(this.curTabIndex==this.targetTabIndex){return;}
		Dom.removeClass('cur', this.eTabs[this.curTabIndex]);
		Dom.addClass('cur', this.eTabs[this.targetTabIndex]);
		var temC=this.curTabIndex;
		var temT=this.targetTabIndex;
		this.curTabIndex=this.targetTabIndex;
		this.changeContent(temC, temT);
}catch(e){}
	};
	this.init=function(){
		for(i=0; i<this.eTabs.length; i++){
			var ttTab=this.eTabs[i];
			if(Dom.hasClass("cur", ttTab)){
				this.curTabIndex=this.targetTabIndex=i;
			}
			this.content[i]=Dom.$id(this.contentIdPreText+(i+1));
			var ttLink=ttTab.getElementsByTagName('a')[0];
			ttLink.setAttribute('i',i);
			ttLink.onclick=function(ev){
				this.blur();
				selfObj.targetTabIndex=this.getAttribute('i');
				selfObj.chgTab();
				return false;
			};
		}
	};
	this.initHover=function(){
		for(i=0; i<this.eTabs.length; i++){
			var ttTab=this.eTabs[i];
			if(Dom.hasClass("cur", ttTab)){
				this.curTabIndex=this.targetTabIndex=i;
			}
			this.content[i]=Dom.$id(this.contentIdPreText+(i+1));
			var ttLink=ttTab.getElementsByTagName('a')[0];
			ttLink.setAttribute('i',i);
			ttLink.onmouseover=function(ev){
				selfObj.targetTabIndex=this.getAttribute('i');
				selfObj.chgTab();
				return false;
			};
		}
	};
	return selfObj;
};

/**
集合: kPage
更新: 10:24 2007-2-27
功能: 页面操作相关
函数列表: 
	fixColsHeight(col, opt) 对齐页面模块
	initFixColsHeight(opt) 调用[对齐页面模块]来对其所有模?
	
*/

var kPage={
	fixColsHeight: function(col, opt){
		var maxH=0;
		var maxHi=0;
		var heights=[];
		var cols=[];
		var col1=Dom.$tagHasClassInNodeChild('div', 'col_1', col);
		var col2=Dom.$tagHasClassInNodeChild('div', 'col_2', col);
		var col3=Dom.$tagHasClassInNodeChild('div', 'col_3', col);
		var col4=Dom.$tagHasClassInNodeChild('div', 'col_4', col);
		if(col1.length){
			cols[0]=col1[0];
		}
		if(col2.length){
			cols[1]=col2[0];
		}
		if(col3.length){
			cols[2]=col3[0];
		}
		if(col4.length){
			cols[3]=col4[0];
		}
		if(cols.length==1){
			return;
		}
		col1=col2=col3=col4=null;
		for(var i=0; i<cols.length; i++){
			var h=cols[i].offsetHeight;
			if(h>maxH){
				maxH=h;
				maxHi=i;
			}
			heights.push(h);
		}
		for(var i=0; i<cols.length; i++){
			var mds=Dom.$tagHasClassInNodeChild('div', 'md', cols[i]);
			if(!mds || !mds.length){
				continue;
			}
			var hs=maxH-heights[i];
			var dToFix=null;
			
			if(!opt || (typeof opt!='object')){//修正md
				dToFix=mds[mds.length-1];//每列中最后一个md
			}else{
				if(opt.fixElm){
					if(opt.fixElm=='md'){
						dToFix=mds[mds.length-1];//每列中最后一个md
					}else if(opt.fixElm=='md_bd'){//修正md_bd
						dToFix=Dom.$tagHasClassInNodeChild('div', 'md_bd', mds[mds.length-1])[0];
					}
				}
			}
			if(dToFix==null){
				dToFix=Dom.$tagHasClassInNodeChild('div', 'md_bd', mds[mds.length-1])[0];
			}
			var hCur=dToFix.offsetHeight;
			var temStyle=kStyle.getRealStyle(dToFix);
			var fixH=0;
			fixH+=isNaN(parseInt(temStyle.borderTopWidth))?0:parseInt(temStyle.borderTopWidth);
			 fixH+=isNaN(parseInt(temStyle.borderBottomWidth))?0:parseInt(temStyle.paddingTop);
			 if(isNaN(fixH)){fixH=0};
			 fixH+=isNaN(parseInt(temStyle.paddingTop))?0:parseInt(temStyle.paddingTop);
			 fixH+=isNaN(parseInt(temStyle.paddingBottom))?0:parseInt(temStyle.paddingBottom);
			if(isNaN(fixH)){fixH=0};
			hCur=hCur-fixH;
			dToFix.style['height']=(hCur+hs)+"px"
		}
	},
	initFixColsHeight: function(opt){
		var pageBody=Dom.$id('page_body');
		if(!pageBody){return;}
		var pageCols=Dom.$tagHasClassInNodeChild('div', 'column_wrapper', pageBody);
		for(var i=0; i<pageCols.length; i++){
			try{
				kPage.fixColsHeight(pageCols[i], opt);
			}catch(er){}
		}
	}
};

/*add by jay @ 2007-06-20 10:35*/
function initDropDown(elmId, tagName){
	if(document.all && elmId && tagName){
		$('#' + elmId + ' ' + tagName).hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
	}
}
/**
模块: 图像浏览[imageView]
更新: 10:26 2007-2-27
参数: 
	@param  elmId{String|Dom node}  要添加动画的element
	@param  opt{Object}  一些属性设?
返回? {Object}
功能: 缩略图滚?水平)浏览，点击大图切?
*/

function ImageView(elmId, opt){
	var elmRoot;
	if(typeof elmId === 'string'){
		elmRoot= $('#'+elmId);
	}else{
		elmRoot= $(elmId);
	}
	if(!elmRoot.length){return;}
	var scrollSpeed= 2;// 1s/500px 单位 ms/px
	var scrollPropName= 'left',
		scrollH= true,
		itemSizePropName= 'offsetLeft',
		viewAreaSizePropName= 'width';
	if(opt){
		('layout' in opt) && (opt.layout === 'v') && (scrollH= false);
	}
	
	if(!scrollH){
		scrollPropName= 'top';
		itemSizePropName= 'offsetTop';
		viewAreaSizePropName= 'height';
	}
	var scrollPart= elmRoot.children('div.pic_list_box'),
		items= scrollPart.find('li'),//所有图片框的集?
		itemNum= items.length,

		scroller= items.parent(),//存放图片的ul, 滚动动画就是靠控制它的位置来实现?滚动的整?
		scrollerW= scroller.parent(),
		item0= items[0],
		itemCur,
		itemSize= items[1][itemSizePropName]- item0[itemSizePropName],
		viewAreaSize= scrollPart[viewAreaSizePropName]()-56;
	
	scrollerW.css(viewAreaSizePropName, viewAreaSize);
	
	if(scrollH){
		
	}else{
		scrollPart.css('overflow', 'hidden');
	}
	
	scroller.css('position', 'relative');
	
	var totalScrollSize= itemSize * itemNum;
	
	// 计算每次翻页的个?
	var scrollPageNum= Math.floor(viewAreaSize/itemSize),
		totalPageNum= Math.ceil(itemNum/scrollPageNum),
		scrollDuration= scrollSpeed * scrollPageNum * itemSize,
		curPageNum= 0;
	
	var dataShowPart= elmRoot.children('div.text_box');//大图片显示区?
	
	//console.log(dataShowPart);return;
	
	var dataShowPic= dataShowPart.find('img'),
		dataShowTxt= dataShowPart.find('div.text_data');
	
	var btnPrev= scrollPart.children('a.previous'),
		btnNext= scrollPart.children('a.next');
	
	function _scroll(){
		var scrollProp= {};
		scrollProp[scrollPropName]= -items[scrollPageNum * curPageNum][itemSizePropName];// 目标位置应该?目标页的第一?item 的左坐标
		scroller.animate(scrollProp, {"duration": scrollDuration});
	}
	
	// 翻页按钮
	btnPrev.click(function(){//图像选择列表  前n 张，需要向左移动，则style.left 应该减小
		this.blur();
		if(curPageNum > 0){
			curPageNum--;
			_scroll();
		}
		return false;
	});
	btnNext.click(function(){//图像选择列表  前n 张，需要向左移动，则style.left 应该减小
		this.blur();
		if(curPageNum < (totalPageNum - 1)){
			curPageNum++;
			_scroll();
		}
		return false;
	});
	
	var datas= {};
	
	items.each(function(i, _item){
			_item= $(_item);
			_item.hover(function(){_item.addClass('hover')}, function(){_item.removeClass('hover')});
			_item.click(function(){
					itemCur && itemCur.removeClass('cur');
					itemCur= _item;
					_item.addClass('cur');
					dataShowPic.attr('src', itemData.img.attr('href')).parent().attr('href', itemData.img.attr('title'));
					dataShowTxt.html(itemData.txt);
					return false;
				});
			
			(!itemCur) && (_item.attr('class').indexOf('cur') !== -1) && (itemCur= _item);
			
			datas[_item]= {};// 这样?key 不知是否会有问题
			var itemData= datas[_item];
			itemData.img= _item.children('a');
			itemData.txt= _item.children('div.hide').html();
			_item.children('div.hide').remove();
		});
}

function imageView(elmId, opt){
	$(function(){
		new ImageView(elmId, opt);
	});
}

function imageView_v(elmId, opt){
	$(function(){
		new ImageView(elmId, {'layout': 'v'});
	});
}

/**
图像(渐隐渐显)浏览
*/
function image_transform(_rootId){
	var elms=Dom.$tagHasClassInNodeChild("div", "image_list_box", Dom.$id(_rootId));
	var timer=null, curI=0, transformElmToHide=null, transformElmToShow=null;
	var isChanging=false;
	var elmToShow=elms[0];
	var htmls=[];
	if(0 && Base.isIE() && (window.createPopup)){
		elmToShow.style.filter="revealTrans(duration=2,transition=18)";
	}
	for(var i=0; i<elms.length; i++){
		if(i!=0){
			kStyle.setAtt(elms[i], 'display', 'none');
		}
		htmls[i]=elms[i].innerHTML;
	}
	elmToShow.innerHTML=htmls[0];
	function chgTo(_ti){
		timeStart=new Date();
		if(0 && Base.isIE() && (window.createPopup)){
			curI=_ti;
			elmToShow.filters[0].Transition=Math.floor(Math.random()*23);
			elmToShow.filters[0].apply();
			elmToShow.innerHTML=htmls[_ti];
			elmToShow.filters[0].play();
		}else{
			if(curI==_ti){
				return;
			}
			var ci=curI;
			curI=_ti;
			var temp1=parseFloat(kStyle.getAtt(elmToShow, 'opacity'));
			animateOpac(timer, elmToShow, temp1, 0, Math.round(500*temp1),
								function(){
									elmToShow.innerHTML=htmls[_ti];
									var temp1=parseFloat(kStyle.getAtt(elmToShow, 'opacity'));
									animateOpac(timer, elmToShow, temp1, 1, Math.round(300*(1-temp1)));
								});
		}
	}
	/*S func animateOpac*/
	function animateOpac(timer, _elm, v1, v2, duration, whenDone){
		clearInterval(timer);
		timer=null;
		var scrollStart=false;
		var startTime=null;
		timer=setInterval(animate, 1000/kAnimator.FPS);
		function animate(){
			if(scrollStart){
				var now=new Date();
				var percent=parseFloat((now-startTime)/duration);
				var sl=v1+(v2-v1)*percent;
				if(percent<0.99999){
					try{
						kStyle.setAtt(_elm, 'opacity', sl);
					}catch(er){}
				}else{
					clearInterval(timer);
					timer=null;
					kStyle.setAtt(_elm, 'opacity', v2);
					scrollStart=false;
					if(whenDone && (typeof whenDone=='function')){
						whenDone();
					}
				}
			}else{
				scrollStart=true;
				startTime=new Date();
			}
		}
		/*E func scroll*/
	}
	
	var timeStart=new Date();
	setInterval(function(){
						if(((new Date()).getTime()-timeStart.getTime())>5000){
							var ti=curI+1;
							if(ti==elms.length){
								ti=0;
							}
							chgTo(ti);
						}
					   }, 1000/(kAnimator.FPS||30));
	/*E func animateOpac*/
}
/**
模块: 图像水平滚动[imageScroll]
更新: 10:26 2007-2-27
参数: 
	@param  elm{String|Dom node}  需要添加滚动效果的模块 id
	@param  opt{Object}  动画效果的一些设?
返回? {Object}
功能: 将图片列表滚动起?水平滚动)
页面结构限制: 
	?div.image_list_box 之外添加id
	每个id 下面只能? 个ul
	每个ul 下面的图片必须足够多(不能? 行完全显?才会滚动
*/

function ImageScroll(elmId, opt){
	var elmRoot;
	if(typeof elmId === 'string'){
		elmRoot= $('#'+elmId);
	}else{
		elmRoot= $(elmId);
	}
	if(!elmRoot.length){return;}
	var scrollDir= 'l';
	var scrollSpeed= 15;//1000/50 单位 ms/px
	var scrollPropName= 'left',
		itemSizePropName= 'offsetLeft',
		viewAreaSizePropName= 'width';

	var aviableDir= {'l':'l',
					 'left':'l',
					 'r':'r',
					 'right':'r',
					 'b':'b',
					 'bottom':'b',
					 't':'t',
					 'top':'t'};
	if(opt){
		('dir' in opt) && (opt.dir in aviableDir) && (scrollDir = aviableDir[opt.dir]);
	}
	var scrollH= (scrollDir === 'r' || scrollDir === 'l');
	if(!scrollH){
		scrollPropName= 'top';
		itemSizePropName= 'offsetTop';
		viewAreaSizePropName= 'height';
	}

	var items= elmRoot.find('ul > li'),//所有图片框的集?
		itemNum= items.length,

		scroller= items.parent(),//存放图片的ul, 滚动动画就是靠控制它的位置来实现?滚动的整?
		scrollerW= scroller.parent(),
		item0= items[0],
		itemSize= items[1][itemSizePropName] - item0[itemSizePropName],//一个图片框的宽?
		viewAreaSize= scrollerW[viewAreaSizePropName]();

	if(scrollH && (scroller.height() < (1.2 * items.height()))){//如果没有2 行，则返?
		return;
	}

	if(scrollH){
		scrollerW.css({ 'width':viewAreaSize,
						'position':'relative',
						'overflow':'hidden'});
		scroller.css({'width':9999, 'position':'relative'});
	}else{
		elmRoot.css('overflow', 'hidden');
		scroller.css('position', 'relative');
	}

	$.each(items.slice(0, Math.ceil(viewAreaSize / itemSize)),
			 function(i, _item){
				 scroller.append(_item.cloneNode(true));
			 });
	items= scroller.children('li');
	var scrollArea= [0, -items[itemNum][itemSizePropName]];
	// 如果是向 ?或是 ?滚动，则互换滚动值域
	if(scrollDir === 'r' || scrollDir === 'b'){
		scrollArea[2]= scrollArea[0];
		scrollArea[0]= scrollArea[1];
		scrollArea[1]= scrollArea[2];
		scrollArea.length= 2;
	}

	function getScrollDuration(){
		return Math.abs(scrollSpeed * ((parseInt(scroller.css(scrollPropName), 10) || 0) - scrollArea[1]));
	}
	// 这个地方比较诡异，需要注?
	var scrollProp= {};
	scrollProp[scrollPropName]= scrollArea[1];
	scroller.css(scrollPropName, scrollArea[0]);
	function _scroll(){
		scroller.animate(scrollProp,
						 {"duration": getScrollDuration(),
						  "easing": "linear",
						  'complete': function(){scroller.css(scrollPropName, scrollArea[0]);_scroll();}
						 });
	}
	function startScroll(start){
		scroller.stop();
		// 明确给定?start ?start
		(start === true) && _scroll();
	}
	scrollerW.hover(startScroll, function(){startScroll(true);});
	startScroll(true);
}

function imageScroll(elmId, opt){
	$(function(){
		new ImageScroll(elmId, opt);
	});
}
function imageScrollV(elmId, opt){
	$(function(){
		if(!opt || !('dir' in opt)){
			opt= {'dir': 't'};
		}
		new ImageScroll(elmId, opt);
	});
}
/**
模块: 图像(水平翻页)滚动[imagePageView]
更新: 10:26 2007-2-27
参数: 
	@param  elm{String|Dom node}  需要添加滚动效果的模块
	@param  opt{Object}  动画效果的一些设?
返回? {Object}
功能: 将图片列表滚动起?水平滚动)
页面结构限制: 
	?div.image_list_box 之外添加id
	每个id 下面只能? 个ul
	每个ul 下面的图片必须足够多(不能? 行完全显?才会滚动
*/
function imagePageView(elmId, opt){
	new imagePageView_build(elmId, opt);
}
function imagePageView_build(elmId, opt){
	var me=this;
	this.elmId=elmId;
	this.elmRoot=Dom.$id(elmId);
	if(!this.elmRoot){return false;}
	if(opt){//如果带了配置，则读取
	}
	var elmListW=Dom.$tagHasClassInNodeChild('div', 'image_list_box', this.elmRoot)[0];//动画显示的范?
	this.lists=Dom.$tagInNode('li', elmListW);//所有图片框的集?
	this.listsLen=this.lists.length;//图片总数
	var list_0=this.lists[0];//第一张图?
	var list_0_style=kStyle.getRealStyle(list_0);
	this.elmList=list_0.parentNode;//存放图片的ul, 滚动动画就是靠控制它的位置来实现?滚动的整?
	this.listSize=[
		this.lists[1].offsetLeft-this.lists[0].offsetLeft,
		list_0.offsetHeight+parseInt(list_0_style.marginTop)+parseInt(list_0_style.marginBottom)
	];//一个图片框的尺寸[width, height]
	if(this.elmList.offsetHeight<(2 * this.lists[0].offsetHeight)){//如果没有2 行，则返?
		//setTimeout(function(){me=null;},100); //此功能未测试,不知道是否能清空内存数据
		return false;
	}
	elmListW.style.width=elmListW.offsetWidth+'px';
	elmListW.style.position='relative';
	//var oh1=elmListW.offsetHeight;
	//elmListW.style.height=oh1+'px';
	//elmListW.style.height=(2*oh1-elmListW.offsetHeight)+'px';
	elmListW.style.overflow='hidden';//限制动画显示区域
	/*
	此处之前的代码与ImageScroll 类似
	*/
	this.positionMax=this.listsLen*this.listSize[0];
	var numberPerPage=Math.floor((elmListW.offsetWidth + parseInt(list_0_style.marginRight))/this.listSize[0]);
	this.pages=Math.ceil(this.listsLen/numberPerPage);
	this.elmList.style.width=this.listsLen*this.listSize[0]+100+'px';
	var i;
	this.positions=[];
	for(i=0; i<this.pages; i++){
		this.positions[i]=0-this.lists[numberPerPage*i].offsetLeft;
		//console.log('position['+i+'] is: '+this.positions[i]);
	}
	this.elmList.style.position='relative';
	this.current=0;
	this.roundView=false;//可以循环浏览
	this.duration=1200;//每次翻页时间(ms)
	this.scrollTimer=null;
	this.nav={};//按钮，状态栏?
	/**
	更新按钮?
	*/
	var updateNav=function() {
		var i, link;
		for(i=0; (link=me.nav.link[i]); i++){
			link.className='';
		}
		me.nav.link[me.current].className='current';
		if(!me.roundView){
			if(me.current==0){
				Dom.addClass('p_off', me.nav.previous);
			}else{
				Dom.removeClass('p_off', me.nav.previous);
			}
			if(me.current==me.pages-1){
				Dom.addClass('n_off', me.nav.next);
			}else{
				Dom.removeClass('n_off', me.nav.next);
			}
		}
	};
	/**
	添加翻页按钮
	*/
	var addNavButtons=function() {
		var p=document.createElement('a'), n=p.cloneNode(true);
		n.href=p.href="javascript:;"//"#"+me.elmId;
		p.innerHTML="&lt;&lt;"
		n.innerHTML="&gt;&gt;"
		p.className="previous";
		n.className="next";
		// insert nodes after <div class="image_list_box">
		//console.log(me);
		me.elmRoot.appendChild(p);
		me.elmRoot.appendChild(n);
		p.style.top=n.style.top=(Dom.$tagHasClassInNode('div', 'image', list_0)[0].offsetHeight-p.offsetHeight)/2+'px';
		p.style.left=(0-p.offsetWidth/2+2)+'px';//这里? 起修正作用，往右边? px
		n.style.left=(me.elmRoot.offsetWidth-n.offsetWidth/2-2)+'px';//这里? 起修正作用，往左边? px
		n.style.right='auto';
		// add handlers
		p.onmousedown=me.scrollPrev_click;
		n.onmousedown=me.scrollNext_click;
		me.nav.previous=p
		me.nav.next=n;
		//n.relIPV=p.relIPV=this;
	};
	
	/**
	添加翻页状态条
	*/
	var addNavStatus=function(){
		function findElmInParent(elm, opt){
			elm=elm.parentNode;
			//console.log(elm);
			if((!elm) || (!opt) || ((!opt.tag) && (!opt.className) && (!opt.id))){return;}
			if(opt.tag && (elm.nodeName.toLowerCase()!=opt.tag.toLowerCase())){
				return findElmInParent(elm, opt);
			}
			if(opt.className && (!(Dom.hasClass(opt.className, elm)))){
				return findElmInParent(elm, opt);
			}
			if(opt.id && (!(elm.id && elm.id==opt.id))){
				return findElmInParent(elm, opt);
			}
			return elm;
		}
		var md=findElmInParent(me.elmRoot, {tag:'div', className:'md'});
		var md_hd = Dom.$tagHasClassInNode('div', 'md_hd', md)[0];
		md_hd.style.position='relative';
		var na=document.createElement('div');
		na.className='image_page_view_nav';
		na.style.visibility='hidden';
		me.nav.link=[];
		var LK=me.nav.link;
		function linkClick(ev){
			this.blur();
			if(me.scrollTimer!==null){
				return;
			}
			var v1, v2;
			v1=v2=0;
			var ito=this.getAttribute('i');
			v1=me.positions[me.current];
			me.current=ito;
			v2=me.positions[ito];
			if(v1!=v2){
				clearInterval(me.scrollTimer);
				me.scrollTimer=null;
				updateNav();
				movePic(me.scrollTimer, me.elmList, v1, v2, me.duration);
			}
			return false;
		};
		for(var i=0; i<me.pages; i++){
			var l=document.createElement('a');
			l.href="javascript:;"//+me.elmId;
			if(i==me.current){
				l.className='current';
			}
			l.setAttribute('i', i);
			l.onclick=linkClick;
			na.appendChild(l);
			LK.push(l);
		}
		na.style.left=(md_hd.offsetWidth-na.offsetWidth)/2+'px';
		na.style.top=(md_hd.offsetHeight-(Base.isIE()?13:8))/2+'px';
		na.style.visibility='visible';
		md_hd.appendChild(na);
	};
	
	this.init=function(){
		addNavButtons();
		addNavStatus();
		updateNav();
	};
	this.scrollPrev_click=function(){
		this.blur();
		if((this.className.indexOf('off')!=-1)||(me.scrollTimer!==null)){
			return false;
		}
		var v1, v2;
		v1=v2=0;
		if(me.current>0){
			v1=me.positions[me.current];
			me.current--;
			v2=me.positions[me.current];
		}else if(me.current==0){
			if(me.roundView){
				v1=me.positions[me.current];
				me.current=me.pages-1;
				v2=me.positions[me.current];
			}
		}
		if(v1!=v2){
			clearInterval(me.scrollTimer);
			me.scrollTimer=null;
			updateNav();
			movePic(me.scrollTimer, me.elmList, v1, v2, me.duration);
		}
		return false;
	};
	this.scrollNext_click=function(){
		this.blur();
		if((this.className.indexOf('off')!=-1)||(me.scrollTimer!==null)){
			return false;
		}
		var v1, v2;
		v1=v2=0;
		if(me.current<me.pages-1){
			v1=me.positions[me.current];
			me.current++;
			v2=me.positions[me.current];
		}else if(me.current==(me.pages-1)){
			if(me.roundView){
				v1=me.positions[me.current];
				me.current=0;
				v2=me.positions[me.current];
			}
		}
		if(v1!=v2){
			clearInterval(me.scrollTimer);
			me.scrollTimer=null;
			updateNav();
			movePic(me.scrollTimer, me.elmList, v1, v2, me.duration);
		}
		return false;
	};
	
	function movePic(timer, elm, v1, v2, duration, whenDone){
		//alert('start');
		clearInterval(me.scrollTimer);
		me.scrollTimer=null;
		var scrollStart=false;
		var startTime=null;
		me.scrollTimer=setInterval(scroll, 15);
		function scroll(){
			//alert(1);
			if(scrollStart){
				var now=new Date();
				var percent=parseFloat((now-startTime)/duration);
				var sl=Math.round(kAnimator.getPV(v1, v2, percent));
				if(percent<0.99999){
					try{
						elm.style.left=sl+'px';
					}catch(er){/*alert(er.name);*/}
					return;
				}else{
					elm.style.left=v2+'px';
					clearInterval(me.scrollTimer);
					me.scrollTimer=null;
					scrollStart=false;
					if(whenDone && (typeof whenDone=='function')){
						whenDone();
					}
					//alert('end');
				}
			}else{
				scrollStart=true;
				startTime=new Date();
			}
		}
	}
	this.init();
}

var page = page || {};
page.Tab = function(rId){
	this.tabId = rId;
};
page.Tab.prototype = {
	constructor: page.Tab,
	init: function(){
		this.tab = jQuery(this.tabId);
		this.btns = this.tab.find("li");
		this.links = this.tab.find("a");
		var cons = this.cons = [];
		this.curIndex = null;
		var _this = this;
		this.links.each(function(_i, _link){
			try{
				cons[_i] = jQuery(_link.getAttribute("href").match(/#[^#]+$/)[0]);
			}catch(ex){}
			//console.log(cons[_i]);
			(_this.curIndex === null) && (jQuery(_this.btns[_i]).hasClass("cur")) && (_this.curIndex = _i);
			_link.setAttribute("_i_", _i);
			_link.onclick = function(){
				this.blur();
				_this._linkClick.call(_this, this.getAttribute("_i_"));
				//console.log(this.getAttribute("_i_"));
				return false;
			};
		});
		this.cons = jQuery(cons);
		(this.curIndex === null) && (this.curIndex = 0);
		this._chgConTo(this.curIndex);
		return this;
	},
	_linkClick: function(index){
		if(index == this.curIndex){return}
		this.btns.each(function(_i, _btn){
			if(_i == index){
				jQuery(_btn).addClass("cur");
			}else{
				jQuery(_btn).removeClass("cur");
			}
		});
		this._chgConTo(index);
		this.curIndex = index;
	},
	_chgConTo: function(index){
		this.cons.each(function(_i, _con){
			if(_i == index){
				jQuery(_con).css("display", "");
			}else{
				jQuery(_con).css("display", "none");
			}
		});
	}
};
page.tab = function(){
	var arg = arguments;
	jQuery(function(){
		var tab = new page.Tab(arg[0]);
		tab.init();
	});
};