function getWHXY(){
		// Crossbrowser: get the window dimensions in an array
        if (window.innerHeight) return [window.innerWidth,window.innerHeight,window.pageXOffset,window.pageYOffset];
        else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth,document.documentElement.clientHeight,document.documentElement.scrollLeft,document.documentElement.scrollTop];
        return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}

function popWin(page,target,w,h,scrollopt,resizeopt){
		if(w.indexOf('%')){
			w = Math.floor(window.screen.availWidth*(w.substring(0,w.indexOf('%'))/100));
		}
		if(h.indexOf('%')){
			h = Math.floor(window.screen.availHeight*(h.substring(0,h.indexOf('%'))/100));
		}
		
		if(scrollopt!="yes"){
			scrollopt = "no";
		}
		
		if(resizeopt!="yes"){
			resizeopt = "no";
		}
		
        var screenwidth = window.screen.availWidth;
        var screenheight = window.screen.availHeight;
        var halfwidth = Math.floor(w/2);
        var halfheight = Math.floor(h/3);

        var leftpos = screenwidth/2 - halfwidth;
        var toppos = screenheight/3 - halfheight;

        var _width = "width="+w+",";
        var _height = "height="+h+",";
        var _scroll = "scrollbars="+scrollopt+",resizable="+resizeopt+",";
        var _posLeft= "screenX=" + leftpos + ",left=" + leftpos + ",";
        var _posTop = "screenY=" + toppos + ",top=" + toppos ;

        var w = window.open(page,target, _width + _height + _scroll + _posLeft + _posTop);

        w.focus();
        return false;
}

function resizeNav(clicked,on_msg,off_msg){
        var navWidth = document.getElementById('navwidth');

        var origWidth = "160px";
        var navContainer = document.getElementById('modnav');

        if(navWidth.style.width == '0px'){

                clicked.src = "/live/images/bar_close.gif";

                for(i=0;i<navContainer.childNodes.length;i++){
                        if(navContainer.childNodes[i].tagName=="A"){
                                navContainer.childNodes[i].style.display = 'block';
                        }
                }

                navWidth.style.width = origWidth;

        }else{

                clicked.src = "/live/images/bar_open.gif";

                navLinks = navContainer.childNodes;
                for(i=0;i<navContainer.childNodes.length;i++){
                        if(navContainer.childNodes[i].tagName=="A"){
                                navContainer.childNodes[i].style.display = 'none';
                        }
                }

                navWidth.style.width = '0px';

        }

}

function htmlToText (htmlMarkup) {
	var div = document.createElement('div');
	div.innerHTML = htmlMarkup;
	if (typeof div.innerText != 'undefined')
	{
		return div.innerText;
	}
	else if (typeof div.ownerDocument != 'undefined' &&
	typeof div.ownerDocument.createRange != 'undefined')
	{
		var range = div.ownerDocument.createRange();
		range.selectNodeContents(div);
		return range.toString();
	}
	else if (typeof div.textContent != 'undefined')
	{
		return div.textContent;
	}
}

function daySuffix(d) {
    d = String(d);
    return d.substr(-(Math.min(d.length, 2))) > 3 && d.substr(-(Math.min(d.length, 2))) < 21 ? "th" : ["th", "st", "nd", "rd", "th"][Math.min(Number(d)%10, 4)];
}

function startClock(){

        var thetime = new Date();
        
        var month_arr = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
        var day_arr   = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

        var day    = thetime.getDay();
        var month  = thetime.getMonth();
        var date    = thetime.getDate();
        var year   = thetime.getYear();
        var nhours = thetime.getHours();
        var nmins  = thetime.getMinutes();
        //var nsecn=thetime.getSeconds();

        var dday = day_arr[day];

        if((year>99) && (year<2000)){
          var dyear="";
          dyear = year+=1900;
        }else{
          dyear = year;
        }

        var dmonth = month_arr[month];
        
        var ddate = date+daySuffix(date);

        var AorP="";
        if(nhours>=12){
          AorP="P.M.";
        }else{
          AorP="A.M.";
        }
        
        if(nhours>=13){
          nhours-=12;
        }

        if(nhours==0){
          nhours=12;
        }

        if(nmins<10){
          nmins="0"+nmins;
        }

        //if(nsecn<10){
        //  nsecn="0"+nsecn;
        //}

        document.getElementById('clock').innerHTML = dday+", "+dmonth+" "+ddate+", "+dyear+" "+nhours+":"+nmins+" "+AorP;

        setTimeout('startClock()',1000);

}

function swapImage(objId,newFile){
	changeTo = new Image(48,48);
	changeTo.src = newFile;
	document.getElementById(objId).src = changeTo.src;
	changeTo.onload = swapImage_setSrc(document.getElementById(objId),newFile);
}
function swapImage_setSrc(obj,src){
	obj.src = src;
}
