TopBannerRotate = {
	TopBannerArray : [],
	TopTimer : null,
	TopTab : 5,
	TopDiv : 'CenterBannerDiv',
	TopGettab : function(id,running){
				$("#"+this.TopDiv).html($("#"+this.TopBannerArray[id-1]).html());
				if(!running){clearTimeout(this.TopTimer);}
				},
	TopRotate : function(id,settime){
				if(this.TopTimer){clearTimeout(this.TopTimer);}
				if(id >this.TopTab){id=1;}
				this.TopGettab(id,true);
				id++;
				this.TopTimer = setTimeout("TopBannerRotate.TopRotate("+id+","+settime+")", settime);
			}
};

CenterBannerRotate = {
	CenterBannerArray : [],
	CenterTimer : null,
	CenterTab : 5,
	CenterDiv : 'CenterBannerDiv',
	CenterGettab : function(id,running){
				$("#"+this.CenterDiv).html($("#"+this.CenterBannerArray[id-1]).html());
				if(!running){clearTimeout(this.CenterTimer);}
				},
	CenterRotate : function(id,settime){
				if(this.CenterTimer){clearTimeout(this.CenterTimer);}
				if(id >this.CenterTab){id=1;}
				this.CenterGettab(id,true);
				id++;
				this.CenterTimer = setTimeout("CenterBannerRotate.CenterRotate("+id+","+settime+")", settime);
			}
};

NewsTab = {
	timerTabsNews : null,
	tabsNews : 5,
	tabsArray : ["news","fashion","beauty","pets","auto"],
	gettab : function(numid,running){
					for (i=1;i<=this.tabsNews;i++){
							if(i==numid){	
								$('#tab-left-'+i).removeClass(this.tabsArray[i-1]+"-tab-left");
								$('#tab-center-'+i).removeClass(this.tabsArray[i-1]+"-tab-center");
								$('#tab-right-'+i).removeClass(this.tabsArray[i-1]+"-tab-right");
								$('#fragment-'+i).removeClass("off");
								$('#tab-left-'+i).addClass("tab-left");
								$('#tab-center-'+i).addClass("tab-center");
								$('#tab-right-'+i).addClass("tab-right");
								$('#tab-center-'+i+' span').html('<img id="imagesHot" src="/th/html/images/icon/hot.gif"> ');
								$('#fragment-'+i).addClass("on");
							}else{
								$('#tab-left-'+i).removeClass("tab-left");
								$('#tab-center-'+i).removeClass("tab-center");
								$('#tab-right-'+i).removeClass("tab-right");
								$('#fragment-'+i).removeClass("on");
								$('#tab-left-'+i).addClass(this.tabsArray[i-1]+"-tab-left");
								$('#tab-center-'+i).addClass(this.tabsArray[i-1]+"-tab-center");
								$('#tab-right-'+i).addClass(this.tabsArray[i-1]+"-tab-right");
								$('#tab-center-'+i+' span').html('');
								$('#fragment-'+i).addClass("off");	
							}
						}
						
						if(!running){
							clearTimeout(this.timerTabsNews);
						}
				},
	rotate : function(id,settime){
				if(this.timerTabsNews){
					clearTimeout(this.timerTabsNews);
				}
				
				if(id >this.tabsNews){
					id=1;
				}
				
				this.gettab(id,true);
				id++;
				this.timerTabsNews = setTimeout("NewsTab.rotate("+id+","+settime+")", settime);
			}
};

ShoppingTab = {
	timerTabsShopping : null,
	tabsShopping : 3,
	gettab : function(numid,running){
					for (i=1;i<=this.tabsShopping;i++){
						if (numid == i){
							$('#tabs-shopping-'+i+'-1').removeClass('tab-left-open');
							$('#tabs-shopping-'+i+'-2').removeClass('tab-center-open');
							$('#tabs-shopping-'+i+'-3').removeClass('tab-right-open');
							
							$('#tabs-shopping-'+i+'-1').addClass('tab-left-hit');
							$('#tabs-shopping-'+i+'-2').addClass('tab-center-hit');
							$('#tabs-shopping-'+i+'-3').addClass('tab-right-hit');
							
							$('#fragment-shopping-'+i).removeClass('off');
							$('#fragment-shopping-'+i).addClass('on');
						}else{
							$('#tabs-shopping-'+i+'-1').removeClass('tab-left-hit');
							$('#tabs-shopping-'+i+'-2').removeClass('tab-center-hit');
							$('#tabs-shopping-'+i+'-3').removeClass('tab-right-hit');
							
							$('#tabs-shopping-'+i+'-1').addClass('tab-left-open');
							$('#tabs-shopping-'+i+'-2').addClass('tab-center-open');
							$('#tabs-shopping-'+i+'-3').addClass('tab-right-open');
							
							$('#fragment-shopping-'+i).removeClass('on');
							$('#fragment-shopping-'+i).addClass('off');
						}
					}
						
						if(!running){
							clearTimeout(this.timerTabsShopping);
						}
				},
	rotate : function(id,settime){
				if(this.timerTabsShopping){
					clearTimeout(this.timerTabsShopping);
				}
				if(id >this.tabsShopping){
					id=1;
				}
				
				this.gettab(id,true);
				id++;
				this.timerTabsShopping = setTimeout("ShoppingTab.rotate("+id+","+settime+")", settime);
			}
};
