// Form
function validateSearchForm() {
	if(!validateEmpty(this.query, '검색어를 입력해주세요.')) return false;
	return true;
}

function confirmDelete() {
	if(confirm('정말로 삭제하시겠습니까?')) {
		$('#delete_frm').submit();
	}
	
	return false;
}

function showPrivacyPolicy() {
	window.open(this.href, 'privacy_popup', 'width=700px, height=715px, resizable=no, scrollbars=yes, menubars=no, status=no');
	return false;
}

function showFamilySite() {
	window.open($(this).val(), '', '');
}

function printPage() {
	window.print();
	return false;	
}

// Editor
function hideImageUpload(editor) {
	$('#' + editor).hide_image_upload();
}

function insertImage(editor, filepath) {
	$('#' + editor).paste_html('<p><img src="' + filepath + '?cmd=thumb&width=600" /></p>');
	hideImageUpload(editor);
}

function getAttachableType() {
	return $('input[name=attachable]').val();	
}

function getAttachableId() {
	var $aid = $('input[name=pid]');
	if($aid.length == 0) $aid = $('input[name=id]');
	
	return $aid.val();
}

function showDeliciiousSave() {
	var link = this.href;
	link += '?v=5&noui&jump=close&url=' + encodeURIComponent(document.location.href);
	link += '&title=' + encodeURIComponent($('.title').text());
	
	window.open(link, 'facebook_share', 'width=550px, height=550px, scrollbars=no');
	return false;	
}

// 투명png파일 스크립트
function setPng24(obj) {
	if(typeof document.body.style.maxHeight == 'undefined') { 
		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 = '';
		return;
	}
}

// GNB
function setLayer(h) {
//	console.log(h);
	$('#gnb').height(h + 'px');
}

function toggleOverImg(container, target) {
	var $img = $('img', target);
	
	// Change tab image.
	$('img', container).each(function() {
		$(this).attr('src', $(this).attr('src').replace('_on', ''));
	});
	$img.attr('src', $img.attr('src').replace('\.gif', '_on.gif'));
}

// TAB
$(window).load(function () {
	$('ul.tabstyle img').mouseover(function(){
		$(this).attr('src').indexOf('_on.gif');
		if($(this).attr('src').indexOf('_on.gif') == -1){
			$(this).attr('src', $(this).attr('src').replace('.gif', '_on.gif'));
			$(this).mouseout(function(){
				$(this).attr('src', $(this).attr('src').replace('_on.gif', '.gif'));
			});
		}
	});
});

// Contact us
function showContactUs() {
	window.open('/en/customer/contact_us.asp', 'contact_us_pop', 'width=620px, height=370px');
}

function showCertification() {
	window.open(this.href, 'cert_popup', 'width=920px, height=600px, scrollbars=1');
	return false;
}
