var activeimg = "";
var timevar;
function mouseOver(img)
{
	if (activeimg != "")
		mouseOut2();
	activeimg = img;
	getElem(img).src = "images/" + img + "-on3.gif";
	if (timevar != null)
		clearTimeout(timevar);
}
function mouseOut(img)
{
	activeimg = img;
	timevar = setTimeout("mouseOut2()",200);
}
function mouseOut2(img)
{
	getElem(img).src = "images/" + img + ".gif";
	activeimg = "";
}
function mouseOut2()
{
	getElem(activeimg).src = "images/" + activeimg + ".gif";
	activeimg = "";
}
function showEditAnnounce()
{
	getStyleOf("pnlAnnouncements").display = 'none';
	getStyleOf("pnlEditAnnouncements").display = 'none';
	getStyleOf("txtAnnouncements").display = '';
	getStyleOf("btnAnnouncements").display = '';
}
function showEditDeadlines()
{
	getStyleOf("pnlDeadlines").display = 'none';
	getStyleOf("pnlEditDeadlines").display = 'none';
	getStyleOf("txtDeadlines").display = '';
	getStyleOf("btnDeadlines").display = '';
}
function showEditAssignments()
{
	getStyleOf("pnlAssignments").display = 'none';
	getStyleOf("pnlEditAssignments").display = 'none';
	getStyleOf("txtAssignments").display = '';
	getStyleOf("btnAssignments").display = '';
}
function showHomeLinks()
{
	if (getElem("hidType").value == "editor" || getElem("hidType").value == "senior editor")
	{
		getStyleOf("liED").display = '';
		getStyleOf("liTI").display = '';
		getStyleOf("liR").display = '';
		getStyleOf("liU").display = '';
		getStyleOf("liMP").display = '';
		getStyleOf("liNL").display = '';
		getStyleOf("liOTN").display = '';
	}
	else
	{
		getStyleOf("liAB").display = '';
		getStyleOf("liPA").display = '';
		getStyleOf("liTI").display = '';
		getStyleOf("liMP").display = '';
		getStyleOf("liEC").display = '';
		getStyleOf("liEO").display = '';
		getStyleOf("liWA").display = '';
		getStyleOf("liWA2").display = '';
		getStyleOf("liPR").display = '';
		getStyleOf("liPR2").display = '';
	}
}
function showDdlType()
{
	if (getElem("hidType").value == "editor" || getElem("hidType").value == "senior editor")
		getStyleOf("trType").display = '';
	if (getElem("hidType").value == "editor" || getElem("hidType").value == "senior editor")
		getStyleOf("trTitle").display = '';
}
function checkForAnonWriter()
{
	if (getElem("hidUserID").value == "189")
	{
		alert("Please create a user account.");
		window.location = "user.aspx?userID=0";
	}
}

function verifyDelUser()
{
	return confirm("Are you sure you want to permanently delete this user?\n\nEach article keeps track of information (such as its author and who it is assigned to) that is dependent upon specific users. Therefore, you will not be allowed to delete an user who is attributed to any article - because this would mess up those articles.");
}
function verifyDelArticle()
{
	return confirm("Are you sure you want to permanently delete this article?");
}
function openeditWNAissuesWin()
{
	window.open('editWNAissues.aspx','editWNAissues','width=420,height=155,resizable=yes');
}
function openEditOTNissuesWin()
{
	window.open('editOTNissues.aspx','editOTNissues','width=420,height=155,resizable=yes');
}
function changeWasSubmittedToYes()
{
	getElem("hidWasSubmitted").value = "yes";
}


function statusChange()
{
	if (getElem("ddlStatus").value == "3")
		getStyleOf('trAssignedTo').display = '';
	else
		getStyleOf('trAssignedTo').display = 'none';
		
	if (getElem("ddlStatus").value == "5" || getElem("ddlStatus").value == "6")
	{
		getElem("radActiveYes").disabled = false;
		getElem("radActiveNo").disabled = false;
		getElem("radFeaturedYes").disabled = false;
		getElem("radFeaturedNo").disabled = false;
		if (getElem("hidIsActive").value == "yes")
		{
			if (getElem("radActiveYes").checked == false)
				getElem("radActiveYes").checked = true;
		}
		else
			getElem("radActiveNo").checked = true;
		if (getElem("hidIsFeatured").value == "yes")
		{
			if (getElem("radFeaturedYes").checked == false)
				getElem("radFeaturedYes").checked = true;
		}
		else
			getElem("radFeaturedNo").checked = true;
	}
	else
	{
		getElem("radActiveYes").disabled = true;
		getElem("radActiveNo").disabled = true;
		getElem("radActiveNo").checked = true;
		getElem("radFeaturedYes").disabled = true;
		getElem("radFeaturedNo").disabled = true;
		getElem("radFeaturedNo").checked = true;
	}
}

function init()
{
	statusChange();
	typeChange();

	if (getElem("hidArticleID").value == "0")
	{
		getStyleOf('trMaxWordCount').display = 'none';
		getStyleOf('trMeetingNotes').display = 'none';
		getStyleOf('trSpecialInstr').display = 'none';
		getStyleOf('trSources').display = 'none';
		getStyleOf('trOtherExpenses').display = 'none';
	}
		
	if (getElem("hidHasArt").value == "yes")
		getElem("radArtYes").checked = true;
	else
		getElem("radArtNo").checked = true;
	if (getElem("hidIsActive").value == "yes")
		getElem("radActiveYes").checked = true;
	else
		getElem("radActiveNo").checked = true;
	if (getElem("hidIsFeatured").value == "yes")
		getElem("radFeaturedYes").checked = true;
	else
		getElem("radFeaturedNo").checked = true;
}
		
function typeChange()
{
	// browsers are weird, so: set display to 'none' to hide, set display to '' to show
	articleType = parseInt(getElem("ddlArticleType").value);
		
	getStyleOf('trPriority').display = 'none';
	getStyleOf('trImage2spacer').display = '';
	getStyleOf('trImage2').display = '';
	getStyleOf('trImage3spacer').display = '';
	getStyleOf('trImage3').display = '';
	getStyleOf('divCaption1').display = '';
	getStyleOf('divCaption2').display = '';
	getElem('divImage1Text').innerHTML = "";
	getElem('divImage2Text').innerHTML = "";
	getElem('divImage3Text').innerHTML = "";
	getStyleOf('divURLs').display = '';
	getElem('divArticleContent').innerHTML = "Article Content";
	
	if (articleType == 1) // news item
	{
		getStyleOf('tblCountryProfile').display = 'none';
		getStyleOf('trSummary').display = '';
		getStyleOf('trBody').display = 'none';
		getStyleOf('trURL').display = 'none';
		getStyleOf('trImage').display = 'none';
		getElem('divArticleName').innerHTML = "Article Name:";
		getStyleOf('trSpotlight').display = '';
		getStyleOf('trMagIssue').display = '';
		getStyleOf('trSection').display = '';
		getStyleOf('trPage').display = '';
		getStyleOf('trNLissue').display = '';
		getElem('divWriter').innerHTML = "Writer:";
		getStyleOf('trStoryIdea').display = '';
		getStyleOf('trArt').display = '';
		getStyleOf('trSources').display = '';
		getStyleOf('trArtDesc').display = '';
		getStyleOf('trMeetingNotes').display = '';
		getStyleOf('trSpecialInstr').display = '';
		getStyleOf('trOTNissue').display = 'none';
		getStyleOf('trTemplate').display = '';
	}
	else if (articleType == 2 || articleType == 3) // news brief or news/feature story
	{
		getStyleOf('tblCountryProfile').display = 'none';
		getStyleOf('trSummary').display = '';
		getStyleOf('trBody').display = '';
		getStyleOf('trURL').display = 'none';
		getStyleOf('trImage').display = '';
		getElem('divArticleName').innerHTML = "Article Name:";
		getStyleOf('trSpotlight').display = '';
		getStyleOf('trMagIssue').display = '';
		getStyleOf('trSection').display = '';
		getStyleOf('trPage').display = '';
		getStyleOf('trNLissue').display = '';
		getElem('divWriter').innerHTML = "Writer:";
		getStyleOf('trStoryIdea').display = '';
		getStyleOf('trArt').display = '';
		getStyleOf('trSources').display = '';
		getStyleOf('trArtDesc').display = '';
		getStyleOf('trMeetingNotes').display = '';
		getStyleOf('trSpecialInstr').display = '';
		getStyleOf('trOTNissue').display = 'none';
		getStyleOf('trTemplate').display = '';
	}
	else if (articleType == 4) // new product item
	{
		getStyleOf('tblCountryProfile').display = 'none';
		getStyleOf('trSummary').display = '';
		getStyleOf('trBody').display = 'none';
		getStyleOf('trURL').display = '';
		getStyleOf('trImage').display = 'none';
		getElem('divArticleName').innerHTML = "Article Name:";
		getStyleOf('trSpotlight').display = '';
		getStyleOf('trMagIssue').display = '';
		getStyleOf('trSection').display = '';
		getStyleOf('trPage').display = '';
		getStyleOf('trNLissue').display = '';
		getElem('divWriter').innerHTML = "Writer:";
		getStyleOf('trStoryIdea').display = '';
		getStyleOf('trArt').display = '';
		getStyleOf('trSources').display = '';
		getStyleOf('trArtDesc').display = '';
		getStyleOf('trMeetingNotes').display = '';
		getStyleOf('trSpecialInstr').display = '';
		getStyleOf('trOTNissue').display = 'none';
		getStyleOf('trTemplate').display = '';
	}
	else if (articleType == 5) // new product brief
	{
		getStyleOf('tblCountryProfile').display = 'none';
		getStyleOf('trSummary').display = '';
		getStyleOf('trBody').display = '';
		getStyleOf('trURL').display = '';
		getStyleOf('trImage').display = '';
		getElem('divArticleName').innerHTML = "Article Name:";
		getStyleOf('trSpotlight').display = '';
		getStyleOf('trMagIssue').display = '';
		getStyleOf('trSection').display = '';
		getStyleOf('trPage').display = '';
		getStyleOf('trNLissue').display = '';
		getElem('divWriter').innerHTML = "Writer:";
		getStyleOf('trStoryIdea').display = '';
		getStyleOf('trArt').display = '';
		getStyleOf('trSources').display = '';
		getStyleOf('trArtDesc').display = '';
		getStyleOf('trMeetingNotes').display = '';
		getStyleOf('trSpecialInstr').display = '';
		getStyleOf('trOTNissue').display = 'none';
		getStyleOf('trTemplate').display = '';
	}
	else if (articleType == 6 || articleType == 7) // promo or promo next issue
	{
		getStyleOf('tblCountryProfile').display = 'none';
		getStyleOf('trSummary').display = '';
		getStyleOf('trBody').display = 'none';
		getStyleOf('trURL').display = 'none';
		getStyleOf('trImage').display = 'none';
		if (articleType == 7)
		{
			getStyleOf('trImage').display = '';
			getStyleOf('trImage2spacer').display = 'none';
			getStyleOf('trImage2').display = 'none';
			getStyleOf('trImage3spacer').display = 'none';
			getStyleOf('trImage3').display = 'none';
		}
		getElem('divArticleName').innerHTML = "Article Name:";
		getStyleOf('trSpotlight').display = '';
		getStyleOf('trMagIssue').display = '';
		getStyleOf('trSection').display = '';
		getStyleOf('trPage').display = '';
		getStyleOf('trNLissue').display = '';
		getElem('divWriter').innerHTML = "Writer:";
		getStyleOf('trStoryIdea').display = '';
		getStyleOf('trArt').display = '';
		getStyleOf('trSources').display = '';
		getStyleOf('trArtDesc').display = '';
		getStyleOf('trMeetingNotes').display = '';
		getStyleOf('trSpecialInstr').display = '';
		getStyleOf('trOTNissue').display = 'none';
		getStyleOf('trTemplate').display = 'none';
	}
	else if (articleType == 8) // country profile
	{
		getStyleOf('tblCountryProfile').display = '';
		getStyleOf('trSummary').display = '';
		getStyleOf('trBody').display = '';
		getStyleOf('trURL').display = 'none';
		getStyleOf('trImage').display = '';
		getElem('divArticleName').innerHTML = "Country Name:";
		getStyleOf('trSpotlight').display = 'none';
		getStyleOf('trMagIssue').display = 'none';
		getStyleOf('trSection').display = 'none';
		getStyleOf('trPage').display = 'none';
		getStyleOf('trNLissue').display = 'none';
		getElem('divWriter').innerHTML = "Researcher:";
		getStyleOf('trStoryIdea').display = 'none';
		getStyleOf('trArt').display = 'none';
		getStyleOf('trSources').display = 'none';
		getStyleOf('trArtDesc').display = 'none';
		getStyleOf('trMeetingNotes').display = 'none';
		getStyleOf('trSpecialInstr').display = 'none';
		getStyleOf('trOTNissue').display = 'none';
		getStyleOf('trTemplate').display = 'none';
	}
	else if (articleType == 9 || articleType == 10 || articleType == 11 || articleType == 12 || articleType == 13)
	{ // 9=OTN Column, 10=OTN Big Picture, 11=OTN Country Report, 12=OTN Category Detail, 13=OTN Company Profile

		getStyleOf('tblCountryProfile').display = 'none';
		if (articleType == 10)
			getStyleOf('trSummary').display = '';
		else
			getStyleOf('trSummary').display = 'none';
		getStyleOf('trBody').display = '';
		if (articleType == 11 || articleType == 13)
		{
			getStyleOf('trURL').display = '';
			getStyleOf('divURLs').display = 'none';
		}
		else
			getStyleOf('trURL').display = 'none';
		getStyleOf('trKeywords').display = 'none';
		if (articleType == 12)
			getStyleOf('trPriority').display = '';
		if (articleType == 9)
		{
			getStyleOf('trImage').display = 'none';
			getStyleOf('trImage2spacer').display = 'none';
			getStyleOf('trImage2').display = 'none';
		}
		else
		{
			getStyleOf('trImage').display = '';
			getStyleOf('trImage2spacer').display = '';
			getStyleOf('trImage2').display = '';
		}
		getStyleOf('trImage3spacer').display = 'none';
		getStyleOf('trImage3').display = 'none';
		if (articleType == 10)
		{
			getElem('divImage1Text').innerHTML = "670px width";
			getElem('divImage2Text').innerHTML = "424px width";
			getStyleOf('divCaption1').display = 'none';
			getStyleOf('divCaption2').display = 'none';
		}
		else if (articleType == 11 || articleType == 13)
		{
			getElem('divImage1Text').innerHTML = "~320px width";
			getElem('divImage2Text').innerHTML = "200px width";
			getStyleOf('divCaption1').display = 'none';
			getStyleOf('divCaption2').display = 'none';
		}
		else if (articleType == 12)
		{
			getElem('divImage1Text').innerHTML = "670px width";
			getElem('divImage2Text').innerHTML = "~250px width";
			getStyleOf('divCaption1').display = 'none';
			getStyleOf('divCaption2').display = 'none';
		}
		
		if (articleType == 13)
			getElem('divArticleName').innerHTML = "Company Name:";
		else if (articleType == 11)
			getElem('divArticleName').innerHTML = "Country Name:";
		else
			getElem('divArticleName').innerHTML = "Article Name:";
		getStyleOf('trSpotlight').display = 'none';
		getStyleOf('trMagIssue').display = 'none';
		getStyleOf('trSection').display = 'none';
		getStyleOf('trPage').display = 'none';
		getStyleOf('trNLissue').display = 'none';
		if (articleType == 13)
			getElem('divWriter').innerHTML = "Researcher:";
		else
			getElem('divWriter').innerHTML = "Writer:";
		getStyleOf('trStoryIdea').display = 'none';
		getStyleOf('trArt').display = 'none';
		getStyleOf('trSources').display = 'none';
		getStyleOf('trArtDesc').display = 'none';
		getStyleOf('trMeetingNotes').display = 'none';
		getStyleOf('trSpecialInstr').display = 'none';
		getStyleOf('trOTNissue').display = '';
		getStyleOf('trTemplate').display = 'none';
	}
	else (alert("Error: Invalid Article Type."));
	
	if (articleType == 13)
		getElem('divArticleContent').innerHTML = "Organic Briefing";
	if (getElem("ddlArticleType").value == "8")
		getElem("divHeading").innerHTML = "Country Profile";
	else if (getElem("hidArticleID").value == "0")
		getElem("divHeading").innerHTML = "Releases";
	else
		getElem("divHeading").innerHTML = "Edit Article";
	
	// template either used or not used, so need to adjust accordingly
	templateChange();
	
}

var isW3C = (document.getElementById) ? true : false;
var isAll = (document.all) ? true : false;

function getStyleOf(elemID)
{
	var styleOf = (isW3C) ? document.getElementById(elemID).style : ((isAll) ? document.all[elemID].style : null);
	return styleOf;
}

function getElem(elemID)
{
	return document.all[elemID];
}
function calendarPicker(strField)
{
	window.open('DatePicker.aspx?field=' + strField,'calendarPopup','width=250,height=160,resizable=yes');
}

function templateChange()
{
	articleType = parseInt(getElem("ddlArticleType").value);
	
	if (articleType == 1 || articleType == 2 || articleType == 3 || articleType == 4 || articleType == 5)
	{ // template used
		if (getElem("radTemplate1").checked == true)
		{
			getStyleOf('divCaption1').display = '';
			getStyleOf('trImage3').display = '';
			getStyleOf('trImage3spacer').display = '';
			getElem('divImage1Text').innerHTML = "260px width";
			getElem('divImage2Text').innerHTML = "260px width";
			getElem('divImage3Text').innerHTML = "260px width";
		}
		else if (getElem("radTemplate2").checked == true)
		{
			getStyleOf('divCaption1').display = 'none';
			getStyleOf('trImage3').display = 'none';
			getStyleOf('trImage3spacer').display = 'none';
			getElem('divImage1Text').innerHTML = "520px width";
			getElem('divImage2Text').innerHTML = "320px width";
			getElem('divImage3Text').innerHTML = "";
		}
	}
}

function verifyPitch()
{
	aName = getElem("txtArticleName").value;
	pitch = getElem("txtPitch").value;
	phone = getElem("txtMainPhone").value;
	email = getElem("txtEmail").value;
	errormsg = "";
	if (aName == "")
		errormsg += "You must enter an 'Article Name'.";
	if (pitch == "")
		errormsg += "\nYou must enter a 'Story Idea'.";
	if (phone == "" || phone.length < 7)
		errormsg += "\nPlease enter your phone number where it says 'Main Phone #'.";
	if (email == "")
		errormsg += "\nPlease enter your e-mail address where it says 'E-mail'.";

	if (errormsg != "")
	{
		alert(errormsg);
		return false;
	}
	return true;
}
function verifyArticleName(action)
{
	articleName = getElem("txtArticleName").value;
	if (articleName == "")
	{
		if (!action)
			alert("You must enter a 'Article Name'.");
		return false;
	}
	return true;
}
function verifyMagPage(action)
{
	if (getElem("txtMagPage").value == "")
		return true;
	try
	{
		intMagPage = parseInt(getElem("txtMagPage").value);
		if (getElem("txtMagPage").value.length > (intMagPage+"").length)
			throw new Exception();
	}
	catch(er)
	{
		if (!action)
			alert("'Magazine Page' must be an integer.");
		return false;
	}

	if (intMagPage > 0)
		return true;
	if (!action)
		alert("'Magazine Page' must be a positive integer.");
	return false;
}
function verifyPriority(action)
{
	if (getElem("txtPriority").value == "")
		return true;
	try
	{
		intPriority = parseInt(getElem("txtPriority").value);
		if (getElem("txtPriority").value.length > (intPriority+"").length)
			throw new Exception();
	}
	catch(er)
	{
		if (!action)
			alert("'OTN Priority' must be an integer.");
		return false;
	}

	if (intPriority > 0)
		return true;
	if (!action)
		alert("'Magazine Page' must be a positive integer.");
	return false;
}
function verifyWordCountMax(action)
{
	if (getElem("txtWordCountMax").value == "")
		return true;
	try
	{
		intWordCountMax = parseInt(getElem("txtWordCountMax").value);
		if (getElem("txtWordCountMax").value.length > (intWordCountMax+"").length)
			throw new Exception();
	}
	catch(er)
	{
		if (!action)
			alert("'Maximum Word Count' must be an integer.");
		return false;
	}
	
	if (intWordCountMax > 0)
		return true;
	if (!action)
		alert("'Maximum Word Count' must be a positive integer.");
	return false;
}
function verifyPopulation(action)
{
	if (getElem("txtPopulation").value == "")
		return true;
	try
	{
		intPopulation = parseInt(getElem("txtPopulation").value);
		if (getElem("txtPopulation").value.length > (intPopulation+"").length)
			throw new Exception();
	}
	catch(er)
	{
		if (!action)
			alert("'Population' must be an integer.");
		return false;
	}
	
	if (intPopulation > 0)
		return true;
	if (!action)
		alert("'Population' must be a positive integer.");
	return false;
}
function verifySize(action)
{
	if (getElem("txtSize").value == "")
		return true;
	try
	{
		intSize = parseInt(getElem("txtSize").value);
		if (getElem("txtSize").value.length > (intSize+"").length)
			throw new Exception();
	}
	catch(er)
	{
		if (!action)
			alert("'Size' must be an integer.");
		return false;
	}
	
	if (intSize > 0)
		return true;
	if (!action)
		alert("'Size' must be a positive integer.");
	return false;
}
function verifyFields(action)
{
	validArticleName = true;
	validMagPage = true;
	validWordCountMax = true;
	validHeadline = true;
	validHighlight = true;
	validKeywords = true;
	validImageCaption = true;
	validPopulation = true;
	validSize = true;
	validBody = true;
	validFees = true;
	returnValue = true;
	errorstr = "";
	if (!verifyArticleName(action))
	{
		returnValue = false;
		validArticleName = false;
		errorstr += "You must enter an 'Article Name'.";
	}
	if (!verifyMagPage(action))
	{
		returnValue = false;
		validMagPage = false;
		errorstr += "\n'Magazine Page' must be a positive integer.";
	}
	if (!verifyWordCountMax(action))
	{
		returnValue = false;
		validWordCountMax = false;
		errorstr += "\n'Maximum Word Count' must be a positive integer.";
	}
	if (getElem("txtFee").value != "" && getElem("txtFlatFee").value != "")
	{
		returnValue = false;
		validFees = false;
		errorstr += "\nYou cannot enter a value for both 'Fee' and 'Flat Fee'.";
	}
	if (!verifyPopulation(action))
	{
		returnValue = false;
		validPopulation = false;
		errorstr += "\n'Population' must be a positive integer.";
	}
	if (!verifySize(action))
	{
		returnValue = false;
		validSize = false;
		errorstr += "\n'Size' must be a positive integer.";
	}
	
	if (getElem("txtBody").value.indexOf("<p>") != -1 || getElem("txtBody").value.indexOf("</p>") != -1)
	{
		returnValue = false;
		errorstr += "\nPlease do not enter '<p>' or '</p>' within the 'Edited Story'.";
		validBody = false;
	}
	
	// make sure no html except in edited story
	if (getElem("txtHeadline").value.indexOf("<") != -1)
	{
		returnValue = false;
		errorstr += "\n'Headline' cannot contain HTML tags.";
		validHeadline = false;
	}
	if (getElem("txtHighlight").value.indexOf("<") != -1)
	{
		returnValue = false;
		errorstr += "\n'Summary' cannot contain HTML tags.";
		validHighlight = false;
	}
	if (getElem("txtURL").value.indexOf("<") != -1)
	{
		returnValue = false;
		errorstr += "\n'URL' cannot contain HTML tags.";
		validURL = false;
	}
	if (getElem("txtKeywords").value.indexOf("<") != -1)
	{
		returnValue = false;
		errorstr += "\n'Keywords' cannot contain HTML tags.";
		validKeywords = false;
	}
	if (getElem("txtImage1Caption").value.indexOf("<") != -1)
	{
		errorstr += "\nHTML is only allowed in the 'Edited Story' section";
		returnValue = false;
		validImageCaption = false;
	}
	
	
	if (!returnValue)
		alert(errorstr);
	if (!validArticleName) { getElem("txtArticleName").focus(); getElem("txtArticleName").select(); }
	else if (!validMagPage) { getElem("txtMagPage").focus(); getElem("txtMagPage").select(); }
	else if (!validWordCountMax) { getElem("txtWordCountMax").focus(); getElem("txtWordCountMax").select(); }
	else if (!validPopulation) { getElem("txtPopulation").focus(); getElem("txtPopulation").select(); }
	else if (!validSize) { getElem("txtSize").focus(); getElem("txtSize").select(); }
	else if (!validHeadline) { getElem("txtHeadline").focus(); getElem("txtHeadline").select(); }
	else if (!validBody) { getElem("txtBody").focus(); getElem("txtBody").select(); }
	else if (!validHighlight) { getElem("txtHighlight").focus(); getElem("txtHighlight").select(); }
	else if (!validKeywords) { getElem("txtKeywords").focus(); getElem("txtKeywords").select(); }
	else if (!validImageCaption) { getElem("txtImageCaption").focus(); getElem("txtImageCaption").select(); }

	return returnValue;
}

function verifyUserForm()
{
	errormsg = "";
	if (getElem("txtUsername").value == "")
		errormsg += "You must enter a username.";
	if (getElem("txtPassword").value != "" && getElem("txtPassword").value.length < 4)
		errormsg += "\nYour password must be at least 4 characters long.";
	else if (getElem("txtPassword").value != getElem("txtPassword2").value)
		errormsg += "\nYou must enter the same thing for 'Password' and 'Confirm Password'.";
	if (getElem("txtMainPhone").value == "" || getElem("txtMainPhone").value.length < 7)
		errormsg += "\nPlease enter your phone number where it says 'Main Phone #'.";
	if (getElem("txtEmail").value == "")
		errormsg += "\nPlease enter your e-mail address where it says 'E-mail'.";
		
	if (errormsg == "")
		return true;
	else
	{
		alert(errormsg);
		return false;
	}
		
}

function noenter() //add this to every textbox so it doesn't submit form when user press enter (ie)
{ return !(window.event && window.event.keyCode == 13); }

var agt=navigator.userAgent.toLowerCase();
var is_konq = false;
var kqPos = agt.indexOf('konqueror');
if (kqPos !=-1)
       is_konq = true;
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var is_khtml  = (is_safari || is_konq)
var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;

var isFirefox = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                 (is_gecko) && (navigator.vendor=="Firefox"));
                 
function btnSearchOnClick()
{
	getElem("hidPage").value = "1";
}
function storeWNAIssue()
{
	getElem("hidWNAIssue").value = getElem("ddlWNAIssue").options[getElem("ddlWNAIssue").selectedIndex].value;
}
function storeOTNIssue()
{
	getElem("hidOTNIssue").value = getElem("ddlOTNIssue").options[getElem("ddlOTNIssue").selectedIndex].value;
}
function lbuPageNavOnClick(page)
{
	// if someone clicks on a page number (triggering lbuPageNavOnCommand), we don't want to
	// keep any changes to the search form since the last populategrid().
	// we would then want to go to the page specified of the CURRENT grid's data.
	// so, only use the use the form's data if the user clicks search.
	getElem("hidPage").value = page;
	getElem("ddlResPerPage").options[getElem("ddlResPerPage").selectedIndex].value = getElem("hidResPerPage").value;
	getElem("ddlMagIssue").options[getElem("ddlMagIssue").selectedIndex].value = getElem("hidMagIssue").value;
	getElem("txtArticleName").value = getElem("hidArticleName").value;
	getElem("ddlArticleType").options[getElem("ddlArticleType").selectedIndex].value = getElem("hidArticleType").value;
	getElem("txtMagSection").value = getElem("hidMagSection").value;
	getElem("ddlAuthor").options[getElem("ddlAuthor").selectedIndex].value = getElem("hidAuthorID").value;
	getElem("ddlStatus").options[getElem("ddlStatus").selectedIndex].value = getElem("hidStatus").value;
	getElem("ddlNLIssue").options[getElem("ddlNLIssue").selectedIndex].value = getElem("hidNLIssue").value;
	getElem("ddlSortResBy").options[getElem("ddlSortResBy").selectedIndex].value = getElem("hidSortResBy").value;
	getElem("ddlAscDesc").options[getElem("ddlAscDesc").selectedIndex].value = getElem("hidAscDesc").value;
}

function email(emails)
{
	window.open("sendemail.aspx?e=" + emails,"emailWin","toolbar=0,location=0,directories=0,menubar=0,status=1,width=490,height=480,left=500,screenX=500,top=400,screenY=400");
	return false;
}
