var c30site = {
	absUri : ''
};

if(Drupal.jsEnabled) {
  $(document).ready(function() {
	  	
	  	//flash embed
		$('#flash_holder_home').flash({ 
			src: c30site.absUri + '/sites/all/themes/CarouselTHIRTY/flash/na-homepage.swf',
			width: '100%',
			height: '424',
			wmode: 'transparent',
			scale: 'noscale'
		},
		{
			version: 8
		});

		$('#flash_holder_contact').flash({ 
			src: c30site.absUri + '/sites/all/themes/CarouselTHIRTY/flash/na-contactmap.swf',
			width: '100%',
			height: '172',
			wmode: 'transparent',
			scale: 'noscale'
		},
		{
			version: 8
		});
		
		$('#flash_holder_company').flash({ 
			src: c30site.absUri + '/sites/all/themes/CarouselTHIRTY/flash/na-companytimeline.swf',
			width: '100%',
			height: '338',
			wmode: 'transparent',
			scale: 'noscale'
		},
		{
			version: 8
		});
		
		$('#flash_holder_project').flash({ 
			src: c30site.absUri + '/sites/all/themes/CarouselTHIRTY/flash/project-map.swf',
			width: '100%',
			height: '424',
			wmode: 'transparent',
			scale: 'noscale'
		},
		{
			version: 8
		});
		
		//accordion
		$("#accordion").accordion({
			collapsible: true,
			icons: {
    			header: "ui-icon-circle-arrow-e",
   				headerSelected: "ui-icon-circle-arrow-s"
			}
		});
		
		$('.accordion').each(function(i){
			$(this).next().addClass('answer');
			$(this).click(function(){
				$(this).next().toggle('slow');
				$(this).toggleClass('minus');
			});
		});
		
		//Carousel
		$('.carousel').jcarousel({
			visible			: 1,
			scroll 			: 1,
			wrap 			: 'both',
			buttonNextHTML 	: 	'<a class="next">More</a>'
			//buttonPrevHTML	:	'<a class="prev">prev</a>',
		});
		
		$("#case_study .carousel").jcarousel({
			auto:3.5,
			wrap:'both',
			initCallback: mycarousel_initCallback,
			buttonNextHTML 	: 	'<a class="next"></a>',
			buttonPrevHTML	:	'<a class="prev"></a>',
			visible			: 1,
			scroll 			: 1
		});
		
		//Drop-Down Script
		$("#nav ul li").hover(
		      function () {
		    	  $(this).children("ul").css("display","block");
		      }, 
		      function () {
		    	  $(this).children("ul").css("display","none");
		      }
	    );
		
		//gets the value of any input and removes it on focus and replaces it on blur if nothing is entered
		$('#search-text').focus(function(){
		        var defaultText = $(this).val();
		        $(this).val('');
		
		        $("input").blur( function () {
		        var userInput = $(this).val();
		
		                if (userInput == ''){
		                        $(this).val(defaultText);
		                }
		        });
		
		});
		
		//adds "forgot password" link
		$("#user-login #edit-pass-wrapper .description").html("The password field is case sensitive.</ br> <a href=\""+ c30site.absUri +"/user/password\">Forgot your password? Click here.</a>");	

  });
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};