// JavaScript - all of Susan' Project 7 scripts

function P7_StyleLoader(tS) { //v1.2 by PVII
 var tH='',tDoc='',tA='<LIN'+'K REL="stylesheet" HREF=',tB=' TYPE="text/css">';
 if(document.getElementsByTagName){var bb=document.getElementsByTagName("LINK");
 if(bb) {for(var k=0;k<bb.length;k++){if(bb[k].rel.toLowerCase()=="stylesheet"){
 var h=bb[k].href,x=h.lastIndexOf("/");if(x>0){tH=h.substring(0,x+1);}
 bb[k].disabled=true;tDoc=tA+'"'+ tH + tS + '"' +tB;
 document.write(tDoc);break;}}}}
}

P7_StyleLoader('w3csheet.css');

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function P7_autoLayers() { //v1.2 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;
 var a = parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc) {p7c=new Array();document.p7setc=true;
  for (var u=0;u<10;u++) {p7c[u] = new Array();}}
 for(k=0; k<p7c[a].length; k++) {
  if((g=MM_findObj(p7c[a][k]))!=null) {
   b=(document.layers)?g:g.style;b.visibility="hidden"}}
 for(k=1; k<args.length; k++) {
  if((g=MM_findObj(args[k])) != null) {
   b=(document.layers)?g:g.style;b.visibility="visible";f=false;
   for(j=0;j<p7c[a].length;j++) {
    if(args[k]==p7c[a][j]) {f=true;}}
  if(!f) {p7c[a][p7c[a].length++]=args[k];}}}
}

function breadCrumbs(base, delStr, defp, cStyle, tStyle, dStyle, nl) {
    loc = window.location.toString();
    subs = loc.substr(loc.indexOf(base) + base.length + 1).split("/");
    document.write("<a href=\"" + getLoc(subs.length - 1) + defp + "\" class=\"" + cStyle + "\">Home</a>  " + "<span class=\"" + dStyle + "\">" + delStr + "</span> ");
    a = (loc.indexOf(defp) == -1) ? 1 : 2;
    for (i = 0; i < subs.length - a; i++) {
        subs[i] = makeCaps(unescape(subs[i]));
        document.write("<a href=\"" + getLoc(subs.length - i - 2) + defp + "\" class=\"" + cStyle + "\">" + subs[i] + "</a>  " + "<span class=\"" + dStyle + "\">" + delStr + "</span> ");
    }
    if (nl == 1) {
        document.write("<br>");
    }
    document.write("<span class=\"" + tStyle + "\">" + document.title + "</span>");
}

function makeCaps(a) {
    g = a.split(" ");
    for (l = 0; l < g.length; l++) {
        g[l] = g[l].toUpperCase().slice(0, 1) + g[l].slice(1);
    }
    return g.join(" ");
}

function getLoc(c) {
    var d = "";
    if (c > 0) {
        for (k = 0; k < c; k++) {
            d = d + "../";
        }
    }
    return d;
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) history.go();
}

MM_reloadPage(true);


function P7_getDD(el,mt) { //v1.8 by PVII
 var rt,h=0,w=0,ww,wx;if((g=MM_findObj(el))!=null){if(document.all||document.getElementById){
 w=parseInt(g.offsetWidth);h=parseInt(g.offsetHeight);
 if(!w){w=parseInt(g.style.pixelWidth);if(!w){w=parseInt(g.style.width);}}
 if(!h){h=parseInt(g.style.pixelHeight);}if(g.hasChildNodes){
 for(wx=0;wx<g.childNodes.length;wx++){ww=parseInt(g.childNodes[wx].offsetWidth);if(ww>w){w=ww;}}}
 }else if(document.layers){w=parseInt(g.clip.width);h=parseInt(g.clip.height);}}
 rt=(mt=="w")?w:h;return rt;
}

function P7_getLT(el,mt) { //v1.8 by PVII
 var rt,ll,tt,g,gg;if((g=MM_findObj(el))!=null){gg=(document.layers)?g:g.style;
 ll=parseInt(gg.left);tt=parseInt(gg.top);if(isNaN(ll)){if(g.currentStyle){
 ll=parseInt(g.currentStyle.left);}else if(document.defaultView){
 ll=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}else{ll=0;}}
 if(isNaN(tt)){if(g.currentStyle){tt=parseInt(g.currentStyle.top);}else if(document.defaultView){
 tt=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}else{tt=0;}}}
 rt=(mt=="l")?ll:tt;return rt;
}

function P7_alignRR() { //v1.8 by PVII
 var i;if(!document.p7alignRR) {return;}if(document.layers){
 if(innerWidth!=document.p7RRiw || innerHeight!=document.p7RRih){location.reload();}
 }else{document.p7RR=1;for(i=0;i<p7aRR.length;i++){eval(p7aRR[i]);}document.p7RR=0;}
}

function P7_alignLL(){ //v1.8 by PVII
 var g,gg,lp,mm,mr,tL,tT,pa='px',args=P7_alignLL.arguments;if(document.layers||window.opera){pa='';}
 for(var i=0;i<args.length;i+=4){if((g=MM_findObj(args[i]))!=null){gg=(document.layers)?g:g.style;
 mm=parseInt(args[i+2]);mr=parseInt(args[i+3]);tL=parseInt(P7_getLT(args[i+1],"l"));tT=parseInt(P7_getLT(args[i+1],"t"));
 if(mm==1){lp=tL-parseInt(P7_getDD(args[i],"w"))-mr;gg.left=lp+pa;
 }else if(mm==2){lp=tL+parseInt(P7_getDD(args[i+1],"w"))+mr;gg.left=lp+pa;
 }else if(mm==3){lp=tT-parseInt(P7_getDD(args[i],"h"))-mr;gg.top=lp+pa;
 }else if(mm==4){lp=tT+parseInt(P7_getDD(args[i+1],"h"))+mr;gg.top=lp+pa;}
 if(!document.p7alignRR){p7aRR=new Array();document.p7alignRR=true;document.p7RR=0;onresize=P7_alignRR;
  if(document.layers){document.p7RR=0;document.p7RRiw=innerWidth;document.p7RRih=innerHeight;}}
 if(document.p7RR==0){p7aRR[p7aRR.length]="P7_alignLL('"+args[i]+"','"+args[i+1]+"',"+mm+","+mr+")";}}}
}


