// *********************************************************************
// Browser Detection
// *********************************************************************
	
	if(document.getElementById) { // IE 5 and up, NS 6 and up
		var upLevel = true;
		}
	else if(document.layers) { // Netscape 4
		var ns4 = true;
		document.getElementById = function() { return null; }
		}
	else if(document.all) { // IE 4
		var ie4 = true;
		document.getElementById = function() { return null; }
		}
		
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);
	var is_safari = (agt.indexOf("safari") != -1);
	var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1)
	&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1)
	&& (agt.indexOf('webtv') == -1) && (agt.indexOf('hotjava') == -1)
	&& (!is_safari) );
	var is_nav2 = (is_nav && (is_major == 2));
	var is_nav3 = (is_nav && (is_major == 3));
	var is_nav4 = (is_nav && (is_major == 4)); 
	var is_nav4up = (is_nav && (is_major >= 4));
	var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||
	(agt.indexOf("; nav") != -1)) );
	var is_nav6 = (is_nav && (is_major == 5));
	var is_nav6up = (is_nav && (is_major >= 5));
	var is_gecko = (agt.indexOf('gecko') != -1);
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)
	&& (!is_safari) );
	var is_ie3 = (is_ie && (is_major < 4));
	var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4") != -1) );
	var is_ie4up = (is_ie && (is_major >= 4));
	var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0") != -1) );
	var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") != -1));
	var is_ie5up = (is_ie && !is_ie3 && !is_ie4);
	var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
	var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.") != -1) );
	var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
	var is_opera = (agt.indexOf("opera") != -1);
	var is_mac = (agt.indexOf("mac") != -1);
	var is_iemac = (is_ie && is_mac);
	
	function FirefoxTwoCompatibility(){
		// If the browser is Firefox get the version number
		var ffv = 0;
		var ffn = "Firefox/"
		var ffp = navigator.userAgent.indexOf(ffn);
		if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));
		// If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG
		if (ffv >= 1.5) {
			Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }
		}
	}

// *********************************************************************
// Macromedia Functions
// *********************************************************************
	
	// Restores original image on roll out.
	function MM_swapImgRestore() {
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	// Preloads rollover images.
	function MM_preloadImages() {
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	// Finds an object on the page.
	function MM_findObj(n, d) {
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	// Swaps an image with its rollover.
	function MM_swapImage() {
		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	// Formats the page whenever it is reloaded.
	function MM_reloadPage(init) {
		if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
		else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);
	
// *********************************************************************
// Page Element Manipulating Functions
// *********************************************************************

	// Gets a page element
	function getObject(ID) {
		if(upLevel) {
			var obj = document.getElementById(ID);
			}
		else if(obj) {
			var obj = eval('document.' + ID);
			}
		else if(obj) {
			var obj = eval('document.all.' + ID);
			}
		return obj
	}	

	// Hides a page element
	function hideObject(ID) {
		var obj = getObject(ID);
		if(obj!=null)
		{	
			if (ns4) {
				obj.visibility = "hide";
			}
			if (ie4 || upLevel) {
				obj.style.visibility = "hidden";
			}
		}

	}	
	
	// Shows a hidden page element
	function showObject(ID) {
		var obj = getObject(ID);
		if(obj!=null)
		{		
			if (ns4) {
				obj.visibility = "show";
			}
			if (ie4 || upLevel) {
				obj.style.visibility = "visible";
			}	
		}
	}
	// Removes a page element
	function removeObject(ID) {
		var obj = getObject(ID);	
		if(obj!=null)
		{				
			if (ns4) {
				obj.display = "none";
			}
			if (ie4 || upLevel) {
				obj.style.display = "none";
			}
		}
	}
	
	// Restores a page element
	function restoreObject(ID) {
		var obj = getObject(ID);	
		if(obj!=null)
		{				
			if (ns4) {
				obj.display = "block";
			}
			if (ie4 || upLevel) {
				obj.style.display = "block";
			}
		}
	}
	
	// Toggles the hiding and display of the div in ID
	function toggleDivDisplay(ID)
	{	
		var div = getObject(ID);
		if(div != null)
		{
			if (ns4) {
				if(div.display == 'none')
					restoreObject(div.id);
				else
					removeObject(div.id);
			}
			if (ie4 || upLevel) {
				if(div.style.display == 'none')
					restoreObject(div.id);
				else
					removeObject(div.id);
			}
		}
	}
	
	// Selects an item from the list
	function selectFromList(list,value)
	{
		list = getObject(list);
		
		for (i=0; i < list.length; i++) {
			list.options[i].selected = false;
		} 
		for (i=0; i < list.length; i++) {
			if(list.options[i].value==value) {
				list.options[i].selected = true;
				return;
			}
		} 	
	}

	// Empties a page element that contains a list.
	function emptyList(ID)
	{
		var list = getObject(ID);
		for (x = list.length; x >= 0; x = x - 1) {
			list[x] = null;
		}
	}	
	
	// Fills a page element with text/value data.
	function fillListItems(ID, listItems)
	{
		var list = getObject(ID);

		// Clear the options currently in the list
		emptyList(ID);
		
		// Load the items into the list	
		for(var k=0; k < listItems.length; k++)
		{
			var item = listItems[k];
			list[k] = new Option(leftTrim(item.Text),item.Value);
		}		
	} 
	
	function insertListItem(ID, index, text, value)
	{
		var list = getObject(ID);
		var listItem = new Option(text,value);
		var existingItem = list.options[index];  
		try {
			list.add(listItem, existingItem); // standards compliant; doesn't work in IE
		}
		catch(ex) {
			list.add(listItem, index); // IE only
		}
	}
	
	function removeListItem(ID, index)
	{
		// Get the list to update
		var list = getObject(ID);
		if(index<list.options.length-1) list.remove(index);
	}
	
	
	function leftTrim(sString) 
	{
		if(sString)
		{
			while (sString.substring(0,1) == ' ')
			{
				sString = sString.substring(1, sString.length);
			}
		}
		return sString;
	}
	
	function addOnloadEvent(fnc)
	{
		if ( typeof window.addEventListener != "undefined" )
			window.addEventListener( "load", fnc, false );
		else if ( typeof window.attachEvent != "undefined" ) 
		{
			window.attachEvent( "onload", fnc );
		}
		else {
			if ( window.onload != null ) 
			{
				var oldOnload = window.onload;
				window.onload = function ( e ) 
					{
						oldOnload( e );
						window[fnc]();
					};
			}
			else 
				window.onload = fnc;
		}
	}

		
	// Fires the submit when the enter key is pressed.
	function enterSubmit(control, validate) {
		
		var tmp;
		var agt = navigator.userAgent.toLowerCase();
		var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1)) ? 1 : 0;
		if (is_safari == 1){
			tmp = window.event.keyCode;			
		}
		else
		{
			if (window.navigator.appName == "Microsoft Internet Explorer"){
				tmp = window.event.keyCode;
			}
			else if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1){
				tmp = arguments.callee.caller.arguments[0].which;
		
			}
			else if (window.navigator.appName.toLowerCase().indexOf("mozilla") > -1){
				tmp = e.keyCode;
			}
		}
		if (( tmp == 13 ) || ((window.event) && (window.event.keyCode == 13))) 
		{
			if (validate == 'True') 
			{
				if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate())
				{
					__doPostBack(control,'');
				}
			} 
			else 
			{
				__doPostBack(control,'');
			}
			return true;
		} 
		else 
		{
			return false;
		}
	}
	
	function clickIt(control, validate)
	{
		if (validate == 'True') 
		{
			if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate())
			{
				__doPostBack(control,'');
			}
		} 
		else 
		{
			__doPostBack(control,'');
		}
		return true;	
	}
	
// *********************************************************************
// Email Functions
// *********************************************************************
	
	var isEmailPaneOpen = 0;

	function togglePane(divEmailAMessageBoxID, textAreaID) 
	{
		if(isEmailPaneOpen == 0) 
		{	
			restoreObject(divEmailAMessageBoxID);
			isEmailPaneOpen = 1;

			try{
				getObject(textAreaID).focus();}
			catch(ex){}
		}
		else
		{
			isEmailPaneOpen = 0;
			removeObject(divEmailAMessageBoxID);  
		}
	}

	function SendEmail(portalID, toUserID, divEmailAMessageBoxID, textAreaID, divEmailSendError, divExplicitLangError, divLenError)
	{
		var subject = 'A YourHub member has sent you this message.';
		var message = getObject(textAreaID).value;
		var messageLength = message.length;
	
		var hasNoCurseWords = AjaxAPI.HasNoCurseWords(message);
		if(messageLength <= 1000 && messageLength > 0 && hasNoCurseWords.value == 1)
		{
			var response = AjaxAPI.SendEmail(portalID,toUserID, subject, message);
			if(response.value == true)
			{
				message.value = '';
				removeObject(divEmailAMessageBoxID);
			}
			else
				restoreObject(divEmailSendError);
		}
		else
		{
			if(hasNoCurseWords.value == 0)
				restoreObject(divExplicitLangError);
			if(messageLength > 1000)
				restoreObject(divLenError);
		}	
	}
	
// *********************************************************************
// Pop-up Window Functions
// *********************************************************************
	
	// Creates a new popup page of specified dimentions.
	function popupPage(pageURL,width,height){
		var windowFeatures = "plain,scrollbars,resizable=no,height=" + height + ",width=" + width + "";
		popWin = window.open(pageURL,"winPopup", windowFeatures);
		popWin.focus();
	}

// *********************************************************************
// Regular Expression Functions
// *********************************************************************
	
	// Removes special characters and leading numbers from an element	
	function removeSpecialChars(txtTempBox){
		txtTempBox.value = txtTempBox.value.replace(/([^0-9a-zA-Z])/g,"");
		txtTempBox.value = txtTempBox.value.replace(/^[0-9]*/, "");
	}
	
	// Returns a string with special characters and leading numbers removed
	function returnSpecialCharlessString(txtTempBox){
		var tempStr = txtTempBox.value;
		tempStr = tempStr.replace(/([^0-9a-zA-Z])/g,"");
		tempStr += tempStr.replace(/^[0-9]*/, "");
		return tempStr;
	}
	
// *********************************************************************
// General AJAX Functions that call the API
// *********************************************************************
function getAbstract(contentID, lblAbstract)
{
	if(contentID > 0)
	{
		var response = AjaxAPI.GetAbstract(contentID, 200);
		if (response.error != null)
			lblAbstract.innerHTML = response.error;
		else 
			lblAbstract.innerHTML = response.value;
	}
	else
		lblAbstract.innerHTML = "There is no featured content for this slide.";		
}