$(document).ready(function(){
	
	// content fade in na loadanju stranice
	$("#contentContainer").fadeIn(800);
	//$("body").animate({ scrollTop: $(document).height() }, "slow");
	
});

// works page -- gallery ///////////////////////////////////////////////////////////////////////////////////////////
var slotIDGlob = 1;

function loadWork(id,backgroundID, contentID) {
	$("#galleryImage").css('background-image','url(../works/' + id + '.png)');
	centerPopup(backgroundID, contentID);
	$("#" + contentID).fadeIn();
	$("#" + backgroundID).fadeIn();
	$("#galleryNextBtn").hide();
	$("#galleryPreviousBtn").hide();
}

function loadFrame(slotID,backgroundID, contentID) {
	slotIDGlob = slotID;
	$("#galleryImage").css('background-image','url(../assets/big/' + slotID + '.jpg)');
	centerPopup(backgroundID, contentID);
	$("#" + contentID).fadeIn();
	$("#" + backgroundID).fadeIn();
	$("#galleryNextBtn").show();
	$("#galleryPreviousBtn").show();
}

function nextFrame() {
	if (slotIDGlob == 24)
		slotIDGlob = 0;
	slotIDGlob = slotIDGlob + 1;
	$("#galleryImage").css('background-image','url(../assets/big/' + slotIDGlob + '.jpg)');
}

function previousFrame() {
	if (slotIDGlob == 1)
		slotIDGlob = 25;
	slotIDGlob = slotIDGlob - 1;
	$("#galleryImage").css('background-image','url(./assets/big/' + slotIDGlob + '.jpg)');
}

function centerPopup(backgroundID, contentID) { 
 
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#" + contentID).height();
    var popupWidth = $("#" + contentID).width();
	
    var topDistance = windowHeight / 2 - popupHeight / 2 + $(document).scrollTop();
    if (topDistance < 18) topDistance = 18;
    $("#" + contentID).css({
        "position": "absolute",
        "z-index": 5,
        "top": topDistance,
        "left": windowWidth / 2 - popupWidth / 2
    });

    $("#" + backgroundID).css({
        "position:": "fixed",
        "z-index": 4
    });
	
    //radi IE6
    $("#" + backgroundID).css({
        "min-height": windowHeight
    });
}

function closeFrame(backgroundID, contentID) {
	$("#" + contentID).fadeOut();
	$("#" + backgroundID).fadeOut();
	$('.galleryItem').children().hide();
	$('.galleryItem').each(function(index) {
		$(this).children().delay(2000+index*30).fadeIn(300);
	});
}


// global -- jezik ///////////////////////////////////////////////////////////////////////////////////////////
var jezik = "eng"

function changeLanguage()
{
	if (jezik == "eng")
		jezik="bos";
	else
		jezik="eng";
	setupLanguage();
}

function setupLanguage(jezikLoc) {	
	if (jezikLoc!=undefined)
	jezik=jezikLoc;
	var currentYear = new Date();
	currentYear = currentYear.getFullYear();
	if (jezik == "eng")
	{
		$(".menuItemLink").removeClass("bos");
		$("#info").html('<p><a class="footerLink" href="http://www.kuruza.com">dražen grujić &nbsp | &nbsp official website &nbsp | &nbsp © '+currentYear+'</a></p>');
	}
	if (jezik == "bos")
	{
		$(".menuItemLink").addClass("bos");
		$("#info").html('<p><a class="footerLink" href="http://www.kuruza.com">dražen grujić &nbsp | &nbsp oficijelna web stranica &nbsp | &nbsp © '+currentYear+'</a></p>');
	}
}



//cufon
//Cufon.replace("h1", {fontFamily: "CArial"});
