
//Display Resources, Portfolio, Quote sub sections if we are in resources / portfolio
//Funtion must be called at the end of the page after elements have been generated
function ShowSection() {

    var pathName = this.location.pathname.toLowerCase();

    if (pathName.indexOf("flooring_fitting_") != -1 ||
       pathName.indexOf("flooring_preparation") != -1 ||
       pathName.indexOf("carpet_checklist") != -1) {
        $('#menu_resources_sec').css('display', 'block');
    }
    else if (this.location.pathname.indexOf("flooring_portfolio") != -1 ||
             this.location.pathname.indexOf("flooring_testimonials") != -1) {
        $('#menu_portfolio_sec').css('display', 'block');
    }

    else if (this.location.pathname.indexOf("laminate_flooring") != -1 ||
		this.location.pathname.indexOf("laminate_floor_range") != -1) {
        $('#menu_laminate_sec').css('display', 'block');
    }

    else if (this.location.pathname.indexOf("designer_flooring") != -1 ||
		this.location.pathname.indexOf("designer_flooring_range") != -1) {
        $('#menu_amtico_sec').css('display', 'block');
    }



    else if (this.location.pathname.indexOf("wood_floor") != -1 ||
		this.location.pathname.indexOf("wood_floor_range") != -1) {
        $('#menu_wood_floor_sec').css('display', 'block');
    }

    else if (this.location.pathname.indexOf("stair-rods") != -1 ||
		this.location.pathname.indexOf("stair-rods-range") != -1) {
        $('#menu_stair_rods_sec').css('display', 'block');
    }

else if (this.location.pathname.indexOf("stair-runners") != -1 ||
		this.location.pathname.indexOf("stair-runners-range") != -1) {
        $('#menu_stair_runners_sec').css('display', 'block');
    }
    


    else if (this.location.pathname.indexOf("flooring_quote") != -1) {
        $('#menu_quote_sec').css('display', 'block');
    }
    else if (this.location.pathname.indexOf("stair-runners") != -1 ||
             this.location.pathname.indexOf("menu_stairrods_sec") != -1) {
        $('#menu_stairrunners_sec').css('display', 'block');
    }
    else if (this.location.pathname.indexOf("stair-rods") != -1 ||
             this.location.pathname.indexOf("menu_stairrods_sec") != -1) {
        $('#menu_stairrunners_sec').css('display', 'block');
    }
    else if (this.location.pathname.indexOf("maintenance_") != -1) {
        $('#menu_maintenance_sec').css('display', 'block');
    }
}

function prevEmail(ID, emailserver, emailname, emailinner) {
    var span = document.getElementById(ID);
    if (span != null) {
        var str = "<a href='mailto:" + emailname + "@" + emailserver + "'>";
        if (emailinner == '') str += emailname + "@" + emailserver; else str += emailinner;
        str += "</a>";
        span.innerHTML = str;
    }
}

var newWindow;
function PhotoWindow(imagePath, imageWidth, imageHeight) {
    var marginWidth = 0;
    var marginHeight = 25;

    newWindow = window.open('photo.aspx?image=' + imagePath, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=10,top=10,width=' + (imageWidth + marginWidth) + ',height=' + (imageHeight + marginHeight));
    if (window.focus) { newWindow.focus() }
}


function BreakOutOfFrames() {
    if (parent != window) { parent.location = location.href; }
}


//called on page load (first 'full, non ajax' load);
$(document).ready(function() {
    main();
});
function main() {
    //disable right-click on img elements (copy-protect!)
    $('img').bind("contextmenu", function(e) { return false; });
    //track click-throughs to 3rd party pages via Google Analytics...
    //$("a[rel*='nofollow']").click(function() {
    $("a[target*='_blank']").click(function() {
        if (typeof (pageTracker) != "undefined")
            pageTracker._trackPageview('/outgoing/' + $(this).attr('href'));
    });

    ShowSection();
    BreakOutOfFrames();

    //googleTranslateElementInit();

    if ($().lightBox)
        $('a.lightbox').lightBox({ fixedNavigation: true }); // Select all links with lightbox class


    if ($().flash)
        $('#celLocationMap').flash({ swf: 'img/swf/map.swf', height: 265, width: 380 });
}
