window.addEvent('domready', function() {

	var buttons = $$('img.buttons');
	var current = 1;
  
	buttons.addEvents({
        'mouseover' : function(){
            this.src = this.src.replace(/off/,"on");},
        'mouseout' : function(){
            this.src = this.src.replace(/on/,"off");}
	});
    
    var events = $$('a.event');
    
    events.addEvents({
		'click' : function(){
			
			loadEvent(this.href.charAt(37)); //start at 0 and count http://ypsipipes.org/events.php#concert1 <-- you get "1", as in "concert1", at position 39
			}
	});
		
	var events = $$('span.c');
    
    events.addEvents({
        'mouseover' : function(){
            this.style.color = "#F62743";
            this.style.cursor = "pointer";},
        'mouseout' : function(){
            this.style.color = "#F6E470";
            }
    });
    
	var events = $$('span.w');
    
    events.addEvents({
        'mouseover' : function(){
            this.style.color = "#5981FF";
            this.style.cursor = "pointer";},
        'mouseout' : function(){
            this.style.color = "#F6E470";
            }
    });
  
  var bio = $$('span.bio');
  
    bio.addEvents({
    'click' : function(){
        alert("asdf");
        window.open("bio/" + this.id + ".php",this.title);
    
            }
    });

	var xmlHttp;
	
	function loadEvent(str){
		xmlHttp = GetXmlHttpObject();
		
		if (xmlHttp==null){ return };
		var url = "getEvent.php";
		url = url + "?q=" + str;
		url = url + "&sid=" + Math.random();

		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
	
	function stateChanged(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			document.getElementById("ajax_content").innerHTML=xmlHttp.responseText;
		}	
	}

	function GetXmlHttpObject(){ 
		var objXMLHttp=null;
		if (window.XMLHttpRequest){
			objXMLHttp = new XMLHttpRequest();
		}
		else if (window.ActiveXObject){
			objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		return objXMLHttp;
	};

});