﻿// js for default

  function load()

{
   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}


function EndRequestHandler()

{
       // alert("end");
         Cufon.replace('h2 a', {
			//	textShadow: '#fff -1px -1px, #333 1px 1px'
			        textShadow: '1px 1px #b6b7ba',
		            color: '-linear-gradient(#41708e, #3a5e74)',
		            hover: {
		                textShadow: '1px 1px #b6b7ba',
		                color: '-linear-gradient(#8d0b22, #d47d8c)'
	                    }
			});
}


    $(function() {
        $('ul.drawers').accordion({
            header: 'H2.drawer-handle',
            selectedClass: 'o pen',
            event: 'mouseover'
        });
    });
    //hide slider of featued if no properties
$(document).ready(function () {

           
    
        Cufon.replace('h2 a', {
                    textShadow: '1px 1px #b6b7ba',
		            color: '-linear-gradient(#41708e, #3a5e74)',
		            hover: {
		                textShadow: '1px 1px #b6b7ba',
		                color: '-linear-gradient(#8d0b22, #d47d8c)'
	                }
			   
			});
        Cufon.replace('li h2', {
                    textShadow: '1px 1px #fff',
		            color: '-linear-gradient(#000, #272727)',
		            hover: {
		                textShadow: '1px 1px #b6b7ba',
		                color: '-linear-gradient(#272727, #000)'
	                }
			   
			});

			var st =0;
			if (document.getElementById('ulinfiniteCarouselID')!=null){
                st = document.getElementById('ulinfiniteCarouselID').innerHTML.length;
            }
        if (st>90)
        {
        document.getElementById('FeaturedSlider').style.display = 'block';
        
        $.fn.infiniteCarousel = function () {
    
    
    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        var $wrapper = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
            
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            
 
 
        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }
 
        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
            
            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 
 
                currentPage = page;
            });                
            
            return false;
        }
        
        $wrapper.after('<a class="arrow back"></a><a class="arrow forward"></a>');
        
        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);                
        });
        
        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function () {
                gotoPage(currentPage + 1);
            });
            
    });  
};
 
$(document).ready(function () {
 // $('.infiniteCarousel').infiniteCarousel();
 // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var autoscrolling = true;
    
    $('.infiniteCarousel').infiniteCarousel().mouseover(function () {
        autoscrolling = false;
    }).mouseout(function () {
        autoscrolling = true;
    });
    
    setInterval(function () {
        if (autoscrolling) {
            $('.infiniteCarousel').trigger('next');
        }
    }, 8000);
 
 
 
 
});
        
        
        }
        else{
        document.getElementById('FeaturedSlider').style.display = 'none';
        };
 });
 
 
$(document).ready(function() {
$('.shortlistingleft a').live('mouseover', function() {
 
 $(this).find('strong').stop().fadeTo('normal', 0.7);
 
});
$('.shortlistingleft a').live('mouseout', function() {
 
 $(this).find('strong').stop().fadeTo('normal', 0);
});
});   
 
 
$(document).ready(function() {
$('.contactusbtn').live('click', function() {
 
 $.fn.colorbox({width:"850px",height:"500px", inline:true, href:"#inline_example1"});
 
});
$('.favoritesbtn').live('click', function() {
 
 $.fn.colorbox({width:"400px",height:"200px", inline:true, href:"#inline_example2"});
 
});
$('.moreinfobtn').live('click', function() {
 
 $.fn.colorbox({width:"400px",height:"550px", inline:true, href:"#inline_example5"});
 
});
$('.brochurebtn').live('click', function() {
 
 $.fn.colorbox({width:"400px",height:"550px", inline:true, href:"#inline_example4"});

});

$('.SiteLogin').live('click', function() {

    $.fn.colorbox({ width: "400px", height: "250px", inline: true, href: "#inline_exampleUL" });

});

});

            var interval_time = 20000; // 10 seconds between changes
            var item_count;
            var item_interval;
            var old_item = 0;
            var current_item = 0;
 
            $(document).ready(function() {
                item_count = $("div.slideshow-item").size();
 
                $("div.slideshow-item").each(function(i) {
                    $(this).hide();
                });
 
                $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");
 
                item_interval = setInterval(item_rotate, interval_time); // time in milliseconds
                $('#slideshow-container').hover(function() {
                    clearInterval(item_interval);
                }, function() {
                    item_interval = setInterval(item_rotate, interval_time); //time in milliseconds
                    item_rotate();
                });
            });
 
            function item_rotate() {
                current_item = (old_item + 1) % item_count;
                $("div.slideshow-item:eq(" + old_item + ")").fadeOut("slow", function() {
                    $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");
                });
                old_item = current_item;
            }


    
  


function createMarker(point, index, pn, infohtml) {
    var letter = String.fromCharCode("A".charCodeAt(0) + index);
    var image = new google.maps.MarkerImage("http://www.google.com/mapfiles/marker" + letter + ".png",
                        new google.maps.Size(20, 34),
                        new google.maps.Point(0, 0),
                        new google.maps.Point(9, 34));
    var marker = new google.maps.Marker({
        map: map,
        title: pn,
        shadow: shadow,
        icon: image,
        content: infohtml,
        position: point
    });
    map.addMarker(marker, point);

    //  var infowindow = new google.maps.InfoWindow(
    //      { content: infohtml
    //     });
    //  infoWindow.setOptions();
    google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setOptions({
            map: map,
            title: pn,
            shadow: shadow,
            icon: image,
            content: infohtml,
            position: point
        });
        infoWindow.open(map, marker);
    });
    markerArray.push(marker);

    return marker;


}
    

    function ShowMap(mymarkerid, latitude, longitude) 
    {   
        var CenterTo = new google.maps.LatLng(latitude, longitude);
        map.setCenter(CenterTo);
      //  infoWindow.open(map, markerArray[mymarkerid]);
        map.setZoom(20);
         google.maps.event.trigger(markerArray[mymarkerid], 'click');
    }
    function ShowPopUpFavorites() {
        document.getElementById('overlay').style.display = 'block';
        document.getElementById('lightboxFavorites').style.display = 'block';
    }
    function HidePopUpFavorites() {
        document.getElementById('overlay').style.display = 'none';
        document.getElementById('lightboxFavorites').style.display = 'none';
    }
    function ShowPopUpContact(propertyName) {
       var lblContactHeader = parent.window["ContactFrame"].LblContactHeader;
       lblContactHeader.innerText = "Contact " + propertyName;
    }
    function HideContactPopUp() {
        $.fn.colorbox({width:"300px",height:"200px", inline:true, href:"#inline_example3"});
    }
    function HideUserLoginPopUp() {
        $.fn.colorbox({ width: "300px", height: "200px", inline: true, href: "#inline_exampleULWelcome",onClosed:function(){  document.location.reload(); } });
       
    }
    function HideUserLoginFBPopUp() {
        $.fn.colorbox({ width: "300px", height: "300px", inline: true, href: "#inline_exampleFBWelcome" });
    }
    function HideFB() {
       $(document).ready(function() {
         $.fn.colorbox({ width: "400px", height: "300px", inline: true, href: "#inline_example9" });
         });
    }

        $(function() {
            $('.bubbleInfo').each(function() {
                var distance = -40;
                var time = 250;
                var hideDelay = 500;

                var hideDelayTimer = null;

                var beingShown = false;
                var shown = false;
                var trigger = $('.trigger', this);
                var info = $('.popup', this).css('opacity', 0);


                $([trigger.get(0), info.get(0)]).mouseover(function() {
                    if (hideDelayTimer) clearTimeout(hideDelayTimer);
                    if (beingShown || shown) {
                        // don't trigger the animation again
                        return;
                    } else {
                        // reset position of info box
                        beingShown = true;

                        info.css({
                            top: -30,
                            left: +500,
                            display: 'block'
                        }).animate({
                            top: '-=' + distance + 'px',
                            opacity: 1
                        }, time, 'swing', function() {
                            beingShown = false;
                            shown = true;
                        });
                    }

                    return false;
                }).mouseout(function() {
                    if (hideDelayTimer) clearTimeout(hideDelayTimer);
                    hideDelayTimer = setTimeout(function() {
                        hideDelayTimer = null;
                        info.animate({
                            top: '-=' + distance + 'px',
                            opacity: 0
                        }, time, 'swing', function() {
                            shown = false;
                            info.css('display', 'none');
                        });

                    }, hideDelay);

                    return false;
                });
            });
        });
 