Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array. Returns false if it is not.
{
	//console.log(value);
	var i;
	for (i=0; i < this.length; i++) {
		// Matches identical (===), not just similar (==).
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};
function initialize(element_id) {
    
    // unload previous maps
   // GUnload();
    
    if (GBrowserIsCompatible()) {

        var map     = null;
        var icon    = null;
        var marker  = null;
        var pPoint  = null;
        var center  = null;                        
        var zoom    = null;
                
        switch(element_id){
            case 'plymouth-gmap':
                pPoint = new GPoint(-4.095819,50.421384);
                center = {'lat':50.421384,'lng':-4.095819};                        
                zoom = 16;
            break;
            case 'germany-gmap':
                pPoint = new GPoint(12.132844,51.046642);
                center = {'lat':51.046642,'lng':12.132844};                        
                zoom = 16;
            break;
            case 'france-gmap':
                pPoint = new GPoint(1.901045,47.910281);
                center = {'lat':47.910281,'lng':1.901045};                        
                zoom = 16;
            break;
            case 'india-gmap':
                pPoint = new GPoint(77.250833,28.547222);
                center = {'lat':28.547222,'lng':77.250833};                        
                zoom = 10;
            break;
        }

        icon = new GIcon();
        icon.image = "/images/map-pointer.png";
        icon.iconSize = new GSize(91, 51);
        icon.iconAnchor = new GPoint(45, 51);

        marker = new GMarker(pPoint, icon);

        map = new GMap2(document.getElementById("the-map"));
        map.setCenter(new GLatLng(center.lat,center.lng), zoom);
        map.addControl(new GSmallMapControl());
        map.setMapType(G_NORMAL_MAP);
        map.addOverlay(marker);


    }
}

/*
$(window).load( function() {
    
    
        
    if($('div#site-wrapper.contact').length > 0){

        function initialize(element_id) {
            
          if (GBrowserIsCompatible()) {
              
                var icon = new GIcon();
                
                switch(element_id){
                    case 'plymouth-gmap':
                        var pPoint = new GPoint(-4.095819,50.421384);
                        var center = {'lat':50.421384,'lng':-4.095819};                        
                        var zoom = 16;
                    break;
                    case 'germany-gmap':
                        var pPoint = new GPoint(12.132844,51.046642);
                        var center = {'lat':51.046642,'lng':12.132844};                        
                        var zoom = 16;
                    break;
                    case 'france-gmap':
                        var pPoint = new GPoint(1.901045,47.910281);
                        var center = {'lat':47.910281,'lng':1.901045};                        
                        var zoom = 16;
                    break;
                    case 'india-gmap':
                        var pPoint = new GPoint(77.250833,28.547222);
                        var center = {'lat':28.547222,'lng':77.250833};                        
                        var zoom = 10;
                    break;
                }
                
                var icon = new GIcon();
                icon.image = "/images/map-pointer.png";
                icon.iconSize = new GSize(91, 51);
                icon.iconAnchor = new GPoint(45, 51);

                var marker = new GMarker(pPoint, icon);

                var map = new GMap2(document.getElementById(element_id));
                map.setCenter(new GLatLng(center.lat,center.lng), zoom);
                map.addControl(new GSmallMapControl());
                map.setMapType(G_HYBRID_MAP);
                map.addOverlay(marker);


                }
        }      
    
        // load in this page
        
        //initialize('plymouth-gmap');
        //initialize('germany-gmap');
        //initialize('france-gmap');
        //initialize('india-gmap');
        
    }
});
*/
$(window).unload(function() {
    if($('div#site-wrapper.contact').length > 0){
        GUnload();
    }
});

$(document).ready(function(){
	
	// image preload function
	function preloadImages()
	{
		var imageObject = arguments[0]; // take of the first argurment which is the object
		//alert(arguments[0]);
		$.each(imageObject.imageList, function(key, value) {  		
			jQuery("<img>").attr("src", imageObject.imagePath + value);
		});
	}
	
	// add markup for rounded corners
	if($('.no-borderradius')){
		// for all browsers except ie6
		if(($.browser.msie && parseFloat($.browser.version) > 6) || $.browser.msie == false){
			// ignore old browsers
			$('.rounded').each(function(){
				$(this).prepend('<div class="top"><span class="tl"></span><span class="tr"></span></div><!--[if IE ]><![endif]-->').append('<div class="bottom"><span class="bl"></span><span class="br"></span></div><!--[if IE ]><![endif]-->');
			});
		}
	}
	
	if(jQuery.fn.bgAnimate){
	
		// only browsers taht don't support css transitions
		if($('.no-csstransitions #top-heading nav.nav ul > li a').length > 0){
			$('#top-heading nav.nav ul > li:not(.selected)').bgAnimate({
				outPosition:'0 0',
				overPosition:'-200px 0',
				easingType: 'linear',
				target:'a',
				speedIn: 800,	
				speedOut: 800
			});
		}
	
	}	
	if($('#movie1')){
			
	
		if((navigator.userAgent.match(/iPhone/i)) ||  (navigator.userAgent.match(/iPad/i))) {
			
			$('#showreel').hide();
			$('#movie1').css({'visibility':'visible'});
				
				
			if(jwplayer && Modernizr && jQuery.fn.getLoadModalFlv){
				$('#movie1 a.show-vid').loadModalFlv({
					width:'377px',
					height:'221px',
					skin:'glow_pink'
				}); 
			}
		}			
		else{
		
			if(jwplayer && Modernizr && jQuery.fn.getLoadModalFlv){
				$('#movie1 a.show-vid').loadModalFlv({skin:'glow'}); 
			}
		}
	}
		
	
	// only browsers taht don't support css transitions
	if($('#top-heading #search input.text').length > 0){
		
		var content = $('#additional').hide();
		var duration = 500;
		var easing = 'swing';
		var intTimeout = null;
		var intShowTimeout = null;
		var timeoutDuration = 500;
		
		function showContent(){
			// don't repeat for an already active li
			intShowTimeout = setTimeout(function(){	
			
				if($('#top-heading #search').hasClass('active') == false){
				
					$('#top-heading #search').addClass('animating');
					$('#additional').fadeIn(duration,function() { // the callback
								// Animation complete
								$(this).css('filter','');
								$('#top-heading #search').addClass('active');		
								$('#top-heading #search').removeClass('animating');
						   	});
				}
			},timeoutDuration);
			clearTimeout(intTimeout);
		}
		function hideContent(){		
			
			if($('#top-heading #search').hasClass('active')){
			
				intTimeout = setTimeout(function(){	
					content.fadeOut('slow',function() { // the callback
								//alert('hidden');
								// Animation complete
								$(this).css('filter','');
								$('#top-heading #search').removeClass('active');		
								$('#top-heading #search').removeClass('animating');
						   	});
				},timeoutDuration);
				clearTimeout(intShowTimeout);
			
			}
		}
		
		$('#searchform').mouseover(function(){
			showContent();
		});
		
		$('#main-nav ul li > a').live('mouseover',function(){
			hideContent();
		});		
		
		$('#additional').live('mouseleave',function(){
			hideContent();
		});
		
	}
	
	// home page only
	if(jQuery.fn.cycle){
	
		if($('#home #carousel').length > 0){
			
			// add prev and next animation  for cycle plugin
			$.fn.cycle.transitions.scrollBothWays=function($cont,$slides,opts){$cont.css('overflow','hidden');opts.before.push($.fn.cycle.commonReset);opts.fxFn=function(curr,next,opts,cb,fwd){var w=$cont.width();opts.cssFirst={left:0};opts.animIn={left:0};if(fwd){opts.cssBefore={left:w,top:0};opts.animOut={left:0-w}}else{opts.cssBefore={left:-w,top:0};opts.animOut={left:w}};var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut,animOut=opts.animOut,animIn=opts.animIn;$n.css(opts.cssBefore);var fn=function(){$n.show();$n.animate(animIn,speedIn,easeIn,cb)};$l.animate(animOut,speedOut,easeOut,function(){if(opts.cssAfter)$l.css(opts.cssAfter);if(!opts.sync)fn()});if(opts.sync)fn()}};
								
			function onBefore(incomingSlide, outgoingSlide, options, isForwardNav) { 
			    /*$(outgoingSlide).children('div.overlay').animate({bottom:-80}, {easing: 'easeInCubic'},{duration:100}, function(){$(this).remove();});*/
				$(outgoingSlide).children('h3').animate({opacity:0, 'filter': ''}, {easing: 'swing'},{duration:10});
				$(outgoingSlide).children('p').animate({opacity:0, 'filter': ''}, {easing: 'swing'},{duration:10});
			} 
			function onAfter(incomingSlide, outgoingSlide, options, isForwardNav) { 
				
				$(this).children('h3').animate({opacity:1, 'filter': ''}, {easing: 'swing'},{duration:200});
				$(this).children('p').animate({opacity:1, 'filter': ''}, {easing: 'swing'},{duration:350});
				
			}
			function hideBannerText(){
				$('#home #carousel li').each(function(){
					$(this).children('h3').css({'opacity':0});
					$(this).children('p').css({'opacity':0});
				});
				
			}
			// hide all banner text to initialise
			hideBannerText();
			
			$('#home #carousel').cycle({ 
			    fx:     'scrollBothWays', 
			    timeout: 5000,
			    speed: 800,
			    fit: 1,
			    pause: 1, // enable pause on hover
			    next:   '#prev-next li.next a', 
			    prev:   '#prev-next li.prev a',
			    cleartype: true,
			    cleartypeNoBg: true,  
			    before:  onBefore, 
			    after:   onAfter
			});
		}
	}
	
	//apply form validation
	function jqueryValidate(){
		
		if(jQuery.fn.validate){
			
			//setup default actions for validate plugin
			$.validator.setDefaults({
				submitHandler: function(form) {
					//on submit make sure that any inputs that have the same value as their label then blank the value
					
					//pass form id to local var
					var formId = jQuery(form).attr('id');
					

					//iterate through submit elements
					$('#'+formId+' input[type=text],select,textarea,radio,checkbox').each(function(){
						
						//get current_input 
						var current_input = $(this);
						//get label for current_input 
						var current_label = $('label[for=' + current_input.attr('id') + ']');
						//check that the element is either a text or textarea
						if(current_input.attr('type') == 'text' || current_input.attr('cols')){
							//if label and input the same then blank the value
							if(current_label.text() == current_input.val()){	
								current_input.val('');
							}
						}
					});

					//submit form
					form.submit();
				},
				highlight: function(element, errorClass) {
						$(element).animate({
							opacity: 1.0
						}, 400, function () {
							$(element).css('color','#000000'); // background for invalid data
							$(element).css('background-color','#fff'); // background for invalid data
							$(element).css('border-color','#3db7f8'); // border for invalid data
						});
				},
				unhighlight: function(element, errorClass) {
					$(element).animate({
						opacity: 1.0
					}, 400, function () {
						$(element).css('color','#000000'); // background for invalid data
						$(element).css('background-color','#fff'); // background for valid data
						$(element).css('border-color','#000'); // border for valid data
					});
				}
			});

			if($('#request-a-quote-form').length > 0 ){ // check if element is on page
				
				$("#request-a-quote-form").validate({
					rules: {
						first_name: {  
							required: true,
							notLabelText: true                             
						},
						surname: {  
							required: true,
							notLabelText: true                             
						},
						email: {
							required: true,
							email: true,
							notLabelText: true           
						},
						phone: {  
							required: true,
							notLabelText: true                     
						}
					},
					messages: {
						first_name: "Please enter your first name.",
						surname: "Please enter your surname.",
						email: {
									required: "Please enter your email.",
									email: "Email address is invalid."
								   },
						phone: "Please enter your phone number."
									}

				});
			}
			if($('#newsletter-form').length > 0 ){ // check if element is on page
				$("#newsletter-form").validate({
					rules: {
						news_name: {  
							required: true,
							notLabelText: true                             
						},
						news_email: {
							required: true,
							email: true,
							notLabelText: true           
						}
					},
					messages: {
						news_name: "Please enter your name.",
						news_email: {
									required: "Please enter your email.",
									email: "Email address is invalid."
						}
					}
				});
			}
			
			if($('#faq-form').length > 0 ){ // check if element is on page
				$("#faq-form").validate({
					rules: {
						faq_name: {  
							required: true,
							notLabelText: true                             
						},
						faq_email: {
							required: true,
							email: true,
							notLabelText: true           
						},
						faq_question: {
							required: true,
							notLabelText: true           
						}
					},
					messages: {
						faq_name: "Please enter your name.",
						faq_email: {
									required: "Please enter your email.",
									email: "Email address is invalid."
						},
						faq_question: "Please enter your question."
					}
				});
			}


			if($('#contact-form').length > 0 ){ // check if element is on page
				
				$("#contact-form").validate({
					rules: {
						cf_name: {  
							required: true,
							notLabelText: true                             
						},
						cf_email: {
							required: true,
							email: true,
							notLabelText: true           
						}
					},
					messages: {
						cf_name: "Please enter your name.",
						cf_email: {
									required: "Please enter your email.",
									email: "Email address is invalid."
								   }
							}

				});
			}
		}
	}

	//fire off validation setup
	jqueryValidate();
	
	/*if($('#top-heading nav.nav').length > 0){ // check if element is on page
		
		var parent_ul = $('#top-heading nav.nav > ul');
		
		$('#top-heading nav.nav ul > li').each(function(){
		
			if($(this).children('ul').length > 0){
				
				// assign vars
				var parent_li = $(this);
				var child_ul = $(this).children('ul');
				var child_width = 0;
				
				// set child width by cuumulative value of each child li's width
				child_ul.children('li').each(function(){
					child_width += $(this).width();	
				});
				
				// calculate remaining horizontal space from parent li left position
				horizontal_space = parent_ul.width() - parent_li.position().left;
				
				// if child ul is wider
				if(horizontal_space < child_width){
					
					// calculate left offset
					width_offset = child_width - horizontal_space;
					// reset the child ul left position
					child_ul.css({'left':'-'+width_offset+'px'});
				}				
			}
			// don't run for ie 6		
			if(!($.browser.msie && $.browser.version == 6)){
				// bind mouseover behaviour
				if($(this).hasClass('selected') == false){
					
					var hide;
				
					function hideSelected(){
					
						$('#top-heading nav.nav ul li.selected').addClass('unselected');
						$('#top-heading nav.nav ul li.selected').removeClass('selected');
					}
					
					$(this).hover(function(){
						hide = setTimeout(hideSelected, .5*100);
					},function(){
						clearTimeout(hide);
					});
				}
			}
			
		});
		
		// don't run for ie 6
		if(!($.browser.msie && $.browser.version == 6)){
			var show;
			
			function showSelected(){
				$('#top-heading nav.nav ul li.unselected').addClass('selected');
				$('#top-heading nav.nav ul li.unselected').removeClass('unselected');
			}
			
			$('#top-heading nav.nav ul:first').mouseleave(function(){
				show = setTimeout(showSelected, .5*500);
			});
		}
	}*/
	
	if($('#sliding-panel-nav li a').length > 0){
		
		$sliding_div 	= $('div.sliding-panel-content').css('display','block');

		$sliding_div 	= $('div.sliding-panel-content').css('height',0);

		function slideDown($link,$target){
			
			if(typeof($link)!='undefined'){				
				$link.addClass('animating');
			}
			
			slideUp(null, $('div.shown'));
			
			setTimeout(function(){
				
				$target.stop().animate(
					{ height: 202 }, // what we are animating
					{
						duration: 100, // how fast we are animating
						easing: 'swing', // the type of easing
						complete: function() { // the callback
							// Animation complete.
							if($link!=null){
								$link.parent('li').siblings().children('a.active').removeClass('active');
								$link.removeClass('animating').addClass('active');
							}
							$(this).addClass('shown');
					   	}
				})
			},200);
						
			
		}
		
		function slideUp($link,$target){
			
			if($link!=null){
				$link.addClass('animating');
			}
			
			$target.stop().animate(
					{ height: 0 }, // what we are animating
					{
						duration: 300, // how fast we are animating
						easing: 'swing', // the type of easing
						complete: function() { // the callback
							// Animation complete.
							if($link!=null){					
								$link.removeClass('active');
								$link.removeClass('animating')
							}
							$(this).removeClass('shown');
					   	}
			});
		}
	
		$('#sliding-panel-nav li a').each (function(){ 
			
			var $link = $(this);
			var $target = $($link.attr('href'));
			// bind click behaviour to contact link
			$link.bind('click', function(){
		
				if($link.hasClass('active')){
					// slide up if active
					slideUp($link,$target);			
				}else{
					// slide down
					slideDown($link,$target);
				}
			
				return false;
			});
		});
				
	}
	
	var $div = $('<div>').attr('id','banner-nav');
	$div.append ($('<a>').attr('id','prev').text('Previous'));
	$div.append ($('<a>').attr('id','next').text('Next'));
	$div.append ($('<a>').attr('id','pause').text('Pause'));


    if($('#banner .col-1 ul').length > 0){
		$('#banner .col-1 ul').before($div).cycle({ 
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			speed: 200,
			timeout: 5000,
			next: '#next',
			prev: '#prev'
		});
	}
	
	$('#pause').toggle(function() {
    	$('#banner .col-1 ul').cycle('pause');
    	// $(this).attr({ class: 'paused'});
    	$(this).addClass('paused');
	}, function() {
	  	$('#banner .col-1 ul').cycle('resume');
    	// $(this).attr({ class: 'play'});
    	$(this).addClass('play');
    }); 
	
		                       
	if(jQuery.fn.inputfocus){
		if($('#newsletter .input').length > 0){
                        
                        if(jQuery.browser.msie){                            
                            $('#newsletter .input').inputfocus({
                                    bgColourFocus:'#ffffff',
                                    bgColour:'#f7f7f7',			
                                    animate:false
                            });
                        }else{                            
                            $('#newsletter .input').inputfocus({
                                    bgColourFocus:'#ffffff',
                                    bgColour:'#f7f7f7',			
                                    animate:true
                            });
                            
                        }
		}
		if($('#request-a-quote-form .input').length > 0){
                    if(jQuery.browser.msie){ 
			$('#sliding-panel .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#f7f7f7',			
				animate:false
			});
                    }else{
			$('#sliding-panel .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#f7f7f7',			
				animate:true
			});                        
                    }
		}
		if($('.form-container .input').length > 0){
                    if(jQuery.browser.msie){ 
			$('.form-container .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:false
			});
                    }else{ 
			$('.form-container .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:true
			});                        
                    }
		}
		if($('#request-a-quote-form .input').length > 0){
                    if(jQuery.browser.msie){
			$('#request-a-quote-form .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:false
			});
                    }else{
			$('#request-a-quote-form .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:true
			});                        
          }
		}
		if($('#search-form .input').length > 0){
   			$('#search-form .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:false
			});                        
		}
		if($('#faq-form .input').length > 0){
                    if(jQuery.browser.msie){
			$('#faq-form .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:false
			});
                    }else{
			$('#faq-form .input').inputfocus({
				bgColourFocus:'#fff',
				bgColour:'#fff',		
				animate:true
			});                        
                    }
		}
	}   
	
	
	if($('#quote-form-container #trigger').length > 0){
	
		var $link = $('#quote-form-container #trigger');
		var $target1 = $('#quote-form-slider');
		
		function slideLeft(){
			
			$link.addClass('animating');
			$('body').addClass('fade');
			
			$target1.stop().animate(
					{ right: 0 }, // what we are animating
					{
						duration: 100, // how fast we are animating
						easing: 'swing', // the type of easing
						complete: function() { // the callback
							// Animation complete.
							$link.removeClass('animating').addClass('active');
							$('#header-outer-wrapper #main-nav ul li').css({'z-index': '9998'});
							$('#fade').bind('click', function() {
								$link.trigger('click');
							});
					   	}
				});
				
		}
		
		function slideRight(){
			
			$('#request-callback a').addClass('animating');
			
			$target1.stop().animate(
					{ right: -863 }, // what we are animating
					{
						duration: 300, // how fast we are animating
						easing: 'swing', // the type of easing
						complete: function() { // the callback
							// Animation complete.						
							$link.removeClass('active');
							$link.removeClass('animating');
							$('body').removeClass('fade');
							$('#header-outer-wrapper #main-nav ul li').css({'z-index': '10001'});
					   	}
			});
		}
		
		// bind click behaviour to contact link
		$link.bind('click', function(){
		
			if($(this).hasClass('active')){
				// slide up if active
				slideRight();			
			}else{
				// slide down
				slideLeft();
			}
			
			return false;
		});
		
	}
	
	//$("#main-nav li.sub").hover(function () {
    //	$("body").addClass("fade");
  	//}, function () {
  	//	$("body").removeClass("fade");
  	//});
			
	$('#applications-block ul li a').showhide({
		animate:false,
		event:'mouseover',
		autoScroll: true,
		autoScrollTimeout:5000,
		wrapper:'#applications-block',
                linkOpacity:null,
                selectedLinkOpacity:null
	});			
	
	$('#materials-block ul li a').showhide({
		animate:false,
		event:'mouseover',
		autoScroll: true,
		autoScrollTimeout:5000,
		wrapper:'#materials-block',
                linkOpacity:null,
                selectedLinkOpacity:null
	});	
	
	
    if($('#content-carousel ul').length > 0){
		$('#content-carousel ul').cycle({ 
			fx: 'fade', 
			timeout: 5000,
			speed: 800,
			fit: 1,
			pause: 1, // enable pause on hover
			cleartype: true,
			cleartypeNoBg: true  
		});
	}
	
	// show hide panes on Quality page
	$('#quality_showhide_buttons a').showhide({
			animate:false,
			event:'mouseover',
			autoScroll: true,
			autoScrollTimeout:5000,
			linkOpacity: '1',
			wrapper:'#quality_showhide_buttons',
                        linkOpacity:null,
                        selectedLinkOpacity:null
	});	

	$('#contact_showhide_buttons a').showhide({
			animate:false,
			event:'click',
			autoScroll: true,
			autoScrollTimeout:5000,
			linkOpacity: '1',
			wrapper:'#contact_showhide_buttons',
                        linkOpacity:null,
                        selectedLinkOpacity:null
	});						
        
        $('#contact_showhide_buttons a').each(function(){
            if($(this).attr('class').length > 0){
                $(this).bind('mouseup', function(){
                    initialize($(this).attr('class')); // load in google map based on class name on mouseup
                });
            }
            
            // onload initialise first link map
            index = $('#contact_showhide_buttons a').index($(this));
            if(index == 0){
                initialize($(this).attr('class')); // load in google map based on class name on mouseup
            }
            
        });
        
	$('#team_showhide_buttons a').showhide({
			animate:false,
			event:'click',
			autoScroll: true,
			autoScrollTimeout:5000,
			linkOpacity: '1',
			wrapper:'#team_showhide_buttons',
                        linkOpacity:null,
                        selectedLinkOpacity:null
	});								

	$('#grades_showhide_buttons a').showhide({
			animate:false,
			event:'click',
			autoScroll: true,
			autoScrollTimeout:5000,
			linkOpacity: '1',
			wrapper:'#grades_showhide_buttons',
                        linkOpacity:null,
                        selectedLinkOpacity:null
	});	
	
	$('#material_showhide_buttons a').showhide({
			animate:false,
			event:'click',
			autoScroll: true,
			autoScrollTimeout:5000,
			linkOpacity: '1',
			wrapper:'#material_showhide_buttons',
                        linkOpacity:null,
                        selectedLinkOpacity:null
	});	
		
	$('#industry_showhide_buttons a').showhide({
			animate:false,
			event:'click',
			autoScroll: true,
			autoScrollTimeout:5000,
			linkOpacity: '1',
			wrapper:'#industry_showhide_buttons',
                        linkOpacity:null,
                        selectedLinkOpacity:null
	});	
		
	/* $('.client_list li').mouseover(function(){
		$(this).children('span').stop().animate({"top": "-153px"}, "fast");
	})
	
	$('.client_list li').mouseout(function(){
		$(this).children('span').stop().animate({"top": "+153px"}, "fast");
	}) */


    if($('#timeline-carousel').length > 0){
    	$('#timeline-carousel').jcarousel({
    		wrap: 'circular',
    		scroll: 1
    	});
	}
	
	if($('ul#roundabout').length > 0){
		$('ul#roundabout').roundabout({
			btnNext: '#next',
   			btnPrev: '#previous',
   			reflect: 'true',
   			minScale: '0.1',
   			maxScale: '1.0',
   			minOpacity: '0.1',
   			maxOpacity: '1.0'
      });
	}
	if($('#accordion').length > 0){
		$('#accordion').accordion();
	}
	
	if($('#show-all').length > 0){
		$('#show-all').click(function() {
			$('#faq-accordion li h2').addClass('active')
			$('.faq-answer').css({'display': 'block'}); 
 			return false;
		});		
	}
	
	if($('#hide-all').length > 0){
		$('#hide-all').click(function() {
			$('#faq-accordion li h2').removeClass('active')
			$('.faq-answer').css({'display': 'none'}); 
 			return false;
		});		
	}
			
	if($('#faq-accordion').length > 0){
		$('#faq-accordion li .faq-answer').css({'display': 'none'});
		$('#faq-accordion li h2').click(function() {
			if($(this).hasClass('active')){
				$(this).removeClass('active')
	 			$(this).next('.faq-answer').css({'display': 'none'}); 
 			}else{
				$(this).addClass('active')
 	 			$(this).next('.faq-answer').css({'display': 'block'}); 
 	 		}
			return false;
		});
	}
	
	// use hassh tag
	       
	var hash = 'li#' + (window.location.hash.substring(1));       

	if (window.location.hash.substring(1)) {
	    $('#faq-accordion').find(hash).each(function(){
//  	      $(this).children('h2').append(window.location.hash.substring(1));
       		$(this).children('h2').trigger('click').trigger('mouseup');
    	});
    }
    
    if (window.location.hash.substring(1)) {
	    $('#grades_showhide_buttons').find(hash).each(function(){
//  	      $(this).children('h2').append(window.location.hash.substring(1));
       		$(this).children('a').trigger('click').trigger('mouseup');
    	});
    }
   
	
	if($('#attribute_type').length > 0){
	
		$('.grades-attribute-form').hide();
		
		$("#attribute_type").change(function(){
			$('.grades-attribute-form').hide();
			$("#" + this.value).show();
		});
		
		$("#attribute_type").change();
	}
	
	$('#print-link').prepend('<a href="#" id="print-results">Print results</a>');
 	$('#print-link a').click(function() {
  		window.print();
  		return false;
 	});
 	
 	if($('.content img').length > 0){
       $('.content img[style*=right]').addClass('alignright');
       $('.content img[style*=left]').addClass('alignleft');
    }
 	
 	$('#material').change(function() {
	    var options = '';
	    if($(this).val() == 'Stainless steel') {
	        options = '<option value="">Grade</option><option value="304/304L">304 / 304L</option><option value="310">310</option><option value="316/316L">316 / 316L</option><option value="316LN">316LN</option><option value="316Ti">316Ti</option><option value="317L">317L</option><option value="321">321</option><option value="347">347</option><option value="254SMo">254SMo (6 Mo)</option><option value="21-6-9 (Nitronic 40)">21-6-9 (Nitronic 40)</option><option value="22-13-5 (Nitronic 50)">22-13-5 (Nitronic 50)</option><option value="446">446</option><option value="17-4PH">17-4PH</option><option value="FV 607">FV 607</option><option value="904L">904L</option>';
	    }
	    else if ($(this).val() == 'Duplex Stainless Steel'){
	        options = '<option value="">Grade</option><option value="UNS S31803">UNS S31803 (Lean Duplex)</option><option value="UNS S32750 (Duplex)">UNS S32750 (Duplex)</option><option value="UNS S32760 (Super Duplex)">UNS S32760 (Super Duplex)</option>';
	    }
	    else if ($(this).val() == 'Nickel'){
	        options = '<option value="">Grade</option><option value="200/201">200 / 201</option><option value="C22">Alloy C22</option><option value="31">Alloy 31</option><option value="59">Alloy 59</option><option value="75">Alloy 75</option><option value="263">Alloy 263</option><option value="C276">Alloy C276</option><option value="400">Alloy 400</option><option value="600">Alloy 600</option><option value="625">Alloy 625</option><option value="690">Alloy 690</option><option value="800/H/HT">Alloy 800/H/HT</option><option value="825">Alloy 825</option><option value="718">Alloy 718</option><option value="MP35N">Alloy MP35N</option>';
	    }
	    else if ($(this).val() == 'Titanium'){
	        options = '<option value="">Grade</option><option value="Ti CP (Grade 1)">Ti CP (Grade 1)</option><option value="Ti CP (Grade 2)">Ti CP (Grade 2)</option><option value="Ti 3Al/2.5V (Grade 9)">Ti 3Al/2.5V (Grade 9)</option><option value="Ti 6Al/4V (Grade 5)">Ti 6Al/4V (Grade 5)</option><option value="Ti 5Al/4V">Ti 5Al/4V</option><option value="Ti 4Al/2.5V">Ti 4Al/2.5V</option>';
	    }
	    else if ($(this).val() == 'Zirconium'){
	        options = '<option value="">Grade</option><option value="UNS R60702">Zircaloy 702</option><option value="UNS R60704">Zircaloy 704</option>';
	    }
		
	    $('#grade').html(options);
	    
	});
	 
 	if($('#how_hear').length > 0){
 		$('#search-term-container').addClass('hide');
		$('#how_hear').change(function() {
	    	if($(this).val() == 'Internet search') {
	   	 		$('#search-term-container').removeClass('hide');
	   		} else {
	   	 		$('#search-term-container').addClass('hide');	   			
	   		}
		});
 	}
	 
	if($('.applications #main #main-center-panel .col-1 .products_list li').length > 0){
       $('.applications #main #main-center-panel .col-1 .products_list li:nth-child(2n)').addClass('second');
    }
	if($('.tech-ref #main #main-center-panel .col-1 .products_list li').length > 0){
       $('.tech-ref #main #main-center-panel .col-1 .products_list li:nth-child(2n)').addClass('second');
    }
         
	 
		
});

// callback function defined by google
//function googleTranslateElementInit() {
//        new google.translate.TranslateElement({
//            pageLanguage: 'en'
//        }, 'google_translate_element');
//}

// using yepnope to asynchronously load in googe translate
//yepnope([{
//  // Load google translate from a 3rd party CDN
//  load: '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'
//}]);
