var req=null;
var console=null;
var READY_STATE_UNINITIALIZED=0;
var READY_STATE_LOADING=1;
var READY_STATE_LOADED=2;
var READY_STATE_INTERACTIVE=3;
var READY_STATE_COMPLETE=4;

function initXMLHTTPRequest () {
    var o;
    try{
        o = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            o = new ActiveXObject("Microsoft.XMLHTTP");    
        }catch(e){
            o = false
        }
    }    
    if(!o && typeof XMLHttpRequest!='undefined'){
        o = new XMLHttpRequest();
    }
//    o.async=false;
    return o;
}


function sendRequest (url,params,HttpMethod) {
	if (!HttpMethod) {
	HttpMethod="GET";	
	}
	req=initXMLHTTPRequest();
	
	if (req) {
	req.onreadystatechange=onReadyState;
	req.open(HttpMethod,url,true);
	//req.setRequestHeader ("Content-Type", "text/xml");
	req.send(params);
	}
}


function onReadyState() {
	var ready=req.readyState;
	var data=null;
	if (ready==READY_STATE_COMPLETE) {
		data=req.responseText;
		//setDataXML(req);
		//alert(data);
		document.getElementById('idSearch').innerHTML=data;
		document.getElementById("pop6").style.display="none"; 
	}
	else {
		document.getElementById("pop6").style.display=""; 
	}

}

function readsongssearch(sKey,sCategory,rLike,value)
{
	 
   document.getElementById('idSearch');
 
 //	document.getElementById("tdrecords").innerHTML="";
 var url="ajax_Songssearch.asp?frmkeyword="+sKey+"&cmbCategory="+sCategory+"&rdLike="+rLike+"&page="+value;
	//var url="ajax_Songssearchnew.asp?frmkeyword=aa&cmbCategory=Movie&rdLike=Like&page=2";
	//alert(url)
	sendRequest(url);
   
  //var url="ajax_Songssearch.asp?frmkeyword="+sKey+"&cmbCategory="+sCategory+"&rdLike="+rLike+"&page="+value;
  
}

function readArtistsongs(sCat,value)
{
	 
    document.getElementById("idSearch").innerHTML="";
 
	var url="ajax_artist.asp?id="+sCat+"&page="+value;
    sendRequest(url);
 
}




//  audio albums 



function readaudioalbums(sId,sCat,value)
{
	 
     document.getElementById("idSearch").innerHTML="";
 
	var url="ajax_audioalbums.asp?albumid="+sId+"&albumtype="+sCat+"&page="+value;
    sendRequest(url);
  
  
}

function readaudioalbums1(sId,sCat)
{
	 
   document.getElementById("idSearch").innerHTML="";
 
 var url="ajax_audioalbums.asp?albumid="+sId+"&albumtype="+sCat;
    sendRequest(url);
   
 
}

function readVideoslist(sCat,value)
{
	 
    document.getElementById("idSearch").innerHTML="";
 
  var url="ajax_videolist.asp?category="+sCat+"&page="+value;
    sendRequest(url);
   
 
  

}


function readgreetings(value)
{
	 
    document.getElementById("idSearch").innerHTML="";
 
   var url="ajax_greetings.asp?page="+value;
    sendRequest(url);
 


}

//   greetings 1 page  ajax call

function readgreetings1(sCat,value)
{
	 
     document.getElementById("idSearch").innerHTML="";
 
   var url="ajax_greetings1.asp?categoryid="+sCat+"&page="+value;
    sendRequest(url);


}


function setDataXML(req)
{
	var books = req.responseXML.getElementsByTagName('book');
	for (var i=0;i<books.length;i++)
	{
		var x = document.createElement('div');
		x.className = 'book';
		var y = document.createElement('h3');
		y.appendChild(document.createTextNode(getNodeValue(books[i],'title')));
		x.appendChild(y);
		var z = document.createElement('p');
		z.className = 'moreInfo';
		z.appendChild(document.createTextNode('By ' + getNodeValue(books[i],'author') + ', ' + getNodeValue(books[i],'publisher')));
		x.appendChild(z);
		var a = document.createElement('img');
		a.src = books[i].getElementsByTagName('cover')[0].getAttribute('src');
		x.appendChild(a);
		var b = document.createElement('p');
		b.appendChild(document.createTextNode(getNodeValue(books[i],'blurb')));
		x.appendChild(b);
		document.getElementById('writeroot').appendChild(x);
	}
}

function getNodeValue(obj,tag)
{
	return obj.getElementsByTagName(tag)[0].firstChild.nodeValue;
}


/*
############Code for generating a random number#################
var ran_number=Math.floor(Math.random()*5);
function get_random()
{
    var ranNum= Math.floor(Math.random()*5);
    return ranNum;
}

This function will simply return a random number between zero and 4. 
Our next function will call this function and assign the returned number to a variable named whichQuote: 
this will be the variable we use to get the proper quote from the array we will define. So, let's also define an array here, 
and set it up with five quotes:

function getaQuote()
{
   var whichQuote=get_random();

    var quote=new Array(5)
     quote[0]="I love JavaScript..sometimes.";
     quote[1]="Why are you pushing my button?";
     quote[2]="The button you pushed can\'t push you back. You bully, you!";   
     quote[3]="This alert is here to inform you that alerts are annoying.";
     quote[4]="Which came first, the button or the alert?";
  
   alert(quote[whichQuote]);
  }

As you can see, the last line of the function gives the user the alert. The value of the alert is the quote stored in the quote array:

quote[whichQuote]

Remember, the whichQuote variable was assigned a random number between zero and 4 from the get_random() function. 
So, if the value of whichQuote is 3, you get an alert with the quote from the array at quote[3]. Each time the button is clicked, 
it is all run again and will assign it another random number.

As for the button, here is how to code it into the body section:

<FORM name="form1">
<INPUT TYPE="button" value="Get a Quote!" onClick="getaQuote()">
</FORM>   


*/

