function goLogin() {
	if (document.form1.txtUsername.value == "admin" || document.form1.txtUsername.value == "contributor") {
		//document.form1.action="login.aspx";
		document.form1.submit();
		return true;
	}
	else {
		alert("Valid logins are:\n1.) admin\n2.) contributor");
		return false;
	}
}

function checkTextLength(mainobj, num, toput)
{
	if (mainobj.value.length > num)
	{
		alert("You have just crossed the limit of  " + num + " characters.");
		mainobj.value = mainobj.value.substring(0,num);
		
	}
	toput.value = mainobj.value.length;
	
}

function clientSideJSValidator(source, arguments) {
	var pv = trim(arguments.Value);
	var dc = 0, cc = 0, tempChar=' ';
	if( pv.length>=6 ) {
		for( var i=0 ; i<pv.length ; i++ ) {
			tempChar = pv.charAt(i);
			if( (tempChar>='A' && tempChar<='Z') || (tempChar>='a' && tempChar<='z') )
				cc++;
			if( tempChar>='0' && tempChar<='9' )
				dc++;
		}
		/*if (cc<3 || dc<3)
			arguments.IsValid = false;
		else
			arguments.IsValid = true; */
	}
	else {
		arguments.IsValid = false;
	}
}
function showHide(divId) {
	var div_linkDisplay = document.getElementById("linkDisplay");
	var div_contentEditor = document.getElementById("contentEditor");
	if (divId == "linkDisplay") {
		div_linkDisplay.style.display='block';
		div_contentEditor.style.display='none';
	}
	else if (divId == "contentEditor") {
		div_linkDisplay.style.display='none';
		div_contentEditor.style.display='block';
	}
}

function AJ_Display(url, id) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id + 
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
	// change it to true: for asynchronous call
	//alert(url);
	if (url.indexOf("?") != -1) {
		url = url + "&date=" + new Date();
	}
	else {
		url = url + "?date=" + new Date();
	}
	
	//alert(url);
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function submitRSSFeed() {
	var rssLink = "";
	if (document.form2.txtSuggestLink.value == "RSS LINK???" || document.form2.txtSuggestLink.value == "") {
		document.form2.txtSuggestLink.value = "RSS LINK???";
		return false;
	}
	else
	{
		rssLink = document.form2.txtSuggestLink.value;
		AJ_Display("displayRssFeed.aspx?f=" + rssLink,"mainNewsSection");
		return true;
	}

}

function submitSuggestion() {
	var Sugg = "";
	var ip = "";
	var contID = "";
	if (document.form1.txtSuggestLink.value == "SUGGESTION???" || document.form1.txtSuggestLink.value == "") {
		document.form1.txtSuggestLink.value = "SUGGESTION??";
		return false;
	}
	else
	{
		Sugg = document.form1.txtSuggestLink.value;
		ip = document.form1.txtIP.value;
		contID = document.form1.txtContributorID.value;
		AJ_Display("displaySuggestion.aspx?f=" + Sugg +"&ip="+ip+"&contID="+contID,"divSuggestion");
		return true;
	}

}
function submitDisplayOrder() {
	var str = '';
	var e_form1 = document.form1;
	var elem = eelleemm.elements;
	for(var i = 0; i < elem.length; i++)
	{
		if (elem[i].type == "text" && elem[i].name.substring(0,5)== "order")
		{
			str=str+elem[i].name.substring(5,elem[i].name.length)+"="+elem[i].value+"|";
		}
	} 
	var e_hdnDisplayOrderList=e_form1.hdnDisplayOrderList;
	e_hdnDisplayOrderList.value = str;
	if (document.form1.hdnDisplayOrderList.value == "") {
		return false;
	}
	else
	{
		AJ_Display("displayOrderMassSave.aspx?f=" + document.form1.hdnDisplayOrderList.value ,"divDisplayOrder");
		
		e_form1.reload;
		return true;
	}
}

function submitDisplayLinkOrder() {
	var str = '';
	var e_form1 = document.form1;
	var elem = e_form1.elements;
	for(var i = 0; i < elem.length; i++)
	{
		if (elem[i].type == "text" && elem[i].name.substring(0,5)== "order")
		{
			str=str+elem[i].name.substring(5,elem[i].name.length)+"="+elem[i].value+"|";
		}
	} 
	var e_hdnDisplayOrderList = e_form1.hdnDisplayOrderList;
	e_hdnDisplayOrderList.value = str;
	if (document.form1.hdnDisplayOrderList.value == "") {
		return false;
	}
	else
	{
		AJ_Display("displayOrderMassSaveLink.aspx?f=" + document.form1.hdnDisplayOrderList.value ,"divDisplayOrder");
		e_form1.reload;
		return true;
	}
}

function submitRssFinally(urlRss, topic) {
	AJ_Display("submitRssFeed.aspx?f=" + urlRss + "&s=" + topic,"mainNewsSection");
}
function displayRssSection(url, id) {
	AJ_Display(url, id)
}

function displayHomeSection(url, id) {
	AJ_Display(url, id)
}
function showHideForRSS() {
	var e_chkRSS = document.form1.chkRSS;
	var e_FeedType;
	for (var i=0; i < document.form1.rdFeedType.length; i++)
	{
		if (document.form1.rdFeedType[i].checked)
		{
			e_FeedType = document.form1.rdFeedType[i].value;
		}
	}
	var e_RssSection = document.getElementById("RssSection");
	var e_RssSection2 = document.getElementById("RssSection2");
	var e_RssSection3 = document.getElementById("RssSection3");
	var e_NormalSection = document.getElementById("NormalSection");
	var e_txtIsRSS = document.getElementById("txtIsRSS");
	if (e_chkRSS.checked == true) {
		e_RssSection.style.display='block';
		e_RssSection2.style.display='block';
		e_RssSection3.style.display='block';
		e_NormalSection.style.display='none';
		e_txtIsRSS.value=e_FeedType;
		checkTextLength(document.form1.txtRSSLink, 1000, document.form1.Remaining);
	}
	else{
		e_RssSection.style.display='none';
		e_RssSection2.style.display='none';
		e_RssSection3.style.display='none';
		e_NormalSection.style.display='block';
		e_txtIsRSS.value="0";
		checkTextLength(document.form1.Description, 1000, document.form1.Remaining);
	}
}