
function propergateformfeild(idname,valuetext){

	values = jQuery(idname).attr('value');

	if(values != valuetext && values == ''){

		jQuery(idname).attr('value',valuetext);

		jQuery(idname).click(function(){
			current_value = jQuery(idname).attr('value');

			if(current_value == valuetext && values == ''){

				jQuery(idname).attr('value','');

			}

		});


		jQuery(idname).blur(function(){
			current_value = jQuery(idname).attr('value');

			if(current_value == ''){

				jQuery(idname).attr('value',valuetext);

			}

		});

	}

}






	jQuery(document).ready(function(){

		
		jQuery('#enquiry-right p textarea').css('resize', 'none');

		jQuery('#enquiry-embed input').click(function(){
			
			input = jQuery(this);


			if(input.hasClass('employee_individual')){

				jQuery('#current_employer').fadeIn();

			}else if(input.hasClass('employer')){

				jQuery('#current_employer').fadeOut();	

			}


		});


		jQuery('#slides').cycle({
			fx:			'fade',
			speed:		1000,
			timeout:	15000,
			pager:		'#slide_nav'
		});


	    jQuery('.case_studies_slide').each(function(index) {
	        jQuery(this).cycle({
				fx:     'fade',
				timeout: 0,
				speed:   400,
				sync:    false,
				slideExpr:	'div.slide',
				pager:  '#case_study_nav',
				pagerAnchorBuilder: function(i) {
					if (index == 0)
						// for first slideshow, return a new anchro
						return '<a href="#">'+(i+1)+'</a>';
					// for 2nd slideshow, select the anchor created previously
					return '#case_study_nav a:eq('+i+')';
	        	}
			});
	    });


		var isVisible = 0;

		jQuery('.accessibility_dropdown .textsize_options a').eq(1).css({
																		'border' : '0',
																		'margin' : '0',
																		'padding' : '0'
																		});
		jQuery('.accessibility_dropdown').hide();

		jQuery('#accessibility_link').click(function(){

			jQuery('.accessibility_dropdown').toggle();

            if(jQuery('#accessibility_link .bottom_left').is(":visible")){
			    jQuery('#accessibility_link .bottom_left').hide();
			    jQuery('#accessibility_link .bottom_right').hide();
            }else{
                jQuery('#accessibility_link .bottom_left').show();
			    jQuery('#accessibility_link .bottom_right').show();
                jQuery('#accessibility_link').removeClass('active');
            }

		});


        jQuery('.accessibility_dropdown .close').click(function(){

            jQuery('.accessibility_dropdown').hide();
			jQuery('#accessibility_link .bottom_left').show();
			jQuery('#accessibility_link .bottom_right').show();
            jQuery('#accessibility_link').removeClass('active');

        });



		jQuery('.accessibility_dropdown').hover(function(){

			jQuery('#accessibility_link').addClass('active');

		}, function(){

            var active_access = jQuery('#accessibility_link').attr("class");

            if(active_access != "active"){
                jQuery('#accessibility_link').removeClass('active');
            }
		});



		jQuery('.home_block').hover(function(){

			jQuery(this).css('cursor', 'pointer');

		});

		jQuery('.home_block').click(function(){
		
			link = jQuery(this).find('a').attr('href');
		
			window.location = link;
		
		
		});



		propergateformfeild('#posted-name','Your Name');
		propergateformfeild('#posted-email','Email Address');
		propergateformfeild('#posted-tel','Phone Number');
		propergateformfeild('#posted-postcode','Postcode');
		propergateformfeild('#posted-currentemployer','Your Current Employer');



			jQuery('.js_enabled').show();
			jQuery('.no_js').hide();

			//jQuery('<div id="shadow"></div>').appendTo('body');
			//jQuery('#shadow').hide();
			jQuery('.enquiry_popup').hide();


			/*jQuery('.register_interest a').click(function(){

				jQuery('.enquiry_popup').fadeIn(300).css('visibility', 'visible');
				//jQuery('#shadow').fadeIn(1000);

				return false;

			});*/


			if(jQuery('#enquiry input').hasClass('error') || jQuery('#enquiry select').hasClass('error')){

				jQuery('.enquiry_popup').show();

			}
	
	
	
			jQuery('#shadow').click(function(){
	
				//jQuery('#shadow').fadeOut(300);
				jQuery('.enquiry_popup').fadeOut(300);
	
			});
		
			jQuery('a.close_enquiry').click(function(){
	
				//jQuery('#shadow').fadeOut(300);
				jQuery('.enquiry_popup').fadeOut(300);
	
			});


            var share_visible = 0;

            jQuery('#share_link').click(function(){

                if(share_visible == 0){
                    jQuery('.addthis_cover').animate({left:  '130px'});
                    share_visible = 1;
                }else{
                    jQuery('.addthis_cover').animate({left:  '0px'});
                    share_visible = 0;
                }
            });


			jQuery('ul:empty').remove();
			




			// Clear default function
			jQuery.fn.clearDefault = function(){
				return this.each(function(){
					var default_value = jQuery(this).val();
			        // Textareas don't read val() function from jquery so we use normal js
			        if(default_value == ""){
			          default_value = this.value;
			        }
					jQuery(this).focus(function(){
						if (jQuery(this).val() == default_value) jQuery(this).val("");
					});
					jQuery(this).blur(function(){
						if (jQuery(this).val() == "") jQuery(this).val(default_value);
					});
				});
			};
			
			jQuery('#enquiry-embed-container input').clearDefault();
			jQuery('#enquiry-embed-container textarea').clearDefault();
		
		



	});


