var autobob={
    // properties
    //methods
    addEvent:function(elm, evType, fn, useCapture)
    {
        if (elm.addEventListener) 
        {
    	    elm.addEventListener(evType, fn, useCapture);
    		return true;
        }
    	else if(elm.attachEvent)
    	{ 
            var r = elm.attachEvent('on' + evType, fn);
            return r;
        }
    	else
    	{
            elm['on' + evType] = fn;
        }

		return true;
    },

    getElement:function(id)
    {
        if(document.all)
        {
            return eval("document.all['" + id + "']");
        }
        else if (document.getElementById)
        {
            return document.getElementById(id);
        }
        else
        {
            return false;
        }
    },
    
    init:function() //set any properties that need some logic
    {
	    if(window.scrollbars)
	    {
	        window.scrollbars.visible = false;
	    }
	    autobob.resizeWindow();

    },

	resizeWindow:function ()
	{
        //alert("GOT HERE");
	    var dim = Position.GetWindowSize();
	    if((dim.width/dim.height) < ($('bgphoto').width/$('bgphoto').height))
	    {
	        $('bgphoto').style.height = "100%"
	        $('bgphoto').style.width = "auto"
	     }
	    else
	    {
	        $('bgphoto').style.width = "100%"
	        $('bgphoto').style.height = "auto"
	    }

        var background_image = autobob.getElement('bgphoto');

        if(background_image && background_image.style.display == 'none')
        {
            //background_image.style.visibility = 'visible';
           // new Effect.Appear(background_image, {duration: .5,fps: 12,queue:'end'});

        }
	},

	getElementsByClassName:function(oElm, strTagName, strClassName){

	/*
	    Written by Jonathan Snook, http://www.snook.ca/jonathan
	    Add-ons by Robert Nyman, http://www.robertnyman.com
	*/
	
	    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	    var arrReturnElements = new Array();
	    strClassName = strClassName.replace(/\-/g, "\\-");
	    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	    var oElement;
	    for(var i=0; i<arrElements.length; i++){
	        oElement = arrElements[i];
	        if(oRegExp.test(oElement.className)){
	            arrReturnElements.push(oElement);
	        }
	    }
	    return (arrReturnElements)
	}
}

Position.GetWindowSize = function(w) {
	var width, height;
        w = w ? w : window;
        this.width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        this.height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
        return this;
}

// initialise stuff if necessary (on load)
autobob.addEvent(window, 'load', autobob.init, false);
// initialise stuff if necessary (on resize)
autobob.addEvent(window, 'resize', autobob.resizeWindow, false);

// Generate Safe Email Links
function generate_address(username, domain, ext)
{
	var atsign = "&#64;";
	var addr = username + atsign + domain + ext;
	document.write
	(
		"<" + "a" + " " + "href=" + "mail" + "to:" + addr + " class=\"email_link\">" + addr +  "<\/a>"
	);
}
