// Copyright © 2001 by Vision Marketing
// All Rights Reserved. No unauthorized use of this code, in any part, without the express written consent of Vision Marketing will result in serious legal repercussions.
// Protected by copyright laws. 2001.

function openAdmin() {
	document.frmAdminPage.submit();
}

function confirm_delete(MSG) {
	return confirm("\Are you sure you want to DELETE this " + MSG + "?\n");
}

function writeBrowserInfo() {
    var browser;
	var browserversion;
	
    if (is_nav2 || is_nav3 || is_nav4 || is_nav6) browser = "NN";
	if (is_ie3 || is_ie4 || is_ie5 || is_ie5_5) browser = "IE";

    if (is_ie3) browserversion = 3;
	if (is_ie4) browserversion = 4;
	if (is_ie5) browserversion = 5;
	if (is_ie5_5) browserversion = 5.5;

    if (is_nav2) browserversion = 3;
    if (is_nav3) browserversion = 3;
	if (is_nav4) browserversion = 4;
	if (is_nav6) browserversion = 5;

	document.write("<input type='hidden' name='Browser' value='" + browser + "'>");
	document.write("<input type='hidden' name='BrowserVer' value='" + browserversion + "'>");
}

function imageBrowserLaunch(id) {
	open("/admin/image_browser.cfm?ImageID="+id, "Image_Browser", "width=790, height=590, resizable=yes, directory=yes, menubar=yes, location=yes, toolbar=no, status=yes, scrollbars=yes");
}

// ORIGINAL
//function imageBrowserLaunch(id) {
//	open("/admin/image_browser.cfm?ImageID="+id, "Image_Browser", "width=790, height=590, resizable=yes, directory=yes, menubar=yes, location=yes, toolbar=no, status=yes, scrollbars=yes");
//}

function PDFBrowserLaunch(id) {
	open("/admin/pdf_browser.cfm?PDFID="+id, "PDF_Browser", "width=790, height=590, resizable=yes, directory=yes, menubar=yes, location=yes, toolbar=yes, status=yes, scrollbars=yes");
}

function changeContent() {
	window.close();
}

function submitContent() {
	window.close();
	opener.frmContent.bttnSubmit.click();
}

function previewPage() {
	document.frmContent.action = "/admin/page_preview" + document.frmContent.TemplateID.value + ".cfm";
	document.frmContent.target = "_blank";
	return true;		
}

function previewPageTeaser1() {
	document.frmContent.action = "/admin/headlines_preview.cfm?Headline=1";
	document.frmContent.target = "_blank";
	return true;		
}

function previewPageTeaser2() {
	document.frmContent.action = "/admin/headlines_preview.cfm?Headline=2";
	document.frmContent.target = "_blank";
	return true;		
}

function submitPage() {
	document.frmContent.action = "/admin/page_modifydb.cfm";
	document.frmContent.target = "";
	return true;		
}

function addLink() {
	var ContentID
	for (var i=0; i< document.frmContent.ContentID.length; i++) {
		if (document.frmContent.ContentID[i].checked) {
			ContentID = document.frmContent.ContentID[i].value
		}
	}
	if (ContentID == 1) {
		for (var i=0; i< document.frmContent.links.length; i++) {
			if (document.frmContent.links.options[i].selected) {
				document.frmContent.TextArea1.value = document.frmContent.TextArea1.value + '<A HREF="' + document.frmContent.links.options[i].value + '">' + document.frmContent.links.options[i].text + '</A>';
			}
		}
	}
	else if (ContentID == 2) {
		for (var i=0; i< document.frmContent.links.length; i++) {
			if (document.frmContent.links.options[i].selected) {
				document.frmContent.TextArea2.value = document.frmContent.TextArea2.value + '<A HREF="' + document.frmContent.links.options[i].value + '">' + document.frmContent.links.options[i].text + '</A>';
			}
		}
	}
	else if (ContentID == 3) {
		for (var i=0; i< document.frmContent.links.length; i++) {
			if (document.frmContent.links.options[i].selected) {
				document.frmContent.Content1.value = document.frmContent.Content1.value + '<A HREF="' + document.frmContent.links.options[i].value + '">' + document.frmContent.links.options[i].text + '</A>';
			}
		}
	}
	else if (ContentID == 4) {
		for (var i=0; i< document.frmContent.links.length; i++) {
			if (document.frmContent.links.options[i].selected) {
				document.frmContent.Content2.value = document.frmContent.Content2.value + '<A HREF="' + document.frmContent.links.options[i].value + '">' + document.frmContent.links.options[i].text + '</A>';
			}
		}
	}
}

function addEmail() {
	var ContentID
	for (var i=0; i< document.frmContent.ContentID.length; i++) {
		if (document.frmContent.ContentID[i].checked) {
			ContentID = document.frmContent.ContentID[i].value
		}
	}
	if (ContentID == 1) {
		document.frmContent.TextArea1.value = document.frmContent.TextArea1.value + '<A HREF="mailto:' + document.frmContent.Email.value + '">' + document.frmContent.Email.value + '</A>';	
		document.frmContent.Email.value = "";
	}
	else if (ContentID == 2) {
		document.frmContent.TextArea2.value = document.frmContent.TextArea2.value + '<A HREF="mailto:' + document.frmContent.Email.value + '">' + document.frmContent.Email.value + '</A>';	
		document.frmContent.Email.value = "";
	}
	else if (ContentID == 3) {
		document.frmContent.Content1.value = document.frmContent.Content1.value + '<A HREF="mailto:' + document.frmContent.Email.value + '">' + document.frmContent.Email.value + '</A>';	
		document.frmContent.Email.value = "";
	}
	else if (ContentID == 4) {
		document.frmContent.Content2.value = document.frmContent.Content2.value + '<A HREF="mailto:' + document.frmContent.Email.value + '">' + document.frmContent.Email.value + '</A>';	
		document.frmContent.Email.value = "";
	}
}


function addBullet() {
	var ContentID
	for (var i=0; i< document.frmContent.ContentID.length; i++) {
		if (document.frmContent.ContentID[i].checked) {
			ContentID = document.frmContent.ContentID[i].value
		}
	}
	if (ContentID == 1) {
		document.frmContent.TextArea1.value = document.frmContent.TextArea1.value + '<LI>' + document.frmContent.Bullet.value + '</LI>';	
		document.frmContent.Bullet.value = "";
	}
	else if (ContentID == 2) {
		document.frmContent.TextArea2.value = document.frmContent.TextArea2.value + '<LI>' + document.frmContent.Bullet.value + '</LI>';	
		document.frmContent.Bullet.value = "";
	}
	else if (ContentID == 3) {
		document.frmContent.Content1.value = document.frmContent.Content1.value + '<LI>' + document.frmContent.Bullet.value + '</LI>';	
		document.frmContent.Bullet.value = "";
	}
	else if (ContentID == 4) {
		document.frmContent.Content2.value = document.frmContent.Content2.value + '<LI>' + document.frmContent.Bullet.value + '</LI>';	
		document.frmContent.Bullet.value = "";
	}
}

function addPDF() {
	var ContentID
	for (var i=0; i< document.frmContent.ContentID.length; i++) {
		if (document.frmContent.ContentID[i].checked) {
			ContentID = document.frmContent.ContentID[i].value
		}
	}
	if (ContentID == 1) {
		for (var i=0; i< document.frmContent.pdfs.length; i++) {
			if (document.frmContent.pdfs.options[i].selected) {
				document.frmContent.TextArea1.value = document.frmContent.TextArea1.value + "<A HREF=javascript:openPDF('" + document.frmContent.pdfs.options[i].text + "');>" + document.frmContent.pdfs.options[i].text + "</A>";
			}
		}
	}
	else if (ContentID == 2) {
		for (var i=0; i< document.frmContent.pdfs.length; i++) {
			if (document.frmContent.pdfs.options[i].selected) {
				document.frmContent.TextArea2.value = document.frmContent.TextArea2.value + "<A HREF=javascript:openPDF('" + document.frmContent.pdfs.options[i].text + "');>" + document.frmContent.pdfs.options[i].text + "</A>";
			}
		}
	}
	else if (ContentID == 3) {
		for (var i=0; i< document.frmContent.pdfs.length; i++) {
			if (document.frmContent.pdfs.options[i].selected) {
				document.frmContent.Content1.value = document.frmContent.Content1.value + "<A HREF=javascript:openPDF('" + document.frmContent.pdfs.options[i].text + "');>" + document.frmContent.pdfs.options[i].text + "</A>";
			}
		}
	}
	else if (ContentID == 4) {
		for (var i=0; i< document.frmContent.pdfs.length; i++) {
			if (document.frmContent.pdfs.options[i].selected) {
				document.frmContent.Content2.value = document.frmContent.Content2.value + "<A HREF=javascript:openPDF('" + document.frmContent.pdfs.options[i].text + "');>" + document.frmContent.pdfs.options[i].text + "</A>";
			}
		}
	}
}

function searchSubmit() {
	document.frmSearch.submit();
}

function popupEvent(id) {
	open("/event_popup.cfm?EventID="+id, "Event_Popup", "width=450, height=400, resizable=yes, directory=yes, menubar=yes, location=no, toolbar=no, status=yes, scrollbars=yes");
}

function backToTemplates(){
	if (confirm("\nChanging templates will reset all data already entered into this template. Aer you sure you wish to go back to the templates?\n")) {
		javascript:history.go(-1);
	}
}
function changeTemplates(PageID){
	document.location="/admin/page_modify_template.cfm?PageID=" + PageID;
}

function imageUploadLaunch() {
	open("/admin/image_upload.cfm", "Image_Upload", "width=630, height=470, resizable=yes, directory=yes, menubar=yes, location=yes, toolbar=no, status=yes, scrollbars=yes");
}

function openNews(NewsID)  {
	open("/news_popup.cfm?NewsID=" + NewsID, "News_Popup", "width=630, height=470, resizable=yes, directory=yes, menubar=yes, location=no, toolbar=no, status=yes, scrollbars=yes");
}

/* Original Code */
function openLink(url) {
	if (confirm("\nNOTE: By following this link, you will be leaving the Smithtowninfo.com website. Our provision of these links does not imply approval of the listed destinations, warrant the accuracy of any information in those destinations, constitute endorsement of the entities to whose sites the links are made, or endorse any of the opinions expressed on any of these outside Web sites.\n")) {
	window.open(url);
	}
}

/* Working Code
function openLink(url) {
	if (
	alert("\nNOTE: By following this link, you will be leaving the Smithtowninfo.com website. Our provision of these links does not imply approval of the listed destinations, warrant the accuracy of any information in those destinations, constitute endorsement of the entities to whose sites the links are made, or endorse any of the opinions expressed on any of these outside Web sites.\n")) 
	{
	window.open(url);
	}
}*/

/*function launchPlayer(channel)
{
	var theURL = 'player/index.asp?channel_id='+channel;
	window.open(theURL,'player','scrollbars=no,width=600,height=400');
}*/

function openPDF(pdf) {
	if (confirm("\nYou are about to open an Adobe Acrobat (.PDF) file. This requires that you have Adobe Acrobat installed on your computer. Do you wish to continue?\n")) {
		open("/pdf/" + pdf, "PDF_Popup", "width=630, height=470, resizable=yes, directory=yes, menubar=yes, location=no, toolbar=no, status=yes, scrollbars=yes");	
	}
}
