function swapMiniPlayer(ary,ind)
{
        //alert('swapMiniPlayer') ;
	document.getElementById('listenTitle').innerHTML = ary[ind].title ;
        document.qtMiniPlayer.SetURL(ary[ind].src)
}

//function swapAudPlayer(title)
//{
//	document.getElementById('audioTitle').innerHTML = title ;
//}
//
//function swapVidPlayer(title)
//{
//	document.getElementById('videoTitle').innerHTML = title ;
//}

function swapMainImg(img)
{
	document.getElementById('mainImg').src = img.src ;
	document.getElementById('imgTitle').innerHTML = img.title ;
}





//AJAX=====================================================================

function ajaxFunc(id,myUrl,params)
{
    if (typeof id == 'string') {
        elmnt = document.getElementById(id) ;
    } else {
        elmnt = id ;
    }
    
    var ajObj = new ajaxObject(myUrl) ;
    ajObj.callback = function(responseText, responseStatus, rsponseXML) {
        if (responseStatus==200) {
            elmnt.innerHTML = responseText ;
        }
        //alert(responseText) ;
    }
    
    var pString = '?' ; 
    var key = true ;
    
    for (i=0; i<params.length; i++)
    {
	
        parm = params[i].toString() ;
        parm = parm.replace(/\//g,'%2F') ;
	if (key){
	        pString += encodeURIComponent(parm) + '=' ;
	} else {
	        pString += encodeURIComponent(parm) + '&' ;
	}
	
	key = (key == true) ? false : true ;

//        pString += encodeURIComponent(params[i]) + '/' ;
    }
    
    //alert(pString) ;
    
    ajObj.update(pString) ;
}


function ajaxObject(url, callbackFunction) {
    var that=this;      
    this.updating = false;
    this.abort = function() {
        if (that.updating) {
            that.updating=false;
            that.AJAX.abort();
            that.AJAX=null;
        }
    }
    this.update = function(passData,postMethod, stamp) {
        if (stamp == null) {
            stamp = true ;
        }
        
        if (that.updating) { return false; }
        that.AJAX = null;                          
        if (window.XMLHttpRequest) {              
            that.AJAX=new XMLHttpRequest();              
        } else {                                  
            that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
        }                                             
        if (that.AJAX==null) {                             
            return false;                               
        } else {
            that.AJAX.onreadystatechange = function() {  
                if (that.AJAX.readyState==4) {             
                    that.updating=false;                
                    that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
                    that.AJAX=null;                                         
                }                                                      
            }                                                        
            that.updating = new Date();
            
            if (stamp)
            {
                if ((/post/i.test(postMethod))) {
                    var uri=urlCall+'/'+that.updating.getTime();
                    that.AJAX.open("POST", uri, true);
                    that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    that.AJAX.setRequestHeader("Content-Length", passData.length);
                    that.AJAX.send(passData);
                } else {
                    var uri=urlCall+'/'+passData+'&timestamp='+(that.updating.getTime()); 
                    that.AJAX.open("GET", uri, true);                             
                    that.AJAX.send(null);                                         
                }              

            } else {

                if ((/post/i.test(postMethod))) {
                    var uri=urlCall+'/' ;
                    that.AJAX.open("POST", uri, true);
                    that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    that.AJAX.setRequestHeader("Content-Length", passData.length);
                    that.AJAX.send(passData);
                } else {
                    var uri=urlCall+'/'+passData ; 
                    that.AJAX.open("GET", uri, true);                             
                    that.AJAX.send(null);                                         
                }              
                
            }
        
            return true;                                             
        }                                                                           
    }
    var urlCall = url;        
    this.callback = callbackFunction || function () { };
}

function processData(responseText, responseStatus) {
  if (responseStatus==200) {
    alert(responseText);
  } else {
    alert(responseStatus + ' -- Error Processing Request');
  }
}

