var soundoff = false;
var playstop = false;
var playon	 = false;
var framesize = 0;

function doInit(){
	if(framesize == 2){
		top.frames["WELLIFE_HIDDEN"].wellife_mp_Setting();
		document.wellife_mp_form.showtitle.value = top.frames[1].welllife_mp_showtitle;
		obj = document.getElementById('Play');
		obj.src = eval("'images/musicplayer/FooterPlay_over.gif'");
		playon = true;
	}
}

function doMute(){
	if(framesize == 2){
		top.frames["WELLIFE_HIDDEN"].wellife_mp_Mute();

		if(soundoff == true){
			obj = document.getElementById('sound');
			obj.src = 'images/musicplayer/FooterSound_on.gif';

			obj = document.getElementById('Play');
			obj.src = eval("'images/musicplayer/FooterPlay_over.gif'");

			obj = document.getElementById('Stop');
			obj.src = eval("'images/musicplayer/FooterStop.gif'");

			soundoff = false;
			top.frames["WELLIFE_HIDDEN"].wellifemp.Play();

			doPlaying("on");
		} else {
			obj = document.getElementById('sound');
			obj.src = 'images/musicplayer/FooterSound_off.gif';

			obj = document.getElementById('Play');
			obj.src = eval("'images/musicplayer/FooterPlay.gif'");

			obj = document.getElementById('Stop');
			obj.src = eval("'images/musicplayer/FooterStop.gif'");

			soundoff = true;
			top.frames["WELLIFE_HIDDEN"].wellifemp.Pause();

			doPlaying("off");
		}
	}
}

function doPlaying(val){
	if(val == "off"){
		playing_on.style.display = "none";
		playing_off.style.display = "";
	} else {
		playing_on.style.display = "";
		playing_off.style.display = "none";
	}
}

function doStop(){
	if(framesize == 2){
		top.frames["WELLIFE_HIDDEN"].wellife_mp_StopTrack();
		playstop = true;

		obj = document.getElementById('Play');
		obj.src = eval("'images/musicplayer/FooterPlay.gif'");

		obj = document.getElementById('Stop');
		obj.src = eval("'images/musicplayer/FooterStop_over.gif'");

		doPlaying("off");
	}
}

function doPlay(){
	if(framesize == 2){
		top.frames["WELLIFE_HIDDEN"].wellife_mp_Play();
		playon = true;
		soundoff = false;

		obj = document.getElementById('Play');
		obj.src = eval("'images/musicplayer/FooterPlay_over.gif'");

		obj = document.getElementById('Stop');
		obj.src = eval("'images/musicplayer/FooterStop.gif'");

		doPlaying("on");
	}
}

function doOver(val) {
	obj = document.getElementById(val);

	if(val == "Play"){
		if(playon == false){
			obj.src = eval("'images/musicplayer/Footer"+val+"_over.gif'");
		}
	} else if(val == "Stop"){
		if(playstop == false){
			obj.src = eval("'images/musicplayer/Footer"+val+"_over.gif'");
		}
	}
}

function doOut(val) {
	obj = document.getElementById(val);

	if(val == "Play"){
		if(playon == false){
			obj.src = eval("'images/musicplayer/Footer"+val+".gif'");
		}
	} else if(val == "Stop"){
		if(playstop == false){
			obj.src = eval("'images/musicplayer/Footer"+val+".gif'");
		}
	}
}

function doPlayList(){
	if(framesize == 2){
		var plist = wellife_mp_PlayList();
		var total =  top.frames["WELLIFE_HIDDEN"].wellife_mp_TrackName.length;

		document.write('<div id="" style="position:relative ; z-index:10">') ;
		
		document.write('<div id="musicplay" style="position:absolute ; left:-146; top:-'+(total*20)+' ; z-index:0 ; display:none">') ;
		document.write('<!-- Å×ÀÌºíÀÇ ½ÃÀÛ -->');
		document.write('<table width="156" border="0" cellspacing="0" cellpadding="0">');
		document.write('	<tr>');
		document.write('	<td><img src="images/musicplayer/FooterTable01.gif"></td>');
		document.write('	</tr>');
		document.write('	<tr>');
		document.write('	<td background="images/musicplayer/FooterTableBg.gif">');
		document.write('	<!-- Å×ÀÌºíÀÇ ½ÃÀÛ -->');
		document.write('		<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.write(plist);
		document.write('		</table>');
		document.write('	<!-- Å×ÀÌºíÀÇ ³¡ -->');
		document.write('	</td>');
		document.write('	</tr>');
		document.write('	<tr>');
		document.write('	<td><img src="images/musicplayer/FooterTable02.gif"></td>');
		document.write('	</tr>');
		document.write('</table>');
		document.write('<!-- Å×ÀÌºíÀÇ ³¡ -->');
		document.write('</div>');

		document.write('</div>') ;
	}
}

function doPlayListView(){
	if(framesize == 2){
		obj = document.getElementById("musicplay") ;
		if (obj.style.display == "none") {
			obj.style.display = "" ;
		} else {
			obj.style.display = "none" ;
		}
	}
}

function wellife_mp_PlayList(){
	var elm_music = "";
	var total = top.frames["WELLIFE_HIDDEN"].wellife_mp_TrackName.length;
	var list_num = 0;

	if(top.frames["WELLIFE_HIDDEN"].wellife_mp_Track != null ){
		for (i=0; i <= top.frames["WELLIFE_HIDDEN"].wellife_mp_TrackName.length -1; i++)
		{
			list_num = i + 1;

			/*
			if(list_num==(top.frames["WELLIFE_HIDDEN"].wellife_mp_CurrentTrack+1)){
				bold = i;
			} else {
				bold = 0;
			}
			*/
			elm_music = elm_music + '<tr>';
			elm_music = elm_music + '<td id="t_m'+list_num+'" style="cursor:hand; FONT-SIZE:10px; COLOR:#876C53;'
			elm_music = elm_music + '		 FONT-FAMILY:Tahoma; padding-left:10px; LINE-HEIGHT:15px;"';
			elm_music = elm_music + ' onClick="javascript:doMusicSelect('+total+','+list_num+');"';
			elm_music = elm_music + ' onMouseOver="javascript:musiclistmouseover('+total+','+list_num+');"';
			elm_music = elm_music + ' onMouseOut="javascript:musiclistmouseover('+total+',0);"';
			elm_music = elm_music + '>';
			elm_music = elm_music + getFillZero(list_num);
			elm_music = elm_music + '&nbsp;&nbsp;'+top.frames["WELLIFE_HIDDEN"].wellife_mp_TrackName[i].substring(0,25)
			elm_music = elm_music + '</td>';
			elm_music = elm_music + '</tr>';
			elm_music = elm_music + '<tr>';
			elm_music = elm_music + '<td><img src="images/musicplayer/FooterTableLine.gif" width="156" height="1"></td>';
			elm_music = elm_music + '</tr>';
			//alert(elm_music);
		}
	}
	return elm_music;
}

function doMusicSelect(total, val){
	top.frames["WELLIFE_HIDDEN"].wellife_mp_SelectTrack(val-1);
	musicselect(total, val);
}

function getFillZero(num){
	if(num < 10){
		num = "0" + num
	}
	return num;
}

function musiclistmouseover(total, val) {
	for(i=1; i<=total; i++){
		eval("t_m"+i+".style.color='#858585'");
	}
	if(val > 0){
		eval("t_m"+val+".style.color='#F26522'");
	}
}

function musicselect(total, val) {
	//alert(total + " / " + val);
	for(i=1; i<=total; i++){
		eval("t_m"+i+".style.fontWeight = ''");
	}
	if(val > 0){
		eval("t_m"+val+".style.fontWeight = 'bold'");
	}
}

function doOver(val) {
	obj = document.getElementById(val);

	if(val == "Play"){
		if(playon == false){
			obj.src = eval("'images/musicplayer/Footer"+val+"_over.gif'");
		}
	} else if(val == "Stop"){
		if(playstop == false){
			obj.src = eval("'images/musicplayer/Footer"+val+"_over.gif'");
		}
	}
}

function doOut(val) {
	obj = document.getElementById(val);

	if(val == "Play"){
		if(playon == false){
			obj.src = eval("'images/musicplayer/Footer"+val+".gif'");
		}
	} else if(val == "Stop"){
		if(playstop == false){
			obj.src = eval("'images/musicplayer/Footer"+val+".gif'");
		}
	}
}

