// JavaScript Document

function initTapThree()
{
 var maxItems = 4;
 var tap3Mask = document.getElementById("tap3_mask");
 var tap3Tray = document.getElementById("tap3_tray");
 var tap3Items = tap3Tray.getElementsByTagName("li");
 var tap3Item = new Object();
 tap3Item.elm = tap3Tray.getElementsByTagName("li")[0];
 tap3Item.width = parseInt(SlateDom.getCurrentStyle(tap3Item.elm,"width"));
 tap3Item.height = (isNaN(SlateDom.getCurrentStyle(tap3Item.elm,"height")))?"auto":SlateDom.getCurrentStyle(tap3Item.elm,"height");
 tap3Item.lMargin = (parseInt(SlateDom.getCurrentStyle(tap3Item.elm,"margin-left")))?parseInt(SlateDom.getCurrentStyle(tap3Item.elm,"margin-left")):parseInt(SlateDom.getCurrentStyle(tap3Item.elm,"marginLeft"));

 with(tap3Mask.style)
 {
 //width = ((tap3Item.width + tap3Item.lMargin * 2) * maxItems) + "px";
 height = tap3Item.height;
 }
 with(tap3Tray.style)
 {
 width = ((tap3Item.width + tap3Item.lMargin * 2) * tap3Items.length) + "px";
 height = tap3Item.height;
 left = "0px"
 }
 var tap3Lefts = new Array();
 var maskWidth = parseInt(tap3Mask.style.width);
 var trayWidth = parseInt(tap3Tray.style.width);
 var failInt = Math.floor(trayWidth/maskWidth);
 for (var i=0; i<failInt; i++)
 {
 tap3Lefts.push((-(maskWidth*i))+"px");
 }
 tap3Tray.style.left = tap3Lefts[parseInt(Math.random()*tap3Lefts.length)];
}


function moveTap3(dir)
{
 var tap3Tray = document.getElementById("tap3_tray");
 var pos = parseInt(tap3Tray.style.left);
 var trayWidth = parseInt(tap3Tray.style.width);
 var maskWidth = parseInt(document.getElementById("tap3_mask").style.width);
 if(dir=="left")
 {
 if(pos - maskWidth < maskWidth - trayWidth)
 {
 tap3Tray.style.left = 0
 }
 else
 {
 tap3Tray.style.left = (pos - maskWidth) + "px";
 }
 }
 if(dir=="right")
 {
 if(pos + maskWidth > 0)
 {
 tap3Tray.style.left = maskWidth - trayWidth + "px";
 }
 else
 {
 tap3Tray.style.left = (pos + maskWidth) + "px";

 }
 }
}


initTapThree();
