

homepage_props_animation_speed = 1200;
homepage_props_easing = 'easeOutCubic';

function show_this_prop_box(target_propbox) {
	var hero = $('#hero');
	var hero_offset = hero.offset();
	
	var target = $(target_propbox);
	var target_offset = target.offset();
	
	var prop_container = $('#props_container');
	var prop_container_current_top = prop_container.position();
	prop_container_current_top = prop_container_current_top.top;
	
	
	var amount_to_move = ((target_offset.top - hero_offset.top) * -1);
	
	var prop_containers_target_top = prop_container_current_top + amount_to_move;
	
	$('#props_container').dequeue().animate({
		top: prop_containers_target_top + "px"
	}, homepage_props_animation_speed, homepage_props_easing, function() {
   		// Animation complete stuff
	});
};

function move_arrow(target_propbox) {
	
	var top_arrows_target_top = 6;
	
	switch(target_propbox){
		case "#prop_two":
			top_arrows_target_top = 101;
		break;
	
		case "#prop_three":
			top_arrows_target_top = 196;
		break;
		
		case "#prop_four":
			top_arrows_target_top = 292;
		break;
	}
	
	$('#sliding_arrow').dequeue().animate({
		top: top_arrows_target_top + "px"
	}, homepage_props_animation_speed, homepage_props_easing, function() {
    	// Animation complete stuff
	});
	
};

function load_google_maps() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		var point = new GLatLng(51.50522991831485, -0.09675264358520508);

		map.setCenter(point, 15);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setMapType(G_NORMAL_MAP);

		var marker = new GMarker(point);
		var html = '<strong>Digitalis Media Limited</strong><br />The Ground Floor<br />76-80 Southwark Street<br />London<br />SE1 0PN<br />United Kingdom';
		//GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); });

		map.addOverlay(marker);
		marker.openInfoWindowHtml(html);
	}
}

function show_height() {
	
	if( $('#twitter_feed').height() > $('#case_study_call').height()){
		$('#case_study_call').height($('#twitter_feed').height());
	}
	
	if( $('#twitter_feed').height() < $('#case_study_call').height() ){
		$('#twitter_feed').height($('#case_study_call').height());
	}
	
}

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}


$(document).ready(function(){
	
	$('#blog_changer',this).bind({
		change: function() {
			if( $('#blog_changer').val() != "/" ){
				window.location = "/blog/" + $('#blog_changer').val();
			}
		}
	});
	
	$('.prop_change',this).bind({
		click: function() {
			$('#text_column .prop_change').each(function(index) {
				$(this).removeClass('on');
			});
			$(this).addClass('on');
			show_this_prop_box('#' +  $(this).attr('rel') );
			move_arrow('#' +  $(this).attr('rel') );
			return false;
		}
	});
	
	$('.page-item-18 ul a',this).bind({
		click: function() {
			return false;
		}
	});
	
	$('.page-item-18 ul li').addClass('off');
	
	if ($('#map').length != 0) {
		load_google_maps();
	}
	
	$("#twitter_old").getTwitter({
		userName: "digitalis_media",
		numTweets: 1,
		loaderText: "Loading tweet...",
		slideIn: false,
		slideDuration: 0,
		showHeading: false,
		headingText: "Latest Tweets",
		showProfileLink: false,
		showTimestamp: true
	});
	
	
	$('#accessibility a .smaller').hide();
	
	$("#medium_size").click(function() {
			$('#accessibility').toggleClass('current_page');
			
			if($('#accessibility').hasClass('current_page')){
				$("#font_sizing").attr("href",'/css/larger.css');
				
				$('#accessibility a span').hide();
				$('#accessibility a .smaller').show();
				
				
			}else{
				$("#font_sizing").attr("href",'');
				
				$('#accessibility a span').show();
				$('#accessibility a .smaller').hide();
			}
			return false;
	});
	
	
	e_updates_input_box_value = "Your email";
	e_updates_input_box = $('#krldm-krldm');
	
	e_updates_input_box.val(e_updates_input_box_value);
	
	e_updates_input_box.focus(function() {
			if($(this).val() == e_updates_input_box_value){
				$(this).val("");
			}
	});
	
	e_updates_input_box.blur(function() {
			if($(this).val() == ""){
				$(this).val(e_updates_input_box_value);
			}
	});
	
	
	
	other_input_box_value = "If you selected other please specify...";
	other_input_box = $('#other_box');

	other_input_box.val(other_input_box_value);

	other_input_box.focus(function() {
			if($(this).val() == other_input_box_value){
				$(this).val("");
			}
	});

	other_input_box.blur(function() {
			if($(this).val() == ""){
				$(this).val(other_input_box_value);
			}
	});
	
	
	$('#twitter_old').hide();
	
	var i = 1000;
	for (i = 1000; i <= 20000; i = i + 500){
		setTimeout(show_height,i)
	}

	
	if(jQuery.url.attr("anchor") != null){
		
		$('.prop_change').each(function(index) {
			$(this).removeClass('on');
		});
		
		if(jQuery.url.attr("anchor") == 2){
			$('[rel=prop_two]').addClass('on');
			show_this_prop_box('#prop_two');
			move_arrow('#prop_two');
		}
		if(jQuery.url.attr("anchor") == 3){
			$('[rel=prop_three]').addClass('on');
			show_this_prop_box('#prop_three');
			move_arrow('#prop_three');
		}
		if(jQuery.url.attr("anchor") == 4){
			$('[rel=prop_four]').addClass('on');
			show_this_prop_box('#prop_four');
			move_arrow('#prop_four');
		}
	}
	

	equalHeight($('.call_to_action'));
	
	
	
});










