/* icons */
/*
var validates_ok = '<img src="common/img/button_ok.png" width="16" height="16" style="vertical-align: middle"/>&nbsp;';
var validates_error = '<img src="common/img/button_cancel.png" width="16" height="16" style="vertical-align: middle"/>&nbsp;';
var validates_info = '<img src="common/img/color_line.png" width="16" height="16" style="vertical-align: middle"/>&nbsp;';


Validator.register({
    "#domain" : {
        "/^((?:[-a-zA-Z0-9]+\\.)+[a-zA-Z]{2,})$/": validates_ok,
        "/[^(a-z|A-Z|0-9|.)]/": validates_error + "半角英数字を入力してね",
        "/^[(a-z|A-Z|0-9|.)]{64,}/": validates_error + "長過ぎます",
        "/^[(a-z|A-Z|0-9|.)]/": validates_error + "短過ぎます",
        "/^$/": validates_info + "入力してください"
    }
});
*/


/* バイト数チェック */
function jf_getLength(value){
    var i,nCnt=0;
    for(i=0; i<value.length; i++){
        if(escape(value.charAt(i)).length >= 4 ) nCnt+=2;
        else nCnt++;
    }
    return nCnt;
}


/* jf_whois */
function jf_whois(){
    //alert(document.frm.domain.value);
    if(document.frm.domain.value == ""){ alert("ドメインが入力されていません"); document.frm.domain.focus(); return; }
    if( document.frm.domain.value.match(/[^0-9A-Za-z_\-]/) ){ alert("ドメインに使えない文字が入力されています"); document.frm.domain.focus(); return; }
    if( jf_getLength(document.frm.domain.value) < 3 || jf_getLength(document.frm.domain.value) > 32 ){ alert("ドメイン名は３文字以上３２文字以内で入力ください"); document.frm.domain.focus(); return; }
    if( document.frm.tld.value == "" ){ alert("ドメインが選択されていません"); document.frm.tld.focus(); return; }
    document.frm.action="?mode=whois";
    document.frm.submit();
}


/* jf_submitMuu */
function jf_submitMuu(psld){
    //if(document.frm.domain.value == ""){ alert("ドメインが入力されていません"); document.frm.domain.focus(); return; }
    //if( document.frm.domain.value.match(/[^0-9A-Za-z_\-\.]/) ){ alert("ドメインに使えない文字が入力されています"); document.frm.domain.focus(); return; }
    document.frm.action="https://muumuu-domain.com/?mode=order_form&state=whois&sld="+psld;
    //document.frm.action="http://muumuu-domain.com/";
    document.frm.submit();
}

var Win=(navigator.userAgent.indexOf("Win")!=-1);
var Mac=(navigator.userAgent.indexOf("Mac")!=-1);
var Explorer=(navigator.appName.indexOf("Explorer")!=-1);
var Netscape=(navigator.appName.indexOf("Netscape")!=-1);
var Version=navigator.appVersion.charAt(0);

var exec;
function getSCR(){
    var x=0
    var y=0;
    if(Explorer){
        x=document.body.scrollLeft;y=document.body.scrollTop;
    }else if(Netscape && Version=="5"){
        x=window.scrollX;y=window.scrollY;
    }else if(Netscape && Version=="4"){
        x=window.pageXOffset;y=window.pageYOffset;
    }
    return {x:x,y:y};
}

//スクロール実行部
function goSCR(x,y,cnt){
    var step=50;
    var rewrt=3;
    exec=getSCR();
    if(cnt++<step){
        var p=cnt/step;
        var q=p-1/Math.PI*Math.sin(Math.PI*p);
        var x_=exec.x+(x-exec.x)*q;
        var y_=exec.y+(y-exec.y)*q;
        window.scrollTo(x_,y_);
        setTimeout("goSCR("+x+","+y+","+cnt+");",rewrt);
    }
    getSCR();
}

function jumpToPageTop(){
    goSCR(0,0,10);
}

function jf_GetRedirect(pUrl, pNewWindow){
    if(!pUrl){
        return;
    }

    if(pNewWindow == undefined){
        pNewWindow = false;
    }

    var outside_protocol = "";
    if(pUrl.match(new RegExp("^http://"))){
        outside_protocol = "http";
        pUrl = pUrl.replace("http://", "");
    }else if(pUrl.match(new RegExp("^https://"))){
        outside_protocol = "https";
        pUrl = pUrl.replace("https://", "");
    }else{
        // 対象外
        return;
    }

    var wRedirectPath = "";
    if(pUrl.indexOf("?") == -1){
        wRedirectPath = "../?mode=jump&state=get&outside_protocol=" + outside_protocol + "&outside_url=" + escape(pUrl);
    }else{
        var wUrlParams = pUrl.split("?");
        // ムームー内の「mode」とぶつかるため、別キー名にしておく
        var wParams = wUrlParams[1].replace("mode=", "outside_mode=");
        wParams = wParams.replace("state=", "outside_state=");
        wRedirectPath = "../?mode=jump&state=get&outside_protocol=" + outside_protocol + "&outside_url=" + escape(wUrlParams[0]) + "&" + wParams;
    }

    if(pNewWindow){
        window.open(wRedirectPath);
    }else{
        location.href = wRedirectPath;
    }
}
