﻿// JavaScript Document for public functions

//return HTML object by object id
function $(id){	var obj = document.getElementById(id);	return obj ? obj : undefined;}

//return HTML object's value
function $V(id){if($(id) != undefined){	return $(id).value;	}else{return null;} }

function $Len(id){if($(id) != undefined){return $(id).options.length;}else{	return null;} }

function $Rows(id){	if($(id) != undefined){	return $(id).rows.length;}else{	return null;} }

function DrawImage(ImgID, Size) {
    var xvar = Size;
    var image = new Image();
    image.src = ImgID.src;
    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= 1) {
            if (image.width > xvar) {
                ImgID.width = xvar;
                ImgID.height = (image.height * xvar) / image.width;
            } else {
                ImgID.width = image.width;
                ImgID.height = image.height;
            }
        }
        else if (image.height > xvar) {
            ImgID.height = xvar;
            ImgID.width = (image.width * xvar) / image.height;
        }
        else {
            ImgID.width = image.width;
            ImgID.height = image.height;
        }
    }
} 
