/*
 * Default JavaScript ($Revision: 1561 $)
 *
 */
/* 플레시 호출 함수 */
function swf_obj(src,w,h,swfid){
	swf_html = '';
	swf_html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'" id="'+swfid+'">';
	swf_html += '<param name="allowScriptAccess" value="always">';
	swf_html += '<param name="movie" value="'+src+'">';
	swf_html += '<param name="quality" value="high">';
	swf_html += '<param name="bgcolor" value="#FFFFFF">';
	swf_html += '<PARAM NAME="wmode" VALUE="transparent">';
	swf_html += '<embed src="'+src+'" quality="high" bgcolor="#FFFFFF" width="'+w+'" height="'+h+'" name="'+swfid+'" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	swf_html += '</object>';
	document.write(swf_html);
}

function open_vk_map(x, y, lev, title) {
	if ((arguments.length == 1) && (typeof x == "string")) {
		var url = x;
	} else {
		if ((typeof lev == "undefined") || (lev == "")) lev = "7";
		var url = "http://emap.visitkorea.or.kr/mapurl/"+x+"-"+y+lev+"&cpname="+title;
	}
	popupMap =  window.open(url,'mapSearch','fullscreen=no,type=Fullwindow');
	popupMap.focus();
}


var pwsL10n = {
 	empty: "<?php echo esc_js( _mp( 'Strength indicator' ) ); ?>",
 	short: "<?php echo esc_js( _mp( 'Very weak' ) ); ?>",
 	bad: "<?php echo esc_js( _mp( 'Weak' ) ); ?>",
 	good: "<?php echo esc_js( _mp( 'Medium' ) ); ?>",
 	strong: "<?php echo esc_js( _mp( 'Strong' ) ); ?>",
 	mismatch: "<?php echo esc_js( _mp( 'Mismatch' ) ); ?>"
};
try{convertEntities(pwsL10n);}catch(e){};

// Password strength meter
function passwordStrength(password1, username, password2) {
	var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;

	// password 1 != password 2
	if ( (password1 != password2) && password2.length > 0)
		return mismatch

	//password < 4
	if ( password1.length < 4 )
		return shortPass

	//password1 == username
	if ( password1.toLowerCase() == username.toLowerCase() )
		return badPass;

	if ( password1.match(/[0-9]/) )
		symbolSize +=10;
	if ( password1.match(/[a-z]/) )
		symbolSize +=26;
	if ( password1.match(/[A-Z]/) )
		symbolSize +=26;
	if ( password1.match(/[^a-zA-Z0-9]/) )
		symbolSize +=31;

	natLog = Math.log( Math.pow(symbolSize, password1.length) );
	score = natLog / Math.LN2;

	if (score < 40 )
		return badPass

	if (score < 56 )
		return goodPass

    return strongPass;
}

function del_comment_en(href) {
	if(confirm("Are you sure you want to delete?")) {
		document.location.href = href;
	}
}
function del_comment_ja(href) {
	if(confirm("削除しますか？")) {
		document.location.href = href;
	}
}


$(document).ready(function() {

	// 1Depth hover
	$('#Nav li').hover(
		function() {var submenu = '#sub' + $(this).attr('id');  showMenu('sub' + $(this).attr('id')); delTimeout_('sub' + $(this).attr('id'));},
		function() {setTimeout_('sub' + $(this).attr('id'));}
	);
	
	// submenu hover (hole)
	$('#submenu2, #submenu3').hover(
		function() {  showMenu($(this).attr('id')); delTimeout_($(this).attr('id'));},
		function() {setTimeout_($(this).attr('id'));}
	);

	/*  non-member comment edit & delet*/  
	$("a.comment_non_modify").click(function(){ 
		var editID = $(this).attr("id");
		$.fancybox({
			'width'				: 280,
			'height'			: 155,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'href'				: template_lang + '/comment/?type=pass_form&mode=non_modfiy&cid='+ editID,
			'type'				: 'iframe'
		});
		return false;
	});
	
	$("a.comment_non_delete").click(function(){ 
		var deleteID = $(this).attr("id");
		$.fancybox({
			'width'				: 280,
			'height'			: 155,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'href'				: template_lang + '/comment/?type=pass_form&mode=non_delete&cid='+ deleteID,
			'type'				: 'iframe'
		});
		return false;
	});
	
	
	/*  comment edit & delet*/  
	$("a.comment_modify").click(function(){ 
		var editID = $(this).attr("id");
		$.fancybox({
			'width'				: 280,
			'height'			: 155,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'href'				: template_lang + '/comment/?type=modfiy&cid='+ editID,
			'type'				: 'iframe'
		});
		return false;
	});
	
	$("a.comment_delete").click(function(){ 
		var deleteID = $(this).attr("id");
		$.fancybox({
			'width'				: 280,
			'height'			: 155,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'href'				: template_lang + '/comment/?type=delete&cid='+ deleteID,
			'type'				: 'iframe'
		});
		return false;
	});
	
	
});

var timeout = new Array();

function setTimeout_(id) {
	timeout[id] = setTimeout('hideMenu("'+id+'")', 50);
}
function delTimeout_(id) {
	clearTimeout(timeout[id]);
}

function hideMenu(id) {
	$('#'+id).hide();
	
/*
	if ($('#submenu div.display:visible').length == 0) {
		$('#'+id).show();
	}
*/
}

function showMenu(id) {
/*
	if ($('#submenu div.display:visible').length != 0) {
		$('#'+id).hide();
	}
*/
	
	$('#'+id).show();
}

/* 공백제거 함수 */
function trim(str) {
      str = str.replace(/^\s*/,'').replace(/\s*$/, '');
      return str;
}

function doSubmit(theform)
{
   //	var theForm = document.theform;

	if( trim(theform.comment.value) =="" )
	{
		alert('Contents are required');
		theform.comment.focus();
		return false;
	}
	return true;
}
function doSubmit_ja(theform)
{
   //	var theForm = document.theform;

	if( trim(theform.comment.value) =="" )
	{
		alert('内容を入力して下さい。');
		theform.comment.focus();
		return false;
	}
	return true;
}


function non_doSubmit(theform)
{

    if( trim(theform.author.value) =="" )
	{
		alert('Name is required');
		theform.author.focus();
		return false;
	}	
	if( trim(theform.comment_pass.value) =="" )
	{
		alert('password address is required');
		theform.comment_pass.focus();
		return false;
	}
	if( trim(theform.comment.value) =="" )
	{
		alert('Contents are required');
		theform.comment.focus();
		return false;
	}
	return true;
	
}

function non_doSubmit_ja(theform)
{

    if( trim(theform.author.value) =="" )
	{
		alert('名前を入力してく下さい。');
		theform.author.focus();
		return false;
	}	
	if( trim(theform.comment_pass.value) =="" )
	{
		alert('暗証番号を入力してください。');
		theform.comment_pass.focus();
		return false;
	}
	if( trim(theform.comment.value) =="" )
	{
		alert('内容を入力して下さい。');
		theform.comment.focus();
		return false;
	}
	return true;
	
}
