<!--Hide from browsers of different ability

// use this file as a repository for all global javascript functions


/* 
this function is used in the browse by topic dropdown menu to redirect uses to their 
selected topic destination
*/
function topicRedirect(form){
	var URL = document.topicselectionform.topic.options[document.topicselectionform.topic.selectedIndex].value;
	window.location.href = URL;
}

// mediaPlayer wraps FQDN version of method for backwards compat 
function mediaPlayer(programId,episodeId,segment) {
  FQDNmediaPlayer(programId,episodeId,segment,false);
}

// also wraps FQDN version of method for backwards compat 
function mediaPlayerWithReturn(programId,episodeId,segment) {
  FQDNMediaPlayerWithReturn(programId,episodeId,segment,false);
}

// the FQDN versions of the mediaPlayer methods are to be called from outside
// of www.kqed.org, and should pass "true" for the fqdn argument.  This will ensure
// that the popup loads resources (frameset, jsp pages) that reside at
// http://www.kqed.org/...

// this calls the media player popup (strips out the return value for safe "onclick" behavior)
function FQDNmediaPlayer(programId,episodeId,segment,fqdn) {
  FQDNmediaPlayerWithReturn(programId,episodeId,segment,fqdn);
}

function FQDNmediaPlayerWithReturn(programId,episodeId,segment,fqdn) {
  var path = '/servlets/playClip';
  var url = null;
  if ( fqdn == true ) {
    url = "http://www.kqed.org" + path;
  } else {
    url = path;
  }
  var qstring = '';
  qstring = 'programId=' + programId;
  if (episodeId != null )
    qstring += '&episodeId=' + episodeId;
  if (segment != null)
    qstring += '&segment=' + segment;
  if ( qstring != '' )
    url+= '?' + qstring;
  plPopup = window.open(url , 'player', 'toolbar=0,locationbar=0,directories=0,scrollbars=0,status=0,menubar=0,resizable=1,width=370,height=500');
  plPopup.focus();
  return plPopup;
}

// this is for calling listen live specifically:
function listenLive () {
  return mediaPlayer('NO_PROG','RADIOLIVE');
  //window.location.href = 'http://www.kqed.org/streamingfiles/kqed_real.ram';
}

// backwards-compatability wrapper on the world's most uselessly named function
function openWindow (prog_id,dbdate,starthour24,startminute) {
   programPopup(prog_id,dbdate,starthour24,startminute,"");
}

// bdu 23oct2003 - future version of this will need to not use programDataID
function openEmailReminderPopup(programDataID,programID,epID,displayDate) {
   erPopup = window.open('/programs/program-reminder.jsp?programDataId='+programDataID+'&progID='+programID+'&epID='+epID+'&displayDate='+displayDate,'activity','toolbar=no,locationbar=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,width=360,height=360')
   erPopup.focus()
}


function programPopup (prog_id,dbdate,starthour24,startminute,channel) {
   // check if program airs tomorrow
   dayOffset = Math.floor(starthour24 / 24);
   if (dayOffset) {
     starthour24 = starthour24 % 24;
     dbdateSplit = dbdate.split("-");
     broadcastDate = new Date( dbdateSplit[0], (dbdateSplit[1] - 1), dbdateSplit[2] );
     calendarMsecs = broadcastDate.getTime() + (dayOffset * 1000 * 60 * 60 * 24);
     calendarDate = new Date(calendarMsecs);
     calYear = "20" + calendarDate.getYear().toString().slice(-2);
     calMonthInt = calendarDate.getMonth() + 1;
     calMonth = calMonthInt.toString();
     calDate = calendarDate.getDate().toString();
     dbdate = calYear + "-" + calMonth + "-" + calDate;
   }
   newWindow = window.open('/programs/program-pop-up.jsp?channel='+channel+'&prog_id='+prog_id+'&dbdate='+dbdate+'&starthour24='+starthour24+'&startminute='+startminute,'activity','toolbar=no,locationbar=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,width=360,height=360'); newWindow.focus();
}

function alertPledgeGiftOptions (thisForm) {
	attrib = thisForm.ATTRIBUTE_CODE;
	if (attrib.type != "hidden") {
		msg = "You have selected a pledge gift with the option: \n" +
			attrib.options[attrib.selectedIndex].text +
			"\n" + "Click OK to continue with this pledge, \n" +
			"or Cancel to go back and change it.";
		if(confirm(msg)) {
			return true;
		} else {
			return false;
		}
	}
}

// erc 05nov2003 - email reminder, renamed and moved from pages into common 
function openEmailReminderPopup(programDataID,programID,epID,displayDate) {
		newWindow = window.open('/programs/program-reminder.jsp?programDataId='+programDataID+'&progID='+programID+'&epID='+epID+'&displayDate='+displayDate,'activity','toolbar=no,locationbar=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,width=360,height=360')
		newWindow.focus()
} // end if listsize > 0

// ken 13feb2004 - code for localvoice popup widget:
function LVPopupSubmit() {
	window.open('http://lv0.net/MemberConsole/ListAPI.aspx?OrgID=336&ReturnURLParameters=1&HTML=1&Email='+escape(document.frmLVListAPI.Email.value)+'&List='+document.frmLVListAPI.listID.value+'&Redirect='+escape(document.frmLVListAPI.urlBase.value+'/newsletters/confirmation-pop-up.jsp'),'kqed_nl_pop','menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=400,height=300');
	document.frmLVListAPI.Email.value="";
}

function LVPopupSubmitOnEnter() {
      if (window.event.keyCode == 13) {
          window.event.keyCode = 0;
          LVPopupSubmit();
      }
}


// 	NPR Modules Localization Code
window.station="KQED_FM";
window.localize=true;




//end hide-->

