﻿function timedMsg()
{
var t=setTimeout("alert('5 seconds!')",5000);
}

function checkSubmission2()
{
    if (document.getElementById("submitted").value == "submitted")
    {
        showdiv( " ", " ", " ", "contact" );
        //alert('test');
        document.getElementById('contactContent').style.visibility = 'hidden';
            
            
        document.getElementById("thankyouContent").style.visibility = 'visible';
        

        
    }
    //alert('test');
    document.getElementById('floatingContainerRight').style.backgroundPosition = "-200px 0px";
    theCoords=getAnchorPosition('floatAnchor');
    document.getElementById('floatingContainerRight').style.left = theCoords.x + 800 + "px";
    document.getElementById('floatingContainerRight').style.top = theCoords.y + "px";
    //alert('test');
    startUp('floatingContainer', 'floatAnchor');
}

function startUp(theFloater, theAnchor)
{
     var randomnumber=Math.floor(Math.random()*300);
     //alert(randomnumber);
     randomnumber=randomnumber + 5;
     //alert(randomnumber);

     theCoords=getAnchorPosition(theAnchor);
    
     document.getElementById(theFloater).style.left = theCoords.x - 200 + "px";
     document.getElementById(theFloater).style.top = theCoords.y + randomnumber + "px";
     //document.getElementById(theFloater).style = theCoords.y - 112 + "px";
     //alert(document.getElementById(theFloater).style.backgroundPosition);
     
     //theValues = document.getElementById(theFloater).style.backgroundPosition;

     //alert(theValues);
     document.getElementById(theFloater).style.backgroundPosition = "200px 0px";
     //document.getElementById(theFloater).style.visibility = 'hidden';
     //document.getElementById('name').style.backgroundPo  sition = '0px 0px';
     var randomnumber=Math.floor(Math.random()*50);
     randomnumber=randomnumber + 5
     doMoveOut(theFloater);

}

function doMoveOut(theFloater)
{
     theCoords=document.getElementById(theFloater).style.backgroundPosition;
     theX=theCoords.split(" ");
     theXvalue=theX[0].split("p");
     theNewXvalue=parseInt(theXvalue[0]) - 2;
     newCoords = theNewXvalue.toString() + "px 0px"
     theCoords=document.getElementById(theFloater).style.backgroundPosition = newCoords;
     //document.getElementById(theFloater).style.backgroundimage = "img/csa.png";
     //alert(theNewXvalue);
     
     //var t=setTimeout("doMoveOut(theFloater)",500);
    
     if ( theNewXvalue > 50 )
     {
          
          setTimeout("doMoveOut('floatingContainer')",30);
     }else{
          setTimeout("doMoveIn('floatingContainer')",2000);
     //doMoveIn('floatingContainer');
     }
}
function doMoveIn(theFloater)
{
     //alert('in');
     theCoords=document.getElementById(theFloater).style.backgroundPosition;
     theX=theCoords.split(" ");
     theXvalue=theX[0].split("p");
     theNewXvalue=parseInt(theXvalue[0]) + 2;
     newCoords = theNewXvalue.toString() + "px 0px"
     theCoords=document.getElementById(theFloater).style.backgroundPosition = newCoords;
     //alert(theNewXvalue);
     
     //var t=setTimeout("doMoveOut(theFloater)",500);
    
     if ( theNewXvalue < 200 )
     {
          setTimeout("doMoveIn('floatingContainer')",30);
     }else{
          setTimeout("startUpRight('floatingContainerRight','floatAnchor')",2000);

     //doMoveOut('floatingContainer');
     }
}
function startUpRight(theFloater, theAnchor)
{
     var randomnumber=Math.floor(Math.random()*300);
     //alert(randomnumber);
     randomnumber=randomnumber + 5;
     //alert(randomnumber);

     theCoords=getAnchorPosition(theAnchor);
    
     document.getElementById(theFloater).style.left = theCoords.x + 800 + "px";
     document.getElementById(theFloater).style.top = theCoords.y + randomnumber + "px";
     //document.getElementById(theFloater).style = theCoords.y - 112 + "px";
     //alert(document.getElementById(theFloater).style.backgroundPosition);
     
     //theValues = document.getElementById(theFloater).style.backgroundPosition;

     //alert(theValues);
     document.getElementById(theFloater).style.backgroundPosition = "-200px 0px";
     //document.getElementById(theFloater).style.visibility = 'hidden';
     //document.getElementById('name').style.backgroundPo  sition = '0px 0px';
     doMoveOutRight(theFloater);

}
function doMoveOutRight(theFloater)
{

     theCoords=document.getElementById(theFloater).style.backgroundPosition;
     theX=theCoords.split(" ");

     theXvalue=theX[0].split("p");
     //alert(theXvalue[0]);
     
     theNewXvalue=parseInt(theXvalue[0]) + 2;
     //alert(theNewXvalue);
     newCoords = theNewXvalue.toString() + "px 0px"
     //alert(newCoords);
     theCoords=document.getElementById(theFloater).style.backgroundPosition = newCoords;
     if ( theNewXvalue < -50 )
     {

          //alert(randomnumber);
          setTimeout("doMoveOutRight('floatingContainerRight')",30);
     }
     
     else{
          setTimeout("doMoveInRight('floatingContainerRight')",2000);

     }
}
function doMoveInRight(theFloater)
{
     //alert('in');
     theCoords=document.getElementById(theFloater).style.backgroundPosition;
     theX=theCoords.split(" ");
     theXvalue=theX[0].split("p");
     theNewXvalue=parseInt(theXvalue[0]) - 2;
     newCoords = theNewXvalue.toString() + "px 0px"
     theCoords=document.getElementById(theFloater).style.backgroundPosition = newCoords;
     //alert(theNewXvalue);
     
     //var t=setTimeout("doMoveOut(theFloater)",500);
    
     if ( theNewXvalue > -200 )
     {
          setTimeout("doMoveInRight('floatingContainerRight')",30);
     }else{
          setTimeout("startUp('floatingContainer','floatAnchor')",2000);

     //doMoveOut('floatingContainer');
     }
}
function doMoveOut2(theFloater) {

     //xVal=200;
     //yVal=0;
     //newCoords=xVal + "px " +yVal + "px";
     //alert(newCoords);
     //alert('about to move');
     //mytool_array=where_is_mytool.split("/");
     
     
     theCoords=document.getElementById(theFloater).style.backgroundPosition;
     //alert('theCoords');
     theX=theCoords.split(" ");
     //alert('test');
     theXvalue=theX[0].split("p");
     //alert(theXvalue[0]);
     theNewXvalue=parseInt(theXvalue[0]) - 2;
     //alert(theNewXvalue);
     newCoords = theNewXvalue.toString() + "px 0px"
     //alert(newCoords);
     theCoords=document.getElementById(theFloater).style.backgroundPosition = newCoords;
     
     //alert("theCoords = " + theCoords);
     //alert("theNewXvalue = " + theNewXvalue);
     //document.getElementById(theFloater).style.backgroundPosition = newCoords;
    if ( theNewXvalue > 80 )
    {
        //setTimeout(doMove,20);
        //setTimeout(doMoveOut(theFloater),20);
        var t=setTimeout("alert('5 seconds!')",50);
    }
}


   
//    setTimeout(doSomething,500); // calls doSomething() 500 miliseconds from now

//    setInterval(doSomething,500);  // calls doSomething() every 500 miliseconds until stopped


//    function doMove() {

//     foo.style.left = (foo.style.left+10)+'px'; // pseudo-property code: Move right by 10px
//
//     setTimeout(doMove,20); // call doMove() in 20 msec

 //   }