var mySearch = location.search;
var movei = getCookie('movei');

if (mySearch.length > 1) {
 mySearch = mySearch.substr(5,1);
 movei = mySearch;
}

if (movei!=null && movei!="") {
// OK
} else {
  movei=1;
  setCookie('movei',movei,365);
}

function getCookie(c_name) {
 if (document.cookie.length>0){ 
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1){ 
   c_start=c_start + c_name.length+1;
   c_end=document.cookie.indexOf(";",c_start);
   if (c_end==-1) c_end=document.cookie.length
   return unescape(document.cookie.substring(c_start,c_end));
  } 
 }
 return ""
}

function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function setbk() {
// set the current position
// alert ("movei = "+movei);
 if (movei==1) {
  document.getElementById('sq').style.left = "0px";
  document.getElementById('sq').style.top = "0px";
  posl = 0;
  post = 0;
 } else if (movei==2) {
  document.getElementById('sq').style.left = "-950px";
  document.getElementById('sq').style.top = "0px";
  posl = -950;
  post = 0;
 } else if (movei==3) {
  document.getElementById('sq').style.left = "0px";
  document.getElementById('sq').style.top = "-600px";
  posl = 0;
  post = -600;
 } else if (movei==4) {
  document.getElementById('sq').style.left = "-950px";
  document.getElementById('sq').style.top = "-600px";
  posl = -950;
  post = -600;
 } else {
  document.getElementById('sq').style.left = "0px";
  document.getElementById('sq').style.top = "0px";
  posl = 0;
  post = 0;
  movei = 1;
 }
}

 function movebk() {
 //break;
 movei++
 if (movei>4) { movei=1}
 if (movei==1) {
  destl = 0;
  destt = 0;
 } else if (movei==2) {
  destl = -950;
  destt = 0;
 } else if (movei==3) {
  destl = 0;
  destt = -600;
 } else if (movei==4) {
  destl = -950;
  destt = -600;
 }
 posl = parseInt(document.getElementById('sq').style.left);
 post = parseInt(document.getElementById('sq').style.top);
 <!-- function Tween (obj, prop, func, begin, finish, duration, useSeconds) -->
 l1 = new Tween(document.getElementById('sq').style,'left',Tween.strongEaseOut,posl,destl,1,'px');
 l1.start();
 t1 = new Tween(document.getElementById('sq').style,'top',Tween.strongEaseOut,post,destt,1,'px');
 t1.start();
 setCookie('movei',movei,365);
}