// JavaScript Document

$(document).ready(function() {
	//showTweets($('#twitter'), 'ChalkandWire', 1, true)
	setupDemoForm();
	setupSmoothAnchors();
	setupFAQ();
	setupPrettyPhoto();
});


function setupDemoForm(){
	$("#header-demo-button").click(function(){
		$("#demo-request").fadeIn(250);
	});
	
	$("#demo-cancel").click(function(){
		$("#demo-request").fadeOut(250);
	});
	
	$("#demo-submit").click(function() {
	  $("#demo-request form").submit();
	});
}

function demoReceived() {
	$("#demo-request").fadeOut(250);
}

function setupFAQ(){
	if($("#accordion").length > 0){
		$("#accordion").accordion({
			header: 'h4',
			collapsible: true,
			active: false,
			autoHeight: false
		});	
	}
}

function setupPrettyPhoto(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'dark_rounded',
		show_title: false	
	});
}



function setupSmoothAnchors(){
	$(function(){
		$('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;
					$('html,body').animate({scrollTop: targetOffset}, 1000);
					return false;
				}
			}
		});
	});	
}
