function CreateXMLHttp()
{
	try
	{
		// Firefox, Opera 8.0+, Safari
		return new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				return new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return null;
			}
		}
	}
}


function linkDetailVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.link_url.value=="")
	{
		themessage = themessage + " - Full URL\n\r";
	}
	if (document.myform.link_description.value=="")
	{
		themessage = themessage + " - Description\n\r";
	}
	if (!isInteger(document.myform.link_orderby.value))
	{
		themessage = themessage + " - Order must be an integer\n\r";
	}
	if (document.myform.link_url.value.match("<") == '<'
		|| document.myform.link_description.value.match("<") == '<'
		|| document.myform.link_text.value.match("<") == '<'
		|| document.myform.link_orderby.value.match("<") == '<')
	{
		themessage = themessage + " - No HTML allowed, please\n\r";
	}

	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function bioVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.columnist_first.value=="")
	{
		themessage = themessage + " - First Name\n\r";
	}
	if (document.myform.columnist_password.value=="")
	{
		themessage = themessage + " - Password\n\r";
	}

	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function commentVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.comment_content.value=="")
	{
		themessage = themessage + " - Comment\n\r";
	}
	if (document.myform.comment_content.value.match("<") == '<')
	{
		themessage = themessage + " - No hyperlinks allowed, please\n\r";
	}
	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function askVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.qtext.value=="")
	{
		themessage = themessage + " - Question\n\r";
	}
	if (document.myform.qtext.value.match("<") == '<')
	{
		themessage = themessage + " - No hyperlinks allowed, please\n\r";
	}
	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function contactVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.comments.value=="")
	{
		themessage = themessage + " - Comments\n\r";
	}
	if (document.myform.email_address.value==""
		|| document.myform.email_address.value.indexOf("@") < 0
		|| document.myform.email_address.value.indexOf(".") < 0)
	{
		themessage = themessage + " - Email Address\n\r";
	}
	if (document.myform.first_name.value=="")
	{
		themessage = themessage + " - First Name\n\r";
	}
	if (document.myform.last_name.value=="")
	{
		themessage = themessage + " - Last Name\n\r";
	}
	if (document.myform.comments.value.match("<") == '<'
		|| document.myform.email_address.value.match("<") == '<'
		|| document.myform.first_name.value.match("<") == '<'
		|| document.myform.last_name.value.match("<") == '<')
	{
		themessage = themessage + " - No hyperlinks allowed, please\n\r";
	}
	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function applyVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.email_address.value==""
		|| document.myform.email_address.value.indexOf("@") < 0
		|| document.myform.email_address.value.indexOf(".") < 0)
	{
		themessage = themessage + " - Email Address\n\r";
	}
	if (document.myform.first_name.value=="")
	{
		themessage = themessage + " - First Name\n\r";
	}
	if (document.myform.last_name.value=="")
	{
		themessage = themessage + " - Last Name\n\r";
	}
	if (document.myform.columnist_worldview.value=="")
	{
		themessage = themessage + " - Religion or Worldview\n\r";
	}
	if (document.myform.columnist_subview.value=="")
	{
		themessage = themessage + " - Sect, Denomination or Tradition\n\r";
	}
	if (document.myform.comments.value=="")
	{
		themessage = themessage + " - Qualifications\n\r";
	}
	if (document.myform.qtext.value=="")
	{
		themessage = themessage + " - Question\n\r";
	}
	if (document.myform.answer_text.value=="")
	{
		themessage = themessage + " - Answer\n\r";
	}
	if (document.myform.comments.value.match("<") == '<'
		|| document.myform.email_address.value.match("<") == '<'
		|| document.myform.first_name.value.match("<") == '<'
		|| document.myform.last_name.value.match("<") == '<'
		|| document.myform.answer_text.value.match("<") == '<')
	{
		themessage = themessage + " - No hyperlinks allowed, please\n\r";
	}
	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function updateVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.last_name.value=="")
	{
		themessage = themessage + " - Last Name\n\r";
	}
	if (document.myform.first_name.value=="")
	{
		themessage = themessage + " - First Name\n\r";
	}
	if (document.myform.email_address.value==""
		|| document.myform.email_address.value.indexOf("@") < 0
		|| document.myform.email_address.value.indexOf(".") < 0)
	{
		themessage = themessage + " - Email Address\n\r";
	}
	if (document.myform.email_address.value.match("<") == '<'
		|| document.myform.first_name.value.match("<") == '<'
		|| document.myform.last_name.value.match("<") == '<')
	{
		themessage = themessage + " - No hyperlinks allowed, please\n\r";
	}

	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function answerVerification()
{
	var themessage = "You are required to complete the following fields:\n\r";
	if (document.myform.answer_text.value=="")
	{
		themessage = themessage + " - Your Answer\n\r";
	}

	if (themessage == "You are required to complete the following fields:\n\r")
	{
		document.myform.submit();
	}
	else
	{
		alert(themessage);
		return false;
	}
}


function openme(url)
{
	var isIE3=false;
	var aV=navigator.appVersion.charAt(0);
	if(aV>3 && navigator.appCodeName=='Mozilla')
	{
	}
	else if(aV==2)
	{
		isIE3=(-1<navigator.userAgent.toLowerCase().indexOf('msie'));
	}
	if( isIE3 )
	{
		alert('IE3 is not compatible with this Pop-Up');
		return;
	}
	var where=url;
	open(where,"SBWIN","toolbar=yes,directories=no,location=yes,status=no,menubar=yes,resizable=no,screenx=10,screeny=10,width=590,height=370,top=10,left=10,scrollbars=yes");
}


function isInteger(s)
{
	var i;

	if (isEmpty(s))
	if (isInteger.arguments.length == 1) return 0;
	else return (isInteger.arguments[1] == true);

	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}


function isEmpty(s)
{
	return ((s == null) || (s.length == 0))
}


function isDigit (c)
{
	return ((c >= "0") && (c <= "9"))
}


function ShowHideCommentForm()
{
	var a_show_comment_form = document.getElementById('a_show_comment_form');
	var a_hide_comment_form = document.getElementById('a_hide_comment_form');
	var div_comment_form = document.getElementById('div_comment_form');

	if (a_show_comment_form != null
		&& a_hide_comment_form != null
		&& div_comment_form != null)
	{
		if (div_comment_form.style.display == 'none')
		{
			a_show_comment_form.style.display = 'none';
			a_hide_comment_form.style.display = 'inline';
			div_comment_form.style.display = 'block';
		}
		else
		{
			a_show_comment_form.style.display = 'inline';
			a_hide_comment_form.style.display = 'none';
			div_comment_form.style.display = 'none';
		}
	}
}


function CheckCharacterCount(textControl, maxLength)
{
	var textBox = document.getElementById(textControl);
	if (textBox != null)
	{
		var theText = textBox.value;
		var charCount = theText.length;
		var warning = '';

		if (maxLength < charCount)
		{
			warning = 'You have exceeded the maximum number of characters.\nYou may only use ' + maxLength + ' characters.';
			while (maxLength < charCount)
			{
				theText = theText.substring(0, (theText.length - 1));
				charCount = theText.length;
			}
			textBox.value = theText;
		}

		if (warning != '')
		{
			alert(warning);
		}
	}
}

