
//--------------------------------------------------------------
// Funcs
//--------------------------------------------------------------
var debug = true;
var popup;

if(document.all && !document.getElementById) 
{ 
    document.getElementById = function(id){ return document.all[id]; }
}

function loadImages(){ var args = loadImages.arguments; document.imageArray = new Array(args.length); for(var i=0; i<args.length; i++) { document.imageArray[i] = new Image; document.imageArray[i].src = args[i]; }}
function switchImage(imgName, imgSrc) { if (document.images) { if (imgSrc != "none"){ document.images[imgName].src = imgSrc;}}}

function closeEntry(){ if(popup != null) popup.close(); popup=null; }

function preLoadImages()
    {
    loadImages('/images/bgtop.jpg','/images/bgbottom.jpg','/images/enter_n.gif', '/images/ener_o.gif', '/images/enter_d.gif','/images/inner_img.jpg','/images/truss2.jpg','/images/stab3.jpg','/images/order.jpg');
    }
    
function setClass(oObject,newstyle)
{
	var a = document.getElementById(oObject);
	a.className = newstyle; 	
}

function setVisible(_obj){ document.getElementById(_obj).style.visibility = "visible"; }
function setHidden(_obj){ document.getElementById(_obj).style.visibility = "hidden"; }
function setZIndex(_obj, _z){ document.getElementById(_obj).style.zindex = _z; }

//.....................................................
// getWindowHeight
// Returns the height in pixels of the current window.
//.....................................................
function getWindowHeight()
{
    if(debug) alert("getWindowHeight");
    var _h = 0;
    if( typeof( window.innerWidth ) == 'number' ) 
        _h = window.innerHeight;                                                //Non-IE
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
        _h = document.documentElement.clientHeight;                             //IE 6+ in 'standards compliant mode'
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )  
        _h = document.body.clientHeight;                                        //IE 4 compatible
        
    return _h;
}

//.....................................................
// getWindowWidth
// Returns the width in pixels of the current window.
//.....................................................
function getWindowWidth()
{  
    if(debug) alert("getWindowWidth");
    var _w = 0;
    if( typeof( window.innerWidth ) == 'number' ) 
        _w = window.innerWidth;                                                 //Non-IE
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
        _w = document.documentElement.clientWidth;                              //IE 6+ in 'standards compliant mode'
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
        _w = document.body.clientWidth;                                         //IE 4 compatible
    return _w;
}


//.....................................................
// show
//.....................................................
function show(_obj)
{
    try
    {
        var oObj = document.getElementById(_obj);
        oObj.style.visibility = 'visible';
        oObj.style.display = 'block';
    }
    catch(err)
    {
        if(debug) alert("Error showing control: " + _obj);
    }
    return false;
}

//.....................................................
// hide
//.....................................................
function hide(_obj)
{
    try
    {
        var oObj = document.getElementById(_obj);
        oObj.style.visibility = 'hidden';
        oObj.style.display = 'none';
    }
    catch(err){
        if(debug) alert("Error hiding control: " + _obj);
    }
    return false;
}

//.....................................................
// getRandomNum
//.....................................................
function getRandomNum(lbound, ubound) 
{
    return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

//.....................................................
// getRandomChar
//.....................................................
function getRandomChar(number, lower, upper, other, extra) 
{
    var charSet = "A1BCDE2CDE2FGH3JKZ4M5NFGH3JK4MS5NP6QRST78UVW9XYZCDE2FGH3JK4M5N";
    return charSet.charAt(getRandomNum(0, charSet.length));
    }
   

//.....................................................
// generatePassword
//.....................................................
function generatePassword() 
{
    var rc = "";
    if (length > 0)
        rc = rc + getRandomChar(true, false, true, false, false);
    for (var idx = 1; idx < 8; ++idx) 
    {
        rc = rc + getRandomChar(true, false, true, false, false);
    }
    return rc;
}

//function addEntry(_c, _s)
//{ 
//    var _h = screen.height; var _w = screen.width; var _x = ((_w / 2) - 200); var _y = ((_h / 2) - 200);
//    popup = window.open('/schedule_entry.aspx?s=' + _s + '&c=' + _c ,'_new',"scrollbars=no,menubar=no,toolbar=no,status=yes,resizable=no,width=500,height=400,screenX=" + _x + ",screenY=" + _y); 
//}