$(function(){
	initDropDown();
	initCufon();
	initGallery();
})


function vodpodSaveComplete(videoId) {
    $('#videoId').val(videoId);
}

function saveVideoEntry(id, titleId, videoId, latId, lngId, itemtype) {
    if ($(latId).val() != 0 || $(lngId).val() != 0) {
        $.ajax({
            type: 'POST',
            url: 'Listeners/blogEntryReceiver.ashx',
            data: { "action": "upsert", "id": id, "videoid": videoId, "itemtype": itemtype, "blogtype": "video", "parentId": parentId, "title": $(titleId).val(), "latitude": $(latId).val(), "longitude": $(lngId).val() },
            success: function(data) {
                getBlogEntry('#blogentryholder', id, 0);
                $(titleId).val('');
                $('#videoId').val('');
                $('#blogentry').show(); $('#videoholder').hide();
                return true;
            },
            error: function(request, status, error) {
                return false;
            }
        });
    } else {
        alert("Please set the entry location before saving.");
        return false;
    }
}

function saveAudioEntry(id, titleId, latId, lngId, itemtype) {
    if ($(latId).val() != 0 || $(lngId).val() != 0) {
        $.ajax({
            type: 'POST',
            url: 'Listeners/blogEntryReceiver.ashx',
            data: { "action": "upsert", "id": id, "itemtype": itemtype, "blogtype": "audio", "parentId": parentId, "title": $(titleId).val(), "latitude": $(latId).val(), "longitude": $(lngId).val() },
            success: function(data) {
                getBlogEntry('#blogentryholder', id, 0);
                $(titleId).val('');
                $('#blogentry').show(); $('#audioholder').hide();
                return true;
            },
            error: function(request, status, error) {
            return false;
            }
        });
    } else {
        alert("Please set the entry location before saving.");
        return false;
    }
}

function saveTextEntry(id, titleId, fulltextId, latId, lngId,itemtype) {
    if ($(latId).val() != 0 || $(lngId).val() != 0) {
        $.ajax({
            type: 'POST',
            url: 'Listeners/blogEntryReceiver.ashx',
            data: { "id": id, "parentId": parentId, "action": "upsert", "itemtype": itemtype, "blogtype": "text", "fulltext": $(fulltextId).val(), "title": $(titleId).val(), "latitude": $(latId).val(), "longitude": $(lngId).val() },
            success: function(data) {
                getBlogEntry('#blogentryholder', id, 0);
                $('#blogentry').show(); $('#textholder').hide();
                $(titleId).val('');
                $(fulltextId).val('');
                return true;
            },
            error: function(request, status, error) {
                return false;
            }
        });
    } else {
        alert("Please set the entry location before saving.");
    }
}

function savePhotoEntry(id, titleId, photoId, latId, lngId, itemtype) {
    if ($(latId).val() != 0 || $(lngId).val() != 0) {
        $.ajax({
            type: 'POST',
            url: 'Listeners/blogEntryReceiver.ashx',
            data: { "id": id, "parentId": parentId, "action": "upsert", "itemtype": itemtype, "blogtype": "photo", "photoId": photoId, "title": $(titleId).val(), "latitude": $(latId).val(), "longitude": $(lngId).val() },
            success: function(data) {
                getBlogEntry('#blogentryholder', id, 0);
                $('#blogentry').show(); $('#photoholder').hide();
                $(titleId).val('');
                $('#photoId').val('');
                return true;
            },
            error: function(request, status, error) {
                return false;
            }
        });
    } else {
        alert("Please set the entry location before saving.");
        return false;
    }
}

function editEntry(id, blogtype) {
    $('.blogholder').hide();
    $('#' + blogtype + 'holder').show();
    $('#blogentryid').val(id);

    var location;
    if ($('#bloglatitude').val() != 0 && $('#bloglongitude').val() != 0) {
        codeLatLng('#bloglatitude', '#bloglongitude', '#bloglocationtext');
    } else {
        location = "Not Set";
    }

    if (blogtype == "text") {
        $('#textentryedittitle').val($('#textentrytitle').html());
        $('#textentryeditfulltext').val($('#textentryfulltext').html());
    } else if (blogtype == "video") {
        $('#videoentryedittitle').val($('#videoentrytitle').html());
    } else if (blogtype == "photo") {
        $('#photoentryedittitle').val($('#photoentrytitle').html());
    } else if (blogtype == "audio") {
        $('#audioentryedittitle').val($('#audioentrytitle').html());
        $('#audioentryembededit').html($('#audioentryembed').html());
        $('.audioentry').hide(); $('.audioeditinput').show();
    }
}

function newEntry(blogtype) {
    $('.blogholder').hide();
    $('#' + blogtype + 'holder').show();
    $('#blogentryid').val(-1);
    $('#bloglatitude,#bloglongitude').val(0);
    $('#bloglocationtext').html("Not Set");

    if (blogtype == "text") {
        $('#textentryedittitle').val('');
        $('#textentryeditfulltext').val('');
    } else if (blogtype == "audio") {
    }
}

function deleteEntry(id, nextId) {
    var dialog = $("#yesno").overlay({ load: true, oneInstance: false, closeOnClick: false });

    var buttons = $("#yesno button").click(function(e) {
        if (buttons.index(this) == 0) {//yes clicked
            $.ajax({
                type: 'POST',
                url: 'Listeners/blogEntryReceiver.ashx',
                data: { "parentId": parentId, "action": "delete", "id": id },
                success: function(data) {
                    getBlogEntry('#blogentryholder', nextId, 0);
                },
                error: function(request, status, error) {
                    //alert(request.responseText);
                }
            });
        }
    });
    dialog.load();
}

function showObjectTags() {
    $('object').show();
}
function hideObjectTags() {
    $('object').hide();
}

function loadMapPopup(latId, lngId, zoomId, update) {
    //hideObjectTags()
    jQuery.modal('<iframe src="MapPopUp.html?latId=' + latId.replace("#", "%23") + '&lngId=' + lngId.replace("#", "%23") + '&zoomId=' + zoomId.replace("#", "%23") + '" scrolling="no" frameborder="0"></iframe><a href="javascript:" onclick=""  class="simplemodal-close"><img src="images/cancel.png" alt="cancel" /></a>&nbsp;&nbsp;<a href="javascript:" onclick="showObjectTags();$.modal.close();' + (update == true ? 'updateStaticMap(\'' + latId + '\',\'' + lngId + '\',\'' + zoomId + '\');updateLatLng(\'' + latId + '\',\'' + lngId + '\',\'' + zoomId + '\');' : '') + '"><img src="images/save.png" alt="save" /></a>');
}

function loadMapPopupUpdateLocationString(latId, lngId, zoomId) {
    //hideObjectTags()
    jQuery.modal('<iframe src="/MapPopUp.html?latId=' + latId.replace("#", "%23") + '&lngId=' + lngId.replace("#", "%23") + '&zoomId=' + zoomId.replace("#", "%23") + '" scrolling="no" frameborder="0"></iframe><a href="javascript:" onclick="" class="simplemodal-close"><img src="/images/cancel.png" alt="cancel" /></a>&nbsp;&nbsp;<a href="javascript:" onclick="$.modal.close();codeLatLng(\'#bloglatitude\', \'#bloglongitude\', \'#bloglocationtext\');"><img src="/images/save.png" alt="save" /></a>');
}


function updateStaticMap(latId, lngId, zoomId) {
    $('#static_map_canvas').attr('src', 'http://maps.google.com/maps/api/staticmap?center=' + $(latId).val() + "," + $(lngId).val() + '&zoom=' + $(zoomId).val() + '&markers=color:blue|' + $(latId).val() + "," + $(lngId).val() + '&size=220x220&maptype=hybrid&sensor=false');
    //now do an ajax post to update the lat lng and zoom in the db.
    return false;
}

function initGallery(){
	/*$('.nav-holder').scrollGallery({
		sliderHolder: '.switcher',
		caption:true
	});*/

    $('.ambassadorwidget').scrollGallery({
        caption: true
    });

	$('.gallery').fadeGallery({
		slideElements:'div.mask > ul > li',
		autoHeight: true, autoRotation: true,
		pagerLinks:'div.switcher li'
	})
	$('.tab-gallery').fadeGallery({
		slideElements:'.tab-content',
		firstSlide:'.first',
		currentNum:'em.cur-num',
		allNum:'em.all-num'
	})
}
// scrolling gallery plugin
jQuery.fn.scrollGallery = function(_options) {
    var _options = jQuery.extend({
        sliderHolder: '>div',
        slider: '>ul',
        slides: '>li',
        pagerLinks: 'div.pager a',
        btnPrev: 'a.prev',
        btnNext: 'a.next',
        activeClass: 'active',
        disabledClass: 'disabled',
        generatePagination: 'div.pg-holder',
        curNum: 'em.scur-num',
        allNum: 'em.sall-num',
        circleSlide: true,
        pauseClass: 'gallery-paused',
        pauseButton: 'none',
        pauseOnHover: true,
        autoRotation: false,
        stopAfterClick: false,
        switchTime: 5000,
        duration: 650,
        easing: 'swing',
        event: 'click',
        caption: false,
        captionHolder: '.text-frame',
        splitCount: false,
        afterInit: false,
        vertical: false,
        step: true
    }, _options);

    return this.each(function() {
        // gallery options
        var _this = jQuery(this);
        var _sliderHolder = jQuery(_options.sliderHolder, _this);
        var _slider = jQuery(_options.slider, _sliderHolder);
        var _slides = jQuery(_options.slides, _slider);
        var _btnPrev = jQuery(_options.btnPrev, _this);
        var _btnNext = jQuery(_options.btnNext, _this);
        var _pagerLinks = jQuery(_options.pagerLinks, _this);
        var _generatePagination = jQuery(_options.generatePagination, _this);
        var _curNum = jQuery(_options.curNum, _this);
        var _allNum = jQuery(_options.allNum, _this);
        var _pauseButton = jQuery(_options.pauseButton, _this);
        var _pauseOnHover = _options.pauseOnHover;
        var _pauseClass = _options.pauseClass;
        var _autoRotation = _options.autoRotation;
        var _activeClass = _options.activeClass;
        var _disabledClass = _options.disabledClass;
        var _easing = _options.easing;
        var _duration = _options.duration;
        var _switchTime = _options.switchTime;
        var _controlEvent = _options.event;
        var _step = _options.step;
        var _vertical = _options.vertical;
        var _circleSlide = _options.circleSlide;
        var _stopAfterClick = _options.stopAfterClick;
        var _afterInit = _options.afterInit;
        var _splitCount = _options.splitCount;
        var _caption = _options.caption;
        var _captionHolder = $(_options.captionHolder, _this);
       
        // gallery init
        if (!_slides.length) return;
        
        if (_splitCount) {
            var curStep = 0;
            var newSlide = $('<slide>').addClass('split-slide');
            _slides.each(function() {
                newSlide.append(this);
                curStep++;
                if (curStep > _splitCount - 1) {
                    curStep = 0;
                    _slider.append(newSlide);
                    newSlide = $('<slide>').addClass('split-slide');
                }
            });
            if (curStep) _slider.append(newSlide);
            _slides = _slider.children();
        }

        var _currentStep = 0;
        var _sumWidth = 0;
        var _sumHeight = 0;
        var _hover = false;
        var _stepWidth;
        var _stepHeight;
        var _stepCount;
        var _offset;
        var _timer;

        _slides.each(function() {
            _sumWidth += $(this).outerWidth(true);
            _sumHeight += $(this).outerHeight(true);
        });

        if (_caption) {
            _captionHolder.html(_slides.eq(_currentStep).find('img').attr('title'));
            _slides.find('a').mouseenter(function() {
                _captionHolder.html($(this).find('img').attr('title'));
            })
        }
        // calculate gallery offset
        function recalcOffsets() {
            if (_vertical) {
                if (_step) {
                    _stepHeight = _slides.eq(_currentStep).outerHeight(true);
                    _stepCount = Math.ceil((_sumHeight - _sliderHolder.height()) / _stepHeight) + 1;
                    _offset = -_stepHeight * _currentStep;
                } else {
                    _stepHeight = _sliderHolder.height();
                    _stepCount = Math.ceil(_sumHeight / _stepHeight);
                    _offset = -_stepHeight * _currentStep;
                    if (_offset < _stepHeight - _sumHeight) _offset = _stepHeight - _sumHeight;
                }
            } else {
                if (_step) {
                    _stepWidth = _slides.eq(_currentStep).outerWidth(true) * _step;
                    _stepCount = Math.ceil((_sumWidth - _sliderHolder.width()) / _stepWidth) + 1;
                    _offset = -_stepWidth * _currentStep;
                    if (_offset < _sliderHolder.width() - _sumWidth) _offset = _sliderHolder.width() - _sumWidth;
                } else {
                    _stepWidth = _sliderHolder.width();
                    _stepCount = Math.ceil(_sumWidth / _stepWidth);
                    _offset = -_stepWidth * _currentStep;
                    if (_offset < _stepWidth - _sumWidth) _offset = _stepWidth - _sumWidth;
                }
            }
        }
        // gallery control
        if (_btnPrev.length) {
            _btnPrev.bind(_controlEvent, function() {
                if (_stopAfterClick) stopAutoSlide();
                prevSlide();
                return false;
            });
        }
        if (_btnNext.length) {
            _btnNext.bind(_controlEvent, function() {
                if (_stopAfterClick) stopAutoSlide();
                nextSlide();
                return false;
            });
        }
        if (_generatePagination.length) {
            _generatePagination.empty();
            recalcOffsets();
            var _list = $('<ul />');
            for (var i = 0; i < _stepCount; i++) $('<li><a href="#">' + (i + 1) + '</a></li>').appendTo(_list);
            _list.appendTo(_generatePagination);
            _pagerLinks = _list.children();
        }
        if (_pagerLinks.length) {
            _pagerLinks.each(function(_ind) {
                jQuery(this).bind(_controlEvent, function() {
                    if (_currentStep != _ind) {
                        if (_stopAfterClick) stopAutoSlide();
                        _currentStep = _ind;
                        switchSlide();
                    }
                    return false;
                });
            });
        }

        // gallery animation
        function prevSlide() {
            recalcOffsets();
            if (_currentStep > 0) _currentStep--;
            else if (_circleSlide) _currentStep = _stepCount - 1;
            switchSlide();
        }
        function nextSlide() {
            recalcOffsets();
            if (_currentStep < _stepCount - 1) _currentStep++;
            else if (_circleSlide) _currentStep = 0;
            switchSlide();
        }
        function refreshStatus() {
            if (_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentStep).addClass(_activeClass);
            if (!_circleSlide) {
                _btnPrev.removeClass(_disabledClass);
                _btnNext.removeClass(_disabledClass);
                if (_currentStep == 0) _btnPrev.addClass(_disabledClass);
                if (_currentStep == _stepCount - 1) _btnNext.addClass(_disabledClass);
            }
            if (_curNum.length) _curNum.text(_currentStep + 1);
            if (_allNum.length) _allNum.text(_stepCount);
        }
        function switchSlide() {
            recalcOffsets();
            if (_vertical) _slider.animate({ marginTop: _offset }, { duration: _duration, queue: false, easing: _easing });
            else _slider.animate({ marginLeft: _offset }, { duration: _duration, queue: false, easing: _easing });
            refreshStatus();
            autoSlide();
        }

        // autoslide function
        function stopAutoSlide() {
            if (_timer) clearTimeout(_timer);
            _autoRotation = false;
        }
        function autoSlide() {
            if (!_autoRotation || _hover) return;
            if (_timer) clearTimeout(_timer);
            _timer = setTimeout(nextSlide, _switchTime + _duration);
        }
        if (_pauseOnHover) {
            _this.hover(function() {
                _hover = true;
                if (_timer) clearTimeout(_timer);
            }, function() {
                _hover = false;
                autoSlide();
            });
        }
        recalcOffsets();
        refreshStatus();
        autoSlide();

        // pause buttton
        if (_pauseButton.length) {
            _pauseButton.click(function() {
                if (_this.hasClass(_pauseClass)) {
                    _this.removeClass(_pauseClass);
                    _autoRotation = true;
                    autoSlide();
                } else {
                    _this.addClass(_pauseClass);
                    stopAutoSlide();
                }
                return false;
            });
        }

        if (_afterInit && typeof _afterInit === 'function') _afterInit(_this, _slides);
    });
}

// slideshow plugin
jQuery.fn.fadeGallery = function(_options) {
    var _options = jQuery.extend({
        slideElements: 'div.slideset > div',
        pagerLinks: 'div.pager a',
        btnNext: 'a.next',
        btnPrev: 'a.prev',
        btnPlayPause: 'a.play-pause',
        btnPlay: 'a.play',
        btnPause: 'a.pause',
        pausedClass: 'paused',
        disabledClass: 'disabled',
        playClass: 'playing',
        activeClass: 'active',
        currentNum: false,
        allNum: false,
        startSlide: null,
        noCircle: false,
        pauseOnHover: true,
        autoRotation: false,
        autoHeight: false,
        onChange: false,
        switchTime: 3000,
        firstSlide: false,
        duration: 650,
        event: 'click'
    }, _options);

    return this.each(function() {
        // gallery options
        var _this = jQuery(this);
        var _slides = jQuery(_options.slideElements, _this);
        var _pagerLinks = jQuery(_options.pagerLinks, _this);
        var _btnPrev = jQuery(_options.btnPrev, _this);
        var _btnNext = jQuery(_options.btnNext, _this);
        var _btnPlayPause = jQuery(_options.btnPlayPause, _this);
        var _btnPause = jQuery(_options.btnPause, _this);
        var _btnPlay = jQuery(_options.btnPlay, _this);
        var _pauseOnHover = _options.pauseOnHover;
        var _autoRotation = _options.autoRotation;
        var _activeClass = _options.activeClass;
        var _disabledClass = _options.disabledClass;
        var _pausedClass = _options.pausedClass;
        var _playClass = _options.playClass;
        var _autoHeight = _options.autoHeight;
        var _duration = _options.duration;
        var _switchTime = _options.switchTime;
        var _controlEvent = _options.event;
        var _currentNum = (_options.currentNum ? jQuery(_options.currentNum, _this) : false);
        var _allNum = (_options.allNum ? jQuery(_options.allNum, _this) : false);
        var _startSlide = _options.startSlide;
        var _noCycle = _options.noCircle;
        var _onChange = _options.onChange;
        var _firstSlide = $(_options.firstSlide);

        // gallery init
        var _hover = false;
        var _prevIndex = 0;
        var _currentIndex = 0;
        var _slideCount = _slides.length;
        var _timer;
        if (_slideCount < 2) return;

        _prevIndex = _slides.index(_slides.filter('.' + _activeClass));
        if (_prevIndex < 0) _prevIndex = _currentIndex = 0;
        else _currentIndex = _prevIndex;
        if (_startSlide != null) {
            if (_startSlide == 'random') _prevIndex = _currentIndex = Math.floor(Math.random() * _slideCount);
            else _prevIndex = _currentIndex = parseInt(_startSlide);
        }
        _slides.hide().eq(_currentIndex).show();
        if (_autoRotation) _this.removeClass(_pausedClass).addClass(_playClass);
        else _this.removeClass(_playClass).addClass(_pausedClass);

        if (_firstSlide.length) {
            _firstSlide.click(function() {
                if (_currentIndex != 0) {
                    _prevIndex = _currentIndex;
                    _currentIndex = 0;
                    switchSlide();
                }
                return false;
            })
        }

        // gallery control
        if (_btnPrev.length) {
            _btnPrev.bind(_controlEvent, function() {
                prevSlide();
                return false;
            });
        }
        if (_btnNext.length) {
            _btnNext.bind(_controlEvent, function() {
                nextSlide();
                return false;
            });
        }
        if (_pagerLinks.length) {
            _pagerLinks.each(function(_ind) {
                jQuery(this).bind(_controlEvent, function() {
                    if (_currentIndex != _ind) {
                        _prevIndex = _currentIndex;
                        _currentIndex = _ind;
                        switchSlide();
                    }
                    return false;
                });
            });
        }

        // play pause section
        if (_btnPlayPause.length) {
            _btnPlayPause.bind(_controlEvent, function() {
                if (_this.hasClass(_pausedClass)) {
                    _this.removeClass(_pausedClass).addClass(_playClass);
                    _autoRotation = true;
                    autoSlide();
                } else {
                    _autoRotation = false;
                    if (_timer) clearTimeout(_timer);
                    _this.removeClass(_playClass).addClass(_pausedClass);
                }
                return false;
            });
        }
        if (_btnPlay.length) {
            _btnPlay.bind(_controlEvent, function() {
                _this.removeClass(_pausedClass).addClass(_playClass);
                _autoRotation = true;
                autoSlide();
                return false;
            });
        }
        if (_btnPause.length) {
            _btnPause.bind(_controlEvent, function() {
                _autoRotation = false;
                if (_timer) clearTimeout(_timer);
                _this.removeClass(_playClass).addClass(_pausedClass);
                return false;
            });
        }

        // gallery animation
        function prevSlide() {
            _prevIndex = _currentIndex;
            if (_currentIndex > 0) _currentIndex--;
            else {
                if (_noCycle) return;
                else _currentIndex = _slideCount - 1;
            }
            switchSlide();
        }
        function nextSlide() {
            _prevIndex = _currentIndex;
            if (_currentIndex < _slideCount - 1) _currentIndex++;
            else {
                if (_noCycle) return;
                else _currentIndex = 0;
            }
            switchSlide();
        }
        function refreshStatus() {
            if (_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentIndex).addClass(_activeClass);
            if (_currentNum) _currentNum.text(_currentIndex + 1);
            if (_allNum) _allNum.text(_slideCount);
            _slides.eq(_prevIndex).removeClass(_activeClass);
            _slides.eq(_currentIndex).addClass(_activeClass);
            if (_noCycle) {
                if (_btnPrev.length) {
                    if (_currentIndex == 0) _btnPrev.addClass(_disabledClass);
                    else _btnPrev.removeClass(_disabledClass);
                }
                if (_btnNext.length) {
                    if (_currentIndex == _slideCount - 1) _btnNext.addClass(_disabledClass);
                    else _btnNext.removeClass(_disabledClass);
                }
            }
            if (typeof _onChange === 'function') {
                _onChange(_this, _currentIndex);
            }
        }
        function switchSlide() {
            _slides.eq(_prevIndex).fadeOut(_duration);
            _slides.eq(_currentIndex).fadeIn(_duration);
            if (_autoHeight) _slides.eq(_currentIndex).parent().animate({ height: _slides.eq(_currentIndex).outerHeight(true) }, { duration: _duration, queue: false });
            refreshStatus();
            autoSlide();
        }

        // autoslide function
        function autoSlide() {
            if (!_autoRotation || _hover) return;
            if (_timer) clearTimeout(_timer);
            _timer = setTimeout(nextSlide, _switchTime + _duration);
        }
        if (_pauseOnHover) {
            _this.hover(function() {
                _hover = true;
                if (_timer) clearTimeout(_timer);
            }, function() {
                _hover = false;
                autoSlide();
            });
        }
        refreshStatus();
        autoSlide();
    });
}

function initDropDown()
{
	var nav = document.getElementById("add-nav");
	if(nav) {
		var lis = nav.getElementsByTagName("li");
		for (var i=0; i<lis.length; i++) {
			if(lis[i].getElementsByTagName("ul").length > 0) {
				lis[i].className += " has-drop-down"
				lis[i].getElementsByTagName("a")[0].className += " has-drop-down-a"
			}
			lis[i].onmouseover = function()	{
				this.className += " hover";
			}
			lis[i].onmouseout = function() {
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}


function initCufon() {
	Cufon.replace('#nav .active a', { fontFamily: 'Zurich-Bold', hover: true });
	Cufon.replace('#nav a', { fontFamily: 'Zurich-Roman', hover: true });
	Cufon.replace('#nav .active a', { fontFamily: 'Zurich-Bold', hover: true });
	Cufon.replace('#header .heading', { fontFamily: 'TrajanPro-Bold' });
	Cufon.replace('#header .title strong', { fontFamily: 'TrajanPro-Regular' });
	Cufon.replace('#main .heading strong span', { fontFamily: 'Zurich-Roman' });
	Cufon.replace('#main .heading strong', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('#main .heading strong span', { fontFamily: 'Zurich-Roman' });
	Cufon.replace('#main .heading .aligncenter span span', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('#content .block h3', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('.aside .involved h3', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('.map-holder h3', { fontFamily: 'TrajanPro-Bold' });
	Cufon.replace('.map-box-small h3', { fontFamily: 'TrajanPro-Bold' });
	Cufon.replace('.content-box h2', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('.button', { fontFamily: 'Zurich-Bold', hover: true });
	Cufon.replace('.content-box .delete', { fontFamily: 'Zurich-Bold', hover: true });
	Cufon.replace('.filters li span', { fontFamily: 'Zurich-Bold', hover: true });
	Cufon.replace('#main .columns .phone', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('#main .columns .title', { fontFamily: 'Zurich-Bold' });
	Cufon.replace('#main .debateinfo', { fontFamily: 'Zurich-Bold' });
}

function getBlogEntry(divId, blogEntryId, showSocialMedia) {
    $.ajax({
        type: 'POST',
        url: 'BlogEntry.aspx',
        data: { "parentId": parentId, "blogItemId": blogEntryId, "showSocialMedia": showSocialMedia },
        success: function(data) {
            $(divId).html(data);
            codeLatLng('#bloglatitude', '#bloglongitude', '#bloglocationtext');
        },
        error: function(request, status, error) {
        }
    });
}

function codeLatLng(latId, lngId, div) {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng($(latId).val(), $(lngId).val());
    $(div).html("Searching...");
    geocoder.geocode({ 'latLng': latlng }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            if (results[1]) {
                $(div).html(results[1].formatted_address);
            }
        } else {
            $(div).html("None Set");
        }
    });
}
