setAjaxDiv("content");
setGoogleAnalyticsID("UA-4418450-37");

window.onload = function() {
	positionFooter();
	positionContent();
	
	setTimeout( "$( '#content' ).fadeIn('slow')", 2000 );
	
}

window.onresize = function() {
	positionFooter();
	positionContent();
}


function positionFooter() {
	
	o_footer = document.getElementById("footer");
	
    n_window_height = window.innerHeight;
    if ( n_window_height == null ) {
    	n_window_height = document.documentElement.clientHeight;
    }
	
	o_footer.style.top = (n_window_height - 100) + "px";

}

function positionContent() {
	
	o_footer = document.getElementById("content");
	
    n_window_height = window.innerHeight;
    if ( n_window_height == null ) {
    	n_window_height = document.documentElement.clientHeight;
    }
	
	o_footer.style.height = (n_window_height - 200) + "px";	
	
}



var io_current_popup_navigation_menu = null;

function zxcPos(obj){
 
 var rtn=[obj.offsetLeft,obj.offsetTop];

 while(obj.offsetParent!=null){

     var objp=obj.offsetParent;
    //rtn[0]+=objp.offsetLeft-objp.scrollLeft;
    //rtn[1]+=objp.offsetTop-objp.scrollTop;

    rtn[0]+=objp.offsetLeft
    rtn[1]+=objp.offsetTop
    obj=objp;
 }

 //rtn[1] = rtn[1] + window.pageYOffset;

 return rtn;
}



function popupNavigation( vo_target ) {

        if ( io_current_popup_navigation_menu != null ) {
            popdownNavigation();
        }

        n_test = zxcPos(vo_target);

	n_x = n_test[0]  //vo_target.offsetLeft;
	n_y = n_test[1]  //vo_target.offsetTop;

        //alert("Y:" + n_y + " X:" + n_x );


        n_height = vo_target.offsetHeight - 17;
        n_width = vo_target.offsetWidth;

        o_nodes = vo_target.childNodes;

        for ( n_index = 0; n_index < o_nodes.length; n_index++ ) {

            if ( o_nodes.item(n_index) instanceof Object || typeof o_nodes.item(n_index) == "object" ) {

                //alert( o_nodes.item(n_index) );

                if ( o_nodes.item(n_index).className == "subNavigation" ) {

                    io_current_popup_navigation_menu = o_nodes.item(n_index);

                    io_current_popup_navigation_menu.style.top = n_y + n_height  + "px";
                    io_current_popup_navigation_menu.style.left = n_x + "px";
                    io_current_popup_navigation_menu.style.display = "block";

                    if ( io_current_popup_navigation_menu.offsetWidth < n_width ) {
                        io_current_popup_navigation_menu.style.width = n_width + "px";
                    }

                }


            }

        }


        document.onmouseover = function(event) {

            event = event || window.event;

            n_cords = zxcPos(io_current_popup_navigation_menu);

            n_mouse_y = ( event.clientY + window.pageYOffset );

           // alert( "mouse_y = " + n_mouse_y + " ||  n_y = " + n_y + " || bottom of popup = " + ( n_cords[1] + io_current_popup_navigation_menu.offsetHeight ) );

            if ( event.clientX < n_cords[0] || event.clientX > (n_cords[0] + io_current_popup_navigation_menu.offsetWidth) ||
                n_mouse_y < n_y || n_mouse_y > ( n_cords[1] + io_current_popup_navigation_menu.offsetHeight ) ) {

                popdownNavigation();

            }

        }

}

function popdownNavigation() {

        if ( io_current_popup_navigation_menu != null ) {
            io_current_popup_navigation_menu.style.display = "none";

            document.onmouseover = null;
        }

}

