
	function checksubmit()
	{
		var fm = document.getElementById("frsearch");
		var txt = document.getElementById("searchtxt");
		if(txt.value.length == 0)
		{
			alert("需要输入查询的歌曲名字");
			txt.focus();
			return false;
		}
		
		//alert(txt.value);
		fm.submit();
		
				   
	}

function submitForm()
	{
		var fm = document.getElementById("frsearch");
		var txt = document.getElementById("searchtxt");
		if(txt.value.length == 0)
		{
			alert("需要输入查询的歌曲名字");
			txt.focus();
			return false;
		}
	}


function cutStr(str, strlen){			
	var l,t,c;
	var rtnStr,tmpStr;
	rtnStr = "";
	l = str.length;
	t = 0;
	for(i = 0; i < l; i++){
		tmpStr = str.substr(i, 1);
		c = str.charCodeAt(i);			
		if(c > 255){					
			t = t + 2;
		}
		else{							
			t = t + 1;
		}
		if (t >= strlen){
			rtnStr = rtnStr + "...";
			break;
		}
		else{
			rtnStr = rtnStr + tmpStr;
		}
	}
	return (rtnStr);
}


var playobjinnerhtml='<EMBED src="http://ring.sohu.com/sound/11713338056620000.mp3" name="mediaplayer" HEIGHT="0"  WIDTH="0"  TYPE="audio/mpeg"   AUTOSTART="true" loop="false"></EMBED>';
var ringid=671;


function changsong(files,songname,singer,songid)
{
	playobjinnerhtml='<EMBED src="http://ring.sohu.com/sound/'+files+'" name="mediaplayer" HEIGHT="0"  WIDTH="0"  TYPE="audio/mpeg"   AUTOSTART="true" loop="false"></EMBED>';
	document.getElementById("playobj").innerHTML=playobjinnerhtml;
	if (typeof(document.getElementById("songname"))!= undefined){
		 ringid=songid;	 
		 document.getElementById("songname").innerHTML ="<font color=\"#D0E6FF\">"+cutStr(songname + "[" + singer + "]", 42)+"</font>";		
	}
	playertd = document.getElementById("playerpic");
	playertd.innerHTML="<img  src=images/ring_133.gif  width=186 height=10 border=0>";
       
	// modified 2007-04-13 begin 
	var url="http://ring.sohu.com/audio_log.php?ringid="+ringid+"&trylistentype=1";
        send_request("GET",url,null,"TEXT",processTextResponse);	
        // modified 2007-04-13 end 
}

// modified 2007-04-13 begin 

//定义XMLHttpRequest对象实例
var http_request = false;
//定义可复用的http请求发送函数
function send_request(method,url,content,responseType,callback) {//初始化、指定处理函数、发送请求的函数
	http_request = false;
	//开始初始化XMLHttpRequest对象
	if(window.XMLHttpRequest) { //Mozilla 浏览器
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {//设置MiME类别
			http_request.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) { // IE浏览器
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) { // 异常，创建对象实例失败
		window.alert("不能创建XMLHttpRequest对象实例.");
		return false;
	}
	if(responseType.toLowerCase()=="text") {
		//http_request.onreadystatechange = processTextResponse;
		http_request.onreadystatechange = callback;
	}
	else if(responseType.toLowerCase()=="xml") {
		//http_request.onreadystatechange = processXMLResponse;
		http_request.onreadystatechange = callback;
	}
	else {
		window.alert("响应类别参数错误。");
		return false;
	}
	// 确定发送请求的方式和URL以及是否异步执行下段代码
	if(method.toLowerCase()=="get") {
		http_request.open(method, url, true);
	}
	else if(method.toLowerCase()=="post") {
		http_request.open(method, url, true);
		http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http_request.setRequestHeader("Accept-Language","zh-cn");
	}
	else {
		window.alert("http请求类别参数错误。");
		return false;
	}
	http_request.send(content);
}


// 处理返回文本格式信息的函数
function processTextResponse() {
	if (http_request.readyState == 4) { 
		if (http_request.status == 200) { 
			var p = http_request.responseText;
			//alert(p);
		} else {
			alert("您所请求的页面有异常。");

		}
	}
	else
	{
		//timervar p = document.getElementById("progress");
		//p.innerText = "完成";
		
	}
}

// modified 2007-04-13 end 


function playsong()
{
	if(window.navigator.userAgent.indexOf("MSIE")>=1)
	{
		document.mediaplayer.play();
	}else
	{
		document.getElementById("playobj").innerHTML=playobjinnerhtml;
	}
	playertd = document.getElementById("playerpic");
	playertd.innerHTML="<img  src=images/ring_133.gif  width=186 height=10 border=0>";
}
function stopsong()
{
	if(window.navigator.userAgent.indexOf("MSIE")>=1)
	{	
		if(typeof(document.mediaplayer)!="undefined")
		{
			document.mediaplayer.stop();
		}
	}else
	{
		document.getElementById("playobj").innerHTML="";
	}
	playertd = document.getElementById("playerpic");
	playertd.innerHTML="<img  src=images/ring_133-2.gif  width=186 height=10 border=0>";
}	


function buyring()
{
	//alert(ringid);
    if(typeof(ringid)!='undefined'){
		var url="send.php?ringid="+ringid+"&type=wap&from=1";
		window.open(" "+url+" ","order","width=500,height=600,resizable=1,scrollbars=0,status=no,toolbar=no,location=no,menu=no");
	}
}

function gosend(sid,tp,fr)
{
	//alert(sid);

    	 // modified 2007-04-13 begin
	 var url="http://ring.sohu.com/audio_log.php?ringid="+sid+"&trylistentype="+tp;
	 //alert(url);
	 send_request("GET",url,null,"TEXT",processTextResponse);	
	 // modified 2007-04-13 begin 
    if(typeof(sid)!='undefined'){
		var url="send.php?ringid="+sid+"&type="+tp+"&from="+fr;
		window.open(" "+url+" ","order","width=500,height=600,resizable=1,scrollbars=0,status=no,toolbar=no,location=no,menu=no");
	}
}
function gosend(sid,tp,fr,typeflag)
{
	//alert(sid);
	 // modified 2007-04-13 begin
	 var url="http://ring.sohu.com/audio_log.php?ringid="+sid+"&trylistentype="+typeflag;
	 //alert(url);
	 send_request("GET",url,null,"TEXT",processTextResponse);	
	 // modified 2007-04-13 begin 
    if(typeof(sid)!='undefined'){
		var url="send.php?ringid="+sid+"&type="+tp+"&from="+fr;
		window.open(" "+url+" ","order","width=500,height=600,resizable=1,scrollbars=0,status=no,toolbar=no,location=no,menu=no");
	}
}
function buyrbt()
{
	//alert(ringid);
    if(typeof(ringid)!='undefined'){
		var url="send.php?ringid="+ringid+"&type=rbt&from=1";
		window.open(" "+url+" ","order","width=500,height=600,resizable=1,scrollbars=0,status=no,toolbar=no,location=no,menu=no");
	}
}
