/*
// +----------------------------------------------------------------------+
// | jamroom_javascript.inc.js - Jamroom Misc Javascript functions        |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003-2004 by Brian Johnson                             |
// +----------------------------------------------------------------------+
// | Miscellaneous javascript functions file                              |
// +----------------------------------------------------------------------+
// | Author: Brian Johnson <bigguy@jamroom.net>                           |
// +----------------------------------------------------------------------+
// $Id: jamroom_javascript.inc.js,v 3.2 2006-07-11 18:42:54 bigguy Exp $
*/

function popwin (mypage,myname,w,h,scroll) {
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
    win = window.open(mypage,myname,settings)
    if (win.opener == null) {
        win.opener = self;
    }
}

function lockFormSubmit (lock) {
    if (document.all || document.getElementById) {
        for ( i=0 ; i < lock.length ; i++ ) {
            if (lock.elements[i]) {
                var tempobj=lock.elements[i];
                if (tempobj.type.toLowerCase()=="submit" || tempobj.type.toLowerCase()=="reset" || tempobj.type.toLowerCase()=="button") {
                    tempobj.disabled=true;
                }
            }
        }
    }
}

function move(index,to) {
    var list = document.form.list;
    var total = list.options.length-1;
    if (index == -1) {
        return false;
    }
    if (to == +1 && index == total) {
        return false;
    }
    if (to == -1 && index == 0) {
        return false;
    }
    var items = new Array;
    var values = new Array;
    for (i = total; i >= 0; i--) {
        items[i] = list.options[i].text;
        values[i] = list.options[i].value;
    }
    for (i = total; i >= 0; i--) {
        if (index == i) {
            list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
            list.options[i] = new Option(items[i + to], values[i]);
            i--;
        }
        else {
            list.options[i] = new Option(items[i], values[i]);
        }
    }
    list.focus();
}

/**
 * The newCaptcha() function resets the captcha image to a new image
 */
function newCaptcha(width,height)
{
    var now = new Date();
    document.captcha.src = 'signup.php?mode=captcha&width='+width+'&height='+height+'&u='+ now.getTime();
    return(false);
}

