﻿var divResult = document.getElementById('result');

// errer message
var errMsg = '<p>It failed in acquisition of the data</p>';

// icon
var imgLoading = '<img src="img/loading.gif" width="32" height="32" alt="Loading">';

var handleSuccess = function(o){
	if(o.status == 200){
		//o.responseText.lengthに1byte紛れる時のチェックもしておく
		if(o.responseText==undefined || o.responseText.length==1){
			divResult.innerHTML = errMsg;
		} else {
			divResult.innerHTML = o.responseText;
		}
	}
};

var handleFailure = function(o){
	if(o.responseText !== undefined){
		divResult.innerHTML = errMsg;
	}
};

var callback =
{
	success:handleSuccess,
	failure:handleFailure,
	argument:['arg1','arg2']
};

function getSearch(){
	var keyword = document.f1.word.value;
	if(!keyword){
		alert('Please input keyword');
		document.f1.word.focus();
		return false;
	}
	var postData = "keyword="+keyword;
	var sUrl = "controller.php";
	sUrl += "?keyword="+keyword;
	sUrl += "&r=" + Math.floor(1000 * Math.random());	//for no cache
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
	divResult.innerHTML = '<div align="center"><p>' + imgLoading + '</p></div>';
	return false;
}

function dispPlayer(mp3){
	var html;
	document.write('<object type="application/x-shockwave-flash" width="200" height="20" data="swf/singlemp3player.swf?file=' + $mp3 + '&autoStart=flase&backColor=FFFFFF&frontColor=333333&songVolume=100&showDownload=false">\n');
	document.write('<param name="movie" value="swf/singlemp3player.swf?file=' + mp3 + '&autoStart=flase&backColor=FFFFFF&frontColor=333333&songVolume=100&showDownload=false" />\n');
	document.write('<param name="wmode" value="transparent" />');
	document.write('</object>');
/*
	html += '<object type="application/x-shockwave-flash" width="200" height="20" data="swf/singlemp3player.swf?file=' + $mp3 + '&autoStart=flase&backColor=FFFFFF&frontColor=333333&songVolume=100&showDownload=false">';
	html += '<param name="movie" value="swf/singlemp3player.swf?file=' + mp3 + '&autoStart=flase&backColor=FFFFFF&frontColor=333333&songVolume=100&showDownload=false" />';
	html += '<param name="wmode" value="transparent" />';
	html += '</object>';
*/
/*
	html += '<object type="application/x-shockwave-flash" width="200" height="20" data="swf/singlemp3player.swf?file=' + mp3 + '&autoStart=flase&backColor=FFFFFF&frontColor=333333&songVolume=100&showDownload=false">';
	html += '<param name="movie" value="swf/singlemp3player.swf?file=' + mp3 + '&autoStart=flase&backColor=FFFFFF&frontColor=333333&songVolume=100&showDownload=false" />';
	html += '<param name="wmode" value="transparent" />';
	html += '</object>';
*/
//	document.open();
//	document.write(html);
//	document.close();
	return;
}

