

$(document).ready(function() {
	
//	initialize();
	
	$('#testclick').click(function(event){
		alert ('testclick!');
	});

	$("*[pageID]").livequery('click',function(event){
		pageID = $(this).attr('pageID');
		urlbase = $(this).attr('urlbase');
		if (!$(this).hasClass('active')) {
			$.get("/ajax/",{urlbase: urlbase, page: pageID},
				function(data){
					$('#content').html(data);
				});
		} else {
			// this is the active page, we don't need to do anything
		}
	});
	
	
	
	$("*[togglevendor]").click(function(event){
		vendorID = $(this).attr('togglevendor');
		if($("#vendordetail" + vendorID).hasClass('exists')){
			$(this).text('+');
			$("#vendordetail" + vendorID).remove();
		}else{
		
			$.get("/dev/eom/vendordetail.php",{vendorID: vendorID, startdate: startdate, stopdate: stopdate},
				function(data){
					// alert('back from vendordetail.php');
					// $(".vendordetail[vendorID=" + vendorID + "]").html(data);
					$(".vendorrow[vendorID=" + vendorID + "]").after(data);
				});
			$(this).text('-');

		}

	});

	$("*[toggleschool]").click(function(event){
		schoolID = $(this).attr('toggleschool');
		if($("#schooldetail" + schoolID).hasClass('exists')){
			$(this).text('+');
			$("#schooldetail" + schoolID).remove();
		}else{
		
			$.get("/dev/eom/schooldetail.php",{schoolID: schoolID, startdate: startdate, stopdate: stopdate},
				function(data){
					$(".schoolrow[schoolID=" + schoolID + "]").after(data);
				});
			$(this).text('-');

		}

	});
	
	$('#asid').change(function(event){
		new_asid = $('#asid option:selected').val();
//		alert('new_asid: ' + new_asid);
		loadrighthalf('display');
		$('#editmeta').show();
	});
	
	$('#editmeta').click(function(event){
		loadrighthalf('edit');
	});
		
	function loadrighthalf(action)
	{
		$.get("/dev/classify2_ajaxhelper.php",{a: 'loadrighthalf', b: new_asid, c: action},
				function(data){
					$('#righthalf').html(data);
					$('#righthalf').show(300);
				});
	}
	
	
	function initialize()
	{
		alert('initialize!');
	}
});