$(function(){
        
    var cookieString1 = "";
    var cookieString2 = "";
    
    //grab the url
    var pathname = window.location.pathname;
        
    //set up arrays to poplate with cookie content
    var property1Array = new Array();
    var property2Array = new Array();
    
    //retrieve details from cookies
    if ($.cookie('BoroProperties_RecentlyViewed1') != null)
    {
        cookieString1 = $.cookie('BoroProperties_RecentlyViewed1');
    }
    if ($.cookie('BoroProperties_RecentlyViewed2') != null)
    {
       cookieString2 = $.cookie('BoroProperties_RecentlyViewed2');
    }
        
    //populate arrays    
    var cookie1Split = cookieString1.split(",");
    for(i = 0; i < cookie1Split.length; i++){
	    property1Array[i] =  cookie1Split[i];
    }    
    var cookie2Split = cookieString2.split(",");
    for(i = 0; i < cookie2Split.length; i++){
	    property2Array[i] =  cookie2Split[i];
    }
    
    //set strings to show address and town
    var property1TextString = property1Array[0] +", " + property1Array[1];
    var property2TextString = property2Array[0] +", " + property2Array[1];
    
    //show recently viewed properties
    if(cookieString1!="")
    {
        $('.recentlyViewed').show();
        $('#noProps').hide();
        $('.recentlyViewed li:first-child a').attr('href', property1Array[4]);
        $('.recentlyViewed li:first-child p:first a').text(property1TextString);
        $('.recentlyViewed li:first img').attr('src', property1Array[3]);
        
        if (cookieString2=="")
        {
            $('.recentlyViewed li.last').hide();
        }
        else{
            $('.recentlyViewed li.last a').attr('href', property2Array[4]);
            $('.recentlyViewed li.last p:first a').text(property2TextString);
            $('.recentlyViewed li.last img').attr('src', property2Array[3]);
            $('.recentlyViewed li.last').show();
        }
    }
    else {
        $('#noProps').show();
        $('.recentlyViewed').hide();
    } 
        
    if(pathname == "/")
    {
        $('#banner').cycle({
            fx: 'fade',
            speed: 800,
            timeout: 5000,
            pauseOnPagerHover: 0
        });
        
        $('#hotProperties .panel').hide();
        $('#hotProperties .panel:first').show();
        $('#hotProperties ul li:first').addClass('active');
        $('#hotProperties ul li a').click(function() {
            $('#hotProperties ul li').removeClass('active');
            $(this).parent().addClass('active');
            var currentTab = $(this).attr('href');
            $('#hotProperties .panel').hide();
            $(currentTab).show();
            return false;
        });
    
    }  
});
