function navhover() {
$('.navigation > li.contactus').children('ul').css({'display': 'none'});

   $(".navigation > li").hover(function() {
      $(this).addClass('active');
      $(this).children("ul").animate({opacity: "show"}, 200);
   }, function() {
      $(this).removeClass('active');
      $(this).children("ul").animate({opacity: "hide"}, 75);
   });
}

$(document).ready(function(){
   navhover();
   if ($('body').is('#executiveprofiles')) {
      initializeexecutiveprofiles();
      executiveprofilesinteraction();
   } //ifexecutiveprofiles
   if ($('body').is('#communityservice')) {
      affiliatescroller();
   } //if communityserviceoraffiliations
   if ($('body').is('#affiliations')) {
      affiliatescroller();
   } //if communityserviceoraffiliations
   if ($('body').is('#scottsdalespotlight')) {
      initializescottsdalespotlight();
   } //if scottsdalespotlight
   if ($('body').is('#ourcommitment')) {
      initializeleedcycle();
   } //if scottsdalespotlight
});



function initializeleedcycle() {

$('.leedcertified').css({'display': 'none'});

$('.newspaper').before('<ul class="leedcycle"></ul>');
$('ul.leedcertified').children('li').each(function () {
   $(this).appendTo('.leedcycle');
}); //each leed

oldleednumber = 100;
howmanyarethere3 = $('.leedcycle').children('li').index($('.leedcycle').children('li:last-child'))+1;
showarandomleed(howmanyarethere3)

         setTimeout( function () {
            randomcharityloop = setInterval (function(){
               showarandomleed(howmanyarethere3);
            }, 2500); //randomcharityloop
         }, 500 );


}; //initializeleedcycle

function showarandomleed(howmanyarethere2) {
   var randomnumber3=Math.floor(Math.random()*howmanyarethere2)
//$('body').append(randomnumber3 + " / " + oldleednumber + "<br />");
   if (randomnumber3 == oldleednumber) {
//   alert("OH NOES! CHARITIES THE SAME");
      showarandomleed(howmanyarethere3);
   } else {
      $('ul.leedcycle').children('li').css({'display': 'none'});
      $('ul.leedcycle').children('li').eq(randomnumber3).css({'display': 'block'})
      oldleednumber = randomnumber3;
   }
}; //showarandomproject



function initializeexecutiveprofiles() {
$('.contentslider').wrap('<div class="slidercontainer"></div>')
$('.slidercontainer').before('<div class="slidernav"></div>')
   $('.contentslider').children('.section').each(function() {
      thesrc = $(this).children('img').attr('src');
      newsrc = thesrc.match(/[^\.]+/)+"2.jpg";
      $(this).children('img').clone().appendTo('.slidernav');
      $(this).children('img').attr({'src': newsrc});
   }); //each section
$('.slidernav').children('img').css({'opacity': '0.5'});
$('.slidernav').children('img').eq(0).css({'opacity': '1'}).addClass('active');
}; //initializeexecutiveprofiles


function executiveprofilesinteraction() {

$('.slidernav').children('img').not('.active').hover(function() {
$(this).css({'opacity': '1'}).siblings().not('.active').css({'opacity': '0.5'});
}, function() {
$(this).css({'opacity': '.5'});
}); //hover
$('.slidernav').children('img').click(function() {
$(this).siblings().css({'opacity': '0.5'}).removeClass('active');
$(this).css({'opacity': '1'}).addClass('active');
whichdidiclick = $('.slidernav').children('img').index(this);
$('.contentslider').animate({'left': -$('.contentslider').children('.section').eq(whichdidiclick).position().left}, {duration: 500, easing: 'easeInOutCirc'});
}); //click slidernav
}; //executiveprofilesinteraction



function affiliatescroller() {
$('.logocolumn').before('<div class="logocycle"></div>');
$('div.logocolumn').children('div.par-img').children('a').each(function() {
$(this).appendTo('.logocycle');
}); //each a

   if ($('body').is('#communityservice')) {
      showarandomimage();
      thehomepageloop = setInterval (function(){
         showarandomimage();
      }, 2500); //thehomepageloop
   } //if

   if ($('body').is('#affiliations')) {
      showarandomimage2();
      thehomepageloop = setInterval (function(){
         showarandomimage2();
      }, 2500); //thehomepageloop
   } //if

}; //affiliatescroller


function showarandomimage() {
      var imgArray = ['0','1','2','3','4','5','6','7','8','9','10','11','12'];
      function ranNum(){ return Math.floor(Math.random()*imgArray.length); }
      var ranNum = ranNum();
      $('.logocycle').children('a').css({'display': 'none'});
      $('.logocycle').children('a').eq(ranNum).css({'display': 'block'});
}; //showarandomimage

function showarandomimage2() {
      var imgArray = ['0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17'];
      function ranNum(){ return Math.floor(Math.random()*imgArray.length); }
      var ranNum = ranNum();
      $('.logocycle').children('a').css({'display': 'none'});
      $('.logocycle').children('a').eq(ranNum).css({'display': 'block'});
}; //showarandomimage




function initializescottsdalespotlight() {

	$.ajax({
		type: "GET",
		url: "/ourcompany/scottsdale_image_slideshow.xml",
		dataType: "xml",
		success: function(xml) {
   		$('#big-description h1').after('<ul class="projectcycle"></ul>');
   		$(xml).children('images').children('image').each(function(i) {
      		$('.projectcycle').append('<li><a href="/project/index.php?p='+$(this).attr('id')+'"><img src="'+$(this).children('url').attr('src')+'" alt="project image" /></a></li>');
   		}); //each child


oldprojectnumber = 100;
oldcharitynumber = 100;

      	howmanyarethere = $(xml).children('images').children('image').index($(xml).children('images:').children('image:last-child'))+1;
      
      	showarandomproject(howmanyarethere)
         randomprojectloop = setInterval (function(){
            showarandomproject(howmanyarethere);
         }, 2500); //randomprojectloop

$('.wesupport').css({'display': 'none'});

$('.projectcycle').before('<ul class="charitycycle"></ul>');
$('ul.charitiessupported').children('li').each(function () {
$(this).appendTo('.charitycycle');
}); //each charity supported

howmanyarethere2 = $('.charitycycle').children('li').index($('.charitycycle').children('li:last-child'))+1;
showarandomcharity(howmanyarethere2)

            randomcharityloop = setInterval (function(){
               showarandomcharity(howmanyarethere2);
            }, 2500); //randomcharityloop

		} //success
	}); //ajax

}; //initializescottsdalespotlight





function showarandomproject(howmanyarethere) {
   var randomnumber=Math.floor(Math.random()*howmanyarethere)
   if (randomnumber == oldprojectnumber) {
//   alert("OH NOES! PROJECTS THE SAME");
//      showarandomproject(howmanyarethere)
   } else {
      $('ul.projectcycle').children('li').css({'display': 'none'});
      $('ul.projectcycle').children('li').eq(randomnumber).css({'display': 'block'})
      oldprojectnumber = randomnumber;
   }
}; //showarandomproject

function showarandomcharity(howmanyarethere2) {
   var randomnumber2=Math.floor(Math.random()*howmanyarethere2)
   if (randomnumber2 == oldcharitynumber) {
//   alert("OH NOES! CHARITIES THE SAME");
      showarandomcharity(howmanyarethere2);
   } else {
      $('ul.charitycycle').children('li').css({'display': 'none'});
      $('ul.charitycycle').children('li').eq(randomnumber2).css({'display': 'block'})
      oldcharitynumber = randomnumber2;
   }
}; //showarandomproject





























