$(function(){

	Cufon.replace('h2');
	Cufon.replace('h3');
	Cufon.replace('h4');
	Cufon.replace('.categoryheader p');



	var slider_x = 0;
	var y = 0;
	$('#homeslider .info .circles li').click(function() {
		y = 1;
		$('#homeslider .info .circles li').removeClass('active');
		$(this).addClass('active');
		slider_x = $('#homeslider .info .circles li').index($(this));
		$('#homeslider #slides li').fadeOut(1000);
		$('#homeslider #slides li').eq(slider_x).fadeIn(1000);
		$('#homeslider #slides li').eq(slider_x).css({"display":"block"});
		$('#homeslider #text li').fadeOut();
		$('#homeslider #text li').eq(slider_x).fadeIn(1000);
	});

	setInterval(function() {
	if(y ==0) {
		slider_x++
		if(slider_x == 8) { slider_x = 0; }
		$('#homeslider .info .circles li').removeClass('active');
		$('#homeslider .info .circles li').eq(slider_x).addClass('active');
		$('#homeslider #slides li').fadeOut(1000);
		$('#homeslider #slides li').eq(slider_x).fadeIn(1000);
		$('#homeslider #slides li').eq(slider_x).css({"display":"block"});
		$('#homeslider #text li').fadeOut();
		$('#homeslider #text li').eq(slider_x).fadeIn(1000);
	}
	}, 5000)

	getTwitters('tweet', {
	  id: 'bima',
	  count: 9,
	  enableLinks: true,
	  ignoreReplies: true,
	  clearContents: true,
	  callback:changeTwitterHeight,
	  template: '<small><a href="http://twitter.com/%user_screen_name%/statuses/%id%/">Twitter</a>&nbsp;&nbsp;&bull;&nbsp;&nbsp;%time%</small><p>%text%</p>'
	});

	function changeTwitterHeight() {
		var twitterheight1 = $('#tweet li').eq(0).height();
		var twitterheight2 = $('#tweet li').eq(1).height();
		var twitterheight3 = $('#tweet li').eq(2).height();
		var twitterheight4 = $('#tweet li').eq(3).height();
		var biggestheight = Math.max(twitterheight1, twitterheight2, twitterheight3, twitterheight4);
		$('#tweet li').css({"height":biggestheight});
	}

	var threecolboxheight1 = $('.threecols .col').eq(0).height();
	var threecolboxheight2 = $('.threecols .col').eq(1).height();
	var threecolboxheight3 = $('.threecols .col').eq(2).height();
	var biggestheight = Math.max(threecolboxheight1, threecolboxheight2, threecolboxheight3);
	$('.threecols .col').css({"height":biggestheight});


	$('.faq h5').click(function() {
		$(this).parent('.faq').find('.inner').slideToggle();
		$(this).parent('.faq').find('.close').toggle();
	});

	$('.faq .close').click(function() {
		$(this).parent('.faq').find('.inner').slideToggle();
		$(this).toggle();
		return false;
	});

	var show = 0;
	$('a.showallfaqs').click(function() {
	if(show == 0) {
		show = 1;
		$('.faq .inner').slideDown();
		$('.faq .close').fadeIn();
		if($(this).text() == "click to view them all") { $(this).text('hide all help topics'); }
		if($(this).text() == "show all terms and conditions") { $(this).text('hide all terms and conditions'); }
	} else {
		show = 0;
		$('.faq .inner').slideUp();
		$('.faq .close').fadeOut();
		if($(this).text() == "hide all help topics") { $(this).text('click to view them all'); }
		if($(this).text() == "hide all terms and conditions") { $(this).text('show all terms and conditions'); }
	}
		return false;
	});


    $('a[href*=#]').click(function() {

    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {

            var $target = $(this.hash);

            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');

            if ($target.length) {

                var targetOffset = $target.offset().top -25;

                $('html,body').animate({scrollTop: targetOffset}, 1000);

                return false;

            }

        }

    });


	var scrollto;
	var minus120 = 0;
	$('.categoryjump').change(function(){
		scrollto = $(this).val();
		if(minus120 == 0) {
			$('html, body').animate({
				scrollTop: $(scrollto).offset().top -85
			}, 1000);
		} else {
			$('html, body').animate({
				scrollTop: $(scrollto).offset().top -25
			}, 1000);
		}

	 });




});
