function imgChg(name, imgURL)
	{document[name].src=imgURL;}
	
function launch(url)
	{openWin=window.open(url, "openWin", "width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");}

function launchSizeable(url, w, h)
	{openWin=window.open(url, "openWin", "width=" + w + ",height=" + h + ",toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");}

function openWindow(url, w, h)
	{openWin=window.open(url, "openWin", "width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");}

function IsInvalid(field,description,minLen,maxLen) { // Will check to see if field is between minLen and maxLen -1 for minLen will prompt to fill in, but not require a  min length.
	if (!field) return false;
	
	var text;
	text = field.value;
	//text = text.replace( " ", "" );

	while (text != text.replace(" ", ""))
	{ 
		text = text.replace(" ", "");
	}
	
	if ( text.length < 1 )
	{
		alert("Please enter " + description + " before proceeding.");
		field.focus();
		return true;
	}
	
    if (minLen==-1 && field.value=="")
		{alert("Please enter " + description + " before proceeding.");field.focus();return true;}
	if (minLen>0 && field.value.length<minLen)
		{alert("Please enter at least " + minLen + " characters for " + description +".");field.focus();return true;}
	if (maxLen>0 && field.value.length>maxLen)
		{alert("Please enter at most " + maxLen + " characters for " + description +".");field.focus();return true;}
	return false;
}

function NotSelected(field,description) {
	if (field) {
    	if (field.selectedIndex<1)
			{alert ("Please select one of the \"" + description + "\" options.");field.focus();return true;}
	}
	return false;
}

function doTracks(cd)
{
	var tNum, tTrack
	
	tNum=eval('tracks'+cd+'.length');
	
	for (x=0; x<=tNum; x++)
	{
		for (i = document.form1.tracks.options.length; i >= 0; i--)
		{
			document.form1.tracks.options[i] = null;
		}
	}
	
	for (x=0; x<tNum; x++)
	{
		tTrack = eval( 'tracks' + cd + '[' + x + ']' )
		
		if ( tTrack.length > 40 ) 
		{
			tTrack = tTrack.substr(0, 39);
			tTrack = tTrack + '...';
		}
	
		document.form1.tracks.options[x] = new Option( tTrack, tTrack );
	}
}


function loadMusic(cd, track)
{
	var cStop = 0;
	cd = cd + 1;
	track = track + 1;
	document.ASFPlayer.filename = 'audio/' + cd + '/' + track + '.asf';
}

function playMusic( pValue )
{	var oASFPlayer = document.getElementById( "ASFPlayer" );
	
	switch( pValue )
	{
		case 0:
			cStop = 0;
			oASFPlayer.Play();
			
			if (document.form1.cPlay.checked)
			{
				loopPlay();
			}
			
			break;
		case 1:
			cStop = 1;
			oASFPlayer.Stop();
			break;
		case 2:
			loopPlay();
			break;
	}
}
  
function loopPlay() 
{
	var timedelay = 3000;
	
	if ( ( document.form1.cPlay.checked ) && ( cStop == 0 ) )
	{
		if ( document.ASFPlayer.PlayState == 0 )
		{
			if ( document.form1.tracks.options.selectedIndex == document.form1.tracks.options.length - 1 )
			{
				if ( document.form1.cds.options.selectedIndex == document.form1.cds.options.length - 1 )
				{
					document.form1.cds.options[0].selected = true;
					doTracks( document.form1.cds.options[document.form1.cds.options.selectedIndex].value );
				}
				else
				{
					document.form1.cds.options[document.form1.cds.options.selectedIndex + 1].selected = true;
					doTracks( document.form1.cds.options[document.form1.cds.options.selectedIndex].value );
				}
				
				document.form1.tracks.options[0].selected = true;
			}
			else
			{
				document.form1.tracks.options[document.form1.tracks.options.selectedIndex + 1].selected = true;
			}
			
			loadMusic( document.form1.cds.options[document.form1.cds.options.selectedIndex].value - 1, document.form1.tracks.options.selectedIndex );
			document.ASFPlayer.Play();
		}
		
		window.setTimeout("loopPlay();", timedelay);
	}
}  

function popUp()
{
	win = new Window('window_id', {className: "dialog", title: "", top:100, left:350, width: 500,  resizable: false, url: "./ad2.asp", maximizable: false, minimizable: false, height:300,showEffectOptions: {duration:1},hideEffect: Effect.Puff});
	win.setDestroyOnClose(); 
	win.showCenter();
	
	win.onclick = function() {win.close();}

	window.open('./ad.asp','_blank','width=500,height=250,scrollbars=yes');
}