		
	var strCEIContentDivPrefix = 'CEI';
	var strCEIContentHomeURL = '/';
	var strCEIContentViewURL = '/content/view/';
	var strCEIContentEditURL = '/content/edit/';

	var strCEIAdminContentDivPrefix = 'CEIAdmin';
	var strCEIAdminContentViewURL = '/admin/content/view/';
	var strCEIAdminContentEditURL = '/admin/content/edit/';

	function initCEI()
	{
		//manageCEI('MyCEI', 'LIST', '&blnMyCEI=True');
	}

	function manageCEI(strSection, strAction, strQueryString, intEntryID, customFunction)
	{
		strSection = (strSection) ? strSection : '';
		strQueryString = (strQueryString) ? strQueryString : '';
		intEntryID = (intEntryID) ? intEntryID : '';
		customFunction = (customFunction) ? customFunction : '';
		
		strQueryString = strQueryString + '&strSection=' + strSection;
		
		if (strAction == 'LOGIN')
		{
			if (strQueryString.indexOf('ERROR') == -1)
				document.location.href = '/admin/default.asp?' + strQueryString;
		}
		else if (strAction == 'VIEW')
			loadAJAXContent('div' + strCEIContentDivPrefix + strSection, strCEIContentViewURL + strSection + '.asp?strAction=' + strQueryString, customFunction);			
		else if (strAction == 'VIEW_RSS')
		{
			if (document.getElementById('div' + strCEIContentDivPrefix + strSection).innerHTML != 'Loading...')
				document.getElementById('div' + strCEIContentDivPrefix + strSection).innerHTML = 'Loading...';
			loadAJAXContent('div' + strCEIContentDivPrefix + strSection, strCEIContentViewURL + strSection + '.asp?strAction=' + strQueryString, customFunction);			
		}
	}
	
	function manageCEIAdmin(strSection, strAction, strQueryString, strItem, intItemID, customFunction)
	{
		strQueryString = (strQueryString) ? strQueryString : '';
		strItem = (strItem) ? strItem : '';
		intItemID = (intItemID) ? intItemID : '';
		customFunction = (customFunction) ? customFunction : '';

		if (strAction.indexOf('DELETE') != -1)
		{
			if (strSection == 'Event')
				executeAJAXPage(strCEIAdminContentEditURL + strSection.toLowerCase() + '.asp?strAction=' + strAction + ((strItem != '') ? '&' + strItem + '=' + intItemID : '') + ((strQueryString && strQueryString != '') ? strQueryString : ''), customFunction);					
			else
				executeAJAXPage(strCEIAdminContentEditURL + strSection.toLowerCase() + '.asp?strAction=' + strAction + ((strItem != '') ? '&' + strItem + '=' + intItemID : '') + ((strQueryString && strQueryString != '') ? strQueryString : ''), 'manageCEIAdmin(\'' + strSection + '\', \'VIEW\', \'' + strQueryString + '\', \'' + customFunction + '\');');					
		}
		else if (strAction.indexOf('EDIT') != -1)
			loadAJAXFloatingPage('', strCEIAdminContentEditURL + strSection.toLowerCase() + '.asp?strAction=' + strAction + '&strSection=' + strSection + ((strItem != '') ? '&' + strItem + '=' + intItemID : '') + ((strQueryString && strQueryString != '') ? strQueryString : ''), '#f3f3f3', this, false, 0, 0, customFunction);
		else if (strAction == 'VIEW')
			loadAJAXContent('div' + strCEIAdminContentDivPrefix + strSection, strCEIAdminContentViewURL + strSection.toLowerCase() + '.asp?strAction=' + strAction + ((strQueryString && strQueryString != '') ? strQueryString : ''), customFunction);
	}
	
	function getRadioValue(objForm, strField)
	{
		for (var i=0; i < objForm.elements[strField].length; i++)
		{
			if (objForm.elements[strField][i].checked)
				return objForm.elements[strField][i].value;
		}
		return -1;
	}

	function emailUnobsfuscate() 
	{	
		// find all links in HTML
		var link = document.getElementsByTagName && document.getElementsByTagName("a");
		var email, e;
		
		// examine all links
		for (e = 0; link && e < link.length; e++) {
		
			// does the link have use a class named "email"
			if ((" "+link[e].className+" ").indexOf("spam") >= 0) {
			
			// get the obfuscated email address
				email = link[e].firstChild.nodeValue.toLowerCase() || "";
				
				// transform into real email address
				email = email.replace(/\[y\]/ig, ".");
				email = email.replace(/\{x\}/ig, "@");
				email = email.replace(/\s/g, "");
				
				// is email valid?
				if (/^[^@]+@[a-z0-9]+([_\.\-]{0,1}[a-z0-9]+)*([\.]{1}[a-z0-9]+)+$/.test(email)) {
				
					// change into a real mailto link
					link[e].href = "mailto:" + email;
					link[e].firstChild.nodeValue = email;
			
				}
			}
		}
	}
	
	function navigateCalendar(intYear, intMonth)
	{
		var lstFilterCountryID;
		lstFilterCountryID = document.getElementById('lstFilterCountryID').value;
		manageCEI('Calendar', 'VIEW', '&y=' + intYear + '&m=' + intMonth + '&lstFilterCountryID=' + lstFilterCountryID);
		manageCEI('Events', 'VIEW', '&y=' + intYear + '&m=' + intMonth + '&lstFilterCountryID=' + lstFilterCountryID);		
	}

	function navigateCalendarAdmin(intYear, intMonth)
	{
		var lstFilterCountryID;
		lstFilterCountryID = document.getElementById('lstFilterCountryID').value;
		manageCEIAdmin('Calendar', 'VIEW', '&y=' + intYear + '&m=' + intMonth + '&lstFilterCountryID=' + lstFilterCountryID);
		manageCEIAdmin('Event', 'VIEW', '&y=' + intYear + '&m=' + intMonth + '&lstFilterCountryID=' + lstFilterCountryID);		
	}

	function navigateEvents(strSection, intYear, intMonth, rpp, p, strQueryString)
	{		
		manageCEI('Events', 'VIEW_EVENTS', '&y=' + intYear + '&m=' + intMonth + '&rpp=' + rpp + '&p=' + p + strQueryString);	
	}	
	
	function toggleEventOverview(blnShow, intEventID)
	{
		lnkEventShow = document.getElementById('lnkEventShow' + intEventID);
		lnkEventHide = document.getElementById('lnkEventHide' + intEventID);
		tblEvent = document.getElementById('tblEvent' + intEventID);
		
		lnkEventShow.style.display = (blnShow) ? 'none' : 'block';
		tblEvent.style.display = (blnShow) ? 'block' : 'none';	
		
		//objEventsNavTop.style.visibility = (objEventsDiv.scrollTop > 0) ? 'visible' : 'hidden';
		//objEventsNavBottom.style.visibility = (objEventsDiv.scrollTop <= objEventsDiv.scrollHeight - 310) ? 'visible' : 'hidden';
	}

	function toggleEventOverviewAll(blnShow)
	{
		var blnShowAll = false;
		var lnkEventShowAll;
		//return;
		lnkEventShowAll = document.getElementById('lnkEventShowAll');
		blnShowAll = (lnkEventShowAll.innerHTML == 'expand all') ? true : false;
		
		lnkEventShowAll.innerHTML = (blnShowAll) ? 'hide all' : 'expand all';
	
		var links = document.getElementsByTagName("a");	
		for (l = 0; l < links.length; l++) 
		{
			if (links[l].name[0] == 'E')
				toggleEventOverview(blnShowAll, links[l].name.substring(1, links[l].name.length));				
		}
		
		
		//objEventsNavTop.style.visibility = (objEventsDiv.scrollTop > 0) ? 'visible' : 'hidden';
		//objEventsNavBottom.style.visibility = (objEventsDiv.scrollTop <= objEventsDiv.scrollHeight - 310) ? 'visible' : 'hidden';
	}


	function toggleLinkOverview(blnShow, intLinkID)
	{
		tblLinkSummary = document.getElementById('tblLinkSummary' + intLinkID);
		tblLinkDetail = document.getElementById('tblLinkDetail' + intLinkID);
		
		tblLinkSummary.style.display = (blnShow) ? 'none' : 'block';
		tblLinkDetail.style.display = (blnShow) ? 'block' : 'none';	
	}

	function toggleLinkOverviewAll(blnShow)
	{
		var blnShowAll = false;
		var lnkLinkShowAll;
		//return;
		lnkLinkShowAll = document.getElementById('lnkLinkShowAll');
		blnShowAll = (lnkLinkShowAll.innerHTML == 'expand all') ? true : false;
		
		lnkLinkShowAll.innerHTML = (blnShowAll) ? 'hide all' : 'expand all';
	
		var links = document.getElementsByTagName("a");	
		for (l = 0; l < links.length; l++) 
		{
			if (links[l].name[0] == 'L')
				toggleLinkOverview(blnShowAll, links[l].name.substring(1, links[l].name.length));				
		}
	}



	var timer_id;
	var intEventsPositionX = 0;
	var intEventsPositionY = 0;
	var intScrollPositionX = 0;
	var intScrollPositionY = 0;
	
	function scrollEvents(strDiv, inc, dir) 
	{
		if (timer_id) clearTimeout(timer_id);
		objEventsDiv = document.getElementById(strDiv);
		objEventsNavTop = document.getElementById('divEventsNavTop');
		objEventsNavBottom = document.getElementById('divEventsNavBottom');

		if (objEventsDiv) 
		{
			intScrollPositionX = intScrollPositionX + inc;
			if (intScrollPositionX < 0)
				intScrollPositionX = 0;
			if (intScrollPositionX > 1000)
				intScrollPositionX = 1000;

			if (dir == "v") 
			  objEventsDiv.scrollTop = objEventsDiv.scrollTop + inc;
				
			objEventsNavTop.style.visibility = (objEventsDiv.scrollTop > 0) ? 'visible' : 'hidden';
			objEventsNavBottom.style.visibility = (objEventsDiv.scrollTop <= objEventsDiv.scrollHeight - 310) ? 'visible' : 'hidden';
			
			timer_id = setTimeout("scrollEvents('" + strDiv + "'," + inc + ",'" + dir + "')", 40);
		}
	}
	
	function stopScroll() 
	{ 
		if (timer_id) 
			clearTimeout(timer_id); 
	}
	
	function updateEventsNav()
	{
		objEventsDiv = document.getElementById('divViewEvents');
		objEventsNavTop = document.getElementById('divEventsNavTop');
		objEventsNavBottom = document.getElementById('divEventsNavBottom');
		//objEventsNavTop.style.visibility = (objEventsDiv.scrollHeight > 300) ? 'visible' : 'hidden';
		objEventsNavBottom.style.visibility = (objEventsDiv.scrollHeight > 300) ? 'visible' : 'hidden';
	}
	
	function updateRSSFeedNav(intRSSSourceID)
	{
		var divs = document.getElementsByTagName("div");	
		for (i = 0; i < divs.length; i++) 
		{
			//alert(divs[i].id.substring(0, 4));
			if (divs[i].id.substring(0, 4) == 'rssS')
			{
				rssS = divs[i].id.substring(4, divs[i].id.length)
				divs[i].style.display = (rssS == intRSSSourceID) ? 'block' : 'none';				
			}
		}
	}
	
	var t;
	function loadAJAXSearch(strAJAXSearchURL, strAJAXSearchType, strAJAXSearchField, strAJAXSearchFilterQuery, customFunction)
	{
		clearTimeout(t);
		t = setTimeout("manageAJAXSearch('" + strAJAXSearchURL + "', '" + strAJAXSearchType + "', '" + strAJAXSearchField + "', '" + strAJAXSearchFilterQuery + "', '" + customFunction + "');",500)
	}	
					
	function manageAJAXSearch(strAJAXSearchURL, strAJAXSearchType, strAJAXSearchField, strAJAXSearchFilterQuery, customFunction)
	{		
		customFunction = (customFunction) ? customFunction : '';
	
		strAJAXSearchURL = '/cei/includes/ajaxsearch.asp'
		
		var strSearchString = document.getElementById('str' + strAJAXSearchField + 'Dummy').value;
		var objTargetList = document.getElementById('int' + strAJAXSearchField + 'IDDummy');
		if (strSearchString.length >= 1 && objTargetList)
		{		
			strSearchString = strSearchString.replace('\'', '\'\'');
			strSearchString = strSearchString.replace('&', '%26');
			strAJAXSearchFilterQuery = strAJAXSearchFilterQuery.replace('%SS%', strSearchString);
		
			objTargetList.options.length = 0;
			AjaxRequest.get(
				{
					'url':'' + strAJAXSearchURL + '?strAJAXSearchType=' + strAJAXSearchType + '&strAJAXSearchFilterQuery=' + strAJAXSearchFilterQuery
					,'onLoading':function() { }
					,'onSuccess':function(req) { populateAJAXSearch(req, strAJAXSearchField, customFunction); }
					,'onError':function(req) { showAJAXMessage(req); }
				}
			);	
		}
	}
	
	function populateAJAXSearch(objRequest, strAJAXSearchField, customFunction)
	{
		filterData = objRequest.responseText; //read response data 
		var objTargetList = document.getElementById('int' + strAJAXSearchField + 'IDDummy');
		var objTargetListClose = document.getElementById('imgClose' + strAJAXSearchField);
		if (!filterData)
		{
			document.getElementById('str' + strAJAXSearchField + 'Dummy').style.backgroundColor = '#ffcccc';
			return;
		}
		else
		{	
			document.getElementById('str' + strAJAXSearchField + 'Dummy').style.backgroundColor = '#ffffff';			
			objTargetList.disabled = false; 
		
			objTargetList.options.length = 0;
			var lstItems = filterData.split(String.fromCharCode(25)); 
			var intCount = 0;
			for(var i = 0; i < lstItems.length; i++)
			{
				var lstValues = lstItems[i].split(String.fromCharCode(26)); 
				objTargetList.options[i] = new Option(lstValues[1], lstValues[0]);
				if (i == 0)
					objTargetList.selectedIndex = i;
					
				intCount++;
			}
			
			if (intCount > 6)
				objTargetList.size = 6; 
			else if(intCount >= 1)
				objTargetList.size = intCount; 

			objTargetList.style.display = 'block';	
			objTargetListClose.style.display = 'inline';				
		}
		
		eval(customFunction);
	} 	
	
	function setAJAXSearch(strAJAXSearchType, strAJAXSearchField, customFunction)
	{
		customFunction = (customFunction) ? customFunction : '';
		
		var objSearchField = document.getElementById('str' + strAJAXSearchField + 'Dummy');
		var objTargetIDField = document.getElementById('int' + strAJAXSearchField + 'ID');
		var objTargetList = document.getElementById('int' + strAJAXSearchField + 'IDDummy');
		var objTargetListClose = document.getElementById('imgClose' + strAJAXSearchField);
		
		if (objSearchField.style.backgroundColor == '#ffcccc')
		{
			objTargetIDField.value = '';
			objTargetList.style.display = 'none';
			objTargetListClose.style.display = 'none';
		}
		else
		{
			objSearchField.style.color = '#000000'
			objSearchField.value = objTargetList.options[objTargetList.selectedIndex].text;
			objTargetIDField.value = objTargetList.options[objTargetList.selectedIndex].value;
			objTargetList.style.display = 'none';
			objTargetListClose.style.display = 'none';
			
			eval(customFunction);			
		}
	}
	
	function setNewAJAXSearch(strAJAXSearchField, strResponse)
	{
		var objSearchField = document.getElementById('str' + strAJAXSearchField + 'Dummy');
		var objTargetIDField = document.getElementById('int' + strAJAXSearchField + 'ID');
		var objTargetList = document.getElementById('int' + strAJAXSearchField + 'IDDummy');
		var objTargetListClose = document.getElementById('imgClose' + strAJAXSearchField);
		
		intNewID = getQueryStringValue(strResponse, 'intNewID');
		strNewText = getQueryStringValue(strResponse, 'strNewText');
		
		objSearchField.value = strNewText;
		objTargetIDField.value = intNewID;
		objSearchField.style.color = '#000000'
		objTargetList.style.display = 'none';
		objTargetListClose.style.display = 'none';
	}
	
	function clearAJAXSearch(strAJAXSearchField)
	{
		var objSearchField = document.getElementById('str' + strAJAXSearchField + 'Dummy');
		var objTargetIDField = document.getElementById('int' + strAJAXSearchField + 'ID');
		var objTargetList = document.getElementById('int' + strAJAXSearchField + 'IDDummy');
		var objTargetListClose = document.getElementById('imgClose' + strAJAXSearchField);
		objSearchField.value = '';
		objTargetIDField.value = '';		
		objTargetListClose.style.display = 'none';
		//objTargetList.style.display = 'none';
	}
	
	function hideAJAXSearch(strAJAXSearchField)
	{
		var objTargetList = document.getElementById('int' + strAJAXSearchField + 'IDDummy');
		var objTargetListClose = document.getElementById('imgClose' + strAJAXSearchField);
		objTargetList.style.display = 'none';
		objTargetListClose.style.display = 'none';
	}	
	
	function clearFieldHelp(objField, strHelp)
	{
		if (objField.value == strHelp) { objField.value = ''; objField.style.color = '#000000'; }
	}
	
	function setFieldHelp(objField, strHelp)
	{
		if (objField.value == '') { objField.value = strHelp; objField.style.color = '#999999'; }
	}	