// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
// If you do remove this, I will hunt you down :)
//
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- myapi version date: 03/29/02 ------------------------------------------------------
//
// ---------------------------------------------------------------------------------------
// Several functions added or modified by Scott Upton, Uptonic.com
// December 2004
// ---------------------------------------------------------------------------------------

Detect = function(){
        var agent = navigator.userAgent.toLowerCase();
        this._mac = agent.indexOf('mac') != -1;
        this._win = !this._mac;
        this._w3c = document.getElementById;
        this._iex = document.all;
        this._ns4 = document.layers;
}
Detect.prototype.getObj = function(name){
        if(this._w3c){
                return document.getElementById(name);
        }else if(this._iex){
                return document.all[name];
        }else if(this._ns4){
                return this.getObjNS4(document,name);
        }
}
Detect.prototype.getObjNS4 = function(obj, name){
        var d = obj.layers;
        var result,temp;
        for(var i=0; i<d.length; i++){
                if(d[i].id == name){
                         result = d[i];
                }else if(d[i].layers.length){
                        var temp = this.getObjNS4(d[i],name);
                }
                if(temp){
                        result = temp;
                }
        }
        return result;
}
Detect.prototype.getStyle = function(obj){
        return (this._ns4) ? obj : obj.style;
}


// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// HTMLobj Constructor

HTMLobj = function(name){
        if(name){
                this._inherit = Detect; this._inherit(name);
                this._id  = name;
                this._el  = this.getObj(this._id);
                this._css = this.getStyle(this._el);
                this._obj = name+'Object'; eval(this._obj+'=this');
                this._timer = null;
                this._glideRunning = false;
                this._tweenRunning = false;
                this._fadeRunning = false;        // Added by SU, Couloir
                this._randNum = null;                // Added by SU, Couloir
                this._startFade = false;        // Added by SU, Couloir
                return this;
        }
}
HTMLobj.prototype = new Detect();


HTMLobj.prototype.setStyle = function(prop, val){ // change the value of any css property
        if(!this._ns4){
                this._el.style[prop] = val;
                if(this._iex && this._mac){
                        this._el.innerHTML = this._el.innerHTML;
                }
        }
}
HTMLobj.prototype.show = function(){ // show the visibility of the element
        this._css.visibility = 'visible';
}
HTMLobj.prototype.hide = function(){ // hide the visibility of the element
        this._css.visibility = 'hidden';
}
HTMLobj.prototype.showhide = function(){ // toggle the visibility of the element
        if(this._css.visibility == 'hidden' || this._css.visibility == 'hide'){
                this._css.visibility = 'visible';
        }else{
                this._css.visibility = 'hidden';
        }
}


HTMLobj.prototype.setOpacity = function(opacity){ // set opacity of the element
        // Fix for math error in some browsers
        opacity = (opacity == 100)?99.999:opacity;
        // IE/Windows
        this._css.filter = "alpha(opacity:"+opacity+")";
        // Safari < 1.2, Konqueror
        this._css.KHTMLOpacity = opacity/100;
        // Older Mozilla and Firefox
        this._css.MozOpacity = opacity/100;
        // Safari 1.2, newer Firefox and Mozilla, CSS3
        this._css.opacity = opacity/100;
}
HTMLobj.prototype.fadeOut = function(opacity, change, speed){ // gradually decrease the opacity of the element
// opacity: starting opacity of element
// change: the size of the increments between steps
// speed: the rate of the animation
        if (opacity >= 0){
          this._fadeRunning = true;
          this.setOpacity(opacity);
          opacity -= change;
          setTimeout(this._obj+'.fadeOut('+opacity+','+change+','+speed+')', speed);
        } else {
                this._fadeRunning = false;
                this.hide();
        }
}
HTMLobj.prototype.fadeIn = function(opacity, change, speed){ // gradually increase the opacity of the element
// opacity: starting opacity of element
// change: the size of the increments between steps
// speed: the rate of the animation
        if (opacity <= 100){
          this.show();
          this._fadeRunning = true;
          this.setOpacity(opacity);
          opacity += change;
          setTimeout(this._obj+'.fadeIn('+opacity+','+change+','+speed+')', speed);
        } else {
                this._fadeRunning = false;
                this.setOpacity(100);
        }
}
HTMLobj.prototype.displayShow = function(){ // display the element as 'block'
        this._css.display = 'block';
}
HTMLobj.prototype.displayHide = function(){ // do not display the element
        this._css.display = 'none';
}

// Create access to 'Detect' object and a place to put instances of 'HTMLobj'
var API = new Detect();
API.thumb = new Array();

function hide_search_image() {
        API.SearchImg = new HTMLobj('searching');
        API.SearchImg.displayHide();
}
function fade_largephoto() {
        hide_search_image();
        API.Container = new HTMLobj('largephoto');
        API.Container.fadeIn(0,15,33);
}
function fade_last_thumbnail(who) {
        hide_search_image();
        fade_thumbnail(who);
}
function fade_thumbnail(who) {
        API.thumb[API.thumb.length] = new HTMLobj(who);
        API.thumb[API.thumb.length-1].fadeIn(0,15,33);
}

function blurAnchors(){
        if(document.getElementsByTagName) {
                var a = document.getElementsByTagName("a");
                for(var i = 0; i < a.length; i++) {
                        a[i].onfocus = function(){this.blur();}
                }
        }
}

window.onload = blurAnchors;
