function openFlash()
{
window.open("http://www.chatham-kent.ca/mayor/ckexposed.swf","","top=0,left=0,width=800,height=600,resizable=yes,scrollbars=no")
}
function openWin(str)
{
if (str =='a')
{
	window.open("http://www.chatham-kent.ca/tourismflash/attractions.html","blank","toolbar=no,width=780,height=515,scrollbars=1,resize=yes");
}
if (str =='b')
{
	window.open("http://www.nxtbook.com/dawson/chathamkent/tg2010/","blanka","toolbar=no,width=780,height=620,scrollbars=1,resizable=1");
}
if (str == 'c')
{
	window.open("http://www.havocrugby.com/international/index.htm","_self","toolbar=no, widht=780, height=620,scrollbars=1,resize=yes");
}

if  (str == 'd')
{
	window.open("http://www.nxtbook.com/nxtbooks/dawson/ckcommunityprofile/","blank", "toolbar=no,widith=780, height=620, scrollbars=1,resizable=1");
}	
 
}
function textarealength(intLength, obj)
{
	if (obj.value.length > intLength-2)
	{
		alert("You have reached the maximum characters allowed for this field.");
		obj.value = obj.value.substring (0, intLength-1)
	}
}

function encodeProblemCharacters(str) 
{
      if (str.indexOf('&') > - 1) str = encodeCharacter(str, "&", "0026;");
      if (str.indexOf('#') > - 1) str = encodeCharacter(str, "#", "0023;");
      if (str.indexOf('+') > - 1) str = encodeCharacter(str, "+", "002B;");
      if (str.indexOf("'") > - 1) str = encodeCharacter(str, "'", "0060;");
      if (str.indexOf('%') > - 1) str = encodeCharacter(str, "%", "0025;");
      if (str.indexOf('=') > - 1) str = encodeCharacter(str, "=", "003D;");
      if (str.indexOf('|') > - 1) str = encodeCharacter(str, "|", "007C;");
      if (str.indexOf(' ') > - 1) str = encodeCharacter(str, " ", "0020;");
      return str;
}

function encodeCharacter(str, chr, encStr) 
{
	n = str.indexOf(chr);
	nlen = n;
	count = 0;
	while (n > - 1) {
		str = str.substring(0, nlen) + encStr + str.substring(nlen + chr.length, str.length);
		n = str.substring(nlen+encStr.length + chr.length, str.length).indexOf(chr);
		nlen += encStr.length + n + chr.length;
	}
	return str;
}
/*function encodeCharacter(str, chr, encStr) {
	var n = str.indexOf(chr);
	while (n > - 1) {
		str = str.substring(0, n) + encStr + str.substring(n+1, str.length);
		n = str.indexOf(chr);
	}
	return str;
}*/

function returnTop(el,start) {
	var t = 0;
	while (el) {
		t += el.offsetTop;
		el = el.offsetParent;
		if (el.tagName == "BODY" || el.tagName == "HTML") break;
	}
	return t;
}

String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}

function eServicesWindow (url) 
{
	if (url == "http://www.chatham-kent.ca/cityIndex/cityIndex.aspx") {
		// Popup window
		window.open(url,'ckdirectory','width=750,height=420,scrollbars=yes,resizable=yes');
	} else if (url == "http://gismapex.chatham-kent.ca/Chatham-KentWeb/WebPages/Map/FundyViewer.aspx") {
		// Popup window
		window.open(url,'maps','width=840,height=570,resizable=yes,scrollbars=yes,status=yes');
	} else if (url == "") {
		// No value passed
		return false;
	} else {
		if (url.search("www\.chatham-kent\.ca") == -1) {
			// New window
			 window.open(url,'_blank');
		} else {
			// Same window
			window.open(url,'_top');
		}
	}
}
