
ddaccordion.init({
	headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	contentclass: "categoryitems", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


$('.terrcycle') 
.cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 2000
});

jQuery.extend({
  min: function(a, b) { return a < b ? a : b; },
  max: function(a, b) { return a > b ? a : b; }
});

$(window).resize(function() {
	if ($('.arrowlistmenu').is(":visible")){
		$('#container').css('width', jQuery.max(1024, jQuery.min($(window).width(), 1280)) + 'px');
		$('#wrap').css('width', jQuery.max(1024, jQuery.min($(window).width(), 1280)) + 'px');
		$('#main').css('width', jQuery.max(1024, jQuery.min($(window).width(), 1280)) + 'px');
		$('#navigation').css('marginLeft', '-' + jQuery.max(1024, jQuery.min($(window).width(), 1280)) + 'px');
		$('#footer').css('width', jQuery.max(1024, jQuery.min($(window).width(), 1280)) - 220 - 160 + 'px');
	};
});


$(document).ready(function() {
	$("a.gallery").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'cyclic'		:	true,
		'hideOnOverlayClick': true,
		'titlePosition'	:	'inside',
		'overlayOpacity' : 0,
		'onStart' : function() {$('#terrcycle').cycle('pause');},
		'onClosed' : function() {$('#terrcycle').cycle('resume');}
	}); 
	$('input.text').focusin(function(){
		var $this = $(this);
		var $fake_text = $this.parent().children('.fake_text').val();
		if ($this.val() == $fake_text) $this.val('');
	});
	$('input.text').focusout(function(){
		var $this = $(this);
		var $fake_text = $this.parent().children('.fake_text').val();
		if ($this.val().length == 0) $this.val($fake_text);
	});
	$('input.text').focusout();
	$('#manufacturer').change(function() {
		var $this = $(this);
		$this.parent().submit();
	});
	$('#calculate_terr').submit(function(){
		jQuery.post("../../workshop/calculator/count", 
					{l: $('#l').val(), d: $('#d').val(), h: $('#h').val(), ht: $('#ht').val(), terrarium: $('#terrarium').val() }, 
					function(data){ $('#price_div').html(data);}, 
					"html");
		//alert('inside');
		return false;
	});
	$('#log').ajaxError(function(event, xhr, request, settings){
		$(this).append("<li>Error requesting page " + settings.url + "</li><li>" + request.status + "<li>" + settings);
	});
	
	$('#subcatheader').click(function(){
		if ($('#subcatlist').is(":visible")){
			$('#subcatlist').hide('fast');
			$('#subcatheader').removeClass('subclassexpand').removeClass('openheader').addClass('closeheader');
		}
		else {
			$('#subcatlist').show('fast');
			$('#subcatheader').removeClass('subclassexpand').removeClass('closeheader').addClass('openheader');
		}
		return false;
	});
	if (top.location != self.location) { top.location = self.location; }
	$(window).resize();
	if (disqus_shortname!==null){
		(function() {
			var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
			dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
			(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
		})();};
	
});



