var homeOff = new Image(68, 22)
var homeOn = new Image(68, 22)
homeOff.src = "images/home-off.gif"
homeOn.src = "images/home-on.gif"

var newsletterOff = new Image(99, 22)
var newsletterOn = new Image(99, 22)
newsletterOff.src = "images/newsletter-off.gif"
newsletterOn.src = "images/newsletter-on.gif"

var websiteOff = new Image(85, 22)
var websiteOn = new Image(85, 22)
websiteOff.src = "images/website-off.gif"
websiteOn.src = "images/website-on.gif"

var patientOff = new Image(140, 22)
var patientOn = new Image(140, 22)
patientOff.src = "images/patient-off.gif"
patientOn.src = "images/patient-on.gif"

var optionsOff = new Image(75, 22)
var optionsOn = new Image(75, 22)
optionsOff.src = "images/options-off.gif"
optionsOn.src = "images/options-on.gif"

var helpOff = new Image(49, 22)
var helpOn = new Image(49, 22)
helpOff.src = "images/support-off.gif"
helpOn.src = "images/support-on.gif"

window.onbeforeunload = confirmExit;

function confirmExit()
{
	if (needToConfirm)
		return strConfirmMessage;
}

function check_newsletter_add_edit(objForm){
	if(objForm.Title.value == "") {
		alert("Please enter a title for this newsletter.");
		objForm.Title.focus();
		return false;
	}
}

function check_mockup_add_edit(objForm){
	if(objForm.Title.value == "") {
		alert("Please enter a title for this ready-to-publish.");
		objForm.Title.focus();
		return false;
	}
}

function confirm_delete_newsletters_asp(intNewsletterID){
	if(confirm("Are you sure you wish to delete this newsletter?\n\n If you click \"OK\", this newsletter will not be retrieveable."))
	{
		window.location = "newsletter_add_edit.asp?newsID=" + intNewsletterID + "&process=deleteall"
	}
}

function confirm_delete_mockups_asp(intMockupID){
	if(confirm("Are you sure you wish to delete this ready-to-publish?\n\n If you click \"OK\", this ready-to-publish will not be retrieveable."))
	{
		window.location = "readymade_add_edit.asp?mockupID=" + intMockupID + "&process=deleteall"
	}
}

function confirm_delete_notice_asp(intNoteID){
	if(confirm("Are you sure you wish to delete this notice?\n\n If you click \"OK\", this notice will not be retrieveable."))
	{
		window.location = "notes_add_edit.asp?noteID=" + intNoteID + "&process=delete"
	}
}

function confirm_delete_pub_notice_asp(intPubNotice){
	if(confirm("Are you sure you wish to delete this notification?\n\n If you click \"OK\", this notification will not be retrieveable."))
	{
		window.location = "newsletter_publish_schedule.asp?PubNoticeID=" + intPubNotice + "&process=delete"
	}
}

function checkPWForm(objForm)
{
	if(objForm.currpass.value == "")
	{
		alert("Please enter your current password.");
		objForm.currpass.focus();
		return false;
	}
	if(objForm.newpass1.value == "")
	{
		alert("Please enter a new password.");
		objForm.newpass1.focus();
		return false;
	}
	if(objForm.newpass1.value != objForm.newpass2.value)
	{
		alert("Passwords do not match.");
		objForm.newpass1.value = "";
		objForm.newpass2.value = "";
		objForm.newpass1.focus();
		return false;
	}
	return true;
}

function exitNoChanges()
{
	needToConfirm = false;
	if(confirm("Are you sure you wish to exit without saving any changes?\n\nIf you click \"OK\", any changes you may have made without\nclicking \"Save your changes\" will be lost."))
	{
		location.href= '/list-newsletters.asp';
	}
}

function exitNoChangesTemplate()
{
	needToConfirm = false;
	if(confirm("Are you sure you wish to exit without saving any changes?\n\nIf you click \"OK\", any changes you may have made without\nclicking \"Save your changes\" will be lost."))
	{
		location.href= '/templates.asp';
	}
}

function logOut()
{
	if(confirm("Are you sure you wish to log out and end your session? \n\n If you click \"OK\", you will need to log in again to access the site."))
	{
		window.location = '/logout.asp';
	}
}

function checkBlastForm(objForm)
{
	if(objForm.SendDate.value == "")
	{
		alert("You must enter a date.");
		objForm.SendDate.focus();
		return false;
	}
	if(objForm.newsletter.value == "")
	{
		alert("You must select a newsletter for this blast.");
		objForm.newsletter.focus();
		return false;
	}
	checkSent();
	return false;
}

function checkBlastNoteForm(objForm)
{
	if(objForm.SendDate.value == "")
	{
		alert("You must enter a date.");
		objForm.SendDate.focus();
		return false;
	}
	if(objForm.newsletter.value == "")
	{
		alert("You must select a newsletter for this blast.");
		objForm.newsletter.focus();
		return false;
	}
}

function unPublishNewsletter(intNewsletterID)
{
	if(confirm("Are you sure you wish to remove this newsletter from availability?\n\n If you click \"OK\", this newsletter will no longer be visible to or editable by anyone but you."))
	{
		window.location = "newsletter_unpublish.asp?newsletterID=" + intNewsletterID;
	}
}

function publishNewsletter(intNewsletterID)
{
	if(confirm("Publishing this newsletter will make it available to all users?\n\n You can delay publication by scheduling notification."))
	{
		window.location = "newsletter_publish.asp?newsletterID=" + intNewsletterID;
	}
}


function publishNotify(intNewsletterID, blnPub) {

	if(blnPub != '' && blnPub != null){
		strPubMsg = "Notification was already sent on " + blnPub
		strPubMsg = strPubMsg + "\nAre you sure you wish to resend?"
		if(confirm(strPubMsg)){
			if(confirm("Are you certain?")) {
				document.sendNotice.action = "readymade_publish_notice.asp?newsID=" + intNewsletterID;
				document.sendNotice.newsID.value = intNewsletterID
				document.sendNotice.submit();
//				window.location = "readymade_publish_notice.asp?newsID=" + intNewsletterID;
			}
		}
	} else {
	
		strPubMsg = "Are you sure you wish to send notification to all users?"
		if(confirm(strPubMsg)){
			if(confirm("Are you certain????")) {
				document.sendNotice.action = "readymade_publish_notice.asp?newsID=" + intNewsletterID;
				document.sendNotice.newsID.value = intNewsletterID
				document.sendNotice.submit();
//				window.location = "readymade_publish_notice.asp?newsID=" + intNewsletterID;
			}
		}
	}
}

function publishSchedule(intNewsletterID){
	x = document.getElementById('DP').value
	strURL = "newsletter_publish_schedule.asp?mockupid=" + intNewsletterID + "&scheduleDate=" + x
	window.location = strURL
}


function previewNewsletter(intNewsLetterID) {
	var NewWin = window.open('newsletter_preview.asp?ID=' + intNewsLetterID, '_blank', 'scrollbars,status=yes,width=650,height=400,left=50,top=50, resizable');
	NewWin.focus();
}

function previewNewsletterNE(intNewsLetterID) {
	var NewWin = window.open('newsletter_preview_ne.asp?ID=' + intNewsLetterID, '_blank', 'scrollbars,status=yes,width=650,height=400,left=50,top=50, resizable');
	NewWin.focus();
}

function previewMockup(intNewsLetterID) {
	var NewWin = window.open('readymade_preview.asp?ID=' + intNewsLetterID, '_blank', 'scrollbars,status=yes,width=650,height=400,left=50,top=50, resizable');
	NewWin.focus();
}

function previewMockupNE(intNewsLetterID) {
	var NewWin = window.open('readymade_preview_ne.asp?ID=' + intNewsLetterID, '_blank', 'scrollbars,status=yes,width=650,height=400,left=50,top=50, resizable');
	NewWin.focus();
}

function previewNotice(intNoteID) {
	var NewWin = window.open('notes_preview.asp?ID=' + intNoteID, '_blank', 'scrollbars,status=yes,width=650,height=400,left=50,top=50, resizable');
	NewWin.focus();
}


function deleteNewsletter(intNewsletterID)
{
	if(confirm("Are you sure you wish to delete this newsletter?\n\n If you click \"OK\", this newsletter will not be retrieveable."))
	{
		window.location = "/delete-newsletter.asp?newsletterID=" + intNewsletterID;
	}
}

function deleteTemplate(intNewsletterID)
{
	if(confirm("Are you sure you wish to delete this newsletter template?\n\n If you click \"OK\", this template will not be retrieveable."))
	{
		window.location = "/delete-template.asp?newsletterID=" + intNewsletterID;
	}
}

function deleteBlast(intBlastID)
{
	if(confirm("Are you sure you wish to delete this blast?\n\n If you click \"OK\", this blast will not be sent."))
	{
		window.location = "blast_schedule.asp?action=delete&blastID=" + intBlastID;
	}
}

function deleteNoticeBlast(intBlastID)
{
	if(confirm("Are you sure you wish to delete this notice blast?\n\n If you click \"OK\", this blast will not be sent."))
	{
		window.location = "notes_blast_schedule.asp?action=delete&blastID=" + intBlastID;
	}
}

function deletePatient(intContactID, intListID)
{
	if(confirm("Are you sure you wish to delete this patient?\n\n If you click \"OK\", this patient will not be retrieveable."))
	{
		window.location = "database_delete_contact.asp?listID=" + intListID + "&contactID=" + intContactID;
	}
}

function optoutPatient(intContactID)
{
	if(confirm("Are you sure you wish to add this patient to the opt-out list?\n\n If you click \"OK\", this patient will not receive emails from you."))
	{
		window.location = "database_add_optout_contact.asp?contactID=" + intContactID;
	}
}

function sendToPatient(intContactID)
{
	window.location = "database_send_to_user.asp?contactID=" + intContactID;
}

function noteToPatient(intContactID)
{
	window.location = "database_note_to_user.asp?contactID=" + intContactID;
}

function deleteOptOut(intContactID)
{
	if(confirm("Are you sure you wish to delete this optout?\n\n If you click \"OK\", this patient will be able to receive emails from you again."))
	{
		window.location = "database_delete_optout_contact.asp?optoutID=" + intContactID;
	}
}

function deleteBounce(intContactID)
{
	if(confirm("Are you sure you want to mark this address as active?\n\n If you click \"OK\", the system will again attempt to send e-mails to this patient."))
	{
		window.location = "database_delete_bounce_contact.asp?bounceID=" + intContactID;
	}
}

function confirmDBDelete()
{
	if(confirm("Are you sure you wish to delete your patient database?\n\n If you click \"OK\", your patient database (all patient information) will not be retrieveable."))
	{
		window.location = "/database_delete.asp?action=delete";
	}
}

function hideAll()
{
	document.getElementById("menu1").style.visibility = "hidden";
	document.getElementById("menu2").style.visibility = "hidden";
//	document.getElementById("menu3").style.visibility = "hidden";
	document.getElementById("menu4").style.visibility = "hidden";
	document.getElementById("menu5").style.visibility = "hidden";
	document.getElementById("menu6").style.visibility = "hidden";
	
	document.home.src = homeOff.src;
	document.newsletter.src = newsletterOff.src;
	document.website.src = websiteOff.src;
	document.patient.src = patientOff.src;
	document.options.src = optionsOff.src;
	document.help.src = helpOff.src;
}

function doHomeOn()
{
	hideAll();
	document.home.src = homeOn.src;
	var imgTarget = document.images["home"];
	document.getElementById("menu1").style.top =  getTop(imgTarget) + 22 + "px";
	document.getElementById("menu1").style.left = getLeft(imgTarget) + 12 + "px";
	document.getElementById("menu1").style.visibility = "visible";
	return true;
}

function doNewsletterOn()
{
	hideAll();
	document.newsletter.src = newsletterOn.src;
	var imgTarget = document.images["newsletter"];
	document.getElementById("menu2").style.top =  getTop(imgTarget) + 22 + "px";
	document.getElementById("menu2").style.left = getLeft(imgTarget) + 12 + "px";
	document.getElementById("menu2").style.visibility = "visible";
	return true;
}

function doNewsletterOnFF()
{
	hideAll();
	document.newsletter.src = newsletterOn.src;
	var imgTarget = document.images["newsletter"];
	document.getElementById("menu2").style.top =  getTop(imgTarget) + 22 + "px";
	document.getElementById("menu2").style.left = getLeft(imgTarget) + 12 + "px";
	document.getElementById("menu2").style.visibility = "visible";
	return true;
}

function doWebsiteOn()
{
	hideAll();
	document.website.src = websiteOn.src;
//	var imgTarget = document.images["website"];
//	document.getElementById("menu3").style.top =  getTop(imgTarget) + 22 + "px";
//	document.getElementById("menu3").style.left = getLeft(imgTarget) + 12 + "px";
//	document.getElementById("menu3").style.visibility = "visible";
	return true;
}

function doPatientOn()
{
	hideAll();
	document.patient.src = patientOn.src;
	var imgTarget = document.images["patient"];
	document.getElementById("menu4").style.top =  getTop(imgTarget) + 22 + "px";
	document.getElementById("menu4").style.left = getLeft(imgTarget) + 12 + "px";
	document.getElementById("menu4").style.visibility = "visible";
	return true;
}

function doOptionsOn()
{
	hideAll();
	document.options.src = optionsOn.src;
	var imgTarget = document.images["options"];
	document.getElementById("menu5").style.top =  getTop(imgTarget) + 22 + "px";
	document.getElementById("menu5").style.left = getLeft(imgTarget) - 4 + "px";
	document.getElementById("menu5").style.visibility = "visible";
	return true;
}

function doHelpOn()
{
	hideAll();
	document.help.src = helpOn.src;
	var imgTarget = document.images["help"];
	document.getElementById("menu6").style.top =  getTop(imgTarget) + 22 + "px";
	document.getElementById("menu6").style.left = getLeft(imgTarget) - 141 + "px";
	document.getElementById("menu6").style.visibility = "visible";
	return true;
}

function Right(str, n)
{
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
	{
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}

function getLeft(imgElem)
{
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null)
	{
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

function getTop(imgElem)
{
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null)
	{
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}

function ShowProgress(objForm, strBarRef)
{
	strAppVersion = navigator.appVersion;
	if(objForm.File1.value == "")
	{
		alert("Please select the list file to be uploaded.");
		return false;
	}
	else
	{

		if(objForm.delete_existing.checked == true) {
			if (confirm("Are you certain you wish to delete your entire database before import?")) {
			} else {
				return false
			}
		}
		if(strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
		{
			winstyle = "dialogWidth=375px; dialogHeight:130px; center:yes";
			window.showModelessDialog(strBarRef + '&b=IE',null,winstyle);
		}
		else
		{
			window.open(strBarRef + '&b=NN','','width=370,height=115', true);
		}
		return true;
	}
}

function ShowProgressDocs(objForm, strBarRef) {

	strAppVersion = navigator.appVersion;
	
	if(objForm.newsTitle.value == ""){
		alert("Please enter a section name.");
		return false;
	}
	
//	if(objForm.newsFile.value == "" && objForm.bonusFile.value == "" && objForm.webFile.value == ""){
//		alert("Please select files to be uploaded.");
//		return false;
//	}

//	if(objForm.newsFile.value == "" || objForm.bonusFile.value == "" || objForm.webFile.value == ""){

	if(objForm.newsFile.value == "" || objForm.bonusFile.value == ""){

		alert("Please enter all files for upload.");
		return false;

//		if(confirm("Not all files entered.  Are you certain you wish to continue?") == false){
//			return false
//		}
	}
	
	if(strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4) {
		winstyle = "dialogWidth=375px; dialogHeight:130px; center:yes";
		window.showModelessDialog(strBarRef + '&b=IE',null,winstyle);
	} else {
		window.open(strBarRef + '&b=NN','','width=370,height=115', true);
	}
}

function checkBoxDataQ()
{
	if(document.forms.MyForm.text_q.checked == true)
	{
		document.forms.MyForm.text_q.checked = false;
	}
	else
	{
		document.forms.MyForm.text_q.checked = true ;  
	}
}

function checkBoxFieldNames()
{
	if(document.forms.MyForm.FieldNames.checked == true)
	{
		document.forms.MyForm.FieldNames.checked = false;
	}
	else
	{
		document.forms.MyForm.FieldNames.checked = true; 
	}
}