jQuery(document).ready(function(){

	jQuery("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
	jQuery("ul.topnav li span").click(function() { //When trigger is clicked...
        if(jQuery(this).parent().find("ul.subnav").is(":visible")){
            jQuery('#banner').show();
        }else{
            jQuery('#banner').hide();
        }
        
        
		//Following events are applied to the subnav itself (moving subnav up and down)
		jQuery(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		jQuery(this).parent().hover(function() {
		}, function(){
			jQuery(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
            if(jQuery(this).parent().find("ul.subnav").is(":visible")){
                jQuery('#banner').show();
            }else{
                jQuery('#banner').hide();
            }
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			jQuery(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			jQuery(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
    
    jQuery(function() {
    	jQuery('html').css('background','none');
    	jQuery('a#log-in, a.login').click(function(){
           if(jQuery('#login').is(":visible")){
                jQuery('#banner').show();
           }else{
                jQuery('#banner').hide();
           }
    	   
           $('#login').slideToggle();
           
        });

    	if(jQuery('#login em').html()==''){
    	   jQuery('#login').hide();
        }else{ 
    	   jQuery('#login em').hide(); 
           jQuery('#login em').slideDown(); 
        }
    });

});




function setWidth(){
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	var right = (myWidth-1000)/2;
	document.getElementById("body_right").style.width = right+"px";
	document.getElementById("body_left").style.width = right+100+"px";
}


var timer;
var xmlHttpReq;
function updateLiveField() {
	if (window.XMLHttpRequest) {
		try {
			xmlHttpReq = new XMLHttpRequest();
		}
		catch(e) {
			return;
        }
	}
	else if (window.ActiveXObject) {
		try {
			xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				return;
			}
		}
	}
	else {
		return;
	}
	
	xmlHttpReq.onreadystatechange = updateLiveFieldResponse;
	xmlHttpReq.open("GET", "msg.php", true);
	xmlHttpReq.send("");
}

function updateLiveFieldResponse() {
	if (xmlHttpReq.readyState == 4) {
		updateLiveFieldTag(xmlHttpReq.responseText);
		
		timer = setTimeout("updateLiveField()", 5000);
	}
}

function updateLiveFieldTag(timeStr) {
	if (document.getElementById) {
		if (document.getElementById("livefield")){
			document.getElementById("livefield").innerHTML = timeStr;
			
		}
		
	}
	else if (document.all) {
		if (document.all["livefield"]){
			document.all["livefield"].innerHTML = timeStr;
		}
	}
}
