// ======= Functions ======


// === Blur links

var blurStatus = 1 ;

function blurMe() { // function to blur links
    if ( blurStatus == 1 ) { 
        this.blur() ; 
        this.hideFocus = true ;
        this.style.outline = 'none' ;
    } else {
        this.hideFocus = false ;
        this.style.outline = null ;
    }
}

function blurLinks() { // function to blur elements onFocus ;
    document.onmousedown = function() { blurStatus = 1 }
    document.onkeydown   = function() { blurStatus = 0 }

    if ( !document.getElementsByTagName ) return ;

    elementArr = new Array ( "a" , "area" ) ;
    for ( j = 0 ; j < elementArr.length ; j++ ) {
        theElements = document.getElementsByTagName( elementArr [ j ] ) ;

        for ( i = 0 ; i < theElements.length ; i++ ) {
            theElements[ i ].onfocus = blurMe ;
        } // End for ( theElements )
    } // End for ( elementArr )
} 

// === Make window open (pop-up)

function makeWindow ( url, name, wd, ht) { 
    var args = "height=" + ht + ",innerHeight=" + ht;
    args += ",width=" + wd + ",innerWidth=" + wd;

    if ( document.all ) {
        w = document.body.clientWidth ;
        h = document.body.clientHeight ;
    } else if ( document.layers ) {
        w = window.innerWidth ;
        h = window.innerHeight ;
    } else if ( window.screen ) {
        w = screen.availWidth ;
        h = screen.availHeight ;
    }

    var xcen = ( w - wd ) / 2 ; 
    var ycen = ( h - ht ) / 2 ;
    args += ",left=" + xcen + ",screenX=" + xcen ;
    args += ",top=" + ycen + ",screenY=" + ycen ;

    args += ",location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=yes" ;

    this.windobj = window.open ( url, name, args ) ; 
    if (window.focus) this.windobj.focus() ;

    return false ;
} 


// Manage e-mail addresses

function manageEmail( atSign ) {

    var theLinks = document.getElementsByTagName( 'a' ) ;

    // Iterate through links

    for ( var i = 0; i < theLinks.length ; i++ ) {

        // Check wether it is an e-mail link

        if ( theLinks[ i ].href.indexOf( 'mailto:' ) == 0 ) { 

            theLinks[ i ].href = theLinks[ i ].href.replace( atSign, '@' ) ;

        } // End if ( mail link )

    } // End for ( iterate through links )


} // End function manageEmail


function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else 
      window.onload = fnc;
  }
}



// ======= Main script =======

// === Initialize

function init() {
    blurLinks() ;
    manageEmail( '-at-' ) ;
	
	bgimage = new Image();
	bgimage.src = "uploads/images/bg_1000_l4.jpg";
	
}

var enableMenuClose = true ;

addOnloadEvent(init);