var welwordv=document.getElementById("idwelwordv"), welword=document.getElementById("idwelword"), 
craftwordv=document.getElementById("idcraftwordv"), craftword=document.getElementById("idcraftword"), winw, posleft, n=0, 
wordsinstart=true, wordsintime, opicd, opfirstind=true, opcount, opval, opvartime, opfunfrom, optim;

set_posin();

function set_posin()
{
  winw = document.body.clientWidth;
  if (winw > 770)
    posleft =  (winw - 770)/2;
  else
    posleft = 0;
  welwordv.style.left=posleft + 256 + "px";
  craftwordv.style.left=posleft + 184 + "px";
}

function preloadImagesin()
{
   if (document.images)
   {
      st_welcome_over = newImage("images/st_welcome1.jpg");
      st_pianocraft_over = newImage("images/st_pianocraft1.jpg");
   }
 window.onresize=set_posin;
 wordsin();
}

function newImage(arg) {
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function wordsin()
{
   if (n == 0)
   {
     wordsintime = setTimeout ("wordsin()", 4000);
     wordsinstart = false;
     n = 1;
   }
   else
   if (n == 1)
   {
        if (document.all)
        {
           welword.style.filter="blendTrans(duration=2.0)";
           welword.filters.blendTrans.Apply();
           welword.src= "images/st_welcome1.jpg";
           welword.filters.blendTrans.Play();
           n = 2;
           wordsintime = setTimeout ("wordsin()", 3000);
        }
        else
        {
           if (opfirstind)
           {
              clearTimeout(wordsintime);
	 welword.style.opacity= 0;
              welword.src= "images/st_welcome1.jpg";
              opvars("wordsin()", welword, wordsintime);
           }
           else
           {
              opfirstind = true;
	 welword.style.opacity= 1;
              n = 2;
              wordsintime = setTimeout ("wordsin()", 1500);
           }
        }
   }
   else
   if (n == 2)
   {
        if (document.all)
        {
           craftword.style.filter="blendTrans(duration=2.0)";
           craftword.filters.blendTrans.Apply();
           craftword.src= "images/st_pianocraft1.jpg";
           craftword.filters.blendTrans.Play();
           n = 3;
           wordsintime = setTimeout ("wordsin()", 5000);
        }
        else
        {
           if (opfirstind)
           {
              clearTimeout(wordsintime);
	 craftword.style.opacity= 0;
              craftword.src= "images/st_pianocraft1.jpg";
              opvars("wordsin()", craftword, wordsintime);
           }
           else
           {
              opfirstind = true;
	 craftword.style.opacity= 1;
              n = 3;
              wordsintime = setTimeout ("wordsin()", 4000);
           }
        }
   }
   else
      location.href="index.php";
}

function opvars(funfrom, picd, timind)
{
     opicd = picd;
     opfunfrom = funfrom;
     optim = timind;
     opcount = 1;
     opval=0;
     opvar();
}

function opvar()
{
    if (opcount < 18)
    {
       opval = opval + .05;
       opicd.style.opacity= opval;
       opcount =  opcount +1;
       opvartime = setTimeout ("opvar()", 1);
    }
    else
    {
       opicd.style.opacity= 1;
       opfirstind = false;
       clearTimeout(opvartime);
       optim = setTimeout (opfunfrom, 0);
    }
}
