var baseUrl = location.href;
var firstFocus = true;
var oldUrl = location.href;
var newUrl = location.href;

function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}


function getBaseUrl(){
 if(baseUrl.indexOf('#')==-1)
 {
  baseUrl = location.href;
 }
 else
 {
  baseUrl = baseUrl.substring(0,baseUrl.indexOf('#'));
 }
 //alert("baseUrl is: "+baseUrl);
}

				 
function getAddonFromFlash(addon){
 //location.replace(baseUrl+'#'+addon);		
				 //location.href("www.google.com");	
 location.href=baseUrl+'#'+addon;	
				 //alert("setting it now");	 
}

function sendAddon(){
 //alert("received instruction from Flash");
 var currentUrl = location.href;
 var endUrl = currentUrl.substring(currentUrl.indexOf('#')+1, currentUrl.length);
 if(currentUrl.indexOf('#')==-1)
 {
  endUrl = "none";
 }
 //alert("endURL is: " + endUrl);
 getFlashMovie("index").sendAddonToFlash(endUrl);
 //alert("sent to flash");
 
 //sendAddonAway();
}


document.onkeyup = KeyCheck;

function KeyCheck(){
 //alert("key pressed");
 sendAddon()
}