var base_url = get_base_url()+"/index.php/";
var story_update;
var story_id=0;
var testimonial_id=0;
var photo_id = 0;

startup();

function get_base_url() {
    var css_url = document.styleSheets[0].href;
    var last_slash = css_url.lastIndexOf('/css');
    return css_url.substr(0,last_slash);
}

function startup() {
	update_photos();
	story_update=new PeriodicalExecuter(update_story, 23);
	//testimonial_update = new PeriodicalExecuter(update_testimonial,13);
	groups_update = new PeriodicalExecuter(update_groups,29);
	photos_update = new PeriodicalExecuter(update_photos,17);
	
}

function update_story() {
	new Ajax.Updater('story-content',base_url+"ajax/get_story/"+story_id+"/", {
					method:'post',evalScripts:true
					});
}

function set_story(newid) {
	story_id=newid;
}

function update_testimonial() {
	new Ajax.Updater('testimonial-content',base_url+"ajax/get_testimonial/"+testimonial_id+"/", {
					method:'post',evalScripts:true
					});
}

function set_testimonial(newid) {
	testimonial_id=newid;
}

function update_groups() {
	new Ajax.Updater('initiatives-content',base_url+"ajax/get_groups/", {
					method:'post',evalScripts:true
					});
}

function update_photos() {
	new Ajax.Updater('photos-content',base_url+"ajax/get_photo/", {
					 method:'post',evalScripts:true
					 });
}

function set_photo(newid){
	photo_id=newid;
}

