// JavaScript Document
function makemail(name, domain, display) {
displayed=(typeof(display)=="undefined") ? name+"@"+domain : display
document.write('<a href=mailto:' + name + '@' + domain + '>' + displayed + '</a>');
}

function foober(emmename){
document.write('<a href=\"mailto:' + emmename + '@geffenplayhouse.com\">'+ emmename + '@geffenplayhouse.com</a>');
}

function OpenBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		BUYTIX_over = newImage("images/BUYTIX-over.jpg");
		RENEW_over = newImage("images/RENEW-over.jpg");
		HOME_over = newImage("images/HOME-over.jpg");
		EVENTS_over = newImage("images/EVENTS-over.jpg");
		STAGE_over = newImage("images/STAGE-over.jpg");
		BOX_OFFICE_over = newImage("images/BOX-OFFICE-over.jpg");
		SUPPORT_US_over = newImage("images/SUPPORT-US-over.jpg");
		EDUCATION_over = newImage("images/EDUCATION-over.jpg");
		PRESS_over = newImage("images/PRESS-over.jpg");
		RESOURCES_over = newImage("images/RESOURCES-over.jpg");
		GEFFEN_over = newImage("images/GEFFEN-over.jpg");
		CONTACT_over = newImage("images/CONTACT-over.jpg");
		MAPODIR_over = newImage("images/MAPODIR-over.jpg");
		preloadFlag = true;
	}
}

	function openwindowlink(pagename) {
newwin = window.open(pagename,"playsWindow",",height=500,width=600,scrollbars=yes,resizable=no")
}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('a.switchmenu,a.switchmenu:link,a.switchmenu:visited { font-family:georgia, "Times New Roman", Times, serif; text-decoration:none; font-size:11px; font-weight:bold; color:#DCE0DF; }')
document.write('a.switchmenu:hover { font-family:georgia, "Times New Roman", Times, serif; text-decoration:underline; font-size:11px; font-weight:bold; color:#BCD4FA; }')
document.write('a.switchmenu_active,a.switchmenu_active:link,a.switchmenu_active:visited { font-family:georgia, "Times New Roman", Times, serif; text-decoration:none; font-size:11px; font-weight:bold; color:#BCD4FA; }')
document.write('a.switchmenu_active:hover { font-family:georgia, "Times New Roman", Times, serif; text-decoration:underline; font-size:11px; font-weight:bold; color:#BCD4FA; }')

document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function closecontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "block"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined")
revivecontent()
}


	function drawAlert () {
alert ("Please Select the show time you wish to attend and then enter your coupon code!");
}

var popwincenter = null;
function NewPopUpWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
popwincenter = window.open(mypage,myname,settings)
}

function email_valid(){

	if (ticketForm.account_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.account_r.focus();

		return (false);

	}



	if (ticketForm.firstname_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.firstname_r.focus();

		return (false);

	}



	if (ticketForm.address_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.address_r.focus();

		return (false);

	}



	if (ticketForm.city_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.city_r.focus();

		return (false);

	}



	if (ticketForm.state_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.state_r.focus();

		return (false);

	}



	if (ticketForm.zip_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.zip_r.focus();

		return (false);

	}



	if (ticketForm.telephone_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.telephone_r.focus();

		return (false);

	}



	if (ticketForm.pay_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.pay_r.focus();

		return (false);

	}



		if (ticketForm.ccname_r.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.ccname_r.focus();

		return (false);

	}



	if (ticketForm.CCN.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.CCN.focus();

		return (false);

	}



	if (ticketForm.CCX.value == ""){

		alert("Please enter a value for the field ");

		ticketForm.CCX.focus();

		return (false);

	}

			

	return (true);

}

function validEmail(email) {

		invalidChars = " /:,;"

		if (email == "") {
			return false
		}
		for (i=0; i<invalidChars.length; i++) {
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) > -1) {
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {
			return false
		}
		if (periodPos+3 > email.length)	{
			return false
		}
		return true
	}

function submitIt(subsForm) {
		if (!validEmail(document.subsForm.email.value))
			{
				alert("Invalid email address")
				document.subsForm.email.focus()
				document.subsForm.email.select()
				return false
			}


		var pref = "";
		var reqfields = new Array('Field2021','Field1881','Field1882','Field2019','Field2022','Field2023');

			for(i=0; i < reqfields.length;i++)
				{
					tempfield = "document.subsForm."+pref+reqfields[i]+".value";
					tempid = "document.subsForm."+pref+reqfields[i]+".id";
					tempval = eval(tempfield);
					tempid = eval(tempid);

					if(tempval=="")
						{
							alert("Please provide a "+tempid+".");
							return false;
						}
			}

		return true
}

function CreateMsgWindow()
{
	msgWindow = window.open("","msgWindow", "width=420,height=150,resizable,scrollbars");
	msgWindow.document.write("<html><head><title>Opt out of receiving future email</title><LINK REL='StyleSheet' HREF='global/global.css' type='text/css'></head><body style='margin:10px'>");
	msgWindow.document.write("<h4>Opt out of receiving future email</h4>");
	msgWindow.document.write("<form action='optout.php' method='POST'><input type='text' size='25' type='Button' name='email_address'><br><br><input type='Submit' value='submit'></form>");
	msgWindow.document.write("<br><br></body></html>");
	msgWindow.document.close();
}

function check_field (objField, sTitle) {
	if (objField.value == '') {
		return '\nPlease enter your ' + sTitle + '.';
	}
	return '';
}

function check_select (objField, sTitle) {
	if (objField.selectedIndex < 1) {
		return '\nPlease select your ' + sTitle + '.';
	}
	return '';
}

function form_valid(){

	var sErrorMsg = '';
	var objForm = window.document.ticketForm;

	//calcTotals();

	sErrorMsg += check_select(objForm.series, 'series');
	//sErrorMsg += check_select(window.document.ticketForm['times ' + objForm.series.options[objForm.series.selectedIndex].value], 'times and seats');
	sErrorMsg += check_field(objForm.seats, 'desired # of seats');
	sErrorMsg += check_field(objForm.firstname_r, 'first name');
	sErrorMsg += check_field(objForm.lastname_r, 'last name');
	sErrorMsg += check_field(objForm.dayphone_r, 'daytime phone number');
	sErrorMsg += check_field(objForm.address_r, 'address');
	sErrorMsg += check_field(objForm.city_r, 'city');
	sErrorMsg += check_field(objForm.state_r, 'state');
	sErrorMsg += check_field(objForm.zip_r, 'zip code');
	sErrorMsg += check_field(objForm.ccfname_r, 'first name that appears on the credit card');
	sErrorMsg += check_field(objForm.cclname_r, 'last name that appears on the credit card');
	sErrorMsg += check_select(objForm.pay_r, 'method of payment');
	sErrorMsg += check_field(objForm.CCN, 'credit card number');
	sErrorMsg += check_field(objForm.CCM, 'credit card\'s expiration month');
	sErrorMsg += check_field(objForm.CCY, 'credit card\'s expiration year');

	if (objForm.Newsletter.checked) {
		sErrorMsg += check_field(objForm.email_r, 'email address so we may send you email as you requested');
	}

	if (sErrorMsg != '') {
		alert('One or more required fields were left blank:\n' + sErrorMsg);
		return false;
	}
	return true;
}

function calcTotals () {
	var dSubTotal = 0.0;

	var objSeries = window.document.ticketForm.series;

	var objTimes = window.document.ticketForm['times ' + objSeries.options[objSeries.selectedIndex].value];

	var objSubTotal = window.document.ticketForm.subtotal;
	objSubTotal.value = '';

	var objTotal = window.document.ticketForm.total;
	objTotal.value = '';

	var objDonate = window.document.ticketForm.donate_r;
	if (isNaN(1*objDonate.value))
		objDonate.value = '';

	var objParking = window.document.ticketForm.park_r;
	if (isNaN(1*objParking.value))
		objParking.value = '0';
	var dParking = 1*objParking.value;
	if (dParking != 0) {
		dParking = 30;
		objParking.value = '30';
	}

	var objSeats = window.document.ticketForm.seats;
	if (isNaN(1*objSeats.value))
		objSeats.value = '';

	if (objTimes) {
		var sLabel = objTimes.options[objTimes.selectedIndex].text;
		var dCost = sLabel.substr(sLabel.length - 3, 3);

		var dSeats = 1;
		dSeats *= window.document.ticketForm.seats.value;
		dSeats *= dCost;

		if (!isNaN(dSeats)) {
			objSubTotal.value = dSeats;
			objTotal.value = (1*dSeats) + (1*objDonate.value) + (1*dParking) + 15.00;
		}
	}
}

function check_radio (arEl, sTitle) {

	for (loop = 0; loop < arEl.length; loop++) {
		objEl = arEl[loop];
		if (objEl.checked) {
			return '';
		}
	}

	return '\nPlease select your ' + sTitle + '.';
}

function check_only (objField, nPicks) {

	var objForm = objField.form;
	var arEl = objForm[objField.name];

	for (loop = 0; loop < arEl.length; loop++) {
		objEl = arEl[loop];
		if (objEl.checked) {
			if (nPicks > 0) {
				nPicks--;
			} else {
				objEl.checked = false;
			}
		}
	}
}

function check_checkbox (arEl, nPicks, sTitle) {
	var iCount = 0;

	for (loop = 0; loop < arEl.length; loop++) {
		objEl = arEl[loop];
		if (objEl.checked) {
			iCount++;
		}
	}

	if (nPicks == iCount) {
		return '';
	}

	return '\nSelect ' + nPicks + ' ' + sTitle + '.';
}

function check_checkbox_atleast (arEl, nPicks, sTitle) {
	var iCount = 0;

	for (loop = 0; loop < arEl.length; loop++) {
		objEl = arEl[loop];
		if (objEl.checked) {
			iCount++;
		}
	}

	if (nPicks <= iCount) {
		return '';
	}

	return '\nSelect at least ' + nPicks + ' ' + sTitle + '.';
}

function check_play (iPlay) {
	var objForm = window.document.ticketForm;

	if (!objForm['play[' + iPlay + ']'].checked) {
		return 0;
	}
	if (objForm['show[' + iPlay + ']'].selectedIndex < 2) {
		return 0;
	}
	if (objForm['type[' + iPlay + ']'].selectedIndex < 2) {
		return 0;
	}
	if (objForm['tickets[' + iPlay + ']'].value < 1) {
		return 0;
	}

	return 1;
}

function showToggle (sName, bDisplay) {

	var objDiv = window.document.getElementById(sName);

	if (objDiv != null) {
		if (bDisplay) {
			objDiv.style.display = 'block';
		} else {
			objDiv.style.display = 'none';
		}
	}
}

function playClick (iPlay, objField) {
	var objForm = objField.form;
	var sShowFieldName = 'show[' + iPlay + ']';
	var sTypeFieldName = 'type[' + iPlay + ']';
	var sTicketFieldName = 'tickets[' + iPlay + ']';

	objForm[sShowFieldName].selectedIndex = 0;
	showSelect(iPlay, objForm[sShowFieldName]);

	showToggle('playdiv' + iPlay, objField.checked);

	calcTotalsFlex();

	return true;
}

function orchPrice (sValue) {
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	return sValue.substr(0, sValue.indexOf(':'));
}

function upperPrice (sValue) {
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	if (sValue.indexOf(':') == -1) {
		return sValue;
	}
	return sValue.substr(0, sValue.indexOf(':'));
}

function balconyFrontPrice (sValue) {
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	if (sValue.indexOf(':') == -1) {
		return 0.0;
	}
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	if (sValue.indexOf(':') == -1) {
		return sValue;
	}
	return sValue.substr(0, sValue.indexOf(':'));
}

function balconyRearPrice (sValue) {
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	if (sValue.indexOf(':') == -1) {
		return 0.0;
	}
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	if (sValue.indexOf(':') == -1) {
		return 0.0;
	}
	sValue = sValue.substr(sValue.indexOf(':') + 1);
	if (sValue.indexOf(':') == -1) {
		return sValue;
	}
	return sValue.substr(0, sValue.indexOf(':'));
}

function showSelect (iPlay, objField) {
	var objForm = objField.form;
	var sShowFieldName = 'show[' + iPlay + ']';
	var sTypeFieldName = 'type[' + iPlay + ']';
	var sTicketFieldName = 'tickets[' + iPlay + ']';

	var iSelected = objField.selectedIndex;
	var sValue = objField.options[iSelected].value;

	var mOrch = orchPrice(sValue);
	var mUpper = upperPrice(sValue);
	var mBalFront = balconyFrontPrice(sValue);
	var mBalRear = balconyRearPrice(sValue);

	objForm[sTypeFieldName].selectedIndex = 0;

	if (iSelected < 2) {
		objField.selectedIndex = 0;
		objForm[sTypeFieldName].style.display = 'none';
		while (objForm[sTypeFieldName].options.length > 2) {
			objForm[sTypeFieldName].options[2] = null;
		}

		objForm[sTypeFieldName].options[2] = new Option('Orchestra', 'O');
		objForm[sTypeFieldName].options[3] = new Option('Upper Orchestra', 'U');
	} else {
		while (objForm[sTypeFieldName].options.length > 2) {
			objForm[sTypeFieldName].options[2] = null;
		}

		objForm[sTypeFieldName].options[2] = new Option('Orchestra - $' + mOrch, 'O');
		objForm[sTypeFieldName].options[3] = new Option('Upper Orchestra - $' + mUpper, 'U');
		if (mBalFront > 0) {
			objForm[sTypeFieldName].options[4] = new Option('Balcony Front - $' + mBalFront, 'BF');
		}
		if (mBalRear > 0) {
			objForm[sTypeFieldName].options[5] = new Option('Balcony Rear - $' + mBalRear, 'BR');
		}

		objForm[sTypeFieldName].style.display = 'block';
	}
	typeSelect(iPlay, objForm[sTypeFieldName]);

	calcTotalsFlex();

	return true;
}

function typeSelect (iPlay, objField) {
	var objForm = objField.form;
	var sShowFieldName = 'show[' + iPlay + ']';
	var sTypeFieldName = 'type[' + iPlay + ']';
	var sTicketFieldName = 'tickets[' + iPlay + ']';

	var iSelected = objField.selectedIndex;
	var sValue = objField.options[iSelected].value;

	if (iSelected < 2) {
		objField.selectedIndex = 0;
		objForm[sTicketFieldName].style.display = 'none';
	} else {
		objForm[sTicketFieldName].style.display = 'block';
	}

	calcTotalsFlex();

	return true;
}

function form_validRenew(){

	var sErrorMsg = '';
	var objForm = window.document.ticketfrm;

	sErrorMsg += check_field(objForm.firstname_r, 'first name');
	sErrorMsg += check_field(objForm.lastname_r, 'last name');
	sErrorMsg += check_field(objForm.dayphone_r, 'daytime phone number');
	sErrorMsg += check_field(objForm.address_r, 'address');
	sErrorMsg += check_field(objForm.city_r, 'city');
	sErrorMsg += check_field(objForm.state_r, 'state');
	sErrorMsg += check_field(objForm.zip_r, 'zip code');
	sErrorMsg += check_field(objForm.ccfname_r, 'first name that appears on the credit card');
	sErrorMsg += check_field(objForm.cclname_r, 'last name that appears on the credit card');
	sErrorMsg += check_field(objForm.pay_r, 'method of payment');
	sErrorMsg += check_field(objForm.CCN, 'credit card number');
	sErrorMsg += check_field(objForm.CCM, 'credit card\'s expiration month');
	sErrorMsg += check_field(objForm.CCY, 'credit card\'s expiration year');

	if (objForm.Newsletter.checked) {
		sErrorMsg += check_field(objForm.email_r, 'email address so we may send you email as you requested');
	}

	if (sErrorMsg != '') {
		alert('One or more required fields were left blank:\n' + sErrorMsg);
		return false;
	}
	return true;
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) { 

	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 

}

function doCheckout(curInput){

  switch (curInput) {

    case "update":

      document.shopping.updateCartQty.value='1';

      document.shopping.viewCart.value='1'; 

      document.shopping.submit();

      break;

    case "empty":

      document.shopping.emptyCart.value='1';

      document.shopping.submit();

      break;

    case "checkout":

      document.shopping.viewLogin.value='1';

      document.shopping.submit();

      break;

    default:

      document.shopping.viewCart2.value='1';

      document.shopping.submit();

      break;

  }

}



function doadminDeptChange(curNum){

	document.admindept.deptNum.value = curNum;

    document.admindept.submit();

}



function removeItem(curID){

  document.shopping.viewCart.value='1'; 

  document.shopping.removeMe.value=curID; 

  document.shopping.submit();

}



function openNewWindow(URLtoOpen, windowName, windowFeatures) { 

	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 

}



function viewOrder(id){

  document.order.orderNumber.value = id;

  document.order.submit();

}



function viewProduct(curID){

  document.shopping.prodviewCart.value = curID;

  document.shopping.submit();

}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate



