

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
 		var isTouchScreen = 1;
 	}else{
 		var isTouchScreen = 0;
 	}


function displayInfo(msginfo){

	var el = $("<div id=msgInfo><div class=msgContent>sd</div></div>"); 
	$("body").append(el);
	el.slideDown('slow');
	setTimeout(function(){el.fadeOut();},5000);

}


function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}


function addActionLoader(){
	var element = null;
	if(arguments.callee.caller.arguments.length > arguments.callee.caller.length){
		element = $(arguments.callee.caller.arguments[arguments.callee.caller.arguments.length-1]);
	}
	if(element){
		var t = $(element).html();
		$(element).html("<img src=/images/loader/ajax-loader4.gif>");
		return [element,t];
	}
}

function removeActionLoader(content){
	
	if(content.length==2) $(content[0]).html(content[1]);
	
}

function checkEmail(val){
var status = false;     
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (val.search(emailRegEx) == -1) {
     }else {
          status = true;
     }
     return status;
}

function initialCap(field) {
	
   return field = field.substr(0, 1).toUpperCase() + field.substr(1);
}

function formatCurrency($val,$culture,decimal){
 	if($val!=undefined){
 		
 		if($culture!=undefined) $culture=$culture.toLowerCase();
	 	if($val.toString().indexOf('.')>=0){
	 		
	 		$val = parseFloat($val).toFixed(2);
	 		
	 		if(!decimal){
	 			$val = $val.toString().replace('.','<sup>');
	 			$val += '</sup>';
	 		}
	 	}
	 	switch($culture){
	 		case 'usd':		
	 			return '$'+$val;
	 		case 'cad':
	 			return 'c$'+$val;
	 		case 'eur':
	 			return $val+'€';
	 		case 'gbp':
	 			return '£'+$val;
	 		case 'pln':
	 			return $val+'zł';
	 		
	 		default:
	 			return '$'+$val; 
	 	}
 	}
}
	function format2Digits(s){
		if(s<10){  return '0'+s; }else{ return s;}
	}
	
	jQuery.fn.equalHeights = function(px) {
	
		jQuery(this).each(function(){
			var currentTallest = 0;
			jQuery(this).children().each(function(i){
				
				if (jQuery(this).height() > currentTallest) { currentTallest = jQuery(this).height(); }
			});

			//if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
			// for ie6, set height since min-height isn't supported
			//jQuery(this).children().css({'height': currentTallest});
			if (jQuery.browser.msie && jQuery.browser.version == 6.0) { jQuery(this).children().css({'height': currentTallest}); }
			jQuery(this).children().css({'min-height': currentTallest}); 
		});
		return this;
	};
	
	function cLen(arr){
		i=0;
		jQuery.each(arr,function(){
			i++;
		});
		return i;
	}
	
	function searchWindow(caller,city,category){
		ajaxDialog(caller,__("Search Daily Deals"),{url:"/search/modify",'data':{city:city,category:category}},{"width":"430px","height":"auto"},{"overflow-y":"auto","height":"auto"}, {oneInstance:1,'overlay':1})
	}
	
	 function time_left($integer)
 { 
     var $seconds=0,$minutes=0,$hours=0,$days=0,$weeks=0,$return='';
     
     $seconds=$integer; 
     if ($seconds/60 >=1){ 
     	$minutes=Math.floor($seconds/60); 
     	if ($minutes/60 >= 1) { 
     		$hours=Math.floor($minutes/60); 
     		if ($hours/24 >= 1){ 
     			$days=Math.floor($hours/24); 
     			if ($days/7 >=1){ 
     				$weeks=Math.floor($days/7); 
     				if ($weeks>=2) $return=$weeks+" Weeks"; 
     				else $return=$weeks+" Week"; 
     			}  
     			$days=$days-(Math.floor($days/7))*7; 
     			if ($weeks>=1 && $days >=1) $return=$return+", "; 
     			if ($days >=2) $return=$return+" "+ $days+" days";
     			if ($days ==1) $return=$return+" "+ $days+" day";
     		} 
     		$hours=$hours-(Math.floor($hours/24))*24; 
     		if ($days>=1 && $hours >=1) $return=$return+", "; 
     		if ($hours >=2) $return=$return+" "+ $hours+" hours";
     		if ($hours ==1) $return=$return+" "+ $hours+" hour";
     	}
     	$minutes=$minutes-(Math.floor($minutes/60))*60; 
     	if ($hours>=1 && $minutes >=1) $return=$return+", "; 
     	if ($minutes >=2) $return=$return+" "+ $minutes+" minutes";
     	if ($minutes ==1) $return=$return+" "+ $minutes+" minute";
     } 
     $seconds=$integer-(Math.floor($integer/60))*60; 
     if ($minutes>=1 && $seconds >=1) $return=$return+", ";  
     if ($seconds >=2) $return=$return+" "+$seconds+" seconds";
     if ($seconds ==1) $return=$return+" "+$seconds+" second";
     $return=$return+"."; 
     return $return; 
 }
 
 jQuery.fn.Toggle = function(target) {
	if(jQuery(target).is(':visible')){ 
		jQuery(this).addClass('off');
		jQuery(this).removeClass('on');
		jQuery(target).hide();
	}else{
		jQuery(this).addClass('on');
		jQuery(this).removeClass('off');
		jQuery(target).show();
		
	}
};


	


	jQuery.fn.tooltip = function(position){
		if(!position) position = 'top';


		return jQuery(this).each(function(){
			var el = jQuery(this);
			el.mouseover(function(){if(el.attr('otitle')) create()});
			
			
			function create(){
				
				if(isTouchScreen){
					var offsetTop = jQuery(window).scrollTop();
					var offsetLeft = jQuery(window).scrollLeft();
				}else{
					var offsetTop = 0;
					var offsetLeft = 0;
				}
				var tooltip_outer = jQuery('<div class="tooltip-outer clearfix"></div>');
				var tooltip_inner = jQuery('<div class=tooltip-inner></div>');
				var tooltip_arrow = jQuery('<div class=tooltip-arrow></div>');
				tooltip_inner.html(el.attr('otitle'));
				
				
				
				
				
				if(position =='top'){
					jQuery('body').append(tooltip_outer.append(tooltip_inner).append(tooltip_arrow));
					tooltip_arrow.css({'background-position':'center bottom'});
					tooltip_outer.css({'display':'block','left':-offsetLeft+el.offset().left-(tooltip_outer.outerWidth()/2-el.outerWidth()/2)+'px','top':-offsetTop+el.offset().top-tooltip_outer.outerHeight()+'px'});
					
				}
				if(position =='bottom'){
					jQuery('body').append(tooltip_outer.append(tooltip_arrow ).append(tooltip_inner));
					tooltip_arrow.css({'background-position':'center top'});
					tooltip_outer.css({'display':'block','left':-offsetLeft+el.offset().left-(tooltip_outer.outerWidth()/2-el.outerWidth()/2)+'px','top':-offsetTop+el.offset().top+el.outerHeight()+'px'});
					
				}
				
				if(position =='right'){
					jQuery('body').append(tooltip_outer.append(tooltip_arrow).append(tooltip_inner));
					tooltip_arrow.css({'background-position':'center left','float':'left','width':'4px'});
					tooltip_inner.css({'white-space':'normal','text-align':'left','float':'left','width':'120px'});
					tooltip_outer.css({'white-space':'normal','height':'auto','display':'block','left':-offsetLeft+el.offset().left+el.outerWidth()+5+'px','top':-offsetTop+el.offset().top-(tooltip_outer.outerHeight()/2-el.outerHeight()/2)+'px'});
					tooltip_arrow.height(tooltip_inner.height());
				}
				
				if(position =='left'){
					jQuery('body').append(tooltip_outer.append(tooltip_inner).append(tooltip_arrow));
					tooltip_arrow.css({'background-position':'center right','float':'left','width':'4px'});
					tooltip_inner.css({'white-space':'normal','text-align':'left','float':'left','width':'120px'});
					tooltip_outer.css({'white-space':'normal','height':'auto','display':'block','left':-offsetLeft+el.offset().left-tooltip_outer.outerWidth()-5+'px','top':-offsetTop+el.offset().top-(tooltip_outer.outerHeight()/2-el.outerHeight()/2)+'px'});
					tooltip_arrow.height(tooltip_inner.height());
				}
				
				el.mouseout(function(){tooltip_outer.remove()});
			}
				
		})
	};
	
	jQuery.fn.initFields = function(){		
		return this.each(function () {
			var f = $(this);
			var s = $(".form_label",f);
			var i = $(".form_input",f);
			i.mouseup(function(e){
		       // e.preventDefault();
			});
			s.mousedown(function(e){e.preventDefault();});
			//f.mousedown(function(e){e.preventDefault();});
			s.bind("mousedown",function(){s.hide();i.focus();});
			f.bind("mousedown",function(){s.hide();i.focus();});
			i.focusin(function(){s.hide();});
			f.focusout(function(){if(i.val()=="") s.show();else s.hide();});
			i.change(function(){if(i.val()=="") s.show();else s.hide();});
			if(i.val()!="")	 s.hide(); else s.show();
		});
	};
	jQuery.fn.initField = function(){
		return this.each(function () {
			var f = $(this);
			var s = $("div",f);
			var i = $("input",f);
			i.mouseup(function(e){
		       // e.preventDefault();
			});
			s.mousedown(function(e){e.preventDefault();});
			//f.mousedown(function(e){e.preventDefault();});
			s.bind("mousedown",function(){s.hide();i.focus();});
			f.bind("mousedown",function(){s.hide();i.focus();});
			i.focusin(function(){s.hide();});
			f.focusout(function(){if(i.val()=="") s.show();});
			if(i.val())	 s.hide(); else s.show();
		});
	};
	
	jQuery.fn.loader = function () {
		  $(this).html("<img src=/images/loader/ajax-loader4.gif>");
	}
		
	
	jQuery.fn.hint = function (blurClass) {
	  if (!blurClass) { 
	    blurClass = 'blur';
	  }
	  
	  return this.each(function () {
	    var $input = jQuery(this),
	     title = $input.attr('title'),
	     $form = jQuery(this.form),
	     $win = jQuery(window);
	
	    function remove() {
	      if ( $input.hasClass(blurClass)) { //$input.val() === $input.attr('title') &&
	        $input.val('').removeClass(blurClass);
	      }
	    }
	
	    if ($input.attr('title')) { 
	      $input.blur(function () {
	        if (this.value === '') {
	          $input.val($input.attr('title')).addClass(blurClass);
	        }
	      }).focus(remove).blur();
	      $form.submit(remove);
	      $win.unload(remove);
	    }
	  });
	};
	
	function iealphapng(){
		if (jQuery.browser.msie)
        	jQuery('img[src$=.png]').each(function() {
            	this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+this.src+",sizingMethod='scale')";
    		});
	}
	
	
	function emailWindow(caller,dealId,affid){
		if(!affid) affid="";
		ajaxDialog(caller,__("Share It With Your Friends"),{url:"/common/shareEmail",'data':{dealId:dealId,affid:affid},type:'get'},{"width":"500px","height":"auto"},{"overflow-y":"auto","height":"auto"}, {oneInstance:1,'overlay':1,'position':'center'})
	}
	
	function shareEmail(subject,message){
		ajaxDialog(null,__("Share It With Your Friends"),{url:"/common/shareEmail",'data':{subject:subject,message:message},type:'get'},{"width":"500px","height":"auto"},{"overflow-y":"auto","height":"auto"}, {oneInstance:1,'overlay':1,'position':'center'})
	}
	
	function setCookie(cookieName, value, daysToExpire, path, domain, secure) {
		var expiryDate;
		if (daysToExpire) {
			// time is in milliseconds
			expiryDate = new Date();
			// there are 1000 * 60 * 60 * 24 milliseconds in a day (i.e., 86400000 or 8.64e7)
			expiryDate.setTime(expiryDate.getTime() + daysToExpire * 8.64e7);
		}
		document.cookie = cookieName + '=' + window.encodeURIComponent(value) +
			                  (daysToExpire ? ';expires=' + expiryDate.toGMTString() : '') +
			                  ';path=' + (path ? path : '/') +
			                  (domain ? ';domain=' + domain : '') +
			                  (secure ? ';secure' : '');
	}

		/*
		 * Get cookie value
		 */
	function getCookie(cookieName) {
		var cookiePattern = new RegExp('(^|;)[ ]*' + cookieName + '=([^;]*)'),
		cookieMatch = cookiePattern.exec(document.cookie);
		return cookieMatch ? window.decodeURIComponent(cookieMatch[2]) : 0;
	}
	
	function getAlert(cityId,dealId){
		if(!dealId) dealId = '';
		if(!cityId) cityId = '';
		staticWindow(this,__("Don't Miss a Deal!"),"/user/getAlert?open=1&dId="+dealId+"&city="+cityId,{"width":"490px","height":"auto"},{"overflow-y":"auto","height":"auto"});return false;
	}
	function getAlert2(msg,dealId){
		
		staticWindow(this,__("Don't Miss a Deal!"),"/user/getAlert?open=1&dId="+dealId+"&msg="+msg,{"width":"490px","height":"auto"},{"overflow-y":"auto","height":"auto"});return false;
	}
	function getAlert4(msg,dealId){
		if(confirm(__("This deal is expired.\n\n Would you like to receive an email when this deal or a similar one becomes available?"))){
		staticWindow(this,__("Don't Miss a Deal!"),"/user/getAlert?open=1&dId="+dealId+"&msg="+msg,{"width":"490px","height":"auto"},{"overflow-y":"auto","height":"auto"});return false;
		}
	}
	function getAlert3(caller,cityId,dealId){
		ajaxDialog(caller,__("Don't Miss a Deal!"),{url:"/user/getAlert?open=1&dId="+dealId+"&city="+cityId},{"width":"490px","height":"auto"},{"overflow-y":"auto","height":"auto"}, {oneInstance:1,'overlay':1})
	}
	function zoomMap(aId){
		staticWindow(this,__("Map"),"/common/zoomMap?aId="+aId,{"width":"400px","height":"400px"},{"overflow-y":"auto","height":"auto"});return false;
	}
	
	function en(s,k) {
	    var sl=s.length;
	    var kl=k.length;    
	    for(encoded='',i=0; i<sl; i++) {
	      var encodedChar=s.charCodeAt(i)^k.charCodeAt(i%kl);      
	      encoded += String.fromCharCode((encodedChar & 0x0F) + 97) + String.fromCharCode((encodedChar >> 4) + 97);      
	    }
	    return encoded;
	  }

	  function dc(s,k) {
	    var sl=s.length;
	    var kl=k.length;    
	    for(decoded='',i=0, j=0; i<sl; i+=2, j++) {
	      decoded += String.fromCharCode(((s.charCodeAt(i) - 97) + ((s.charCodeAt(i+1) - 97) << 4))^k.charCodeAt(j%kl));      
	    }
	    return decoded;
	  }


	
	
	function getDatePresetRange(){
		
		return [
		   			{text: __('Today'), dateStart: 'today', dateEnd: 'today' },
		   			{text: __('Yesterday'), dateStart: 'today-1days', dateEnd: 'today-1days' },
		   			{text: __('Last 7 days'), dateStart: 'today-7days', dateEnd: 'today' },
		   			{text: __('Month to date'), dateStart: function(){ return Date.parse('today').moveToFirstDayOfMonth();  }, dateEnd: 'today' },
		   			{text: __('Year to date'), dateStart: function(){ var x= Date.parse('today'); x.setMonth(0); x.setDate(1); return x; }, dateEnd: 'today' },
		   			//extras:
		   			
		   			{text: __('The previous Month'), dateStart: function(){ return Date.parse('1 month ago').moveToFirstDayOfMonth();  }, dateEnd: function(){ return Date.parse('1 month ago').moveToLastDayOfMonth();  } },
		   			{text: __('Last 6 months'), dateStart: function(){ return Date.parse('6 month ago').moveToFirstDayOfMonth();  }, dateEnd: function(){ return Date.parse('1 month ago').moveToLastDayOfMonth();  } },
		   			{text: __('The previous Year'), dateStart: function(){ var x= Date.parse('1 year ago'); x.setMonth(0); x.setDate(1); return x;  }, dateEnd: function(){ var x= Date.parse('1 year ago'); x.setMonth(11); x.setDate(31); return x;   } }
		   			
		   			//{text: 'Tomorrow', dateStart: 'Tomorrow', dateEnd: 'Tomorrow' },
		   			//{text: 'Ad Campaign', dateStart: '03/07/08', dateEnd: 'Today' },
		   			//{text: 'Last 30 Days', dateStart: 'Today-30', dateEnd: 'Today' },
		   			//{text: 'Next 30 Days', dateStart: 'Today', dateEnd: 'Today+30' },
		   			//{text: 'Our Ad Campaign', dateStart: '03/07/08', dateEnd: '07/08/08' }
		   		];
	}
	function getDatePreset(){
		return {
			specificDate: __('Specific Date'), 
			dateRange: __('Date Range')
		};

	}
 
 function changeCity(city,url){
	if(!url) url = "/"; 
	$.ajax({
		url:"/common/changeCity?city="+city,
		success:function(data){
			window.location.href = url;
		}
		});
		
 }
 
 function addOverlay(el){
 	if(!el) el = "body";
 	removeOverlay();	
	jQuery(el).prepend("<div class=dw_overlay style='height:"+jQuery(document).height()+"px'></div>");
}
function removeOverlay(){
	$('.dw_overlay').remove();
}
 
 function notify_share(did,type){
	 
	 $.ajax({
         url: '/user/share',
         data: {did:did,type:type}, 
         success: function(data){}
		});
	 return false;
 }

 function uniqid (prefix, more_entropy) {
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +    revised by: Kankrelune (http://www.webfaktory.info/)
	    // %        note 1: Uses an internal counter (in php_js global) to avoid collision
	    // *     example 1: uniqid();
	    // *     returns 1: 'a30285b160c14'
	    // *     example 2: uniqid('foo');
	    // *     returns 2: 'fooa30285b1cd361'
	    // *     example 3: uniqid('bar', true);
	    // *     returns 3: 'bara20285b23dfd1.31879087'
	    if (typeof prefix == 'undefined') {
	        prefix = "";
	    }

	    var retId;
	    var formatSeed = function (seed, reqWidth) {
	        seed = parseInt(seed, 10).toString(16); // to hex str
	        if (reqWidth < seed.length) { // so long we split
	            return seed.slice(seed.length - reqWidth);
	        }
	        if (reqWidth > seed.length) { // so short we pad
	            return Array(1 + (reqWidth - seed.length)).join('0') + seed;
	        }
	        return seed;
	    };

	    // BEGIN REDUNDANT
	    if (!this.php_js) {
	        this.php_js = {};
	    }
	    // END REDUNDANT
	    if (!this.php_js.uniqidSeed) { // init seed with big random int
	        this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
	    }
	    this.php_js.uniqidSeed++;

	    retId = prefix; // start with prefix, add current milliseconds hex string
	    retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
	    retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
	    if (more_entropy) {
	        // for more entropy we add a float lower to 10
	        retId += (Math.random() * 10).toFixed(8).toString();
	    }

	    return retId;
	}
 
 //ScrollTo
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
//LocalScroll
;(function($){var l=location.href.replace(/#.*/,'');var g=$.localScroll=function(a){$('body').localScroll(a)};g.defaults={duration:1e3,axis:'y',event:'click',stop:true,target:window,reset:true};g.hash=function(a){if(location.hash){a=$.extend({},g.defaults,a);a.hash=false;if(a.reset){var e=a.duration;delete a.duration;$(a.target).scrollTo(0,a);a.duration=e}i(0,location,a)}};$.fn.localScroll=function(b){b=$.extend({},g.defaults,b);return b.lazy?this.bind(b.event,function(a){var e=$([a.target,a.target.parentNode]).filter(d)[0];if(e)i(a,e,b)}):this.find('a,area').filter(d).bind(b.event,function(a){i(a,this,b)}).end().end();function d(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,'')==l&&(!b.filter||$(this).is(b.filter))}};function i(a,e,b){var d=e.hash.slice(1),f=document.getElementById(d)||document.getElementsByName(d)[0];if(!f)return;if(a)a.preventDefault();var h=$(b.target);if(b.lock&&h.is(':animated')||b.onBefore&&b.onBefore.call(b,a,f,h)===false)return;if(b.stop)h.stop(true);if(b.hash){var j=f.id==d?'id':'name',k=$('<a> </a>').attr(j,d).css({position:'absolute',top:$(window).scrollTop(),left:$(window).scrollLeft()});f[j]='';$('body').prepend(k);location=e.hash;k.remove();f[j]=d}h.scrollTo(f,b).trigger('notify.serialScroll',[f])}})(jQuery);
//SerialScroll
;(function(a){var b=a.serialScroll=function(c){return a(window).serialScroll(c)};b.defaults={duration:1e3,axis:"x",event:"click",start:0,step:1,lock:!0,cycle:!0,constant:!0};a.fn.serialScroll=function(c){return this.each(function(){var t=a.extend({},b.defaults,c),s=t.event,i=t.step,r=t.lazy,e=t.target?this:document,u=a(t.target||this,e),p=u[0],m=t.items,h=t.start,g=t.interval,k=t.navigation,l;if(!r){m=d()}if(t.force){f({},h)}a(t.prev||[],e).bind(s,-i,q);a(t.next||[],e).bind(s,i,q);if(!p.ssbound){u.bind("prev.serialScroll",-i,q).bind("next.serialScroll",i,q).bind("goto.serialScroll",f)}if(g){u.bind("start.serialScroll",function(v){if(!g){o();g=!0;n()}}).bind("stop.serialScroll",function(){o();g=!1})}u.bind("notify.serialScroll",function(x,w){var v=j(w);if(v>-1){h=v}});p.ssbound=!0;if(t.jump){(r?u:d()).bind(s,function(v){f(v,j(v.target))})}if(k){k=a(k,e).bind(s,function(v){v.data=Math.round(d().length/k.length)*k.index(this);f(v,this)})}function q(v){v.data+=h;f(v,this)}function f(B,z){if(!isNaN(z)){B.data=z;z=p}var C=B.data,v,D=B.type,A=t.exclude?d().slice(0,-t.exclude):d(),y=A.length,w=A[C],x=t.duration;if(D){B.preventDefault()}if(g){o();l=setTimeout(n,t.interval)}if(!w){v=C<0?0:y-1;if(h!=v){C=v}else{if(!t.cycle){return}else{C=y-v-1}}w=A[C]}if(!w||t.lock&&u.is(":animated")||D&&t.onBefore&&t.onBefore(B,w,u,d(),C)===!1){return}if(t.stop){u.queue("fx",[]).stop()}if(t.constant){x=Math.abs(x/i*(h-C))}u.scrollTo(w,x,t).trigger("notify.serialScroll",[C])}function n(){u.trigger("next.serialScroll")}function o(){clearTimeout(l)}function d(){return a(m,p)}function j(w){if(!isNaN(w)){return w}var x=d(),v;while((v=x.index(w))==-1&&w!=p){w=w.parentNode}return v}})}})(jQuery);


