var numberOfSlides=0;
var current=0;


$(document).ready(function(){

   // initial setup
   $("#contactForm").hide();
   $("#email").hide();
   $(':radio[value="phone"]').attr("checked", true);

   $("#name").val("name");
   $("#phone").val("phone");
   $("#email").val("email");
   $("#emailaddress").html("<a href='mailto:info@neweralighting.ie'>info@neweralighting.ie</a>");
   
 // quick css fix for webkit
    if ($.browser.safari) {
   $("#menu ul").addClass("webkitMenuFix");
   $("#contactButton").addClass("webkitMenuFix");

 }

   // click functions
   $("#contactButton").click(function(event){
                                              $("#contactForm").toggle("slow");
                                               });
   $("#submit").click(function(event){
                                              $("#contactForm").toggle("slow");
                                               });
   $("#cancel").click(function(event){
                                              $("#contactForm").toggle("slow");
                                               });
   $("#name").click(function(event){
                                              $("#name").val("");
                                               });
   $("#email").click(function(event){
                                              $("#email").val("");
                                               })
   $("#phone").click(function(event){
                                              $("#phone").val("");
                                               })
$("input:radio").change(function()
                                  {
                                  $("#email").toggle("slow");
                                  $("#phone").toggle("slow");
                                  }
                                  );
                                  
                                  
                                  

// carousel
   


$("div.slide").each(function(){

		numberOfSlides++;
});

var starter=Math.floor(Math.random()*numberOfSlides);
current=starter;

iterate();



function iterate(){
		current++;
		if(current==numberOfSlides)current=0;
		refreshDisplay();
		 
		}

function refreshDisplay(){
		var j=0;		
		$("div.slide").each(function(){

		if(j==current)
			{
			$(this).show();
			}
		else $(this).hide();

		j++;
		});
	}


setInterval("current++;	if(current==numberOfSlides)current=0;	var j=0;	$('div.slide').each(function(){	if(j==current)	{	$(this).css('z-index',1);	$(this).fadeIn('slow');	}		else {	$(this).css('z-index',0);	$(this).fadeOut('slow');}	j++;});",7000);


// workflow animation
   $(".bubbleDetail").hide();
   $(".bubble").hover(
                      function(){ 
                                 $(this).toggleClass("bubbleLit");

                                 $(this).next().toggleClass("open");
                                 $(".open").toggleClass("bubbleDetail");
                                 $(".bubbleDetail").slideUp("slow");
                                 $(".open").slideToggle("slow");
                                 $(".open").toggleClass("bubbleDetail");

                                 $(".open").toggleClass("open");
                      }
                      ,
                      function(){
                                 $(this).toggleClass("bubbleLit");
                                 //$(this).next().toggle("slow");
                      }
                      );
//mockup room
     $(".demo").each(function(){$(this).hide();});

if (!$.browser.msie) {
     $("#flood").hover(function(){
                                $('#mockupRoom').fadeOut('fast');
                                $('#floodlight').fadeIn('slow');
                                }
                                ,
                      function(){
                                $('#mockupRoom').fadeIn('fast');
                                $('#floodlight').fadeOut('slow');
                                }
                                );

    $("#spot").hover(function(){
                                $('#mockupRoom').fadeOut('fast');
                                $('#accent').fadeIn('slow');
                                }
                                ,
                      function(){
                                $('#mockupRoom').fadeIn('fast');
                                $('#accent').fadeOut('slow');
                                }
                                );

    $("#down").hover(function(){
                                $('#mockupRoom').fadeOut('fast');
                                $('#downlights').fadeIn('slow');
                                }
                                ,
                      function(){
                                $('#mockupRoom').fadeIn('fast');
                                $('#downlights').fadeOut('slow');
                                }
                                );
     
    $("#inground").hover(function(){
                                $('#mockupRoom').fadeOut('fast');
                                $('#grazing').fadeIn('slow');
                                }
                                ,
                      function(){
                                $('#mockupRoom').fadeIn('fast');
                                $('#grazing').fadeOut('slow');
                                }
                                );
}
     
     $("#radioflood").click(function(){
                                $(".demo").each(function(){$(this).fadeOut('slow');});
                                $('#mockupRoom').fadeOut('fast');
                                $('#floodlight').fadeIn('slow');
                                }

                                );

    $("#radiospot").click(function(){
                                $(".demo").each(function(){$(this).fadeOut('slow');});
                                $('#mockupRoom').fadeOut('fast');
                                $('#accent').fadeIn('slow');
                                }
                                );

    $("#radiodown").click(function(){
                                $(".demo").each(function(){$(this).fadeOut('slow');});
                                $('#mockupRoom').fadeOut('fast');
                                $('#downlights').fadeIn('slow');
                                }
                                );
     
    $("#radioinground").click(function(){
                                $(".demo").each(function(){$(this).fadeOut('slow');});
                                $('#mockupRoom').fadeOut('fast');
                                $('#grazing').fadeIn('slow');
                                }
                                );
    $("#lightsoff").click(function(){
                                $(".demo").each(function(){$(this).fadeOut('slow');});
                                $('#mockupRoom').fadeIn('fast');
                                }
                                );

// fisheye menu
	$(document).ready(
		function()
		{
			$('#fisheye').Fisheye(
				{
					maxWidth: 80,
					items: 'a',
					itemsText: 'span',
					container: '.fisheyeContainer',
					itemWidth: 75,
					proximity: 80,
					alignment : 'left',
					valign: 'bottom',
					halign : 'center'
				}
			)
		}
	);




 });


