// 郵便番号探し(fname=formname, p1=postcode1, p2=postcode2, a1=addr1, a2=addr2)
function post(fname, p1, p2, a1, a2, zno) {
	var url = "/postcode.php?type="+fname+"&p1="+p1+"&p2="+p2+"&a1="+a1+"&a2="+a2+"&zno="+zno;
	postWin=window.open(url, "zip","height=260,width=480,menubar=no,directories=no,resizable=no,status=no,scrollbars=yes");
	postWin.focus();
}

function user_info_modify(uid) {
	var url = "/member/registration02.html?uid="+uid;
	window.top.location = url;
	//var userInfo = window.showModelessDialog(url, '_modify', "dialogwidth:748px;dialogheight:507px;status:0;help:0;center:1;resizable:0;scrollbars:1");
}

function discussion_proposal() {
	var url = "/trans_bulletin/discussion_proposal.html";
	var userInfo = window.showModelessDialog(url, '_propoal', "dialogwidth:625px;dialogheight:507px;status:0;help:0;center:1;resizable:0;scrollbars:1");
}

// id 重複確認
function idCheck(fname, chf) {
	if(document.member.id.value=='') {
		alert('アイディーを先に入力してください.');
		document.member.id.focus();
		return;
	} else {
		var idStr =  document.member.id.value;
	}

	var url = "/idcheck.php?form="+fname+"&id="+idStr+"&chf="+chf;
	newWin = window.open(url, "idcheck", "height=248,width=350,menubar=no,directories=no,resizable=no,status=no,scrollbars=no");
	newWin.focus();
}

function loginCheck() {
	if(document.mlogin.id.value=='') {
		alert('アイディーを入力してください!');
		document.mlogin.id.focus();
		return false;
	} else if(document.mlogin.passwd.value=='') {
		alert('パスワードを入力してください!');
		document.mlogin.passwd.focus();
		return false;
	} 	
	if ( document.mlogin.SSL_Login.checked ) { 
		document.mlogin.action = "https://pay.gokorea.jp/member/login.php";
	} else {
		document.mlogin.action = "http://www.gokorea.jp/member/login.php";
	}
return true; 
}

// ハングルがあるのかないのかチェック(あったら false)
function check_hangul(str) {
	for (var i = 0; i < str.length; i++) {
		if (str.charCodeAt(i) > 127) return false;
	}
	return true;
}

// クッキー値が存在するのかチェック
function is_cookie(Name) {
	var search = Name + "=";
	if(document.cookie.length > 0) {
		var offset = document.cookie.indexOf(search);
		if(offset == -1) return false;
		else {
			offset += search.length;
			var end_idx = document.cookie.indexOf(";", offset);
			if (end_idx <= 0) end_idx = document.cookie.length;
			var user = document.cookie.substring(offset, end_idx);
			if(user.length >= 4) return true;
			else return false;
		}
	} else {
		return false;
	}
}

function loginMsg() {
	alert('ログイン後使うことができます。');
}

// 数字チェック
function containsCharsOnly(input,chars) {
	for (var inx = 0; inx < input.value.length; inx++) {
		if (chars.indexOf(input.value.charAt(inx)) == -1)
		return false;
	}
	return true;
}

function isNumber(input) {
	var chars = "0123456789";
	return containsCharsOnly(input,chars);
}


// 電子メールチェック
function isEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) return true;
	else return false;
}

//会員IDが英文科数字, '_' の組合だけでなっているのかチェックする関数
function CheckID(str) {
	var ch;
	for (i=0 ; i < str.length ; i++ ) {
		ch = str.charCodeAt(i);
		if((ch >=48 && ch <= 57) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || ch == 95) {
			continue;
		} else {
			return false;
		}
	}
	return true;
}

// アップロード可能なファイルなのかチェック(イメージファイル)
function allow_image(file) {
	var allowSubmit = false;
	var extArray = new Array(".gif", ".jpg", ".png");

	extArray.join(" ");

	if (!file) return;

	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);

	var ext = file.slice(file.indexOf(".")).toLowerCase();

	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) {
			return true;
		}
	}

	return false;
}

 // 文字入力禁止関数設定
function CheckKeys()
{
	if( event.keyCode < 48 || event.keyCode > 57)
	{
		event.keyCode=0;
	}
}


function go_login() {
	var thisUrl = escape(document.location);
	document.location.href='/member/login.html?returnUrl='+thisUrl;
}

// 日本ニュース検索
function newsSearch(theForm) {
	theForm.QR.value = theForm.QR.value.replace(/(^\s*)|(\s*$)/g, "");
	w=screen.width-50;
	h=screen.height-250;
	if (theForm.QR.value == "") {
		alert("検索キーワードを入力しませんでした。");
		theForm.QR.focus();
	} else {

		if(theForm.nwhere.options[theForm.nwhere.selectedIndex].value == "infoseek") {
			var temp = "http://news.www.infoseek.co.jp/search/results.html?query="+theForm.QR.value;
		} else if(theForm.nwhere.options[theForm.nwhere.selectedIndex].value == "mainichi") {
			var temp = "http://search.mainichi.co.jp/cgi-bin/news/search.cgi?keyword="+theForm.QR.value;
		} else if(theForm.nwhere.options[theForm.nwhere.selectedIndex].value == "sankei") {
			var temp = "http://ez.st37.arena.ne.jp/cgi-bin/search/namazu.cgi?whence=0&whence=0&max=20&result=short&sort=date%3Alate&idxname=nat&idxname=spo&idxname=pol&idxname=bus&idxname=int&idxname=bun&idxname=1m&query="+theForm.QR.value;
		} else if(theForm.nwhere.options[theForm.nwhere.selectedIndex].value == "nhk") {
			var temp = "http://search.nhk.or.jp/new/query.html?qt="+theForm.QR.value;
		}

		var trans = window.open("/webtrans/keyword_check.php?keyword="+theForm.QR.value+"&url="+temp,"_blank","left=1,top=1,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");

		//trans.focus();
	}
	return false;
}

// 日本郵便番号検索
function JPostSearch(theForm) {
	for(i = 0 ; i < theForm.kind.length ; i++) {
		if(theForm.kind[i].checked==true) {
			var kind=theForm.kind[i].value;
			break;
		}
	}
	if(!kind) kind = "2";
	var url = "http://channel.goo.ne.jp/postcode/search.php";
	var theURL = url+"?kind="+kind+"&MT="+theForm.MT.value;
	if(theForm.MT.value == '') {
		alert('検索キーワードを入れてください!');
		theForm.MT.focus();
		return false;
	} else {
		var trans  = window.open("/webtrans/url_check.php?url="+theURL,"_blank","left=1,top=1,width=800,height=550,status=yes,resizable=yes,toolbar=no");
		//trans.focus();

	}
	return false;
}

// 音楽情報検索
function JMusicSearch(theForm) {
	for(i = 0 ; i < theForm.u0.length ; i++) {
		if(theForm.u0[i].checked==true) {
			var u0=theForm.u0[i].value;
			break;
		}
	}
	var theURL = theForm.surl.value+"?u0="+u0+"&query="+theForm.query.value;
	if(theForm.query.value == '') {
		alert('検索キーワードを入れてください!');
		theForm.query.focus();
		return false;
	} else {
		var trans  = window.open("/webtrans/url_check.php?url="+theURL,"_blank","left=1,top=1,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
		//trans.focus();
	}
	return false;
}

// URL 検索
function url_search(theForm) {
	w=screen.width-50;
	h=screen.height-250;
	if(theForm.url.value=='') {
		alert('翻訳するサイトを入力してください。');
		return false;
	} else {
		var url_comp = theForm.url.value.replace('http://','');
		if(url_comp=='') {
			alert('翻訳するサイトを入力してください。');
			return false;
		} else {
			var theURL = 'http://'+url_comp;
			var theURL = escape(theURL);
			var trans  = window.open("/webtrans/url_check.php?url="+theForm.url.value,"_blank","left=1,top=1,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
			//trans.focus();

			return false;
		}
	}
}

// ウェプ翻訳リンク
function web_trans(theURL) {
	w=screen.width-50;
	h=screen.height-250;
	if(theURL.substring(0,7) != 'http://') {
		theURL = 'http://'+theURL;
	}
	var theURL = escape(theURL);
	var trans  = window.open("http://www.gokorea.jp/webtrans/url_check.php?url="+theURL,"_blank","left=1,top=120,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
	return;
	//trans.focus();
}
function web_xtrans(theURL) {
	w=screen.width-50;
	h=screen.height-250;
	trans  = window.open("http://www.gokorea.jp/webtrans/?xurl="+theURL,"_blank","left=1,top=120,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
	trans.focus();
	//trans.focus();
}
// ウェプ翻訳リンク
function web_xtrans_kr(theURL) {
	w=screen.width-50;
	h=screen.height-250;
	trans  = window.open("http://www.gojapan.com/webtrans/?xurl="+theURL,"_blank","left=1,top=120,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
	trans.focus();
	//trans.focus();
}
// onClick 翻訳検索
function searchWord(keyWord) {
	w=screen.width-50;
	h=screen.height-250;
	var temp = "http://search.naver.com/search.naver?query="+keyWord;
//	var temp = "http://www.waazle.com/bbs/search.php?stx="+keyWord;
	keyWord=escape(keyWord);
	temp=escape(temp);
	var trans  = window.open("http://www.gokorea.jp/webtrans/keyword_check.php?keyword="+keyWord+"&url="+temp,"_blank","left=1,top=1,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
	return false;
	//trans.focus();
}


function bookWord(keyWord) {
	var temp = "http://100.naver.com/search.nhn?query="+keyWord;
	keyWord=escape(keyWord);
	temp=escape(temp);
	var trans  = window.open("http://www.gokorea.jp/webtrans/keyword_check.php?keyword="+keyWord+"&url="+temp,"_blank","left=1,top=1,width=800,height=550,status=yes,resizable=yes,toolbar=no");
	return false;
}



// clickSearch
function onClickSearch(keyWord,site) {
	w=screen.width-50;
	h=screen.height-250;
	if(!is_cookie('cs_user[id]')) {
		loginMsg();
		go_login();
		return;
	} else {
		if(site == "yahoo") {
			var temp = "http://search.yahoo.co.jp/bin/search?p="+keyWord;
		} else if(site == "google") {
			var temp = "http://www.google.co.jp/search?hl=ja&lr=lang_ja&q="+keyWord;
		} else if(site == "infoseek") {
			var temp = "http://www.infoseek.co.jp/OTitles?lk=noframes&qp=0&st=0&nh=10&col=WW&svp=SEEK&svx=100600&qt="+keyWord;
		} else if(site == "excite") {
			var temp = "http://www.excite.co.jp/search.gw?target=combined&lk=excite_jp&lang=jp&c=web&search="+keyWord;
		} else {
			document.query.QR.value=keyWord;
			document.query.method="GET";
			document.query.action="/trans_web/search.html";
			document.query.submit();
			return;
		}
		window.open("/webtrans/keyword_check.php?keyword="+keyWord+"&url="+temp,"_blank","left=1,top=1,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
	}
}


// キーワード検索
function search(theForm) {
	w=screen.width-50;
	h=screen.height-250;
	theForm.QR.value=theForm.QR.value.toUpperCase();
	var tmp=escape(theForm.QR.value);
	if (tmp == "") {
		alert("検索キーワードを入力しませんでした。");
		theForm.QR.focus();
	} else {
		if(theForm.where.value == "naver") {
			var temp = "http://search.naver.com/search.naver?query="+tmp;
		} else if(theForm.where.value == "daum") {
			var temp = "http://search.daum.net/cgi-bin/nsp/search.cgi?q="+tmp;
		} else if(theForm.where.value == "google") {
			var temp = "http://www.google.co.kr/search?hl=ko&q="+tmp;
		} else if(theForm.where.value == "wiki") {
			var temp = "http://ko.wikipedia.org/wiki/"+tmp;
		} else {
			theForm.method="GET";
			theForm.action="/trans_web/search.html";
			return true;
		}
		var trans  = window.open("/webtrans/keyword_check.php?keyword="+tmp+"&url="+temp,"_blank","left=1,top=1,width="+w+",height="+h+",status=yes,resizable=yes,toolbar=no");
		//trans.focus();
	}

	return false;
}

function mainPopup(url,size)
{
  if(GetCookie("jp_GoKoreaPop")==null){
    var win = window.open(url,'jp_GoKoreaPop',size);
    win.focus();
  }
}

function GetCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while(i < clen) {
    var j = i + alen;
    if(document.cookie.substring(i, j) == arg) {
      var end = document.cookie.indexOf(";", j);
      if(end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(j, end));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if(i == 0) break;
  }
  return null;
}

function mainPopup2(url,size)
{
  if(GetCookie("jp_GoKoreaPop2")==null){
    var win = window.open(url,'jp_GoKoreaPop2',size);
    win.focus();
  }
}

function GetCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while(i < clen) {
    var j = i + alen;
    if(document.cookie.substring(i, j) == arg) {
      var end = document.cookie.indexOf(";", j);
      if(end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(j, end));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if(i == 0) break;
  }
  return null;
}

var checkMedia=true;
function LayerMove(id,type){
if(id=="jHotList"||id=="jAreaList"||id=="jTrendZone"||id=="jMultimedia"){
AjaxLayerMove(id,type);
}else{
GeneralLayerMove(id,type);
}
}
function GeneralLayerMove(id,type){
var obj=document.getElementById(id);
var childObj;
var count;
if(checkMedia){
if(id=="jHotList"||id=="jAreaList"||id=="jTrendZone"){
childObj=obj.getElementsByTagName("DIV");
}else{
childObj=obj.getElementsByTagName("UL");
}
for(var i=0;i<childObj.length;i++){
if(childObj[i].style.display=="block"){
childObj[i].style.display="none";
count=i;
}
}
if(type=="next"){
if(count==childObj.length-1)count=0;
else count++;
}else if(type=="prev"){
if(count==0)count=childObj.length-1;
else count--;
}
childObj[count].style.display="block";
}
}
function AjaxLayerMove(id,type){
var obj=document.getElementById(id);
var childObj;
var count;
var bLoaded=false;
if(id=="jHotList"){
bLoaded=im_bIssueLoad;
}else if(id=="jAreaList"){
bLoaded=im_bLocalLoad;
}else if(id=="jTrendZone"){
bLoaded=im_bTrendLoad;
}else if(id=="jMultimedia"){
bLoaded=im_bMediaLoad;
}else if(id=="goodsList"){
bLoaded=im_bShop1Load;
}else if(id=="goodsList02"){
bLoaded=im_bShop2Load;
}
if(bLoaded){
if(id=="jHotList"||id=="jAreaList"||id=="jTrendZone"){
childObj=obj.getElementsByTagName("DIV");
}else{
childObj=obj.getElementsByTagName("UL");
}
for(var i=0;i<childObj.length;i++){
if(childObj[i].style.display=="block"){
childObj[i].style.display="none";
count=i;
}
}
if(type=="next"){
if(count==childObj.length-1)count=0;
else count++;
}else if(type=="prev"){
if(count==0)count=childObj.length-1;
else count--;
}
childObj[count].style.display="block";
}
}