var imgId;
var newSrc;
var prodName;
function sh_termsnav(onoff){
    if(onoff==0)
        document.getElementById('termsnav').style.visibility="hidden";
    else
        document.getElementById('termsnav').style.visibility="visible";
}
function randImg()
{
	var myImages = new Array();
	myImages[0]="0";
	myImages[1]="1";
	myImages[2]="2";
	myImages[3]="3";
	myImages[4]="4";
	myImages[5]="5";
	myImages[6]="6";
	myImages[7]="7";
	myImages[8]="8";
	myImages[9]="9";
	myImages[10]="10";
	myImages[11]="11";
	myImages[12]="12";
	myImages[13]="13";
	myImages[14]="14";
	myImages[15]="15";
	myImages[16]="16";
	myImages[17]="17";
	myImages[18]="18";
	myImages[19]="19";
	myImages[20]="20";
	myImages[21]="21";
	myImages[22]="22";
	myImages[23]="23";
	myImages[23]="23";
	myImages[24]="24";
	myImages[25]="25";
	myImages[26]="26";
	myImages[27]="27";
	myImages[28]="28";
	myImages[29]="29";
	myImages[30]="30";
	
	ry = Math.floor(Math.random()*myImages.length);
	swpBg();
}

function swpBg()
{
	ry = parseInt(ry);
	document.getElementById('inner').style.backgroundImage="url(/images/homepage/bg" + ry + ".jpg)";
}

function swpImg(imgId, newSrc)
{
	//alert(imgId);
	document.getElementById(imgId).src = newSrc;
}

function displayProd(prodName)
{
	document.getElementById(prodName).style.visibility = "visible";
	document.getElementById(prodName).style.display = "block";
	document.getElementById("intro1").style.visibility = "hidden";
	document.getElementById("intro1").style.display = "none";
	document.getElementById("intro2").style.visibility = "hidden";
	document.getElementById("intro2").style.display = "none";

}

function hideProd(prodName)
{
	document.getElementById(prodName).style.visibility = "hidden";
	document.getElementById(prodName).style.display = "none";
}
displayImg  = 'displayImg';
imageWidth  = 400;
imageHeight = 400;
timer       = 4000;
animation   = 20;
delay       = null;
var currImg     = 0;
nextImg     = 1;
wipeWidth   = 0;
curLeft     = 0;
curTop      = 0;
frame       = 0;
wait        = timer;
function init() {
    if (document.images && document.getElementById) {
      if (document.getElementById(displayImg)){
        findImgPos(document.getElementById(displayImg));
        document.getElementById("wipe").style.left = curLeft + 'px';
        document.getElementById("wipe").style.top = curTop + 'px';
        slideShow(1);
     }
   }
}

function findImgPos(obj) {
    if(obj.offsetParent) {
        while(1) {
            curLeft += obj.offsetLeft;
            curTop += obj.offsetTop;
            if(!obj.offsetParent) {
                break;
            }
            obj = obj.offsetParent;
        }
    } else if(obj.x) {
        curLeft += obj.x;
        curTop += obj.y;
    }
}

function slideShow(newImg,wipe) {
    clearTimeout(delay);
    currImg = newImg;
    nextImg = currImg;


    if (frame == 0) {
        wipeWidth += 20;
        frame = (wipeWidth < imageWidth ? 0 : 1);
        wait = animation;
        document.getElementById("wipe").style.width = wipeWidth + 'px';
    } else if (frame == 1) {
        nextImg = (currImg >= (imageSlides.length-1) ? 0 : currImg+1);
        frame = 2;
        wait = animation;
        document.getElementById(displayImg).src = imageSlides[currImg].src;
    } else if (frame == 2) {
        wipeWidth -= 20;
        frame = (wipeWidth > 0 ? 2 : 3);
        wait = animation;
        document.getElementById("wipe").style.width = wipeWidth + 'px';
    } else {
        wipeWidth = 0;
        frame = 0;
        wait = timer;
        document.getElementById("wipe").style.width = wipeWidth + 'px';
    }
    
    delay = setTimeout('slideShow(nextImg,frame)',wait);
}
