
var Home = {
	kutu2Home: 1,
	kutu2Count: 2,
	start: function(){
		
		
		
		
		
		Home.kutu2ImSlide.periodical(5000) ;
		
		
		
		 
	},
	siteMap: function() {
		var container = $table(1, 2, {'border': '0', 'id': 'MapTab', 'cellPadding': '0', 'cellSpacing': '0'}) ;
		container.inject($('block1_tab'))
		container.tab = $(container.rows[0].cells[0]).setProperty('vAlign', 'top') ;
		container.content = $(container.rows[0].cells[1]).setProperty('vAlign', 'top').addClass('main') ;
		container.divs = $("MapTab-Source").getChildren() ; 
		$each(container.divs, function(div, index) {
			div.content = div.innerHTML ;
			div.setProperty('id', 'MapTabLabel'+index) ;
			div.addEvent('click', function() {
				if (container.opened == this || container.fxMenuStarted) {
					return ;
				}
				if (container.opened) {
					container.opened.removeClass('tab-on') ;
				}
				Cookie.set('MapTabLabelIndex', this.getProperty('id').replace(/[^0-9]/g, ''), {duration: 1*7*4*12}) ; 
				container.opened = this ;
				this.addClass('tab-on') ;
				container.content.empty() ;
				container.fxMenuStarted = true ;
				new Fx.Style(new Element('div').setOpacity(0).setHTML(this.content).inject(container.content), 'opacity', {duration: 300}).start(0, 1).chain(function() { container.fxMenuStarted = false }) ; 
			}) ;
			var fx = new Fx.Style(div, 'opacity', {duration: 500}) ;
			div.addEvent('mouseenter', function() {
				if (container.opened == this) {
					return ;
				}
				fx.start(0, 1) ;
			}) ;
			div.addClass('tab').setHTML(div.getProperty('title') + ' » ').inject(container.tab) ;
		}) ;
		var index = Cookie.get('MapTabLabelIndex') ;
		if (index === false) {
			index = 0 ;
		} else if (index < 0 || container.divs.length - 1 < index) {
			index = 0 ;
		}
		$('MapTabLabel' +(index)).fireEvent('mouseenter').fireEvent('click') ;
		
		new Fx.Style($('block1_tab'), 'background-position', {duration: 1500, transition: Fx.Transitions.Back.easeOut}).start(0, 590) ; 
	},
	ytop: function() {
		var root = $("TopTapContainer") ;
		root.setStyle('display', 'block') ;
		root.divs = root.getChildren() ;
		root.top = new Element('div', {'styles': {}}).inject(root) ;
		root.top.table = $table(1, root.divs.length, {'border': '0', 'cellPadding': '0', 'cellSpacing': '0'}).inject(root.top) ;
		root.main = new Element('div', {'styles': {}}).addClass('main').setHTML('&nbsp;').inject(root) ;
		var cells = root.top.table.rows[0].cells ;
		$each(root.divs, function(div, index) {
			var cell = $(cells[index]).addClass('off') ;
			cell.content = div ;
			cell.root = root ;
			div.setStyle('display', 'none') ;
			cell.setHTML(div.getProperty('title')) ;
			root.main.appendChild(cell.content) ;
			var fx = new Fx.Style(cell, 'opacity', {duration: 500}) ;
			cell.addEvent('mouseenter', function() {
				$$(cells).each(function(cell) { 
					cell.className = 'off' 
				}) ;
				root.divs.setStyle('display', 'none') ;
				this.content.setStyle('display', 'block') ;
				this.setProperty('class', 'on') ;
				fx.start(0, 1) ;
			}) ;
		}) ;
		$(cells[0]).fireEvent('mouseenter') ;
	},
	kutu2ImSlide: function() {
		var gallery = $('gallery-preview') ;
		if (window.gecko && gallery.__SLIDE_ZINDEX == undefined) {
			gallery.__SLIDE_ZINDEX = 0 ;
			gallery.__SLIDE_INDEX = gallery.getChildren().length - 1 ;
		}
		var height = $('gallery-preview').getCoordinates().height ;
		
		
		function get(index) {
			return $('gp'+index) ; //document.getElementById('gallery-preview').childNodes[index] ;
		}
		if (window.gecko) {
			var div = get(gallery.__SLIDE_INDEX) ;
			if (!div) {
				div = get(2) ;
				gallery.__SLIDE_INDEX = 2 ;
			}
		} else 
		var div = gallery.childNodes[gallery.childNodes.length-1]
		var fx = new Fx.Styles(div, {duration:1000}) ;
		fx.start({'margin-top': [0, 0], 'margin-left': [0, 25], 'opacity': [1,0]}).chain(function(){
			div.setStyles({
				'opacity':1,
				'margin-top': 0,
				'margin-left': 0
			}) ;
			if (window.gecko) {
				div.setStyles({
					'z-index': gallery.__SLIDE_ZINDEX
				}) ;
			} else 
			gallery.insertBefore(div, gallery.childNodes[0]) ;
		}) ;
		if (window.gecko) {
			gallery.__SLIDE_INDEX-- ;
			gallery.__SLIDE_ZINDEX-- ;
		}
	},
	paint: function(color, defaultPaintColor) {
		var strPaintKey = 'strPaintBlockColor' ;
		if (!color) {
			color = Cookie.get(strPaintKey) ; 
			if (!color) {
				color = defaultPaintColor ;
			}
		}
		Cookie.set(strPaintKey, color, {duration: 1*7*4*12}) ; 
		var styleBlock = $('stylePaintBlock') ;
		if (window.ie) {
			if (!styleBlock.styleSheet.tempCssText) {
				styleBlock.styleSheet.tempCssText = styleBlock.styleSheet.cssText ;
			}
			styleBlock.styleSheet.cssText = styleBlock.styleSheet.tempCssText ;
			var rules = styleBlock.styleSheet.rules ;
		} else {
			if (!styleBlock.tempCssText) {
				styleBlock.tempCssText = styleBlock.innerHTML ;
			}
			styleBlock.setHTML(styleBlock.tempCssText) ;
			var rules = styleBlock.sheet.cssRules ;
		}
		(rules.length).times(function(i) {
			rules[i]['style'].cssText = window.gecko ? rules[i]['style'].cssText.replace(/255, 255, 244/gi, new Color('#'+color)) : rules[i]['style'].cssText.replace(/FFFFF4/gi, color) ;
		}) ;
	}
};
window.addEvent('load', Home.start);
