var loading = new Image();
loading.src = '/nm_webkit/libs/images/loadingAnimation.gif';

var waitHTML = '<div class="waitHTML"><img src = "' + loading.src + '" alt = "loading animation" /></div>';

var changeHoverState = true;

var mpsettings_1 = $H({
        mpWidth:625,
        mpHeight:31,
        mpFirstload:true,
        mpDlButton:false,
        mpLoader:false,
        mpAltmediaplayer:'',
        mpDivtag:'',
        mpScrollto:false
});

function ajaxpage_callback(page) {
	// strip leading slash, if it exists
	page = page.replace(/^\//,'');
	switch (page) {
		case 'presskit.php':
		document.body.className = 'nm_currentPage_presskit';
		document.title = 'Press Kit and Photos';
		break;
		
		case 'press.php':
		document.body.className = 'nm_currentPage_pressquotes';
		document.title = 'Press Quotes and Articles';		
		break;
		
		case 'photogallery.php':
		document.body.className = 'nm_currentPage_photogallery';
		document.title = 'Photo Gallery';		
		break;
		
		case 'media.php':
		document.body.className = 'nm_currentPage_media';
		document.title = 'CD/DVD Clips';		
		break;
		
		case 'triobios.php':
		document.body.className = 'nm_currentPage_triobios';
		document.title = 'Lynne Arriale Bio';
		break;
		
		case 'music.php':
		document.body.className = 'nm_currentPage_music';
		document.title = 'The Music of the Trio';
		break;
		
		case 'order.php':
		document.body.className = 'nm_currentPage_order';
		document.title = 'Order CDs';
		break;
		
		case 'itinerary.php':
		document.body.className = 'nm_currentPage_itinerary';
		document.title = 'Itinerary';
		break;
		
		case 'bookinginfo.php':
		document.body.className = 'nm_currentPage_booking';
		document.title = 'Booking Info';
		break;
		
		case 'contact.php':
		document.body.className = 'nm_currentPage_contact';
		document.title = 'Contact Lynne/Lessons';
		break;
	}
	
	pageObservers();
}

function checkrequired(which) {
	var pass=true;
	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
					tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
				tempobj.selectedIndex==0)) {
					pass=false;
					break;
				}
			}
		}
	}
	if (!pass) {
		shortFieldName=tempobj.name.substring(8,30).toUpperCase();
		alert("Please make sure the "+shortFieldName+" field was properly completed.");
		return false;
	}
	else
		return true;
}

function playclip(song) {
	var videoclips = $H({Wrapped:'Wrapped Around Your Finger',IMeanYou:'I Mean You',
						Longing:'Longing',Gumbo:'Crawfish &amp; Gumbo',
						YoungMen:'Ballad of the Sad Young Men',CarryOn:'Carry On',
						Noche:'La Noche',Yada:'Yada Yada Yada',Rhapsody:'I Hear a Rhapsody',
						Tunisia:'A Night in Tunisia',Gentle:'A Gentle Soul',
						
						MeetLynne:'Meet the Artists: Lynne Arriale',MeetRandy:'Meet the Artists: Randy Brecker',
						MeetGeorge:'Meet the Artists: George Mraz',MeetAnthony:'Meet the Artists: Anthony Pinciotti',
						MeetSuzi:'Meet the Artists: Suzi Reynolds',
		
						Braziliana:'Braziliana', AloneTogether:'Alone Together', 
						SevenStepsToHeaven:'Seven Steps to Heaven', ComeTogether:'Come Together',
						BemshaSwing:'Bemsha Swing', MountainOfTheNight:'Mountain of the Night',
						Flamenco:'Flamenco', IkoIko:'Iko Iko', Arise:'Arise', Home:'Home',
						
						PBS:'PBS Profile of a Performing Artist',LynneInterview:'Interview with Woomy Schmidt'});
							
	new Effect.ScrollTo('stage', { duration:0.5, afterFinish:function() {
		$('media_stage').update('<div id="downloadclip"><div id="ipodicon"><a href = "' + song + '.m4v"><img src = "/images/ipodicon.jpg" alt="download this clip" /></a></div><a href = "' + song + '.m4v">Download clip for my iPod</a><br />(control + click in Windows, option + click in Macintosh to initiate download)</div><h1>' + videoclips.get(song) + '</h1><div id="videoframe"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="720" height="497"><param name="src" value="http://lynnearriale.com/' + song + '.mp4" /><param name="target" value="myself" /><param name="controller" value="true" /><param name="autoplay" value="true" /><param name="plugin" value="quicktimeplugin" /><param name="type" value="video/quicktime" /><embed src="http://lynnearriale.com/' + song + '.mp4" width="720" height="497" controller="true" target = "myself" pluginspage="http://www.apple.com/quicktime/download/" autoplay="true" plugin="quicktimeplugin" type="video/quicktime"></embed></object></div>');
	}})
	
}

function adjustheight() {
	if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	/* document.getElementById('content').style.height = (winH - 225) + "px"; */
}

document.observe('dom:loaded', function() {
	if (document.body.className !== "nm_currentPage_home") {
		initAjaxLinks('menublock');	
		initAjaxLinks('pagecontent');
		
		// remove observer from for promoters section
		$$('#nm_id_forpromoters a').each(function(o) {
			o.stopObserving('click');
		});

		$('ordernuancelink').observe('click', function(e) {
			add_tocart('store_cartdisplay','9',1);
			e.stop();
		});
		$('nuancepromo').observe('click', function(e) {		
			add_tocart('store_cartdisplay','9',1);
			e.stop();
		});

		pageObservers();	
	}
	else {
		var bodyHeight = document.viewport.getHeight();
		if (bodyHeight) {
			$('menublocksplash').setStyle({display:'none'});
			var topMargin = Math.round((bodyHeight - 600) / 2);
			$('homeframewrapper').setStyle({marginTop:topMargin + 'px'});
			new Effect.Appear('menublocksplash', { duration:2});	
		}
	}
	
	
	
})

function pageObservers() {
	if (document.body.className == "nm_currentPage_media") {
		$$('#mediaanchors a').each(function(o) {
			o.stopObserving('click');
			o.observe('click', function(e) {
				new Effect.ScrollTo(o.id.replace('_anchor',''), { duration:0.5 });
				e.stop();
			})
		})
				
		$$('.mediaplayer_table td').each(function(o) {
			o.observe('mouseover', function() {
				cursorLink();
				o.setOpacity('0.7');
				o.setStyle({border:'2px #699bcb solid'});
			});
			o.observe('mouseout', function() {
				cursorClear();
				o.setOpacity('1.0');
				o.setStyle({border:'2px #5b5b5b solid'});				
			});
			o.observe('click', function(e) {
				e.stop();
				cursorClear();
				o.setOpacity('1.0');
				o.setStyle({border:'2px #5b5b5b solid'});
				playclip(o.id)								
			});
		});
		
		
		$$('.mediaplayer_table td a').each(function(o) {
			o.stopObserving('click');
		})
	}
	
	if (document.body.className == "nm_currentPage_presskit") {
		$$('#presskitphotos a').each(function(o) {
			o.stopObserving('click');
		})
		
		$$('#presskitanchors a').each(function(o) {
			o.stopObserving('click');
			o.observe('click', function(e) {
				new Effect.ScrollTo(o.id.replace('_anchor',''), { duration:0.5 });
				e.stop();
			})
		})
	}
	
	if (document.body.className == "nm_currentPage_pressquotes") {
		$$('#pressquotesanchors a').each(function(o) {
			o.stopObserving('click');
			o.observe('click', function(e) {
				new Effect.ScrollTo(o.id.replace('_anchor',''), { duration:0.5 });
				e.stop();
			})
		});
		$$('#articles a').each(function(o) {
			o.stopObserving('click');
			o.observe('click', function(e) {
				new Effect.ScrollTo(o.id.replace('_anchor',''), { duration:0.5 });
				e.stop();
			})
		})
	}
	
	if (document.body.className == "nm_currentPage_music") {
		$$('.clips ul li').each(function(o) {
			o.observe('mouseover', function(e) {
				cursorLink();
			})
		});
		$$('.clips ul li').each(function(o) {
			o.observe('mouseout', function(e) {
				cursorClear();
			})
		});
		$$('.clips ul li').each(function(o) {
			o.observe('click', function(e) {
				webkit_playsonglegacy(o.id);
				e.stop();
			})
		});
		$$('.addtocart').each(function(o) {
			o.observe('click', function(e) {
				add_tocart('store_cartdisplay',o.id,1);
				e.stop();
			})
		})
	}
	
	if (document.body.className == "nm_currentPage_booking") {
		$$('#riderdownload a').each(function(o) {
			o.stopObserving('click');
		})
	}
}