// オープンイメージ
function openImage(url, sizeX, sizeY)
{
    window.open(url, 'imageViewer', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, width='+sizeX+', height='+sizeY+'');
}

// ロールオーバー
function changeImage(imgId, imgSrc)
{
    if (document.getElementById) {
        document.getElementById(imgId).src = imgSrc;
    }
}

// 別ウインドウオープン
function openWin(theURL, winName)
{
    window.open(theURL,winName,'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes');
}

// 別ウインドウオープン(サイズ指定 600px)
function openWinSmall(theURL, winName)
{
    window.open(theURL,winName,'toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, width=600, height=600');
}

// スクロール
function scroller(ps)
{
    scroller_up(ps,1000);
}

function scroller_up(ps,y)
{
    y = y + (ps - y)*.1;
    window.scroll(0,y);
    if (((ps - y) <= .5)&&((ps - y) >= -.5)) {
        y = ps;
    }else{
        setTimeout("scroller_up("+ps+","+y+")",1);
    }
}

function scroller_e(ps)
{
    y = 1;
    kyoukai = ps*.5;
    while(y <= kyoukai) {
        window.scroll(0,y);
        y = y + (y*.05);
        // speed
    }
    while(y != ps) {
        window.scroll(0,y);
        y = y + (ps-y)*.05;
        // speed
        if (((ps - y) <= .5)&&((ps - y) >= -.5)) {
            y = ps;
        }
    }
}

// 削除確認
function delCheck()
{
    nRet = confirm("この写真を削除してもよろしいですか？");
    if (!nRet) {
        return false;
    } else {
        document.delfoto.submit();
    }
}

// チェックボタンのリセット
function clear_rb(f,rbName)
{ 
    for(i = 0; i < f.elements[rbName].length; i++){ 
        f.elements[rbName][i].checked=false;
    }
}

// コメント削除
function comDel(ID,comID)
{
    passwd = window.prompt("書き込み時に登録したパスワードを入力してください", "");
    if(passwd != "" && passwd != null){
        location.href = "comment.php?action=del&ID=" + ID + "&comID=" + comID + "&passwd=" + passwd + "&display=news";
    }
}

// オープンイメージ
function openImage(url)
{
    window.open(url,'imageViewer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=50,height=50');
}

// イメージビュアー
function resizeToImageSize()
{
    if (document.getElementById && document.getElementById('img')) {
        var elm = document.getElementById('img');
        var imgWidth = parseInt(elm.getAttribute('width'));
        var imgHeight = parseInt(elm.getAttribute('height'));
        
        window.moveTo(10, 10);
        
        var innerH;
        var innerW;
        var deltaH;
        var deltaW;
        if (navigator.userAgent.indexOf('Mac') != -1
            && navigator.userAgent.indexOf('IE') != -1){
            //MacIE
            deltaH = 4;
            deltaW = 4;
        } else if (document.all){
            window.resizeTo(150, 150);
            innerH = document.body.clientHeight;
            innerW = document.body.clientWidth;
            deltaH = 150 - innerH;
            deltaW = 150 - innerW;
        } else {
            innerH = window.innerHeight;
            innerW = window.innerWidth;
            deltaH = window.outerHeight - innerH;
            deltaW = window.outerWidth - innerW;
        }
        window.resizeTo(imgWidth + deltaW, imgHeight + deltaH);
    }
}
