function JLJS_ToursDomRecommendTab() {
	this.tabs = [];
	this.tabImgs = [];
	this.suffixs = [];
	this.remains = [];
	this.srcs = [];
	this.fileSuffixPtn   = /\.(jpe?g|gif|png)$/i;
	this.statusSuffixPtn = /_[nso]$/;
	this.areaCode = ["TAB1", "TAB2", "TAB3", "TAB4", "TAB5", "TAB6", "TAB7", "TAB8", "TAB9", "TAB10"];
}

JLJS_ToursDomRecommendTab.prototype = {
	
	init : function(code){
		this.tabs = JLJS.getElementsByTagName( "li", document.getElementById( "tabtab" ));
		
		for( var i = 0; i < this.tabs.length; i ++ ){
			this.tabImgs[i] = JLJS.getElementsByTagName( "img", this.tabs[i] )[0];
			this.srcs[i] = JLJS.getAttr( this.tabImgs[i], "src" );
			this.suffixs[i] = this.srcs[i].match( this.fileSuffixPtn )[0];
			this.remains[i] = this.srcs[i].replace( this.fileSuffixPtn, "" ).replace( this.statusSuffixPtn, "" );
		}
		
		this.toggleTab(code);
	},
	
	mouseover : function ( n ) {
		if( JLJS.classAttr.check( this.tabs[n], "pseudo-current" ) ) {
			JLJS.setAttr( this.tabImgs[n], "src", this.remains[n] + "_s" + this.suffixs[n] );
		} else {
			JLJS.setAttr( this.tabImgs[n], "src", this.remains[n] + "_o" + this.suffixs[n] );
		}
	},
	
	mouseout : function ( n ) {
		if( JLJS.classAttr.check( this.tabs[n], "pseudo-current" ) ) {
			JLJS.setAttr( this.tabImgs[n], "src", this.remains[n] + "_s" + this.suffixs[n] );
		} else {
			JLJS.setAttr( this.tabImgs[n], "src", this.remains[n] + "_n" + this.suffixs[n] );
		}
	},

	toggleTab : function ( code ) {
	
		for(var i=0; i<this.areaCode.length; i++) {
			if(this.areaCode[i] == code){
				break;	
			}
			
			if( (i+1) == this.areaCode.length) {
				code = "TAB1";	
			}
		}
	
		for(var i=0; i<this.tabs.length; i++) {
			if(this.areaCode[i] == code){	
				JLJS.classAttr.add( this.tabs[i], "pseudo-current" );
				document.getElementById( this.areaCode[i] ).style.display = "block";
			} else {
				JLJS.classAttr.remove( this.tabs[i], "pseudo-current" );
				document.getElementById( this.areaCode[i] ).style.display = "none";
			}
			
			this.mouseout(i);
		}
		
	}

}

var JLJS_Tours_DRT = new JLJS_ToursDomRecommendTab();
JLJS.addOnload(function() {JLJS_Tours_DRT.init("TAB1")});
