$(function() {
	$('html').removeClass('no-js').addClass('js');
	$('#artlines_logo').css({cursor: 'pointer'}).click(function() {
		window.location = '/';
	});
	/*
	if ($('html.ie7, html.ie6').size())
	{
		$('body').prepend('<div id="ie_warning">This website is going to look a little buggy in your version of Internet Explorer (6/7). We recommend you <a href="http://windows.microsoft.com/en-GB/internet-explorer/products/ie/home">upgrade to version 9</a>, or <a href="http://windows.microsoft.com/en-GB/internet-explorer/downloads/ie-8">version 8</a> for XP operating systems</div>');
	};
	*/
 });
 
$(function() {

	var original_width;
	var original_height;
	var original_left;
	var original_img_left;
	
	
	//OPEN CASE STUDIES
	$('#case_studies_home .panel#case_study_1').toggle(function() {		
		original_width = '24.5%';
		original_height = '100%';
		original_left = false;
		original_img_left = false;
	}, function() {
		return case_study_close(original_width, original_height, original_left, original_img_left);
	});
	
	$('#case_studies_home .panel#case_study_2').toggle(function() {		
		original_width = '24.5%';
		original_height = '49%';
		original_left = '25.5%';
		original_img_left = $('img.banner', this).position().left;
	}, function() {
		return case_study_close(original_width, original_height, original_left, original_img_left);
	});
	
	$('#case_studies_home .panel#case_study_3').toggle(function() {
		original_width = '49%';
		original_height = '49%';
		original_left = false;
		original_img_left = false;
	}, function() {
		return case_study_close(original_width, original_height, original_left, original_img_left);
	});
	
	$('#case_studies_home .panel#case_study_4').toggle(function() {
		original_width = '49%';
		original_height = '49%';
		original_left = '25.5%';
		original_img_left = $('img.banner', this).position().left;
	}, function() {
		return case_study_close(original_width, original_height, original_left, original_img_left);
	});
	
	$('#case_studies_home .panel#case_study_5').toggle(function() {
		original_width = '24.5%';
		original_height = '49%';
		original_left = false;
		original_img_left = false;
	}, function() {
		return case_study_close(original_width, original_height, original_left, original_img_left);
	});
	
	$('#case_studies_home .panel').click(function() {
		case_studies_home_open(this, original_left, original_img_left);
	});
	
	//CLOSE CASE STUDIES
	$('#case_study_close').click(function() {
		return case_study_close(original_width, original_height, original_left, original_img_left);
	});
	
	
	
	function case_studies_home_open(element, left_offset, left_img_offset) {
	
		//alert(left_img_offset);
	
		if ($('#case_studies_home .panel').hasClass('open'))
		{
			return false;
		};
		$(element).addClass('open');
	
		var div_anim = {};
		var img_anim = {};
		
		if (left_offset) {		
			div_anim['left'] = '0%';
			img_anim['left'] = '0';
			
			$('img.banner', element).css({
				'left': left_img_offset+'px'
			}).animate(img_anim, 1000);
			
		};
		
		div_anim['width'] = '100%';
		div_anim['height'] = '100%';
		
		$(element).css({
			'z-index': '1000'
		}).animate(div_anim, 1000, function() {
			
			$('#case_studies_home_placeholder .placeholder').html($('.summary', this).html());
			$('#case_studies_home_placeholder #case_study_view').attr('href', $('a.hidden', this).attr('href'));
			$('#case_studies_home_placeholder').slideDown(500);
		
		});
		
	
	};
	
	function case_study_close(width, height, left_offset, left_img_offset) {
	
		//alert(left_img_offset);
	
		var element = $('#case_studies_home .open');
		
		var div_anim = {};
		var img_anim = {};
		div_anim['width'] = width;
		div_anim['height'] = height;
		if (left_offset) {		
			div_anim['left'] = left_offset;
		};
		if (left_img_offset) {
			img_anim['left'] = left_img_offset+'px';			
		};
	
		$('#case_studies_home_placeholder').slideUp(500, function() {
		
			$('img.banner', element).animate(img_anim, 1000);
			
			$(element).animate(div_anim, 1000, function() {
				$(this).removeClass('open').css({
					'z-index': '0'
				});
			});
			
		});
		
		return false;
	
	};

});

$(function() {

	case_study_home_sizing();
	$(window).resize(function() {
		case_study_home_sizing();
	});
	
	function case_study_home_sizing() {
	
		var container_width = $('#case_studies_home').width();
		$('#case_studies_home').height(container_width/2);
		$('#case_studies_home .panel img').css({
			'max-width': container_width+'px'
		});
	
	};
	
});

$(function() {

  function gmap() {
    var myOptions = {
      zoom: 15,
      center: new google.maps.LatLng(51.633549, -0.689778),
      mapTypeId: google.maps.MapTypeId.ROADMAP	
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"),
                                  myOptions);
 
    var image = '/images/gmap-marker.png';
    var myLatLng = new google.maps.LatLng(51.633549, -0.689778);
    var beachMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });
  };

  function gmap_colour() {
    var myOptions = {
      zoom: 12,
      center: new google.maps.LatLng(51.633549, -0.689778),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
	styles: [{
		    stylers: [
		      { invert_lightness: true },
		      { hue: "#ff4d00" }
		    ]
		  }]
    }
    var map = new google.maps.Map(document.getElementById("map_canvas_colour"),
                                  myOptions);
 
    var image = '/images/gmap-marker.png';
    var myLatLng = new google.maps.LatLng(51.633549, -0.689778);
    var beachMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });
  };
  
	if (document.getElementById("map_canvas")) {
		gmap();
	};
	
	if (document.getElementById("map_canvas_colour")) {
		gmap_colour();
	};
	
	
  
  
});

$(function() {
	$('#blog_side .by_date ul li:gt(0)').mouseenter(function() {
		$('a:first', this).css({
			backgroundImage: 'url(/images/blog-minus.gif)'
		});
		$('ul', this).slideDown(300);
	}).mouseleave(function() {
		$('a:first', this).css({
			backgroundImage: 'url(/images/blog-plus.gif)'
		});
		$('ul', this).slideUp(300);
	});
});

$(function() {
	
	var container_width = $('#case_study_images').width();
	var container_height = container_width/2;	
	
	$('#case_study_images ul').cycle({
		fx: 'scrollHorz',
		slideExpr: 'li',
		timeout: 0,
		speed: 1000,
		pause: 1,
		pager: '#gallery_controls .slides',
		next: '#gallery_controls .right',
		prev: '#gallery_controls .left',
		width: container_width,
		height: container_height,
		fit: true
	}).parent().mouseenter(function() {
		$("#gallery_controls").fadeIn(300);
	}).mouseleave(function() {
		$("#gallery_controls").fadeOut(300);
	});
	
	$("#gallery_controls").width(($("#gallery_controls .slides a").size()*14)+21+13+13);

});























/*

function case_studies_close(animate_from_h, animate_from_v, width, height, left_offset) {	
	

	
	if (left_)
	{
		var img_left = $('img', this).css('left');
		var img_left_px = 0;
		
		if (img_left.substr(-2) == 'px')
		{
			img_left_px = parseInt(img_left,10);
		}
		else if (img_left.substr(-1) == '%')
		{
			var container_width = $(this).width();
			img_left = parseInt(img_left,10)*0.01;
			img_left_px = parseInt(container_width*img_left,10);
		};
		
		$('img', this).css({
			'left': img_left_px+'px'
		}).animate({
			'left': '0px'
		}, 1000);		
		
	};
	
	var anim = {
		width: '100%',
		height: '100%'		
	};
	anim[animate_from_y] = '0%';
	
	$(this).css({
		'z-index': '1000'
	}).animate(anim, 1000);
	
};

*/


