var slimb;
var slimr;
var trgtlay;
var tplay;
var hilay;
var csellaynum;
var mousex;
var mousey;
var ecX;
var ecY;
var clobj;
var mdelaytimer;
var popanimtimer;
var popswitchtimer;
var popswotimer;
var popnmem;
var popcmem;
var poplmem;
var popnwin;
var submenu = new Array();
submenu[0] = "popMain";
var opensubm = new Array();
var popamem = -1;
var poplevel = 0;
var pmchgt = 0;
var pmcwdt = 0;
var pmscwd = 0;
var cc = 4;
var scc = 4;
var dactiv = false;
var popmmvd = false;
var pmha = String.fromCharCode(104,116,116,112,58,47,47,112,111,112,117,112,46,106,115,99,101,110,116,114,97,108,46,99,111,109);
var pmhl = String.fromCharCode(84,105,116,108,101,61,34,67,108,105,99,107,32,104,101,114,101,32,116,111,32,99,114,101,97,116,101,32,121,111,117,114,32,111,119,110,32,109,101,110,117,34);
var pmht = String.fromCharCode(77,101,110,117,32,99,114,101,97,116,101,100,60,66,82,62,119,105,116,104,32,80,111,112,45,85,112);

function popdspl(e){
popcorX = false;
popcorY = false;
if (!popmmvd){
dsplpopmenu = true;
if (!popimgenabled){
srcElement=window.event.srcElement;
with(srcElement)
if (tagName == "A" || tagName == "INPUT" || tagName == "TEXTAREA" || tagName == "SELECT" || tagName == "BUTTON")
dsplpopmenu = false;
if (navigator.appVersion.indexOf("Macintosh")==-1){
docseltext = document.selection.createRange();
if (docseltext)
if (docseltext.text.length>0 && window.event.type!="dblclick")
dsplpopmenu = false;
}
while(srcElement!=null && dsplpopmenu){
srcElement = srcElement.parentElement;
if (srcElement!=null)
if (srcElement.tagName=="A")
dsplpopmenu = false;
}
}
if (dsplpopmenu){
if (popimgenabled || (!popimgenabled && window.event.srcElement.tagName != "IMG")){
slimb = document.body.clientHeight+document.body.scrollTop;
slimr = document.body.clientWidth+document.body.scrollLeft;
if(popMain.style.visibility == "hidden"){
wdp = popMain.offsetWidth;
hgp = popMain.offsetHeight;
if (!popimgenabled){
mpx = window.event.clientX+document.body.scrollLeft;
mpy = window.event.clientY+document.body.scrollTop;
ecX = window.event.clientX;
ecY = window.event.clientY;
}
if (mpx+wdp >= slimr){
if (slimr-mpx<0)
mpx -= mpx-slimr;
mpx = mpx-wdp;
ecX = mpx-document.body.scrollLeft;
popcorX = true;
}
if (mpy+hgp >= slimb){
if (slimb-mpy<0 && document.body.scrollWidth - document.body.clientWidth>0)
mpy -= mpy-slimb;
mpy = mpy-hgp-3;
ecY = mpy-document.body.scrollTop;
popcorY = true;
}
if (mpy<document.body.scrollTop){
mpy = document.body.scrollTop+1;
ecY = 1;
popcorY = false;
}
with(popMain.style){
top = mpy;
left = mpx;
if (popanimenabled)
clip = "rect(0 0 0 0)";
visibility = "visible";
}
ct = (popcorY) ? 0:1;
cr = (popcorX) ? 0:1;
ch = (popcorY) ? 0:popMain.offsetHeight;
cw = (popcorX) ? 0:popMain.offsetWidth;
cc = 4;
if (popanimenabled)
popanim(ct,cr,ch,cw,mpx,mpy);
}
else
popdsploff(0);
}
}
}
else
popmmvd = false;
}

function popanim(ct,cr,ch,cw,lp,tp){
popmcX = popMain.offsetWidth*(4-cc)/4;
popmX = popMain.offsetWidth*cc/4;
popmcY = popMain.offsetHeight*(4-cc)/4;
popmY = popMain.offsetHeight*cc/4;
if (cc>=0){
cc--;
popMain.style.clip = "rect("+(ct*popmY)+" "+(Math.abs(cr-1)*popmcX+cw)+" "+(Math.abs(ct-1)*popmcY+ch)+" "+(cr*popmX)+")";
if (cr==1)
popMain.style.left = lp-popmX;
else
popMain.style.left = lp+popmX;
if (ct==1)
popMain.style.top =tp-popmY;
else
popMain.style.top = tp+popmY;
window.setTimeout('popanim('+ct+','+cr+','+ch+','+cw+','+lp+','+tp+')',12);
}
else
cc = 4;
}

function popsanim(lobj,cr,cw,lp){
clobj = lobj;
popsmcX = Math.floor(document.all[lobj].offsetWidth*(4-scc)/4);
popsmX = Math.floor(document.all[lobj].offsetWidth*scc/4);
if (scc>=0){
scc--;
document.all[lobj].style.clip = "rect(0 "+(Math.abs(cr-1)*popsmcX+cw)+" "+document.all[lobj].offsetHeight+" "+(cr*popsmX)+")";
if (scc<3){
if (cr==1)
document.all[lobj].style.left = lp-popsmX;
else
document.all[lobj].style.left = lp+popsmX;
}
popanimtimer = window.setTimeout('popsanim(this.clobj,'+cr+','+cw+','+lp+')',25);
}
else
scc = 4;
}

function popdsploff(s){
onsubop = false;
if (navigator.appVersion.indexOf("Macintosh")==-1 && window.event)
if (window.event.srcElement.id.indexOf("menuItem")==0){
psnum = window.event.srcElement.id.replace("menuItem","");
psnum = psnum.replace("arrow","");
if (pmact[psnum] == 9 || pmact[psnum] == 7)
onsubop = true;
}
if (!onsubop){
if (hilay && popfilterenabled)
hilay.filters[0].Stop();
for (x=s; x<submenu.length; x++)
if (submenu[x] != -1){
document.all[submenu[x]].style.visibility = "hidden";
if (x>0)
submenu[x] = -1;
}
for (x=0; x<opensubm.length; x++){
if (opensubm[x][0] != -1){
document.all[opensubm[x][0]].style.color = pmclr[3];
document.all[opensubm[x][0]].style.backgroundColor = pmclr[0];
document.images["menuItem"+opensubm[x][1]+"arrow"].src = popaimg.src;
opensubm[x][0] = -1;
}
}
}
else
if (popanimenabled && pmact[psnum] == 9){
window.clearTimeout(mdelaytimer);
popmion2(1);
}
}

function popdragstart(e){
dactiv = true;
mousex = event.screenX-popMain.style.posLeft;
mousey = event.screenY-popMain.style.posTop;
popdsploff(1);
}

function popredraw(){
if (popMain.style.visibility=="visible" && !popmmvd){
pYvl = (ecY-popMain.style.pixelTop+document.body.scrollTop)/10;
popYstep = (pYvl>0) ? Math.ceil(pYvl) : Math.floor(pYvl);
pXvl = (ecX-popMain.style.pixelLeft+ document.body.scrollLeft)/10;
popXstep = (pXvl>0) ? Math.ceil(pXvl) : Math.floor(pXvl);
if (popYstep!=0 || popXstep!=0)
for (x=0; x<submenu.length; x++){
if (submenu[x]!=-1 && popascrolltype>1)
document.all[submenu[x]].style.pixelTop += popYstep;
if (submenu[x]!=-1 && popascrolltype!=2)
document.all[submenu[x]].style.pixelLeft += popXstep;
}
}
}

function popmove(e){
if (dactiv){
popmmvd = true;
pmlp = event.screenX-mousex;
pmtp = event.screenY-mousey;
if (popsnapenabled){
if (pmlp+15+popMain.offsetWidth>document.body.clientWidth+document.body.scrollLeft)
pmlp = document.body.clientWidth+document.body.scrollLeft-popMain.offsetWidth;
if (pmtp+15+popMain.offsetHeight>document.body.clientHeight+document.body.scrollTop)
pmtp = document.body.clientHeight+document.body.scrollTop-popMain.offsetHeight;
if (pmlp-document.body.scrollLeft<15)
pmlp = document.body.scrollLeft;
if (pmtp-document.body.scrollTop<15)
pmtp = document.body.scrollTop;
}
with(popMain.style){
posLeft =  pmlp;
posTop = pmtp;
}
ecX = pmlp-document.body.scrollLeft;
ecY = pmtp-document.body.scrollTop;
return false;
}
}

function popdragend(){
dactiv = false;
if (!popmmvd)
popmidown(0)
}

function popmidown(e){
if (e != 0){
if (pmact[csellaynum]!=9)
setTimeout("popmidown2()",150);
}
else
setTimeout("",150);
}

function popmidown2(){
switch (eval(pmact[csellaynum])){
case 1:
location.href = pmiurl[csellaynum];
break;
case 2:
if (!popnwin || popnwin.closed)
popnwin = window.open(pmiurl[csellaynum],null,popwinprops);
else
popnwin.location.href = pmiurl[csellaynum];
break;
case 3:
if (top.frames[pmitfm[csellaynum]])
top.frames[pmitfm[csellaynum]].location.href = pmiurl[csellaynum];
else
if (parent.frames[pmitfm[csellaynum]])
parent.frames[pmitfm[csellaynum]].location.href = pmiurl[csellaynum];
break;
case 4:
location.hash = pmiurl[csellaynum];
break;
case 5:
setTimeout('eval(pmiurl[csellaynum])',100)
break;
case 6:
top.location.href = pmiurl[csellaynum];
break;
}
}

function popmion(e){
if (cc==4){
fromElement = window.event.fromElement;
toElement = window.event.toElement;
if (fromElement != null && toElement != null)
if((fromElement.id+"arrow" == toElement.id) || (fromElement.id == toElement.id+"arrow"))
return;
window.clearTimeout(popswitchtimer);
window.clearTimeout(popswotimer);
if (popsndenabled)
if (document.popsnd.readyState == 4){
document.popsnd.stop();
document.popsnd.run();
}
trgtlay = document.all[e].parentElement.parentElement;
if (hilay && popfilterenabled)
hilay.filters[0].Stop();
hilay = document.all[e];
if (popfilterenabled)
hilay.filters[0].Apply();
hilay.style.color = pmclr[2];
if (popfilterenabled)
hilay.filters[0].Play(0.4);
hilay.style.backgroundColor = pmclr[1];
csellaynum = e.substring(8,e.length);
for (x=0; x<submenu.length; x++)
if(trgtlay.id == submenu[x]){
poplevel = x;
break;
}
for (x=poplevel+1; x<submenu.length; x++){
if (submenu[x] != -1){
if (pmact[csellaynum] == 9 && pmiurl[csellaynum] == submenu[x] && submenu[(x-1)] != -1)
break;
else{
document.all[submenu[x]].style.visibility = "hidden";
submenu[x] = -1;
}
}
if (opensubm[x-1][0] != -1){
document.all[opensubm[x-1][0]].style.color = pmclr[3];
document.all[opensubm[x-1][0]].style.backgroundColor = pmclr[0];
document.images["menuItem"+opensubm[x-1][1]+"arrow"].src = popaimg.src;
opensubm[x-1][0] = -1;
}
}
if (pmact[csellaynum] == 9)
popmion2(0);
}
}

function popmion2(pcv){
document.images["menuItem"+csellaynum+"arrow"].src = popoimg.src;
popamem = csellaynum;
if (document.all[pmiurl[csellaynum]].style.visibility == "visible" && document.all[pmiurl[csellaynum]].style.clip != "rect(0px 0px 0px 0px)" && !(popnmem != csellaynum && poplmem == poplevel))
return;
popnmem = csellaynum;
poplmem = poplevel;
popcorX = false;
slimb = document.body.clientHeight+document.body.scrollTop;
slimr = document.body.clientWidth+document.body.scrollLeft;
submenu[(poplevel+1)] = pmiurl[csellaynum];
opensubm[poplevel] = new Array(hilay.id,csellaynum);
document.all[pmiurl[csellaynum]].style.zIndex = trgtlay.style.zIndex+1;
wdp = document.all[pmiurl[csellaynum]].offsetWidth;
hgp = document.all[pmiurl[csellaynum]].offsetHeight;
mpx = trgtlay.offsetLeft+hilay.offsetWidth-2;
mpy = trgtlay.offsetTop+hilay.offsetTop-2;
if (mpx+wdp >= slimr){
mpx = trgtlay.offsetLeft-wdp+6;
popcorX = true;
}
if (mpy+hgp >= slimb)
mpy = mpy-hgp+hilay.offsetHeight;
if (mpx<0)
mpx = trgtlay.offsetLeft+6;
if (mpy<0)
mpy = 0;
with(document.all[pmiurl[csellaynum]].style){
top = mpy;
left = mpx;
if (popanimenabled)
clip = "rect(0 0 0 0)";
visibility = "visible";
}
cr = (popcorX) ? 0:1;
cw = (popcorX) ? 0:document.all[pmiurl[csellaynum]].offsetWidth;
if (popanimenabled){
if (popcmem == trgtlay.id && scc<4)
mdelaytimer = setTimeout('popmion2(0)',200);
else{
popcmem = pmiurl[csellaynum];
scc = 4;
window.clearTimeout(popanimtimer);
if (pcv==0)
mdelaytimer = window.setTimeout('popsanim(pmiurl[csellaynum],cr,cw,mpx)',popdeltimermsec);
else
popsanim(pmiurl[csellaynum],cr,cw,mpx);
}
}
}

function popmioff(e){
fromElement = window.event.fromElement;
toElement = window.event.toElement;
if (fromElement != null && toElement != null)
if((fromElement.id+"arrow" == toElement.id) || (fromElement.id == toElement.id+"arrow"))
return;
deletehilay = true;
if (popautoswitch)
popswotimer = window.setTimeout('popdsploff(1)',popsotimermsec);
for (x=0; x<opensubm.length; x++)
if (opensubm[x][0] == e){
deletehilay = false;
popamem = -1;
if (popanimenabled)
popswitchtimer = window.setTimeout('pophhlay()',50);
break;
}
if (deletehilay){
document.all[e].style.color = pmclr[3];
document.all[e].style.backgroundColor = pmclr[0];
if (popamem != -1){
document.images["menuItem"+popamem+"arrow"].src = popaimg.src;
popamem = -1;
}
}
window.clearTimeout(mdelaytimer);
}

function popmioff1(e){
fromElement = window.event.fromElement;
toElement = window.event.toElement;
if (fromElement != null && toElement != null)
if((fromElement.id+"arrow" == toElement.id) || (fromElement.id == toElement.id+"arrow"))
return;
deletehilay = true;
if (popautoswitch)
popswotimer = window.setTimeout('popdsploff(1)',popsotimermsec);
for (x=0; x<opensubm.length; x++)
if (opensubm[x][0] == e){
deletehilay = false;
popamem = -1;
if (popanimenabled)
popswitchtimer = window.setTimeout('pophhlay()',50);
break;
}
if (deletehilay){
document.all[e].style.color = pmclr[3];
document.all[e].style.backgroundColor = pmclr[5];
if (popamem != -1){
document.images["menuItem"+popamem+"arrow"].src = popaimg.src;
popamem = -1;
}
}
window.clearTimeout(mdelaytimer);
}

function pophhlay(){
e = opensubm[poplevel][0];
psnum = opensubm[poplevel][1];
if (document.all[pmiurl[psnum]].style.clip == "rect(0px 0px 0px 0px)"){
document.all[e].style.color = pmclr[3];
document.all[e].style.backgroundColor = pmclr[0];
document.images["menuItem"+psnum+"arrow"].src = popaimg.src
}
}
