﻿//var map = null;

////use
//var LA = new VELatLong(34.0540, -118.2370);

//var pinPoint = null;
//var pinPixel = null;

//function GetMap() {
//    map = new VEMap('map');
//    map.LoadMap(LA, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);

//    AddPin();
//}

//function AddPin() {
//    // Add a new pushpin to the center of the map.
//    pinPoint = map.GetCenter();
//    pinPixel = map.LatLongToPixel(pinPoint);
//    map.AddPushpin(pinPoint);
//}

//function toggleMap() {
//    if (map == null) {
//        GetMap();
//    }

//    $('#detail-mapview').toggle();
//}

$(document).ready(function($) {
    // We only want these styles applied when javascript is enabled
    $('div.navigation').css({ 'width': '100%', 'float': 'left' });
    $('div.content').css('display', 'block');
    if (imgcount != null) {
        if (imgcount > 9) {
            $('#thumb-photo').css('height', '150px');
        } else {
            $('#thumb-photo').css('height', '100px');
        }
    }

//    $('#button-mapview').click(function() {
//        toggleMap();
//    });

    $('.listingrequest').click(function() {
        $("#modal-contact-form").modal({
            appendTo: 'form',
            overlayClose: true
        });
    });

    $('#button-video').click(function() {
        $("#listing-video").modal({
            overlayClose: true,
            minHeight: 400,
            minWidth: 400
        });
    });

    //set subject message for contact forms
    $('#modal-subject,#subject').val('Please contact me regarding listing MLS#'+mlsnumber);

    // Initially set opacity on thumbs and add
    // additional styling for hover effect on thumbs
    var onMouseOutOpacity = 0.67;
    $('#thumbs ul.thumbs li').css('opacity', onMouseOutOpacity)
			            .hover(
				            function() {
				                $(this).not('.selected').fadeTo('fast', 1.0);
				            },
				            function() {
				                $(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
				            }
			            );

    // Initialize Advanced Galleriffic Gallery
    var gallery = $('#gallery').galleriffic('#thumbs', {
        delay: 4000,
        numThumbs: 18,
        preloadAhead: 10,
        enableTopPager: false,
        enableBottomPager: false,
        maxPagesToShow: 7,
        imageContainerSel: '#slideshow',
        controlsContainerSel: '#controls',
        //captionContainerSel:       '#caption',
        loadingContainerSel: '#loading',
        renderSSControls: true,
        renderNavControls: true,
        playLinkText: 'Play Slideshow',
        pauseLinkText: 'Pause Slideshow',
        prevLinkText: '&lsaquo; Previous Photo',
        nextLinkText: 'Next Photo &rsaquo;',
        nextPageLinkText: 'Next &rsaquo;',
        prevPageLinkText: '&lsaquo; Prev',
        enableHistory: false,
        autoStart: true,
        syncTransitions: true,
        defaultTransitionDuration: 900,
        onSlideChange: function(prevIndex, nextIndex) {
            $('#thumbs ul.thumbs').children()
				            .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				            .eq(nextIndex).fadeTo('fast', 1.0);
        },
        onTransitionOut: function(callback) {
            $('#caption').fadeTo('fast', 0.0);
            $('#slideshow').fadeTo('fast', 0.0, callback);
        },
        onTransitionIn: function() {
            $('#slideshow').fadeTo('fast', 1.0);
            $('#caption').fadeTo('fast', 1.0);
        },
        onPageTransitionOut: function(callback) {
            $('#thumbs ul.thumbs').fadeTo('fast', 0.0, callback);
        },
        onPageTransitionIn: function() {
            $('#thumbs ul.thumbs').fadeTo('fast', 1.0);
        }
    });

    // PageLoad function
    // This function is called when:
    // 1. after calling $.historyInit();
    // 2. after calling $.historyLoad();
    // 3. after pushing "Go Back" button of a browser
    //function pageload(hash) {
    // hash doesn't contain the first # character.
    //if(hash) {
    //						$.galleriffic.goto(hash);
    //} else {
    //						$.galleriffic.goto(0);
    //}
    //}

    // Initialize history plugin.
    // The callback is called at once by present location.hash. 
    //$.historyInit(pageload, "advanced.html");

    // set onlick event for buttons using the jQuery 1.3 live method
    //$("a[rel='history']").live('click', function() {
    //					var hash = this.href;
    //hash = hash.replace(/^.*#/, '');

    // moves to a new page. 
    // pageload is called at once. 
    // hash don't contain "#", "?"
    //$.historyLoad(hash);

    //return false;
    //});

});
