// this script is for internal use

function badMusic (music_id) {
	var req = getXMLRequest();

	if (req) {
		var url = "/best/badmusic.php?music_id=" + music_id;
		req.open('GET', url, false);
		req.send(null);
		mediaplayer_src = req.responseText;
		realplayer_src = mediaplayer_src;
		setupPlayer();
	}
}
function getTopbarPicture(image, f, event)
{
	var height = image.height;
	if (req_object == null) {
		req_object = getXMLRequest();
		
	}

	if (req_object) {
		var url = "http://maplereview.org/best/getTopbarPicture.php?f=" + f + "&r=" + Math.floor(Math.random()*1001);
		req_object.open('GET', url, false);
		req_object.send(null);
		var node=req_object.responseXML.documentElement.childNodes
		// alert(node.item(0).text);
		image.src = node.item(0).text;
		
		if (f == 1) {
			image.height = height;
		}
	}
	
	StopBubble(event);
	
	return false;
}

function StopBubble(e)
{
    if ((e == null) || !e)
        e = window.event;

    e.cancelBubble = true; /* Microsoft */
    if (e.stopPropagation)
        e.stopPropagation(); /* W3C */
}

function getPoetOptions(name)
{
	if (req_object == null) {
		req_object = getXMLRequest();
	}

	if (req_object) {
		var url = "http://maplereview.org/common/getPoetOptions.php?name=" + encodeURIComponent(name);
		
		req_object.open('GET', url, false);
		req_object.send(null);
		
		// var root = req_object.responseXML.documentElement;
		// var node = root.childNodes; // root.SelectSingleNode(@"/poets");
		var poets = req_object.responseXML.getElementsByTagName("poets");

		if (poets[0] != null) {
			return poets[0].childNodes[0].data;
		} else {
			return '';
		}
	}
}


function getPoemOptions(name)
{
	if (req_object == null) {
		req_object = getXMLRequest();
	}
	

	if (req_object) {
		var url = "http://maplereview.org/cpoetry/getPoemOptions.php?name=" + encodeURIComponent(name);

		req_object.open('GET', url, false);
		req_object.send(null);
		
		var poems = req_object.responseXML.getElementsByTagName("poems");

		if (poems[0] != null) {
			return poems[0].childNodes[0].data;
		} else {
			return '';
		}
	}
}


function getSongContent(poem_id)
{		
	if (req_object == null) {
		req_object = getXMLRequest();
	}

	if (req_object) {
		var url = "http://maplereview.org/cpoetry/getSongContent.php?poem_id=" +poem_id;
		
		try {
			req_object.open('GET', url, false);
			req_object.send(null);
			
		} catch (err) {
			return null;
		}
		
		return req_object.responseXML;
	}

	return null;
}


function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Vers?o: 2.1 - 04/09/2007
* Autor: Micox - N¨˘iron Jos¨¦ C. Guimar?es - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    // objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se n?o ¨¦ option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML


    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];

        if(spantemp.tagName){
            opt = document.createElement("OPTION")

   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }

   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  }
 }
 document.body.removeChild(selTemp)
 selTemp = null
}
