
var isTwinkleLoaded = false;

$(function(){
					
	var speed = 1000;
	
	if($.browser.msie && parseFloat($.browser.version) < 7){
		
		$('#searchbox, #top_menu, #bottom_menu').css({display:'block'});
		$('#img1, #img2, #img3').css({opacity:0, display:'block'});
	}else{
		$('#searchbox, #top_menu, #bottom_menu, #img1, #img2, #img3, #loading').css({opacity:0, display:'block'});
	}
	
	$('#img1').animate({opacity:1},speed,function(){
		$('#img2').animate({opacity:1},speed,function(){
			$('#img3').animate({opacity:1},speed,function(){
				
				if(!$.browser.msie || ($.browser.msie && parseInt($.browser.version) >= 7)){
					$('#searchbox, #top_menu, #bottom_menu').animate({opacity:1},speed);
				}
				
				if(!isTwinkleLoaded){
					$('#loading').animate({opacity:1},speed);
				}
				
				setInterval(function(){
					PlayFlashMovie();
				},500);
				
			});
		});
	});

	var flashLoc = $('#twinkle_swf').attr('data');
	$('#twinkle_swf').append('<embed width="320" height="230" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" quality="high" src="'+flashLoc+'" name="twinkle_swf" swliveconnect="true" play="false" />');
	
});

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function StopFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	flashMovie.StopPlay();
}

function PlayFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	flashMovie.Play();
	//embed.nativeProperty.anotherNativeMethod();
}

function RewindFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	flashMovie.Rewind();
}

function NextFrameFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	// 4 is the index of the property for _currentFrame
	var currentFrame=flashMovie.TGetProperty("/", 4);
	var nextFrame=parseInt(currentFrame);
	if (nextFrame>=10)
		nextFrame=0;
	flashMovie.GotoFrame(nextFrame);		
}


function ZoominFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	flashMovie.Zoom(90);
}

function ZoomoutFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	flashMovie.Zoom(110);
}


function SendDataToFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	flashMovie.SetVariable("/:message", document.controller.Data.value);
}

function ReceiveDataFromFlashMovie()
{
	var flashMovie=getFlashMovieObject("twinkle_swf");
	var message=flashMovie.GetVariable("/:message");
	document.controller.Data.value=message;
}


function isLoaded(){
	isTwinkleLoaded = true;
}

