
document.documentElement.className += 'active';

(function($) {
$.fn.setImage;		  
$.fn.nirvanaslider = function(options){
	var defaults = {
		              time:2000,
					  width:883,
					  height:273,
					  maskborder:'none',
					  effect:'none',
					  blocksize: {height:'',width:'' },
					  maskInduration:300,
					  maskOutduration:300,
					  mode:"images",
					  controls:false,
					  customblocksize:{
						  // mask transitions global settings
						  maskcube:{ height:100,width:100 },
						  maskvertical:{ height:100,width:50 },
						  maskhorizontal:{ height:60,width:100 },
						  maskcube2:{ height:100,width:100 },
						  maskverticalstrip:{ height:100,width:70 },
						  // image transitions global settings
						  cubeoutcenter:{ height:100,width:100 },
						  cubegrow:{ height:100,width:100 },
						  cubesidegrow:{ height:100,width:100 },
						  stripalternate:{ height:100,width:40 },
						  stripfade:{ height:273,width:838 },
						  striphalffade:{ height:100,width:40 }
						  
						  
						  },
					  callback:function(){   } 
					  
					  
					};
	
	
	var options = $.extend(defaults, options);
	// Variables declaration and precaching
	
	return this.each(function()
		{
			
	// -------------------- Declaring variables ---------------------		
	var root = $(this);
	var li = root.find("li");
	var images;
	
    var type,pos,random_no,timer,image_timer,arr,index,block,w,h,src,parent,im,override=false,in_animation = false,controls;
	var prev,current = li.first().toggleClass('active');
	
	// -------------------- Initialization ---------------------		
	li.last().addClass("reset");
	if(options.mode=="images")
	type= "img";
	else
	{
	type= "div";
	li.children().addClass('inline');
	li.children().css("height",options.height);
	}
	current.children(type).hide();
	init();

	function init(){
	
	if(options.controls==true)
	{
		appendControls();
	}
	current.find("span").fadeIn('fast');
	
	root.wrap("<div class='nirvana' />");
	root.parent().css({"width":options.width,height:options.height});
	
	if(options.mode=="images")
	images = li.find("img");
	else
	image = li.find("div");
	
	// -------------------- Slide switching module ---------------------		
	 function switcher()
	 {
		 if(current.prev().length>0)
		 prev = current.prev();
		 else
		 prev = li.last();
		  
		 prev.removeClass("reset");
		
		 current.toggleClass("active reset");
		 
		 if(current.next().length>0)         // setting the next slide
		 current = current.next();
		 else
		 current = li.first(); 
		 
		current.children(type).hide();
	
		 current.addClass("active");
		
		 options.callback(current.children(type)[0]);
		 
		 
		
			 
		 
	 }
	
	// ------------------- Masking Transitions applicable to div images etc ------------
	
	 
	function Maskcube(image)
	{
		in_animation = true;
		 im = image;
		 
		 if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.maskcube.width);
		 h = Math.floor(options.customblocksize.maskcube.height);	 
		 }
		 
		
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:h,
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
		    j=0;
			while(j<options.height)
			{
				
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px "+-j+"px" });
				 parent.append( arr[index++] );
				
			j = j + h;
			}
			
			i = i + w;
		 }
		 //.show({ duration:4+i*5,easing:'easeOutSine' })
		 
		 i=0;
		setTimeout( function (){ 
							  
			timer =	setInterval(function(){
									if(i>=arr.length)
									{
										clearInterval(timer);
										setTimeout(function(){ animateout(); },300);
										return;
									}
								arr[i++].fadeIn({ duration:options.maskInduration,easing:'easeOutSine' })
								
									 },60);			  
							  
							  
							  },200);
		
		function animateout()
		{
		im.fadeIn(500); 
		i=0;
		random_no = random_array(arr.length);
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			
			 
		 }
					clearInterval(timer);
					
					setTimeout(function(){
						in_animation = false;	
						$(".disblock").remove();
						
						
						if(override==false)
						{
							
							image_timer = setTimeout(function() {  switcher();  image.next().fadeOut('slow'); effects();  },options.time); 
						}
						},2000);
					return;
				}
									 
				
				arr[random_no[i]].stop(true,true).fadeOut({duration:options.maskOutduration,easing:'easeInSine'});
				i++;
				},80);
		
		
		}
		
		
	  };	
	  
	 function Maskvertical(image)
	{
		in_animation =true;
		 im = image;
		
		
			 if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.maskvertical.width);
		 h = Math.floor(options.customblocksize.maskvertical.height);	 
		 }
		
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:options.height,
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px 0px" });
				 parent.append( arr[index++].fadeIn(i*5+4));
			
			i = i + w;
		 }
		 
		setTimeout( function (){ im.fadeIn(500); 
		i=0;
		
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
		
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						
						$(".disblock").remove();
						in_animation =false;
						
						if(override==false)
						image_timer = setTimeout(function() { switcher();  effects(); image.next().fadeOut('slow'); },options.time); 
						},2000);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(2000);
				i++;
				},80);
		
		},1500);
		
	  };
	  
	function Maskhorizontal(image)
	{
		in_animation =true;
		 im = image;
		
		
			 if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.maskhorizontal.width);
		 h = Math.floor(options.customblocksize.maskhorizontal.height);	 
		 }
		
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:options.width,
						height:h,
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.height)
		 {
			
				arr[index] = block.clone().css({top:i });
				 parent.append( arr[index++].fadeIn(i*3+4));
			
			i = i + h;
		 }
		 
		setTimeout( function (){ 
		i=0;
		 im.fadeIn(500); 
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						
						$(".disblock").remove();
						in_animation =false;
						
						if(override==false)
						image_timer = setTimeout(function() { switcher();  effects(); image.next().fadeOut('slow'); },options.time); 
						},2000);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(2000);
				i++;
				},80);
		
		},1500);
		
	  };	
	  
	 function Maskfull(image)
	{
		in_animation = true;
		 im = image;
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:options.width,
						height:options.height,
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
			
				arr[index] = block.clone().css({top:i});
				 parent.append( arr[index++].fadeIn(options.maskInduration));
			
			
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},2000);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);					
				
	  };
	  
	 function Maskcube2(image)
	{
			in_animation = true;
		 im = image;
		 if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.maskcube2.width);
		 h = Math.floor(options.customblocksize.maskcube2.height);	 
		 }
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:h,
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
		    j=0;
			while(j<options.height)
			{
				
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px "+-j+"px" });
				 parent.append( arr[index++] );
				
			j = j + h;
			}
			
			i = i + w;
		 }
		 //.show({ duration:4+i*5,easing:'easeOutSine' })
		 
		 i=0;
		setTimeout( function (){ 
							  
			timer =	setInterval(function(){
									if(i>=arr.length)
									{ current.find("span").fadeIn('slow');
										clearInterval(timer);
										setTimeout(function(){ animateout(); },300);
										return;
									}
								arr[i++].show({ duration:options.maskInduration,easing:'easeOutSine' })
								
									 },92);			  
							  
							  
							  },200);
		
		function animateout()
		{
		im.fadeIn(500); 
		i=0;
		random_no = random_array(arr.length);
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					
					setTimeout(function(){
						in_animation = false;	
						$(".disblock").remove();
						
						
						if(override==false)
						{
							
							image_timer = setTimeout(function() {  switcher();  image.next().fadeOut('slow'); effects();  },options.time); 
						}
						},2000);
					return;
				}
									 
				
				arr[random_no[i]].stop(true,true).hide({duration:options.maskOutduration,easing:'easeInSine'});
				i++;
				},80);
		
		
		}	
		
	  };	
	  
	function Maskverticalstrip(image)
	{
		in_animation =true;
		 im = image;
		  if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.maskverticalstrip.width);
		 h = Math.floor(options.customblocksize.maskverticalstrip.height);	 
		 }
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:options.height,
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px 0px" });
				 parent.append( arr[index++].fadeIn(i*5+4));
			
			i = i + w;
		 }
		 
		setTimeout( function (){ im.fadeIn(500); 
		i=0;
		random_no = random_array(arr.length);
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						
						$(".disblock").remove();
						in_animation =false;
						
						if(override==false)
						image_timer = setTimeout(function() { switcher();  effects(); image.next().fadeOut('slow'); },options.time); 
						},2000);
					return;
				}
						
						
						arr[random_no[i]].stop(true,true).fadeOut(800);
				
				
				i++;
				},60);
		
		},1500);
		
	  }; 
	  
	 // Default Image animations --------------------- Applicable to images only !!!!! --------------------------
	 function cubeoutcenter(image)
	{
		in_animation = true;
		if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.cubeoutcenter.width);
		 h = Math.floor(options.customblocksize.cubeoutcenter.height);	 
		 }
		 parent = image.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = image.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:0,
						height:0,
						marginTop:h/2,
						marginLeft: w/2,
						'background-image':'url('+src+')',
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
		    j=0;
			while(j<options.height)
			{
				
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px "+-j+"px" });
				parent.append(arr[index++]);
			j = j + h;
			}
			
			i = i + w;
		 }
		 
		i=0;
		
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},1000);
					return;
				}
									 
				arr[i++].animate({height:h,width:w,marginTop:0,marginLeft:0},{duration: options.maskOutduration, easing:'easeOutSine'});
				
				},80);
		
			
		
		
	};		

	 function cubegrow(image)
	{
		in_animation = true;
		 im = image;
		if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.cubegrow.width);
		 h = Math.floor(options.customblocksize.cubegrow.height);	 
		 }
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:0,
						height:0,
						'background-image':'url('+src+')',
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
		    j=0;
			while(j<options.height)
			{
				
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px "+-j+"px" });
				parent.append(arr[index++]);
			j = j + h;
			}
			
			i = i + w;
		 }
		 
		i=0;
		random_no = random_array(arr.length);
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{ current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},1000);
					return;
				}
									 
				arr[i++].animate({height:h,width:w},{duration: options.maskOutduration, easing:'easeOutSine'});
				
				},80);
		
	  	
	};	
	
	function cubesidegrow(image)
	{
		 im = image;
		if(options.blocksize.width!=''){
		 w = Math.floor(options.blocksize.width);
		 h = Math.floor(options.blocksize.height);
		 }
		 else
		 {
		w = Math.floor(options.customblocksize.cubesidegrow.width);
		 h = Math.floor(options.customblocksize.cubesidegrow.height);	 
		 }
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:0,
						height:0,
						opacity:0,
						top:options.height,
						'background-image':'url('+src+')',
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99
						
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
		    j=0;
			while(j<options.height)
			{
				
				arr[index] = block.clone().css({left:i ,top:j,backgroundPosition:-i+"px "+-j+"px" });
				parent.append(arr[index++]);
			j = j + h;
			}
			
			i = i + w;
		 }
		 
		i=0;
		random_no = random_array(arr.length);
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{
				 current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},1000);
					return;
				}
									 
				arr[random_no[i++]].animate({height:h,width:w,opacity:1},{duration: options.maskOutduration, easing:'easeOutCubic'});
				
				},80);
		
	};	
	 
	function stripalternate(image)
	{
		in_animation = true;
		 im = image;
			if(options.blocksize.width!='')
		w = Math.floor(options.blocksize.width);
		else
		w = Math.floor(options.customblocksize.stripfade.width);
		
		h = options.height;
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 var css,flag=true;
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:h,
						'background-image':'url('+src+')',
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'block',
						marginTop:options.height,
						opacity:0
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
			if(flag==true)
		   	{
				css = {left:i ,backgroundPosition:-i+"px 0px" };
				flag = false;
			}
			else
			{
				css = {left:i ,backgroundPosition:-i+"px 0px",marginTop:-options.height };
				flag = true;
			}
			arr[index] = block.clone().css(css);
			parent.append(arr[index++]);
			
			i = i + w;
		 }
		 
		i=0;
		random_no = random_array(arr.length);
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{
				 current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},1000);
					return;
				}
									 
				arr[i++].animate({marginTop:0,opacity:1},{duration:options.maskOutDuration, easing:'easeOutSine'});
				
				},80);
		
		
	};	
	
	
	function stripfade(image)
	{
		in_animation = true;
		 im = image;
		 
		if(options.blocksize.width!='')
		w = Math.floor(options.blocksize.width);
		else
		w = Math.floor(options.customblocksize.stripfade.width);
		
		h = options.height;
		
		
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:h,
						'background-image':'url('+src+')',
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'block',
						opacity:0
						
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			
		   	
			arr[index] = block.clone().css({left:i ,backgroundPosition:-i+"px 0px" });
			parent.append(arr[index++]);
			
			i = i + w;
		 }
		 
		i=0;
		
		setTimeout(function(){
							
	    timer = setInterval(function(){
		
				if(i>=arr.length)
				{
				 current.find("span").fadeIn('slow');
					if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},1000);
					return;
				}
									 
				arr[i++].stop(true,true).animate({opacity:1},{duration: 700, easing:'easeOutSine'});
				
				},60);
		
							},500);
		
	};	
	
	function striphalffade(image)
	{
		
		in_animation = true;
		 im = image;
				if(options.blocksize.width!='')
		w = Math.floor(options.blocksize.width);
		else
		w = Math.floor(options.customblocksize.stripfade.width);
		
		h = options.height;
		 parent = im.parent();
		 arr = new Array(); i =0;  j =0; index = 0;
		 var css;
		 src = im.attr("src");
		 block = $("<div />",{
					css:{
						position:"absolute",
						width:w,
						height:h/2,
						'background-image':'url('+src+')',
						'background-color':options.maskbg,
						'border':options.maskborder,
						zIndex:99,
						display:'block',
						opacity:0
						
						}
							
							}).addClass('disblock');
		
		
		 while(i<options.width)
		 {
			j=0;
			while(j<h)
			{
				
			if(j==0)
			css ={left:i,top:j ,backgroundPosition:-i+"px "+(-j)+"px" ,marginTop: -(h/2)};
			else
			css ={left:i,top:j ,backgroundPosition:-i+"px "+(-j)+"px" ,marginTop: h};
			
			arr[index] = block.clone().css(css);
			parent.append(arr[index++]);
			j = j + h/2;
			}
			i = i + w;
		 }
		 
		i=0;
		
		setTimeout(function(){
							
	    timer = setInterval(function(){
				
				if(i>=arr.length)
				{
				 current.find("span").fadeIn('slow');	
		  if(options.controls=true)
		 {
			 
		 }
					clearInterval(timer);
					setTimeout(function(){
						image.show(); // show the real image
						$(".disblock").remove(); // remove the divs
						 // switch next slide
						in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 
						},500);
					return;
				}
									 
				arr[i++].stop(true,true).animate({opacity:1,marginTop:0},{duration: 700, easing:'easeOutBack'});
				
				},60);
		
							},1000);
		
	};	
	
	// -------------------- Effects selector module ---------------------		
	function effects()
	{
		 
		  var ch = Math.floor(Math.random()* 9);
		  
		  if(type=="div")
		  {
		 
		  ch = Math.floor(Math.random()* 6);
		  }
		   if(!isNaN(options.effect))
		   ch = options.effect;
		  
		 
		 
		 switch(ch)
		 {
		 case 0:Maskcube2(current.children(type));break; 
		 case 1:Maskcube(current.children(type));break;
		 case 2:Maskvertical(current.children(type));break;
		 case 3:Maskhorizontal(current.children(type));break;
		 case 4:Maskfull(current.children(type));break;
		 case 5:Maskverticalstrip(current.children(type));break;
		 case 6:cubesidegrow(current.find("img"));break;
		 case 7:cubeoutcenter(current.find("img"));break;
		 case 8:cubegrow(current.find("img"));break;
		 case 9:stripalternate(current.find("img"));break;
		 case 10:stripfade(current.find("img"));break;
		 case 11:striphalffade(current.find("img"));break;
		 }
	}
	
	// -------------------- Method to set Specific image and controls ---------------------			
     
	 function appendControls()
	 {
		var str = "<ul class='controls'>";
		for(var i=0;i<li.length;i++)
		str = str + "<li>"+(i+1)+"</li>";
		str = str+"</ul>";
		
		 root.after(str);
		 
		 controls = root.parent().find(".controls li");
		controls.last().addClass("control_active");
		
		controls.bind({
		click:function(){ setImage($(this).index()); 	},
		mouseover:function(){ $(this).toggleClass("control_hover"); },
		mouseout:function(){ $(this).toggleClass("control_hover"); }
		  });
		 
		
	 }
	 
     function setImage(index)
	{
		
	    if(in_animation==true||current.index(".nirvana ul li")==index)
		return;
		li.removeClass("reset active");
		current.find("span").hide();	
		
		clearInterval(image_timer); // Manual Override...
		
		current.addClass("reset");
		
		current = li.eq(index).addClass("active");
		current.children(type).hide();
		current.find("span").fadeIn(700);	
		
		override = true;
		
		effects();
	
	}
	
	
	
		//switcher();
	 image_timer = setTimeout(function() {   effects();  },options.time);  // Starting the Slideshow
	
	}
	
	
		});
	
} 


function random_array(maxn)
 {
	
    var array = new Array();
	var temp,i,flag=true;
	var index =0;
	 while(index<maxn)
	 {
		 flag = true;
		 temp = Math.floor(Math.random() * maxn);
		 for(i=0;i<array.length;i++)
		 {
			 if(temp==array[i])
			 {
				flag=false;
				break;
			 }
		 }
		 
		 if(flag==true)
		 array[index++] = temp;
	 }
	 
	 return array;
 };

		  })(jQuery);





jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	
	
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	
	
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	}
	
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
 
