// JavaScript Document

// Get the HTTP Object

/*
function getHTTPObject(){
	//testing...
	if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest()) return new window.XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
		return null;
	}
}
*/

function getHTTPObject() {
    var xhr = false;//set to false, so if it fails, do nothing
    if(window.XMLHttpRequest) {//detect to see if browser allows this method
        var xhr = new XMLHttpRequest();//set var the new request
    } else if(window.ActiveXObject) {//detect to see if browser allows this method
        try {
            var xhr = new ActiveXObject("Msxml2.XMLHTTP");//try this method first
        } catch(e) {//if it fails move onto the next
            try {
                var xhr = new ActiveXObject("Microsoft.XMLHTTP");//try this method next
            } catch(e) {//if that also fails return false.
                xhr = false;
            }
        }
    }
    return xhr;//return the value of xhr
}


// Change the value of the outputText field

function setOutput(){
	if(httpObject.readyState == 4){
		document.getElementById('ajax_text').innerHTML =   httpObject.responseText ;
	}
}


function setNews(){
	if(httpObject.readyState == 4){
		document.getElementById('ajax_news').innerHTML =   httpObject.responseText ;
	}
}

// Implement business logic

function doWork(id, more, more2){
	
	httpObject = getHTTPObject();
	if (httpObject != null) {
		httpObject.open("GET", "includes/cf/get_detail.cfm?panel_id="+id+"&more="+more+"&more2="+more2 , true);
		httpObject.onreadystatechange = setOutput;
		httpObject.send(null);
	
		if (id != 1) {
			document.getElementById('ajax_news').innerHTML = "";
		} 

	//wmalyk2 - dynamically change the class of the menu item
	oldID = jQuery.id8_panel_id ? "menuItem" + jQuery.id8_panel_id : "none";
	newID = "menuItem" + id;
		
	//Adds the class 'stick' to the selected item, and removes it from the previously selected item (if there was one)
	if(oldID) jQuery('#' + oldID).removeClass("sticky");
	jQuery('#' + newID).addClass("sticky");
		
	jQuery.id8_panel_id = id;  //wmalyk - updates a panel_flag
	jQuery.stickpanel();       //wmalyk - foces the accordian to reload the selected panel
	
	}
}



var httpObject = null;


