function cons(v) {
	if (console)
		console.log(v);
}

function initTabs() {
	$('.tabset, .tablist, .tabs, .tabtab, .searchtab').each(function(){
		var _list = $(this);
		var _links = _list.find('a.tab');

		_links.each(function() {
			var _link = $(this);
			var _href = _link.attr('href');
			var _tab = $('.'+_href);
			if(_link.hasClass('active')) 
				_tab.show();
			else 
				_tab.hide();

			_link.click(function(){
				_links.filter('.active').each(function(){
					$('.'+ $(this).attr('href')).hide();
				});
				_links.removeClass('active');
				_link.addClass('active');
				_tab.show();
				return false;
			});
		});
	});
}


/* Gallery */
jQuery.fn.gallery = function(_options){
	// defaults options	
	var _options = jQuery.extend({
		duration: 700,
		autoSlide: true,
		slideElement: 1,
		effect: false,
		fadeEl: 'ul',
		switcher: 'ul > li',
		disableBtn: false,
		next: 'a.link-next, a.btn-next, a.next',
		prev: 'a.link-prev, a.btn-prev, a.prev',
		circle: true
	},_options);

	/* Gallery */
jQuery.fn.gallery = function(_options){
	// defaults options	
	var _options = jQuery.extend({
		duration: 700,
		autoSlide: false,
		slideElement: 1,
		effect: true,
		fadeEl: 'ul',
		switcher: 'ul > li',
		disableBtn: false,
		next: 'a.link-next, a.btn-next, a.next',
		prev: 'a.link-prev, a.btn-prev, a.prev',
		circle: true
	},_options);

	return this.each(function(){
		var _hold = $(this);
		if (!_options.effect) var _speed = _options.duration;
		else var _speed = $.browser.msie ? 0 : _options.duration;
		var _timer = _options.autoSlide;
		var _sliderEl = _options.slideElement;
		var _wrap = _hold.find(_options.fadeEl);
		var _el = _hold.find(_options.switcher);
		var _next = _hold.find(_options.next);
		var _prev = _hold.find(_options.prev);
		var _count = _el.index(_el.filter(':last'));
		var _w = _el.outerWidth(true);
		var _wrapHolderW = Math.ceil(_wrap.parent().width()/_w);
		if (((_wrapHolderW-1)*_w + _w/2) > _wrap.parent().width()) _wrapHolderW--;
		if (_timer) var _t;
		var _active = _el.index(_el.filter('.active:eq(0)'));
		if (_active < 0) _active = 0;
		var _last = _active;
		if (!_options.effect) var rew = _count - _wrapHolderW + 1;
		else var rew = _count;
		
		if (!_options.effect) _wrap.css({marginLeft: -(_w * _active)});
		else {
			_wrap.css({opacity: 0}).removeClass('active').eq(_active).addClass('active').css({opacity: 1}).css('opacity', 'auto');
			_el.removeClass('active').eq(_active).addClass('active');
		}
		if (_options.disableBtn) {
			if (_count < _wrapHolderW) _next.addClass(_options.disableBtn);
			_prev.addClass(_options.disableBtn);
		}
		
		function fadeElement(){
			_wrap.eq(_last).animate({opacity:0}, {queue:false, duration: _speed});
			_wrap.removeClass('active').eq(_active).addClass('active').animate({
				opacity:1
			}, {queue:false, duration: _speed, complete: function(){
				$(this).css('opacity','auto');
			}});
			_el.removeClass('active').eq(_active).addClass('active');
			_last = _active;
		}
		function scrollEl(){
			_wrap.animate({marginLeft: -(_w * _active)}, {queue:false, duration: _speed});
		}
		function toPrepare(){
			if ((_active == rew) && _options.circle) _active = -_sliderEl;
			for (var i = 0; i < _sliderEl; i++){
				_active++;
				if (_active > rew) {
					_active--;
					if (_options.disableBtn &&(_count > _wrapHolderW)) _next.addClass(_options.disableBtn);
				}
			};
			if (_active == rew) if (_options.disableBtn &&(_count > _wrapHolderW)) _next.addClass(_options.disableBtn);
			if (!_options.effect) scrollEl();
			else fadeElement();
		}
		function runTimer(){
			_t = setInterval(function(){
				toPrepare();
			}, _timer);
		}
		_next.click(function(){
			if(_t) clearTimeout(_t);
			if (_options.disableBtn &&(_count > _wrapHolderW)) _prev.removeClass(_options.disableBtn);
			toPrepare();
			if (_timer) runTimer();
			return false;
		});
		_prev.click(function(){
			if(_t) clearTimeout(_t);
			if (_options.disableBtn &&(_count > _wrapHolderW)) _next.removeClass(_options.disableBtn);
			if ((_active == 0) && _options.circle) _active = rew + _sliderEl;
			for (var i = 0; i < _sliderEl; i++){
				_active--;
				if (_active < 0) {
					_active++;
					if (_options.disableBtn &&(_count > _wrapHolderW)) _prev.addClass(_options.disableBtn);
				}
			};
			if (_active == 0) if (_options.disableBtn &&(_count > _wrapHolderW)) _prev.addClass(_options.disableBtn);
			if (!_options.effect) scrollEl();
			else fadeElement();
			if (_timer) runTimer();
			return false;
		});
		if (_options.effect) _el.click(function(){
			_active = _el.index($(this));
			if(_t) clearTimeout(_t);
			fadeElement();
			if (_timer) runTimer();
			return false;
		});
		if (_timer) runTimer();
	});
}
}

$(document).ready(function(){
//*	
$('div.tabs1 , div.tabs2 , div.tabs3').gallery({
		duration: 2000,
		fadeEl: '.text-holder-wrapper',
		switcher: '.text-holder-wrapper .text-holder-container',
		next: 'a.next',
		prev: 'a.previous'
	});
//*/
	initTabs();
	fadeGall();
});

function fadeGall(){
	var wait_time = 4000; // in ms
	var change_speed = 800; // in ms
	var _hold = $('div.heading');
	if(_hold.length){
		var _t;
		var _f = true;
		var _list = _hold.find('ul.fader > li');
		var _btn = $('<ul class="paging"></ul>');
		_list.each(function(_i){
			_btn.append('<li><a href="#">'+(_i+1)+'</a></li>');
		});
		_btn = _btn.find('a');
		var _a = _list.index(_list.filter('.active:eq(0)'));
		if(_a == -1) _a = 0;
		
		_list.show().removeClass('active').css('opacity', 0).eq(_a).addClass('active').css('opacity', 1);
		_btn.eq(_a).parent('li').addClass('active');
		_btn.click(function(){
			changeEl(_btn.index(this));
			return false;
		});
		_hold.mouseenter(function(){
			_f = false;
			if(_t) clearTimeout(_t);
		}).mouseleave(function(){
			_f = true;
			if(_t) clearTimeout(_t);
			if(_f && wait_time){
				_t = setTimeout(function(){
					if(_a < _list.length - 1) changeEl(_a + 1);
					else changeEl(0);
				}, wait_time);
			}
		});
		if(_f && wait_time){
			_t = setTimeout(function(){
				if(_a < _list.length - 1) changeEl(_a + 1);
				else changeEl(0);
			}, wait_time);
		}
		function changeEl(_ind){				
			if(_t) clearTimeout(_t);
			if(_ind != _a){
				_list.eq(_a).removeClass('active').animate({opacity: 0}, {queue:false, duration:change_speed});
				_list.eq(_ind).addClass('active').animate({opacity: 1}, {queue:false, duration:change_speed});
				_btn.eq(_a).parent('li').removeClass('active');
				_btn.eq(_ind).parent('li').addClass('active');
				_a = _ind;
			}
			if(_f && wait_time){
				_t = setTimeout(function(){
					if(_a < _list.length - 1) changeEl(_a + 1);
					else changeEl(0);
				}, wait_time);
			}
		}
	}
}
$(document).ready(function(){
  /* View all links in kosher dropdown */
  
  $(".menu-holder .kosher .btn-01").each(function(i,el){
    var href = $(el).attr('href'); 
    $(el).parent().find('.block').append($('<a>',{
      href:href,
      text:'View All',
      'class': 'view-all'
      }));
  });
	
	/* Resources learn more link */
	
	$(".menu-holder .departments ul li").each(function(i,el){
	  var href = $(el).find('a').attr('href');
	  $(el).append($('<a>',{
	    text:'Learn More',
	    href:href,
	    'class':'learn-more'
	  }));
	});
/************************
Torah Mega Dropdown
*************************/
	//Flag what triggered
	var is_hover = false;
	
	//Hide/Show from Menu Nav
	$("#torah_nav").hover(function() { 
		$("#torah_dd_main").show();
		is_hover = true;
	}, function() {
		$("#torah_dd_main").hide();	
	});
	
	//Hide/Show from Popup
	$("#torah_dd_main").hover(function() { 
		$("#torah_dd_main").show();
	}, function() {
		$("#torah_dd_main").hide();	
	});

	//Hide/Show from Position
	$(document).mousemove(function(e){		
		if(e.pageY > 196 && e.pageY < 502 && e.pageX > 300 && e.pageX < 972 && is_hover)
		{
			$("#torah_dd_main").show();
			is_hover = false;
		}
	});
	
	$('ul.accordion').accordion({
		active: ".selected",
		autoHeight: false,
		header: ".opener",
		collapsible: true,
		event: "click"
	});

	$('ul.accordion2').accordion({
		autoHeight: false,
		header: ".opener",
		collapsible: true,
		fillSpace: true,
		event: "click"
	});
	
	// Make default input text disappear
	$('input.has-default-text').click(function(){
		var $this = $(this);
		if (!$this.data('defaultText'))
			$this.data('defaultText', $this.val());
		
		if ($this.val() == $this.data('defaultText'))
			$this.val('');
	});
	$('input.has-default-text').blur(function(){
		//$(this).val($(this).data('defaultText'));
	});
	
	/* Torah Page Letter Navigation */
	$('.letters-nav a').click(function(e){
		e.preventDefault();
		var letter = $(this).attr('href');
		$('.info-block').hide();
		$('.blocks-holder .' + letter).show();
		$('.current-letter').html(letter.toUpperCase());
		$(this).parent().siblings().removeClass('active');
		$(this).parent().addClass('active');
		$(this).blur();
	});
	
	// Redirecting Product Search
	$('.product-search').submit(function(e){
		e.preventDefault();
		cons('got here');
		var url = "http://www.oukosher.org/index.php/product_search#" + $('.product-search-text').val();
		location.href = url;
	});
	
	// Show change location form for zmanim, shuls, and mikvahs
	$('.change-location-link').bind('click', function(e){
		e.preventDefault();
		$(this).siblings('form').slideToggle();
	});

	$('.zmanim-tab').click(function(e){
		if ($(e.target).hasClass('change-location-link')) {
			e.preventDefault();
			$(e.target).siblings('form').slideToggle();
			
			$(".zmanim-tab .ac_location").autocomplete(
				"http://www.ou.org/autocomplete_location_encode.php",
				{
					delay:10,
					minChars:3,
					matchSubset:1,
					//matchContains:1,
					cacheLength:10,
					maxItemsToShow:10,
					//onItemSelect:selectItem,
					//onFindValue:findValue,
					//formatItem:formatItem,
					autoFill:false
				}
			).result(function(event, data, formatted) {
			  $(this).parent().hide();
			  var locationStr = formatted;
			 
			  if ($(this).parent().attr('id') == 'ac-zmanim') {
					updateZmanim(locationStr);
				}
				else {
					updateList(locationStr, getUpdateListOptions($(this).parent().attr('id')));
				}
			});
		}
	});

	$('.shuls-by-location li').mouseover(switchShulInfo);
	$('.mikvahs-by-location li').mouseover(switchMikvahInfo);
	
	// Location autocomplete for zmanim, synagogue, and mikvah
	$(".ac_location").autocomplete(
		"http://www.ou.org/autocomplete_location_encode.php",
		{
			delay:10,
			minChars:3,
			matchSubset:1,
			//matchContains:1,
			cacheLength:10,
			maxItemsToShow:10,
			//onItemSelect:selectItem,
			//onFindValue:findValue,
			//formatItem:formatItem,
			autoFill:false
		}
	);
});

function convertTime(time) {
	var time = time.split(':');
	var hval = parseInt(time[0], 10);
	var mval = parseInt(time[1], 10);
	var sval = parseInt(time[2], 10);
	var ampm = '';
	
	if (sval >= 30) {
		mval = mval + 1;
		if (mval >= 60) {
			mval = mval - 60;
			hval = hval + 1;
		}
	}
	if (hval >= 12) {
		ampm = "PM";
		if (hval >= 13) {
			hval = hval - 12;
		}
	} else {
		ampm = "AM";
	}
	
	return hval + ":" + (mval < 10 ? '0':'') + mval + " " + ampm;
}

/* Handling the change location events for sections: Closest Synagogues and Closest Mikvahs */

function switchMikvahInfo(){
	var $this = $(this),
		entryId = $this.attr('id');
	
	$this.addClass('active');
	$this.siblings().removeClass('active');
	
	$('.mikvah-info').hide();
	$('#mikvah-info-' + entryId).show();
}

function switchShulInfo(){
	var $this = $(this),
		entryId = $this.attr('id');
		
	$this.addClass('active');
	$this.siblings().removeClass('active');
	
	$('.shul-info').hide();
	$('#shul-info-' + entryId).show();
	
//	console.log('d');
	
}

function locationObj(locationStr) {
	var loc = {city: locationStr.split(',')[0]};
	var rest = $.trim(locationStr.split(",")[1]);

	if (rest.search(" ") == -1) {
		loc.region = '';
		loc.country = rest;
	} else {
		loc.region = rest.split(" ")[0];
		loc.country = rest.split(" ")[1];
	}

	return loc;
}

function changeLocation(locationStr, callback) {
	var locationData = locationObj(locationStr),
		locationUrl = 'http://www.ou.org/holidays/get_location_data2';

	$.get(locationUrl, locationData, callback);
}

// Function to update zmanim in info tab
function updateZmanim(locationStr) {
	changeLocation(locationStr, function(data) {
		// Start Callback Function
		
		var locationData = locationObj(locationStr),
			d = new Date(),
			zmanimData = {
				mode: "day",
				numberOfResults: 7
			};
		
		$('.zmanim-tab #current-location').html(locationStr.replace(/(US|CA)$/, ''));
		
		var qString = 'mode=zmanim&city=' + locationData.city + '&region=' + locationData.region + '&country=' + locationData.country;
		$('.zmanim-calendar-link').attr('href', 'http://www.ou.org/_dev/calendar?' + qString);
		
		data = $.parseJSON(data);
		zmanimData.startDate 	= "" + (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear();
		zmanimData.lat 			= data.latitude;
		zmanimData.long 		= data.longitude;
		zmanimData.timezone 	= data.timezone;
		zmanimData.zmanim		= "all";
		
		if (locationData.city == "Jerusalem")
			zmanimData.candles_offset = "40";
		if (locationData.country == "IL")
			zmanimData.holidays = "israel";		
		
		$.get('http://www.ou.org/ou_services/getCalendarData.php', zmanimData, function(zmanim){
			zmanim = zmanim.substring( zmanim.indexOf('{'), zmanim.lastIndexOf('}') + 1);
			zmanim = $.parseJSON(zmanim);
			zmanim = zmanim.days[0].zmanim
			$('#sunrise').html(convertTime(zmanim.sunrise));
			$('#sunset').html(convertTime(zmanim.sunset));
		});

		// We must make a second GET request to get the upcoming candle lighting time
		// Getting date of this friday
		var d = new Date(),
			t = d.getTime(),
			msInDay = 86400000,
			daysTillFriday = 7 - d.getDay() - 2,
			friday = new Date(t + daysTillFriday * msInDay),
			month = friday.getMonth() + 1,
			day = friday.getDate(),
			year = friday.getFullYear();
		
		// Changing some properties for the new request
		zmanimData.mode = 'month';
		zmanimData.startDate = month + '/' + day + '/' + year;
		
		// Making request for candle lighting time
		$.get('http://www.ou.org/ou_services/getCalendarData.php', zmanimData, function(zmanim){
			zmanim = zmanim.substring( zmanim.indexOf('{'), zmanim.lastIndexOf('}') + 1);
			zmanim = $.parseJSON(zmanim);
			var candleLighting = zmanim.days[0].candle_lighting;
			$('#candle-lighting').html(convertTime(candleLighting));			
		});

	});
}

// Function to update Synagogue and Mikvah list on homepage
function updateList(locationStr, options) {
	// Calling changeLocation, which will dynamically get the user's location information and 
	// pass it to the callback.
	changeLocation(locationStr, function(data){
		// Start Callback Function
				
		// Creating an an object with the user's location information
		var locationObj = $.parseJSON(data),
			url = '/includes/' + options.ac_template + '/' + locationObj.latitude + '/' + locationObj.longitude; 
		
		// Making GET request for shul information
		$.get(url, function(entries) {
			// Creating an array filled with shul objects
			var entriesArray = $.parseJSON(entries),
				items = '<ul class="tabs">',
				entryInfo = '',
				member = '';
			
			// Iterating through the array of shuls
			for (i in entriesArray) {
				var website = entriesArray[i].website,
					name = entriesArray[i].name,
					style = (i > 0 ? 'style="display: none"' : ''),
					website = '';
				
				// Creating a group of <li> elements of the shul's name. If there is a website
				// the name is linked to it.
				
				items += '<li><a href="' + options.tabContainer + '-' + (i + 1) + '" class="tab' +  (i == 0 ? ' active' : '') + '">' + name + '</a></li>';
				
				// Creating sections to display shul's information
				if (entriesArray[i].website != '') {
					website = '<dt>Website:</dt>'	+ '<dd><a href="http://' + entriesArray[i].website 	+ '">' + entriesArray[i].website + '</a></dd>';
				}
				
				member = '';
				if (entriesArray[i].member == 'Yes') {

					member = '<img title="OU Member Synagogue" src="http://images.ou.org/icons/sm/ou_gray18.png" />' +
							 '<div class="member">Member</div>';
				}
				
				entryInfo += '<div class="description ' + options.tabContainer + '-' + (i + 1) + '" ' + style + '>' + 
								member +
								'<dt>City:</dt>' 	+ '<dd>' + entriesArray[i].city 	+ '</dd>' +
								'<dt>Address:</dt>'	+ '<dd>' + entriesArray[i].address 	+ '</dd>' +
								'<dt>Location:</dt>'	+ '<dd>' + entriesArray[i].location + '</dd>' +
								'<dt>Rabbi:</dt>' 	+ '<dd>' + entriesArray[i].rabbi 	+ '</dd>' +
								'<dt>Phone:</dt>' 	+ '<dd>' + entriesArray[i].phone 	+ '</dd>' +
								website +				
							'</div>';
			}
						
			$('.' + options.infoBoxClass).html(items);
			$('.' + options.infoBoxClass).append(entryInfo);
			$('.' + options.tabContainer + ' h3').html(options.title + ' for ' + locationStr.replace(/(US|CA)$/, ''));
			
			
//			initTabs();
//*			
			$('.shul-info .tabs a').bind('click', function(e){
				e.preventDefault();
			
				var href = $(this).attr('href');
				
				// parse href for IE7 bug
				if (href.search('http') > -1) {
					href = href.replace('http://www.ou.org/', '');
				}
				
				$('.shul-info .tabs a').removeClass('active');
				$(this).addClass('active');
				
				$('.shul-info .description').hide();
				$('.shul-info .' + href).show();
			});
//*/
		});
	});
}

function getUpdateListOptions(formId) {
	if (formId == 'ac-shuls') {
		return {
			ac_template: '_json_shuls',
			title: 'Synagogues',
			tabContainer: 'tabs1',
			infoBoxClass: 'shul-info',
			switchInfoCallback: switchShulInfo
		};
	} else if (formId == 'ac-mikvahs') {
		return {
			ac_template: '_ac_mikvahs',
			title: 'Mikvahs',
			tabContainer: 'tabs2',
			infoBoxClass: 'mikvah-info',
			switchInfoCallback: switchMikvahInfo
		};
	}
}

function updateTheNumberPaginate() {
	var firstPageNum = $('.browse-by-topic .pageME .active_page').text();
	var lastPageNum = $('.browse-by-topic .pageME .last').text();
	$('.browse-by-topic .insertFirstNumber').text(' ').text(firstPageNum);
	$('.browse-by-topic .insertLastNumber').text(' ').text(lastPageNum);
}

function paginateContent() {
	var itemsPerPage = 15;

	if ($('.browse-by-topic #ajax-container li').length <= itemsPerPage) {
		$('.arg, .paging').hide();
	}
	else {
		$('.arg, .paging').show();
		$('.pageME').remove();
		$('<div class="pages pageME"></div>').appendTo('.browse-by-topic');
		$('.browse-by-topic').pajinate({
			num_page_links_to_display : 4,	
			items_per_page : itemsPerPage,	
			item_container_id: '#ajax-container',	
			nav_panel_id: '.pageME'	
		});
		$('.browse-by-topic .pageME, .browse-by-topic .arg').appendTo('.browse-by-topic .paging-frame');
	
		$('.pageME a.first_link, .pageME a.last_link, .pageME .ellipse').remove();
		$('.browse-by-topic .previous_link').insertBefore('.browse-by-topic .next_link');	
		
		updateTheNumberPaginate();
		
		$('.browse-by-topic .next_link, .browse-by-topic .previous_link, .browse-by-topic .page_link').click(function (){
			updateTheNumberPaginate();
		});
	}
}

function loadContent() {
	$("div#pagination a").click(function(event) {
		event.preventDefault();
		$(".torah-tab .items").load($(this).attr("href"), '', loadContent);
	});
}

$(document).ready(function(){
	// Toggle full bio on torah page for browse by author
	$('.view-full-bio').live("click", function(e){
		e.preventDefault();
		$(this).parents('.bio').find('.full, .short').toggle();
	});
	
	// Restaurant Search (in megamenu)
	$('#restaurant-search').submit(function(e){
		e.preventDefault();

		var restaurantLocation 		= $('.restaurant-location').val(),
			establishment 	= $('.restaurant-establishment').val(),
			resultPage 		= 'http://www.oukosher.org/index.php/dev/restaurants-dev/' + restaurantLocation + establishment;
			
		location.href = resultPage;
	});
	
	
	$('.ac_form').submit(function (e) {
        e.preventDefault();
        $(this).hide();
        var locationStr = $(this).find('.ac_location').val();
        if ($(this).attr('id') == 'ac-zmanim') {
            updateZmanim(locationStr);
        }
        else {
            updateList(locationStr, getUpdateListOptions($(this).attr('id')));
        }
    });
    
    
	// Podcasting page
	$('.search-area .text').keydown(function(e){
		if ((e.which >= 65 && e.which <= 122) || e.which == 8) {
			$val = $(this).val();
			if (e.which == 8)
				var value = $val.substr(0, $val.length - 1);
			else
				var value = $val + String.fromCharCode(e.which);
			var first = true;
			$('.podcast-list li').each(function(){
				var title = $(this).find('strong').html().toLowerCase();
				if (title.search('^' + value.toLowerCase()) >= 0 || value.length == 0) {
					$(this).show();
					if (first) {
						$(this).css('border', 'none');
						first = false;	
					}
				}
				else
					$(this).hide();
			});
		}
	});
	
	// Torah stand alone entry form
//	$('#torah-standalone #entryform').submit(function(){
		

//	});
});

(function($){$.fn.truncatable=function(options){var defaults={limit:100,more:'...',less:false,hideText:'[read less]'};var options=$.extend(defaults,options);return this.each(function(num){var stringLength=$(this).html().length;if(stringLength>defaults.limit){var splitText=$(this).html().substr(defaults.limit);var splitPoint=splitText.substr(0,1);var whiteSpace=new RegExp(/^\s+$/);for(var newLimit=defaults.limit;newLimit<stringLength;newLimit++){var newSplitText=$(this).html().substr(0,newLimit);var newHiddenText=$(this).html().substr(newLimit);var newSplitPoint=newSplitText.slice(-1);if(whiteSpace.test(newSplitPoint)){var hiddenText='<span class="hiddenText_'+num+'" style="display:none">'+newHiddenText+'</span>';var setNewLimit=(newLimit-1);var trunkLink=$('<a>').attr('class','more_'+num+'');$(this).html($(this).html().substr(0,setNewLimit)).append('<a class="more_'+num+'" href="#">'+defaults.more+'<a/> '+hiddenText);$('a.more_'+num).bind('click',function(){$('span.hiddenText_'+num).show();$('a.more_'+num).hide();if(defaults.less==true){$('span.hiddenText_'+num).append('<a class="hide_'+num+'" href="" title="'+defaults.hideText+'">'+defaults.hideText+'</a>');$('a.hide_'+num).bind('click',function(){$('.hiddenText_'+num).hide();$('.more_'+num).show();$('.hide_'+num).empty();return false})}});newLimit=stringLength}}}})}})(jQuery);

$(function(){
	 $('#header em.date').truncatable({	limit: 84, more: '.....', less: true, hideText: '[hide]' }); 
	});
