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";
	
	myImages[31]="31";
	myImages[32]="32";
	myImages[33]="33";
	myImages[34]="34";
	myImages[35]="35";
	myImages[36]="36";
	myImages[37]="37";
	myImages[38]="38";
	myImages[39]="39";
	myImages[40]="40";
	myImages[41]="41";
	myImages[42]="42";
	myImages[43]="43";
	myImages[44]="44";
	myImages[45]="45";
	myImages[46]="46";
	myImages[47]="47";
	myImages[48]="48";
	myImages[49]="49";
	myImages[50]="50";
	myImages[51]="51";
	myImages[52]="52";
	myImages[53]="53";
	myImages[54]="54";
	myImages[55]="55";
	myImages[56]="56";
	myImages[57]="57";
	myImages[58]="58";
	myImages[59]="59";
	myImages[60]="60";
	myImages[61]="61";
	myImages[62]="62";
	
	myImages[63]="63";
	myImages[64]="64";
	myImages[65]="65";
	myImages[66]="66";
	myImages[67]="67";
	myImages[68]="68";
	myImages[69]="69";
	myImages[70]="70";
	myImages[71]="71";
	myImages[72]="72";
	myImages[73]="73";
	myImages[74]="74";
	myImages[75]="75";
	myImages[76]="76";
	myImages[77]="77";
	myImages[78]="78";
	myImages[79]="79";
	myImages[80]="80";

	myImages[81]="81";
	myImages[82]="82";
	myImages[83]="83";
	myImages[84]="85";
	myImages[86]="86";
	myImages[87]="87";
	myImages[88]="88";
	myImages[89]="89";
	myImages[90]="90";
	myImages[91]="91";
	myImages[92]="92";
	myImages[93]="93";
	myImages[94]="94";
	myImages[95]="95";
	myImages[96]="96";
	myImages[97]="97";
	myImages[98]="98";
	myImages[99]="99";
	
	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);
}

