
document.documentElement.className += 'active';

(function($) {
$.fn.setImage;		  
$.fn.quartzslider = function(options){
	var defaults = {
		              time:4000,
					  width:600,
					  height:400,
					  maskbg:'#ffffff',
					  maskborder:'none',
					  effect:'none',
					  blocksize: {height:'',width:'' },
					  maskInduration:300,
					  maskOutduration:900,
					  mode:"html5",
					  controls:true,
					  customblocksize:{
						 
						  // image transitions global settings
						  cubeoutcenter:{  height:130,width:130},
						  cubegrow:{ height:130,width:130 },
						  cubesidegrow:{ height:130,width:130 },
						  stripalternate:{ height:100,width:60 },
						  stripfade:{ height:100,width:60 },
						  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 = li.find("img");
	
    var pos,random_no,timer,image_timer,arr,index,block,w,h,src,parent,im,override=false,in_animation = false,controls,canvas,html5_flag=false,imageData,canvas,context;
	var current = li.eq(1).toggleClass('active'),prev = li.first().addClass("reset");
	var bool = true,first_bool = true;
	
	// -------------------- Initialization ---------------------		
	li.first().find("span").css("display","block");
	
	// ------------------- Setting slider content [ for this version images ]-----------------------
	type= "img";
	
	
	current.children(type).hide();
	
	// ------------------- Checking HTML5 canvas support -----------------------
	 canvas = document.createElement('canvas');
    if (!canvas.getContext) {
      options.mode= "default";
	  
	   if(!isNaN(options.effect)&&parseInt(options.effect)>=7)
	   options.effect='none';
	   
    }
	
		
		
	init();

	function init(){
	
	if(options.controls==true)
	{
		appendControls();
	}
	
	
	root.wrap("<div class='quartz' />");
	root.parent().css({"width":options.width,height:options.height});
	li.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]);
		 
		 
		
			 
		 
	 }
	
	
	 // 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)
				{endeffect(image);
					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)
				{ endeffect(image);
					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)
				{
				 endeffect(image);
					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)
				{
				endeffect(image);
					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)
				{
				endeffect(image);
					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)
				{
				endeffect(image);
					return;
				}
									 
				arr[i++].stop(true,true).animate({opacity:1,marginTop:0},{duration: 700, easing:'easeOutBack'});
				
				},60);
		
							},1000);
		
	};	
	
	
	// -------------------- HTML5 canvas effects ------------------------
	
	function bluechannel(image)
	{
		in_animation = true;html5_flag = 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,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		        
			
				arr[index] = block.clone().css({top:i});
				arr[index].html("<canvas width="+options.width+" height="+options.height+" id='sl5' />");
				 parent.append( arr[index]);
				if(current.prev().length>0)
		image = current.find("img")[0];
		else
		image = current.find("img")[0];
	
		
		
		 canvas = document.getElementById('sl5');
		 context = canvas.getContext('2d');
       
	     context.drawImage(image, 0, 0);
         imageData    = context.getImageData(0,0,canvas.width,canvas.height),
		data        = imageData.data;


        for(var i = 0,z=data.length;i<z;i++){

            // The values for red, green and blue are consecutive elements
            // in the imageData array. We modify the three of them at once:

             data[i] = data[i+2] ;
            data[++i] = data[i+1] ;
            data[++i] = data[i] ;
 			data[++i] = 255;
			
			
          
        }

        // Putting the modified imageData back on the canvas.
        context.putImageData(imageData,0,0,0,0,imageData.width,imageData.height);
			$("#sl5").show();	
			arr[index++].fadeIn("slow");		
				
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				image = im;
				if(i>=arr.length)
				{ endeffect(image);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);
		
		
	}
	
	
	function greenchannel(image)
	{
		in_animation = true;html5_flag = 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,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		        
			
				arr[index] = block.clone().css({top:i});
				arr[index].html("<canvas width="+options.width+" height="+options.height+" id='sl5' />");
				 parent.append( arr[index]);
				if(current.prev().length>0)
		image = current.find("img")[0];
		else
		image = current.find("img")[0];
	
		
		
		var canvas = document.getElementById('sl5');
		var context = canvas.getContext('2d');
       
	    context.drawImage(image, 0, 0);
        var imageData    = context.getImageData(0,0,canvas.width,canvas.height),
		data        = imageData.data;

        for(var i = 0,z=data.length;i<z;i++){

            // The values for red, green and blue are consecutive elements
            // in the imageData array. We modify the three of them at once:

             data[i] = data[i+1] ;
            data[++i] = data[i] ;
            data[++i] = data[i-1] ;
 			data[++i] = 255;
			
			
          
        }

         // Putting the modified imageData back on the canvas.
        context.putImageData(imageData,0,0,0,0,imageData.width,imageData.height);
			$("#sl5").show();	
			arr[index++].fadeIn("slow");		
				
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				image = im;
				if(i>=arr.length)
				{ endeffect(image);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);
	}
	
	
	
	function redchannel(image)
	{
		in_animation = true;html5_flag = 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,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		        
			
				arr[index] = block.clone().css({top:i});
				arr[index].html("<canvas width="+options.width+" height="+options.height+" id='sl5' />");
				 parent.append( arr[index]);
				if(current.prev().length>0)
		image = current.find("img")[0];
		else
		image = current.find("img")[0];
	
		
		
		var canvas = document.getElementById('sl5');
		var context = canvas.getContext('2d');
       
	    context.drawImage(image, 0, 0);
        var imageData    = context.getImageData(0,0,canvas.width,canvas.height),
		data        = imageData.data;



        for(var i = 0,z=data.length;i<z;i++){

            // The values for red, green and blue are consecutive elements
            // in the imageData array. We modify the three of them at once:

              data[i] = data[i] ;
            data[++i] = data[i-1] ;
            data[++i] = data[i-2] ;
 			data[++i] = 255;
			
			
          
        }

         // Putting the modified imageData back on the canvas.
        context.putImageData(imageData,0,0,0,0,imageData.width,imageData.height);
			$("#sl5").show();	
			arr[index++].fadeIn("slow");		
				
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				image = im;
				if(i>=arr.length)
				{ endeffect(image);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);
	}
	
	
	function overlay(image)
	{
		in_animation = true;html5_flag = 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,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		        
			
				arr[index] = block.clone().css({top:i});
				arr[index].html("<canvas width="+options.width+" height="+options.height+" id='sl5' />");
				 parent.append( arr[index]);
				if(current.prev().length>0)
		image = current.find("img")[0];
		else
		image = current.find("img")[0];
	
		
		
		var canvas = document.getElementById('sl5');
		var context = canvas.getContext('2d');
       
	    context.drawImage(image, 0, 0);
        var imageData    = context.getImageData(0,0,canvas.width,canvas.height),
		data        = imageData.data;



        for(var i = 0,z=data.length;i<z;i++){

            // The values for red, green and blue are consecutive elements
            // in the imageData array. We modify the three of them at once:

             data[i] = data[i] < 128 ? ( 2 * data[i] *  data[i] ) / 255 : 255 - ( 2 * ( 255 - data[i]) * ( 255 -  data[i] ) / 255 );
            data[++i] =  data[i] < 128 ? ( 2 * data[i] *  data[i] ) / 255 : 255 - ( 2 * ( 255 - data[i] ) * ( 255 -  data[i] ) / 255 );
            data[++i] =  data[i] < 128 ? ( 2 * data[i] *  data[i] ) / 255 : 255 - ( 2 * ( 255 - data[i] ) * ( 255 -  data[i] ) / 255 );
 			data[++i] = 255;
			
			
          
        }

         // Putting the modified imageData back on the canvas.
        context.putImageData(imageData,0,0,0,0,imageData.width,imageData.height);
			$("#sl5").show();	
			arr[index++].fadeIn("slow");		
				
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				image = im;
				if(i>=arr.length)
				{ endeffect(image);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);
	}
	
	
	
	function colorburn(image)
	{
		in_animation = true;html5_flag = 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,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		        
			
				arr[index] = block.clone().css({top:i});
				arr[index].html("<canvas width="+options.width+" height="+options.height+" id='sl5' />");
				 parent.append( arr[index]);
				if(current.prev().length>0)
		image = current.find("img")[0];
		else
		image = current.find("img")[0];
	
		
		
		var canvas = document.getElementById('sl5');
		var context = canvas.getContext('2d');
       
	    context.drawImage(image, 0, 0);
        var imageData    = context.getImageData(0,0,canvas.width,canvas.height),
		data        = imageData.data;



        for(var i = 0,z=data.length;i<z;i++){

            // The values for red, green and blue are consecutive elements
            // in the imageData array. We modify the three of them at once:

             data[i] =     data[i] <= 0? 0 : Math.max(255 - ((255 -  data[i]) * 255 /  data[i]), 0);
            data[++i] =  data[i] <= 0? 0 : Math.max(255 - ((255 -  data[i]) * 255 /  data[i]), 0);
            data[++i] =   data[i] <= 0? 0 : Math.max(255 - ((255 -  data[i]) * 255 /  data[i]), 0);
 			data[++i] = 255;
			
			
          
        }

        // Putting the modified imageData back on the canvas.
       // Putting the modified imageData back on the canvas.
        context.putImageData(imageData,0,0,0,0,imageData.width,imageData.height);
			$("#sl5").show();	
			arr[index++].fadeIn("slow");		
				
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				image = im;
				if(i>=arr.length)
				{ endeffect(image);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);
	}
	function screene(image)
	{
		in_animation = true;html5_flag = true;
	   in_animation = true;html5_flag = 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,
						zIndex:99,
						display:'none'
						}
							
							}).addClass('disblock');
		
		        
			
				arr[index] = block.clone().css({top:i});
				arr[index].html("<canvas width="+options.width+" height="+options.height+" id='sl5' />");
				 parent.append( arr[index]);
				if(current.prev().length>0)
		image = current.find("img")[0];
		else
		image = current.find("img")[0];
		
		
		var canvas = document.getElementById('sl5');
		var context = canvas.getContext('2d');
       
	    context.drawImage(image, 0, 0);
        var imageData    = context.getImageData(0,0,canvas.width,canvas.height),
		data        = imageData.data;

        for(var i = 0,z=data.length;i<z;i++){

            // The values for red, green and blue are consecutive elements
            // in the imageData array. We modify the three of them at once:
 data[i] =    255 - ( ( 255 - data[i] ) * ( 255 - data[i] ) ) / 255;
            data[++i] =   255 - ( ( 255 - data[i] ) * ( 255 - data[i] ) ) / 255;
            data[++i] =   255 - ( ( 255 - data[i] ) * ( 255 - data[i] ) ) / 255;
 			data[++i] = 255;
			
			
          
        }

        // Putting the modified imageData back on the canvas.
        // Putting the modified imageData back on the canvas.
        context.putImageData(imageData,0,0,0,0,imageData.width,imageData.height);
			$("#sl5").show();	
			arr[index++].fadeIn("slow");		
				
		setTimeout( function (){ im.show(); 
		i=0;
		
	    timer = setInterval(function(){
				image = im;
				if(i>=arr.length)
				{ endeffect(image);
					return;
				}
									 
				
				arr[i].stop(true,true).fadeOut(options.maskOutduration,function(){ $(this).remove();   });
				i++;
				},80);
		
		},1500);
	}
	
	function endeffect(image)
	{
		
		
		 current.find("span").fadeIn('slow');
					if(options.controls==true)
					 {
					 controls.removeClass("control_active");
					 controls.eq(current.index(".quartz li")).addClass("control_active");
					 }
					clearInterval(timer);
				
					if(html5_flag==true)
				{
					 // show the real image
				   image.show();
					$(".disblock").fadeOut(200,function(){
					$(this).remove();
					
					});
				
					in_animation = false;
						if(override==false) // Return if manually triggered
						image_timer = setTimeout(function() {   switcher(); image.next().fadeOut('slow'); effects();  },options.time); 	
				
						
					html5_flag=false;
						
						
				}
				else	
				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);
						
						
	};
	
	
	// -------------------- Effects selector module ---------------------		
	function effects()
	{
		 
		  var ch = Math.floor(Math.random()* 13);
		
		if(options.mode=="html5")
		ch = Math.floor(Math.random()* 6) + 7;
		else if((options.mode=="default"))
		ch = Math.floor(Math.random()* 7);
		
		
		   if(!isNaN(options.effect))
		   ch = options.effect;
		  
		  if(bool==true)
		{
			li.first().find("span").hide();
			bool=false;
			 first_bool = false;
		}
		 
		 switch(ch)
		 {
		 case 0:$(current.children(type)).fadeIn("slow",function(){
			 
			 endeffect($(this));
			  
			 });break;
		 case 1:cubeoutcenter(current.find("img"));break;
		 case 2:cubegrow(current.find("img"));break;
		 case 3:stripalternate(current.find("img"));break;
		 case 4:stripfade(current.find("img"));break;
		 case 5:striphalffade(current.find("img"));break;
		 case 6: cubesidegrow(current.find("img"));break;
		 case 7: bluechannel(current.find("img"));break;
		  case 8: redchannel(current.find("img"));break;
		   case 9: greenchannel(current.find("img"));break;
		   case 10: overlay(current.find("img"));break;
		   case 11: colorburn(current.find("img"));break;
		   case 12: screene(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.first().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(".quartz ul li")==index)
		return;
		
		
		
		li.removeClass("reset active");
		
		current.find("span").hide();	
		
		clearTimeout(image_timer); // Manual Override...
		
		if(first_bool==true)
		{
			
			li.first().addClass("reset");
		}
		
		current.addClass("reset");
		prev = current;
		current = li.eq(index).addClass("active");
		
		current.children().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. 
 *
 */
 
 

