var time_offset;
function curTime(s) {
		if (s) {
			var todayserver = new Date(s);
			var todayclient = new Date();
			time_offset = todayserver.getTime() - todayclient.getTime();
			}
		var daynames = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
		var monthnames = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		var now=new Date();
		now.setTime(now.getTime() + time_offset); //adjust for differenece between client and server
		var hrs=now.getHours();
		var min=now.getMinutes();
		var sec=now.getSeconds();
		var yr=now.getYear();
		var monthname=monthnames[now.getMonth()];
		var day=now.getDate();
		var dayname=daynames[now.getDay()];
		var don='';
		//var don="AM";
		//if (hrs>=12){ don="PM"; }
		//if (hrs>12) { hrs-=12; }
		//if (hrs==0) { hrs=12; }
		if (hrs<10) { hrs="0"+hrs; }
		if (min<10) { min="0"+min; }
		if (sec<10) { sec="0"+sec; }
		if (yr<1900) yr+=1900;
		
		document.getElementById("clock").innerHTML=dayname + "&nbsp;" + monthname + "&nbsp;" + day + ",&nbsp;" + hrs+":"+min+":"+sec+" "+don;
		setTimeout("curTime()",1000);
    }

function Encrypt(theText) {
var output = new String;
for (i = 0; i < theText.length; i++) {
	var rnd = Math.round(Math.random() * 64) + 64;
	var code = theText.charCodeAt(i) + rnd;
	output += code.toString(16);
	output += rnd.toString(16);
	}
//alert(theText);
//alert(output);
return output;
}

function replaceBrokenImages(imgname) {
	for (var i = 0; i < document.images.length; i++) {
		if (!IsImageOk(document.images[i])) {
				document.images[i].src=imgname;
		}
	}
}
function IsImageOk(img) {
		// from http://talideon.com/weblog/2005/02/detecting-broken-images-js.cfm
		
    // During the onload event, IE correctly identifies any images that
    // weren't downloaded as not complete. Others should too. Gecko-based
    // browsers act like NS4 in that they report this incorrectly.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth and
    // naturalHeight. These give the true size of the image. If it failed
    // to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}
