// JavaScript Document
jQuery(function($) {
$(document).ready(function(){

	$('.btn-buying').click(function() {
		window.location=('http://marionanderson.net/listings.php');
	});
	$('.btn-selling').click(function() {
		window.location=('http://marionanderson.net/selling.php');
	});
	$('.btn-blog').click(function() {
		window.location=('http://marionanderson.tumblr.com');
	});
	
	$('#contact').click(function() {
		window.location=('contact.php');
	});

	$('.facebook').click(function() {
		window.open('http://www.facebook.com/pages/Whistler-Houses-Marion-Anderson-Remax-Sea-to-Sky-Real-Estate/143531659039497');
	});
	$('.twitter').click(function() {
		window.open('http://twitter.com/#!/whistlerhouses');
	});
	$('.linkedin').click(function() {
		window.open('http://ca.linkedin.com/in/marionanderson');
	});
	$('.youtube').click(function() {
		window.open('http://www.youtube.com/user/WhistlerHouses');
	});
	$('.googleplus').click(function() {
		window.open('https://plus.google.com/b/112241818812687150424/');
	});
	$('.rss').click(function() {
		window.open('http://marionanderson.tumblr.com/api/read');
	});
	
	$('#logo').click(function() {
		window.location=('index.php');
	});

	$('#contact_badge').click(function() {
		window.location=('mailto:marionanderson@remax.net');
	});
	$('#contact_email').click(function() {
		window.location=('mailto:marionanderson@remax.net');
	});

//GET TUMBLR FEED



function get_rss_feed() {
	//clear the content in the div for the next feed.
	
	$("#recent_post").empty();
 
	//use the JQuery get to grab the URL from the selected item, put the results in to an argument for parsing in the inline function called when the feed retrieval is complete
	$.get('include/proxy.php?proxy_url=http://marionanderson.tumblr.com/api/read', function(d) {
 
		//find each 'item' in the file and parse it
		$(d).find('post').first().each(function() {
 
			//name the current found item this for this particular loop run
			var $item = $(this);
			var title = $item.find('regular-title').text();
			// now create a var 'html' to store the markup we're using to output the feed to the browser window
			var html = "<h1>RECENT REAL ESTATE NEWS | <\/h1>";
			html += "<h1>" + title + "<\/h2>";
			html += " | <a href=\'http://marionanderson.tumblr.com'\>Read More<\a>";
 
			//put that feed content on the screen!
			$('#recent_post').append($(html));  
		});
	});
 
};

$(get_rss_feed());

});
//Slide Show

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

});
jQuery.noConflict();
