//// JQUERY PLUGIN - EASING
$jYtc.easing={easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var a=t-d/2;return-2*c*a*a/(d*d)+2*c*a/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}if(t<d/2)return a*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return a*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-$jYtc.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return $jYtc.easing['bouncein'](x,t*2,0,c,d)*.5+b;return $jYtc.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}};

//// GANESH PLUGIN - jCarouselLite
(function($) {                                          // Compliant with jquery.noConflict()
$.fn.jCarouselLite = function(o) {
    o = $.extend({
        tabslider_btnPrev: null,
        tabslider_btnNext: null,
        tabslider_btnGo: null,
        mouseWheel: false,
        auto: 0,
        speed: 0,
        easing: null,
        vertical: false,
        circular: true,
        visible: 3,
        start: 0,
        scroll: 1,
        beforeStart: null,
        afterEnd: null,
        moduleId: 0,
        catId: 0,
        numberRow: 0,
		numimage: 0
    }, o || {});

    return this.each(function() {                           // Returns the element collection. Chainable.
		
        var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
        var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

        if(o.circular) {
            ul.prepend(tLi.slice(tl-v-1+1).clone())
              .append(tLi.slice(0,v).clone());
            o.start += v;
        }
        
		
        var buttons = $("#tabslider_image_button"+o.numimage+o.moduleId).children('li');
        $.each(buttons, function(key, val){
            var keyVal = ++key;			
            $(val).click(function() {							
				return go(keyVal);
			});
			
        })
       
        var parentUl = ul.parent('div');
        //var heightDivParent = parseInt(height(div));
        //alert(heightDivParent);
        var li = $("li", ul), itemLength = li.size(), curr = o.start;
        div.css("visibility", "visible");
        var lis = ul.children('li');
       
        li.css({overflow: "hidden", float: o.vertical ? "none" : "none"});
        ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
        div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});
        var heightDiv = parseInt(height(li));
        li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});  
		//heightDiv+=5;
        
        //parentUl.css({height: heightDiv});
        /*
        BrowserDetect.init();
        
        if(BrowserDetect.browser=="Chrome")
        {
            div.css({ position: "relative", "z-index": "2", left: "0px", height: heightDiv+"px"});
        }
        */
       
            
        //set height for each li
        
        /*
         for(var i=0;i<li.length;i++)
                 {
                   $(li[i]).css({height:heightDiv});           
                 }
         */
        BrowserDetect.init();
        var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
        var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
        var divSize = liSize * v;                      // size of entire div(total length for just the visible items)
        //alert(liSize +"---"+ v)
        
        if((BrowserDetect.browser=="Explorer") && (BrowserDetect.version==6))
        {
            var arrTabHeightIe6 = $('div.wrap-items-ie6'+o.catId+'_'+o.moduleId);
            var maxHeightIe6 = 0;
            $.each(arrTabHeightIe6,function(key, val){
                if(maxHeightIe6<$(val).height()){
                    maxHeightIe6 = $(val).height(); 
                }
              
            });
            //alert(o.catId+'_'+o.moduleId)
            $.each(arrTabHeightIe6,function(key,val){
                 $(val).css('height',maxHeightIe6);       
            });
           // $('div.lite_multi_ie6'+o.catId+'_'+o.moduleId).css('height',((maxHeightIe6 * numberRow + 10)+'px'));
            $('div.lite_multi_ie6'+o.catId+'_'+o.moduleId).css('height',(maxHeightIe6 * o.numberRow) +'px');
            
        }
        
        if((BrowserDetect.browser=="Explorer") && (BrowserDetect.version==6))
        {
            li.css({width: (li.width()+1), height: parseInt(heightDiv)});
            
        }
        else
            {li.css({width: li.width(), height: parseInt(heightDiv)});}
           
        //alert(ulSize)       
        ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
        
            div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images     
        
        if(o.tabslider_btnPrev)
            $(o.tabslider_btnPrev).click(function() {
                return go(curr-o.scroll);
            });

        if(o.tabslider_btnNext)
            $(o.tabslider_btnNext).click(function() {
                return go(curr+o.scroll);
            });

        /*if(o.tabslider_btnGo)
            $.each(o.tabslider_btnGo, function(i, val) {
                $(val).click(function() {
                    return go(o.circular ? o.visible+i : i);
                });
            });
*/
        if(o.mouseWheel && div.mousewheel)
            div.mousewheel(function(e, d) {
                return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
            });

        if(o.auto)
            setInterval(function() {
                go(curr+o.scroll);
            }, o.auto+o.speed);
        
        function setCssDiv(){
                   
        };
        
        function vis() {
            return li.slice(curr).slice(0,v);
        };

        function go(to) {//alert('#tabslider_image_button'+o.numimage+o.moduleId);
            var countslide
            var buttons = $('#tabslider_image_button'+o.numimage+o.moduleId).children();
            var lengthButtons = buttons.length;
           
            $.each(buttons , function(key, val){++key;//alert($(val).hasClass('tabslider_button_img_selected'));
                if($(val).hasClass('tabslider_button_img_selected'+o.moduleId))
                {
                    $(val).removeClass("tabslider_button_img_selected"+o.moduleId);$(val).addClass("tabslider_button_img"+o.moduleId);
                }
                if(to==key)
                {
                    $(val).removeClass("tabslider_button_img"+o.moduleId);$(val).addClass("tabslider_button_img_selected"+o.moduleId);
                }
                if(to==0)
                {
                    if(key == lengthButtons)
                        $(val).removeClass("tabslider_button_img"+o.moduleId);$(val).addClass("tabslider_button_img_selected"+o.moduleId);
                }
                if(to==-1)
                {
                    if(key == (lengthButtons-1))
                        $(val).removeClass("tabslider_button_img"+o.moduleId);$(val).addClass("tabslider_button_img_selected"+o.moduleId);
                }
                
                if(to == (lengthButtons+1))
                {
                    if(key == 1)
                        $(val).removeClass("tabslider_button_img"+o.moduleId);$(val).addClass("tabslider_button_img_selected"+o.moduleId);
                }
                
                if(to == (lengthButtons+2))
                {
                    if(key == 2)
                        $(val).removeClass("tabslider_button_img"+o.moduleId);$(val).addClass("tabslider_button_img_selected"+o.moduleId);
                }
            
            });
            if(!running) {

                if(o.beforeStart)
                    o.beforeStart.call(this, vis());

                if(o.circular) {            // If circular we are in first or last, then goto the other end
                    if(to<=o.start-v-1) {           // If first, then goto last
                        ul.css(animCss, -((itemLength-(v*2))*liSize)+"px");
                        // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                        curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll;
                    } else if(to>=itemLength-v+1) { // If last, then goto first
                        ul.css(animCss, -( (v) * liSize ) + "px" );
                        // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
                        curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
                    } else curr = to;
                } else {                    // If non-circular and to points to first or last, we just return.
                    if(to<0 || to>itemLength-v) return;
                    else curr = to;
                }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                running = true;

                ul.animate(
                    animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
                    function() {
                        if(o.afterEnd)
                            o.afterEnd.call(this, vis());
                        running = false;
                    }
                );
                // Disable buttons when the carousel reaches the last/first, and enable when not
                if(!o.circular) {
                    $(o.tabslider_btnPrev + "," + o.tabslider_btnNext).removeClass("disabled");
                    $( (curr-o.scroll<0 && o.tabslider_btnPrev)
                        ||
                       (curr+o.scroll > itemLength-v && o.tabslider_btnNext)
                        ||
                       []
                     ).addClass("disabled");
                }

            }
            return false;
        };
    });
};

function css(el, prop) {
    return parseInt($.css(el[0], prop)) || 0;
};
function width(el) {
    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
};
function height(el) {		
	return el.offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
};

function height(el) {
    BrowserDetect.init();
    var maxLength = 0;
    var liLength = 0;
    var arrValue = [];
    var subValue = 0;
    if((BrowserDetect.browser=="Explorer") && (BrowserDetect.version==6)){
      for(var i=0;i<el.length;i++){
        arrValue[i] = el[i].offsetTop;
      }
      for(var j=0; j<arrValue.length; j++){
        subValue = (arrValue[j +1 ]) - arrValue[j];
        if(maxLength<subValue) maxLength = subValue;
      }
    }
    else{
        for(var i=0;i<el.length;i++)
        {  
          liLength = el[i].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
          if(maxLength<liLength) maxLength = liLength;
            
        }
    }
    //alert(maxLength)
    return maxLength;
};
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};


})($jYtc);


