var init_after_swfobject = true;
var displayedId = null;

$(document).ready(function() {
  swfobject.embedSWF(
    'swf/kg_home.swf', //swfUrl
    'main',	// id
    '700',	// width
    '500',	// height
    '9.0.0',	// version
    null,		// expressInstallSwfurl
    null, 	// flashvars
    null,		// params
    null,		// attributes
    swfobject_callback   // callbackFn
  );
});

function adjustPops() {
  $("#pops").offset($("#circle").offset());
}


function swfobject_callback(init_success) {
  if (init_success) {

  } else {
	$(window).resize(function() {
	  adjustPops();
	});

     $("#pops").offset($("#circle").offset());
     $("img.nav").hover(
       function() {
         if (displayedId) {
           $("#pop"+displayedId).hide();
           $("#circle").attr("src", $("#circle").attr("src").replace("_" + displayedId, "_0"));
           displayedId = null;
         }
         this.src = this.src.replace("_0","_1");
         $("#popbar").attr("src", $("#popbar").attr("src").replace("_0", "_" + this.name.substr(-1,1)));
       },
       function() {
         this.src = this.src.replace("_1","_0");
         $("#popbar").attr("src", $("#popbar").attr("src").replace("_" + this.name.substr(-1,1), "_0"));
       }
     );
     
     $(".circlearea").hover(
       function() {
         if (displayedId) {
           $("#pop"+displayedId).hide();
           $("#circle").attr("src", $("#circle").attr("src").replace("_" + displayedId, "_0"));
         }
         displayedId = this.id.substr(-1,1);
         $("#pop"+displayedId).show();
         $("#circle").attr("src", $("#circle").attr("src").replace("_0", "_" + displayedId));
       }
     );
  }
}


