// JavaScript Document
// global namespace vars
// jQuery or $ // commented to prevent overwriting
var path; // if on stage = stage else = ''
var $id; // function short hand for document.getElementById()
var fadeBG; // fades a bg and inserts a containing div
var fade_container_id = 'fade_container'; 
var sf; // this will be a reference to the sucker fish functions - object literal
var winDim; // window dimensions
var slideShow = {};
var cellIt = {}; // the cell it text message contact info
var cl = function (){};
var pr = function () {};
winDim = {
	getWidth: function ()
    {
		var x = 0;
        if (self.innerHeight) {
			x = self.innerWidth;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			x = document.documentElement.clientWidth;
        } else if (document.body) {
			x = document.body.clientWidth;
		}
		return x;
	}, // end get wid
	getHeight: function ()
	{
		var y = 0;
		if (self.innerHeight) {
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
 			y = document.documentElement.clientHeight;
		} else if (document.body) {
			y = document.body.clientHeight;
		}
		return y;
	} // end get ht
};

function filterPath(string) {
  return string
    .replace(/^\//,'')
    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
    .replace(/\/$/,'');
}


////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////		START DOM READY FUNCTIONS

$(document).ready( function ()
{
	///*
	sf.sfHover();
	
	$('.ex_col').click(function () {

		if ($(this).hasClass('collapsed')){
			$(this).removeClass('collapsed');
			$(this).addClass('expanded');
			$(this).parent().find('ul:first').show();
		}else{
			$(this).removeClass('expanded');
			$(this).addClass('collapsed');
			$(this).parent().find('ul:first').hide();

		}
	});
	
	var locationPath = filterPath(location.pathname);
	$('[href*=#]').each(function() {
		var thisPath = filterPath(this.pathname) || locationPath;
		if (  locationPath == thisPath
		 && (location.hostname == this.hostname || !this.hostname)
		 && this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html, body').animate({scrollTop: targetOffset}, 800, function() {
						location.hash = target;
					}); // end animating the scroll top
				}); // end click function
			} // end if target exists
		} // end if location this that and the other thing
	}); // end each [href]
		  
	$('#Mail').click( function (ev) {
		ev.preventDefault();
		fadeBG.windowHeight = 205; 
		fadeBG.windowWidth = 402;
		fadeBG.getBGcontents( '/ajax_content/get_send_link_html.php', {}, function () { });
	});
	$('#Print').click( function (ev) {
		ev.preventDefault();
		window.print();
	});
	
	/////////////// set up cell it information	
	///*
	if ( $id( 'newsletter') ) {
		$(".newsletter a").click(function( ev ){
			ev.preventDefault();
			$id('update_switch').style.display = 'none';
			$id('newsletter_input').style.display = 'block';
			$id('mobile_input').style.display = 'none';
		});
		$(".mobile a").click(function(ev){
			ev.preventDefault();
			$id('update_switch').style.display = 'none';
			$id('newsletter_input').style.display = 'none';
			$id('mobile_input').style.display = 'block';
		});
	} 
	if ( $id('aid') ) {
		$( $id('aid').parentNode ).submit( function ( ev ) {
			cellIt.sendForm( ev );
		});
	} // end if aid id exists
    // make podcast download
    $( '#download_pod_link' ).click( function ( ev )
    {
        ev.preventDefault();
        var src = this.href;
        var el = document.createElement( 'iframe' );
        el.setAttribute( 'src', src );
        $('body').prepend( el );
        
    }); // end dowload click


});

//////////////////		END DOM READY FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////
$id = function (el)
{
	return document.getElementById(el);
} // end id

cl = function ( msg ) 
{
	//console.log( typeof console )
	if ( typeof console == 'object' ) {
		console.log( msg )
	}
}; // end cl

pr = function ( obj ) 
{
	if ( typeof console == 'object' ) { // don't bother unless this exists
		for( i in obj ) {
			cl( i + ' is: ' + obj[i] );	
		}
	} //
}; // end pr
///*
cellIt = {
	sending: false, // are we currently sending the form?
	sendInfo: { // init the info to send to cell it
		aid: 662,
		sucode: 'GPMFWEB',
		responsetype: 'text',
		phone: '',
		//failureurl: 'http://www.grantparkmusicfestival.com/',
		//successurl: 'http://www.grantparkmusicfestival.com/',
		acceptterms: 0
		
	}, 
	sendForm: function ( ev ) {
		ev.preventDefault();
		if ( this.sending ) { // prevent double submission
			return false;
		}
		this.sending = true;
		$id('mobile_input').style.display = 'none';
		$id('sending_msg').style.display = 'block';
		var phNum = $id('aid').parentNode.getElementsByTagName('input')[0].value;
		var testNum = phNum.replace( /[^\d]/g, '' );
		var alert_msg = "Sorry, there was an error.";
		var alertUser = false;
		if ( testNum.length < 10 ) {
			alert_msg += "\nPlease verify that you typed a valid 10 digit phone number.";
			alertUser = true;
		}
		if ( !$id('acceptterms').checked ) {
			alert_msg += "\nPlease verify that you checked the box and accepted our terms.";	
			alertUser = true;
		}
		if ( alertUser ) {
			alert( alert_msg );
			this.sending = false;
			$id('mobile_input').style.display = 'block';
			$id('sending_msg').style.display = 'none';
			return;
		}
		
		
		if ( testNum.length > 9 && $id('acceptterms').checked == true ) { // pass introductory tests?
			this.sendInfo.phone = phNum;
			this.sendInfo.acceptterms = $id('acceptterms').value;
			// set the loading message
			
			
			$.post( '/ajax_content/mobile-signup.php', this.sendInfo, function ( resp ) {
				cl( 'the resp was: ' + resp );
				if ( resp == '1' ) {
					cellIt.success();
				} else {
					cellIt.failure();
				}
			});
		} else { 
			alert( 'Sorry, there was a problem. Please try again.');
			this.sending = false;
			$id('mobile_input').style.display = 'block';
			$id('sending_msg').style.display = 'none';
		}
	}, // end send form
	success: function () {
		// give success message
		this.sending = false;
		$id('sending_msg').style.display = 'none';
		$id('success_msg').style.display = 'block';
		setTimeout( function() {
			//$id('success_msg').style.display = 'none';
			$('#success_msg').fadeOut('fast', function() {
				$('#update_switch').fadeIn('fast');
			});
		}, 3000);
	}, // end success
	failure: function () {
		this.sending = false;
		alert( 'Sorry, there was an error. \nPlease verify that you typed a valid 10 digit phone number and that you checked the box to accept our terms.' );
		this.showForm();
	}, // end success
	showForm: function () {
		// turn the form on 
		$id('sending_msg').style.display = 'none';
		$id('success_msg').style.display = 'none';
		$id('mobile_input').style.display = 'block';
	}
	
} // end cell it object
/* */
slideShow = {
	slides: [],
	captions: [],
	allowClick: true,
	arrayLenth: 0,
	shifter: {}, // shifter element - container
	slide0: {}, //   left slide element
	slide1: {}, // center slide element
	slide2: {}, //  right slide element
	holder: {}, //   hold slide element
	rightArrow: {}, // right arrow element
	leftArraow: {}, // left arrow element
	aniTime: 1250, // default set of 1250 ms animation time
	pauseTime: 7000, // default pause time before we slide on
	sectionWidth: 648, // image / container width
	timer: 0,
	links: [],
	// slide right - function
	// slide left - function
	// init - function
	
	
	count: 0, ///100 * arrLength
	arrLen: 0, //arrLength
	getC: function () 
	{
		return this.count;
	},
	setC: function (num)
	{
		this.count = num;
	},		
	addC: function ()
	{
		this.count = ( this.count + 1 );
	},
	subC: function () 
	{
		this.count = ( this.count - 1 );
	},
	getArrPrev: function ()
	{
		return ( (this.count - 1) % this.arrLen );
	},
	getArrNow: function ()
	{
		return ( this.count % this.arrLen );
	},
	getArrNext: function ()
	{
		return ( (this.count +1) % this.arrLen );
	},
	slideLeft: function ()
	{
		if ( this.allowClick == true ){
			// this is only for photo slide show
			if ( $id( 'play_btn') ) {
				$id( 'play_btn' ).style.display = 'none';
				$id( 'pause_btn' ).style.display = 'block';
			}
			//stop users from clicking before animation has finished
			slideShow.addC(); // increment one to get to the next one
			this.allowClick = false;
			
			clearTimeout( slideShow.timer );
			
			$('#photo_caption').fadeOut('fast', function () {
				$id('photo_caption').innerHTML = slideShow.captions[slideShow.getArrNow()]
			});
	
			$( this.shifter ).animate({left: ( -2 * this.sectionWidth ) }, this.aniTime, 'swing', function ()
			{ 
				var next = slideShow.getArrNext(); // next is the next in line after animating
	
				$( slideShow.shifter.getElementsByTagName('img')[0] ).remove();
				slideShow.shifter.style.left = ( -1 * slideShow.sectionWidth ) + 'px'; //'-668px';
				slideShow.slide0 = slideShow.slide1;
				slideShow.slide1 = slideShow.slide2;
				slideShow.slide2 = slideShow.slides[next];
				$(slideShow.shifter).append( slideShow.slide2 );
				slideShow.allowClick = true;
				slideShow.play();
				$( '.shifter_link2 > a' ).attr( 'href', slideShow.links[ slideShow.getArrNow() ] );
				$('#photo_caption').fadeIn('fast', function () {});
				return false;
			});
		}
 		return false;
	},
	slideRight: function ()
	{
		if (this.allowClick==true){
			
			// this is only for photo slide show
			if ( $id( 'play_btn') ) {
				$id( 'play_btn' ).style.display = 'none';
				$id( 'pause_btn' ).style.display = 'block';
			}
			//stop users from clicking before animation has finished
			slideShow.subC(); // decrement one to get to the next one
			this.allowClick=false;
			clearTimeout( slideShow.timer );
			$('#photo_caption').fadeOut('fast', function () {
				$id('photo_caption').innerHTML = slideShow.captions[slideShow.getArrNow()]
			});
			
			$(this.shifter).animate({left: 0}, this.aniTime, 'swing', function ()
			{ 
				slideShow.allowClick = true;
				
				var prev = slideShow.getArrPrev(); // prev will be the one that was just showing
			
				// fix the shifter child elements
				$( $id( slideShow.shifter.id.toString() ).getElementsByTagName('img')[2] ).remove();
				slideShow.shifter.style.left = ( -1 * slideShow.sectionWidth ) + 'px';
				slideShow.slide2 = slideShow.slide1;
				slideShow.slide1 = slideShow.slide0;
				slideShow.slide0 = slideShow.slides[prev];
				var test = slideShow.shifter.id.toString();
				//cl( 'shifter slideshow: ' + $id( .src );
				$( $id( slideShow.shifter.id.toString() ).getElementsByTagName('img')[0] ).before( slideShow.slide0 );
				slideShow.allowClick = true;
				slideShow.play();
				$( '.shifter_link2 > a' ).attr( 'href', slideShow.links[ slideShow.getArrNow() ] );
				$('#photo_caption').fadeIn('fast', function () {});
				return false;
			}); 
			
		} // end if allow click wrapper
		return false; // kill the # link

	},
	
	play: function ()
	{
		
		this.timer = setTimeout( function () { slideShow.slideLeft(); }, slideShow.pauseTime );
	},
	
	pause: function ()
	{
		clearTimeout( this.timer  );
		// this is only for photo slide show
		if ( $id( 'play_btn') ) {
			$id( 'play_btn' ).style.display = 'block';
			$id( 'pause_btn' ).style.display = 'none';
			$('#play_btn').click( function (ev) {
				ev.preventDefault();
				$id( 'play_btn' ).style.display = 'none';
				$id( 'pause_btn' ).style.display = 'block';
				slideShow.slideLeft();			
			});
		}
	},
	

	init: function (imgSize, containerElement, leftEl, rightEl )
	{
		if( $id('shifter') ) {
			$('#shifter').append('<div class="shifter_link1"><a href="#">LEARN MORE</a></div>');
			$('#shifter').append('<div class="shifter_link2"><a href="#">LEARN MORE</a></div>');
			$('#shifter').append('<div class="shifter_link3"><a href="#">LEARN MORE</a></div>');
			$( '.shifter_link2 > a', $id('shifter') ).attr( 'href', slideShow.links[0] );
		} // shifter is on the home page

		
		for ( i in slideShow.slides ) {
			// these arrays have the entire <img> tag - so we need to parse the value to get the image URL
			var srcHold = slideShow.slides[i].match( /src=["|'].+?["|']/).toString().replace(/src=["|']/, '').replace(/['|"]/, '');
			var image = new Image()
			image.src = srcHold;
		}
		this.arrLen = this.slides.length;
		this.count = 100 * this.arrLen;
		this.rightArrow =  rightEl; // $id('right_arrow');
		this.leftArraow =  leftEl;  // $id('left_arrow');
		this.shifter = containerElement; 
		this.slide0 = this.slides[(this.arrLen - 1)];
		this.slide1 = this.slides[0];
		this.slide2 = this.slides[1];
		if ( imgSize ) {
			this.sectionWidth = imgSize;
		}
		$(this.shifter).append( this.slide0 );  // '<div id="slide0">'+slides[(arrLength - 1)]+'</div>'
		$(this.shifter).append( this.slide1 ); //'<div id="slide1">'+slides[0]+'</div>'
		$(this.shifter).append( this.slide2 ); //'<div id="slide2">'+slides[1]+'</div>'
		
		$(this.rightArrow).click( function (ev) {
											cl( 'slide left left left to be called' );
			ev.preventDefault();
			slideShow.slideLeft();
		});
		$(this.leftArraow).click( function (ev) {
											cl( 'slide right to be called' );
			ev.preventDefault();
			slideShow.slideRight();
		});
		if ( $id('photo_caption') ) {
			$('#photo_caption').fadeOut('fast', function () {
				$id('photo_caption').innerHTML = slideShow.captions[slideShow.getArrNow()];
				$('#photo_caption').fadeIn('fast', function () {});
			});
		} // end if id photo caption exists
		this.play();
	} // end init function
	
}; // end slide show object





// this is for the pop ins

fadeBG = {
	windowHeight: 600,
	windowWidth: 800,
	contentTop: 0,
	sizeIframe: function()
	{
		//$('#pop_up_container > iframe').css({backgroundColor: '#ffffff'});
		//$('#pop_up_container > iframe').animate({height: fadeBG.windowHeight, width: fadeBG.windowWidth}, 1)
		$id('up_frame').height = this.windowHeight + 'px';
		$id('up_frame').width = this.windowWidth + 'px';
	}, // end size Iframe function
	getDocHeight: function ()
	{
		var db = document.body;
		var de = document.documentElement
		return Math.max(
			Math.max(db.scrollHeight, de.scrollHeight),
			Math.max(db.offsetHeight, de.offsetHeight),
			Math.max(db.clientHeight, de.clientHeight)
		);
	},
	
	getBGcontents: function(getcontent, args, callback )
	{
		if ( !$id(fade_container_id) ) { // if the fade container is not in the dom, add it
			var html = '<div id="' + fade_container_id + '"></div>';
			$('body').prepend( html );
		}
		if ( typeof args == 'undefined' || typeof args == 'object' ) {
			// ok
		} else {
			
			return false;
		}
		var scrollTop = $().scrollTop();
		//var centeringAdd =  Math.round( (winDim.getHeight() - ($id(elID).offsetHeight / 2) ) / 2 );
		//var contentTop = ( scrollTop + centeringAdd ) + 'px';
		//var contentTop = scrollTop + 20;
		$.get( getcontent, args, function (resp)
		{ /*
			$('#'+fade_container_id).css({ 
				opacity: 0, 'z-index': 5, width: window.offsetWidth, height: fadeBG.getDocHeight(),
				top: 0, left: 0, position: 'absolute',
				backgroundColor: '#000000', display: 'block'
			}).fadeTo( 750, .65, function()
			{
			/* */	
				var scrollTop = $().scrollTop();
					setTimeout( function () { // pause for the bg fade in - then add iframe content
					$('body').prepend( '<div id="pop_up_container" style="position: absolute;z-index: 20; left: 50%; margin-left: -'+(fadeBG.windowWidth/2)+'px">'+resp+'</div>' );
					var centeringAdd =  Math.round( (winDim.getHeight() - $id("pop_up_container").offsetHeight) / 2 );
					var contentTop = ( scrollTop + centeringAdd ) + 'px';
					// only if the up frame needs to be resized
					if ( $id('up_frame').offsetWidth < 499 ) {
						//cl( 'going to change the size' );
						fadeBG.sizeIframe();
					}
					$id("pop_up_container").style.top = contentTop;
					$(this).click( function()
					{
						parent.fadeBG.closeBGcontainers();
					}); // end click
					if ( typeof callback == 'function' ) {
						callback()	
					}
				}, // end anon func in set time out pause
				750 ); // end timeout
			//}); // end fade to
			/* */
		}); // leaving data type off (or string) to keep parsing abilities
	
		//var ht = winDim.getHeight();
		// /*
		$('#' + fade_container_id).css({ 
		   opacity: 0, 'z-index': 10, 
		   width: '100%', height: '100%', position: 'absolute', left: 0, top: scrollTop+'px',
		   backgroundColor: '#000000', display: 'block'
		}).fadeTo( 750, 0.6, function() {
			$(this).click( function()
			{	
				$(this).unbind('click');
				fadeBG.closeBGcontainers();
			}); // end click
		})
		/* */
	}, // end getBGcontents
	
	fadeInPopUp: function ( elID, closeID, callback )
	{
		var clickedEl = this;
		$(clickedEl).unbind('click');
		var scrollTop = $().scrollTop();
		if ( !$id(fade_container_id) ) { // if the fade container is not in the dom, add it
			var html = '<div id="' + fade_container_id + '"></div>';
			$('body').prepend( html );
		}
		
		$('#' + fade_container_id).css({ opacity: 0, 'z-index': 10, 
			width: '100%', height: fadeBG.getDocHeight(), position: 'absolute', left: 0, top: 0,
			backgroundColor: '#000000', display: 'block'
		}).fadeTo( 750, 0.6, function () {
			$id(elID).style.display = 'block';
			var scrollTop = $().scrollTop();
			var centeringAdd =  Math.round( (winDim.getHeight() - $id(elID).offsetHeight ) / 2 );
		 	var contentTop = ( scrollTop + centeringAdd ) + 'px';
			if( typeof callback == 'function') {
				callback();
			}
			
			$id(elID).style.top = contentTop;
			
			$('#'+closeID).click( function(ev)
			{	
				$('#'+closeID).unbind('click');
				me_id = elID;
				ev.preventDefault();
				fadeBG.fadeOutPopUp(me_id, clickedEl);
			}); // end click
		});
	}, // fade in pop up
	fadeOutPopUp: function (elID, clickedEl)
	{
		$id(elID).style.display = 'none';
		if ( elID == 'discipline_container' ) { // must be removed to clean it out
			if( $id('discipline_container') ) { // double check it exists
				$('#discipline_container').remove();
			}
		} // end if disc container
		$($id('fade_container')).fadeOut(750, function()
		{
			$($id('fade_container')).remove();	
		});
		$(clickedEl).click( function( ev )
		{
			ev.preventDefault();
			fadeBG.fadeInPopUp('video_holder','video_close');
		}); // CLOSE CLICK
	}, // fade out pop up
	closeBGcontainers: function ()
	{
		$('#' + fade_container_id).unbind('click');
		//if ( $id('up_frame') ) { // prevent the function from running twice
				$('.close_button', $id('up_frame').contentWindow.document).unbind('click');
			
			$($id(fade_container_id)).fadeOut(750, function()
			{
				$($id(fade_container_id)).remove();
			});
		//}
		//$($id('pop_up_container')).fadeOut(750, function()
		//{
			//$id('up_frame').remove();
			$($id('pop_up_container')).remove();	
		//});
	},
	showUploadProgress: function () {
		var scrollTop = $().scrollTop();
		
		var html = '<div id="upload_progress"><img  src="../images/loading.gif" /></div>';
		$('body').prepend( html );
		
		var centeringAdd =  Math.round( (winDim.getHeight() - $id('upload_progress').offsetHeight  ) / 2 );
		$id('upload_progress').style.top = ( scrollTop + centeringAdd ) + 'px';
		$( $id('upload_progress') ).dblclick( function ()
		{
			var answer = confirm( 'Do you want to close the progress bar?' );
			if ( answer ) {
				fadeBG.hideUploadProgress();	
			}
		}); // end double click function
	}, // end upload progress function
	hideUploadProgress: function () {  
		if ( $id( 'upload_progress' ) ) {
			$('#upload_progress').remove();
		} 
	} // end hide upload progress
} // end fadeBG object




path = ( function() 
{
	var loc = window.location.href.toString();
	if ( loc.match(/\/stage\//) ) {
		return '/stage';
	} else {
		return '';
	}
})(); // self executing function to return the current path

// sucker fish IE6 fix
sf = {
	MM_sr: new Array(),
	MM_p: new Array(),
	sfHover: function() {
		if ( !$id("nav") ) { // if there is no navigation id
			return false; // kill the sfhover
		}
		var sfEls = $id("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			$(sfEls[i]).mouseover( function() {
				this.className+=" sfhover";
			});
			$(sfEls[i]).mouseout(function() {
				this.className=this.className.replace("sfhover", "");
			});
		}
	},
	MM_swapImgRestore: function () { //v3.0
	  var i, x, a = this.MM_sr; // init i, x, and set a to MM_sr
	  for(i=0; a && i<a.length && (x = a[i]) && x.oSrc; i++) x.src=x.oSrc; // set the source to the orig. source for all images in MM_sr
	},
	MM_preloadImages: function () { //v3.0
		var d=document; 
		if(d.images){ // make sure there are images in this function
			var i,j = this.MM_p.length, a = this.MM_preloadImages.arguments; 
			for(i=0; i<a.length; i++) { // for the number of arguments inserted into this function
				if (a[i].indexOf("#")!=0){ // I think this is supposed to be -1, as in not present
					this.MM_p[j]=new Image; // j is set to the length of pre-existing preloaded images
					this.MM_p[j++].src=a[i];
				} // end if 
			} // end for loop
		}
	},
	MM_findObj: function (n, d) { //v4.01
		var p,i,x;  
		if(!d) d=document; // if no context is set, set it to document
		if( (p = n.indexOf("?")) > 0 && parent.frames.length ) { // if no parent frames this does not execute
			d=parent.frames[n.substring(p+1)].document; 
			n=n.substring(0,p);
		}
		if( !(x=d[n]) && d.all) x=d.all[n]; 
		for (i=0; !x && i<d.forms.length; i++) x=d.forms[i][n];
		for(i=0; !x &&d.layers&&i<d.layers.length;i++) x= this.MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) 
			x=d.getElementById(n); 
		return x;
	},
	MM_swapImage: function () { //v3.0
		var i,j=0,x,a= this.MM_swapImage.arguments;  
		for(i=0; i < (a.length-2); i+=3 ) {
			if ((x=this.MM_findObj(a[i]))!=null){
				this.MM_sr[j++]=x; 
				if(!x.oSrc) x.oSrc=x.src; 
				x.src=a[i+2];
			} // end if obj not null
		} // end for loop
	} // end swap image
}; // end sucker fish ( sf ) object literal




///added by vb 041309
function change(id, newClass) {
	if (document.getElementById(id) == null){
		//no object
	}else{
		document.getElementById(id).className=newClass;
	}
	
	
	
}

function openCenterWindow(URL,winName,w,h,features) {

  // if screen.dimension is true (available), 
  // then calculate the position using that value, else use a fixed value
  xPos = (screen.width) ? (screen.width-w)/2 : 50;
  yPos = (screen.height) ? (screen.height-h)/2 : 50;
  
  // assemble all window settings from calculations and parameters
  settings = 'height='+h+',width='+w+',top='+yPos+',left='+xPos+','+features
  
  // open the window
 var test =  window.open(URL,winName,settings);
test.focus();
return test;
 
}

//end added




///////////////////////////////////////////////////////////////////////
// MUSIC PLAYER POP UP

function listenNowPop(url){

var winl = (screen.width-400);
//var wint = (screen.height-200);
	my_win_object =  window.open( url, "music_player", "status = 0, location = 0, menubar=0, toolbar=0, top=20, left="+winl+", height = 150, width = 400, resizable = 0" );

 my_win_object.focus();
}


///////////////////////////////////
//Email newsletter and mobile signup clear and restore
function emailFocus(thisELE){
	if(thisELE.value=="Enter your email"){
		thisELE.value='';
		inputHandle="newsletter";
	}else if(thisELE.value=="Enter mobile number"){
		thisELE.value='';
		inputHandle="mobile";
}

	thisELE.onblur=function(){
  		if(thisELE.value=='' && inputHandle=="newsletter"){
   			thisELE.value="Enter your email"
   		}else if(thisELE.value=='' && inputHandle=="mobile"){
   			thisELE.value="Enter mobile number"
   		}
  	}
};

///////////////////////////////////
//eTapestry FORM Popup for email

function popWindow(wName){
	//reset the newsletter/mobile switch
		$("#update_switch").show();
		$("#newsletter_input").hide();
		
	  xPos = (screen.width) ? (screen.width-770)/2 : 50;
  yPos = (screen.height) ? (screen.height-600)/2 : 50;
	features = 'width=770,height=600,toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes, top='+yPos+', left='+xPos+'';
	pop = window.open('',wName,features);
		if(pop.focus){
		 	pop.focus(); 
		}
	return true;
}

//all other eTapestry FORM Popups
function formPop(URL){
	  xPos = (screen.width) ? (screen.width-770)/2 : 50;
  yPos = (screen.height) ? (screen.height-600)/2 : 50;
	features = 'width=770,height=600,toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes, top='+yPos+', left='+xPos+'';
	pop = window.open(URL,'formPop',features);
		if(pop.focus){
		 	pop.focus(); 
		}
	return false;
}



var orch = {
	callDisp: function ( disc ) {
		
		$.get( '/ajax_content/orchestra_chorus.php', { 'disc': disc }, function ( resp ) { // callback function
			// set js scroll?
			$('body').prepend( resp );
			
			fadeBG.fadeInPopUp( 'discipline_container', 'close_btn', function () {
				$('.jScrollPane').jScrollPane();
			}); // end fadin and callback

		}); // end callback and get BG contents	
	}, // end call discipline
	toggleView: function ( show ) { // key_info
		
		if ( show == 'graphic' ) {
			$id('list_Chorus').style.display = 'none';
			$id('list_Orchestra').style.display = 'none';
			//$id('key_info').style.display = 'none';
			$id('graphic_view').style.display = 'block';
			// switch images
			$id('switch_view').innerHTML = "\
			<p>View &nbsp;</p>\
<img id=\"Orchestra\" width=\"24\" height=\"15\" border=\"0\" src=\"/images/orchestra_view_hov.gif\" alt=\"Graphic View\" name=\"Orchestra\"/>\
\
<a href=\"#\" onclick=\"orch.toggleView('list'); return false;\" onmouseout=\"sf.MM_swapImgRestore()\" onmouseover=\"sf.MM_swapImage('Column','','/images/column_view_hov.gif',1)\">\
<img id=\"Column\" width=\"14\" height=\"15\" border=\"0\" src=\"/images/column_view.gif\" alt=\"List View\" name=\"Column\"/>\
</a>\
";
			
		} else {
			$id('list_Chorus').style.display = 'block';
			$id('list_Orchestra').style.display = 'block';
			//$id('key_info').style.display = 'block';
			$id('graphic_view').style.display = 'none';			
			// switch images
			
			$id('switch_view').innerHTML = "\
			<p>View &nbsp;</p>\
<a href=\"#\" onclick=\"orch.toggleView('graphic'); return false;\" onmouseout=\"sf.MM_swapImgRestore()\" onmouseover=\"sf.MM_swapImage('Orchestra','','/images/orchestra_view_hov.gif',1)\">\
<img id=\"Orchestra\" width=\"24\" height=\"15\" border=\"0\" src=\"/images/orchestra_view.gif\" alt=\"Graphic View\" name=\"Orchestra\"/>\
</a>\
\
<img id=\"Column\" width=\"14\" height=\"15\" border=\"0\" src=\"/images/column_view_hov.gif\" alt=\"List View\" name=\"Column\"/>\
";
			
		} // end if else current view
	} // end toggle view
}// end orchestra object



function htmlentities (string, quote_style) {
    // Convert all applicable characters to HTML entities  
    // 
    // version: 905.1002
    // discuss at: http://phpjs.org/functions/htmlentities
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}

function html_entity_decode( string, quote_style ) {
    // Convert all HTML entities to their applicable characters  
    // 
    // version: 905.1002
    // discuss at: http://phpjs.org/functions/html_entity_decode
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');
    // *     returns 2: '&lt;'
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }

    // &amp; must be the last character when decoding!
    delete(histogram['&']);
    histogram['&'] = '&amp;';

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    
    return tmp_str;
}

function get_html_translation_table(table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 905.412
    // discuss at: http://phpjs.org/functions/get_html_translation_table
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brettz9.blogspot.com)
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';

    useTable 	  = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';

    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw Error("Table: "+useTable+' not supported');
        // return false;
    }

    // ascii decimals for better compatibility
    entities['38'] = '&amp;';
    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#039;';
    }
    entities['60'] = '&lt;';
    entities['62'] = '&gt;';

    if (useTable === 'HTML_ENTITIES') {
	    entities['160'] = '&nbsp;';
	    entities['161'] = '&iexcl;';
	    entities['162'] = '&cent;';
	    entities['163'] = '&pound;';
	    entities['164'] = '&curren;';
	    entities['165'] = '&yen;';
	    entities['166'] = '&brvbar;';
	    entities['167'] = '&sect;';
	    entities['168'] = '&uml;';
	    entities['169'] = '&copy;';
	    entities['170'] = '&ordf;';
	    entities['171'] = '&laquo;';
	    entities['172'] = '&not;';
	    entities['173'] = '&shy;';
	    entities['174'] = '&reg;';
	    entities['175'] = '&macr;';
	    entities['176'] = '&deg;';
	    entities['177'] = '&plusmn;';
	    entities['178'] = '&sup2;';
	    entities['179'] = '&sup3;';
	    entities['180'] = '&acute;';
	    entities['181'] = '&micro;';
	    entities['182'] = '&para;';
	    entities['183'] = '&middot;';
	    entities['184'] = '&cedil;';
	    entities['185'] = '&sup1;';
	    entities['186'] = '&ordm;';
	    entities['187'] = '&raquo;';
	    entities['188'] = '&frac14;';
	    entities['189'] = '&frac12;';
	    entities['190'] = '&frac34;';
	    entities['191'] = '&iquest;';
	    entities['192'] = '&Agrave;';
	    entities['193'] = '&Aacute;';
	    entities['194'] = '&Acirc;';
	    entities['195'] = '&Atilde;';
	    entities['196'] = '&Auml;';
	    entities['197'] = '&Aring;';
	    entities['198'] = '&AElig;';
	    entities['199'] = '&Ccedil;';
	    entities['200'] = '&Egrave;';
	    entities['201'] = '&Eacute;';
	    entities['202'] = '&Ecirc;';
	    entities['203'] = '&Euml;';
	    entities['204'] = '&Igrave;';
	    entities['205'] = '&Iacute;';
	    entities['206'] = '&Icirc;';
	    entities['207'] = '&Iuml;';
	    entities['208'] = '&ETH;';
	    entities['209'] = '&Ntilde;';
	    entities['210'] = '&Ograve;';
	    entities['211'] = '&Oacute;';
	    entities['212'] = '&Ocirc;';
	    entities['213'] = '&Otilde;';
	    entities['214'] = '&Ouml;';
	    entities['215'] = '&times;';
	    entities['216'] = '&Oslash;';
	    entities['217'] = '&Ugrave;';
	    entities['218'] = '&Uacute;';
	    entities['219'] = '&Ucirc;';
	    entities['220'] = '&Uuml;';
	    entities['221'] = '&Yacute;';
	    entities['222'] = '&THORN;';
	    entities['223'] = '&szlig;';
	    entities['224'] = '&agrave;';
	    entities['225'] = '&aacute;';
	    entities['226'] = '&acirc;';
	    entities['227'] = '&atilde;';
	    entities['228'] = '&auml;';
	    entities['229'] = '&aring;';
	    entities['230'] = '&aelig;';
	    entities['231'] = '&ccedil;';
	    entities['232'] = '&egrave;';
	    entities['233'] = '&eacute;';
	    entities['234'] = '&ecirc;';
	    entities['235'] = '&euml;';
	    entities['236'] = '&igrave;';
	    entities['237'] = '&iacute;';
	    entities['238'] = '&icirc;';
	    entities['239'] = '&iuml;';
	    entities['240'] = '&eth;';
	    entities['241'] = '&ntilde;';
	    entities['242'] = '&ograve;';
	    entities['243'] = '&oacute;';
	    entities['244'] = '&ocirc;';
	    entities['245'] = '&otilde;';
	    entities['246'] = '&ouml;';
	    entities['247'] = '&divide;';
	    entities['248'] = '&oslash;';
	    entities['249'] = '&ugrave;';
	    entities['250'] = '&uacute;';
	    entities['251'] = '&ucirc;';
	    entities['252'] = '&uuml;';
	    entities['253'] = '&yacute;';
	    entities['254'] = '&thorn;';
	    entities['255'] = '&yuml;';
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}




function trHov(){
    $("tr").mouseover(function(){
      $(this).addClass("myHov");
    }).mouseout(function(){
       $(this).removeClass("myHov");
    });
 };

function bubbles() {
//calendar pop ups
  $('.event_container').each(function () {
    // options
    var distance = 6;
    var time = 200;
    var hideDelay = 80;

    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('p', this);
    var popup = $('.popup', this).css('opacity', 0);
	

    // set the mouseover and mouseout on both element
    $([trigger.get(0), popup.get(0)]).mouseover(function () {
	//get the height of this particular bubble
	var bubble_height=$([ popup.get(0)]).height();
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
		// don\'t trigger the animation again if we\'re being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;
        // reset position of popup box
        popup.css({
          top:-(bubble_height-5),
          left: -55,
          display: 'block' // brings the popup back in to view
        })

        // (we\'re using chaining on the popup) now animate it\'s opacity and position
        .animate({
          top: '-=' + distance + 'px',
          opacity: 1
        }, time, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      }
    }).mouseout(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });
  });
  
  // question pop ups
    $('.legend_item').each(function () {
    // options
    var distance = 6;
    var time = 200;
    var hideDelay = 80;

    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('a', this);
    var popup = $('.popup', this).css('opacity', 0);
	

    // set the mouseover and mouseout on both element
    $([trigger.get(0), popup.get(0)]).mouseover(function () {
	//get the height of this particular bubble
	var bubble_height=$([ popup.get(0)]).height();
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
		// don't trigger the animation again if we're being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;
        // reset position of popup box
        popup.css({
          top:-(bubble_height-5),
          left: -55,
          display: 'block' // brings the popup back in to view
        })

        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          top: '-=' + distance + 'px',
          opacity: 1
        }, time, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      }
    }).mouseout(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });
  });
};
