// Common JavaScript functions

window.addEvent('domready',function(){

	// Create s SmoothScroll instance for later use
	new SmoothScroll({
			duration:2500,
			fps:50,
			transition:Fx.Transitions.quartInOut
	});
	
	// Initialize sound manager class to play sound
	var myElement = $('musicOn');
	var myElementOff = $('musicOff');
	var myVolumeLevel = 15;
	
	//Play sound on body onload 
	soundManager.onload = function() {
		//don't play music if cookie is off
		if (Cookie.get('bgMusic') == 'stop' ) {
			myElement.removeClass('current');
			myElementOff.addClass('current');
		} else {
			if (Cookie.get('bgMusic') == 'play')
			{
				 // soundManager is ready to use - createSound() / play() etc. can now be called
				 soundManager.createSound({
					 id:'mySound',
					 url:strMusicFileURL,
					 onfinish:function() {
					   soundManager.play('mySound');
					   soundManager.setVolume('mySound', myVolumeLevel);
					 }
				})
	
				soundManager.play('mySound');
				soundManager.setVolume('mySound', myVolumeLevel);
				
				myElementOff.removeClass('current');
				myElement.addClass('current');

			}
			else
			{
				myElement.removeClass('current');
				myElementOff.addClass('current');
			}
		}	
		
	}
	
	
	myElement.addEvent('click', function(){
			
			if ( Cookie.get('bgMusic') == 'stop') {
				 Cookie.remove('bgMusic');
			}

			if ( Cookie.get('bgMusic') == 'stop') {
				document.cookie = "name=bgMusic; expires=13/06/2003 00:00:00; path=/";
			}

			if ( Cookie.get('bgMusic') == 'stop') {
				Cookie.set('bgMusic', 'play', {duration: 3000, path: '/'});
			}
						
			soundManager.createSound({
				 id:'mySound',
				 url:strMusicFileURL,
				 onfinish:function() {
				   soundManager.play('mySound');
				   soundManager.setVolume('mySound', myVolumeLevel);
				 }
			});
		 
			soundManager.play('mySound');
			soundManager.setVolume('mySound', myVolumeLevel);
			this.addClass('current');
			
			myElementOff.removeClass('current');						
	});
									
	myElementOff.addEvent('click', function(){

			soundManager.pause('mySound');
			Cookie.set('bgMusic', 'stop', {duration: 3000, path: '/'});

			this.addClass('current');
			myElement.removeClass('current');
			 
	});
	 
});

// function to bookmark a page
function CreateBookmarkLink(strTitle, strLink) {

	strVersion = navigator.appVersion;
	strVersion = strVersion.toLowerCase();

	if( document.all ) { // IE Favorite
	
		window.external.AddFavorite( strLink, strTitle); 
	} else if (window.sidebar  && strVersion.indexOf('safari') == -1 ) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(strTitle, strLink,"");
	}
	else { // Opera Hotlist
		alert('To bookmark this site, click Bookmarks | Add bookmark or press Ctrl+D.' );
	}
	 

}

// function to navigate to a URL
function twu_goToURL(strURL)
{
    if (strURL != "")
    {
      location.href = document.URL + strURL;
    }
}