function setup(){
    xorigin=800;
    yorigin=300;
    xoffset=600;

    time1 = 0;
    time2 = 0;
    time3 = 0;
    time4 = 0;
    time5 = 0;
    time6 = 0;

    timelimit1 = 10000;
    timelimit2 = 9000;
    timelimit3 = 8000;
    timelimit4 = 7000;
    timelimit5 = 6000;
    timelimit6 = 5000;

    a1 = 0;
    a2 = 0;
    a3 = 0;
    a4 = 0;
    a5 = 0;
    a6 = 0;

    angle1=0;
    angle2=0;
    angle3=0;
    angle4=0;
    angle5=0;
    angle6=0;

    astep1 = 100/timelimit1;
    astep2 = 93/timelimit2;
    astep3 = 86/timelimit3;
    astep4 = 79/timelimit4;
    astep5 = 71/timelimit5;
    astep6 = 60/timelimit6;

    ll1 = xorigin;
    tt1 = yorigin;

    ll2 = xorigin;
    tt2 = yorigin;

    ll3 = xorigin;
    tt3 = yorigin;

    ll4 = xorigin;
    tt4 = yorigin;

    ll5 = xorigin;
    tt5 = yorigin;

    ll6 = xorigin;
    tt6 = yorigin;

    radius = 150;

    t1 = setTimeout("animateBubble1()",100);
    t2 = setTimeout("animateBubble2()",110);

    t3 = setTimeout("animateBubble3()",210);
    t4 = setTimeout("animateBubble4()",310);
    t5 = setTimeout("animateBubble5()",410);
    t6 = setTimeout("animateBubble6()",510);

   
    bubsize=120;
    voff=bubsize/3;
    hoff=bubsize/3;
    pow=3;

    timestep=100;
}

function animateBubble1(){
    a1+=astep1;
    angle1=180*a1/57.3;
    time1+=timestep;
    if (time1 < timelimit1){
        ll1 = radius * Math.sin(angle1) - Math.pow(a1,pow)*xoffset + (xorigin-radius);
        tt1 = radius * Math.cos(angle1) +(yorigin-radius);
        scale1=time1/timelimit1;
        moveBubble1();
        resetAnimationTimer1();
    }
}

function animateBubble2(){
    //return;
    a2+=astep2;
    angle2=180*a2/57.3;
    time2+=timestep;
    if (time2 < timelimit2){
        ll2 = radius * Math.sin(angle2) - Math.pow(a2,pow)*xoffset + (xorigin-radius);
        tt2 = radius * Math.cos(angle2) +(yorigin-radius);
        scale2=time2/timelimit2;
        moveBubble2();
        resetAnimationTimer2();
    }
}

function animateBubble3(){
    //return;
    a3+=astep3;
    angle3=180*a3/57.3;
    time3+=timestep;
    if (time3 < timelimit3){
        ll3 = radius * Math.sin(angle3) - Math.pow(a3,pow)*xoffset + (xorigin-radius);
        tt3 = radius * Math.cos(angle3) +(yorigin-radius);
        scale3=time3/timelimit3;
        moveBubble3();
        resetAnimationTimer3();
    }
}

function animateBubble4(){
    a4+=astep4;
    angle4=180*a4/57.3;
    time4+=timestep;
    if (time4 < timelimit4){
        ll4 = radius * Math.sin(angle4) - Math.pow(a4,pow)*xoffset + (xorigin-radius);
        tt4 = radius * Math.cos(angle4) +(yorigin-radius);
        scale4=time4/timelimit4;
        moveBubble4();
        resetAnimationTimer4();
    }
}

function animateBubble5(){
    a5+=astep5;
    angle5=180*a5/57.3;
    time5+=timestep;
    if (time5 < timelimit5){
        ll5 = radius * Math.sin(angle5) - Math.pow(a5,pow)*xoffset + (xorigin-radius);
        tt5 = radius * Math.cos(angle5) +(yorigin-radius);
        scale5=time5/timelimit5;
        moveBubble5();
        resetAnimationTimer5();
    }
}

function animateBubble6(){
    a6+=astep6;
    angle6=180*a6/57.3;
    time6+=timestep;
    if (time6 < timelimit6){
        ll6 = radius * Math.sin(angle6) - Math.pow(a6,pow)*xoffset + (xorigin-radius);
        tt6 = radius * Math.cos(angle6) +(yorigin-radius);
        scale6=time6/timelimit6;
        moveBubble6();
        resetAnimationTimer6();
    }
    else{
        to=setTimeout("makeLinksVisible()",100);
        collectBubbles();
    }
}

function resetAnimationTimer1(){
    t1 = setTimeout("animateBubble1()",5);
}

function resetAnimationTimer2(){
    t2 = setTimeout("animateBubble2()",10);
}

function resetAnimationTimer3(){
    t3 = setTimeout("animateBubble3()",15);
}

function resetAnimationTimer4(){
    t4 = setTimeout("animateBubble4()",20);
}

function resetAnimationTimer5(){
    t5 = setTimeout("animateBubble5()",25);
}

function resetAnimationTimer6(){
    t6 = setTimeout("animateBubble6()",30);
}

function moveBubble1(){

    div1 =  document.getElementById("bub1");
    //div1.setAttribute("visibility", "visible");
    div1.style.visibility="visible";
    div1.style.top=tt1;
    div1.style.left=ll1;

    link1.style.top =tt1+voff;
    link1.style.left =ll1+hoff;

    div1.style.width=scale1*bubsize;
    div1.style.height=scale1*bubsize;
}

function moveBubble2(){

    div2 =  document.getElementById("bub2");
    div2.style.visibility="visible";
    div2.style.top=tt2;
    div2.style.left=ll2;
    link2.style.top =tt2+voff;
    link2.style.left =ll2+hoff;
    div2.style.width=scale2*bubsize;
    div2.style.height=scale2*bubsize;
}

function moveBubble3(){
    div3 =  document.getElementById("bub3");
    div3.style.visibility="visible";
    div3.style.top=tt3;
    div3.style.left=ll3;
    link3.style.top =tt3+voff;
    link3.style.left =ll3+hoff-20;
    div3.style.width=scale3*bubsize;
    div3.style.height=scale3*bubsize;
}

function moveBubble4(){
    div4 =  document.getElementById("bub4");
    div4.style.visibility="visible";
    div4.style.top=tt4;
    div4.style.left=ll4;
    link4.style.top =tt4+voff+ 40;
    link4.style.left =ll4+hoff;
    div4.style.width=scale4*bubsize;
    div4.style.height=scale4*bubsize;
}

function moveBubble5(){
    div5 =  document.getElementById("bub5");
    div5.style.visibility="visible";
    div5.style.top=tt5;
    div5.style.left=ll5;
    link5.style.top =tt5+voff;
    link5.style.left =ll5+hoff;
    div5.style.width=scale5*bubsize;
    div5.style.height=scale5*bubsize;
}

function moveBubble6(){
    div6 =  document.getElementById("bub6");
    div6.style.visibility="visible";
    div6.style.top=tt6;
    div6.style.left=ll6;
    link6.style.top =tt6+voff;
    link6.style.left =ll6+hoff;
    div6.style.width=scale6*bubsize;
    div6.style.height=scale6*bubsize;
}

function makeLinksVisible(){
    //link1.style.top = div1.style.top;
    //link1.style.left = div1.style.left;
    link1.style.visibility="visible";

    //link2.style.top = div2.style.top;
    //link2.style.left = div2.style.left;
    link2.style.visibility="visible";

    //link3.style.top = div3.style.top;
    //link3.style.left = div3.style.left;
    link3.style.visibility="visible";

    //link4.style.top = div4.style.top;
    //link4.style.left = div4.style.left;
    link4.style.visibility="visible";

    //link5.style.top = div5.style.top;
    //link5.style.left = div5.style.left;
    link5.style.visibility="visible";

    //link6.style.top = div6.style.top;
    //link6.style.left = div6.style.left;
    link6.style.visibility="visible";

}

function doubleWidth(el){
    el =  document.getElementById("bub1");
    alert("dw");
    el.style.width*=2;
    el.style.width="400px";
    el.style.backgroundColor="red";
}

function increaseSize(el){
    images = el.
    oldw=el.style.width;
    oldh=el.style.height;
    el.style.width= '100px';
    el.style.height= '100px';

}

function decreaseSize(el){
    //return;
    el.style.width = oldw;
    el.style.height = oldh;
}

function burstBubble(el){
    el.src="images/nbubble_burst.png";
//el.innerHTML = el.innerHTML +"<br>";
}

function delayedLink(str){
    //return;
    thelocation = str;
    dlt = setTimeout("gotoo()",1000);
}

function gotoo(){
    
    if (thelocation=="mapwindow.html"){
        //alert(thelocation);
        w = window.open(thelocation);
    }
    else{
        //alert(thelocation);
        self.location = thelocation;
    }
}

function openMapView(){
    map.style.visibility="visible";
    map.style.width=200;
    //map.style.height=120;

}

function closeMapView(){
    map.style.visibility="hidden";
    //map.style.width=0;
    //map.style.height=0;

}

function openNewMapWindow(){

    w = window.open("mapwindow.html");
//window.location="mapWindow.html";
}

function openContactDetails(){
    contact.style.visibility="visible";
    contact.style.width=250;
    contact.style.height=60;

}

function closeContactDetails(){
    contact.style.visibility="hidden";
    contact.style.width=0;
    contact.style.height=0;
}
function opendif1View(){
    dif1.style.visibility="visible";
    dif1.style.width=250;
    //dif1.style.height=120;

}

function closedif1View(){
    dif1.style.visibility="hidden";
    //dif1.style.width=0;
    //dif1.style.height=0;
}
function collectBubbles(){
    ta = new Array(6);

    ta[0] = document.getElementById("link1");
    ta[1] = document.getElementById("link2");
    ta[2] = document.getElementById("link3");
    ta[3] = document.getElementById("link4");
    ta[4] = document.getElementById("link5");
    ta[5] = document.getElementById("link6");



    ba = new Array(6);

    ba[0] = document.getElementById("bub1");
    ba[1] = document.getElementById("bub2");
    ba[2] = document.getElementById("bub3");
    ba[3] = document.getElementById("bub4");
    ba[4] = document.getElementById("bub5");
    ba[5] = document.getElementById("bub6");

    orig = new Array(6);

    orig[0]=ba[0].style.top;
    orig[1]=ba[1].style.top;
    orig[2]=ba[2].style.top;
    orig[3]=ba[3].style.top;
    orig[4]=ba[4].style.top;
    orig[5]=ba[5].style.top;

   tb = window.setInterval("bounceBubbles()",500);

}

function bounceBubbles(){
    for (i =0; i<6; i++){
        //alert(parseInt(ba[i].style.top + (Math.random()*20 -10)));
        txt = parseInt(orig[i]) + (Math.random()*10 -5);
        txtt = txt + hoff;
        txt+="px";
        txtt+="px";
        
        ba[i].style.top = txt;
        ta[i].style.top = txtt;
        //document.write("<h1>"+txt+"</h1>");
    }
}
function openenglish_boxView(){
    english_box.style.visibility="visible";
 
    //dif1.style.height=120;

}

function closeenglish_boxView(){
    english_box.style.visibility="hidden";
    //english_box.style.width=0;
    //english_box.style.height=0;
}
function openfrench_boxView(){
    french_box.style.visibility="visible";
    
    //french_box.style.height=120;

}

function closefrench_boxView(){
    french_box.style.visibility="hidden";
    //french_box.style.width=0;
    //french_box.style.height=0;
}
function openujView(){
    uj.style.visibility="visible";

    //uj.style.height=120;

}

function closeujView(){
    uj.style.visibility="hidden";
    //uj.style.width=0;
    //uj.style.height=0;
}
function openffView(){
    ff.style.visibility="visible";

    //ff.style.height=120;

}

function closeffView(){
    ff.style.visibility="hidden";
    //ff.style.width=0;
    //ff.style.height=0;
}
function openNewnewsletterWindow(){

    w = window.open("images/newsletter.pdf");
//window.location="mapWindow.html";
}

