var topDiv='div1'; var bottomDiv; //Описание переменных для подмены слоев var posLeft1, posTop1, posIndex1, posWidth1; var posLeft2, posTop2, posIndex2, posWidth2; var timerAnimation; var firstDx1, firstDx2, firstDy1, firstDy2; var topDiv2; function changeDiv(divName) { //делаем имя слоя глобальным bottomDiv=divName; topDiv2=topDiv; //Собираем свойства верхнего слоя posLeft1=parseInt(document.getElementById(topDiv).currentStyle.left); posTop1=parseInt(document.getElementById(topDiv).currentStyle.top); posIndex1=document.getElementById(topDiv).currentStyle.zIndex; posWidth1=parseInt(document.getElementById(topDiv).currentStyle.width); //Собираем свойства выбранного слоя posLeft2=parseInt(document.getElementById(divName).currentStyle.left); posTop2=parseInt(document.getElementById(divName).currentStyle.top); posIndex2=document.getElementById(divName).currentStyle.zIndex; posWidth2=parseInt(document.getElementById(divName).currentStyle.width); //Запуск анимации setupAnimation(); //Сделать выбранный слой верхним topDiv=divName; } function setupAnimation() { dx2=(posLeft2+posWidth2)/20; firstDx2=-dx2; dx1=(document.body.clientWidth-posLeft1)/20; firstDx1=dx1; dy1=(posTop2+posTop1)/2-posTop1; firstDy1=dy1/20; dy2=(posTop2+posTop1)/2-posTop2; firstDy2=dy2/20; timerAnimation=window.setInterval("moveImage()",10); } function moveImage() { divLeft1=parseInt(document.getElementById(topDiv2).currentStyle.left); divLeft2=parseInt(document.getElementById(bottomDiv).currentStyle.left); divTop1=parseInt(document.getElementById(topDiv2).currentStyle.top); divTop2=parseInt(document.getElementById(bottomDiv).currentStyle.top); if(divLeft1 <= document.body.clientWidth || divLeft2 >= -posWidth2) { document.getElementById(topDiv2).style.left=divLeft1+firstDx1; document.getElementById(bottomDiv).style.left=divLeft2+firstDx2; document.getElementById(topDiv2).style.top=divTop1+firstDy1; document.getElementById(bottomDiv).style.top=divTop2+firstDy2; divLeft1=parseInt(document.getElementById(topDiv2).currentStyle.left); divLeft2=parseInt(document.getElementById(bottomDiv).currentStyle.left); } if(divLeft1 > document.body.clientWidth && divLeft2 <-posWidth2) { counter=1; firstDx1=-firstDx1; firstDx2=-firstDx2; document.getElementById(topDiv2).style.left=divLeft1+firstDx1; document.getElementById(bottomDiv).style.left=divLeft2+firstDx2; document.getElementById(bottomDiv).style.zIndex=posIndex1; document.getElementById(topDiv2).style.zIndex=posIndex2; } if(counter=1 && ( (divLeft1-posLeft2) <=30 || (posLeft1-divLeft2)<=30)) { document.getElementById(topDiv2).style.left=posLeft2; document.getElementById(bottomDiv).style.left=posLeft1; document.getElementById(topDiv2).style.top=posTop2; document.getElementById(bottomDiv).style.top=posTop1; clearInterval(timerAnimation); } } //Описание переменных для печатной машинки var textAreaName=text1; var myStr; var i; var myStrAsArray; var typeStr; var xInterval; //Функция печатной машинки function machineText(textName) { i=0; typeStr=""; textAreaName=textName; myStr=document.getElementById(textName).innerText; myStrAsArray=myStr.split(""); xInterval=setInterval("wrtext()",50); } function wrtext() { if (i