//共通javascript
function pop_center(w,h,url,name){ 
	LeftPosition=(screen.width-w)/2;
	TopPosition=(screen.height-h)/2;
	
	try { 
		window.open(
	        url, 
	        name,
	        "width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+", scrollbars=no");
	}catch (e) {} ;
}

function number_only() {
	if((event.keyCode<48)||(event.keyCode>57)){
		event.returnValue=false;
	}
}

function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();


if(navigator.appName=="Netscape"){
 (function(){
  var events = ["mousedown", "mouseover", "mouseout", "mousemove",
                "mousedrag", "click", "dblclick","keydown"];  
  for (var i = 0; i < events.length; i++){
   window.addEventListener(events[i], function(e){
    window.event = e;
   }, true);
  }
 }());
};

}
MM_reloadPage(true);


function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() {
	var ctop = document.documentElement.scrollTop;
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=MM_findObj(args[i]))!=null){
			v=args[i+2];
			if (obj.style) {
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			obj.visibility=v;
			obj.left=(event.clientX+20) + "px";
			obj.top=(ctop + event.clientY-20) + "px";
		}
	}
}

function MM_showHideLayers_center() {
	var ctop = document.documentElement.scrollTop;
	var i,p,v,obj,args=MM_showHideLayers_center.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=MM_findObj(args[i]))!=null){
			v=args[i+2];
			if (obj.style){
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			}
			obj.visibility=v;
			obj.left=((document.body.clientWidth/2)-(424/2)) + "px";
			obj.top=(ctop + event.clientY-20) + "px";
		}
	}
}

function MM_showHideLayers_login() {
	var ctop = document.documentElement.scrollTop;
	var i,p,v,obj,args=MM_showHideLayers_login.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
			if (obj.style){
				obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			}
			obj.visibility=v; 
			obj.left=((document.body.clientWidth/2)+330) + "px";
			obj.top=(ctop + event.clientY+30) + "px";
		}
	}
}
function inviteConfirm(){
	if(chkForm()){
		var ans = confirm("マイトモを申請しますか？");
		if(ans==true){
			document.invite.submit();
		}
	}
}

function chkForm(){
	if(document.getElementById('message').value == ''){
		alert('申請メッセージを入力してください');
		document.getElementById('message').focus();
		return false;
	}
	
	return true;
}



function messageConfirm(){
	if(chkForm_m()){
		document.message.submit();
	}
}

function chkForm_m(){
	str = document.getElementById('title_m').value;
	
	if(str.length >= 90){
		alert('タイトルが長すぎます');
		document.getElementById('title_m').focus();
		return false;
	}
	
	if(document.getElementById('title_m').value == ''){
		alert('タイトルを入力してください');
		document.getElementById('title_m').focus();
		return false;
	}
	
	if(document.getElementById('message_m').value == ''){
		alert('メッセージを入力してください');
		document.getElementById('message_m').focus();
		return false;
	}
	
	return true;
}

function messageConfirm_c(){
	if(chkForm_c()){
		document.message_comment.submit();
	}
}

function chkForm_c(){
	str = document.getElementById('title_c').value;
	
	if(str.length >= 90){
		alert('タイトルが長すぎます');
		document.getElementById('title_c').focus();
		return false;
	}
	
	if(document.getElementById('title_c').value == ''){
		alert('タイトルを入力してください');
		document.getElementById('title_m').focus();
		return false;
	}
	
	if(document.getElementById('message_c').value == ''){
		alert('メッセージを入力してください');
		document.getElementById('message_m').focus();
		return false;
	}
	
	return true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function handleEnter (field, event) {
                var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
                if (keyCode == 13) {
                        var i;
                        for (i = 0; i < field.form.elements.length; i++)
                                if (field == field.form.elements[i])
                                        break;
                        i = (i + 1) % field.form.elements.length;
                        field.form.elements[i].focus();
                        return false;
                } 
                else
                return true;
        }      


function search_condition(){
	var menu_no=document.search_proc.search_cond.value;
	for(var i=1;i<=8;i++){
		document.getElementById("con_block"+i).style.display ='none';
	}
	if(menu_no!=0){
		document.getElementById("con_block7").style.display ='block';
		document.getElementById("con_block"+menu_no).style.display ='block';
		document.getElementById("con_block6").style.display ='block';
	}
	
}

function check_searchform(){
	var menu_no=document.search_proc.search_cond.value;
	if(menu_no==0){
	}else if(document.search_proc.search_text.value==''){
		alert('検索する文字列を入力してください');
	}else{
		document.getElementById("search_proc").submit();
	}
}

function search_item(item){
	switch(item){
		case '1':
			document.getElementById("kijiSearch").style.display ='block';
			document.getElementById("userSearch").style.display ='none';
			document.getElementById("communitySearch").style.display ='none';
			document.getElementById("eventSearch").style.display ='none';
			document.getElementById("kijiTitle").className ='SearchMenuOn';
			document.getElementById("userTitle").className ='SearchMenuOff';
			document.getElementById("communityTitle").className ='SearchMenuOff';
			document.getElementById("eventTitle").className ='SearchMenuOff';
			break;
		case '2':
			document.getElementById("kijiSearch").style.display ='none';
			document.getElementById("userSearch").style.display ='block';
			document.getElementById("communitySearch").style.display ='none';
			document.getElementById("eventSearch").style.display ='none';
			
			document.getElementById("kijiTitle").className ='SearchMenuOff';
			document.getElementById("userTitle").className ='SearchMenuOn';
			document.getElementById("communityTitle").className ='SearchMenuOff';
			document.getElementById("eventTitle").className ='SearchMenuOff';
			break;
		case '3':
			document.getElementById("kijiSearch").style.display ='none';
			document.getElementById("userSearch").style.display ='none';
			document.getElementById("communitySearch").style.display ='block';
			document.getElementById("eventSearch").style.display ='none';
			
			document.getElementById("kijiTitle").className ='SearchMenuOff';
			document.getElementById("userTitle").className ='SearchMenuOff';
			document.getElementById("communityTitle").className ='SearchMenuOn';
			document.getElementById("eventTitle").className ='SearchMenuOff';
			break;
		case '4':
			document.getElementById("kijiSearch").style.display ='none';
			document.getElementById("userSearch").style.display ='none';
			document.getElementById("communitySearch").style.display ='none';
			document.getElementById("eventSearch").style.display ='block';
			
			document.getElementById("kijiTitle").className ='SearchMenuOff';
			document.getElementById("userTitle").className ='SearchMenuOff';
			document.getElementById("communityTitle").className ='SearchMenuOff';
			document.getElementById("eventTitle").className ='SearchMenuOn';
			break;
	}
}

var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}


var enlarge_image;
var enlarge_content;
var enlarge_title;
var enlarge_tokui;
var enlarge_address;
var enlarge_show_flg;

function enlarge2(which,content,title,tokui,address){
	enlarge_show_flg = true;
	enlarge_image = new Image();
	enlarge_image.src=which;
	enlarge_content = content;
	enlarge_title = title;
	enlarge_tokui = tokui;
	enlarge_address = address;

	if(enlarge_image.complete == true){
		enlarge2_onload();
	}else{
		enlarge_image.onload=enlarge2_onload;
	}
}

function enlarge2_onload(){
	if(enlarge_show_flg == true){
		enlarge_show_flg = false;
		var imgwidth = enlarge_image.width - 36;
		var imgheight = enlarge_image.height;
		if(enlarge_title){
				var imgwidth = 154;
				var imgheight = 154;
		}
		if (ie||ns6){
			crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage;
			pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop);
			horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2;
			vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2;
			if (window.opera && window.innerHeight){
				vertpos=pgyoffset+window.innerHeight/2-imgheight/2;
				vertpos=Math.max(pgyoffset, vertpos);
			}
			crossobj.style.left=(horzpos-40)+"px";
			crossobj.style.top=(vertpos-50 )+ "px";
			divwidth = imgwidth+36;
			divwidthicon = imgwidth+41;
			if(enlarge_title){
				enlarge_content = enlarge_content.replace(/-BR-/g, '<br />');
				crossobj.innerHTML='<div style="padding:10px;border:8px solid #888;word-break:break-all;width:'+ divwidth + 'px">	<div style="margin-top:-5px;position:absolute;width:'+divwidthicon + 'px;text-align:right" oncick="closepreview()"><img src="/img/x2.gif" style="cursor:pointer" onclick="closepreview()"></div><span id="closetext" onClick="closepreview()" style="font-size:12px"><img src="'+enlarge_image.src+'" width="184px" height="184px" title="イメージをクリックすると閉じます。" style="cursor:pointer;margin-bottom:8px"><br / ><div style="text-align:left;line-height: 150%"><b>'+ enlarge_title +'</b><br /><hr>・出身地：'+ enlarge_address +'<br /><hr>・特技：' + enlarge_tokui + '<br /><hr>・お客様へ一言：<br />' +enlarge_content +'</div></span></div>';			
			}else if(enlarge_content){
				enlarge_content = enlarge_content.replace(/-BR-/g, '<br />');
				crossobj.innerHTML='<div style="padding:10px;border:8px solid #888;word-break:break-all;width:'+ divwidth + 'px">	<div style="margin-top:-5px;position:absolute;width:'+divwidthicon + 'px;text-align:right" oncick="closepreview()"><img src="/img/x2.gif" style="cursor:pointer" onclick="closepreview()"></div><span id="closetext" onClick="closepreview()" style="font-size:12px"><img src="'+enlarge_image.src+'" title="イメージをクリックすると閉じます。" style="cursor:pointer;margin-bottom:8px"><br / >'+ enlarge_content +'</span></div>';
			}else{
				crossobj.innerHTML='<div style="padding:10px;border:8px solid #888;word-break:break-all;width:'+ divwidth + 'px">	<div style="margin-top:-5px;position:absolute;width:'+divwidthicon + 'px;text-align:right" oncick="closepreview()"><img src="/img/x2.gif" style="cursor:pointer" onclick="closepreview()"></div><span id="closetext" onClick="closepreview()"><img src="'+enlarge_image.src+'" title="イメージをクリックすると閉じます。" style="cursor:pointer;"></span></div>';
			}
			crossobj.style.visibility="visible";
			return false;
		} else {
			return true;
		}
	}
}


function enlarge(which, e, position, imgwidth, imgheight,content){


var i = new Image();
i.onload=function(){
}
i.src=which;
imgwidth = i.width - 36;
imgheight = i.height;
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) 
vertpos=pgyoffset+window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobj.style.left=(horzpos-40)+"px"
crossobj.style.top=(vertpos-50 )+ "px";
divwidth = imgwidth+36;
divwidthicon = imgwidth+41;

if(content){
	content = content.replace(/-BR-/g, '<br />');
	crossobj.innerHTML='<div style="padding:10px;border:8px solid #888;word-break:break-all;width:'+ divwidth + 'px"><div style="margin-top:-5px;position:absolute;width:'+divwidthicon + 'px;text-align:right" oncick="closepreview()"><img src="/img/x2.gif" style="cursor:pointer" onclick="closepreview()"></div><span id="closetext" onClick="closepreview()" style="font-size:12px"><img src="'+which+'" title="イメージをクリックすると閉じます。" style="cursor:pointer;margin-bottom:8px"><br / >'+ content +'</span></div>'
}else{
	crossobj.innerHTML='<div style="padding:10px;border:8px solid #888;word-break:break-all;width:'+ divwidth + 'px"><div style="margin-top:-5px;position:absolute;width:'+divwidthicon + 'px;text-align:right" oncick="closepreview()"><img src="/img/x2.gif" style="cursor:pointer" onclick="closepreview()"></div><span id="closetext" onClick="closepreview()"><img src="'+which+'" title="イメージをクリックすると閉じます。" style="cursor:pointer;"></span></div>'
}
crossobj.style.visibility="visible";
return false;
}
else
return true;
}
function closepreview(){
	crossobj.style.visibility="hidden";
}
///////▼
function showGenre(){
		var msize = document.documentElement.clientHeight
		var back =document.getElementById("back_popup");
		var bw = document.body.scrollHeight+40;
		if(bw < msize){
			bw = msize;
		}
		var bh = document.body.scrollWidth+20;
		var dw = window.pageXOffset + window.innerWidth/2 - 100;
		var dh = window.pageYOffset + window.innerHeight/2 - 50;
		if(navigator.appName.indexOf("Microsoft")!=-1 && (!dw || !dh)){
			dw = document.body.scrollLeft + document.body.offsetWidth/2 - 200;
			dh = document.body.scrollTop + document.body.offsetHeight/2 - 50;
		}
		back.style.top = 0+'px';
		back.style.left = 0+'px';
		back.style.width = bh+'px';
		back.style.height = bw+'px';
		back.style.display = "block";

	}

	function hideGenre(){

		var back =document.getElementById("back_popup");
		back.style.display = "none";

	}
///////▲

//////////////////////////////////////////////////////////////////////////////▼ SHOW EDIT
function show_edit(e, position, width,height){
showGenre();
if (ie||ns6){
crossobjED=document.getElementById? document.getElementById("showedit") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-width/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-width/2
vertpos=ns6? pgyoffset+window.innerHeight/2-height/2 : pgyoffset+ietruebody().clientHeight/2-height/2
if (window.opera && window.innerHeight) 
vertpos=pgyoffset+window.innerHeight/2-height/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobjED.style.left=horzpos+"px"
crossobjED.style.top=vertpos+"px"
crossobjED.style.visibility="visible"
return false
}
else
return true
}

function closepreedit(){
crossobjED.style.visibility="hidden"
}

function autotxt(){
var m=50;var s=this.scrollHeight;if(s>=m)this.style.pixelHeight=s+4
}

function EditMode(e, position, width,height,layer){
showGenre();
if (ie||ns6){
crossobj=document.getElementById? document.getElementById(layer) : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-width/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-width/2
vertpos=ns6? pgyoffset+window.innerHeight/2-height/2 : pgyoffset+ietruebody().clientHeight/2-height/2
if (window.opera && window.innerHeight) 
vertpos=pgyoffset+window.innerHeight/2-height/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobj.style.left=horzpos - 15 +"px"
crossobj.style.top=vertpos+"px"
crossobj.style.visibility="visible"
return false
}
else
return true
}

function EditModeClose(){
crossobj.style.visibility="hidden"
}



/* Fild Check */
function IsInt() {
	if(95 <= event.keyCode && event.keyCode <= 105 ){
		return true;
	}
	m = String.fromCharCode(event.keyCode);
	if("0123456789\t\b\r".indexOf(m, 0) < 0){
		return false;
	}
	return true;
}

/*maxlength="3" onkeyDown="return IsInt()" */

function IsInt() {
	if(95 <= event.keyCode && event.keyCode <= 105 ){
		return true;
	}
	m = String.fromCharCode(event.keyCode);
	if("0123456789\t\b\r".indexOf(m, 0) < 0){
		return false;
	}
	return true;
}

function isEmail(str) {     
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,4})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
} 

var uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var lowercase = 'abcdefghijklmnopqrstuvwxyz';
var number = '0123456789';
var option = '~!@#$%^&*()_+`=-<>/[]{},.'; 


function containsCharsOnly(input, chars, type){
    var form = document.signform;
    
    for(var inx=0; inx<input.value.length; inx++){
        if(chars.indexOf(input.value.charAt(inx)) == -1){
            if(type == 'alpha')
                return false;
            else if(type == 'number')
                return false;
            else if(type == 'isAll')
                return false;
            return true;
        }
    }
} 

function isAlphabet(input){
    var chars = uppercase + lowercase;
    return containsCharsOnly(input, chars, 'alpha');
}

function isNumber(input){
    return containsCharsOnly(input, number, 'number');
}

function isAll(input){
    var chars = uppercase + lowercase + number + option;
    return containsCharsOnly(input, chars, 'isAll');
} 

function isJapan(input) {
      for (var i = 0; i < input.length; ++i) {
        var c = input.charCodeAt(i);       
        if (c < 256 || (c >= 0xff61 && c <= 0xff9f)) {
          return false;
        }
      }
      return true;
}
/*
function LoadingCheck(){
		objs = document.getElementsByName('ShowConfigPop[]'); 
		len = objs.length;
		for(i=0; i<len; i++) {
			objs[i].style.display = 'block';
		}
}
*/
function IframHtml(divname,width,height){
	if(width == 100){
		var pxnp = '%';
	}else{
		var pxnp = 'px';	
	}
	document.getElementById(divname).innerHTML=	"<iframe  src='ifm."+ divname +".html' allowTransparency='true' " +
																	"frameborder='0' style='width:"+ width + pxnp +";height:"+ height+ "px'  frameborder='0' marginwidth='0' "+
																	"marginheight='0' align='center' scrolling='no' ></iframe>";
}

function ImageAlt(URL){
	var Wd = window.open('','AltTagChange','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no,width=500,height=100,status=no');
	Wd.location.href='AltTagChange.php?p='+URL; 
}


