// Clothing Donations Javascript v0.1
$(function () {
// effects for the quick tips

// tip classes, up to 5 in the quick tips box
$('.tip1').click(function () {
	//$('.hidden').show();
    $('ul#mytips').hide();
    $('#tip1').removeClass('hidden').fadeIn('slow');
	return false;
});

$('.tip2').click(function () {
	//$('.hidden').show();
    $('ul#mytips').hide();
    $('#tip2').removeClass('hidden').fadeIn('slow');
	return false;
});

$('.tip3').click(function () {
	//$('.hidden').show();
    $('ul#mytips').hide();
    $('#tip3').removeClass('hidden').fadeIn('slow');
	return false;
});

$('.tip4').click(function () {
	//$('.hidden').show();
    $('ul#mytips').hide();
    $('#tip4').removeClass('hidden').fadeIn('slow');
	return false;
});

$('.tip5').click(function () {
	//$('.hidden').show();
    $('ul#mytips').hide();
    $('#tip5').removeClass('hidden').fadeIn('slow');
	return false;
});


// close buttons for the quick tips
$('.close1').click(function () {
	$('#tip1').addClass('hidden').fadeOut('slow');
	$('ul#mytips').show();
	return false;
});

$('.close2').click(function () {
	$('#tip2').addClass('hidden').fadeOut('slow');
	$('ul#mytips').show();
	return false;
});

$('.close3').click(function () {
	$('#tip3').addClass('hidden').fadeOut('slow');
	$('ul#mytips').show();
	return false;
});

$('.close4').click(function () {
	$('#tip4').addClass('hidden').fadeOut('slow');
	$('ul#mytips').show();
	return false;
});

$('.close5').click(function () {
	$('#tip5').addClass('hidden').fadeOut('slow');
	$('ul#mytips').show();
	return false;
});

// tab button for footer
$('.statefooter').hide();

$('#schedule-tab').click(function() {
  $('.statefooter').slideToggle('fast', function() {
    // Animation complete.
  });
});

});



// Slider functions
var totalitems = 3;
var teasersize = 3;

function trislidefunc_initCallback(carousel) {
	jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
};

function highlight(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control a:nth-child('+ liindex +')').attr("class","trislideactive");
};

function removehighlight(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control a:nth-child('+ liindex +')').removeAttr("class","trislideactive");
};


// Ride the carousel...
$(document).ready(function() {
    $("#cdtrislide").jcarousel({
        scroll: 1,
		visible: 1,
		wrap: 'last',
		auto: 12,
		size: 3,
		initCallback: trislidefunc_initCallback,
		itemVisibleInCallback:  highlight,
        itemVisibleOutCallback: removehighlight,
        buttonNextHTML: null,
        buttonPrevHTML: null,
		itemFallbackDimension: 611
    });

// initialize the accordian
	$("#faqcordian").accordion({
		autoHeight: false,
		navigation: true
	});
	
});

$(document).ready(function(){
	$(".jcarousel-control a").click(
		function(){
				$(".jcarousel-control a").removeClass("trislideactive");
				$(this).addClass("trislideactive");
			}
		);		   
});



		
		//var dataString = 'to='+ myphonenum + '&username=' + secname + '&pword=' + secpword + '&message=' + mymessage;




// End slider functions

// get tweets
/*
$(function() {

var query = "https://api.twitter.com/1/lists/statuses.json?slug=organizing-experts&owner_screen_name=CloDo_org&page=1&per_page=20";

$.ajax({
	   type: "GET",
	   dataType: "jsonp",
	   url: query,
	   success: processData
});

function processData(data) {
	$.each(data, function(i, item) {
		
function parseTwitterDate(text) {
//running regex to grab everything after the time
var newtext = text.replace(/(\d{1,2}[:]\d{2}[:]\d{2}) (.*)/, '$2 $1');
//moving the time code to the end
newtext = newtext.replace(/(\+\S+) (.*)/, '$2 $1')
var date = new Date(Date.parse(newtext)).toLocaleDateString();
var time = new Date(Date.parse(newtext)).toLocaleTimeString();
return date;
}

var myDate = parseTwitterDate(item.created_at);


function HtmlEncode(str)
{
  var el = document.createElement("div");
  el.innerText = el.textContent = str;
  str = el.innerHTML;
  delete el;
  return str;
}

$('<li></li>').html("<p><img src='"+item.user.profile_image_url_https+"'><strong>"+item.user.name+"</strong><br>"+ FormatIt(item.text) +"<br>"+dateFormat(myDate, "d mmm")+" <a href='http://www.twitter.com/share?text="+HtmlEncode(item.text)+"' target='_blank' class='retweetlink'>Retweets ("+item.retweet_count+")</a></p>").appendTo('#tweetfeed');

});
}

function FormatIt(text_results) { // Formats the text. Makes In Love become bold and adds links
	//text_results = text_results.replace(/(gissisim)/ig, '<strong class="inlove">$1</strong>');
	return text_results.linkify();
}

String.prototype.linkify = function() {  //Make links linkable
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/~.=]+/, function(m) {
		return m.link(m);
});
};

// set variables here
var newsInterval = 10000;
	
function slideArticle() {
	$('#tweetfeed li:last').clone().prependTo('#tweetfeed').css('display','none');
	$('#tweetfeed li:first').fadeIn(1000).slideDown(1000);
	$('#tweetfeed li:last').fadeOut().remove();
} 

setInterval(slideArticle, newsInterval);
}); */
