// JavaScript Document

// JavaScript Document
var GolfLogoSplashStartLeft = 140;   //left:144;
var GolfLogoSplashWidth =  0;    
var GolfLogoSplashStartTop = 75;  //top:75;
var GolfLogoSplashHeight = 0;  
var to=0;
var opacity=0;
//GolfSplash
/*var GolfSplashStartTop = getNumericVal(document.getElementById('GolfSplash').style.top);  //top:10px;
var GolfSplashStartleft= getNumericVal(document.getElementById('GolfSplash').style.left);  //top:10px;
*/
	
	/*
var myimages = new Array();
	function preloading(){
		alert(123);
		alert(preloading.arguments.length);
		for (x=0; x<preloading.arguments.length; x++){
			alert(456);
		myimages[x] = new Image();
		myimages[x].src = images/preloading.arguments[x];
		//alert(myimages[x].src);
		}
	}

	*/
	

	function getNumericVal(val)
	{
	  var arr = new Array();
	  arr = val.split("px");
	  return parseInt(arr[0]);
	}
	
function main_initAnime() {
	
    anime = {elemID:"", 
			 xStart:0, 
             yStart:0, 
             xTarg:0, 
             yTarg:0, 
			 left:0,
			 top:0,
			 width:0,
			 height:0,
			 vel:1,
             interval:null
            };
}



function main_init(){
	//PigAPopnLogo
	GolfGameLogoStartLeft = getNumericVal(document.getElementById('GolfGameLogo').style.left);   //left:310px;
	GolfGameLogoWidth =  getNumericVal(document.getElementById('GolfGameLogo').style.width);    //width:260px;
	GolfGameLogoStartTop = getNumericVal(document.getElementById('GolfGameLogo').style.top);  //top:10px;
	GolfGameLogoHeight = getNumericVal(document.getElementById('GolfGameLogo').style.height);  //height:436px;

	main_initAnimation('GolfGameLogo',GolfGameLogoStartLeft , GolfGameLogoStartTop ,GolfLogoSplashStartLeft ,GolfLogoSplashStartTop ,10);
 }


function main_initAnimation(elemID, startX, startY, endX , endY , speed) {
	//alert(5645656);	
	main_initAnime();
	// alert("startX = "+startX+"endX = "+endX);
   //  alert("startY = "+startY+"endY = "+endY);
	anime.elemID = elemID;
	
    anime.xStart = startX ;  //-61     
    anime.yStart = startY ;      
    anime.xTarg = endX;    
    anime.yTarg = endY;   
	//alert("xTarg = "+anime.xTarg+"endY = "+anime.yTarg);
	anime.vel = (speed) ? speed : 1;
	 
    // set element's start position

    document.getElementById(elemID).style.left = anime.xStart ;   
    document.getElementById(elemID).style.top = anime.yStart ;  
	var yStep = -2 * anime.vel;
	
	
	anime.interval = setInterval("main_doAnimation()",1);
	
	
}
opacity=0;
function fadeInMyNumoLogo(){
	fadeLogo=setInterval("fadelogoAni()",30);
}
	
function fadelogoAni(){
	opacity+=0.006;
	document.getElementById('MyNuMoLogo').style.opacity=opacity;
	if(opacity>=1) { clearInterval(fadeLogo); opacity=0;}

}

function loading()
{
	document.getElementById('MyNuMoLogo').style.opacity=0;
	document.getElementById('MyNuMoLogo').style.display='';
	fadeInMyNumoLogo();
	setTimeout("document.getElementById('logoBackground').style.display='';document.getElementById('logoLoading').style.display='';document.getElementById('GolfLogoBar').style.display='';", 100 );
	animateLoadGame();
}

function animateLoadGame(){
		tout=setInterval("ani()",100);
}
opacity=0;	
function ani(){
	++to;
	
	document.getElementById('GolfLogoBar').innerHTML+="<img src='images/GolfLoadingDot.gif' STYLE='position:relative;margin-top:2;margin-left:3;'>";	
	if(to>8) { clearInterval(tout); fadeInButtons(); 
	document.getElementById('logoBackground').style.display='none';
	document.getElementById('logoLoading').style.display='none';
	document.getElementById('GolfLogoBar').style.display='none';
	}

}
opacity=0;
function fadeInButtons(){
	document.getElementById('playButon').style.opacity=0;
	document.getElementById('moreGamesButon').style.opacity=0;
	document.getElementById('instructionsButon').style.opacity=0;
	document.getElementById('playButon').style.display='';
	document.getElementById('moreGamesButon').style.display='';
	document.getElementById('instructionsButon').style.display='';
	fade=setInterval("fadeAni()",20);
}
	
function fadeAni(){
	opacity+=0.02;
	document.getElementById('playButon').style.opacity=opacity;
	document.getElementById('moreGamesButon').style.opacity=opacity;
	document.getElementById('instructionsButon').style.opacity=opacity;
	if(opacity>=1) { clearInterval(fade); }

}


function main_doAnimation() {
	
	
	//for(i=anime.yStart;i>=anime.yTarg;i--)
	if(anime.yStart >= anime.yTarg)
	{
		var y = anime.yStart;
		var x = anime.xStart;
		
		//alert("x="+x+"y="+y);
		document.getElementById(anime.elemID).style.left = x ;   
        document.getElementById(anime.elemID).style.top = y ;  
		
		
		anime.yStart = anime.yStart - 15;  // to increase the speed of GAME LOGO on splash screen reduce the value of anime.yStart
		
	}
	else{
		document.getElementById(anime.elemID).style.left = anime.xTarg ;
    	document.getElementById(anime.elemID).style.top = anime.yTarg;
		//alert("xTarg = "+anime.xTarg+"endY = "+anime.yTarg);
        clearInterval(anime.interval);
		loading();
	}
	
	
	
}
function applyPropertyToElement(id,ntop,nleft,nheight,nwidth,nbackgouundimg)
  {
	  if(ntop)
		document.getElementById(id).style.top = ntop;
	  if(nleft)
		document.getElementById(id).style.left = nleft;
	  if(nheight)
		document.getElementById(id).style.height = nheight;
	  if(nwidth)
		document.getElementById(id).style.width = nwidth;
		//alert('top = '+ntop+' left = '+nleft+' height = '+nheight+' width = '+nwidth);
  }	
 
