$(document).ready(function () {
	
	if ($('.aVasaTvrtkaJe').length > 0) {
		//klupko position
		var off = $('.aVasaTvrtkaJe').offset();
		var pos = off.top - 85;
		$(".klupko").css({
			background: "url(/images/klupko.png) -208px "+pos+"px no-repeat"
		});
		$(".klupkoBack").css({
			background: "url(/images/klupko.png) -227px "+pos+"px no-repeat #FFF"
		});
	}
	else if ($('.aVasaTvrtkaJe_en').length > 0) {
		//klupko position
		var off = $('.aVasaTvrtkaJe_en').offset();
		var pos = off.top - 85;
		$(".klupko").css({
			background: "url(/images/klupko.png) -208px "+pos+"px no-repeat"
		});
		$(".klupkoBack").css({
			background: "url(/images/klupko.png) -227px "+pos+"px no-repeat #FFF"
		});
	}
	
	if ($(".columnHolder").length > 0 && $(".klupkoFlipLow").length > 0) {
		var off = $('.top50').offset();
		var pos = off.top - 189;
		$(".klupkoFlipLow").css({
			background: "url(/images/klupkoFlip.png) -266px "+pos+"px no-repeat"
		});
		$(".klupkoFlipBackLow").css({
			background: "url(/images/klupkoFlip.png) -285px "+pos+"px no-repeat #FFF"
		});
	}
	
	//klupkoLow position (stranica nase usluge)
	/*
	.klupkoFlipLow {
	background: url(../images/klupkoFlip.png) -266px 126px no-repeat;	
}
div.klupkoFlipBackLow {
	background: url(../images/klupkoFlip.png) -285px 126px no-repeat;
}
	*/
	
	// resize footer
	var offset = $('#footer').offset();
	var fheight = 310;
	var y=offset.top+fheight;
	var h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight);
	if(y<h) {
		fheight = h - y + 280;
	}
	$('#footer').css('height',fheight+'px');
	
	//main page animation
	var _height = "278px";
	//FirstCompany
	$("li#companyFirst").hover(function () {
	if ($("li#companyFirst").is(':animated')) {
			return;
		}
	else {
		$("li#companyFirst").addClass ("pop green hover").removeClass("small").animate ({
			height: _height,
			top:"-100px"
			}, 220, function () {
				if ($("li#companyFirst").is(".hover")) {
					return;
				}
				else {
					$("li#companyFirst").addClass("small").removeClass ("pop").animate ({
					height:"150px",
					top: 0,
					opacity: 0
					}, 220, function () {
						$("li#companyFirst").removeClass("green").removeAttr("style");
					});
				}
			});
		}
		//mouseover end
	}, function () {
		$("li#companyFirst").removeClass("hover");
		if ($("li#companyFirst").is(':animated')) {
			return;
		}
		else {
			$("li#companyFirst").addClass("small").removeClass ("pop").animate ({
			height:"150px",
			top: 0,
			opacity: 0
			}, 220, function () {
				$("li#companyFirst").removeClass("green").removeAttr("style");
			});
		}
	});
	
	//SecondCompany
	$("li#companySecond").hover(function () {
	if ($("li#companySecond").is(':animated')) {
			return;
		}
	else {
		$("li#companySecond").addClass ("pop pink hover").removeClass("small").animate ({
			height: _height,
			top:"-100px"
			}, 220, function () {
				if ($("li#companySecond").is(".hover")) {
					return;
				}
				else {
					$("li#companySecond").addClass("small").removeClass ("pop").animate ({
					height:"150px",
					top: 0,
					opacity: 0
					}, 220, function () {
						$("li#companySecond").removeClass("pink").removeAttr("style");
					});
				}
			});
		}
		//mouseover end
	}, function () {
		$("li#companySecond").removeClass("hover");
		if ($("li#companySecond").is(':animated')) {
			return;
		}
		else {
			$("li#companySecond").addClass("small").removeClass ("pop").animate ({
			height:"150px",
			top: 0,
			opacity: 0
			}, 220, function () {
				$("li#companySecond").removeClass("pink").removeAttr("style");
			});
		}
	});
	
	//ThirdCompany
	$("li#companyThird").hover(function () {
	if ($("li#companyThird").is(':animated')) {
			return;
		}
	else {
		$("li#companyThird").addClass ("pop blue hover").removeClass("small").animate ({
			height: _height,
			top:"-100px"
			}, 220, function () {
				if ($("li#companyThird").is(".hover")) {
					return;
				}
				else {
					$("li#companyThird").addClass("small").removeClass ("pop").animate ({
					height:"150px",
					top: 0,
					opacity: 0
					}, 220, function () {
						$("li#companyThird").removeClass("blue").removeAttr("style");
					});
				}
			});
		}
		//mouseover end
	}, function () {
		$("li#companyThird").removeClass("hover");
		if ($("li#companyThird").is(':animated')) {
			return;
		}
		else {
			$("li#companyThird").addClass("small").removeClass ("pop").animate ({
			height:"150px",
			top: 0,
			opacity: 0
			}, 220, function () {
				$("li#companyThird").removeClass("blue").removeAttr("style");
			});
		}
	});
});