var value=new Array(0,0);
var sTEP=new Array(0,0);
var cPIC=new Array(0,0);
var prevID=new Array(0,0);
var maxPIC=new Array(0,0);
var timeDelay=1;
var pTime;
var cIMG=0;
var maxSHOW=0;
var ClickPage=0;

// Distributed by http://www.hypergurl.com
// Scrollers width here (in pixels) 
var scrollerwidth="296px";
// Scrollers height here 
var scrollerheight="80px";
// Scrollers speed here (larger is faster 1-10) 
var scrollerspeed=2;
// Scrollers content goes here! Keep all of the message on the same line! 
var scrollercontent='';
var pauseit=1; // Change nothing below! 
scrollerspeed=(document.all)? scrollerspeed : Math.max(1,scrollerspeed-1); //slow speed down by 1 for NS 
var copyspeed=scrollerspeed;
var iedom=document.all||document.getElementById;
var actualheight=''; 
var cross_scroller, ns_scroller;
var pausespeed=(pauseit==0)? copyspeed: 0; 
//--end scroll 

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id, zdx) {
    var object = document.getElementById(id).style;
    object.visibility='visible';
    object.zIndex=zdx; 
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function run_(j){
var alla=document.getElementById("win_"+j).getElementsByTagName("div");
gp=(j==0?"A":"B");
maxPIC[j]=alla.length;
sTEP[j]=value[j]%20;
cPIC[j]=Math.floor(value[j]/20);
prevID[j]=(cPIC[j]>0?cPIC[j]-1:maxPIC[j]-1);
if (maxPIC[j]>1){
   if (sTEP[j]==0){changeOpac(1,gp+cPIC[j],maxPIC[j]);changeOpac(100,gp+prevID[j],maxPIC[j]-1);
   }else{
   if (sTEP[j]<6){
        changeOpac(sTEP[j]*20,gp+cPIC[j],maxPIC[j]);changeOpac(100-sTEP[j]*20,gp+prevID[j],maxPIC[j]-1);
       }else{document.getElementById(gp+prevID[j]).style.visibility='hidden';}
   }
}else{changeOpac(100,gp+cPIC[j],maxPIC);}
if (value[j]+1<(maxPIC[j]*20)){value[j]++;}else{value[j]=0;}
}

function pic_change(id,desc){
document.getElementById(id).src=id+desc+".jpg";
}

function pic_change_gif(id,desc){
document.getElementById(id).src=id+desc+".gif";
}

function addVAR(obj,vSTART,vEND,vADD){
if (vSTART>vEND) {
   vSTART=vSTART+vADD;
   obj.style.left=vSTART+'px';
   pTime=setTimeout((function(){addVAR(obj,vSTART,vEND,vADD);}),timeDelay);
}else{
   vSTART=vEND;
   obj.style.left=vSTART+'px';
   clearTimeout(pTime);
}
}

function decVAR(obj,vSTART,vEND,vADD){
if (vSTART<vEND) {
   vSTART=vSTART+vADD;
   obj.style.left=vSTART+'px';
   pTime=setTimeout((function(){decVAR(obj,vSTART,vEND,vADD);}),timeDelay);
}else{
   vSTART=vEND;
   obj.style.left=vSTART+'px';
   clearTimeout(pTime);
}
}

function click_left(){
var obj=document.getElementById('tSHOW');
sT=-cIMG*368;
if (cIMG>0){cIMG--;}
eN=-cIMG*368;
pTime=setTimeout((function(){decVAR(obj,sT,eN,8);}),timeDelay);
}

function click_right(){
var obj=document.getElementById('tSHOW');
var alla=document.getElementById("tSHOW").getElementsByTagName("img");
maxSHOW=alla.length;
sT=-cIMG*368;
if (cIMG<maxSHOW-1) {cIMG++;}
eN=-cIMG*368;
pTime=setTimeout((function(){addVAR(obj,sT,eN,-8);}),timeDelay);
}

function click_up(){
var obj=document.getElementById('pic_scroller');
if (parseInt(obj.style.top)<0){
  obj.style.top=parseInt(obj.style.top)+10+"px";
}else{
  obj.style.top="0px"; 
}
}

function click_down(){
var obj=document.getElementById('pic_scroller');
rh=obj.offsetHeight;
if (rh+parseInt(obj.style.top)>355){
  obj.style.top=parseInt(obj.style.top)-10+"px";
}
}

function flyUP(obj,vSTART,vEND,vADD){
if (vSTART>vEND) {
   vSTART=vSTART+vADD;
   obj.top=vSTART+'px';
   pTime=setTimeout((function(){flyUP(obj,vSTART,vEND,vADD);}),200);
}else{
   vSTART=vEND;
   obj.top=vSTART+'px';
   obj.visibility='hidden';
   clearTimeout(pTime);
}
}

function bfly(){
var obj=document.getElementById('butterfly').style;
obj.visibility='visible';
obj.zIndex=100;
obj.left=(Math.round(Math.random()*600)+100)+'px';
pTime=setTimeout((function(){flyUP(obj,600,-100,-15);}),200);
}

function InitEveryPage(){
if (ClickPage==2){
   menu2_SelectProduct(4);
   ClickPage=0;
}
}

function coverOPEN(pname){
document.getElementById("overlay").style.display="block";
document.getElementById("overlay").style.visibility="visible";
document.getElementById("overlay").style.zIndex=999;
document.getElementById("overlay1").style.visibility="visible";
document.getElementById("overlay1").style.zIndex=9999;
document.getElementById("pshow").src=""+pname;
}

function coverCLOSE(){
document.getElementById("overlay").style.display="none";
document.getElementById("overlay").style.visibility="hidden";
document.getElementById("overlay1").style.visibility="hidden";
}



function populate(){ 
if (iedom){
cross_scroller=document.getElementById?document.getElementById("iescroller") : document.all.iescroller;
cross_scroller.style.top=parseInt(scrollerheight)+8+"px";
cross_scroller.innerHTML=scrollercontent;
actualheight=cross_scroller.offsetHeight;
} else if (document.layers){
ns_scroller=document.ns_scroller.document.ns_scroller2;
ns_scroller.top=parseInt(scrollerheight)+8;
ns_scroller.document.write(scrollercontent);
ns_scroller.document.close();
actualheight=ns_scroller.document.height;
}
//lefttime=setInterval("scrollscroller()",20); 
} 

function scrollscroller(){
if (iedom){ 
cross_scroller=document.getElementById("iescroller");
actualheight=cross_scroller.offsetHeight;
if (parseInt(cross_scroller.style.top)>(actualheight*(-1)+8))
cross_scroller.style.top=parseInt(cross_scroller.style.top)-copyspeed+"px";
else cross_scroller.style.top=parseInt(scrollerheight)+8+"px";
} else if(document.layers){ 
ns_scroller=document.ns_scroller.document.ns_scroller2;
actualheight=ns_scroller.document.height;
if (ns_scroller.top>(actualheight*(-1)+8))
ns_scroller.top-=copyspeed; else
ns_scroller.top=parseInt(scrollerheight)+8;
}
} 

