window.addEvent('domready', function() {

		/*if (!FlashDetect.versionAtLeast(9)) {
			$('mainTitle_area').set('class', 'noFlash');
		}*/

		Element.implement( {
			show : function() {
				this.fade('in');
			},

			hide : function() {
				this.fade('out');
			}
		});

		function rotate(list, el) {
			list.each(function(element) {
				element.hide();
			});
		}

		numMember = 1;
		maxMember = 4;

		rotateMember = function() {
			rotate($$('#member li'), 'img' + numMember);
			numMember++;
			if (numMember > maxMember)
				numMember = 1;
			$('img' + numMember).show();
		};

		numPartner = 1;
		maxPartner = 4;

		rotatePartner = function() {
			rotate($$('#partner li'), 'imgp' + numPartner);
			numPartner++;
			if (numPartner > maxPartner)
				numPartner = 1;
			$('imgp' + numPartner).show();
		};

		numAlliance = 1;
		maxAlliance = 1;

		rotateAlliance = function() {
			rotate($$('#alliance li'), 'imga' + numAlliance);
			numAlliance++;
			if (numAlliance > maxAlliance)
				numAlliance = 1;
			$('imga' + numAlliance).show();
		};

		rotatePartner.periodical(5000);
		rotateAlliance.periodical(5000);
		rotateMember.periodical(5000);

		numFCCI = 1;
		maxFCCI = 8;

		rotateFCCI = function() {
			rotate($$('#FCCI li'), 'imgf' + numFCCI);
			numFCCI++;
			if (numFCCI > maxFCCI)
				numFCCI = 1;
			$('imgf' + numFCCI).show();
		};

		rotatePartner.periodical(5000);
		rotateAlliance.periodical(5000);
		rotateMember.periodical(5000);
		rotateFCCI.periodical(5000);

		$('subscribe').addEvent('click', function(e) {
			if (isValidEmail($('email').value)) {
				new Request.HTML({
					method : 'post',
					url : '/cms/common/newsletter_write.php',
					data : {
						'email' : $('email').value
					},
					update : $('msg'),
					onComplete : function(response) {
						if ($('msg').get('html') == 'Thank you for signing up!')
							$('msg').set('class', 'success');
						if ($('msg').get('html') == 'This email adress already exist!')
							$('msg').set('class', 'red');
					}
				}).send();
			} else {
				$('msg').set('class', 'red');
				$('msg').set('html', 'Your email adress is incorrect!');
			}
		});
});

function selectHighlight(e) {
	$$('#links_hightlights a').each(function(el) {el.className = '';});	
	$(e.id).className = 'active';
	$$('#mainTitle_area .index_highlight').each(function(el) {el.className = 'index_highlight';});
	$('highlight' + e.id.substring(1,2)).className = 'index_highlight active';
}

function cityhall() {
	$("ztype_2").set("checked", "checked");
}

function gangdong() {
	$("ztype_4").set("checked", "checked");
}

function gangnam() {
	$("ztype_1").set("checked", "checked");
}

function yongsan() {
	$("ztype_3").set("checked", "checked");
}

function isValidEmail(str) {
	var filter = /^([\w-]+(?:\.[\w-']+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return (filter.test(str));
}

