/* common mouseover/mouseout */
function imageOver(imgEl) {
	imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");
}

jQuery(document).ready(function() {
jQuery('#sidebar').each(function() {
	var thisclass = jQuery(this).attr('class');
	jQuery(this).find('li.' + thisclass).children('a').addClass('hover');
});

jQuery('ul.exhibitionlist').each(function() {
	jQuery(this).children('li:eq(2)').addClass('last');
	jQuery(this).children('li:eq(5)').addClass('last');
});

jQuery('ul.directorybook').each(function() {
	jQuery(this).children('li:eq(3)').addClass('last');
	jQuery(this).children('li:eq(7)').addClass('last');
	jQuery(this).children('li:eq(11)').addClass('last');
});

/* ecoexposearch */
jQuery('.langmenu').each(function() {
		jQuery(this).find('img.clk').click(function() {
		jQuery(this).next('ul#langlist').show(function() {
			jQuery(this).click(function() {
				jQuery('ul#langlist').hide();
			});
			jQuery('ul#langlist li').click(function() {
				var sltxt = jQuery(this).text();
//				jQuery(this).parent().parent().next().removeClass().addClass(sltxt).children().text(sltxt);
				jQuery('ul#langlist').hide();
			});
			jQuery('img.clk').click(function() {
//				jQuery('ul#langlist').hide();
			});
		});

	});
});

jQuery('.ecoexposearch').each(function() {
	var jQuerysearch = jQuery(this);
	var jQuerysearchInput = jQuerysearch.find('input');
	var jQuerysearchLabel = jQuerysearch.find('label');

	jQuerysearch.find('a.escate').click(function() {
		jQuery(this).next('ul#escatelist').show(function() {
			jQuery(this).click(function() {
				jQuery('ul#escatelist').hide();
			});
			jQuery('ul#escatelist li').click(function() {
				var sltxt = jQuery(this).text();
				jQuery(this).parent().prev().text(sltxt);
				jQuery('ul#escatelist').hide();
			});
			jQuery('body').click(function() {
				jQuery('ul#escatelist').hide();
			});
		});

		return false;
	});

	if (jQuerysearchInput.val())	{
		jQuerysearchLabel.hide();
	}

	jQuerysearchInput.focus(function() {
			jQuerysearchLabel.hide();
		}).blur(function() {
			if (this.value == '') {
				jQuerysearchLabel.css('display','');
			}
		});

		jQuerysearchLabel.click(function() {
			jQuerysearchInput.trigger('focus');
		});
});

/* boardsearchdiv */
jQuery('.boardsearchdiv').each(function() {
	var jQuerysearch = jQuery(this);
	var jQuerysearchInput = jQuerysearch.find('input');
	var jQuerysearchLabel = jQuerysearch.find('label');

	if (jQuerysearchInput.val())	{
		jQuerysearchLabel.hide();
	}

	jQuerysearchInput.focus(function() {
			jQuerysearchLabel.hide();
		}).blur(function() {
			if (this.value == '') {
				jQuerysearchLabel.css('display','');
			}
		});

		jQuerysearchLabel.click(function() {
			jQuerysearchInput.trigger('focus');
		});
});

jQuery('.booksearch').each(function() {
	var jQuerysearch = jQuery(this);
	var jQuerysearchInput = jQuerysearch.find('input');
	var jQuerysearchLabel = jQuerysearch.find('label');

	if (jQuerysearchInput.val())	{
		jQuerysearchLabel.hide();
	}

	jQuerysearchInput.focus(function() {
			jQuerysearchLabel.hide();
		}).blur(function() {
			if (this.value == '') {
				jQuerysearchLabel.css('display','');
			}
		});

		jQuerysearchLabel.click(function() {
			jQuerysearchInput.trigger('focus');
		});
});

	/* common mouseover/mouseout */
	jQuery('img.onoff').each(function() {	
		jQuery(this).mouseenter(function() {
			imageOver(this);
		});
		jQuery(this).mouseleave(function() {
			imageOut(this);
		});
	});

	/* common mouseover/mouseout */
	jQuery('img.clk').each(function() {	
		jQuery(this).css('cursor', 'pointer');
		jQuery(this).toggle(function() {
			imageOver(this);
		}, function() {
			imageOut(this);
		});
	});

/* main banner list */
jQuery('div.mainbanroll').each(function() {
	var spacing = 150;

	jQuery('div.mainbanroll').css({
		'width' : '953px',
			'height' : '46px',
			'overflow' : 'hidden'
	}).find('li').css({
		'float': 'none',
		'position' : 'absolute',
		'left' : 1000
	});

	var setUpCovers = function() {
		var jQuerycovers = jQuery('ul.banlist li');
		var jQueryupbtn = jQuery('p.rightbtn img');
		var jQuerydownbtn = jQuery('p.leftbtn img');

		jQueryupbtn.unbind('click');
		jQuerydownbtn.unbind('click');

		jQuerycovers.eq(0).css('left', 0);
		jQuerycovers.eq(1).css('left', spacing);
		jQuerycovers.eq(2).css('left', spacing * 2);
		jQuerycovers.eq(3).css('left', spacing * 3);
		jQuerycovers.eq(4).css('left', spacing * 4);
		jQuerycovers.eq(5).css('left', spacing * 5);

		jQueryupbtn
			.click(function(event) {
				jQuerycovers.eq(0).animate({'left': spacing}, 'fast');
				jQuerycovers.eq(1).animate({'left': spacing * 2}, 'fast');
				jQuerycovers.eq(2).animate({'left': spacing * 3}, 'fast');
				jQuerycovers.eq(3).animate({'left': spacing * 4}, 'fast');
				jQuerycovers.eq(4).animate({'left': spacing * 5}, 'fast');
				jQuerycovers.eq(5).animate({'left': spacing * 6}, 'fast');
				jQuerycovers.eq(jQuerycovers.length - 1)
					.css('left', -spacing)
					.animate({'left': 0}, 'fast', function() {
						jQuery(this).prependTo('div.mainbanroll ul');
						setUpCovers();
					});
				event.preventDefault(); 
			});
		
		jQuerydownbtn
			.click(function(event) {
				jQuerycovers.eq(0)
					.css('left', 0)
					.animate({'left': -spacing}, 'fast', function() {
						jQuery(this).appendTo('div.mainbanroll ul');
						setUpCovers();
					});
				jQuerycovers.eq(1).animate({'left':0}, 'fast');
				jQuerycovers.eq(2).animate({'left':spacing}, 'fast');
				jQuerycovers.eq(3).animate({'left': spacing * 2}, 'fast');
				jQuerycovers.eq(4).animate({'left': spacing * 3}, 'fast');
				jQuerycovers.eq(5).animate({'left': spacing * 4}, 'fast');
				jQuerycovers.eq(6)
					.css('left', spacing * 6)
					.animate({'left':spacing * 5}, 'fast');
				event.preventDefault();
			});
	};

	setUpCovers();
}); 

	/* main banner rolling 
	jQuery('div.mainbanroll').each(function() {
		jQuery(this).children().children('li:eq(8)').addClass('last');
		jQuery(this).children().children('li').each(function() {
			var jQueryaltxt = jQuery(this).find('img').attr("alt");
			jQuery('<span class="altxt"></span>').appendTo(this).text(jQueryaltxt);
		})		
	}); */

	/* common popup */
	jQuery('a.popupbtn').each(function() {	
		var popupid = jQuery(this).attr('href');
		jQuery(this).click(function() {
			jQuery('div' + popupid).css('display', 'block');

			return false;
		});
	});
	jQuery('p.popclose').click(function() {
		jQuery(this).parent().css('display', 'none');
	});


	/* membership - id/pw check */
	jQuery('#idpw').each(function() {
		jQuery('label.lp').click(function() {
			jQuery('tbody.lp').show();
			jQuery('tbody.lc').hide();
			jQuery('tbody.bp').hide();
			jQuery('tbody.bc').hide();
		});
		jQuery('label.lc').click(function() {
			jQuery('tbody.lp').hide();
			jQuery('tbody.lc').show();
			jQuery('tbody.bp').hide();
			jQuery('tbody.bc').hide();
		});
		jQuery('label.bp').click(function() {
			jQuery('tbody.lp').hide();
			jQuery('tbody.lc').hide();
			jQuery('tbody.bp').show();
			jQuery('tbody.bc').hide();
		});
		jQuery('label.bc').click(function() {
			jQuery('tbody.lp').hide();
			jQuery('tbody.lc').hide();
			jQuery('tbody.bp').hide();
			jQuery('tbody.bc').show();
		});
	});

	/* main - notice / qna tab */
	jQuery('.subjectmv').each(function() {
		jQuery(this).find('p.notice').children('a').click(function() {
			jQuery('#qnalist').hide();
			jQuery('#noticelist').show();
		});
		jQuery(this).find('p.qna').children('a').click(function() {			
			jQuery('#noticelist').hide();
			jQuery('#qnalist').show();
		});
	});

	/* membership - namecheck tab */
	jQuery('.namecheckdiv').each(function() {
		jQuery(this).find('li.local').children('a').click(function() {
			jQuery('#foreigners.namecheckdiv').hide();
			jQuery('#local.namecheckdiv').show();
		});
		jQuery(this).find('li.foreigners').children('a').click(function() {			
			jQuery('#local.namecheckdiv').hide();
			jQuery('#foreigners.namecheckdiv').show();
		});
	});

	/* business room - estimate/inquire tab */
		jQuery("#inbox").find('li.estimate').children('a').click(function() {
			jQuery('#inbox').hide();
			jQuery('#esbox').show();
		});
		jQuery('#esbox').find('li.inquire').children('a').click(function() {			
			jQuery('#esbox').hide();
			jQuery('#inbox').show();
		});

	/* Schedule tip */
	var jQueryScheduleTip = jQuery('#scheduleList');
	var positionScheduleTip = function(event) {
//		var tPosX = event.pageX + 10;
		var tPosY = event.pageY + 0;
		jQueryScheduleTip.css({top: tPosY, left:"50px"});
	}
	var showScheduleTip = function(event) {
		jQueryScheduleTip.show();
		positionScheduleTip(event);
	}
	var hideScheduleTip = function() {
		jQueryScheduleTip.hide();
	};
	var havScheduleDate = jQuery('table.maincalen td a');
	havScheduleDate.hover(showScheduleTip);

		jQuery('div#scheduleList').mouseleave(function() {
			jQuery('div#scheduleList').hide();
		});	
		jQuery('li.start').each(function() {	
			jQuery(this).css('font-weight', 'bold');
			jQuery(this).toggle(function() {
				imageOver(this);
			}, function() {
				imageOut(this);
			});
		});

/* jQuery end */
});

/* png24 for ie6 */
function setPng24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bpng24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src='blank.gif';  
    return ''; 
} 
