$(document).ready(function() {
	$('.real_klik').colorbox({width:1070, height: 610, inline:false});
	
	projectActive();
	$("#accordion").accordion({ 
		header: "h3", 
		autoHeight: false, 
		collapsible: true,
		event: 'mouseup'
	});
	daneKsiegow();
	scrool();
	sendEmail();
	imageClick();
});

function imageClick()
{
	$('.OneProjectBox img').click(
			function () {
				
				//alert($(this).next().attr('href'));
				$(this).next().click();
				//eval($(this).next().attr('href'));
			}
	);
	
	$('.OneProjectBox img').mouseenter(
			function () {
				$(this).next().hover();
			}
	);
}

function sendEmail()
{
	//alert('asa');
	//$('.EmailShare').colorbox({width:600, height: 310, inline:false});
	$('.share_email').click(
		function() {
			alert('sa');
		}
			);
}

function daneKsiegow()
{
	$('.kdData').click(
			function() {
				var display = $('#ksDataContent').css('display');
				if (display == 'none') {
					$('#ksDataContent').show('slow');
					if ($('.kdData img').attr('src') != './themes/prowokator/common/showAccoutingData.jpg') {
						$('.kdData img').attr('src', './themes/prowokator/common/btn-ukryjdaneksiegowe.jpg');
					}
				} else {
					$('#ksDataContent').hide('slow');
					if ($('.kdData img').attr('src') != './themes/prowokator/common/showAccoutingData.jpg') {
						$('.kdData img').attr('src', './themes/prowokator/common/btn-zobaczdaneksiegowe.gif');
					}
				}
			}
			);
}
function scrool()
{
$(".scroll").click(function(event){
	//prevent the default action for the click event
	event.preventDefault();

	//get the full url - like mysitecom/index.htm#home
	var full_url = this.href;

	//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
	var parts = full_url.split("#");
	var trgt = parts[1];

	//get the top offset of the target anchor
	var target_offset = $("#"+trgt).offset();
	var target_top = target_offset.top - 100;

	//goto that anchor by setting the body scroll top to anchor top
	$('html, body').animate({scrollTop:target_top}, 500);
});
}
function jById(href,id)
{
	var h=$('#'+id);
	h.load(href,{},function(){
		$('.real_klik').colorbox({width:1070, height: 610, inline:false});
		sendEmail();
		 imageClick()
		loadEnd(id);
	});
	loadStart(id);
}

function loadEnd(id) {
	var h=$('#'+id);
	//h.animate({opacity: 1},500);
}


function loadStart(id) {
	var h=$('#'+id);
	//h.animate({opacity: 0.4},400);
}
function loadStart2(id) {
	var h=$('#'+id);
	var he = h.css('height');
	
	var wi = h.css('width');
	hei = he.replace('px','');
	wid = wi.replace('px','');
	heig = (Math.round((hei)/2));
	widt = (Math.round((wid)/2));
	h.append('<div style=\'top:'+heig+'px; left: '+widt+'px;\' class=\'Loadrek\'></div>');
}
function projectActive()
{
	$('.custom_pager li a').click(
			function() {
				$('.custom_pager').find('li .active').removeClass('active');
				$(this).addClass('active');
			}
	);
}

function preLoad(id)
{
	$.colorbox({width:1070, height: 610, href:"prowokator,1,"+id+".html?ajax=y"});
}
