var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
function myXMLHttpRequest() {
  var xmlhttplocal;
  try {
    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
    xmlhttplocal=false;
  }
 }

if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
 try {
  var xmlhttplocal = new XMLHttpRequest();
 } catch (e) {
  var xmlhttplocal=false;
  alert('couldn\'t create xmlhttp object');
 }
}
return(xmlhttplocal);
}

function sndtagvote(call,tag,rate) {
  xmlhttp.open("GetNoCache", "/addtagscore.php?call=" + call + "&tag=" + tag + "&rating=" + rate);
  xmlhttp.onreadystatechange = handleResponse;
  xmlhttp.send(null);
}


function sndtag(call,tag) {
  xmlhttp.open("GetNoCache", "/addtag.php?call=" + call + "&tag=" + tag);
  xmlhttp.onreadystatechange = handleResponse;
  xmlhttp.send(null);
}



function snddlReq(id_num) {
    var starelement = document.getElementById('star_long'+id_num);
    starelement.innerHTML = '<em>Loading ...</em>';
  xmlhttp.open("GetNoCache", "/allowvote.php?call=" + id_num);
  xmlhttp.onreadystatechange = handleResponse;
  xmlhttp.send(null);

}

function sndReq(vote,id_num) {

    var starelement = document.getElementById('star_long'+id_num);
    starelement.innerHTML = '<em>Loading ...</em>';
    xmlhttp.open("GetNoCache", "/addscore.php?score=" + vote + "&call=" + id_num);
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(null);
	
}


function handleResponse() {
    if(xmlhttp.readyState == 4){
		 if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
            
	      if(update[2] != null && update[3] != null)
           	changeText(update[2],update[3]);
	
        }
		
		 }
    }
}



function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"

    if (DOM) {
        var viewer = document.getElementById(div2show)
        viewer.innerHTML=text
    }
    else if(IE) {
        document.all[div2show].innerHTML=text
    }
}

function clearText(thefield){
	thefield.value = "";
} 


// Pop-Up Embedder Script by David Battino, www.batmosphere.com; Object tag implementation by Mark Levitt, http://digitalmedia.oreilly.com
var UniqueID = 314 // Make each link open in a new window.
var newWinOffset = 0 // Position of first pop-up
function PlayerOpen(soundfilepath) {

PlayWin = window.open('',UniqueID,'width=320,height=190,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
PlayWin.focus(); 
var winContent = "<HTML><HEAD><TITLE>DONTCALLTHIS.COM</TITLE></HEAD><BODY bgcolor='#CDDB9D'>";
winContent += "<OBJECT width='300' height='42'>";
winContent += "<param name='SRC' value='" +  soundfilepath + "'>";
winContent += "<param name='AUTOPLAY' VALUE='true'>";
winContent += "<param name='CONTROLLER' VALUE='true'>";
winContent += "<param name='BGCOLOR' VALUE='#CDDB9D'>";
winContent += "<EMBED SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='FALSE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#CDDB9D'></EMBED>";
winContent += "</OBJECT>";

winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='"+soundfilepath+"'>Download this file</a> <SPAN style='font-size:10px'>(right-click or Option-click)<br /><br />PLEASE RATE THIS CALL AFTER YOU LISTEN TO IT (click on the stars).  Also consider adding a tag describing the call.</SPAN></p>";

winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onClick='javascript:window.close();'></DIV></FORM>";
winContent += "</BODY></HTML>";
PlayWin.document.write(winContent);
PlayWin.document.close(); // "Finalizes" new window
UniqueID = UniqueID + 1
// newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower.
}

function highlight(field) {
        field.focus();
        field.select();
}