//flashLoad
function mainGraphicLoad(){
	var flashLoaded = new Hash.Cookie('flashLoaded');
	//alert(flashLoaded.get('flag'));
	loadSwfValuable = flashLoaded.get('flag');
	//alert(loadSwfValuable);
	//
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="622" height="253">');
	document.write('<param name="movie" value="/swf/main20081101.swf?loadedFlag=' + loadSwfValuable + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<embed src="/swf/main20081101.swf?loadedFlag=' + loadSwfValuable + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="622" height="253"></embed>');
	document.write('</object>');
}

//flash cookie	
function flashSetCookie(){
	var flashLoaded = new Hash.Cookie('flashLoaded', {autoSave: true});
	flashLoaded.set('flag', 'true');
	//alert(flashLoaded.get('flag'));
}

	
window.addEvent('domready', function(){
	var accordion = new Accordion('h3.atStart', 'div.atStart', {
		alwaysHide:true,
		opacity: true,
		onActive: function(toggler, element){
			toggler.setStyle('backgroundImage', 'url(/image/i_open.gif)');
			atext = toggler.getChildren();
			atext[1].className = atext[1].className.replace(/newsNormal/,"testClass");
		},
		
		onBackground: function(toggler, element){
			toggler.setStyle('backgroundImage', 'url(/image/i_close.gif)');
			atext = toggler.getChildren();
			atext[1].className = atext[1].className.replace(/testClass/,"newsNormal");
		}
	}, $('accordion'));
	
	
	var szNormal = 25, szSmall  = 24 , szFull   = 40;

	var kwicks = $$("#kwicks .kwick");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 200, transition: Fx.Transitions.Cubic.easeInOut});
	kwicks.each(function(kwick, i) {
		kwick.addEvent("mouseenter", function(event) {
			var o = {};
			o[i] = {height: [kwick.getStyle("height").toInt(), szFull]}
			kwick.setStyle('backgroundImage', 'url(/image/' + kwick.getProperty("id") + '_Over.jpg)');
			
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("height").toInt();
					if(w != szSmall) o[j] = {height: [w, szSmall]};
					other.setStyle('backgroundImage', 'url(/image/' + other.getProperty("id") + '.jpg)');
				}
			});
			fx.start(o);
		});
	});
	 
	$("kwicks").addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			o[i] = {height: [kwick.getStyle("height").toInt(), szNormal]}
			kwick.setStyle('backgroundImage', 'url(/image/' + kwick.getProperty("id") + '.jpg)');
		});
		fx.start(o);
	})

	//preload
	new Asset.image('/image/b_LiveData_Over.jpg');
	new Asset.image('/image/b_Profile_Over.jpg');
	new Asset.image('/image/b_DiscoGraph_Over.jpg');
	new Asset.image('/image/b_Download_Over.jpg');
	new Asset.image('/image/b_Goods_Over.jpg');
	new Asset.image('/image/b_StaffDiary_Over.jpg');
	new Asset.image('/image/b_Link_Over.jpg');
	new Asset.image('/image/b_ContactUs_Over.jpg');
	new Asset.image('/image/b_Dm_Over.jpg');
	new Asset.image('/image/b_Myspace_Over.jpg');
}); 