
var casestudy = false;

jQuery(document).ready(function(){
jQuery('#mycarousel').jcarousel({itemFallbackDimension:'113px'});
jQuery(".tool").tooltip();
    //jQuery('#slider1').anythingSlider({ animationTime : 0 }); // add any non-default options here

jQuery('.content-right-sub-bx ul li a').click(function() {
		//jQuery('.content-right-sub-bx ul li ol').parent().find('.sub-list').slideUp();
	  //jQuery('.content-right-sub-bx ul li ol').removeClass('active');

	  jQuery(this).parent().find('.sub-list').slideToggle();
	  if (jQuery(this).hasClass('active') == true ){
		//jQuery(this).removeClass('active');
		jQuery(this).css('background-position','0 -24px');
		}
		else
		{
		//jQuery(this).addClass('active');
		jQuery(this).css('background-position','0 0');
		}
return false;

});
// Used on Portfolio page
/*jQuery('.content-right-sub-bx ol li a').click(function() {
		//jQuery('.content-right-sub-bx ul li ol').parent().find('.sub-list').slideUp();
	  //jQuery('.content-right-sub-bx ul li ol').removeClass('active');

	  jQuery(this).parent().find('.sub-list').slideToggle();
	  if (jQuery(this).hasClass('active') == true ){
		jQuery(this).removeClass('active');
		jQuery(this).css('background-position','0 -24px');
		}
		else
		{
		jQuery(this).addClass('active');
		jQuery(this).css('background-position','0 0');
		}


});*/


/* Anything slider thumbs*/
var i = 1;
var ids = new Array();
while (i <= 999){
	ids.push(i); // adds i to the ids array
	jQuery(".slide-jump"+ i).click(function(){
	// removes slide-jump from class from selected leaving the correct id for the slide.
	  jQuery('#slider1').anythingSlider(jQuery(this).attr('class').replace('slide-jump', ''));
		});
	i++;
}

jQuery('#content-top a').lightBox();

	 jQuery('#slider1')
	  .anythingSlider({
	   width 		 : 980,
	   height 		 : 400,
	   animationTime : 0,
	   startStopped  : true,

	   navigationFormatter : function(i, panel){ // add thumbnails as navigation links
	return false;
	   }
  })
  // target all images inside the current slider
  // replace with 'img.someclass' to target specific images
  .find('.panel:not(.cloned) img') // ignore the cloned panels
   .attr('rel','group')            // add all slider images to a colorbox group


   jQuery('#slider1').anythingSliderFx({
              '.panel' : [ 'fade', 4000, 'easeOutCirc' ] // target the entire panel and fade will take 1000ms
             });
});




// Tool Tip
/*
 * Tooltip script
 * powered by jQuery (http://www.jquery.com)
 *
 * written by Alen Grakalic (http://cssglobe.com)
 *
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */



this.tooltip = function(){
	/* CONFIG */
		xOffset = 10;
		yOffset = 20;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
	/* END CONFIG */
	$("a.tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#tooltip").remove();
    });
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
};



jQuery(document).ready(function() {
	if(casestudy)
	{
		jQuery('.project_section:not(:last)').hide();
	}
	else
	{
		jQuery('.project_section:not(:first)').hide();
	}
	jQuery('.project_section_list a').click(function() {
		project_id = jQuery(this).attr('id').replace('_link', '');
		jQuery('.project_section').hide();
		jQuery('#'+project_id).show();
		jQuery('.project_section_list a.active').removeClass('active');
		jQuery(this).addClass('active');
		return false;
	});
	jQuery('.casestudy_link').click(function() {
		jQuery('.project_section_list').last().find('a').trigger('click');
		return false;
	});

	jQuery('.service_section:not(:first)').hide();
	jQuery('.service_section_list a').click(function() {
		service_id = jQuery(this).attr('id').replace('_link', '');
		jQuery('.service_section').hide();
		jQuery('#'+service_id).show();
		jQuery('.service_section_list a.active').removeClass('active');
		jQuery(this).addClass('active');
		return false;
	});

	jQuery('.about_section:not(:first)').hide();
	jQuery('.about_section_list a').click(function() {
		about_id = jQuery(this).attr('id').replace('_link', '');
		jQuery('.about_section').hide();
		jQuery('#'+about_id).show();
		jQuery('.about_section_list a.active').removeClass('active');
		jQuery(this).addClass('active');
		return false;
	});

	jQuery('#subsciber_email').keydown(function(e) {
		if(e.keyCode == 13)
		{
			jQuery('#subscriber_signup_submit').trigger('click');
			return false;
		}
	});
	jQuery('#subscriber_signup_submit').click(function() {
		email = jQuery('#subsciber_email');
		page_ref = jQuery('#subscriber_page_ref');
		jQuery.ajax({
			url: '/newsletter',
			data: 'email='+email.val()+'&page_ref='+page_ref.val(),
			type: 'POST',
			success: function(data) {
				title = '';
				message = '';
				switch(data)
				{
					case 'noEmail':
						title = 'Newsletter Subscription - Error';
						message = 'Please enter an email address.';
						break;
					case 'invalidEmail':
						title = 'Newsletter Subscription - Error';
						message = 'Please enter a valid email address, for example, <em>name@domain.com</em>';
						break;
					case 'alreadySubscribed':
						title = 'Newsletter Subscription - Error';
						message = 'You are already subscribed to the newsletter with this email address.';
						break;
					case 'error':
						title = 'Newsletter Subscription - Error';
						message = 'There was an error subscribing you to the newsletter. Please try again.';
						break;
					case 'success':
						title = 'Newsletter Subscription - Success';
						message = 'Thank you for subscribing to the newsletter, we will be in touch soon.';
						break;
					default:
						title = 'Newsletter Subscription - Error';
						message = 'An unknown error has occured. Please try again.';
				}
				jQuery('#dialog').dialog('destroy');
				jQuery('#dialog').attr('title', title).html(message);
				jQuery('#dialog').dialog({
					modal: true,
					draggable: false,
					resizable: false,
					buttons: {
						"Ok": function() {
							jQuery('#dialog').dialog('close');
						}
					}
				});
			}
		});
		return false;
	});
});
