/**
 *Filename:      ue_tab.js
 *Version:       1.0.0(2009-03-02)
 *Website:       http://
 *Author:        S.S.L
 *Modify:        2009-07-17
**/

function ue_tab( tab_menu,tab_main,cur_tab,mouse,time ){
	var pre_no;
	var timer,autoplay_timer;
	var tab;
	
	function $( id ){ return document.getElementById( id );}
	
	function run( no ){
		if( no != null ){
			if( timer != null )clearInterval( timer );
			timer = setInterval( function(){
				doChange(no);
			},200 );
		}
	}
	
	function addEvent(){
		for( var i = 0; i < tab.length; i++ ){
			tab[i].cur_no = i;
			if( mouse == null ){
				tab[i].onclick = function(){ 
					run( this.cur_no );
					return false;
				}
			} else {
				tab[i].onmouseover = tab[i].onmouseout= function(){
					run( this.cur_no );
					return false;
				}
			}
		}
	}
	
	function doChange( k ){
		if( tab[pre_no] != null && $(tab_main+(pre_no+1)) != null ){
			tab[pre_no].className = "off";
			$(tab_main+(pre_no+1)).style.display = "none";
		}
		
		if( tab[k] != null && $(tab_main+(k+1)) != null ){
			tab[k].className = "on";
			$(tab_main+(k+1)).style.display = "block";
		}
		
		pre_no = k;
		
		if( timer != null )clearInterval( timer );
	}
	
	function autoplay(){
		if( pre_no < tab.length ){
			doChange( pre_no+1 );
		} else {
			pre_no = tab.length-1;
			doChange( 0 );
		}
	}
	
	function init(){
		if( tab_menu == null || tab_main == null ) return;
		
		var tabs = tab_menu.split(" ");
		
		if( tabs[0] == null || tabs[1] == null || $( tabs[0] ) == null ) return;
		
		tab = $( tabs[0] ).getElementsByTagName( tabs[1] );

		pre_no = ( cur_tab == null ) ? 0:(cur_tab-1);
		
		doChange( pre_no );
		addEvent();
		
		if( time != null && time > 0 )
			autoplay_timer = setInterval( autoplay,time );
	}
	
	init();

}

function flashObject(file_name,width,height){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '">');
  document.write('<param name="movie" value="' + file_name + '">');
  document.write('<param name="quality" value="high">');
  document.write('<param name="menu" value="false">');
  document.write('<param name="wmode" value="transparent">');
  document.write('<embed src="' + file_name + '" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
  document.write('</object>');
}
