$(document).ready(function() {

Shadowbox.init();

		// tool tips start 
		$("#whatsgoingon .item a").tooltip();
		// tool tip stop


/////////////////Superfish////////////////

 $("#sample-menu-1").superfish();

///////////////End Superfish/////////////////


	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$("#topmid_center").click(function() {

		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('#topmid_center').removeClass('on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('#video').slideUp('normal');
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($("#video").is(':hidden') == true) {
			//open the video 
			$("#video").slideDown('normal',function(){
						// $(this).css("height", "429px");
			});
		 } 
	 });
	// close video on load
	$('#video').hide();
	
	
	$('.feed').hide();
	
	///twitter feed open
	
	$(".twitterbutton").click(function(){$(this).siblings('.feed').slideToggle("fast");});

	 $('#staff .region .views-row:eq(1) .staff_twit').html('<div class="twitterBody" style="margin-top:15px;margin-bottom:15px;">Terry Jaymes\' Twitter Account is visible only to followers.  <a href="http://www.twitter.com/terryjaymes" target="_new">Click here</a> to Follow Terry on Twitter!</div>');
	//alert(terrytweet);
	
	
	
	$('#staff_link').attr('href','#');
	$('#staff_link').css('cursor','default');
	
	$('#links_links').attr('href','#');
	$('#links_links').css('cursor','default');
	
	
	
	// ///////RSS feed info
		// $("#slideShowContainter .views-row").each(function(){
			// // get background image
		// var background = $(this).children('.views-field-field-backgroundimg').children('.field-content').children('img').attr('src');
		// //var backgroundsrc = background.attr('src');
			// // get our rss feed link 	 - or weather -
		// var rssfeedlink =	$(this).children('.views-field-field-rsslink').children('div').html();
// 			
// 			
// 		
// 			
		// if (rssfeedlink == 'weather'){ // if we have a weather slide lets show it :)
			// $(this).css("background-image", "url("+background+")" ).html('<div id="weather"></div>');	
		// }
		// else{
			// // else lets try to load our rss feed
		// $(this).css("background-image", "url("+background+")" ).rssfeed(rssfeedlink,);
			// }	// end else
// 		
		// });// end feed info
// 	
	// start slide show
	    $('#slideshow').after('<div id="navpager" />').cycle({
		pause: 1,
		fx: 'fade',
		pager:  '#navpager',
        pagerAnchorBuilder: function(idx, slide) {
			//var src = $('div.views-field-title',slide).text();
			return '<span><a href="#">&bull;</a></span>';
		
		}
			});

	//end slide show
		
		
		
		///////////START AD Form code
		var adtarget = $('.view-adblock a').attr('href');
		
		if(adtarget == 'http://www.lexandterry.com/advertise-with-us'){		
			$('.view-adblock a').removeAttr('target');
		};
		////////////End ad form code
			
			
		// lets make sure the twitter feed is as tall as the podcast	
		
		var pod_height = $("#podcast").height();
			
			$('#staff').height(pod_height);
			
			
		// geting our RSS feeds  a lot simpler than what i thought	
	$('#slideshow').children().each(function(){
		 // if it's  a rss feed  do this 
		if ( $(this).attr("rel") == "RSS"){
			var link = $(this).find('a').attr('href'); // lets get our rss link
			
			$(this).find('.feed_cont').rssfeed(link, {
								    limit: 4,
								    header: false,
								    snippet: true,
								    content: false
								  });
		}
		
	
	   // if we have weather  lets give our user some weather 
		if ( $(this).attr("rel") == "Misc"){
			//alert($(this).attr("id"));
				if($(this).attr("id") == "weather"){
					
					
						$.simpleWeather({
				         location: geoplugin_city()+", "+geoplugin_region(),
				        unit: 'f',
				        success: function(weather) {
				                html = '<h2>'+weather.city+', '+weather.region+' '+weather.country+'</h2>';
				                html += '<p><strong>Today\'s High</strong>: '+weather.high+'&deg; '+weather.units.temp+' - <strong>Today\'s Low</strong>: '+weather.low+'&deg; '+weather.units.temp+'</p>';
				                html += '<p><strong>Current Temp</strong>: '+weather.temp+'&deg; '+weather.units.temp+'</p>';
				                html += '<p><strong>Thumbnail</strong>: <img src="'+weather.thumbnail+'"></p>';
				                html += '<p><strong>Wind</strong>: '+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+' <strong>Wind Chill</strong>: '+weather.wind.chill+'</p>';
				                html += '<p><strong>Currently</strong>: '+weather.currently+' - <strong>Forecast</strong>: '+weather.forecast+'</p>';
				                html += '<p><img src="'+weather.image+'"></p>';
				                html += '<p><strong>Humidity</strong>: '+weather.humidity+' <strong>Pressure</strong>: '+weather.pressure+' <strong>Rising</strong>: '+weather.rising+' <strong>Visibility</strong>: '+weather.visibility+'</p>';
				                html += '<p><strong>Heat Index</strong>: '+weather.heatindex+'"></p>';
				                html += '<p><strong>Sunrise</strong>: '+weather.sunrise+' - <strong>Sunset</strong>: '+weather.sunset+'</p>';
				                html += '<p><strong>Tomorrow\'s Date</strong>: '+weather.tomorrow.day+' '+weather.tomorrow.date+'<br /><strong>Tomorrow\'s High/Low</strong>: '+weather.tomorrow.high+'/'+weather.tomorrow.low+'<br /><strong>Tomorrow\'s Forecast</strong>: '+weather.tomorrow.forecast+'<br /> <strong>Tomorrow\'s Image</strong>: '+weather.tomorrow.image+'</p>';
				                html += '<p><strong>Last updated</strong>: '+weather.updated+'</p>';
				                html += '<p><a href="'+weather.link+'">View forecast at Yahoo! Weather</a></p>';
				
				                $(this).find('.cont_').html(html);
				        },
				        error: function(error) {$(this).find('.cont_').html("<p>"+error+"</p>");}
							});// end simple weather	
				}// end if weather
		}// end if misc
		
	});
			
			
			
			
			
});// end document ready.
		
		
		

		
