﻿function CallWebService(url) {

    var req = init();
    req.open("GET", url, true);
    req.send(null);

    function init() {
        if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
}

function toggleAll() {
    $(".collapseOnLoad").each(function (i) {
        $(this).toggle();
    })
}
function toggle(elementID) {
    $('#' + elementID).toggle();
}

function ShowImagePopup() {
    $find('MPE').show();
    var width = $("img[id$='imgEnlarged']").width();
    $("div[id$='pnlPopup']").css('width', width);
    $find('MPE').hide();
    $find('MPE').show();
}

function ChangeImageSrc(imgID, src) {
    $("img[id=" + imgID + "]").attr('src', src);
}

function selectElementText(el, win) {
    win = win || window;
    var doc = win.document, sel, range;
    if (win.getSelection && doc.createRange) {
        sel = win.getSelection();
        range = doc.createRange();
        range.selectNodeContents(el);
        sel.removeAllRanges();
        sel.addRange(range);
    } else if (doc.body.createTextRange) {
        range = doc.body.createTextRange();
        range.moveToElementText(el);
        range.select();
    }
}

$(function () {
    $(".hoverDiv").hover(function () {
        $(this).children().each(function () {
            $(this).attr("class", $(this).attr("class").replace("Dark", "Mid"));
        });
    }, function () {
        $(this).children().each(function () {
            $(this).attr("class", $(this).attr("class").replace("Mid", "Dark"));
        });
    });
});

$(function () {
    $("h3.expandCollapse").click(function () {
        var $this = $(this);

        if ($this.is('.selected')) {
            $this.removeClass('selected');
        }
        else {
            $this.addClass('selected');
        }
        return false;
    });
});


function initializeMap(divID, lat, lng, companyName) {
    var latlng = new google.maps.LatLng(lat, lng);
    var myOptions = {
        zoom: 11,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById(divID), myOptions);

    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: companyName
    });

}

function setupCovFancyBoxes() {
    $("a#send").fancybox({ 'width': 600, 'height': 700 });
    $("a#enlarge").fancybox({ 'width': 602, 'height': 402, 'titleShow': false });
}

function ScrollToTop(time) {
    $('html, body').animate({ scrollTop: '0px' }, time);
    return false;
}





