function NumField()
{
    if ((event.keyCode < 48) || (event.keyCode > 57)) {
        event.returnValue = false;
    }
}

function PhoneField()
{
    if (((event.keyCode >= 48) && (event.keyCode <= 57)) || (event.keyCode == 40) || (event.keyCode == 41) || (event.keyCode == 45))
	    event.returnValue = true;
	else
        event.returnValue = false;
}

function AlphaField()
{
    if (((event.keyCode >= 65) && (event.keyCode <= 90)) || ((event.keyCode >= 97) && (event.keyCode <= 122)) || (event.keyCode == 32) || (event.keyCode == 46))
	    event.returnValue = true;
	else
        event.returnValue = false;

}

function AlphaField2()
{
    if (((event.keyCode >= 65) && (event.keyCode <= 90)) || ((event.keyCode >= 97) && (event.keyCode <= 122)) || (event.keyCode == 32))
	    event.returnValue = true;
	else
        event.returnValue = false;

}

function FocusMove(srcObj, maxLen, moveObj)
{
    if (srcObj.value.length >= maxLen)
        moveObj.focus();
}

function truncateComa(str)
{
    var tmpstr = "";
    var i = 0;
    for(i = 0; i < str.length; i++)
    {
        if (str.substring(i, i+1) != ",")
            tmpstr = tmpstr + str.substring(i, i+1);
    }
    return tmpstr
}

function num_check(str)
{
    var is_num = true;
    for (var i=0; i < str.length; i++) {
        if (str.substring(i, i+1) != "0" &&
            str.substring(i, i+1) != "1" &&
            str.substring(i, i+1) != "2" &&
            str.substring(i, i+1) != "3" &&
            str.substring(i, i+1) != "4" &&
            str.substring(i, i+1) != "5" &&
            str.substring(i, i+1) != "6" &&
            str.substring(i, i+1) != "7" &&
            str.substring(i, i+1) != "8" &&
            str.substring(i, i+1) != "9")
            { is_num = false }
    }
    return is_num;
}

function MoneyFormat(str)
{
    var newStr = "";
    var strLen   = str.length;
    var commCnt  = parseInt((strLen - 1) / 3);
    var fCnt = strLen % 3;
    if (fCnt == 0 )    fCnt = 3;
    
    for(var i = 0, lidx = 0; i <= commCnt; i++ )
    {
        fidx = lidx;
        lidx = fCnt + (i * 3);
        
        if (newStr.length > 0)    newStr = newStr + ",";
        newStr = newStr + str.substring(fidx, lidx);
    }

    return newStr;
}

function SetMoneyValue(FieldName)
{
    var strReplaceOption = /,/gi;
    var strMoney = FieldName.value.replace(strReplaceOption,"");

    FieldName.value = MoneyFormat(strMoney);
}

function ChkEmail(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,3})(\\]?)$");
	
	return (!r1.test(str) && r2.test(str));
}

function ConfirmMsg(msg, width,height)
{
	var WinAttr = "toolbar=NO;center=yes;scrollbars=NO;status=NO;dialogwidth="+width+"px;dialogheight="+height+"px";

	retval=window.showModalDialog("/Lib/ConfirmMsg.asp?msg="+msg,"confirmmsg", WinAttr);

	return retval;
}

function AlertMsgModal(msg, width,height)
{
	var WinAttr = "toolbar=NO;center=yes;scrollbars=NO;status=NO;dialogwidth="+width+"px;dialogheight="+height+"px";

	retval=window.showModalDialog("/Lib/AlertMsg.asp?msg="+msg,"confirmmsg", WinAttr);

	return retval;
}

function OpenWindow(url, boxname, width, height)
{
	var winLeft = (screen.width - width) / 2;
    var winTop = (screen.height - height) / 2;
    var winProps = "width="+width+",height="+height+",top="+winTop+",left="+winLeft+",scrollbars=no";

    window.open(url,boxname,winProps);
}

// scrollbar enabled
function OpenWindow2(url, boxname, width, height)
{
	var winLeft = (screen.width - width) / 2;
    var winTop = (screen.height - height) / 2;
    var winProps = "width="+width+",height="+height+",top="+winTop+",left="+winLeft+",scrollbars=yes";

    window.open(url,boxname,winProps);
}

function click() 
{
	if ((event.button==2) || (event.button==3))  
	{
		return false;
	}
}

function keypressed() 
{    
	if ((event.keyCode >= 113 && event.keyCode <= 123) || (event.ctrlKey == true))
	{                                        
		event.keyCode=0;
		event.cancelBubble = true;
        event.returnValue = false;

        return false;
    }                                                          
}

function nocontextmenu()
{
   event.cancelBubble = true;
   event.returnValue = false;

   return false;
}

function returnfalse()
{
   event.cancelBubble = true;
   event.returnValue = false;

   return false;
}

function goCategory(strCategory)
{
    with (document.form1)
    {
        target = "_self";
        action = "/ItemShopWeb/Rappelz/shop.asp";
        currpage.value = 1;
        categoryid.value = strCategory;
        try
        {
            if (searchtext && strCategory != "")
            {
                searchtext.value = "";
            }
        }
        catch (e)
        {
        }
        submit();
    }
}

function banner()
{
    document.write('<tr><td><img src=\"/images/global/spacer.gif\" width=\"1\" height=\"10\"></td></tr>\n');
    document.write('<tr>\n');
    //document.write('<td align=\"center\" valign=\"top\"><a href=\"#\"><img src=\"http://image.gpotato.jp/images/toptop_lbanner_s070220.gif\" width=\"600\" height=\"59\" alt=\"\" border=\"0\"></a></td>\n');
    document.write('<td align=\"center\" valign=\"top\"><img src=\"http://image.gpotato.jp/images/top/top_lbanner_s070220.gif\" width=\"600\" height=\"59\" alt=\"\" border=\"0\"><!--<br><br><span style=\"color:#FF6633\"><b>※ポテトの価格は、20％OFF後の表記となります。</b>--></span></td>\n');
    document.write('</tr>\n');
}

function BrowserCheck() 
{
	if(window.navigator.userAgent.indexOf("SV1") != -1)
		return "SV1";
	else if(window.navigator.userAgent.indexOf("MSIE 7.0") != -1)
		return "IE7";
	else
		return "";
}

function SelfClose()
{
	if(BrowserCheck() == "IE7")
	{
		window.open('about:blank','_self').close();
	}
	else
	{
		self.opener = this; 	
		self.close();
	}
}

function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    { 
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    }
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    { 
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    return curtop;
}

//document.onkeydown     = keypressed;
//document.onmousedown   = click;
//document.oncontextmenu = nocontextmenu;
//document.ondragstart   = returnfalse;
//document.onselectstart = returnfalse;
