
//
// determines the relative link to a page based on the current page
// the user is visiting.
//
function smartLink(pageName) {
    var path = window.location.pathname;
    var count = 0;
    var ndx = 0;
    var retVal = "";
    
    while (path.indexOf('/') != -1) {
        count++;
        path = path.substr(path.indexOf('/') + 1);
    }
    
    //
    // assumes all pages calling this will be in sub-directory under
    // web-root.
    //
    count = count - 2;
    
    for (x = 0; x < count; x++) {
        retVal += "../";
    }
    
    retVal += pageName;
    
    return retVal;
}

/*
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
*/

function morePopup(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function addItem(text, link, target, moreLink, moreTarget) {
    if (!target) {target=linkTarget}
    document.write('<TR><TD align=left BGCOLOR="'+linkBGColor+'" onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'">');
    document.write('<ILAYER><LAYER onmouseover="bgColor=\''+linkOverBGColor+'\'" onmouseout="bgColor=\''+linkBGColor+'\'" WIDTH="100%">');
    document.write('<FONT face="'+linkFontFamily+'" Size="'+linkFontSize+'">&nbsp;&nbsp;&nbsp;&nbsp;');
    document.write('<A HREF="'+link+'" target="'+target+'" CLASS="ssm2Items">'+text+'</A>');
    
    //onMouseDown="MM_openBrWindow('g3.asp?page=3','wedding','width=560,height=560')
    
    if (moreLink != "") {
        document.write('&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="javascript: void 0;" onMouseDown="morePopup(\''+moreLink+'\',\''+moreTarget+'\',\'width=560,height=560\');" CLASS="ssm2Items">more</A>');
    }
    document.write('</FONT></LAYER></ILAYER></TD></TR>');
}

function addHdr(text) {
    document.write('<tr><td align=left bgcolor="'+hdrBGColor+'" WIDTH="115"><font face="'+hdrFontFamily+'" Size="'+hdrFontSize+'" COLOR="'+hdrFontColor+'"><b>'+text+'</b></font></td></tr>')
}

function drawMenu(x, y) {
    if (IE) {
        document.write('<DIV ID="ssm2" style="Position : Absolute ;Left : ' + x + 'px ;Top : '+y+'px ;Z-Index : 20;width:1px" onmouseover="moveOut()" onmouseout="moveBack()">')
    } 

    if (NS) {
        document.write('<LAYER visibility="hide" top="'+y+'" name="ssm2" bgcolor="'+menuBGColor+'" left="' + x + '" onmouseover="moveOut()" onmouseout="moveBack()">')
    }

    tempBar=""
    for (i=0;i<barText.length;i++) {
        tempBar+=barText.substring(i, i+1)+"<BR>"
    }

    var menuImage = smartLink('images/contents.gif');

    document.write('<table border="0" cellpadding="0" cellspacing="1" width="'+(menuWidth+16+2)+'" bgcolor="'+menuBGColor+'"><tr><td align=right valign=bottom height=17 bgcolor="#333333" WIDTH="'+menuWidth+'"></td><td align="center" rowspan="100" width="17" bgcolor="'+barBGColor+'"><p align="center"><font face="'+barFontFamily+'" Size="'+barFontSize+'" COLOR="'+barFontColor+'"><img src="' + menuImage + '" width=12 height=180></font></p></TD></tr>')

    addHdr('HOME');
    addItem('John Solano', smartLink('index2.htm'), '', '', '');

    addHdr('GALLERY I');
    //addItem('portraits', smartLink('gallery/gallery01/gallery_01.htm'), '', smartLink('gallery/more.asp?id=5'), '');
    addItem('portraits', smartLink('gallery/gallery01/gallery_01.htm'), '', '', '');
    
    addHdr('AUDITORIUM');
    addItem('video|slideshow', smartLink('gallery/audtitorium/auditorium.htm'), '', '', '');

    addHdr('GALLERY III');
    //addItem('weddings', smartLink('gallery/gallery03/gallery_03.htm'), '', smartLink('gallery/more.asp?id=6'), '');
    addItem('weddings', smartLink('gallery/gallery03/gallery_03.htm'), '', '', '');

    addHdr('GALLERY IV');
    //addItem('bar/bat mitzvahs', smartLink('gallery/gallery04/gallery_04.htm'), '', smartLink('gallery/more.asp?id=7'), '');
    addItem('bar/bat mitzvahs', smartLink('gallery/gallery04/gallery_04.htm'), '', '', '');

    addHdr('GEARBOX');
    addItem('cameras|lenses|film', smartLink('template/index.asp?name=gearbox'), '', '', '');

    addHdr('BIO');
    addItem('about john solano', smartLink('template/index.asp?name=bio'), '', '', '');

    addHdr('CONTACT');
    addItem('book our services', smartLink('contact/index.asp'), '', '', '');
    
    addHdr('EVENT GALLERY');
    addItem('online events', 'http://www.imagemakr.com/solano', '', '', '');

    document.write('<tr><td bgcolor="'+barBGColor+'"><font size="0" face="Arial">&nbsp;</font></td></TR></table>')

    if (IE) {
        document.write('</DIV>')
    }
    if (NS) {
        document.write('</LAYER>')
    }

    if ((IE||NS) && (menuIsStatic=="yes"&&staticMode)) {
        makeStatic(staticMode);
    }
}

