// JavaScript Document

$(document).ready(function(){
	
	var headerActive = 0;
	
	$('div#content div.request h2 a').toggle(
		function () {
        	$(this).parent().next().slideDown(500);
      	},
      	function () {
        	$(this).parent().next().slideUp(500);
    	}
	);
	
	//$('body#contact div#content div.request form').slideDown(1000);
	
	/*$('div#content div.service span.details a').hover(function () {
    	$(this).addClass('hilite');
    }, function () {
    	$(this).removeClass('hilite');
    });*/
	
	$("#accordion:not(body#contact #accordion)").accordion({
		active: false,
		animated: 'swing',
		duration: 500,
		header: ".header",
		clearStyle: true,
		collapsible: true,
		icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-minus' }
	});
	
	//$("div#accordion div#content div.contact-content").css('display', 'block');
	
	$('body#home div#accordion div.project div.header').toggle(
		function () {
			$(this).parent().parent().find('div.project div.img-wrap').not($(this).next().next().find('div.img-wrap')).css('height', '185px');
			if ($(this).hasClass('ui-state-active')) {
				$(this).next().next().find('div.img-wrap').animate({ height: '285px' });
			} else {
				$(this).next().next().find('div.img-wrap').animate({ height: '185px' });
			}
      	},
      	function () {
			if ($(this).hasClass('ui-state-active')) {
				$(this).parent().parent().find('div.img-wrap').not($(this).next().next().find('div.img-wrap')).css('height', '185px');
				$(this).next().next().find('div.img-wrap').animate({ height: '285px' });
			} else {
				$(this).next().next().find('div.img-wrap').animate({ height: '185px' });
			}
    	}
	);
	
	$('body#projects div#accordion div.project div.header').toggle(
		function () {
			$(this).parent().parent().find('div.project div.img-wrap').not($(this).next().next().find('div.img-wrap')).css('height', '185px');
			if ($(this).hasClass('ui-state-active')) {
				$(this).next().next().find('div.img-wrap').animate({ height: '285px' });
				$(this).parent().parent().find('div.img-box').not($(this).next().next()).slideUp(300);
				$(this).next().next().slideDown(300);
			} else {
				$(this).next().next().find('div.img-wrap').animate({ height: '185px' });
				//$(this).next().next().slideUp();
			}
      	},
      	function () {
			if ($(this).hasClass('ui-state-active')) {
				$(this).parent().parent().find('div.img-wrap').not($(this).next().next().find('div.img-wrap')).css('height', '185px');
				$(this).next().next().find('div.img-wrap').animate({ height: '285px' });
				$(this).parent().parent().find('div.img-box').not($(this).next().next()).slideUp(300);
				$(this).next().next().slideDown(300);
			} else {
				$(this).next().next().find('div.img-wrap').animate({ height: '185px' });
				//$(this).next().next().slideUp();
			}
    	}
	);
	
	$('body#projects div#accordion div.project div.header').hover(
			
			function () {
				if (!($(this).parent().parent().find('div.project div.header').hasClass('ui-state-active'))) {
					//alert('hover');
					$(this).next().next().slideDown(300);
					$(this).parent().parent().find('div.img-box').not($(this).next().next()).slideUp(300);
				}
				
			},
			function () {
				if (!($(this).parent().parent().find('div.project div.header').hasClass('ui-state-active'))) {
					//$(this).next().next().slideUp();
				}
			}
			
	);
	
	$('body#projects div#accordion div.project div.img-box:first').slideDown(500);
	
	
	
});