
$(document).ready(function(){
	if (document.cookie && document.cookie != '') {
		var cookies = document.cookie.split(';');
		for (var i = 0; i < cookies.length; i++) {
			var cookie = jQuery.trim(cookies[i]);
			if (cookie.substring(0, 6) == ('state_')) {
				cookie = cookie.substring(6);
				var idValueArr = new Array();
				idValueArr = cookie.split('=');
				document.getElementById(idValueArr[0]).style.display = idValueArr[1];
			}
		}
	}

	if (document.cookie == '')
	{
		setTimeout("jQuery('#expandTab').click()", 1250)
	}


	$('#collapseTab').click(function(){
		$(this).fadeOut("fast");
		$('#panel').slideToggle(300);
		$('#expandTab').fadeIn("slow");
		$('#expandableFeaturesContainer').slideUp("normal");
		$.cookie('state_expandTab','block');
		$.cookie('state_panel','none');
		$.cookie('state_expandableFeaturesContainer','none');
		$.cookie('state_collapseTab','none');
		return false;
	 });

	$('#expandTab').click(function(){
		$(this).fadeOut("fast");
		$('#panel').slideToggle(300);
		$('#collapseTab').fadeIn("slow");
		$('#expandableFeaturesContainer').slideDown("normal");
		$.cookie('state_expandTab','none');
		$.cookie('state_panel','block');
		$.cookie('state_expandableFeaturesContainer','block');
		$.cookie('state_collapseTab','block');
		return false;
	 });

	$('#testimonialsOpenClose').click(function(){
		$("#testimonials .tabContent").slideToggle("fast");
		$("#testimonials ul li a").toggleClass("arrowDownTab");
		return false;
	 });

	$('#featClientOpenClose').click(function(){
		$("#featClient .tabContent").slideToggle("fast");
		$("#featClient ul li a").toggleClass("arrowDownTab");
		return false;
	 });

	$('#blogOpenClose').click(function(){
		$("#blog .tabContent").slideToggle("fast");
		$("#blog ul li a").toggleClass("arrowDownTab");
		return false;
	 });

// sitemap popup (click sitemap on home page. Doesn't work in ie6. a id sitemapTrigger is currently only on the index page)
	$("a#sitemapTrigger").click(function () {
		$("#popup_sitemap").fadeIn("slow");
	});

	$("#popup_closer").click(function () {
		$("#popup_sitemap").fadeOut("normal");
	});


// tab expand collapse toggle (DO NOT ERASE. This is for the expandable tabs in the bottom panel.)

//	$('#testimonials').click(function(){
//		$("#testimonials .tabContent").slideToggle("fast");
//		$("#testimonials ul li a").toggleClass("arrowDownTab");
//		return false;
//	 });
//
//	$('#news').click(function(){
//		$("#news .tabContent").slideToggle("fast");
//		$("#news ul li a").toggleClass("arrowDownTab");
//		return false;
//	 });
//
//	$('#blog').click(function(){
//		$("#blog .tabContent").slideToggle("fast");
//		$("#blog ul li a").toggleClass("arrowDownTab");
//		return false;
//	 });


// Home page services
$('#webAppAnimation').hover(
	function() {
		$('#svc_scroll').stop().scrollTo('p#svc1', 300);
	},
	function() {
});

$('#shopCartAnimation').hover(
      function () {
        $('#svc_scroll').stop().scrollTo('p#svc2', 300);
      },
      function () {
      });

$('#cmsAnimation').hover(
	function() {
		$('#svc_scroll').stop().scrollTo('p#svc3', 300);
	},
	function() {
});

// Animations for about the team

$('a#dave').hover(function() {
	$('.descriptionBoxContent').stop().scrollTo('#daveDiv', 350, {offset:-10});
	},
	function() {
});

$('a#dan').hover(function() {
	$('.descriptionBoxContent').stop().scrollTo('#danDiv', 350);
	},
	function() {
});

$('a#matt').hover(function() {
	$('.descriptionBoxContent').stop().scrollTo('#mattDiv', 350);
	},
	function() {
});

$('a#chris').hover(function() {
	$('.descriptionBoxContent').stop().scrollTo('#chrisDiv', 350);
	},
	function() {
});

$('a#blake').hover(function() {
	$('.descriptionBoxContent').stop().scrollTo('#blakeDiv', 350);
	},
	function() {
});


// -----this is contact box 1 animations ------

	//$("#contactBox1 div.descriptionBoxContent a.down").click(function(){
//		$("#contactBox2, #contactBox3").fadeOut("fast");
//		$("#contactBox1").animate({
//			width: "800px"
//		}, 1500 );
//	$("#contactBox1 div.descriptionBoxContent .summary").fadeOut("slow");
//		$("#contactBox1 div.descriptionBoxContent .full").fadeIn("slow");
//		});


// days checkboxes for consultation form
	$(".days").click(function () {
		$(this).toggleClass("daysChecked");
	});

// ------ Contact Box 1 expands
	$("#contactBox1 div.descriptionBoxContent a.down").click(function(){
		$("#contactBox2, #contactBox3").fadeOut("fast", function() {
		$("#contactBox1").animate({
			width: "800px"
		},480,'linear',function(){
		$("#contactBox1 div.descriptionBoxContent .summary").fadeOut("fast", function() {

		$("#contactBox1 div.descriptionBoxContent .full").slideDown("slow");
		});
		});
		});
	});

// ----- Contact Box 1 collapses
	$("#contactBox1 div.descriptionBoxContent .full a.arrowUpContact").click(function(){
	$("#contactBox1 div.descriptionBoxContent .full").slideUp("normal", function () {
		$("#contactBox1 div.descriptionBoxContent .summary").fadeIn("slow", function () {
		$("#contactBox1").animate({
			width: "255px"
		}, 380,'linear',function () {
		$("#contactBox2, #contactBox3").fadeIn("fast");
		});
		});
		});
	});

// ------ Contact Box 2 expands
	$("#contactBox2 div.descriptionBoxContent a.down").click(function(){
		$("#contactBox3").fadeOut("fast", function() {
		$("#contactBox1").hide("normal");
		$("#contactBox2").animate({
			width: "800px"
		},480,'linear',function(){
		$("#contactBox2 div.descriptionBoxContent .summary").fadeOut("fast", function() {

		$("#contactBox2 div.descriptionBoxContent .full").slideDown("slow");
		});
		});
		});
	});

// ----- Contact Box 2 collapses
	$("#contactBox2 div.descriptionBoxContent .full a.arrowUpContact").click(function(){
	$("#contactBox2 div.descriptionBoxContent .full").slideUp("normal", function () {
		$("#contactBox2 div.descriptionBoxContent .summary").fadeIn("slow", function () {
		$("#contactBox1").show("normal");
		$("#contactBox2").animate({
			width: "255px"
		}, 380,'linear',function () {
		$("#contactBox3").show("fast");
		});
		});
		});
	});

// ------ Contact Box 3 expands
	$("#contactBox3 div.descriptionBoxContent a.down").click(function(){
		$("#contactBox1, #contactBox2").fadeOut("fast", function() {
		$("#contactBox3").animate({
			width: "800px"
		},480,'linear',function(){
		$("#contactBox3 div.descriptionBoxContent .summary").fadeOut("fast", function() {

		$("#contactBox3 div.descriptionBoxContent .full").slideDown("slow");
		});
		});
		});
	});

// ----- Contact Box 3 collapses
	$("#contactBox3 div.descriptionBoxContent .full a.arrowUpContact").click(function(){
	$("#contactBox3 div.descriptionBoxContent .full").slideUp("normal", function () {
		$("#contactBox3 div.descriptionBoxContent .summary").fadeIn("slow", function () {
		$("#contactBox3").animate({
			width: "255px"
		}, 380,'linear',function () {
		$("#contactBox1, #contactBox2").fadeIn("fast");
		});
		});
		});
	});

// ------ support box 3 expands
	$("#supportBox3 div.descriptionBoxContent ul.customList a").click(function(){
		$("#supportBox1, #supportBox2").fadeOut("fast", function() {
		$("#supportBox3").animate({
			width: "800px"
		},480,'linear',function(){
		$("#supportBox3 div.descriptionBoxContent .summary").fadeOut("fast", function() {
		$("#supportBox3 div.descriptionBoxContent .full").slideDown("slow", function () {
		$("a.arrowUpContact").fadeIn("fast");
		});
		});
		});
		});
	});

// ----- support box 3 collapses
	$("#supportBox3 div.descriptionBoxContent .full a.arrowUpContact").click(function(){
	$(this).fadeOut("fast", function () {
	$("#supportBox3 div.descriptionBoxContent .full").slideUp("normal", function () {
		$("#supportBox3 div.descriptionBoxContent .summary").fadeIn("slow", function () {
		$("#supportBox3").animate({
			width: "255px"
		}, 380,'linear',function () {
		$("#supportBox1, #supportBox2").fadeIn("fast");
		});
		});
		});
	});
	});


	$('#contactForm').formValidation({
 		newmask : /[0-9]{1}-[0-9]{1}/,	// 1-1
 		err_class : "invalidInput"
  	});

	$('#consultForm').formValidation({
 		newmask : /[0-9]{1}-[0-9]{1}/,	// 1-1
 		err_class : "invalidInput"
  	});
});
