function ChangeImage(obj) {
	var tmp = obj.src;
	obj.src = obj.oversrc;
	obj.oversrc = tmp;
}

function SetSubMenu(id) {
	//document.all['SUBMENU'].style = document.all[id].style;
	document.all['SUBMENU'].innerHTML = document.all[id].innerHTML;
}

function SearchZipCode(id) {
	this.href = "zipcode.php?id=" + id;
	zoomBox(event, this, 400, 150, 200, 100);
}

function CheckUserID(form) {
	this.href = "checkID.php" + form.userid.value;
	zoomBox(event, this, 400, 150, 200, 100);
}

function OpenDialog(nLink, nWin, nWidth, nHeight, xPos, yPos) {
	if(typeof nLink == "object") url = nLink.href;
	else url = nLink;
	var qResult = window.showModalDialog( url, nWin,
          				"dialogwidth:"+nWidth+"px;dialogheight:"+nHeight+"px;toolbar:no;location:no;help:no;directories:no;status:no;menubar:no;scroll:no;resizable:no");
}

function OpenWindow(nLink, nTarget, nWidth, nHeight, xPos, yPos) {
	if(typeof nLink == "object") url = nLink.href;
	else url = nLink;

	adjX = xPos ? xPos : (window.screen.width/2 - nWidth/2);
	adjY = yPos ? yPos : (window.screen.height/2 - nHeight/2 - 100);
	var qResult = window.open( url, nTarget, "width="+nWidth+", height="+nHeight+",left="+adjX+",top="+adjY+",toolbar=no,status=no,scrollbars=no,resizable=no");
}

function ConfirmAction(obj) {
	if(confirm(obj.name + "しますか？")) {
		location.href = obj.href;
	}
}

function HiddenBox(obj) {
	if(confirm(obj.name + "しますか？")) {
		window.showModalDialog(obj.href, '_blank', 'dialogwidth:0px;dialogheight:0px;toolbar:no;location:no;help:no;directories:no;status:no;menubar:no;scrollbars=no;resizable:no');
	}
}

function Go(url) {
	location.href = url;
}

function go_submit() {

	var f = document.registFrm;
	if (!f.domain_name.value)
	{
		alert('ドメイン名を入力してください。');
		f.domain_name.focus();
		return false;
	}
	pageMove('main','/DomainManage/Residence_Regist',Form.serialize(document.registFrm));
}

function isFilled( elm ) {
	if ( elm.value == "" || elm.value == null )
	return false;
	else
	return true;
}

function isReady( form ) {
	if ( isFilled(form.domain_name) == false ) {
		alert("ドメイン名を入力してください。");
		form.domain_name.focus();
	return false;
	}
	pageMove('main','/DomainManage/Residence_Regist',Form.serialize(document.registFrm));
}

function number_format (number, decimals, dec_point, thousands_sep)
{
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp; 
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i) 
      fractional += "0"; 
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null; 
  if (thousands_sep != null && thousands_sep != "")
  {
    for (i = integer.length - 3; i > 0; i -= 3) 
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}

function trim(str) 
{     
	if(!str || typeof str != 'string')
		return null;     
		
	return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' '); 
}

//会員登録popup
function Member_Regist_Notice() {
	var nLink = '../CustCenter/CustCenter_Member_Regist_Notice.php';
	var nTarget = 'confirm';
	var nWidth = 650;
	var nHeight = 300;
	var xPos = 0;
	var yPos = 0;
	if(typeof nLink == "object") url = nLink.href;
	else url = nLink;

	adjX = xPos ? xPos : (window.screen.width/2 - nWidth/2);
	adjY = yPos ? yPos : (window.screen.height/2 - nHeight/2 - 100);
	var qResult = window.open( url, nTarget, "width="+nWidth+", height="+nHeight+",left="+adjX+",top="+adjY+",toolbar=no,status=no,scrollbars=yes,resizable=no");
}

//会員登録popup
function Domain_Regist_Notice(type) {
	var nLink = '../CustCenter/CustCenter_Domain_Regist_Notice.php?type='+type;
	var nTarget = 'confirm';
	var nWidth = 650;
	var nHeight = 400;
	var xPos = 0;
	var yPos = 0;
	if(typeof nLink == "object") url = nLink.href;
	else url = nLink;

	adjX = xPos ? xPos : (window.screen.width/2 - nWidth/2);
	adjY = yPos ? yPos : (window.screen.height/2 - nHeight/2 - 100);
	var qResult = window.open( url, nTarget, "width="+nWidth+", height="+nHeight+",left="+adjX+",top="+adjY+",toolbar=no,status=no,scrollbars=yes,resizable=no");
}


// whoisjapan login ID, PW check
function checkForm1() {
	var theform = login;
	if ( theform.userid.value =="" ) {
		alert('IDを入力してください。');
		theform.userid.focus() ;
		return false;
	}
	else if ( theform.passwd.value =="" ) {
		alert('パスワードを入力してください。');
		theform.passwd.focus() ;
		return false;
	}
	else {
		return true;
	}
}

// webmail login ID,Domain,Password Check
function webmail_login()
{
	var f = document.forms['loginform'];
	if(!f.user_id.value) {
	alert('メールIDを入力してください。');
	f.user_id.focus();
	return false;
	}
	if(!f.domain.value) {
	alert('ドメインを入力してください。');
	f.domain.focus();
	return false;
	}
	if(!f.user_pass.value) {
	alert('パスワードを入力してください。');
	f.user_pass.focus();
	return false;
	}
	if(f.domain.value == 'whois.co.jp') {
	f.action = 'http://webmail.whois.co.jp/login_post.php?language=jp';
	//f.action = 'http://webmail.whoismail.jp/login_post.php?language=jp';
	} else {
	f.action = 'http://webmail.whois.co.jp/login_post.php?language=jp';
	//f.action = 'http://webmail.whoismail.jp/login_post.php?language=jp';
	}
	return true;
}

//link
function bluring() {
	if (event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;

//domain search popup
function check_search_domain(theform, search_domain)
{
	if(!theform.search_domain.value)
	{
		alert("ドメイン名を入力してください。");
		theform.search_domain.focus();
		return false;
	}
 
	var pattern = /^[ ]+$/;
	var form = document.searchFrm;
	var search_domain = document.searchFrm.search_domain.value;
	var nLink = "/common/whoisSearch_name.php?search_domain="+search_domain;
	var nTarget = "child";
	var nWidth = 530;
	var nHeight = 700;
	var xPos = 0;
	var yPos = 0;
	if(typeof nLink == "object") url = nLink.href;
	else url = nLink;
 
	adjX = xPos ? xPos : (window.screen.width/2 - nWidth/2);
	adjY = yPos ? yPos : (window.screen.height/2 - nHeight/2 - 100);
	var qResult = window.open( url, nTarget, "width="+nWidth+", height="+nHeight+",left="+adjX+",top="+adjY+",toolbar=no,status=no,scrollbars=yes,resizable=no");
}
