//When the DOM tree is loaded
$(document).ready(function () {

    $("a[rel^='prettyPhoto']").prettyPhoto();  //for prettyPhoto

    if (jQuery.trim(getQS("autoplay")) != '') {
        $('#nv_autoplay').trigger('click');
    }

    $(".newsletter").focus(function (srcc) {
        if ($(this).val() == $(this)[0].title) {
            // $(this).removeClass("defaultTextActive");
            $(this).val("");
        }
    });

    $(".newsletter").blur(function () {
        if ($(this).val() == "") {
            // $(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
        }
    });

    $(".newsletter").blur();
    

    //call display functions first
    if ($("#home_tabs").length > 0) {
    }
    else {
        ResizePage();
    }
    //Add pointer class to .photo .item
    $(".photo .item").addClass("pointer");

    //Hover over photo fade in hidden span
    $(".photo .item").hover(
        function () {
            $(this).find("span").fadeIn();
        },
        function () {
            $(this).find("span").fadeOut();
        }
    );

    $(window).resize(function () {
        ResizePage()
    });

    /* $("#map-link-holder").click(function() {
    $("#map").html("<iframe  width='700' height='500' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Newvision+Communications,+Inc+5100+W+Tilghman+St+Allentown,+PA+18104&amp;sll=40.749338,-75.338745&amp;sspn=1.104849,2.210999&amp;ie=UTF8&amp;hq=Newvision+Communications,+Inc&amp;hnear=5100+W+Tilghman+St,+Allentown,+PA+18104&amp;ll=40.589976,-75.568396&amp;spn=0.006295,0.006295&amp;output=embed'></iframe>");
    // alert($("#map").html());
    $("#map-link").click();
    return false;
    });
    */
});


function getQS(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
    return null;
}



function ResizePage() {
 //   var o = $("#footer").offset();
 //   var i = o.top - 105;
 //   $("#body_wrapper").css("min-height", i + "px");
 //   i = i - 120;
 //   $("#content-wrapper").css("min-height", i + "px");
}

$(document).ready(function() {
    $('a.zoom').each(function() {
        var fWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)
[0].replace('width=', ''));
        var fHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)
[0].replace('height=', ''));
        $(this).fancybox({ 'width': fWidth, 'height': fHeight, 'overlayOpacity': 0.7, 'overlayColor': '#000', 'zoomOpacity': true });
    });
    $("#map-link").fancybox({
  
    'autoDimensions': true,
    'transitionIn': 'none',
    'transitionOut': 'none'
   

    });


    $(".comment-link").click(function() {
        var id = $(this).attr("href");
        $(id).slideToggle();
        return false;
    });




 $(".ovly-link").fancybox({
    
      'hideOnContentClick' : false,
      'height': 500,
      'showNavArrows':true}
      );
      
   


}); 
