

var gallery = null;
var galleryHTML = null;
try {
    var pageTracker = _gat._getTracker("UA-1862702-2");
    pageTracker._trackPageview();
} catch(err) {}


/* request a page from servepage.php
*/
function RequestPage(request, destinationElement, callBack)
{
//    destinationElement.innerHTML = "<div style='width:300px;margin-left:auto;margin-right:auto'><img src='images/barloader.gif'/></div>";
    var myAjax = new Ajax.Request('scripts/servepage.php',
      {
        method:'get',
        parameters: { request: request},
        onComplete: function(transport) {
            var response = transport.responseText || "no response text";
            destinationElement.innerHTML =  eval(transport.responseText);
            if ( callBack != null ) {
                callBack();
            }
        },
        onFailure: function(){
            //alert('Something went wrong...')
        },
        onException: function(req, exception) {
            alert("Exception during image retrieval:" + exception)
        }
      }
    );

}

function FadeInGallery()
{
    try {
        var myAnim = new YAHOO.util.Anim('frontpagecontent', {
                opacity: { to: 1 }
        }, 0.1, YAHOO.util.Easing.easeNone);
/*        myAnim.onComplete.subscribe(this._myOnCompleteFadeOutMainImage);*/
    } catch(e)
    {
        alert(e);
    }
    myAnim.animate();
}

function ShowServices()
{
    RequestPage('services', document.getElementById('frontpagecontent'), null);
    HideClients();
}
function ShowAboutMe()
{
    RequestPage('aboutme', document.getElementById('frontpagecontent'), null);
    HideClients();
}

function ShowContact()
{
    RequestPage('contact', document.getElementById('frontpagecontent'), null);
    HideClients();
}


function ShowVideo()
{
    HideClients();
    document.getElementById('menubarcontent').innerHTML='<a onclick="gallery.SwitchGallery(\'theatre/movies\');">Movies</a><a onclick="gallery.SwitchGallery(\'theatre/docco\');">Docco</a>';
    document.getElementById('portfoliodiv').style.display='block';
    document.getElementById('frontpagecontent').style.display='none';
    gallery.SwitchGallery('theatre/movies');
    document.getElementById('portfoliodiv').style.display='block';
    document.getElementById('frontpagecontent').style.display='none';
    FadeInGallery();
}

function ShowPortfolioCallback()
{
 //       var newGallery = gallery == null;
 //       if ( gallery ) {
  //          delete gallery;
   //         alert("a");
    //    }
    if ( gallery == null ) {
        galleryLocation = unescape(document.location.hash.substring(1));
        gallery = new AKGalleryViewer("scripts", galleryLocation.length == 0 ? "gallery/people" : galleryLocation, "images/barloader.gif");
        gallery.Insert();
    } else {
//        if ( newGallery ) {
            gallery.SwitchGallery('gallery/people');
            gallery.Restart();
        }
        ShowClients();

return;
    document.getElementById('menubarcontent').innerHTML=' \
                    <a onclick="ShowClients(); gallery.SwitchGallery(\'gallery/people\');">People</a> \
                    <a onclick="HideClients(); gallery.SwitchGallery(\'gallery/personal\');">      Personal</a> \
                    ';
/*
                    <a onclick="HideClients(); gallery.SwitchGallery(\'gallery/outdoors\');">Outdoors</a> \
                    <a onclick="HideClients(); gallery.SwitchGallery(\'gallery/music\');">Music</a> \
                    <a onclick="HideClients(); gallery.SwitchGallery(\'gallery/play\');">Play</a> \

                    <a onclick="gallery.SwitchGallery(\'gallery/animals\');">Animals</a> \
                    <a onclick="gallery.SwitchGallery(\'gallery/art\');">Abstract/Art</a> \
*/

//    gallery.SwitchGallery('gallery/people');
//    FadeInGallery();
}

function HideClients()
{
    document.getElementById('clientcontent').innerHTML='';
}

var showClients = true;
function ShowClients()
{
    if ( showClients ) {
        document.getElementById('clientcontent').innerHTML=' People: \
                        <a class="mainmenubartext" onclick="gallery.SwitchGallery(\'gallery/clients/amandaandbrendan\');">Amanda and Brendan</a> -  \
                        <a class="mainmenubartext" onclick="gallery.SwitchGallery(\'gallery/clients/peterandgesa\');">Peter and Gesa</a> -  \
                        <a class="mainmenubartext" onclick="gallery.SwitchGallery(\'gallery/clients/nicandtyler\');">Nic and Tyler</a> <br> Commercial: \
                        <a class="mainmenubartext" onclick="gallery.SwitchGallery(\'gallery/clients/sbreno\');">Mansion Renovation</a> \
                        ';
    }
}

function ShowAbout()
{
    RequestPage('aboutme', document.getElementById('frontpagecontent'), null);
}
// Shows the Q&A Page
function ShowQAndA()
{
    HideClients();
    RequestPage('qanda', document.getElementById('frontpagecontent'), null);
}

function ShowPortfolio()
{
    RequestPage('portfolio', document.getElementById('frontpagecontent'), ShowPortfolioCallback);
}

function highlight(hoverItem)
{
    hoverItem.style.borderColor = "#888888";
}

function unhighlight(hoverItem)
{
    hoverItem.style.borderColor = "#000000";
}

function showMenuTitle(title)
{
    return;
    var item = document.getElementById('menutitle');
    item.innerHTML = title;
}

function toggleVisibility(controlId, show)
{
    var control = document.getElementById(controlId);
    if( (control.style.visibility == "visible" || control.style.visibility == "") && show == 0)
        control.style.visibility = "hidden";
    else if ( show == 1 ) {
        control.style.visibility = "visible";
    }
}


function ShowPage(controlId)
{
    window.location = './' + controlId;
}

