var url="scripts/month.php";
var csvUrl = "portfolio.csv";

var http = getHTTPObject();
var csvHttp = getHTTPObject();
var csvArray = new Array(new Array());

/*
//function to automatically remove all child nodes from the argument node
function removeAllChildNodes(elem){	
	
	if ( elem.hasChildNodes() )
	{
		while ( elem.childNodes.length >= 1 )
		{
			elem.removeChild( elem.firstChild );       
		} 
	}

}

function handleHttpResponse() {
   if(document.getElementById){
     // 4 is the signal for finished
     //if (http.readyState == 4) { 
     
     	 var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
   
         results = months[new Date().getMonth()];
         //results = http.responseText;
         path = "images/" + results.toLowerCase() + "_tips_stick.jpg";
   
         var elem = document.getElementById('tips_stick_wrapper');
               
            /*Opera keeps on adding tipsticks so you get two??? Removing child nodes
            seems to stop it*/
 /*     		removeAllChildNodes(elem);
   
            var img = document.createElement('img');
            
      		img.id = "tips_stick";
            img.src = path;
            img.title = "click for " + results + " tips";
            img.alt = results + " tips";
            
            var a = document.createElement('a')
            
            a.href = "tips.php";      
            
            a.appendChild(img);
      		elem.appendChild(a);
     //}
   }
}


function performLookup()
{
handleHttpResponse();
/*      http.open("GET", url, true);
      
      // handleHttpResponse
      http.onreadystatechange = handleHttpResponse;
      
      // end comms, only do this at the end of your interaction
      http.send(null);
*/
//}


function handleCsvHttpResponse() {

  if(document.getElementById){
   	// 4 is the signal for finished
     if (csvHttp.readyState == 4) {
   	
       // Split the comma delimited response into an array
       csvArray = csvHttp.responseText.split("\n");
       
       for(i = 0; i<csvArray.length; i++){
         csvArray[i] = csvArray[i].split("~");
         try{
            document.getElementById('category' + csvArray[i][0]).style.cursor = 'pointer';
         }
         catch(eOldIEVersion){
            document.getElementById('category' + csvArray[i][0]).style.cursor = 'hand';
         }
       }
       
       initPage();//location = gallery.js
       autoOpen();//location = gallery.js
       
     }
   }
}


function performCsvLookup()
{
   csvHttp.open("GET", csvUrl, true);
   // handleHttpResponse
   csvHttp.onreadystatechange = handleCsvHttpResponse;
   // end comms, only do this at the end of your interaction
   csvHttp.send(null);
}

/* This method is pretty much standard AJAX, you'll see it 
everywhere. The curious can read into its details, the rest of
you can just know that this gives you a HTTP object */

function getHTTPObject() {
  
var http = null;
try {
if (window.XMLHttpRequest) // Mozilla, Safari,...
http = new XMLHttpRequest();
else if (window.ActiveXObject) { // IE
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
} catch ( e ) {}
return http;
  

}

