//-----------------------------------------------------------------------------------
function OneClick(inside){
	var check=1;
	var copyText=eval("document."+inside);
	copyText.focus();
	copyText.select();
	if(document.all&&check==1) {
		txt=copyText.value
	    txRange=copyText.createTextRange();
    	txRange.execCommand('copy');
		if (txt.indexOf("<")==0) {
    		alert("『リンクタグ』をクリップボードにコピーしました");
		}else{
    		alert("『紹介文』をクリップボードにコピーしました");
		}
 	 }
}

//-----------------------------------------------------------------------------------
function idCheck(){
	if(document.myForm.id.value){
		lid.innerText="大切に保管して下さい。";
	}else{
		lid.innerText='';
	}
}

//-----------------------------------------------------------------------------------
function pwCheck(){
	if(document.myForm.pw.value){
		lpw.innerText="大切に保管して下さい。";
	}else{
		lpw.innerText='';
	}
}

//-----------------------------------------------------------------------------------
function FixOn(){
	document.getElementById('pfirst').disabled=false;
	document.myForm.chk_first.disabled=false;
	document.getElementById('fs1').style.color='black';
}

//-----------------------------------------------------------------------------------
function FreeOn(){
	document.getElementById('pfirst').disabled=true;
	document.myForm.chk_first.disabled=true;
	document.getElementById('fs1').style.color='silver';
}

//-----------------------------------------------------------------------------------
function CheckOn(){
	if (document.myForm.chk_first.checked){
    	fs2.innerText="　※ページ位置の記憶が失われます。";
		document.getElementById('fs2').style.color='red';
	}else{
    	fs2.innerText=" ";
	}
}

//-----------------------------------------------------------------------------------
function MailOn(){
	document.getElementById('tken').disabled=false;
	document.myForm.subject.readOnly=false;
	document.myForm.subject.style.backgroundColor='#FFFFFF';
}

//-----------------------------------------------------------------------------------
function MailOff(){
	document.getElementById('tken').disabled=true;
	document.myForm.subject.readOnly=true;
	document.myForm.subject.style.backgroundColor='#DBDBDB';
}

//-----------------------------------------------------------------------------------
function request_input_check(){
	cell=document.myForm.toname;
	txt=cell.value;
	if (!txt) {
    	alert("宛先が未入力です。");
		cell.focus();
		return false;
	}
	cell=document.myForm.mail_addr;
	txt=cell.value;
	if (!txt) {
    	alert("メールアドレスが未入力です。");
		return false;
		cell.focus();
	}
}


//-----------------------------------------------------------------------------------
function input_check(para){
	myDomain=document.myForm.myDomain.value;
	myDomain=myDomain.replace("http://","")
	myDomain=myDomain.replace("/","")
	
	cell=document.myForm.site_name;
	txt=cell.value;
	if(!txt) {
    	alert("サイト名を入力してください。");
		cell.focus();
		return false;
	}
	if(jstrlen(txt) > 80){
    	alert("サイト名が４０文字を超えています。");
		cell.focus();
		return false;
	}
	if(txt.indexOf('http') != -1 ){
	    alert("ＵＲＬでなく、サイト名を入力してください。");
		cell.focus();
		return false;
	}

	cell=document.myForm.your_url;
	txt=cell.value;
	if(!txt || txt=="http://") {
		if(para=='admin_j'){
    		alert("リンク先ＵＲＬを入力してください。");
    	}else{
    		alert("貴ＵＲＬを入力してください。");
		}
		cell.focus();
		return false;
	}
	if(jstrlen(txt) > 80){
		if(para!='admin_j'){
		   	alert("貴ＵＲＬが８０文字を超えています。");
		}
		cell.focus();
		return false;
	}
	if(txt.indexOf('http') == -1 ){
	    alert("入力した内容は、ＵＲＬではありません。");
		cell.focus();
		return false;
	}

	if(txt.indexOf(myDomain) != -1){
	    alert("当社のＵＲＬではなく、貴ＵＲＬを入力してください。");
		cell.focus();
		return false;
	}
	txt=txt.match(/(http|ftp):\/\/[!#-9A-~]+\.+[a-z0-9]/i);
	if (!txt){
	    alert("ＵＲＬが間違っています。");
		cell.focus();
		return false;
	}

	cell=document.myForm.comment;
	txt=cell.value;
	if(jstrlen(txt) > 200){
    	alert("紹介文が１００文字を超えています。");
		cell.focus();
		return false;
	}
	if(txt.indexOf("\n") != -1 ){
    	alert("紹介文に改行は使用できません。");
		cell.focus();
		return false;
	}

	if(para=='general_j'){
		if(document.myForm.act == 'regist_admin'){
			return true;
		}
		cell=document.myForm.link_url;
		txt=cell.value;
		if(txt == '' || txt == 'http://'){
	    	alert("相互リンク設置ＵＲＬを入力してください。");
			cell.focus();
			return false;
		}	
		if (!(txt.match(/(http|ftp):\/\/[!#-9A-~]+\.+[a-z0-9]/i))){
			alert("ＵＲＬが間違っています。");
			cell.focus();
			return false;
		}
		if(txt.indexOf(document.myForm.your_url.value) == -1){
	    	alert("貴ＵＲＬと相互リンク設置ＵＲＬのドメインが違います。");
			cell.focus();
			return false;
		}
	}
}

//-----------------------------------------------------------------------------------
function search_input_check(){
	cell=document.myForm.your_url;
	txt=cell.value;
	if (!txt || txt=="http://") {
    	alert("検索URLが未入力です。");
		cell.focus();
		return false;
	}
}

//-----------------------------------------------------------------------------------
function initialize_check(){
	cell=document.myForm.company;
	txt=cell.value;
	if (!txt) {
    	alert("会社名が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.incharge;
	txt=cell.value;
	if (!txt) {
    	alert("担当者名が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.zipcode;
	txt=cell.value;
	if (!txt) {
    	alert("郵便番号が未入力です。");
		cell.focus();
		return false;
	}
	txt=txt.match(/^\d{3}-\d{4}$|^\d{3}-\d{2}$|^\d{3}$/);
	if (!txt) {
    	alert("郵便番号が不正です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.address;
	txt=cell.value;
	if (!txt) {
    	alert("住所 が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.phone;
	txt=cell.value;
	if (!txt) {
    	alert("電話番号が未入力です。");
		cell.focus();
		return false;
	}
	txt=txt.match(/^\d{1,4}-\d{4}$|^\d{2,5}-\d{1,4}-\d{4}$/);
	if (!txt) {
    	alert("電話番号が不正です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.myDomain;
	txt=cell.value;
	if (!txt) {
    	alert("自分のURLが未入力です。");
		cell.focus();
		return false;
	}
	if(txt.charAt(txt.length-1) != '/'){
    	alert("自分のURLが不正です。");
		cell.focus();
		return false;
	}
	txt=txt.match(/(http|ftp):\/\/[!#-9A-~]+\.+[a-z0-9]/i);
	if (!txt) {
    	alert("自分のURLが不正です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.email;
	txt=cell.value;
	if (!txt) {
    	alert("メールアドレスが未入力です。");
		cell.focus();
		return false;
	}
	txt=txt.match(/^\S+@\S+\.\S+$/);
	if (!txt) {
    	alert("メールアドレスが不正です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.mySiteName;
	txt=cell.value;
	if (!txt) {
    	alert("自分のサイト名が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.comment;
	txt=cell.value;
	if (!txt) {
    	alert("自分のサイトの紹介文が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.contwidth;
	txt=cell.value;
	if (!txt) {
    	alert("メインコンテンツの巾が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.pv_general;
	txt=cell.value;
	if (!txt) {
    	alert("１ページ当りの表示件数 （一般用）が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.pv_admin;
	txt=cell.value;
	if (!txt) {
    	alert("１ページ当りの表示件数 （管理者用）が未入力です。");
		cell.focus();
		return false;
	}

	if(document.myForm.mailon=="yes"){
		cell=document.myForm.subject;
		txt=cell.value;
		if (!txt) {
	    	alert("登録通知用メールの件名が未入力です。");
			cell.focus();
			return false;
		}
	}

	cell=document.myForm.ngWord;
	txt=cell.value;
	if (!txt) {
    	alert("相互リンク依頼用メールの件名が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.tmpsubject;
	txt=cell.value;
	if (!txt) {
    	alert("相互リンク依頼メールのテンプレート名が未入力です。");
		cell.focus();
		return false;
	}

	cell=document.myForm.mailTemplate;
	txt=cell.value;
	if (!txt) {
    	alert("相互リンク依頼メールテンプレート内容が未入力です。");
		cell.focus();
		return false;
	}
}

//-----------------------------------------------------------------------------------
function deleteOK(){
	if(confirm("削除すると元に戻せなくなります。本当によろしいですか？")){
		return true;
	}else{
		return false;
	}
}

//-----------------------------------------------------------------------------------
function jstrlen(str){
	len = 0;
	str = escape(str);
	for(i=0;i<str.length;i++,len++){
	if(str.charAt(i) == "%"){
		if(str.charAt(++i) == "u"){
			i += 3;
			len++;
		}
		i++;
	}
	}
	return len;
}

//-----------------------------------------------------------------------------------
function license_check(fcName){
	if(fcName=="lic1"){
		if(document.myForm.lic1.value.length==4){
			if(document.myForm.lic2.value==""){
				document.myForm.lic2.focus();
			}
		}else if(document.myForm.lic1.value.length>4){
			document.myForm.lic1.value = document.myForm.lic1.value.substring(0, 4);
		}
	}else if(fcName=="lic2"){
		if(document.myForm.lic2.value.length==4){
			if(document.myForm.lic3.value==""){
				document.myForm.lic3.focus();
			}
		}else if(document.myForm.lic2.value.length>4){
			document.myForm.lic2.value = document.myForm.lic2.value.substring(0, 4);
		}
	}else if(fcName=="lic3"){
		if(document.myForm.lic3.value.length==4){
			if(document.myForm.lic4.value==""){
				document.myForm.lic4.focus();
			}
		}else if(document.myForm.lic3.value.length>4){
			document.myForm.lic3.value = document.myForm.lic3.value.substring(0, 4);
		}
	}else if(fcName=="lic4"){
		if(document.myForm.lic4.value.length==4){
			if(document.myForm.lic5.value==""){
				document.myForm.lic5.focus();
			}
		}else if(document.myForm.lic4.value.length>4){
			document.myForm.lic4.value = document.myForm.lic4.value.substring(0, 4);
		}
	}else if(fcName=="lic5"){
		if(document.myForm.lic5.value.length==4){
			document.myForm.ok.disabled=false;
		}else if(document.myForm.lic5.value.length>4){
			document.myForm.lic5.value = document.myForm.lic5.value.substring(0, 4);
		}
	}

	if(document.myForm.lic1.value.length==4 && document.myForm.lic2.value.length==4 && document.myForm.lic3.value.length==4 && document.myForm.lic4.value.length==4 && document.myForm.lic5.value.length==4){
		document.myForm.ok.disabled=false;
	}else{
		document.myForm.ok.disabled=true;
	}
}
