/* Author: 
	lainfox
*/

function main_images_handle(carousel) {
	jQuery('#main-carousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#main-carousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

var openLetter = function(obj) {
	window.open( obj.href, 'letter', 'top=100px, left=300px, height=340px, width=350px, scrollbars=yes');
};

$(function(){
	// GNB 
	var $currentGNB = $('#gnb li.active');
	$('#gnb li').mouseenter(function() {
			$(this).siblings().removeClass('hover');
			$(this).addClass('hover');
			$currentGNB.removeClass('active');
	});
	$('#gnb').mouseleave(function(){
		$(this).find('li').removeClass('hover');
		$currentGNB.addClass('active');
	});


	// main Category select value
	$('#category, #category-btn').click(function(event){
		event.preventDefault();
		$cThis = $('#category');	
		$('#category-expand').toggle();
		
		$('#category-expand p').click(function(){
			$cThis.val( $(this).text() );
			$('#category-expand').hide();
		});
	});

	// main tab list
	$('.mainTab .tab').mouseover(function(){
		$(this).addClass('active')
			.siblings().removeClass('active');
	});

	// main carousel
	$('#main-carousel').jcarousel({	
        scroll: 5,
		initCallback: main_images_handle
	});


	// login box focusing placehold
	$('#sid').focus(function(){
		if( $(this).val() == '이메일' ) $(this).val('');
	});
	$('#spwd').focus(function(){
		if( $(this).val() == '패스워드' ) $(this).val('');
	});

	// check all function
	$('.checkall').bind('click', function () {
		$('body').find(':checkbox').attr('checked', this.checked);
	});
	
	$('#products-all, #system-all, #news-all, #others-all').click(function(){
		type = $(this).attr('data-check');
		$('body').find(':checkbox[name="'+type+'"]').attr('checked', this.checked);
	});
	
	$('a[rel*=facebox]').facebox();

	// about table bg color
	$('table.about tbody tr').each(function(){
		$(this).find('td:even').css('background','#f1f6fc');
	});





	// quick link
	var $quick = $('<div id="quick" />'),
		menuYloc = 0;
	$quick.append('<ul><li><a href="#header"><img src="/images/common/quick_top.gif" alt="" /></a></li><li><a onclick="_jsGoto(\'1\',\'5\')"><img src="/images/common/quick_ceo.gif" alt="" /></a></li><li><a onclick="_jsGoto(\'8\',\'1\',\'\')"><img src="/images/common/quick_hp.gif" alt="" /></a></li><li><a onclick="_jsGoto(\'8\',\'6\')"><img src="/images/common/quick_schedule.gif" alt="" /></a></li><li><a onclick="_jsGoto(\'8\',\'2\')"><img src="/images/common/quick_ads.gif" alt="" /></a></li><li><a onclick="_jsGoto(\'9\',\'2\')"><img src="/images/common/quick_foot.gif" alt="" /></a></li><ul>');	
	$quick.appendTo('body');
	menuYloc = parseInt($quick.css('top').substring(0, $quick.css('top').indexOf('px')));
	
	$(window).scroll(function () { 
		offset = menuYloc + $(document).scrollTop();
		$quick.animate({top:offset+"px"},{duration:500,queue:false});   
	});
});




















