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 = "%65%6D%61%63%6B";
	var domain = "%69%63%61%2E%63%6F%6D"; 
	document.write('<li><a href=\"mailto:' + name + '@' + domain +'?subject=[Web-Query: ' + escape(document.title) + 
		']\" title=\"Send me an email (no Spam please).\">Email</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;
var contentImages =  "main_image_home1.jpg,main_image_home2.jpg".split(",");
function imgRotator() {
	var el = document.getElementById("content").getElementsByTagName("img");
	if(!el.length)
		return;
	if(typeof contentImages == "undefined")
		return;
	var d = new Date();
	var i = d.getSeconds() % contentImages.length;
	el[0].src = contentImages[i] + "/$file/" + contentImages[i];
}
// To turn off image rotator, comment out the next three lines.
if(typeof addEvent != "undefined"){
	addEvent(window, "DOMContentLoaded", imgRotator);
}
// 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];
}
// The following JS is used in the conact-us form
var f = document.contactusform;
var req;
var which;
var TargetDiv;
 
function submitform()
{
  document._test.submit();
}
function openDoc(url){
	window.location.href = url;
}
function reset_form(){
var f = document.contactusform;
f.q1.selectedIndex = 0;
f.q2.selectedIndex = 0;
f.q3.selectedIndex = 0;
f.q4.selectedIndex = 0;
f.q5.value = '';
f.q6.selectedIndex = 0;
f.q7.value = '';
f.q8.value = '';
f.q9.value = '';
f.q10.value = '';
f.q11.selectedIndex = 0;
f.q12.value = '';
f.q13.value = '';
f.q14.value = '';
f.q15.value = '';
f.q16.value = '';
f.q17.value = '';
f.q18.value = '';
f.q19.value = '';
f.q20.selectedIndex = 0;
f.q21.selectedIndex = 0;
f.q22.value = '';
f.q23.value = '';
f.q24.value = '';
f.q25.selectedIndex = 0;
f.q1.focus();
}
function submit_form(){
	var f = document.contactusform;
	var putdata = '';	
	
	if (f.q1.selectedIndex == 0) {
		alert("Please specify why you are contacting us.");
		f.q1.focus();
		return false;
	}
	if (f.q2.selectedIndex == 0) {
		alert("Please specify the version of Lotus Notes you are using.");
		f.q2.focus();
		return false;
	}
if (f.q6.selectedIndex == 0) {
		alert("Please specify how you learned about us.");
		f.q6.focus();
		return false;
	}
	if (f.q7.value.length == 0) {
		alert("Please enter your first name.");
		f.q7.focus();
		return false;
	}
	if (f.q8.value.length == 0) {
		alert("Please enter your last name.");
		f.q8.focus();
		return false;
	}
	if (f.q25.selectedIndex == 0) {
		alert("Please enter your role.");
		f.q25.focus();
		return false;
	}
	if (f.q9.value.length == 0) {
		alert("Please enter your company name.");
		f.q9.focus();
		return false;
	}
	if (f.q10.value.length == 0) {
		alert("Please enter your title/position within your company.");
		f.q10.focus();
		return false;
	}

	if (f.q12.value.length == 0) {
		alert("Please enter your email address.");
		f.q12.focus();
		return false;
	}
//check to see that passwords are not blank and are equal
	if (f.q12.value != f.q13.value) {
		alert("Your email addresses do not match. Please ensure the email addresses you have entered are correct.");
		f.q12.value = '';
		f.q13.value = '';
		f.q12.focus();
		return false;
	}
	if (f.q14.value.length == 0) {
		alert("Please enter your phone number, including area code.");
		f.q14.focus();
		return false;
	}
	if (f.q11.selectedIndex == 0) {
		alert("Please specify how you would like to be contacted.");
		f.q11.focus();
		return false;
	}
	if (f.q17.value.length == 0) {
		alert("Please enter your address.");
		f.q17.focus();
		return false;
	}
	if (f.q19.value.length == 0) {
		alert("Please enter your city.");
		f.q19.focus();
		return false;
	}
	if (f.q21.selectedIndex == 0) {
		alert("Please enter your country.");
		f.q21.focus();
		return false;
	}
	if (f.q22.value.length == 0) {
		alert("Please enter postal code.");
		f.q22.focus();
		return false;
	}
if (f.q25.selectedIndex == 11 || f.q25.selectedIndex == 12 || f.q1.selectedIndex == 11){
if (f.q24.value.length == 0) {
		alert("Please enter a web site. This is required as you have specified you are interested in writing about eProductivity, or your role is as a blogger or in the media.");
		f.q24.focus();
		return false;
}
	}
// Pass values from the form to the agent
	if (f.q1_other.value != ''){
		putdata = "q1=" + encodeURIComponent(f.q1_other.value);
	}else{
		putdata = "q1=" + encodeURIComponent(f.q1[f.q1.selectedIndex].text);
	}
	if (f.q2_other.value != ''){
		putdata += "&q2=" + encodeURIComponent(f.q2_other.value);
	}else{
		putdata += "&q2=" + encodeURIComponent(f.q2[f.q2.selectedIndex].text);
	}
putdata += "&q3=" + encodeURIComponent(f.q3[f.q3.selectedIndex].text);
putdata += "&q4=" + encodeURIComponent(f.q4[f.q4.selectedIndex].text);
putdata += "&q5=" + encodeURIComponent(f.q5.value);
putdata += "&q6=" + encodeURIComponent(f.q6[f.q6.selectedIndex].text);
	if (f.q6_other.value != ''){
		putdata += "&q6Other=" + encodeURIComponent(f.q6_other.value);
	}else{
		putdata += "&q6Other=" + encodeURIComponent('No referral');
	}
putdata += "&q7=" + encodeURIComponent(f.q7.value);
putdata += "&q8=" + encodeURIComponent(f.q8.value);
putdata += "&q9=" + encodeURIComponent(f.q9.value);
putdata += "&q10=" + encodeURIComponent(f.q10.value);
putdata += "&q11=" + encodeURIComponent(f.q11[f.q11.selectedIndex].text);
putdata += "&q12=" + encodeURIComponent(f.q12.value);
putdata += "&q13=" + encodeURIComponent(f.q13.value);
putdata += "&q14=" + encodeURIComponent(f.q14.value);
putdata += "&q15=" + encodeURIComponent(f.q15.value);
putdata += "&q16=" + encodeURIComponent(f.q16.value);
putdata += "&q17=" + encodeURIComponent(f.q17.value);
putdata += "&q18=" + encodeURIComponent(f.q18.value);
putdata += "&q19=" + encodeURIComponent(f.q19.value);
putdata += "&q20=" + encodeURIComponent(f.q20[f.q20.selectedIndex].text);
putdata += "&q21=" + encodeURIComponent(f.q21[f.q21.selectedIndex].text);
putdata += "&q22=" + encodeURIComponent(f.q22.value);
putdata += "&q23=" + encodeURIComponent(f.q23.value);
putdata += "&q24=" + encodeURIComponent(f.q24.value);
	if (f.q25_other.value != ''){
		putdata += "&q25=" + encodeURIComponent(f.q25_other.value);
	}else{
		putdata += "&q25=" + encodeURIComponent(f.q25[f.q25.selectedIndex].text);
	}
		document.getElementById("buttons").style.visibility = "hidden";
		document.getElementById("buttons").style.display = "none";
	document.getElementById("processing").style.visibility = "visible";
		document.getElementById("processing").style.display = "block";
	url= basehref + "/ContactSubmit?OpenAgent";
	if (req){
		req.abort();  
	}
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
//		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.onreadystatechange = signupResponse;
		try {
			req.open("POST", url, true);
		} catch (e) {
			alert(e);
		}
		req.send(putdata);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
//		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		if (req) {
			req.onreadystatechange = signupResponse;
			req.open("POST", url, true);
			req.send(putdata);
		}
	}
};
function signupResponse() {
	if (req.readyState == 4) { // Complete
	if (req.status == 200) { // OK response
	if (req.responseText.substring(0,7) == "Success"){
window.location = "http://www.eproductivity.com/ICA/eproductivity.nsf/dx/contact-us-successful";
			}else{
				document.getElementById("contactustable").style.color = "#FF0000";
				document.getElementById("contactustable").innerHTML = req.responseText ;
			}       
			req = null;
		} else {
			//the line below fails sometimes on ie7
			//alert("Problem: " + req.statusText);
			document.getElementById("contactustable").style.backgroundColor = "#FFFFFF";
			document.getElementById("contactustable").style.color = "#FF0000";
			document.getElementById("contactustable").innerHTML = req.statusText ;
		}
	}
}
function displayFieldQ1(){
var f = document.contactusform;
	if (f.q1.selectedIndex == 12) {
		document.getElementById("q1_otherinformation").style.visibility = "visible";
		document.getElementById("q1_otherinformation").style.display = "block";
		f.q1_other.focus();
		}else{
		f.q1_other.value = '';
		document.getElementById("q1_otherinformation").style.visibility = "hidden";
		document.getElementById("q1_otherinformation").style.display = "none";
	}
}
function displayFieldQ2(){
var f = document.contactusform;
	if (f.q2.selectedIndex == 9) {
		document.getElementById("q2_otherinformation").style.visibility = "visible";
		document.getElementById("q2_otherinformation").style.display = "block";
		f.q2_other.focus();
		}else{
		f.q2_other.value = '';
		document.getElementById("q2_otherinformation").style.visibility = "hidden";
		document.getElementById("q2_otherinformation").style.display = "none";
	}
}
function displayFieldQ6(){
var f = document.contactusform;
	if (f.q6.selectedIndex == 2 || f.q6.selectedIndex == 3 || f.q6.selectedIndex == 4 || f.q6.selectedIndex == 5 || f.q6.selectedIndex == 13) {
		document.getElementById("q6_otherinformation").style.visibility = "visible";
		document.getElementById("q6_otherinformation").style.display = "block";
		f.q6_other.focus();
		}else{
		f.q6_other.value = '';
		document.getElementById("q6_otherinformation").style.visibility = "hidden";
		document.getElementById("q6_otherinformation").style.display = "none";
	}
}
function displayFieldQ25(){
var f = document.contactusform;
	if (f.q25.selectedIndex == 13) {
		document.getElementById("q25_otherinformation").style.visibility = "visible";
		document.getElementById("q25_otherinformation").style.display = "block";
		f.q25_other.focus();
		}else{
		f.q25_other.value = '';
		document.getElementById("q25_otherinformation").style.visibility = "hidden";
		document.getElementById("q25_otherinformation").style.display = "none";
	}
}
function hideField(fieldname){
	window.location.href = url;
}
