function getElement(id){return document.getElementById(id);}
function getCoordinates(id){var id=getElement(id);var
left=id.offsetLeft,top=id.offsetTop;for(var parent=id.offsetParent;parent;parent=parent.offsetParent){left+=parent.offsetLeft-parent.scrollLeft;top+=parent.offsetTop-parent.scrollTop;}
return{width:id.offsetWidth,height:id.offsetHeight,left:left,top:top};}
var
basketMessage_timer;function basketMessage(set){if(!set){getElement("basketMessage").style.display="none";window.clearInterval(basketMessage_timer);}else{getElement("basketMessage").style.display="block";basketMessage_timer=window.setInterval('basketMessage(false)',5000);}}
var
setMove_key=false,setMove_timer,setMove_step=1,setMove_steps=60;function setMove(elementID,sourceID,targetID){setMove_key=true;var
coordinatesElement=getCoordinates(elementID),coordinatesSource=getCoordinates(sourceID),coordinatesTarget=getCoordinates(targetID);var
element=getElement(elementID),source=getElement(sourceID),target=getElement(targetID);element.style.display="block";var
x1=coordinatesSource.left,y1=coordinatesSource.top,x2=coordinatesTarget.left,y2=coordinatesTarget.top,xDelta,yDelta,x,y;if(x1<x2){xDelta=Math.abs(x2-x1);}else{xDelta=Math.abs(x1-x2);}
if(y1<y2){yDelta=Math.abs(y2-y1);}else{yDelta=Math.abs(y1-y2);}
step=setMove_step/setMove_steps;if(setMove_step<=setMove_steps){if(x1<x2){x=x1+Math.round(xDelta*step);}else{x=x1-Math.round(xDelta*step);}
if(y1<y2){y=y1+Math.round(yDelta*step);}else{y=y1-Math.round(yDelta*step);}
width=coordinatesSource.width-Math.round((coordinatesSource.width-coordinatesTarget.width)*step);height=coordinatesSource.height-Math.round((coordinatesSource.height-coordinatesTarget.height)*step);element.setAttribute("width",width);element.setAttribute("height",height);element.style.left=x+"px";element.style.top=y+"px";setMove_step++;}else{setMove_key=false;setMove_step=1;element.style.display="none";if(getElement("submitBasket")&&getElement("submitBasket").getAttribute("disabled")){getElement("submitBasket").removeAttribute("disabled");}
if(getElement("productForm"))
{getElement("productForm").submit();}else if(getElement("productForm_"+sourceID)){getElement("productForm_"+sourceID).submit();}
window.clearInterval(setMove_timer);getElement("basketTarget").style.display="none";window.location.href="/shop-basket.html";}}
var
scrollSmooth_key=false,scrollSmooth_timer,scrollSmooth_step=scrollSmooth_steps=50,scrollDistance=false;function scrollSmooth(sourceID){if(getElement("submitBasket")){getElement("submitBasket").setAttribute("disabled","disabled");}
scrollSmooth_step--;var
scrollDeterminant=getCoordinates("scroll");if(scrollDistance==false){scrollDistance=Math.abs(scrollDeterminant.top);}
if(scrollSmooth_step==0||scrollDistance===0){window.scroll(0,0);scrollSmooth_step=50;scrollDistance=false;window.clearInterval(scrollSmooth_timer);scrollSmooth_key=true;setBasket(sourceID);}else{window.scroll(0,Math.round(scrollDistance*(scrollSmooth_step/scrollSmooth_steps)));}}
function setBasket(sourceID)
{if(getElement("productForm")){getElement("productForm").submit();}else if(getElement("productForm_"+sourceID)){getElement("productForm_"+sourceID).submit();}}
