﻿function pageInit() {

HightLightTopNavButton();

    $(".topbtn").mouseover(function() {
        var src = $(this).attr("src");
        $(this).attr("src", src.replace("default", "over"));
    });
    $(".topbtn").mouseout(function() {
        var src = $(this).attr("src");
        $(this).attr("src", src.replace("over", "default"));

        HightLightTopNavButton();
    });
    $("#logo").mouseover(function() {
        $("#logo").attr("src", "../images/topnav/over/logo.png");
    });
    $("#logo").mouseout(function() {
        $("#logo").attr("src", "../images/topnav/default/logo.png");
    });
    
    $(".icon").mouseover(function() {
    var src = $(this).attr("src");
    $(this).attr("src", src.replace("default", "over"));
    });
    $(".icon").mouseout(function() {
    var src = $(this).attr("src");
    $(this).attr("src", src.replace( "over","default"));
    });
    
}
function LoopSlides() {

  var oCurPhoto =$(" .slidesec img.current");
  var oNxtPhoto = oCurPhoto.next();
    
    if(oNxtPhoto.length ==0)
        oNxtPhoto = $(" .slidesec img:first");

    oCurPhoto.removeClass("current").addClass("previous");
    oNxtPhoto.css({ opacity: 0.0 }).addClass("current").animate({opacity:1.0},1000,
        function() {
            oCurPhoto.removeClass("previous");  
        }); //animate

     setTimeout(" LoopSlides();", 5000);
    }
    function LoopBuilders() {

        if (backward) {
            viewslide(-1);
            featurecount--;
            if (featurecount == 0)
                backward = false;
        }
        else {
            viewslide(1);
            featurecount++;
            if (featurecount == 2)
                backward = true;
        }

        binfoT = setTimeout("LoopBuilders()", 4500);
    }
    function BuilderInfoPage(bid) {
        window.location = "../builders/builderinfo.aspx?bid=" + bid;
    }
function HightLightTopNavButton() {
    var url = document.location.href;
    
    if (url.indexOf("homepages/") > 0)
        $("#logo").attr("src", "../images/topnav/over/logo.png");
    else if (url.indexOf("builders/") > 0)
        $("#top1").attr("src", "../images/topnav/over/topnav1.png");
    else if (url.indexOf("lot/") > 0)
        $("#top2").attr("src", "../images/topnav/over/topnav2.png");
    else if (url.indexOf("tour/") > 0)
        $("#top3").attr("src", "../images/topnav/over/topnav3.png");
    else if (url.indexOf("news/") > 0)
        $("#top4").attr("src", "../images/topnav/over/topnav4.png");
    else if (url.indexOf("contact/") > 0)
        $("#top5").attr("src", "../images/topnav/over/topnav5.png");
    
}
function getBuilderName(bid) {
    var arrBnames = ["", "Ashton Custom Homes", "Crystal Creek Homes", "Lupi Luxury Homes"];

    return arrBnames[bid];
}
function BuilderProduct() {
    var imageWidth = 643; //$(".stage").width();
    var imageSum = $(".image_reel img").size();
    var imageReelWidth = imageWidth * imageSum +20;

    //Adjust the image reel to its new size
    $(".image_reel").css({ 'width': imageReelWidth });


   /* $("#pre").mouseover(function() {

        if (triggerID > 0)
            $("#pre").attr("src", "../images/slidshow/over/blueleft.png");
    });
    $("#pre").mouseout(function() {
        if (triggerID > 0)
            $("#pre").attr("src", "../images/slidshow/default/blueleft.png");
    });

    $("#nxt").mouseover(function() {
        if (triggerID <= 2)
            $("#nxt").attr("src", "../images/slidshow/over/blueright.png");
    });
    $("#nxt").mouseout(function() {
        if (triggerID <= 2)
            $("#nxt").attr("src", "../images/slidshow/default/blueright.png");
    });
*/
}

function viewslide(num) {

    clearTimeout(binfoT);
    var thumbgroup = $(".image_reel img").size();
 
    triggerID += num; //Get number of times to slide
    //alert("triggerID:" + triggerID + " thumbgroup:" + thumbgroup);
    if (triggerID <= 0) {
        // $("#pre").addClass("opacity50");
        $("#pre").attr("src", "../images/slidshow/default/blueleft_narw.png");
        $("#pre").css({"cursor": "default", "float": "left" });

        //  $("#nxt").removeClass("opacity50");
        $("#nxt").attr("src", "../images/slidshow/default/blueright.png");
        $("#nxt").css({"cursor": "pointer", "float": "left" });

        triggerID = 0;
        //return;

    } else {
        if (triggerID < thumbgroup -1) {
            // $("#nxt").removeClass("opacity50");
            $("#nxt").attr("src", "../images/slidshow/default/blueright.png");
            $("#nxt").css({"cursor": "pointer", "float": "left" });

            //$("#pre").removeClass("opacity50");
            $("#pre").attr("src", "../images/slidshow/default/blueleft.png");
            $("#pre").css({"cursor": "pointer", "float": "left" });


        } else {
        //$("#nxt").addClass("opacity50");
            $("#nxt").attr("src", "../images/slidshow/default/blueright_narw.png");
            $("#nxt").css({"cursor": "default", "float": "left" });
            triggerID = thumbgroup - 1;
            // return;
        }
    }
    var image_reelPosition = triggerID * imageWidth;

    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500);
}
function LeftButtonClick(btnid) {

}
function getParameter(url, indexstring) {
    var length = url.length;
    var post = url.indexOf(indexstring) + indexstring.length;
    var id = 0;
    id = url.substr(post, length - post);

    if (id.length > 0)
        id = parseInt(id);

    return id;
}
function ClearField(txtfield) {
    //alert(txtfield.value);
    if (txtfield.value == "Comment ....")
        txtfield.value = "";
}
function displayform(display) {

    if (display) {
        $("#regform").show();
        $("#envbtn").hide();
    }
    else {
        $("#regform").hide();
        $("#envbtn").show();
    }
}
function getBuildName(builderid) {
    var bname = "";

    switch (builderid) {
        case 1:
            bname = "Ashton Custom Homes";
            break;
        case 2:
            bname = "Crystal Creek Homes";
            break;
        case 2:
            bname = "Lupi Luxury Homes";
            break;

    }


    return bname;
}
