var lastHash = "animation";	// That's the initial state...
var mask = new Image();		// for caching purposes...
var contentbg = new Image();	// for caching purposes...
var polling_ID;			// ID for function that keeps waiting for content frame to load
var counter = 0;		// hash polling (for bookmarks and animated menu) should start once only...

function pollContent() {
 var content_loaded = getObjRef("content", "frame_loaded");
 var menu_loaded = getObjRef("menu", "frame_loaded");   
 var menu_ready=null;	// reference object later, when it's safe to do so...
 var theMenu=null;	// reference object later, when it's safe to do so...

 if((content_loaded != null) && (menu_loaded != null)) {	// first of all, frames need to be complete...
   if((content_loaded.value == "done") && (menu_loaded.value == "done")) {	// wait until menu and content frames are _really_ there...
     menu_ready = getObjRef("menu", "menu_ready");
     if (menu_ready.value == "READY.") {	// ...and, more importantly, wait for flash menu to signal that it's ready to go!!!
       if(!counter) {		// just once
         menu_ready.value = "RESETPOLLINGREADY.";	// now signal menu reset polling that it's ok to go!
         theMenu=getFlashMovieObject("menu", "ssmenu");
         theMenu.SetVariable("/:menuGO", "GO!");	// signal animated menu to go!
         setHash(lastHash);	// set hash value in menu frame
         startPolling();	// starting asking for values of animated menu (bookmark functionality too)
         counter = 1;		// it's over now...
         }
       else clearInterval(polling_ID);	// bye, bye
       }
     }
   }
 } 

function startPollingContent() {
 polling_ID = setInterval("pollContent()", 250);
 }

// a little bit of caching
mask.src = "http://www.schloss-schule.at/presentation/projection/mask.jpg";
contentbg.src = "http://www.schloss-schule.at/presentation/background/page_bg.jpg";

// start as soon as possible, do avoid glitches w/ menu clicks...
startPollingContent();
