$(document).ready(function() {

    // âûçîâ fancybox
    $('a.fancybox').fancybox({
        titlePosition: 'inside',
        titleFormat: FancyTitleFormat,
        overlayOpacity: 0.5,
        overlayColor: '#000000'
    });

    $(window).resize(function() {
        var width = $(this).width();

        if ($('.ie6').length == 0) {
            if (width >= 1140) {
                $('#menu ul li').css('margin-right', '30px');
                $('#contacts img').css('margin-left', '85px');
            }
            else if (width >= 1050) {
                $('#menu ul li').css('margin-right', '20px');
                $('#contacts img').css('margin-left', '95px');
            }
            else {
                $('#menu ul li').css('margin-right', '13px');
                $('#contacts img').css('margin-left', '140px');
            }
        }
    });

    $(window).resize();

});

// fancy title format
function FancyTitleFormat(title, currentArray, currentIndex, currentOpts) {
    return '<div id="tip7-title">' + (title && title.length ? '<b>' + title + '</b>' : '' ) + '<div>Ôîòî ' + (currentIndex + 1) + ' èç ' + currentArray.length + '</div></div>';
}

// google map
function LoadContactMap(id, lat, lng, zoom) {
    if (google.maps.BrowserIsCompatible()) {
        var map = new google.maps.Map2($(id)[0]);
        map.setCenter(new google.maps.LatLng(lat, lng), zoom);
        map.setMapType(G_NORMAL_MAP);
        map.addControl(new google.maps.LargeMapControl());
        map.addControl(new google.maps.HierarchicalMapTypeControl());
        //map.enableScrollWheelZoom();

		var point = map.getCenter();
		var marker = new google.maps.Marker(point);
		//map.openInfoWindowHtml(point, $(id + '-contact-marker').html());
		google.maps.Event.addListener(marker, 'click', function() {
			map.openInfoWindowHtml(point, $(id + '-contact-marker').html());
		});
		map.addOverlay(marker);
    }
}

function popup(url, name, width, height) {
    var popupWin = window.open(url, name, 'height=' + height + ',width=' + width + ',scrollbars=yes');
    popupWin.focus();
    return false;
}



