function getCenter() {
    var centerPoint = (document.body.offsetWidth / 2);
    return centerPoint;
}

function setHeights() {
//    var leftCntHeight = $("#leftContent").height();
//    var rightCntHeight = $("#rightContent").height();

//    if (parseInt(leftCntHeight) > parseInt(rightCntHeight)) {
//        $("#rightContent").css("height", leftCntHeight + 10); //not sure why we need the +10 but we do.
//    }
//    if (parseInt(rightCntHeight) > parseInt(leftCntHeight)) {
//        $("#leftContent").css("height", rightCntHeight - 10); //not sure why we need the +10 but we do.
//    }
}

function searchHeight() {
//    var leftCntHeight = $("#leftTwoColumn").height();
//    var rightCntHeight = $("#rightContent").height();

    //if (parseInt(leftCntHeight) > parseInt(rightCntHeight)) {
//    $("#rightContent").css("height", leftCntHeight + 30); //not sure why we need the +10 but we do.
//    $("#leftContent").css("height", leftCntHeight + 20); //not sure why we need the +10 but we do.
//    //}
    //if (parseInt(rightCntHeight) > parseInt(leftCntHeight)) {
        //$("#leftTwoColumn").css("height", rightCntHeight - 10); //not sure why we need the +10 but we do.
    //}

}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


$(document).ready(function () {
    var browser = navigator.appName;
    var b_version = navigator.appVersion;

    $('ul.sf-menu').superfish();
    $(".sf-menu li ul").css("position", "absolute");

    $('.loadIFrame').colorbox({ width: "500", height: "500", iframe: true });

    //var breadCrumbs = $("#breadCrumbs").text();
    //breadCrumbs.text(breadCrumbs.text().replace('Circuits, LLC: Quality Across the Board', 'Home'));

    //    var breadCrumbs = $("#breadCrumbs").html();
    //    if (breadCrumbs != null) {
    //        breadCrumbs = Right(breadCrumbs, (breadCrumbs.length - 24)); //Remove leading spaces

    //        //Netscape type browsers are reporting white space differently so we need to crop accordingly
    //        if (browser == "Netscape" && b_version.indexOf("Safari") == -1) { breadCrumbs = Right(breadCrumbs, (breadCrumbs.length - 572)); }
    //        else { breadCrumbs = Right(breadCrumbs, (breadCrumbs.length - 567)); }
    //        if (browser == "Microsoft Internet Explorer") { breadCrumbs = Right(breadCrumbs, (breadCrumbs.length - 577));}

    //        $("#breadCrumbs").html(breadCrumbs); //rewrite the HTML inside the breadcrumb div
    //    }

    $(window).resize(function () {
        var offset = $("#rightColumn").offset();
        var exOffset = $("#expertsFloat").offset();
        if ($(window).width() < 1016) {
            if ($("#expertsFloat").hasClass("expertsDyn") == true) { $("#expertsFloat").removeClass("expertsDyn"); }
            $("#expertsFloat").addClass("expertsSta");
        }
        else {
            if ($("#expertsFloat").hasClass("expertsSta") == true) { $("#expertsFloat").removeClass("expertsSta"); }
            $("#expertsFloat").addClass("expertsDyn");
        }
    });

    $("#mapContainer a").click(function () {
        var thisID = $(this).attr("id");
        var thisPage = $(this).attr("rev");
        $("#" + thisID).colorbox({ width: "600", height: "550", iframe: true, href: thisPage, open: true });
    });

    $("#btnChem").hover(function () { $("#btnChem ul").css("left", "14px"); $("#btnChem ul").fadeIn("normal"); },
        function () { $("#btnChem ul").fadeOut("fast"); }
    );
    $("#btnOpt").hover(function () { $("#btnOpt ul").css("left", "14px"); $("#btnOpt ul").fadeIn("normal"); },
        function () { $("#btnOpt ul").fadeOut("fast"); }
    );
    $("#btnMech").hover(function () { $("#btnMech ul").css("left", "14px"); $("#btnMech ul").fadeIn("normal"); },
        function () { $("#btnMech ul").fadeOut("fast"); }
    );

    /*****OUR PEOPLE*****/
    $(".employees a").click(function () {
        var thisID = $(this).attr("id");
        var divID = $(this).attr("rel");
        $("#" + thisID).colorbox({ width: "600", inline: true, href: "#" + divID, open: true });
    });

    $('#searchBox').gSearch({ submitBtn: '#btnGo', siteRestriction: 'circuits-corp.com', useCB: true, CBTitle: 'Search Results' });
});

function thanks() {
    setTimeout(function () { parent.$.fn.colorbox.close(); }, 700);

    $.fn.colorbox({ width: "250px", height: "190px", open: true, inline: true, href: "#thanks" });
}
