function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	///ToggleOptions
	function ToggleOptions(txt){
		var signIn = document.getElementById('SignInText');
		var register = document.getElementById('RegisterText');
		var signInForm = document.getElementById('SignInForm');
		var registerForm = document.getElementById('RegisterForm');
		var err = document.getElementById('LoginRegisterError');
		var tipSignIn = document.getElementById('SignInHelp');
		var tipRegister = document.getElementById('RegisterHelp');
		if (signIn != null && register != null && signInForm != null && registerForm != null){
			switch(txt){
				case 'register':
					signIn.className = '';
					signInForm.className = '';
					register.className = 'selected';
					registerForm.className = 'selected';
					if (tipSignIn != null) tipSignIn.className = '';
					if (err != null) err.style.display = 'none';
					break;
				case 'sign-in':
					signIn.className = 'selected';
					signInForm.className = 'selected';
					register.className = '';
					registerForm.className = '';
					if (tipRegister != null) tipRegister.className = '';
					break;
			}
		}
	}
	///HighlightRow
	function HighlightRow(obj, id, seconds){
		var el = document.getElementById(id);
		if (el != null){
			if (obj.checked){
				if (el.className.indexOf('Selected') > 0){
					el.title = el.className.substring(0, (el.className.length-8));
				}
				else{
					el.title = el.className;
					el.className += 'Selected';			
				}
			}
			else{
				if (el.title == ''){
					if (el.className.indexOf('Selected') > 0)
						el.title = el.className.substring(0, (el.className.length-8));
					else
						el.title = el.className;
				}
				el.className = el.title;
				el.title = '';

			}
		}
		//UpdateSongListStats();
	}
	///UpdateSongListStats
	function UpdateSongListStats(){
		var s = '';
		var el = document.getElementById('SongListStats');
		var totalSeconds = songListDuration;
		if (el != null){

			s += songListCount + ' song';
			if (songListCount != 1) s += 's';
			var hours = 0;
			var minutes = 0;
			var seconds = 0;
			if (totalSeconds > 0){
				if (totalSeconds > 3600){
					while (totalSeconds > 3600){
						hours ++;
						totalSeconds -= 3600
					}
				}
				if (totalSeconds > 60){
					while (totalSeconds > 60){
						minutes ++;
						totalSeconds -= 60
					}
				}	
				seconds = totalSeconds;
			}
			if (hours > 0) s += ', ' + hours + ' hour';
			if (hours > 1) s += 's';
			if (minutes > 0) s += ', ' + minutes + ' minute';
			if (minutes > 1) s += 's';
			if (seconds > 0) s += ', ' + seconds + ' second';
			if (seconds > 1) s += 's';
			el.innerHTML = s;
		}
	}

	function toggleSubmit(obj){
		count=0
		while(document.getElementById("GlmGenres"+count)){
			document.getElementById("GlmGenres"+count).style.display="none"
			count++
		}
		document.getElementById("GlmGenres"+obj.selectedIndex).style.display="block"
	}

	function echeck(str) {

			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)

			if (str.indexOf(at)==-1){
			   alert("Please enter a valid email address")
			   return false
			}

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert("Please enter a valid email address")
			   return false
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    alert("Please enter a valid email address")
			    return false
			}

			 if (str.indexOf(at,(lat+1))!=-1){
			    alert("Please enter a valid email address")
			    return false
			 }

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			    alert("Please enter a valid email address")
			    return false
			 }

			 if (str.indexOf(dot,(lat+2))==-1){
			    alert("Please enter a valid email address")
			    return false
			 }

			 if (str.indexOf(" ")!=-1){
			    alert("Please enter a valid email address")
			    return false
			 }

	 		 return true					
		}

	function ValidateForm(){
		var emailID=document.mailingList.emailSignup

		if ((emailID.value==null)||(emailID.value=="")){
			alert("Please enter a valid email address")
			emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
		return true
	 }
	
   	var musicGenre = new Array();
		musicGenre[1] = '<a href="http://s39451.gridserver.com/assets/playlist/jazz/jazzPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/jazz/jazzPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Jazz</a>';
      	musicGenre[2] = '<a href="http://s39451.gridserver.com/assets/playlist/ballads/balladsPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/ballads/balladsPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Ballads</a>';
      	musicGenre[3] = '<a href="http://s39451.gridserver.com/assets/playlist/rb_funk_disco_motown/rb_funkPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/rb_funk_disco_motown/rb_funkPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to R&amp;B/Funk/Disco &amp; Motown</a>';
      	musicGenre[4] = '<a href="http://s39451.gridserver.com/assets/playlist/mediumRock/mediumRockPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/mediumRock/mediumRockPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Medium Rock</a>';
      	musicGenre[5] = '<a href="http://s39451.gridserver.com/assets/playlist/classicRock/classicRockPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/classicRock/classicRockPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Classic Rock</a>';
      	musicGenre[6] = '<a href="http://s39451.gridserver.com/assets/playlist/modernRock/modernRockPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/modernRock/modernRockPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Modern Rock</a>';
      	musicGenre[7] = '<a href="http://s39451.gridserver.com/assets/playlist/contemporary_dance/contemporary_dancePopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/contemporary_dance/contemporary_dancePopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Contemporary &amp; Dance</a>';
      	musicGenre[8] = '<a href="http://s39451.gridserver.com/assets/playlist/latin_specialty/latin_specialtyPopup.html" target="_blank" onclick="window.open(\'http://s39451.gridserver.com/assets/playlist/latin_specialty/latin_specialtyPopup.html\',\'audioPlayer\',\'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500\'); return false">Click to listen to Latin &amp; Specialty</a>';

	var musicGenreId = 0
	var musicGenreLength = musicGenre.length

   	function swapNext() {
		musicGenreId++
		//alert(musicGenre.length)
		if (musicGenreId > musicGenre.length - 1) {
			musicGenreId = musicGenre.length - 1
		}else{
   			document.getElementById("musicGenre").innerHTML = musicGenre[musicGenreId];
		}
   	}

   	function swapPrevious() {
		musicGenreId--
		//alert(tempID)
 		if (musicGenreId <= 0) {
			musicGenreId = 1
		}else{
  			document.getElementById("musicGenre").innerHTML = musicGenre[musicGenreId];
		}
   	}
	
	function popUp(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=382,height=500');");
	}

