CONTEXT_PATH = "";

PAGE_TITLE = "ILMA Fireplaces - Камини, Горивни камери, Скари, Барбекю, Аксесоари. ЕТ Илма, Nordpeis, Ilma, fireplaces, Илия Манолов, Нордпейс, камина, skara, скара, stove, kamina, kamini.";

//address handling
var addressValue = $.address.value();
if(addressValue != "/") {
	if(addressValue.indexOf("http://") != -1) {
		window.location = addressValue;
	} else {
		window.location = CONTEXT_PATH + addressValue;
	}
}

//document ready
$(function(){	
	embedHomeFlash();
});

function loadContent(element) {
		disableClickFunctions();
		$(".loader").css("display", "block");
		$('html, body').animate({
			scrollTop: $(".header").offset().top
		}, 200);
		var href = element.attr("href");
		var productLayout = $("<div class='main_wrp'></div>");
		productLayout.load(href, "ajax=true", function(){
			href = href.replace(CONTEXT_PATH, "");
			$.address.value(href);
			var newContent = productLayout.find(".main_cont").html();
			var newPagination = productLayout.find(".pag_cont").html();
			$(".main_cont").fadeOut("fast", function(){
				$(".main_cont").html("");
				$(".main_cont").html(newContent);
				disableClickFunctions();
				$(".main_cont").fadeIn("fast", function(){
					$(".loader").css("display", "none");
					embedHomeFlash();
					$(".pag_cont").html(newPagination);
					enableClickFunctions();
					if(typeof bindAboutEventFunctions == "function") {
						bindAboutEventFunctions();
					}
					if($(".open").html() != null) {
						document.title = $(".info>p").text() + " " + PAGE_TITLE;
					} else {
						document.title = PAGE_TITLE;
					}
				});
			});
		});
}

function disableClickFunctions() {
	$("a").unbind("click");
	$("a").click(function(){
		return false;
	});
}

function enableClickFunctions() {
	$("a").unbind("click");
	
	if(typeof bindCommonEventFunctions == "function") {
		bindCommonEventFunctions();
	}
	if(typeof bindHomeEventFunctions == "function") {
		bindHomeEventFunctions();
	}
	if(typeof bindNavigationEventFunctions == "function") {
		bindNavigationEventFunctions();
	}
	if(typeof bindPaginationEventFunctions == "function") {
		bindPaginationEventFunctions();
	}
	if(typeof bindThumbEventFunctions == "function") {
		bindThumbEventFunctions();
	}

//	$("a:not([href])").unbind("click");
//	$("a:not([href])").click(function(){
//		return false;
//	});
}


function embedHomeFlash() {
	var homeFlash = $("#home_flash");
	if (homeFlash.html() != null) {
		try {
			so = new SWFObject(CONTEXT_PATH + "/assets/flash/home_fla.swf", "homefla", "944", "315", "1");
			so.addParam("wmode", "transparent");
			so.write("home_flash");
		} catch (err) {
		}		
	}
}
