/*
 * jQuery Expander plugin
 * Version 0.4  (12/09/2008)
 * @requires jQuery v1.1.1+
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */


(function($) {

  $.fn.expander = function(options) {

    var opts = $.extend({}, $.fn.expander.defaults, options);
    var delayedCollapse;
    return this.each(function() {
      var $this = $(this);
      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
     	var cleanedTag, startTags, endTags;	
     	var allText = $this.html();
     	var startText = allText.slice(0, o.slicePoint).replace(/\w+$/,'');
     	startTags = startText.match(/<\w[^>]*>/g);
   	  if (startTags) {startText = allText.slice(0,o.slicePoint + startTags.join('').length).replace(/\w+$/,'');}
   	  
     	if (startText.lastIndexOf('<') > startText.lastIndexOf('>') ) {
     	  startText = startText.slice(0,startText.lastIndexOf('<'));
     	}
     	var endText = allText.slice(startText.length);    	  
     	// create necessary expand/collapse elements if they don't already exist
   	  if (!$('span.details', this).length) {
        // end script if text length isn't long enough.
       	if ( endText.replace(/\s+$/,'').split(' ').length < o.widow ) { return; }
       	// otherwise, continue...    
       	if (endText.indexOf('</') > -1) {
         	endTags = endText.match(/<(\/)?[^>]*>/g);
          for (var i=0; i < endTags.length; i++) {

            if (endTags[i].indexOf('</') > -1) {
              var startTag, startTagExists = false;
              for (var j=0; j < i; j++) {
                startTag = endTags[j].slice(0, endTags[j].indexOf(' ')).replace(/(\w)$/,'$1>');
                if (startTag == rSlash(endTags[i])) {
                  startTagExists = true;
                }
              }              
              if (!startTagExists) {
                startText = startText + endTags[i];
                var matched = false;
                for (var s=startTags.length - 1; s >= 0; s--) {
                  if (startTags[s].slice(0, startTags[s].indexOf(' ')).replace(/(\w)$/,'$1>') == rSlash(endTags[i]) 
                  && matched == false) {
                    cleanedTag = cleanedTag ? startTags[s] + cleanedTag : startTags[s];
                    matched = true;
                  }
                };
              }
            }
          }

          endText = cleanedTag && cleanedTag + endText || endText;
        }
     	  $this.html([
     		startText,
     		'<span class="read-more">',
     		o.expandPrefix,
       		'<a href="#">',
       		  o.expandText,
       		'</a>',
        '</span>',
     		'<span class="details">',
     		  endText,
     		'</span>'
     		].join('')
     	  );
      }
      var $thisDetails = $('span.details', this),
        $readMore = $('span.read-more', this);
   	  $thisDetails.hide();
 	    $readMore.find('a').click(function() {
 	      $readMore.hide();

 	      if (o.expandEffect === 'show' && !o.expandSpeed) {
          o.beforeExpand($this);
 	        $thisDetails.show();
          o.afterExpand($this);
          delayCollapse(o, $thisDetails);
 	      } else {
          o.beforeExpand($this);
 	        $thisDetails[o.expandEffect](o.expandSpeed, function() {
            $thisDetails.css({zoom: ''});
            o.afterExpand($this);
            delayCollapse(o, $thisDetails);
 	        });
 	      }
        return false;
 	    });
      if (o.userCollapse) {
        $this
        .find('span.details').append('<span class="re-collapse">' + o.userCollapsePrefix + '<a href="#">' + o.userCollapseText + '</a></span>');
        $this.find('span.re-collapse a').click(function() {

          clearTimeout(delayedCollapse);
          var $detailsCollapsed = $(this).parents('span.details');
          reCollapse($detailsCollapsed);
          o.onCollapse($this, true);
          return false;
        });
      }
    });
    function reCollapse(el) {
       el.hide()
        .prev('span.read-more').show();
    }
    function delayCollapse(option, $collapseEl) {
      if (option.collapseTimer) {
        delayedCollapse = setTimeout(function() {  
          reCollapse($collapseEl);
          option.onCollapse($collapseEl.parent(), false);
          },
          option.collapseTimer
        );
      }
    }
    function rSlash(rString) {
      return rString.replace(/\//,'');
    }    
  };
    // plugin defaults
  $.fn.expander.defaults = {
    slicePoint:       100,  // the number of characters at which the contents will be sliced into two parts. 
                            // Note: any tag names in the HTML that appear inside the sliced element before 
                            // the slicePoint will be counted along with the text characters.
    widow:            4,  // a threshold of sorts for whether to initially hide/collapse part of the element's contents. 
                          // If after slicing the contents in two there are fewer words in the second part than 
                          // the value set by widow, we won't bother hiding/collapsing anything.
    expandText:       'read more', // text displayed in a link instead of the hidden part of the element. 
                                      // clicking this will expand/show the hidden/collapsed text
    expandPrefix:     '&hellip; ',
    collapseTimer:    0, // number of milliseconds after text has been expanded at which to collapse the text again
    expandEffect:     'fadeIn',
    expandSpeed:      '',   // speed in milliseconds of the animation effect for expanding the text
    userCollapse:     true, // allow the user to re-collapse the expanded text.
    userCollapseText: '[collapse expanded text]',  // text to use for the link to re-collapse the text
    userCollapsePrefix: ' ',
    beforeExpand: function($thisEl) {},
    afterExpand: function($thisEl) {},
    onCollapse: function($thisEl, byUser) {}
  };
})(jQuery);
;
/**
 * jQuery.Preload - Multifunctional preloader
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
 * Dual licensed under MIT and GPL.
 * Date: 3/25/2009
 * @author Ariel Flesler
 * @version 1.0.8
 */
;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);;
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}('q $1y(g){7(g.18&&g.18==1)8 h=g;t 7(1z(g).19(/^#([^$]+)$/i)){8 h=1A.1B(K.$1+\'\');7(!h)9 Q}t 9 Q;7(W(h.6)!=\'X\'&&h.6){h.6.R();9 h};h.1C=0.1;h.6={};h.6.4=[];h.6.C=0;7(W(h.L)!=\'X\')1a{1b h.L}1c(1d){h.L=Q}8 k={\'1e|1f|1D|1E|1g|1h|1F|1G|1H|1i|1j\':\'1I\',\'1J\':\'1K\',\'E\':\'\'};8 l=!!1L.1M.19(/1N/1O);8 m={1k:S,H:5,D:\'\'};8 n={E:q(a,b){a=u(a);7(z(a)){7(l){8 c=(T K(\'1l\\\\s*\\\\(E\\\\s*=\\\\s*(\\\\d+)\\\\)\')).Y(h.v.1m+\'\');7(c)9 u(c[1]);t 9 1}t{9 Z.1P((h.v.E?1Q(h.v.E):1)*S)}}t{a=Z.1R(S,Z.1S(0,a));7(l){h.v.1T=1;h.v.1m=\'1l(E=\'+a+\');\'}t{h.v.E=a/S}}},\'1i\':q(a,b){a=u(a);8 x=0,y=0;8 c=(T K(\'^(-?\\\\d+)[^\\\\d\\\\-]+(-?\\\\d+)\')).Y(h.v.U+\'\');7(c){x=u(c[1]);y=u(c[2])}7(z(a))9 x;t{h.v.U=a+b+\' \'+y+b}},\'1j\':q(a,b){a=u(a);8 x=0,y=0;8 c=(T K(\'^(-?\\\\d+)[^\\\\d\\\\-]+(-?\\\\d+)\')).Y(h.v.U+\'\');7(c){x=u(c[1]);y=u(c[2])}7(z(a))9 y;t{h.v.U=x+b+\' \'+a+b}}};8 o={1g:q(){9 u(h.1U)},1h:q(){9 u(h.1V)},1e:q(){8 a=0;A(8 b=h;b;b=b.1n)a+=u(b.1W);9 a},1f:q(){8 a=0;A(8 b=h;b;b=b.1n)a+=u(b.1X);9 a}};h.1o=q(){3.6.R();9 3};h.1p=q(a,b){7(h.6.4[3.6.C].I)9 3;8 b=u(b);3.6.4[z(b)?3.6.C:b].10=a;9 3};h.1q=q(c){8 d=3.6.C;7(3.6.4[d].I)9 3;A(8 p 1r m){7(!c[p])c[p]=m[p]};7(!c.D){A(8 e 1r k)7((T K(e,\'i\').1Y(c.r))){c.D=k[e];1Z}};c.J=(c.J&&c.J.B)?c.J:q(){};c.M=(c.M&&c.M.B)?c.M:q(){};7(!3.6[c.r]){7(n[c.r])3.6[c.r]=n[c.r];t{8 f=3;3.6[c.r]=q(a,b){7(W(a)==\'X\')9 u(f.v[c.r]);t f.v[c.r]=u(a)+b}}};7(z(c.F)){7(z(3.6[c.r]()))7(o[c.r])c.F=o[c.r]();t c.F=0;t c.F=3.6[c.r]()}c.11=c.F;3.6[c.r](c.F,c.D);3.6.4[d].w.20(c);9 3};h.1s=q(a,b,c){8 d=h.6.C;7(3.6.4[d].I){9 3}1t(q(){7(h.6.4[d].I)9 h;h.6.4[d].I=12;7(h.6.4[d].N>0)9 h;h.6.4[d].13=(a&&a.B)?a:q(){};h.6.4[d].1u=(c&&c.B)?c:q(){};7(!z(b))h.6.4[d].V=b;A(8 i=0;i<h.6.4[d].w.G;i++){h.6.4[d].w[i].J.B(h);h.6.O(d,i)}},h.6.4[d].10);9 3};h.1v=q(a,b){3.6.4[!z(b)?b:3.6.C].14=a;9 3};h.1w=q(a){3.6.4[!z(a)?a:3.6.C].15=12;9 3};h.1x=q(){A(8 i=0;i<3.6.4.G;i++){A(8 j=0;j<3.6.4[i].w.G;j++){8 a=3.6.4[i].w[j];7(z(a.11))3.6[a.r](\'\',\'\');t 3.6[a.r](a.11,a.D)}}8 b=[\'6\',\'1p\',\'1q\',\'1o\',\'1s\',\'1v\',\'1w\',\'1x\'];A(8 i=0;i<b.G;i++)1a{1b 3[b[i]]}1c(1d){3[b[i]]=Q}3.L=12};h.6.R=q(){8 a=3.4.G;3.C=a;3.4[a]={};3.4[a].V=1;3.4[a].15=16;3.4[a].w=[];3.4[a].N=0;3.4[a].P=0;3.4[a].10=0;3.4[a].14=16;3.4[a].I=16;3.4[a].13=q(){};9 3};h.6.O=q(a,b){7(!3.4[a]||3.4[a].15||h.L)9;8 c=3.4[a].w[b];8 d=3[c.r]();7((c.H>0&&d+c.H<=c.17)||(c.H<0&&d+c.H>=c.17)){7(!3.4[a].14)3[c.r](d+c.H,c.D);8 e=3;1t(q(){7(e.O)e.O(a,b)},c.1k)}t{3[c.r](c.17,c.D);3.4[a].N++;c.M.B(h);7(3.4[a].w.G==3.4[a].N){3.4[a].N=0;3.4[a].P++;3.4[a].1u.B(h,3.4[a].P);7(3.4[a].P<3.4[a].V||3.4[a].V==-1){A(8 i=0;i<3.4[a].w.G;i++){3[c.r](c.F,3.4[a].w[i].D);3.4[a].w[i].J.B(h,3.4[a].P);3.O(a,i)}}t{3.4[a].13.B(h)}}}};h.6.R();9 h}',62,125,'|||this|sets||_fx|if|var|return|||||||||||||||||function|type||else|parseInt|style|_queue|||isNaN|for|call|_currSet|unit|opacity|from|length|step|_isrunning|onstart|RegExp|_fxTerminated|onfinish|_effectsDone|_process|_loopsDone|null|_addSet|100|new|backgroundPosition|_loops|typeof|undefined|exec|Math|_holdTime|_initial|true|_onfinal|_paused|_stoped|false|to|nodeType|match|try|delete|catch|err|left|top|width|height|backgroundx|backgroundy|delay|alpha|filter|offsetParent|fxAddSet|fxHold|fxAdd|in|fxRun|setTimeout|_onloop|fxPause|fxStop|fxReset|fx|String|document|getElementById|fxVersion|right|bottom|margin|padding|spacing|px|font|pt|navigator|userAgent|MSIE|ig|round|parseFloat|min|max|zoom|offsetWidth|offsetHeight|offsetLeft|offsetTop|test|break|push'.split('|'),0,{}))
;
var basePath = "http://" + window.location.host;
var t;
var lastUrl;
var currentSlide = 0;

//Onload
jQuery(document).ready(function() {	

	//fullscreenrNoResize EVENTS
	jQuery(window).bind("resize", function() { jQuery(".imageback").fullscreenrNoResize(); });	
	jQuery("img").bind("load", function() { jQuery(".imageback").fullscreenrNoResize(); });	
	
	//Ajax
	jQuery.fn.preload();
	jQuery.fn.ajaxMenu();
	
	//Init
	lastUrl = window.location.pathname;
	jQuery.fn.pageinit();
	jQuery.fn.checkUrl();
	
});	


//Page init
jQuery.fn.pageinit = function() {

	jQuery.fn.bioCollapse();
	//jQuery.fn.menuItemsCollapse();
	jQuery.fn.imagelsider();
	jQuery.fn.menusitemAjax();
	jQuery(".imageback").fullscreenrNoResize();
	jQuery.colorbox.init()

};	

//Preload
jQuery.fn.preload = function() {

	jQuery.preload([ 'ki-page-wrapper-00',
				'ki-page-wrapper-01',
				'ki-page-wrapper-02',
				'ki-page-wrapper-03',
				'ki-page-wrapper-04',
				'ki-page-wrapper-05'], {
	    base:'sites/default/themes/sushi/images/',
	    ext:'.jpg'
	});

};	


//fullscreenrNoResize
jQuery.fn.fullscreenrNoResize = function() {
	
	// Get sizes
	var browserwidth = jQuery(window).width();
	var browserheight = jQuery(window).height();
	var pagewrapperwidth = jQuery("#page-wrapper").width();
	var pagewrapperheight = jQuery("#page-wrapper").height();
	
	//Set width
	if(pagewrapperwidth<browserwidth) jQuery(this).width(browserwidth);
	else jQuery(this).width(pagewrapperwidth);
	
	//Set height
	if(pagewrapperheight<browserheight) jQuery(this).height(browserheight);
	else jQuery(this).height(pagewrapperheight+20);
	
	return this; 		
};



//Bio collapse
jQuery.fn.bioCollapse = function() {

	jQuery(".view-about-us .views-field-body-1").each(function(){
		
		jQuery(this).hide().parent().append("<span class='readmore'>+ READ MORE.</span>");
		
		jQuery(this).parent().children(".readmore").click(function(){
		
			if(jQuery(this).html() == "- MINIMIZE") {
			
				jQuery(this).parent().children(".views-field-body-1").slideUp(400, function(){
					jQuery(".imageback").fullscreenrNoResize();
				});
				jQuery(this).html("+ READ MORE");
			
			} else {
			
				jQuery(this).parent().children(".views-field-body-1").slideDown(400, function(){
					jQuery(".imageback").fullscreenrNoResize();
				});
				jQuery(this).html("- MINIMIZE");
			}
		});		
		
	})
};

//Menu items collapse
jQuery.fn.menuItemsCollapse = function() {

	jQuery(".view-node-menu .views-field-body").each(function(){
	
		//if(jQuery(this).height()<300) return;
		
		jQuery(this).hide().parent().append("<span class='readmore'>+ VIEW ALL ITEMS.</span>");
		
		jQuery(this).parent().children(".readmore").click(function(){
		
			if(jQuery(this).html() == "- MINIMIZE") {
			
				jQuery(this).parent().children(".views-field-body").slideUp(400, function(){
					jQuery(".imageback").fullscreenrNoResize();
				});
				jQuery(this).html("+ VIEW ALL ITEMS");
			
			} else {
			
				jQuery(this).parent().children(".views-field-body").slideDown(400, function(){
					jQuery(".imageback").fullscreenrNoResize();
				});
				jQuery(this).html("- MINIMIZE");
			}
		});		
		
	})
};


//Image slider
jQuery.fn.imagelsider = function() {

	jQuery('.slidericon').remove();
	jQuery('.sliderbrowse').remove();
		
	var count = 0;
	jQuery("ul.imagelsider li").each(function(i){
				
		if(count == 0) {
			jQuery("#content .node .content").append('<div class="sliderbrowse"></div>');	
		}
	
		var item = jQuery('<div class="slidericon"></div>');
		item.data('itemid', i);
		item.click(function(){	
			currentSlide = jQuery(this).data('itemid');
			jQuery("ul.imagelsider").animate({left:currentSlide*-575}, 500);
		});
		
		jQuery(this).click(function(){	
			var max = jQuery("ul.imagelsider li").size();
			currentSlide = (currentSlide+1) % max;
			jQuery("ul.imagelsider").animate({left:currentSlide*-575}, 500);
		});

		
		jQuery("#content .node .content").append(item);		
		count ++;		
	}) 
};





//AJAX : menu
jQuery.fn.ajaxMenu = function() {

	jQuery("ul.menu li a, a#logo").each(function(){
		
		var link = jQuery(this).attr("href");
		jQuery(this).attr("href", "#" + link);	
		
		//Click		
		jQuery(this).click(function() {
			
			var href = jQuery(this).attr("href").replace("#", "");
			lastUrl = href;
			jQuery.fn.pageLoad(href);
									
		});
		
	})
};




//AJAX : menu
jQuery.fn.menusitemAjax = function() {

	jQuery("a.detailedmenu, .view-node-menu .view-header a").each(function(){
		
		var link = jQuery(this).attr("href");
		jQuery(this).attr("href", "#" + link);	
		
		//Click		
		jQuery(this).click(function() {
			
			var href = jQuery(this).attr("href").replace("#", "");
			lastUrl = href;
			jQuery.fn.pageLoad(href);
									
		});
		
	})
};



//AJAX : Menu items ajax

jQuery.fn.pageLoad = function(href) {

	//GET
	jQuery.get(href, function(data) {				
		
		//Image back
		jQuery(".imageback").addClass('old').fadeOut(500);				
		jQuery(".imageback").parent().append(jQuery(".imageback", data).hide().fadeIn(500, function(){
			jQuery(".imageback.old").remove();
		}));
		
		//Page content
		jQuery(".region-footer").fadeOut(300);
		jQuery(".main-wrapper").addClass('old');
		jQuery(".main-wrapper:eq(0)").fadeOut(300, function(){							
			
			jQuery(".main-wrapper.old").remove();							
			jQuery("#header").after(jQuery(".main-wrapper", data).hide().fadeIn(300, function(){ jQuery(".imageback").fullscreenrNoResize(); }));
			jQuery(".region-footer").fadeIn(300);
			jQuery.fn.pageinit();
		});
	
						
		//Title
		document.title = jQuery(".title", data).html() + ' | KI-Sushi';
		
		//Analytics
		console.log(href);
		_gaq.push(['_trackPageview', '/' + href]);
	});
}



//Chek url
jQuery.fn.checkUrl = function() {

	var requ = window.location.hash.replace('#','');
	
	if(requ!="" && requ!=lastUrl)
	{
		jQuery.fn.pageLoad(requ);
		lastUrl = requ;
	}
	
	
	t = setTimeout("jQuery.fn.checkUrl()",200);
	
}
;

var positions = [
	
	[{ props: {left: 0, 	top:243, 	opacity:0.0	}, time: 2 },
	 { props: {left: 32, 	top:255, 	opacity:1.0	}, time: 500 },
	 { props: {left: 97, 	top:271, 	opacity:0.8	}, time: 1000 },
	 { props: {left: 134, 	top:291, 	opacity:0.4	}, time: 600 },
	 { props: {left: 177, 	top:321, 	opacity:0.2	}, time: 800 },
	 { props: {left: 249, 	top:384, 	opacity:0.0	}, time: 1200 },
	 { props: {left: 0, 	top:243, 	opacity:0.0	}, time: 1000 }],	 
	
	[{ props: {left: -8, 	top:172, 	opacity:0.0	}, time: 1 },
	 { props: {left: 25, 	top:173, 	opacity:1.0	}, time: 500 },
	 { props: {left: 76, 	top:172, 	opacity:0.8	}, time: 1000 },
	 { props: {left: 112, 	top:165, 	opacity:0.8	}, time: 800 },
	 { props: {left: 162, 	top:167, 	opacity:0.8	}, time: 1000 },
	 { props: {left: 231, 	top:140, 	opacity:0.8	}, time: 800 },
	 { props: {left: 253, 	top:134, 	opacity:0.8	}, time: 800 },
	 { props: {left: 288, 	top:134, 	opacity:0.8	}, time: 800 },
	 { props: {left: 313, 	top:141, 	opacity:0.6	}, time: 1000 },
	 { props: {left: 357, 	top:163, 	opacity:0.0	}, time: 1000 },
	 { props: {left: -8, 	top:176, 	opacity:0.0	}, time: 4000 }],
	 
	
	[{ props: {left: -8, 	top:48, 	opacity:0.0	}, time: 500 },
	 { props: {left: 31, 	top:51, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 49, 	top:35, 	opacity:1.0	}, time: 500 },
	 { props: {left: 60, 	top:16, 	opacity:0.8	}, time: 1000 },
	 { props: {left: 64, 	top:0, 		opacity:0.4	}, time: 600 },
	 { props: {left: 64, 	top:-10, 	opacity:0.0	}, time: 600 }]	,
	 
	
	[{ props: {left: -8, 	top:256, 	opacity:0.0	}, time: 500 },
	 { props: {left: 4, 	top:267, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 14, 	top:293, 	opacity:1.0	}, time: 500 },
	 { props: {left: 25, 	top:316, 	opacity:1.8	}, time: 1000 },
	 { props: {left: 42, 	top:335,	opacity:1.4	}, time: 600 },
	 { props: {left: 60, 	top:349, 	opacity:1.0	}, time: 600 },
	 { props: {left: 120, 	top:363, 	opacity:1.0	}, time: 1600 },
	 { props: {left: 166, 	top:369, 	opacity:1.0	}, time: 800 },
	 { props: {left: 211, 	top:388, 	opacity:1.0	}, time: 800 },
	 { props: {left: 250, 	top:409, 	opacity:0.8	}, time: 900 },
	 { props: {left: 273, 	top:430, 	opacity:0.4	}, time: 900 },
	 { props: {left: 301, 	top:470, 	opacity:0.0	}, time: 600 }],
	 
	 
	[{ props: {left: -8, 	top:192, 	opacity:0.0	}, time: 500 },
	 { props: {left: 21, 	top:190, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 72, 	top:186, 	opacity:1.0	}, time: 900 },
	 { props: {left: 127, 	top:202, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 200, 	top:203, 	opacity:1.0	}, time: 1200 },
	 { props: {left: 230, 	top:184, 	opacity:0.8	}, time: 600 },
	 { props: {left: 266, 	top:176, 	opacity:0.4	}, time: 600 },
	 { props: {left: 310, 	top:174, 	opacity:0.0	}, time: 600 }]	,

	[{ props: {left: -8, 	top:115, 	opacity:0.0	}, time: 1500 },
	 { props: {left: 20, 	top:121, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 45, 	top:104, 	opacity:1.0	}, time: 800 },
	 { props: {left: 71, 	top:93, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 101, 	top:82, 	opacity:1.0	}, time: 1000 },
	 { props: {left: 114, 	top:76, 	opacity:1.0	}, time: 800 },
	 { props: {left: 136, 	top:57, 	opacity:1.0	}, time: 800 },
	 { props: {left: 148, 	top:38, 	opacity:0.8	}, time: 600 },
	 { props: {left: 160, 	top:12, 	opacity:0.4	}, time: 600 },
	 { props: {left: 179, 	top:01, 	opacity:0.0	}, time: 600 }]
	 
];


//Onload
jQuery(document).ready(function() {	

	//Create
	for(var i=0; i<positions.length; i++) {
		jQuery('body').append("<div class='particle' id='particle-" + i + "'>&nbsp;</div>");
		jQuery('.particle:last').data('count', 0).data('id', i).loop();
		
		
		/*
		var stars = document.getElementById('particle-' + i);		
		for(var i2=0; i2<positions[i].length; i2++) {
			
			console.log(positions[i][i2]["props"]['left']);
			
			var moveX = {type: 'left', to: positions[i][i2]["props"]['left'], step: 1, delay: 20};
			var moveY = {type: 'top', to: positions[i][i2]["props"]['top'], step: 1, delay: 20};
			var opacity = {type: 'opacity', to: positions[i][i2]["props"]['opacity'], step: 1, delay: 20};
			$fx(stars).fxAdd(moveX).fxAddSet().fxAdd(moveY).fxAddSet().fxAdd(opacity).fxRun(null, -1);;
		}
		
		$fx(stars).fxRun(null, -1);
		
		//alert(stars);
		//$fx(stars[1]).fxAdd(moveBg1).fxRun(null, -1);
		
		*/
	}
	
	

});	


//Loop
jQuery.fn.loop = function(){		

	var count = jQuery(this).data('count');
	var i = jQuery(this).data('id');
	
	//console.log(count);
	
	jQuery(this).animate(positions[i][count].props, positions[i][count].time, 'linear', jQuery.fn.loop);
	jQuery(this).data('count', (count+1)%(positions[i].length));
	
	return this;
}	
;

