var domain_path = 'http://arsonstudio.com';

// saves all slides id
	var slides = [];
	// saves current slide
	var current_slide = null;
	// saves first and last slide
	var first_slide = null;
	var last_slide = null;
		
	// reload prev and next slide
	function preLoadSlide(slide) {
		var prev = slides[slide].prev.attr("id");
		var next = slides[slide].next.attr("id");
		$("<img>").attr('src',domain_path+'/i/slides/'+prev+'.jpg');
		$("<img>").attr('src',domain_path+'/i/slides/'+next+'.jpg');
	}

$(function() {

	// loop to save all slides and prev and next of each one of them
	$("#slides ul li").each(function(i) {
		var obj = $(this);
		var next = obj.next();
		var prev = obj.prev();
		if(next.length == 0) last_slide = this;
		if(prev.length == 0) first_slide = this;
		slides[this.id] = { index:i, next:next, prev:prev };
	});

	// prev and next slide of the fist and last slide
	slides[first_slide.id].prev = $("#slides ul li:last");
	slides[last_slide.id].next = $("#slides ul li:first");
	
	// preload next and prev of the first slide
	preLoadSlide(first_slide.id);

	// set up the carousel
	$("#slides").jCarouselLite({
		 btnNext: "#next",
		 btnPrev: "#prev",
		 visible: 1,
		 speed: 380,
		 beforeStart: function(e) {
			// before animation, save current slide id
			current_slide = e[0].id;
		 },
		 afterEnd: function(e) {
			// after animation, preload prev and next slides of the current slide
			preLoadSlide(e[0].id);
		 }
	});

	$('a#next').click(function(){
		// load slide image
		var slide = slides[current_slide].next.attr("id");
		$('#slides-container').removeClass().addClass(slide);
	});
	
	$('a#prev').click(function(){
		// load slide image
		var slide = slides[current_slide].prev.attr("id");
		$('#slides-container').removeClass().addClass(slide);
	});
	
	// Hide
	$('.accessibility').hide();
	
	$("q").prepend("&ldquo;").append("&rdquo;");
	$("q q").prepend("&lsquo;").append("&rsquo;");
	// Add classes to input pseudotypes
	$("input[type='text'], input[type='password']").addClass("text");
	$("input[type='button'], input[type='submit'], input[type='checkbox'], input[type='image'], input[type='radio'], input[type='reset'], button").addClass("nontext");
	$("input[type='button'], input[type='submit'], input[type='reset'], button").addClass("button");
	// Add classes to link pseudotypes
	$("a[href^='mailto:']").addClass("mailto");
	$("a[href$='.pdf']").addClass("docpdf");
	$("a[href$='.swf']", "a[href$='.fla']", "a[href$='.swd']").addClass("docflash");
	$("a[href$='.xls']", "a[href$='.csv']", "a[href$='.xlt']", "a[href$='.xlw']").addClass("docexcel");
	$("a[href$='.ppt']", "a[href$='.pps']").addClass("docppoint");
	$("a[href$='.doc']", "a[href$='.rtf']", "a[href$='.txt']", "a[href$='.wps']").addClass("docword");
	$("a[href$='.zip']", "a[href$='.gzip']", "a[href$='.rar']").addClass("doczip");
	// External link popper
	$('a[href^=http://]').not('[href*='+window.location.host+']').attr('target','_blank').addClass("external");
	
	// Remove classes from a link containing an image
	$("a img").parent().removeClass();
		
	// Wrap <hr> so bg-image doesn't have a border in IE6 and Opera
	$("hr").wrap('<div class="hr"></div>');
	
	/* Add class="obfuscated" and href="mailto:name(at)example.com" to an email address link */
	$('.obfuscated').defuscate();
	
	// Add Clearfix
	$("#window, #content, #sub").addClass("clearfix");
	
	
});

/*
 * Email Defuscator - jQuery plugin 1.0 alpha
 *
 * Copyright (c) 2007 Joakim Stai
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Converts obfuscated email addresses into normal, working email addresses.
 *
 * @name defuscate
 * @param Boolean link If true, all defuscated email addresses will be turned into links, defaults to true (optional)
 * @descr Converts obfuscated email addresses into normal email addresses
 */
 
jQuery.fn.defuscate=function(b){b=jQuery.extend({link:true},b);var c=/\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;return this.each(function(){if($(this).is('a[@href]')){$(this).attr('href',$(this).attr('href').replace(c,'$1@$2'));var a=true}$(this).html($(this).html().replace(c,(b.link&&!a?'<a href="mailto:$1@$2">$1@$2</a>':'$1@$2')))})}

/**
 * jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.
 * @requires jQuery v1.2 or above
 *
 * http://gmarwaha.com/jquery/jcarousellite/
 *
 * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 1.0.1
 * Note: Requires jquery 1.2 or above from version 1.0.1
 */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.1g.1w=6(o){o=$.1f({r:n,x:n,N:n,17:q,J:n,L:1a,16:n,y:q,u:12,H:3,B:0,k:1,K:n,I:n},o||{});8 G.R(6(){p b=q,A=o.y?"15":"w",P=o.y?"t":"s";p c=$(G),9=$("9",c),E=$("10",9),W=E.Y(),v=o.H;7(o.u){9.1h(E.D(W-v-1+1).V()).1d(E.D(0,v).V());o.B+=v}p f=$("10",9),l=f.Y(),4=o.B;c.5("1c","H");f.5({U:"T",1b:o.y?"S":"w"});9.5({19:"0",18:"0",Q:"13","1v-1s-1r":"S","z-14":"1"});c.5({U:"T",Q:"13","z-14":"2",w:"1q"});p g=o.y?t(f):s(f);p h=g*l;p j=g*v;f.5({s:f.s(),t:f.t()});9.5(P,h+"C").5(A,-(4*g));c.5(P,j+"C");7(o.r)$(o.r).O(6(){8 m(4-o.k)});7(o.x)$(o.x).O(6(){8 m(4+o.k)});7(o.N)$.R(o.N,6(i,a){$(a).O(6(){8 m(o.u?o.H+i:i)})});7(o.17&&c.11)c.11(6(e,d){8 d>0?m(4-o.k):m(4+o.k)});7(o.J)1p(6(){m(4+o.k)},o.J+o.L);6 M(){8 f.D(4).D(0,v)};6 m(a){7(!b){7(o.K)o.K.Z(G,M());7(o.u){7(a<=o.B-v-1){9.5(A,-((l-(v*2))*g)+"C");4=a==o.B-v-1?l-(v*2)-1:l-(v*2)-o.k}F 7(a>=l-v+1){9.5(A,-((v)*g)+"C");4=a==l-v+1?v+1:v+o.k}F 4=a}F{7(a<0||a>l-v)8;F 4=a}b=12;9.1o(A=="w"?{w:-(4*g)}:{15:-(4*g)},o.L,o.16,6(){7(o.I)o.I.Z(G,M());b=q});7(!o.u){$(o.r+","+o.x).1n("X");$((4-o.k<0&&o.r)||(4+o.k>l-v&&o.x)||[]).1m("X")}}8 q}})};6 5(a,b){8 1l($.5(a[0],b))||0};6 s(a){8 a[0].1k+5(a,\'1j\')+5(a,\'1i\')};6 t(a){8 a[0].1t+5(a,\'1u\')+5(a,\'1e\')}})(1x);',62,96,'||||curr|css|function|if|return|ul|||||||||||scroll|itemLength|go|null||var|false|btnPrev|width|height|circular||left|btnNext|vertical||animCss|start|px|slice|tLi|else|this|visible|afterEnd|auto|beforeStart|speed|vis|btnGo|click|sizeCss|position|each|none|hidden|overflow|clone|tl|disabled|size|call|li|mousewheel|true|relative|index|top|easing|mouseWheel|padding|margin|200|float|visibility|append|marginBottom|extend|fn|prepend|marginRight|marginLeft|offsetWidth|parseInt|addClass|removeClass|animate|setInterval|0px|type|style|offsetHeight|marginTop|list|jCarouselLite|jQuery'.split('|'),0,{}))

