/*window.addEvent('domready', function() {
	//create our Accordion instance
	// may need to change toggler back to an h3 -C
	var myAccordion = new Accordion($('accordion'), 'p.toggler', 'div.element', {
		opacity: false,
		onActive: function(toggler, element){
			//toggler.setStyle('display', 'block');
			toggler.addClass ('accordion_open');
		},
		onBackground: function(toggler, element){
			//toggler.setStyle('display', 'block');
			toggler.removeClass ('accordion_open');
		}
	});

	//add click event to the "add section" link
	$('add_section').addEvent('click', function(event) {
		event.stop();
		
		// create toggler
		var toggler = new Element('h3', {
			'class': 'toggler',
			'html': 'Common descent'
		});
		
		// create content
		var Mycontent = new Element('div', {
			'class': 'element',
			'html': '<p>A group of organisms is said to have common descent if they have a common ancestor. In biology, the theory of universal common descent proposes that all organisms on Earth are descended from a common ancestor or ancestral gene pool.</p><p>A theory of universal common descent based on evolutionary principles was proposed by Charles Darwin in his book The Origin of Species (1859), and later in The Descent of Man (1871). This theory is now generally accepted by biologists, and the last universal common ancestor (LUCA or LUA), that is, the most recent common ancestor of all currently living organisms, is believed to have appeared about 3.9 billion years ago. The theory of a common ancestor between all organisms is one of the principles of evolution, although for single cell organisms and viruses, single phylogeny is disputed</p>'
		});
		
		// position for the new section
		var Myposition = 0;
		
		// add the section to our myAccordion using the addSection method
		myAccordion.addSection(toggler, Mycontent, Myposition);
	});
	

    
});
*/




var target;
var on;
var f;
function showGraph(t, type, filter, companyId, industryId){
	on=t+"_"+filter;
	f=filter;
	target=t;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	//CAN'T FIGURE OUT THE FORMAT FOR A PAGE REQUEST
	var url="ajax/Graph.php";
	url=url+"?type="+type+"&filter="+filter+"&companyId="+companyId+"&industryId="+industryId;
	//url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged(){
	if (xmlhttp.readyState==4){
		document.getElementById(target+"_state").className ="";
		document.getElementById(target+"_country").className ="";
		//document.getElementById(on).setAttribute("class", "active");
		document.getElementById(on).className="active";
		document.getElementById(target).innerHTML=xmlhttp.responseText;
	}
}

function updateCal(t,aq,bs,cs,cr,factor){
	target=t;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	
	var url="ajax/Calculator.php";
	url +="?chartFormSubmitted=1&annualQuota="+aq+"&baseSalary="+bs+"&commissionStart="+cs+"&commissionRate="+cr+"&factor="+factor+"";
	xmlhttp.onreadystatechange=stateChangedC;
	xmlhttp.open("GET",url,true);
	xmlhttp.send();
}

function stateChangedC(){
	if (xmlhttp.readyState==4){
		document.getElementById(target).innerHTML=xmlhttp.responseText;
	}
}
function GetXmlHttpObject(){
	if (window.XMLHttpRequest){
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	}
	if (window.ActiveXObject){
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

function updateSalesCompTable() {
	salesForm = new Form.Request("sales_comp_form", "sales_table");
	salesForm.send();
}


window.addEvent('domready', function() {
	if ($('sales_comp_form')) {
    $('sales_comp_form').addEvent('submit',function(event) {
        event.preventDefault();
        this.set('',{onComplete:function(response){
                $('sales_table').set('html', response);
                if((response != undefined)&&(response != "")&&(response!="undefined")){
			alert(response);
		}
            }
        }).send();
    })
  }
});
