﻿$(function () {
    $('#search,.textbox').formwatermark();
    /*$(window).resize(function () {        
    winchange($(this));
    });*/
    
    $('.accordian').accordian();
    $('.sub .filter a').bvfilter();
    $('.map').bvmap();
    $('#capabilities').capabilities();

    $('.rotator-images').cycle({
        fx: 'scrollHorz',
        pause: 1,
        next: $('.rotator-images').parent().children('.next'),
        prev: $('.rotator-images').parent().children('.prev'),
        timeout: 5000,
        easing: 'easeInOutExpo',
        before: function (currslide, nextslide, options) {

        }
    });

    $('.work-container').bvwork();

    $(window).load(function () {
        init();
    });

    $('#request-info').capabilities('addedbutton', { added: 'You have {0} item(s) in {1}' });
    $('#contact-form').capabilities('form');

    var header = $('#header');
    var top = header.offset().top - parseFloat(header.css('marginTop').replace(/auto/, 0));
    var prevleft = header.css('left');
    var left = header.offset().left;
    $(window).resize(function (e) {
        left = header.offset().left;
        init();
    });
    $(window).scroll(function (event) {
        // what the y position of the scroll is
        var y = $(this).scrollTop();

        // whether that's below the form
        if (y > top) {
            // if so, ad the fixed class
            //header.parent().addClass('fixed').end().css({ left: left });
        } else {
            // otherwise remove it
            //header.parent().removeClass('fixed').end().css({ left: prevleft });
        }
    });


});

function init() {
    
    jQuery('.capability').equalheight();
}
// Detect whether device supports orientationchange event, otherwise fall back to
// the resize event.
/*var supportsOrientationChange = "onorientationchange" in window,
    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";

window.addEventListener(orientationEvent, function () {
    winchange($(window));  
}, false);
*/
/*
function winchange(win) {
    if (win.width() <= content_width) {
        prev_width = content_width;
        content_pos = (content_width_array[content_pos + 1]) ? content_pos + 1 : content_pos;
        content_width = content_width_array[content_pos];
        $('#main').width(content_width);
    } else if (win.width() >= prev_width) {
        content_pos = (content_width_array[content_pos - 1]) ? content_pos - 1 : content_pos;
        content_width = content_width_array[content_pos];
        $('#main').width(content_width);
    }
    $('body > div:first').html(win.width() + " - " + content_width);
}*/

