function dspDate()
{
	// Create an array of day names.
	var dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	// Create an array of month names.
	var monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	// Create a date object that default to current time.
	var d = new Date();
	var day = d.getDate();
	var dayPostfix = "";
	if (day > 29)
		day -= 30;
	else if (day > 19)
		day -= 20;
	if (day == 1)
		dayPostfix = "st";
	else if(day == 2)
		dayPostfix = "nd";
	else if(day == 3)
		dayPostfix = "rd";
	else
		dayPostfix = "th";
	var year = d.getYear();
	if (year < 2000)
		year += 1900;
	// display the date in long date format.
	document.write(dayName[d.getDay()] + ", " + monName[d.getMonth()] + " " + d.getDate() + dayPostfix + ", " + year);
}

function dspCurrentYear()
{
	var d = new Date();
	var year = d.getYear();
	if (year < 2000)
		year += 1900;
	document.write(year);
}
/* Old version of function. Gave up for new version that shows domain of site for requester.
function contactMe()
{
	var name = "%65%6D%61%63%6B";
	var domain = "%69%63%61%2E%63%6F%6D"; 
	document.write('<a href=\"mailto:' + name + '@' + domain +'?subject=[ica.com web inquiry]\" title=\"Send me an email (no Spam please).\">email</a>');
}
*/
function contactMe()
{
	var name = "%49%6e%73%69%64%65%2e%65%50%72%6f%64%75%63%74%69%76%69%74%79";
	var domain = "%69%63%61%2E%63%6F%6D"; 
	document.write('<a href=\"mailto:' + name + '@' + domain +'?subject=[Web-Query: ' + escape(document.title) + 
		']\" title=\"Send me an email.\">Contact Us</a>');
}
/* this code, when called, will popup a window with the url */
function viewPage(page){
	window.open(page,"Quote","width=500,height=500,resizable,scrollbars=yes,status=yes")
}
function getPageName() {
	var sUrl = document.URL;
	var iPos = sUrl.lastIndexOf("/") + 1;
	sUrl = sUrl.substr(iPos);
	iPos = sUrl.lastIndexOf("?");
	if(iPos != -1)
		sUrl = sUrl.substring(0, iPos);
	iPos = sUrl.lastIndexOf("#");
	if(iPos != -1)
		sUrl = sUrl.substring(0, iPos);
	return sUrl;
}
function getComments()
{
	var el = window.event.srcElement;
	el.frameWindow = document.frames[el.id];
	if (el.readyState == "complete")
	{
		// Finish initialization.
//		alert("(" + el.readyState + ")\n" + el.frameWindow.document.body.innerHTML);
		var sHtml = el.frameWindow.document.body.innerHTML;
		var iPos = sHtml.indexOf("<BR>");
		if (iPos == -1)
			return;
		sHtml = sHtml.substr(iPos + 4);
		iPos = sHtml.indexOf('<TABLE');
		if (iPos == -1)
			return;
		sHtml = sHtml.substring(0, iPos);
		window.commentdiv.innerHTML = sHtml;
	}
}
function goPermanentLink()
{
	var el = event.srcElement;
	var elSrc = el;
	while(1)
	{
		if(el.tagName == "DIV")
		{
			if(el.className == "entrytop")
				break;
		}
		el = el.parentElement;
	}
	el = el.children.tags("A")[0];
//	window.open(el.href, "_self");
	elSrc.href = el.href;
}
function startRealVideo(el, url, width, height)
{
el.innerHTML = '<OBJECT id="rvocx" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="' + width + '" height="' + height + '"  >' +
'<param name="src" value="' + url + '">' +
'<param name="autostart" value="true">' +
'<param name="controls" value="imagewindow">' +
'<param name="console" value="video">' +
'<param name="loop" value="false">' +
'<EMBED src="' + url + '" loop="false" type="audio/x-pn-realaudio-plugin" controls="imagewindow" console="video" autostart="true">' + 
'</EMBED>' + 
'<OBJECT id="rvocx" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="' + width + '" height="30">' + 
'<param name="src" value="' + url + '">' + 
'<param name="autostart" value="true">' + 
'<param name="controls" value="ControlPanel">' + 
'<param name="console" value="video">' + 
'<EMBED src="' + url + '" width="' + width + '" height="30" controls="ControlPanel" type="audio/x-pn-realaudio-plugin" console="video" autostart="true">' + 
'</EMBED>' + 
'</OBJECT>';
}
function startWindowsMedia(el, url, width, height){
	if(url.substr(0,4).toLowerCase() != "http")
		if(swfServerLocation) url = (swfServerLocation + url);
	var els = el.getElementsByTagName('img');
	var sStyle = "";
	if(els.length)
		sStyle = 'style="background-image: url(' + els[0].src + ')"';
	
	el.innerHTML = '<OBJECT id="mediaPlayer" width="'+width+'" height="'+height+
		'" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="'+
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '+
		'standby="Loading Microsoft Windows Media Player components..." '+
		'type="application/x-oleobject"' + sStyle + '>' + 
		'<param name="fileName" value="'+url+'">' + 
		'<param name="animationatStart" value="true">' + 
		'<param name="transparentatStart" value="true">' + 
		'<param name="autoStart" value="true">' + 
		'<param name="showControls" value="true">' + 
		'<param name="loop" value="false">' + 
		'<param name="showtracker" value = "1">' + 
		'<param name="showdisplay" value ="0">' + 
		'<param name="showstatusbar" value="1">' + 
		'<EMBED type="application/x-mplayer2" '+
		'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '+
		'id="mediaPlayer" name="mediaPlayer" displaysize="4" autosize="-1" '+
		'bgcolor="darkblue" showcontrols="true" showtracker="1" showdisplay="0" '+
		'showstatusbar="1" videoborder3d="-1" width="'+width+'" height="'+height+
		'" src="'+url+'" autostart="true" designtimesp="5311" loop="false">' + 
		'</EMBED>' + 
		'</OBJECT>';
	//alert(el.innerHTML);
}
function setVideo(url, width, height){
	if(url.indexOf(".") == -1)
		return;
	// Get the extention of video file name.
	var ext = url.split(".")[1].toLowerCase();
	// Get the file path without the extention.
	var filepath = url.split(".")[0].split("\/");
	// Get the file name.
	var filename = filepath[filepath.length-1];
	// Create an image file name the same as the video file 
	// name but with a jpg extention.
	var imgFile = filename + ".jpg";
	if(ext == "wmv")
		var sFunction = "startWindowsMedia";
	else if(ext == "flv")
		var sFunction = "playFlashVideo";
	else if(ext == "swf")
		var sFunction = "playFlash";
	else {
		alert("Error in video file extension, must be .wmv, .flv or .swf.\n" + url);
		return;
	}
	// Create the html for the link to the video.
	var sHTML = "<div class=\"webcam\" id=\"video" + setVideo.guid + "\"><a href=\"javascript:" + sFunction + "(fcUse('video" + setVideo.guid + "'),'" + url + "'," + width + "," + height + ")\" title=\"Click image to play video.\"><img src=\"" + imgFile + "\/$file\/" + imgFile + "\" alt=\"Click image to play video.\"></a></div>";
	document.write(sHTML);
//	alert(sHTML);
	setVideo.guid++;
}
setVideo.guid = 1;
// rotate images from array 4/7/7 used for rotating graphics
function imgRotator(elID, objImages) {
	var el = document.getElementById(elID);
	if(!el)
		return;
	if(typeof objImages == "undefined")
		return;
	var d = new Date();
	var i = d.getSeconds() % objImages.length;
	el.src = objImages[i] + "/$file/" + objImages[i];
}
