image1=new Image;
image1.src="http://www.energyvibe.com/wp-content/themes/energyVIBE/style/images/energyvibe.png";
image2=new Image;
image2.src="http://www.energyvibe.com/wp-content/themes/energyVIBE/style/images/energyvibe02.png";



function showGadget() {
  var feeds = [
   {title:'EERE Network News',
    url:'http://apps1.eere.energy.gov/news/rss/enn.xml'},
   {title:'TreeHugger',
    url:'http://feedproxy.google.com/treehuggersite'}];

  new GFdynamicFeedControl(feeds, 'feedGadget',
                           {numResults : 3, stacked : true,
                           title: " "});
}
google.load("feeds", "1");
google.setOnLoadCallback(showGadget);


$(function() {
	
	if(window.location.href.indexOf("archives")>0)
	{
		$("#nav li:eq(2)").addClass("current_page_item");
	}
	
	$('#twitter-box').click(function(){
		window.open('http://www.twitter.com/EnergyVibe');
		
	});
	
	$('#slidertext li').each(function(){
    	$(this).hide();
    });
    
    $('#banner img').hover(function (){
   		$('span').show();
    },
    function() {
    	$('span').css("display","none");
    }
    );
    
   
    
    
	$('#s3').cycle({
		fx:     'scrollLeft',
		speed:   800,
		timeout: 5000,
		next:   '#s3',
		pause:   1
	});
	
	 $('#slideshow').cycle({
        fx:     'fade',
        speed:  700,
        timeout: 0,
        pager:  '#aboutnav',
        pagerEvent: 'click',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#aboutnav li:eq(' + (idx) + ') a';
        },
        after: changeText,
        before: removeText
    });
    
    function changeText(curr, next, opts){
   		 var index = opts.currSlide;
    	
    	
    	$('#slidertext li:eq('+index+')').animate({opacity: 1.0}, 1000).slideDown("slow");
    	
    	
    }
    
    function removeText(curr, next, opts){
    	
    	var index = opts.currSlide;
    	$('#slidertext li:eq('+index+')').slideUp("fast");
    }
    
    
    
    $('#aboutnav li a').click(function(){
    	$('#aboutnav li a').each(function(){
    		$(this).css("color","black");
    	});
    	
    	$(this).css("color","#07B6F5");
    	});

	$('#aboutnav li a').click(function(){
		return false;
	});
	
	$('#aboutnav li:eq(0) a').css("color","#07B6F5");
	
	$('#s4').cycle({
		fx:     'scrollLeft',
		speed:   800,
		timeout: 5000,
		next:   '#s4',
		pause:   1,
		after: afterFunc
	});
	
	function afterFunc (curr, next, opts) {
		var index = opts.currSlide;
		$('#serv1')[index == 0 ? 'show' : 'hide']();
    	$('#serv2')[index == 1 ? 'show' : 'hide']();
    	$('#serv3')[index == 2 ? 'show' : 'hide']();
    	$('#serv4')[index == 3 ? 'show' : 'hide']();
    	$('#serv5')[index == 4 ? 'show' : 'hide']();

	}
	
	
	$("form").submit(function(){
		console.log("Test1");
		var str = $("form").serialize();
		 $.ajax({
		 type: "POST",
		 url: "wp-content/themes/energyVIBE/contactform/contact.php",
		 data: str,
		 success: function(msg){
			$("#note").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						  result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
						  $("#fields").hide();
					}else{
					 console.log("Test2");
						  result = msg;
			  }
		   //$(this).html(result);
		   console.log("Test2");
		   console.log(result);
			  });
			 }});
		   return false;
			});


});

		    
		    