// JavaScript Document

	var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;
	
	var newURL = window.location.href;
	
	$(function(){
		//accordion on services page
			$( "#accordion" ).accordion();
		
		//for ceebox 
			$(".sub").ceebox({});
			$(".ceebox").ceebox({});
		
		//for rollover categories
			$('.portfolio_work_box').hover(function()
				{
					$(".cover", this).stop().animate({top:'70px'},{queue:false,duration:160});
				},
				function()
				{
					$(".cover", this).stop().animate({top:'80px'},{queue:false,duration:160});
				});			
			
		//for main_navigation
		var j = 1;

		$('#header a').each(function()
		{
			$(this).click(function()
			{
				$('#header a').removeClass('current');
				$(this).addClass('current');
			});
			j++;
		});	
		
		//for portfolio section
		$("#portfolio_nav a:first").addClass("current");
		
		var i = 1;
		$('#portfolio_nav a').each(function()
		{
			$(this).click(function()
			{	
				$('#portfolio_nav a').removeClass('current');
				$(this).addClass('current');
			});
			i++;
		});
		
		//for home page slideshow
	/*	$('#home .secondary_content').cycle(
		{
			fx: 'fade', speed: 2000, timeout: 4000 
		});
	*/		
		//change class depending on URL
		if(newURL.indexOf('#portfolio') != -1 ||
		newURL.indexOf('portfolio_brand_campaign') != -1 ||
		newURL.indexOf('portfolio_interactive') != -1 ||
		newURL.indexOf('portfolio_identity') != -1 ||
		newURL.indexOf('portfolio_environmental') != -1 ||
		newURL.indexOf('portfolio_print') != -1 ||
		newURL.indexOf('portfolio_promo') != -1)
		{
			$('a#sec_portfolio').addClass('current');
		}
		else if (newURL.indexOf('#company') != -1)
		{
			$('a#sec_company').addClass('current');
		}
		else if (newURL.indexOf('#services') != -1)
		{
			$('a#sec_services').addClass('current');
		}
		else if (newURL.indexOf('#clients') != -1)
		{
			$('a#sec_clients').addClass('current');
		}
		else if (newURL.indexOf('#contact') != -1)
		{
			$('a#sec_contact').addClass('current');
		}
		
	//for portfolio section	
		if(newURL.indexOf('portfolio_interactive') != -1)
		{
			$("#portfolio_nav a:first").removeClass("current");	
			$("#interactive_link").addClass("current");	
		}
		else if (newURL.indexOf('portfolio_identity') != -1)
		{
			$("#portfolio_nav a:first").removeClass("current");	
			$("#identity_link").addClass("current");	
		}
		else if (newURL.indexOf('portfolio_environmental') != -1)
		{
			$("#portfolio_nav a:first").removeClass("current");	
			$("#environmental_link").addClass("current");	
		}
		else if (newURL.indexOf('portfolio_print') != -1)
		{
			$("#portfolio_nav a:first").removeClass("current");	
			$("#print_link").addClass("current");	
		}
		else if (newURL.indexOf('portfolio_promo') != -1)
		{
			$("#portfolio_nav a:first").removeClass("current");	
			$("#promo_link").addClass("current");	
		}
		
	});// and jquery object	
	
	//scroll to areas of website section	
		if (!IE6)
		{
			jQuery(function( $ )
			{
				$('#header a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
					$.scrollTo( this.hash, 1500, {});
					return false;
				});
				
				$('a.read_next').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
					$.scrollTo( this.hash, 1500, {});
					return false;
				});
		
				$.localScroll.defaults.axis = 'xy';
				
				$.localScroll.hash({
					target: '#content', // Could be a selector or a jQuery object too.
					queue:true,
					duration:1500
				});
				
				
				$.localScroll({
					target: '#content', // could be a selector or a jQuery object too.
					queue:true,
					duration:1000,
					hash:true,
					onBefore:function( e, anchor, $target ){
						// The 'this' is the settings object, can be modified
					},
					onAfter:function( anchor, settings ){
						// The 'this' contains the scrolled element (#content)
					}
				});
			}); // end jquery objects
				
		}// end if statement
