var autoShowTab = Class.create();
autoShowTab.prototype = {
	//参数初始化
	initialize: function(id, contsid, baseCss, currentCss, allowPlay, autoInterval) {
		this.id = id;
		this.autoInterval = autoInterval;
		this.contsid = contsid;
		this.currentCss = currentCss;
		this.baseCss = baseCss;
		this.allowPlay = Boolean(allowPlay) || false;
		this.stop = false;
		this.i = 0;
		this.init();
	},
	
	//初始
	init:function(){
		var self = this;
		if($(this.id)){
			//事件激活
			$(this.id).childElements().each(function(s,index){
				s.onmouseover = function(){
					self.play(s,index);
					self.stop = true;
					self.i = index;
				}
				s.onmouseout = function(){
					self.stop = false;
				}				
			});
			$(this.contsid).onmouseover  = function(){
				self.stop = true;	
			}
			$(this.contsid).onmouseout  = function(){
				self.stop = false;	
			}			
		}
		if(this.allowPlay){
			this.autoPlay();
		}
	},
	
	autoPlay:function() {
		var self = this;
		window.setInterval(
			function(){
				self.autoShowTab(self.i);
			}
		,this.autoInterval*1000);
	},
	play:function(s,index){
		var self = this;
		s.parentNode.childElements().each(
			function(el){
				el.className = self.baseCss;
			}
		);
		s.className = self.currentCss;
		$(self.contsid).childElements().each(function(cl){
				cl.style.display = "none";
			}	
		)
		$(self.contsid).childElements()[index].setStyle({'display':'block'});
	},
	autoShowTab:function(i){
		var els = $(this.id).childElements();
		if(this.stop) return;
		if(i==(els.length-1)) i=0;
		else i++;
		this.i = i;
		s = els[i];
		this.play(s,i);
	}
}


function showSpecia(pre, n, select_n) {
	for (i = 1; i <= n; i++) {
		$(eval(pre+i)).setStyle({'display':'none'});
	}
	$(eval(pre+select_n)).setStyle({'display':'block'});
}




//首页搜索
function Searchindex(){
	var key_name = $("key_name").value;
	if (key_name == ''){
		alert("请填写关键词");
		return false;
	}
	
	var key_select = $("key_select").value;
	//alert(key_select);
	switch (parseInt(key_select)){
   case 2:
	 window.location.href="search/index.php?name="+key_name;	 
     break;
   case 3:
	 window.location.href="search/class.php?name="+key_name; 
     break;
   case 4:
   	 window.location.href="search/luntan.html?name="+key_name; 
     break;
   case 5:
	 window.location.href="search/cart.php?name="+key_name;	 
     break;
   case 6:
	 window.location.href="#";	 
     break;
   default:
     document.write("请选择栏目!");
	}
}

// 搜索
function SearchForward()
{
	var cid = $("cid").value;
	var areaid = $("areaid").value;
	var keyword = "";
	var url="/video/index.php?cary="+cid+"&arid="+areaid;
	self.location.href = url;
}


function switchTabs1(obj){
	$('eee1').style.display='block'; obj.className = 'EggTab1over'; $('eee2').style.display='none'; $('eeet2').className = 'EggTab2';
}
function switchTabs2(obj){
	$('eee1').style.display='none'; obj.className = 'EggTab2over'; $('eee2').style.display='block'; $('eeet1').className = 'EggTab1';
}
