// GLOBAL VARIABLES

var concertSponsor
var startOutterTable = "<center><table border='0' width='760' cellpadding='0' cellspacing='0'><tr><td>"
var headerTable = "<table class='HeaderBG' width='100%' border='0' cellpadding='0' cellspacing='0'>" +
"<tr>" +
"<td width=500>" +
"<script type='text/javascript'>document.write(getLogo())</script>" +
"</td>" +
"<td width= 260 align=right>" +
"<script type='text/javascript'>document.write(getSponsor())</script>" +
"</td>" +
"</tr>" +
"<tr>" +
"<td class='Divider' colspan='2'><img src=/images/ecblank.gif alt='' height='1' width='1'></td>" +
"</tr>" +
"</table>"
var startBodyTable = "<table border='0' cellpadding='0' cellspacing='0' class='TextArea' width='100%'><tr valign='top'>"
var startTextAreaTD = "<td><table border='0' width='100%' cellpadding='12' cellspacing='0'><tr><td class='TextArea'>"
var endTable = "</td></tr></table>" 

var footerTable = "<table width='100%' border=0 cellspacing=0 cellpadding=0><tr><td class='Divider' colspan=2><img src=/images/ecblank.gif alt='' height=1 width=1></td></tr><tr valign=top><td class='footerbg'><font class=FooterText>&nbsp;<a href='mailto:rcmg@juno.com'>Nancy Lambert, Executive Director</a><br>&nbsp;<font color='#333333'>Raleigh Chamber Music Guild<br>&nbsp;PO Box 2059<br>&nbsp;Raleigh NC 27602<br>&nbsp;Phone: (919) 821-2030<br><br></font></td><td class='footerbg' align=right><font class=FooterText><a href='mailto:doug@dshort.net'>Doug Short, Webmaster</a>&nbsp;<p><a font class='none' href='http://validator.w3.org/check?uri=referer'><img src='/images/valid-html40.png' alt='Valid HTML 4.0 Transitional' title='Valid HTML 4.0 Transitional' height='31' width='88' border='0'></a></td></tr></table>"

var returnLink = "<div align=right><a class='RCMGbutton' href=/index.htm><b>&nbsp;Back&nbsp;</b></a></div>"
var endPage = "</body><!-- WORKAROUND FOR MSIE CACHE BUG --><head><meta http-equiv='Pragma' content='no-cache'></head></html>"
var back = "<p align=right><a href='javascript: history.go(-1)'>Back</a></p>"

var ticketsales = "<b>TICKETS:</b> $22 General Public; $8 Students<p>The Guild offers <a href=http://www.rcmg.org/tickets.htm>four ways</a> to purchase tickets: by mail, by phone, at the door, or online.&nbsp;&nbsp;<a href=http://www.rcmg.org/tickets.htm>More...</a></p><p>" +
"<table border=0 cellpadding=0 cellspacing=0><tr><td valign='middle'><b><i>Buy now online!</i></b>&nbsp;&nbsp;&nbsp;</td><td>" +
"<script language='JavaScript'>document.write(getTicketURL())</script>" +
"</td></tr></table>"

var ticketsales259 = "<b>TICKETS:</b> $25 General Public; $9 Students<p>The Guild offers <a href=http://www.rcmg.org/tickets.htm>four ways</a> to purchase tickets: by mail, by phone, at the door, or online.&nbsp;&nbsp;<a href=http://www.rcmg.org/tickets.htm>More...</a></p><p>" +
"<table border=0 cellpadding=0 cellspacing=0><tr><td valign='middle'><b><i>Buy now online!</i></b>&nbsp;&nbsp;&nbsp;</td><td>" +
"<script language='JavaScript'>document.write(getTicketURL())</script>" +
"</td></tr></table>"

var ticketsales2510 = "<b>TICKETS:</b> $25 General Public; $10 Students<p>The Guild offers <a href=http://www.rcmg.org/tickets.htm>four ways</a> to purchase tickets: by mail, by phone, at the door, or online.&nbsp;&nbsp;<a href=http://www.rcmg.org/tickets.htm>More...</a></p><p>" +
"<table border=0 cellpadding=0 cellspacing=0><tr><td valign='middle'><b><i>Buy now online!</i></b>&nbsp;&nbsp;&nbsp;</td><td>" +
"<script language='JavaScript'>document.write(getTicketURL())</script>" +
"</td></tr></table>"

function getMap(arg) {

	var urlStart = "<a class=RCMGbutton href=\"JavaScript:popup('"
	var urlEnd = "')\"><b>&nbsp;Map&nbsp;</b></a>"

	if (arg=="museum") {
		return urlStart + "/docs/ncma-map.htm" + urlEnd
	} else if (arg=="masters") {
		return urlStart + "/docs/progress-energy-map.htm" + urlEnd
	} else if (arg=="naturalsciences") {
		return urlStart + "http://naturalsciences.org/visinfo/directions.html" + urlEnd
	} else if (arg=="holy-trinity") {
		return urlStart + "/docs/holy-trinity-map.htm" + urlEnd
	} else if (arg=="temple-beth-or") {
		return urlStart + "/docs/temple-beth-or-map.htm" + urlEnd
	} else if (arg=="jones-chapel") {
		return urlStart + "/docs/jones-chapel-map.htm" + urlEnd
	} else {
		return ""
	}
}

//Note: ticketID var is set on the calling page, alternatively it may be passed as arg
function getTicketURL(arg) {

	var urlStart = "<a href=\"http://www.ticketweb.com/t3/sale/SaleEventDetail?dispatch=loadSelectionData&eventId="
	var urlEnd = "\" target='_blank'><img src=/images/ticketweb.gif border='0' hspace='0'  alt='Buy Now!'  title='Buy Now!'></a>"
	var noTicketURL = "<img src=/images/tweb-small-NYA.gif border=0 hspace=5 title='Not yet available. Check back later.' alt='Not yet available. Check back later.' height=16>"
	if (ticketID=='9999999') {
		return noTicketURL
	} else {
		return urlStart + ticketID + urlEnd
	}
}

//BUILD THE COLUMN NAVIGATOR AS A TD ELEMENT OR NO NAVIGATOR IF AN ARG IS PASSED
function buildNavigator(arg) {

	var str = "" + document.location;
	var start = str.indexOf('.org/') + 5;
	var end = str.indexOf('.htm');
	if (arg!=null) {
	    return "<td align=right><a href='javascript: history.go(-1)'>Back&nbsp; &nbsp;</a></td></tr><tr>"
	}

	if (end==-1) {
		var thisPage = "index"
	} else {
		var thisPage = (str.substring(start, end))
	}

	return "<td class='ColNavBG' width= '140'>" + 
	"<table align=left width='100%' border=0 cellpadding=2 cellspacing=0>" + 
	"<tr>" + fetchClass(thisPage, "index") + " href='/index.htm'>RCMG Home</a>&nbsp;</td></tr>" + 
	"<tr>" + fetchClass(thisPage, "preview") + " href='/preview.htm'>2010-11 Season!</a>&nbsp;</td></tr>" + 
	"<tr>" + fetchClass(thisPage, "newsletters/index") + " href='/newsletters/index.htm'>RCMG Newsletter</a>&nbsp;</td></tr>" + 
	"<noscript><tr>" + fetchClass(thisPage, "calendar") + " href='/calendar.htm'>Event Calendar</a>&nbsp;</td></tr><noscript>" + 
	"<noscript><tr>" + fetchClass(thisPage, "2007-raffle") + " href='/raffle/2007-raffle.htm'>2007 Raffle</a>&nbsp;</td></tr></noscript>" + 
	"<noscript><tr>" + fetchClass(thisPage, "07-gala-flier") + " href=\"JavaScript:popup('http://rcmg.org/docs/07-gala-flier.pdf')\">Fundraising Gala</a>&nbsp;</td></tr></noscript>" + 
	"<tr>" + fetchClass(thisPage, "masters") + " href='/masters.htm'>Masters Series</a>&nbsp;</td></tr>" +
	"<noscript<tr>" + fetchClass(thisPage, "master-classes") + " href='/master-classes.htm'>Master Classes</a>&nbsp;</td></tr></noscript>" + 
	"<tr>" + fetchClass(thisPage, "prelude") + " href='/docs/2010-SP-flyer.pdf'>Sept.&nbsp;Prelude</a>&nbsp;</td></tr>" + 
	"<tr>" + fetchClass(thisPage, "sights") + " href='/sights.htm'>Sights & Sounds</a>&nbsp;</td></tr>" + 
	"<noscript><tr>" + fetchClass(thisPage, "sights-call-for-proposals") + " href='/sights-call-for-proposals.htm'>S&S '10-'11 RFP</a>&nbsp;</td></tr></noscript>" + 
	"<tr>" + fetchClass(thisPage, "tickets") + " href='/tickets.htm'>Ticket Info</a>&nbsp;</td></tr>" + 
	"<tr>" + fetchClass(thisPage, "maps") + " href='/maps.htm'>Maps to Concerts</a>&nbsp;</td></tr>" + 
	"<tr>" + fetchClass(thisPage, "about") + " href='/about.htm'>About the Guild</a></td></tr>" + 
	"<tr>" + fetchClass(thisPage, "archives") + " href='/archives.htm'>Archives</a></td></tr>" + 
	"<noscript><tr>" + fetchBoldClass(thisPage, "preview") + "  href='/preview.htm'><br><center><i>2006-2007<br>Season<br>Preview!</i></center></a>&nbsp;</td></tr></noscript>" +
	
	"<noscript><tr>" + fetchBoldClass(thisPage, "calendar") + " href='/season-brochure.htm'><center>Season Brochure</center></a>&nbsp;</td></tr><noscript>" + 

	"<noscript><tr><td align=center><a href='/programs/prelude/2006/index.htm'><img src=/images/prelude-nav.gif alt='September Prelude' border=0 height=75 width=125 vspace=3></a></td></tr></noscript>" +
	
	"<tr><td align=center><a class=none href='http://www.facebook.com/pages/Raleigh-Chamber-Music-Guild/170294002036'><img src=/images/facebook-link.gif alt='Season Brochure' border=0 height=75 width=125 vspace=3 onmouseover=\"this.src='/images/facebook-link-hover.gif'\" onmouseout=\"this.src='/images/facebook-link.gif'\"></a></td></tr>" +

	"<tr><td align=center><a class=none href='/season-brochure.htm'><img src=/images/season-brochure.jpg alt='Season Brochure' border=0 height=75 width=125 vspace=3 onmouseover=\"this.src='/images/season-brochure-hover.jpg'\" onmouseout=\"this.src='/images/season-brochure.jpg'\"></a></td></tr>" +
	
	"<tr><td align=center><a class=none href='/supporters/paypal.htm'><img src=/images/support-the-guild.jpg alt='' border=0 height=75 width=125 vspace=3 onmouseover=\"this.src='/images/support-the-guild-hover.jpg'\" onmouseout=\"this.src='/images/support-the-guild.jpg'\"></a></td></tr>" +
	
	"<tr><td align=center><a class=none href=\"JavaScript:popup('http://www.cvnc.org/',920,600)\"><img src=/images/cvnc.gif alt='Classical Voice of North Carolina' border=0 height=75 width=125 vspace=3 onmouseover=\"this.src='/images/cvnc-hover.gif'\" onmouseout=\"this.src='/images/cvnc.gif'\"></a><br></td></tr>" +

	"<tr><td align=center><img src=/images/rcmg-12th-year.gif alt='' border=0 height=75 width=125 vspace=0><br><br></td></tr>" +

	"</table>"
}

function fetchClass(thisPage, arg) {

	if (thisPage==arg) {	
		return "<td class='ColNavActive'>&nbsp;<a class='ColNavActive'"
	} else {
		return "<td>&nbsp;<a class='ColNav'"
	}
}

function fetchBoldClass(thisPage, arg) {

	if (thisPage==arg) {	
		return "<td class='ColNavActive'>&nbsp;<a class='ColNavBoldActive'"
	} else {
		return "<td>&nbsp;<a class='ColNavBold'"
	}
}

//DYNAMIC HEADER GRAPHICS
function getLogo() {

	var rcmgLogo = "<a href='http://rcmg.org'><img src=/images/rcmg-logo.jpg border=0 vspace=0 alt='Raleigh Chamber Music Guild' height=75 width=350></a>"
	var seriesLogo
	if (pageType=="masters"){
	   seriesLogo = "<a href='/masters.htm'><img src=/images/masters.jpg border=0 vspace=0 alt='Masters Series' height=75 width=150></a>"
	} else if (pageType=="sights"){
	   seriesLogo = "<a href='/sights.htm'><img src=/images/sights.jpg border=0 vspace=0 alt='Sights & Sounds on Sunday' height=75 width=150></a>"
	} else if (pageType=="preview"){
	   seriesLogo = "<a href='/preview.htm'><img src=/images/preview.jpg border=0 vspace=0 alt='Season Preview' height=75 width=150></a>"
	} else if (pageType=="prelude"){
	   seriesLogo = "<img src=/images/prelude.jpg border=0 vspace=0 alt='September Prelude' height=75 width=150></a>"
	} else {
	   seriesLogo = "<a href='/'><img src=/images/season.jpg border=0 vspace=0 alt='Current Season' height=75 width=150></a>"
	}
	return "<a href='http://rcmg.org'><img src=/images/rcmg-header-0910.jpg border=0 vspace=0 alt='Raleigh Chamber Music Guild' height=75 width=500></a>"
}

//INTEGER MULTIPLIER SHOULD BE ONE LESS THAN THE SPONSOR ARRAY IN FOLLOWING FUNCTION
function get_random() { 
    var ranNum= Math.round(Math.random()*5); 
	return ranNum; 
} 

function getSponsor() {
	var str = "" + document.location;
	var whichSponsor = get_random();
	var cvnc = "<a href=\"JavaScript:popup('http://www.cvnc.org/')\"><img src='/supporters/cvnc.gif' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
	var zenph = "<a href=\"JavaScript:popup('http://www.zenph.com/')\"><img src='/supporters/zenph.gif' border=0 hspace=0 alt='A valued RCMG Sponsor' height=75 width=260></a>"

    var Sponsor=new Array(6)
     Sponsor[0]="<a href='http://www.ruggeropiano.com/'><img src='http://rcmg.org/supporters/ruggero.jpg' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
     Sponsor[1]="<a href='http://www.raleighneurology.com/'><img src='http://rcmg.org/supporters/raleigh-neurology-associates.gif' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
     Sponsor[2]="<a href='http://www.montgomeryviolins.com/'><img src='http://rcmg.org/supporters/montgomery-violins.gif' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
     Sponsor[3]="<a href='http://www.allentate.com/brianwolborsky/desktopdefault.aspx'><img src='http://rcmg.org/supporters/wolborsky-group.gif' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
     Sponsor[4]="<a href='http://www.hunton.com/'><img src='http://rcmg.org/supporters/hunton-williams.gif' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
     Sponsor[5]="<a href='http://www.smithlaw.com/'><img src='http://rcmg.org/supporters/smith-anderson.gif' border=0 hspace=0 alt='A valued RCMG supporter' height=75 width=260></a>"
	if (concertSponsor == "zenph") {
		return zenph
	} else if (str.match("cvnc")=="cvnc"){
		return cvnc
	} else {
		return Sponsor[whichSponsor]
	}
} 


//GENERIC POPUP WINDOW
var remote
var oldURL
var nav=navigator.appName
var ver=navigator.appVersion.charAt(0)

function launch(newURL, newName, newFeatures, orgName) {
	if (nav=="Microsoft Internet Explorer" && remote!=null && oldURL!=newURL) {
		closeWin();
	}
	if (!remote || remote.closed || oldURL!=newURL) {
		remote = open(newURL, newName, newFeatures)
	if (oldURL!=null && nav == "Netscape" && ver!="2") {
		remote.focus()
		}
		oldURL = newURL
	} else if (nav == "Netscape"&& ver!="2") {
		remote.focus()
	} else {
		closeWin();
		remote = open(newURL, newName, newFeatures)
	}
	if (remote!=null && remote.opener == null) {
		remote.opener = window;
		remote.opener.name = orgName
	}
	return remote
}

function closeWin() {
	remote.close();
	remote=null
}

function popup(url,w,h) {
	if (url.indexOf("/")==-1) {
		url="/"+DB+"/Popup/" + url
	}
	if (h==null) {
		h=600
	}
	if (w==null) {
		w=800
	}
	var features="height=" + h + ",width=" + w + ",top=20,left=20,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=1,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0,z-lock=0";
	myRemote = launch(url,"PopUp1",features,"myWindow");
}

function closepage(arg) {

    if (arg != null) {
        return back + endTable + endTable + footerTable + endTable + endPage
    } else {
        return endTable + endTable + footerTable + endTable + endPage
    }
}
