// CLIENT MENU

var cmenu=[

["HOME","/index.php",0],

["ABOUT",0,[
 ["Njoy","/about-njoy.htm",0],
 ["Impulse Sales","/about-Impulsesales.htm",0],
 ["Branding","/about-branding.htm",0],
 ["The Card","/about-thecard.htm",0],
 ["Mission of John Green Consulting","/about-mission.htm",0],
 ["The Software","/about-software.htm",0]
]],

["NEWS",0,[
 ["Special Promotions","/Xtras-boat.htm",0],
 ["NJOY Commercials","/news-commercial.php",0],
 ["NJOY Videos","/news-videos.php",0],
 ["AVN Awards Gallery","/avn/news-avnawardsgal1.htm",0],
 ["Party Cove Gallery","/partycove/news-partycovegal.htm",0],
 ["Press Releases","/news-pr.php",0],
 ["Where To Buy NJOY Cards","/news-locations.php",0],
 ["Wall Street Gets in the Game","/biz-skingame.html",0]
]],

["WHY?",0,[
 ["Locations","/why-locations.htm",0],
 ["Recession Proof","/why-recessproof.htm",0],
 ["Sales","/why-sales.htm",0],
 ["Identity Theft","/why-identitytheft.htm",0],
 ["Tax Advantages","/why-taxadvantages.htm",0],
 ["What People Are Saying","/why-quotes.htm",0],
 ["FAQ","/why-faq.htm",0]
]],

["BUSINESS",0,[
 ["Calculator","/biz-calculator.htm",0],
 ["Investment","/biz-investment.htm",0],
 ["Target Markets (US)","/biz-targetmarkets.htm",0],
 ["Target Markets (Canada)","/biz-targetmarketsc.htm",0],
 ["You Can Do It","/biz-youcandoit.htm",0],
 ["About 'The Industry'","/biz-abouttheindustry.htm",0],
 ["Franchise","/biz-franchise.htm",0],
 ["Our Cards","/biz-intcards.htm",0],
 ["Do's and Dont's","/biz-dosdont.htm",0],
 ["Time Matrix","/biz-tmatrix.htm",0],
 ["Resources","/biz-resources.htm",0]
]],

["CONTACT",0,[
 ["Distributor Request Form","/contact.htm",0],
 ["Merchant Request Form","/contact-merchant.htm",0],
 ["Master Distributor Application","/contact-master.htm",0],
 ["Visit John Green Consulting","/contact-visitjgc.htm",0],
 ["Employment Opportunities","/contact-empl.htm",0],
 ["Privacy Policy","/contact-privacypolicy.htm",0]
]],

["DEMO",0,[
 ["Demo Njoy","/demo.htm",0],
 ["Tour Njoy","/flv/tour.php",0],
 ["Gadgets For Girls","/gfg.htm",0],
 ["The Erotic Toolbox","/tet.htm",0],
 ["NJOY Submissions","/xtras-submit.htm",0],
 ["NJOY Webcams","/xtras-webcam.htm",0],
 ["NJOY Hook Ups","/xtras-conn.htm",0]
]],
 
 
["SUPPORT",0,[
 ["Site map","/support-sitemap.htm",0]
]]

];


// ENTER SITE
function EnterSite() { location.href="http://www.njoynow.com/tour.php?pc="+(document.pform.pc.value).toUpperCase(); }


// CALCULATOR

function comma(s){s+='';
 x=s.split('.');
 x1=x[0];
 x2=x.length>1?'.'+x[1]:'';
 var rgx=/(\d+)(\d{3})/;
 while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
 return x1+x2;}

function FormCalc(form) {

var DailyTotal;
var MonthlyTotal;
var YearlyTotal;
var DailynetTotal;
var MonthlynetTotal;
var YearlynetTotal

var NumMachines=form.nod.value;
var PlaysPerDay=form.cpd.value;

DailyTotal = (PlaysPerDay * 14 * NumMachines);

MonthlyTotal = (DailyTotal * 30);
YearlyTotal = (DailyTotal * 365);

DailynetTotal = (PlaysPerDay * 11 * NumMachines);

MonthlynetTotal = (DailynetTotal * 30);
YearlynetTotal = (DailynetTotal * 365);

form.dyg.value = "$"+comma(DailyTotal);
form.mng.value = "$"+comma(MonthlyTotal);
form.yrg.value = "$"+comma(YearlyTotal);
form.dyn.value = "$"+comma(DailynetTotal);
form.mnn.value = "$"+comma(MonthlynetTotal);
form.yrn.value = "$"+comma(YearlynetTotal);

}

function FormReset(form){
form.nod.value="";
form.cpd.value="";
form.dyg.value="";
form.dyn.value="";
form.mng.value="";
form.mnn.value="";
form.yrg.value="";
form.yrn.value="";
}




// POPUP MENU LIBRARY 

// MAP FUNCTION TO ARRAY ( FUNCTION(ELEMENT,ARGUMENT,INDEX), ARGUMENT )
Array.prototype.m=function(f,a){var i=0,e=this.length-1,r=[];for(;i<=e;i++){r[i]=f(this[i],a,i);}return r;};

// APPLY FUNCTION TO ELEMENTS OF ARRAY ( FUNCTION(ELEMENT,ARGUMENT,INDEX,START,END), ARGUMENT, START, END )
Array.prototype.a=function(f,a,s,e){var i=(s==null)?0:s,e=(e==null)?this.length-1:e;for(;i<=e;i++){f(this[i],a,i,s,e);}};

// APPLY FUNCTION TO ELEMENTS OF ARRAY WITH RETURN ( FUNCTION(ELEMENT,ARGUMENT,INDEX,START,END), ARGUMENT, START, END )
Array.prototype.as=function(f,a,s,e){var r="",i=(s==null)?0:s,e=(e==null)?this.length-1:e;for(;i<=e;i++){r+=f(this[i],a,i,s,e);}return r;};
Array.prototype.ai=function(f,a,s,e){var r=0,i=(s==null)?0:s,e=(e==null)?this.length-1:e;for(;i<=e;i++){r+=f(this[i],a,i,s,e);}return r;};

// ARRAY REMOVE ( INDEX )
Array.prototype.r=function(i){var n=this.length;for(;i<n;i++){this[i]=this[i+1];}this.length--;};

// ARRAY FUNCTION TO RETURN TOP ITEM OF ARRAY
Array.prototype.t=function(){return this[this.length-1];}

// ARRAY PUSH NEW ( ITEM )
Array.prototype.p=function(i){this[this.length]=i;}

// IMAGE PATH PREFIX
var ipath="../";

// CLAMP ( A, B, C )
function clamp(a,b,c){if(b<a)b=a;if(b>c)b=c;return b;}

// WRITE MAIL LINK ( NAME, ADDRESS ) 
function mail(n,a){return n+'@'+a;}

// DO NOTHING
function nop(){}

// INPUT HIDDEN ( NAME, VALUE )
function ih(n,v){return '<input type="hidden" name="'+n+'" value="'+v+'">';}

// WRITE INTO DOCUMENT ( HTML )
function dw(t){document.write(t);}

// LOOKUP ELEMENT ( ID )
function id2e(i){return document.getElementById(i);}

// SET CLASS NAME ( ELEMENT, CLASS )
function cname(e,c){if(e)e.className=c;}

// DEBUG MESSAGE SUPPORT
var bug=nop;function debug(){dw('<br><textarea id="debug" rows="30" cols="60"></textarea>');id2e('debug').value="";bug=function(m){id2e('debug').value+=m;};}

// TOGGLE DISPLAY ( ELEMENT, 0=HIDE|1=SHOW )
function dpy(e,s){e.style.display=['none','block'][s];}

// TOGGLE DISPLAY OF A TAB OF IDS ( TO ID, ARRAY OF IDS )
function tab(t,a){a.a(function(e,a){var i=(e==a)?1:0;cname(id2e(e+'_p'),['normal','over'][i]);dpy(id2e(e),i);},t);}

// PASSIVE SWITCH TO TAB ( TO ID, ARRAY OF IDS )
function tabp(t,a){a.a(function(e,a){var i=(e==a)?1:0;cname(id2e(e+'_p'),['normal','active'][i]);dpy(id2e(e),i);},t);}

// GET EVENT TARGET ( EVENT )
//function tar(e){return e.target?e.target:e.srcElement;}

// GET WINDOW [width,height] 
function winxy(){var r=[800,600];if(typeof(window.innerWidth)=='number'){r[0]=window.innerWidth;r[1]=window.innerHeight;}else if(document.documentElement&&document.documentElement.clientWidth){r[0]=document.documentElement.clientWidth;r[1]=document.documentElement.clientHeight;}else if(document.body&&document.body.clientWidth){r[0]=document.body.clientWidth;r[1]=document.body.clientHeight;}return r;}

// GET ABSOLUTE POSITION [x,y] OF ( ELEMENT )
function absxy(e){var t=[0,0];if(e.offsetParent){while(e.offsetParent){t[0]+=e.offsetLeft;t[1]+=e.offsetTop;e=e.offsetParent;}}else if(e.x||e.y){t[0]=e.x;t[1]=e.y;}return t;}

// GET SIZE [x,y] OF ( ELEMENT )
function exy(e){return [e.offsetWidth,e.offsetHeight];}

// MOVE ELEMENT TO ( ELEMENT, X, Y )
function movxy(e,x,y){e.style.left=x+'px';e.style.top=y+'px';}

// DELAYED HIDE TIMEOUT HANDLE
var hideh=null;

// DELAYED HIDE ELEMENT
var hidee=null;

// DELAYED HIDE ( ELEMENT )
function hide(e){if(hideh!=null){clearTimeout(hideh);hideh=null;movxy(hidee,-2000,-2000);}hidee=e;hideh=setTimeout("movxy(hidee,-2000,-2000);hideh=null;",10);}

// REMOVE HIDE ON ( ELEMENT )
function uhide(e){if(hideh==null||hidee!=e)return;clearTimeout(hideh);hideh=null;}

// POPUP [ [ PARENT, CONTAINER, SELF ] ... ] ARRAY
var popa=[];

// POPUP TIMEOUT HANDLE
var poph=null;

// POPUP DEATH TO TIMER
function popd(){if(poph){clearTimeout(poph);poph=null;}}

// POPUP KILL POPUP ( ITEM )
function popk(i){cname(i[0],'');cname(i[1],'normal');cname(i[2],'normal');hide(i[1]);}

// POPUP NONE - REMOVE ALL POPUPS
function popn(){popd();popa.a(popk);popa.length=0;}

// POPUP MOUSE OUT ( THIS, EVENT )
function popu(t,e){
//if(t!=tar(e))return;
if(poph==null){poph=setTimeout("popa.a(popk);popa.length=0;poph=null;",500);}}

// POPUP MOUSE OVER TERMINAL ( THIS, EVENT, CONTAINER ID )
function popt(t,e,c){
//if(t!=tar(e))return;
popd();var i,a=popa;c=id2e(c);while(a.length>0){i=a.t();if(i[1]==c){cname(i[2],'normal');i[2]=t;cname(t,'over');cname(i[0],'over');return;}popk(i);a.length--;}}

// POPUP MOUSE OVER CONTAINER ( THIS, EVENT )
function popc(t,e){
//if(t!=tar(e))return;
popd();var i,j,a=popa;j=a.length-1;for(;j>=0;j--){i=a[j];if(i[1]==t){cname(i[0],'over');return;}}}

// LOCATE POPUP ( THIS, CONTAINER, [XANCHOR, YANCHOR], [XOFFSET, YOFFSET] )
function popl2(t,c,b,o){var i=0,p=absxy(t),w=winxy(),cs=exy(c),ts=exy(t);for(;i<2;i++){p[i]+=o[i];if(b[i]==0)p[i]-=cs[i];else if(b[i]==2)p[i]+=ts[i]/2-cs[i]/2;else if(b[i]==3)p[i]+=ts[i]-cs[i];else if(b[i]==4)p[i]+=ts[i];if(p[i]<16)p[i]=16;}if((p[0]+cs[0])>(w[0]-16))p[0]=w[0]-(cs[0]+16);uhide(c);movxy(c,p[0],p[1]);}
function popl(t,c,b,o){popl2(t,c,b,o);popl2(t,c,b,o);}

// POPUP NEW ( THIS, EVENT, PARENT CONTAINER ID, CONTAINER ID, [XANCHOR, YANCHOR], [XOFFSET, YOFFSET] )
function pop(t,e,g,c,b,o){
//if(t!=tar(e))return;
popd();c=id2e(c);g=id2e(g);var i,a=popa;while(a.length>0){i=a.t();if(i[1]==g){cname(i[2],'normal');break;}popk(i);a.length--;}a.p([t,c,null]);cname(t,'over');popl(t,c,b,o);}

// MOUSE OVER - GENERATE TAG ( THIS, TAG ID, [XANCHOR, YANCHOR], [XOFFSET, YOFFSET] )
function tag(t,c,b,o){tagu();popl(t,id2e(c),b,o);tagt[1]=id2e(c);}

// TAG POPUP TIMER CONTROL [ TIMER, CURRENT TAG, [TCBO] ]
var tagt=[null,null,null];

// TAG ACTUAL GENERATION
function taga(){tag(id2e(tagt[2][0]),tagt[2][1],tagt[2][2],tagt[2][3]);}

// RUN DELAYED TAG REGENERATION - USED FOR POSITION CORRECTION AFTER REFRESH
function tagr(){if(tagt[0])clearTimeout(tagt[0]);tagt[0]=setTimeout("tagt[0]=null;taga();",10);}

// MOUSE OVER - GENERATE REGENERATABLE TAG ( ID, TAG ID, [XANCHOR, YANCHOR], [XOFFSET, YOFFSET] )
function tagd(t,c,b,o){tagt[2]=[t,c,b,o];taga();}

// MOUSE OUT - CLOSE TAG
function tagu(){if(tagt[1])hide(tagt[1]);if(tagt[0])clearTimeout(tagt[0]);tagt[0]=tagt[1]=null;}








// GENERATE MENU

var gmenu1="";
var gmenu2="";


// WRAP MENU BAR
function gmenu1w(){return '<div id="MenuSpan"><table cellspacing=0 cellpadding=0 id="MenuTab"><tr>'+gmenu1+'</tr></table></span>';}

// WRAP DROP DOWN MENU
function gmenu2w(t,n){return '<span id="'+n+'" style="position:absolute; top:-2000px; left:-2000px;" onMouseOver="popc(this,event);" onMouseOut="cname(this,\'active\');popu(this,event);"><table cellspacing=0 cellpadding=0 id="MenuI">'+t+'</table></span>'}

// MAP DROP DOWN MENU ITEMS
function gmenu2m(e,a,i){var t=""; var n=a+"m"+i;
 if(e[2]){}
 else{t=' onMouseOver="popt(this,event,\''+a+'\');"';}
 if(e[1]){t+=' onClick="location.href=\''+e[1]+'\';"';}
 return '<tr><td id="'+n+'"'+t+' onMouseOut="popu(this,event);">'+e[0]+'</td></tr>';}

// GENERATE DROP DOWN MENU
function gmenu2a(e,n){gmenu2+=gmenu2w((e.m(gmenu2m,n)).join(""),n);}

// GENERATE MENU BAR
function gmenu1a(e,a,i){var t=""; var n="Menu"+i;
 if(e[2]){gmenu2a(e[2],n);}
 if(e[2]){t=' onMouseOver="pop(this,event,null,\''+n+'\',[2,4],[0,0]);" onMouseOut="popu(this,event);"';}
 else{t=' onMouseOver="cname(this,\'inside\');" onMouseOut="cname(this,\'\');"';}
 if(e[1]){t+=' onClick="location.href=\''+e[1]+'\';"';}
 gmenu1+='<td align="center" valign="center"'+t+'>'+e[0]+'</td>';}

// GENERATE MENU
function gmenu() { 
 cmenu.a(gmenu1a);
 id2e("Page2").innerHTML+=gmenu1w();
 id2e("Bdy").innerHTML+=gmenu2;
}





















