$(function() {
	
	function current_page() {		
		var loc = document.location.href,
			url = loc.split('chlux.co.kr/'),
			page_url = url.pop(),
			page_url2 = page_url.split('/'),
			page = page_url2.shift(),
			page = page.split('.'),
			page = page.shift();
		
		//alert(page);
		if (page == 'index' || page == '' || page == 'home' ) {
			var page = 'home';
		}
			$('.main_nav div p').children('span:contains("'+page+'")').css({'color':'#639'}).parent('p').css({'background':'url(images/menu_top_center.png) repeat-x center top #FFF', 'height':'50px'}).attr('id', 'active').next('p').css({'background':'url(images/menu_top_right.png) no-repeat right top #FFF', 'height':'50px'}).attr('id', 'active').prev('p').prev('p').css({'background':'url(images/menu_top_left.png) no-repeat left top #FFF', 'height':'50px'}).attr('id', 'active');

	}
	
	current_page();
	
	$('.pic').cycle({
		fx: 'fade',
		speed:  1000,
		timeout: 5000,
		before : rotation,
		after : pager_img,
		pager:  '#pager'
		
	});
	
	function rotation() {
		
		var max_num = $('.pic').children('img').size(),
			current = this.src,
			array = current.split('/'),
			current_pic = array.pop(),
			num = current_pic.split('.'),
			array2 = num.shift(),
			next = 'pics/'+((array2*1)+1)+'.jpg';
		
		if (array2 == max_num) {
			var next = 'pics/1.jpg';
		}	
		$('.pic2').hide().html('<img src="'+next+'" alt="" />').fadeIn('slow');
		$('.text_banner').hide().html('<img src="text_banner/'+array2+'.png" alt="" width="460" height="193" />').fadeTo(800,1).pngFix();
	}
	
	function pager_img() {
		$('#pager a[class != activeSlide]').html('<img src="pics/next.png" alt="" width="15" height="15" />').parent('p').show().pngFix();
		$('.activeSlide').html('<img src="pics/current2.png" alt="" width="15" height="15" />').parent('p').show().pngFix();
	}
	
	$('.main_nav div').css({'overflow':'visible'});
	$('.main_nav div').children('.m_c, .m_r').dropShadow({opacity:0.1});
	$('.main_nav div').children('.m_c, .m_r').hide();
	$('.dropShadow').hide();
	
	// hover menu	
	$('.first, .second, .third, .fourth, .fifth').hoverIntent(function() {
		if ($('.mc:hidden')) {		
			$(this).children('.t_l').css({'background':'url(images/menu_top_left.png) no-repeat left top #FFF', 'height':'39px'}).next('p').css({'background':'url(images/menu_top_center.png) repeat-x center top #FFF', 'height':'39px'}).children('span').css({'color':'#639'}).parent('p').next('p').css({'background':'url(images/menu_top_right.png) no-repeat right top #FFF', 'height':'39px'});
			
			var width_sh = parseInt($(this).children('p.m_c').width()) + 1; //width
			var height_sh = parseInt($(this).children('p.m_c').height()) + 20; //height
			
			$(this).children('.m_c').slideDown('fast');	
			$(this).children('.dropShadow').css({'width':width_sh+'px', 'height':height_sh+'px', 'position':'absolute', 'top':'48px'}).show('fast');
			$(this).children('.dropShadow').children('.dropShadow').css({'width':width_sh+'px', 'position':'absolute', 'top':'2px'}).show('fast');
		}
	}, function() {		
			$(this).children('.m_c').slideUp('fast');
			$('.dropShadow').hide();
			$(this).children('.t_l[id != "active"], .t_m[id != "active"], .t_r[id != "active"]').css({'background':'none'}).children('span').css({'color':'#3d3c3c'});
	});							  
	// hover menu END
		
	$('#header_bottom_content').pngFix();
	$('#footer_top_content').pngFix();
	
	//var menu_min_width = $('');
	//$('.m_c').css({'':''});
	
	/* function scroll_twitter() {
		var position = $('.left div div').position();
		var content_height = $('.left div div').height();
		var max_height = content_height - 135;
		var speed = content_height*30;
		
		if (position.top <= max_height) {// position.top 
		
		$('.left div div').animate({
			'top':'-='+max_height	
		},speed, function() {
			$('.left div div').animate({'top':'-55px'},1000);
			scroll_twitter();
		});

		}
	}
	
	scroll_twitter();
	
	$('.left div div').live('click', function() {
		
		if ($('.twitter_board:hidden')) {
		
			var height_body = '100%';
			var position = 'fixed';
			var overlay = 'url(images/overlay.png) repeat';
			
			$('#header').before('<div class="cover"></div>');
			
			if ($.browser.msie && ($.browser.version == '6.0')) {

				var overlay = 'none';
				var height_body = $('body').height();
				var position = 'absolute';
				
				$('.cover').before('<div class="cover_bg"></div>');
				$('.cover_bg').css({"width":"100%", "height":height_body, "background":"#000", "opacity":0.5, "position":position, "bottom":0, "top":0, "z-index":997});
			} 
			
			$('.cover').css({"width":"100%", "height":height_body, "background":overlay, "position":position, "bottom":0, "top":0, "z-index":998});
			$('.cover').html('<div class="twitter_board" style="position:absolute; top:50%; left:50%; margin:-210px 0 0 -210px; background:#333; color:#FFF;  overflow:auto; line-height:150%; font-size:0.8em; text-indent:30px; height:400px; width:400px; border:20px solid #FFF; display:none"></div>');
			
			$('.twitter_content').clone().appendTo('.twitter_board');
			$('.twitter_board').fadeIn();
		}
	});
	
	$('.left div').live('mouseenter', function() {
			$('.twitter_bg').attr('src', 'images/twitter_bg_over.png');
	});
	
	$('.left div').live('mouseleave', function() {
			$('.twitter_bg').attr('src', 'images/twitter_bg.png');
	});

	$('.cover').live('click', function() {
		$('.cover, .cover_bg').remove();
	});
	
	$('.contact_info_email').html('<a href="mailto:chlux@chlux.co.kr" title="chlux@chlux.co.kr">chlux@chlux.co.kr</a>');
	
	$('.twitter_board div div p').live('mouseenter', function() {
		$(this).css({'background':'#000'});		
	}); 
	
	$('.twitter_board div div p').live('mouseleave', function() { 
		$(this).css({'background':'transparent'});	
	}); */

});
