//jQuery
$(document).ready(function(){
						   
					   
	$('.top_nav').hover(function(){
	var temp=$(this).attr('src')
	temp=temp.replace('-off.gif', '-over.gif');
	$(this).attr('src', temp);
	}, 
	function() {
	var temp=$(this).attr('src')
	temp=temp.replace('-over.gif', '-off.gif');
	$(this).attr('src', temp);
	});
	

$("#nav_top_company").click(function(){
if ($("#top_nav_items_company").is(":visible")) {
$("#top_nav_items_company").slideUp();
} else {
$(".top_nav_items").hide();
//$("#top_nav_items_services").hide();
//$("#top_nav_items_renewable_energy").hide();
//$("#top_nav_items_news").hide();
//$("#top_nav_items_faq").hide();
//$("#top_nav_items_contact").hide();
$("#top_nav_items_company").slideDown();
}
});

$("#nav_top_services").click(function(){
if ($("#top_nav_items_services").is(":visible")) {
$("#top_nav_items_services").slideUp();
} else {
$(".top_nav_items").hide();
$("#top_nav_items_services").slideDown();
}
});

$("#nav_top_renewable_energy").click(function(){
if ($("#top_nav_items_renewable_energy").is(":visible")) {
$("#top_nav_items_renewable_energy").slideUp();
} else {
$(".top_nav_items").hide();
$("#top_nav_items_renewable_energy").slideDown();
}
});

$("#nav_top_news").click(function(){
if ($("#top_nav_items_news").is(":visible")) {
$("#top_nav_items_news").slideUp();
} else {
$(".top_nav_items").hide();
$("#top_nav_items_news").slideDown();
}
});

$("#nav_top_faq").click(function(){
if ($("#top_nav_items_faq").is(":visible")) {
$("#top_nav_items_faq").slideUp();
} else {
$(".top_nav_items").hide();
$("#top_nav_items_faq").slideDown();
}
});

$("#nav_top_contact").click(function(){
if ($("#top_nav_items_contact").is(":visible")) {
$("#top_nav_items_contact").slideUp();
} else {
$(".top_nav_items").hide();
$("#top_nav_items_contact").slideDown();
}
});

	
var tab_on=0;	
$('.item_tab').click(function() {
var index=$('.item_tab').index(this);
tab_on=index;
for (var i=0; i<$('.item_tab').length ;i++) {
var t=$('.item_tab:eq(' + i + ')').attr('src');
if (i==index) {
t=t.replace('_down.gif', '_up.gif');
$('.item_tab:eq(' + i + ')').attr('src', t);
$('.tab_container:eq(' + i + ')').fadeIn(300);
} else {
t=t.replace('_up.gif', '_down.gif');
$('.item_tab:eq(' + i + ')').attr('src', t);
$('.tab_container:eq(' + i + ')').hide();
}
}
return false;
});

var tab_org;
$('.item_tab').hover(function(){
var temp=$(this).attr('src');
tab_org=temp;
temp=temp.replace('_down.gif', '_up.gif');
$(this).attr('src', temp);
}, 
function() {
if ($('.item_tab').index(this)!=tab_on) {
$(this).attr('src', tab_org);		
}

});
/* */


$(".faq_q").click(function(){
//$(".faq_a:eq(" + vindex + ")").slideToggle();
var vindex=$(".faq_q").index(this);
if ($(".faq_a:eq(" + vindex + ")").is(":visible")) {
	$(".faq_a:eq(" + vindex + ")").slideUp();
$(this).css({'color': '#000000'});	
$(".faq_arrow:eq(" + vindex + ")").attr("src", "/images/FAQ_blue_arrow.gif");
} else {
$(".faq_a:eq(" + vindex + ")").slideDown();	
$(this).css({'color': '#000000'});	
$(".faq_arrow:eq(" + vindex + ")").attr("src", "/images/FAQ_grey_arrow.gif");
}



});


$("#enews_email").click(function(){
		$("input#enews_email").val("");						 
});

$("#signup_submit").click(function(event){
var email=$("input#enews_email").val();
if (email!="") {
var dataString = 'contact_email=' + email; // + '&phone=' + phone;   
//alert (dataString);return false;   


$.ajax({   
  type: "POST",   
  cache: false,
  url: "/contact/contact_newsletter.aspx",   
  data: dataString,  
  success: function(xml) { 
	$(xml).find('message').each(function(){
	var msg = $(this).attr('id');
	if (msg=='failed') {
	$("input#enews_email").val("Error. Please try again");
	}else{
	$("input#enews_email").val("Thank You!");	
	$('#signup_form').html("<div id='message'><p>Thank You!</p></div>");
	}
	});
  
  }   
});
}
return false;
});


		
}); // end ready


function slideSwitch() {
    var $active = $('#slideshow div.active');

    if ( $active.length == 0 ) $active = $('#slideshow div:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow div:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 7000 );
});


