$(document).ready(function(){

/*	----------------------DETAILS----------------------	*/

	//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	//Caption Sliding (Partially Hidden to Visible)
	$('.boxgrid.caption').hover(function(){
		$(".cover", this).stop().animate({top:'190px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'250px'},{queue:false,duration:160});
	});
	
	$(".accordion h3:first").addClass("active");
	$(".accordion p:not(:first)").hide();

	$(".accordion h3").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});
	

	/*	------------------------MENU-----------------------------	*/


	$("#nav-reflection li").append('<span class="ref"></span><span class="hint"></span>');
	$("#nav-reflection a").hover(function() {
		$(this).stop().animate({ marginTop: "-10px" }, 200);
		$(this).parent().find("span.ref").stop().animate({ marginTop: "18px", opacity: 0.25 }, 200);
	},function(){
		$(this).stop().animate({ marginTop: "0px" }, 300);
		$(this).parent().find("span.ref").stop().animate({ marginTop: "1px", opacity: 1 }, 300);
	});

	$("#nav-reflection a").hover(function() {
		$(this).parent().find("span.hint").stop(true, true).animate({opacity: "show" }, "slow");
		var hoverText = $(this).attr("title");
		$(this).parent().find("span.hint").text(hoverText);
	}, function() {
		$(this).parent().find("span.hint").stop(true, true).animate({opacity: "hide" }, "fast");
	});

	/*	-----------------------FILTER PORTFOLIO------------------------	*/
	

	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});


	/*	-----------------------------MAIN PAGE-------------------------------	*/
	

	$('ul.tabs li').css('cursor', 'pointer');

	$('ul.tabs.tabs1 li').click(function(event){
		var thisClass = this.className.slice(0,2);
		$('div.t1').hide();
		$('div.t2').hide();
		$('div.' + thisClass).show();
		$('ul.tabs.tabs1 li').removeClass('tab-current');
		$(this).addClass('tab-current');
		event.preventDefault();
	});

	$(".displayall").click(function(){
		$(".companies").slideToggle("slow")
		return false;
	});

	/*	-------------------------------PRICE------------------------------	*/
	

	var i = 0;

	$("a.displaytips").click(function(){
		$(this).parent().parent().find("div.tips").slideToggle("slow");
		return false;

	});

	$(".displaypages").click(function(){
		i++; 
		$(".pages").slideToggle("slow")
		if (i > 1) {
			$(".pages input").attr('checked','');
			i = 0;
		}
	});
	

	$(".radiogrup").bind('click',function() {
			if ($(this).attr('id') == 'radioHide' && $(this).attr('checked')) 
			$('#modules').slideToggle('slow');
			else {
				$('#modules').hide();
				$("#modules input").attr('checked','');
			}
	});

});

var checkbox = document.getElementsByTagName("input");
function calc() {
	var sum1 = 0;
	var sum2 = 0;
	for (var i = 0; i < checkbox.length; i++) {
		if (checkbox[i].checked) {
			if (checkbox[i].name == "postoyanno") {
				sum2 = sum2 + parseInt(checkbox[i].value);
				}
			else sum1 = sum1 + parseInt(checkbox[i].value);
		}
	}
	document.getElementById("sum1").value = sum1;
	document.getElementById("sum2").value = sum2;
}
