//  Bungalo.is - 2010
//  Main javascript file by mogue

$(document).bind("ready", function (){

	

	//--------------
	// Map
	//--------------
	$(".geo").bind("mouseover", function () {
		var where = parseInt($(this).attr("index"));
		$("#map_iceland").css({ "background-position":"0 -" + (230 * where) + "px" });
	});
	$(".geo").bind("mouseout", function () {
		$("#map_iceland").css({ "background-position":"0 0" });
	});

	//--------------
	// Datepicker
	//--------------
	$("#dateTo,#dateFrom").datepicker({ 
		hideIfNoPrevNext: true, minDate: '+0d', 
		showOtherMonths: true,   
		beforeShow: function(input, inst) {
			//inst.dpDiv.append("<h2>awofoooo</h2>");
		},
	    onSelect: function(dateText, inst) {
			$(this).css({ "color":"black" });
		}
	});
	$("#dateTo,#dateFrom").bind("change", function() { $(this).css({ "color":"black" }) });


	//--------------
	// Feeds
	//--------------

	
    // twitter date hack
    //$("#twitter_date").append($("#twitter_update_list>li>a"));

	/** Twitter **/
    $.jGFeed('http://feeds.feedburner.com/Bungalotweets',
    function(feeds){
      if(!feeds) return false;
	  for(var i=0; i<feeds.entries.length; i++){
	    var entry = feeds.entries[i];
	    $("#twitter .bubble").append('<a href="' + entry.link + '">' + entry.content + '</a>');
		$("#twitter #twitter_date").append(entry.publishedDate.substring(0,16));
	  }
    }, 1);

    /** Facebook **/
    $.jGFeed('http://feeds.feedburner.com/BngalsFacebookWall',
    function(feeds){
      if(!feeds) return false;
	  for(var i=0; i<feeds.entries.length; i++){
	    var entry = feeds.entries[i];
	    $("#facebook>#content>#text>.padd").append('<a href="' + entry.link + '">' + entry.title.substring(0, 100) + '...</a>');
		$("#facebook>#content>#text>.padd").append('<a href="' + entry.link + '" id="read_more"><img src="img/rss_facebook_more.png" />&nbsp;Lesa meira</a>');
	  }
    }, 1);

	
	// $("#facebook").append($("#stream_content").html());

	//$('#facebook').simplerss({url:'http://www.facebook.com/feeds/page.php?format=rss20&id=238000198706'});
	

});
