function getEvents(){
	var inputs =  $("#rsecs :input");
	var inputs2 = $("#aopts :input");
	var sRegs  = '';
	var aOpts  = '';
	
	for(i=0;i<inputs.length;i++){
		if($(inputs[i]).attr('checked')){
			if(inputs[i].value != "on"){
				sRegs += inputs[i].value;
				if(i != (inputs.length -1)){
					sRegs += ":";
				}
			}
		}
	}
	
	for(i=0;i<inputs2.length;i++){
		if($(inputs2[i]).attr('checked')){
			if(inputs2[i].value != "on"){
				aOpts += inputs2[i].value;
				if(i != (inputs2.length -1)){
					aOpts += ":";
				}
			}
		}
	}
	
	
	if(sRegs != "" || aOpts != ""){
		
		$("#pLocs").val(sRegs);
		$("#pOpts").val(aOpts);
		
		$.ajax({
		   type: "POST",
		   url: "http://www.americanauctioneers.com/pusher.php",
		   data: "action=getEvents&loc=" + sRegs + "&opts=" + aOpts,
		   success: function(html){
			  $("#eventData").empty();
			  $("#eventData").append(html);
			  tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
		   }
		 });
	}else{
		alert('Please select a region');
	}
}

function selectAllRegions(){
	var inputs = $("#regionTool :input");
	if(!$(inputs[0]).attr('checked')){
		for(i=0;i<inputs.length;i++){
			$(inputs[i]).attr('checked', false);
		}	
	}else{
		for(i=0;i<inputs.length;i++){
			$(inputs[i]).attr('checked', true);
		}
	}
}

function addEmail(){
	var name  = document.getElementById('emName').value;
	var email = document.getElementById('emEmail').value;
	if( name == "" || email == ""){
		alert('Please enter your name and email');
	}else{
		$.ajax({
		   type: "POST",
		   url: "./pusher.php",
           data: "action=emList&name=" + name + "&email=" + email,
		   //data: {action:"emList",name:name,email:email},
		   success: function(html){
              $("#emName").val('');
              $("#emEmail").val('');
              $("#Emsg").empty();
			  $("#Emsg").css({display:"inline"}).html(html).fadeOut(15000);
		   }
		 });		
	}
}
