var isiPad = navigator.userAgent.match(/iPad/i);
var isiPhone = navigator.userAgent.match(/iPhone/i);
var isiPod = navigator.userAgent.match(/iPod/i);
var isAndroid = navigator.userAgent.match(/Android/i);


	
$(document).ready(function(){


	

	$('body').addClass("js");

	$(function() {
	  setInterval(proceed, 1500);
	});

	if ( (isiPhone === null) && (isiPod === null) && (isAndroid === null) )
	{
		$('div.quote').animate({ opacity: 0 }, 0);
	}

	function proceed() {
		$('div#quote-open').animate({ opacity: 1, left: "0px" }, 1200);
		$('div#quote-close').animate({ opacity: 1, right: "0px" }, 1200);
		$('div#quote-text').animate({ opacity: 1 }, 3500);
	}

	// Lastest Work Slider
	$("#slideshow").easySlider({
		auto: true,
		continuous: true,
		speed: 2000,
		pause: 5000,
		numeric: true
	});
	$("#slideshow li").css("position","static");

	// Lastest Work Captions
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'132px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'192px'},{queue:false,duration:160});
	});

	$(".tweet").tweet({
	join_text: "auto",
	username: "tobydenham",
	count: 5,
	loading_text: "loading tweets..."
	});	
    
	if ( (isiPad === null) && (isiPhone === null) && (isiPod === null) )
	{

		$.fn.qtip.styles.smTip = { 
			padding: 5,
			background: '#cc3399',
			color: '#ffffff',
			border: { width:0,color:'#cc3399' },
			tip: { corner:'bottomLeft',size: { x:10,y:10 }
			}
		}


		$('.tooltipz').each(function() {
			$(this).qtip({
				content: '<h2 class="leagueGothic"><nobr>'+$(this).attr('title')+'</nobr></h2>',
				position: {
					target: 'mouse',
					corner: {
						target: 'topLeft',
						tooltip: 'bottomLeft'
					},
					adjust: {
						x: 15,
						y: -8,
						screen: true
					}
				},
				show: { effect: { length: 200 } },
				style: 'smTip'
			}).removeAttr('title');
		});

	};		
	
	if ( (isiPhone === null) && (isiPod === null) && (isAndroid === null) )
	{	

		$('ul#portfolio-preview a').click(function(e) {

			var url = $(this).attr('href') + ' #showcase';

			$('#portfolio-panel').animate({ height: "0px" }, 650, function(){
				$('#portfolio-panel').css({ "background-image" : "none" }).html('<img src="/images/ajax-loader.gif" width="31" height="31" alt="Loading" class="ajax-loader" />').load(url);
			});
			$('#portfolio-panel').animate({ height: "220px" }, 650);
			e.preventDefault();
		})
	};

	
	$(".accordion h3:first").addClass("active");
	$(".accordion div:not(:first)").hide();

	//$(".accordion .wrapper").hide();

	$(".accordion h3").click(function(){
		$(this).next("div.wrapper").slideToggle("slow").siblings("div.wrapper:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});


});


if ( (isiPhone != null) || (isiPod != null) ) {
	addEventListener("load", function() {
	setTimeout(hideURLbar, 0);
	}, false);
}

function hideURLbar() {
	window.scrollTo(0, 1);
}

function bookmarksite(title, url) {
    if (window.sidebar) // firefox 
    //window.sidebar.addPanel(title, url, ""); Dont use until it's fixed 
        alert('Firefox users. Please press CTRL+D to Bookmark this page');
    else if (window.opera && window.print) { // opera 
        //var elem = document.createElement('a');
        //elem.setAttribute('href', url);
        //elem.setAttribute('title', title);
        //elem.setAttribute('rel', 'sidebar');
    //elem.click();
    alert('Opera users. Please press CTRL+D to Bookmark this page');
    }
    else if (document.all)// ie
        window.external.AddFavorite(location.href, document.title);
} 


