// -----------------------------
// Add a new image for roll over
// Args:
//  - prefix  : the prefix of key in roll_img array
//  - path_off: the path to roll 'off' image
//  - path_on: the path to roll 'on' image
function new_roll(prefix,path_off,path_on) {
    if(prefix && path_off && path_on) {
        roll_img[prefix+'_off'] = new Image(0,0);
        roll_img[prefix+'_off'].src = path_off;
        roll_img[prefix+'_on']  = new Image(0,0);
        roll_img[prefix+'_on'].src  = path_on;
    }
    return;
}
// -----------------------------
// Pic Switch
// Args:
//  - img_name : the prefix of the key of roll_img
//  - dest_name: the name of destination image
function pic_switch (img_name, dest_name) {
    if(img_name && dest_name) {
        document.images[dest_name].src = roll_img[img_name].src;
    }

    return;
}
// -----------------------------
// Do roll
// Args:
//  - img_name : the prefix of the key of roll_img
//  - dest_name: the name of destination image
//  - type     : 'on' or 'off'
function do_roll (img_name, dest_name, type) {
    if((type != 'off') && (type != "on")) {
        type = 'off';
    }

    if(img_name && dest_name && document.images[dest_name]) {
        document.images[dest_name].src = roll_img[img_name +"_"+ type].src;
    }

    return;
}

function pop_img(pic,width,height,title) {
    var win = window.open('','pop_img_win','scrollbars=0,width='+width+',height='+height+','+
        'menubar=0,resizable=0,titlebar=0,toolbar=0,status=0');
    win.document.write('<html>\n'+
        '<head>'+
        '<title>TesMed::'+title+'</title>'+
        '<style type="text/css">\n'+
        '<!--\n'+
        'body {\n'+
        '\tmargin:0px 0px 0px 0px;\n'+
        '}\n'+
        '-->\n'+
        '</style>\n'+
        '</head>\n'+
        '<body>'+
        '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">'+
        '<tr>'+
        '<td align="center" valign="middle">'+
        '<img align="center" src="../static/img/'+pic+'" border="0">'+
        '</td>'+
        '</tr>'+
        '</table>'+
        '</body>\n'+
        '</html>');
}
function pop_page(name,url,x,y,width,height,scroll) {
    if(name && url && width && height) {
        // try to close an old popup with the same name
        if(top.win[name]) {
            top.win[name].close();
        }
        // now open popup window
        top.win[name] = window.open(url,name,'screenX='+x+',screenY='+y+',top='+y+',left='+x+','+
                     'height='+height+',width='+width+',menubar=0,resizable=0,'+
                     'scrollbars='+scroll+',status=0,titlebar=0,toolbar=0');
        // and focus it
        top.win[name].focus();
    }
}
function pop_close(name) {
    if(name && top.win[name]) {
        top.win[name].close();
    } else {
        self.close();
    }
}
function dad_url(url) {
    if(url) {
        window.opener.location.href=url;
        window.opener.focus();
    }
}


