function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


/*------------// SHOW,HIDE SHOWCASE //-------------*/
function toggleShowcase(showcase_id) {
	if ($('showcase_prods_'+showcase_id).getStyle('display') == 'none') {
		$('showcase_prods_'+showcase_id).setStyle('display', 'block');
		$('showcase_ddangddang_'+showcase_id).setStyle('display', 'none');
	} else {
		$('showcase_prods_'+showcase_id).setStyle('display', 'none');
		$('showcase_ddangddang_'+showcase_id).setStyle('display', 'block');
	}
}


/*------------// PRODUCT OF DAY:pod //-------------*/
function podSlide(direction) {
	if (direction == 'left') {
		hideTD = $('podLeftDesc');
		showTD = $('podRightDesc');
		hideBTN = $('podToLeft');
		showBTN = $('podToRight');
	} else {
		hideTD = $('podRightDesc');
		showTD = $('podLeftDesc');
		hideBTN = $('podToRight');
		showBTN = $('podToLeft');
	}
	
	hideTD.setStyle('display', 'none');
	hideBTN.setStyle('visibility', 'hidden');
	showTD.setStyle('display', '');
	showBTN.setStyle('visibility', 'visible');
}

/*----------------// THEME CUT //------------------*/
function rotateThemeCut() {
	$('themeCut').src = theme_url + '/' + theme_cuts[next_idx];
	next_idx++;
	if (next_idx >= theme_cuts.length) next_idx = 0;

	new Fx.Tween($('themeCut'), {duration:'long'}).start('opacity', '0', '1').chain(
			function () {timer =  hideCurrenCut.delay(3500); }
	);
}

function hideCurrenCut() {
	new Fx.Tween($('themeCut'), {duration:'long'}).start('opacity', '1', '0').chain(
			function () {rotateThemeCut(); }
	);
	if (event_bnn_number && sync_eventbnn_slide) {
		event_bnn_idx += 1;
		if (event_bnn_idx >= event_bnn_number) event_bnn_idx = 0;
		$$('h3.toggler')[event_bnn_idx].fireEvent('click');
	}
}

var timer;
var next_idx = 1;
var theme_cuts;
var theme_url = '';
var sync_eventbnn_slide = true;
var event_bnn_number;		//이벤트 베너의 수
var event_bnn_idx = 0;	//클릭할 이벤트 배너 idx

window.addEvent('load', function() {
	event_bnn_number = $$('h3.toggler').length;

	theme_url = $('themeCut').getAttribute('theme_url');
	theme_cuts = $('themeCut').getAttribute('theme_cuts').split(':');
	timer =  hideCurrenCut.delay(2000); 
	for(i=0;i<theme_cuts.length;i++) {
		MM_preloadImages(theme_url+'/'+theme_cuts[i]);
	}

});


window.addEvent('domready', function() {	
	
	//Event Accordion
	var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#870287');
			toggler.setStyle('font-weight', 'bold');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#616161');
			toggler.setStyle('font-weight', 'normal');
		}
	});
		
});