$(window).load(function () {
	//vars
	var container = $("#doncafe-slider");
	var ul = $(".doncafe-offers", container),
	    li = $(".doncafe-offers li");

	var ulWidth = li.length * parseInt(li.css("width"));
	ul.css("width", ulWidth);

	//config
	var sliderOpts = {
		max: ulWidth - parseInt(container.css("width")),
		slide: function(e, ui) {
			ul.css("left", "-" + ui.value + "px");;
		}
	};
	if (li.length>3) {
		//create slider
		$("#slider").slider(sliderOpts);
	} else {
		$("#slider-area").hide();
	}
});



$(document).ready(function() {

	//$('div#flower').ifixpng(); 
	if ($.browser.msie && $.browser.version == "6.0") {
		$('#flower').css('background', 'none')
	}
	//hardcode blank value for target attribute to dev link & all links with no target attr
	$("#footer .dev a, .blank, a[rel='external']").attr("target","_blank");

	//cufonize
	Cufon.replace("#domainTitle", {
		fontFamily: "Georgia",
		fontWeight: "normal"
	});

	Cufon.replace("#page #main #content #primary ul.doncafe-list li .title", {
		fontFamily: "Georgia",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		hover: {
			color: "#FFF"
		}
	});

	Cufon.replace("#pageTitle", {
		fontFamily: "Georgia",
		fontWeight: "normal",
		textShadow: "-1px 1px #000"
	});

	var bodyClass = $("body").attr("class").split(" ");
	if (bodyClass[1]!="contact") {
		Cufon.replace("body.subdomain #page #main #content #secondary .head", {
			fontFamily: "Myriad Pro",
			fontWeight: "normal"
		});

		Cufon.replace("body.subdomain #page #main #content #secondary .head p span", {
			fontFamily: "Myriad Pro",
			fontWeight: "bold"
		});
	}


	Cufon.replace("#doncafe-product .product-title, #doncafe-product .box .box-title", {
		fontFamily: "Georgia",
		fontWeight: "normal",
		hover: {
			color: "#FFF"
		}
	});

	Cufon.replace("#doncafe-product .box .head", {
		fontFamily: "Georgia",
		fontWeight: "normal",
		textShadow: "-1px 1px #000"
	});

	Cufon.replace("#primary .box .box-content .title", {
		fontFamily: "Georgia",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		hover: {
			color: "#FFF"
		}
	});

	Cufon.replace(".parent_page_box h2.title", {
		fontFamily: "Georgia",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		hover: {
			color: "#FFF"
		}
	});

	Cufon.replace(".label", {
		fontFamily: "Myriad Pro",
		fontWeight: "bold",
		fontSize: "12px",
		color: "#FFF"
	});
	Cufon.replace(".label_big", {
		fontFamily: "Myriad Pro",
		fontWeight: "bold",
		fontSize: "15px",
		color: "#FFF"
	});
	
	
	
	
	
	
	
	
	Cufon.replace("#homepackages .item_title", {
		fontFamily: "Trebuchet MS",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		color: "#E0AE89"
	});
	Cufon.replace("#productpackages .item_title", {
		fontFamily: "Trebuchet MS",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		color: "#E0AE89"
	});
	Cufon.replace("h1", {
		fontFamily: "Trebuchet MS",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		color: "#E0AE89"
	});
	Cufon.replace(".innertitle", {
		fontFamily: "Trebuchet MS",
		fontWeight: "normal",
		color: "#E0AE89"
	});	
	Cufon.replace(".innertitle span", {
		fontFamily: "Trebuchet MS",
		fontWeight: "normal",
		color: "#CC6F2A"
	});	
	Cufon.replace("h3", {
		fontFamily: "Trebuchet MS",
		fontWeight: "normal",
		textShadow: "-1px 1px #000",
		color: "#EAC9B0"
	});	
	
	
	
	
	
	
	


	//pngFix
	if ($.browser.msie && $.browser.version == "6.0") {
		$.ifixpng('/_res/img/bullets/pixel.gif');
		$(".box, .visual, .presentation-border, #footer, body.active-offers ul.doncafe-offers li .visual, .dev a, #doncafe-product .product-logo, .contest-image img").ifixpng();
	}

	$("body.subdomain #navigation .bottomLine").hide();

	//navigation
	$("#navigation .primaryNav li").each(function(i) {
		$(this).hover(
			function() {
				$("#navigation .primaryNav").addClass("hover");
				$("#navigation .primaryNav li").eq(i).addClass("current");
				$("#navigation .primaryNav li a").eq(i).removeClass("inactive").addClass("active");
				$("#navigation .primaryNav li:not('.current') a").addClass("inactive");

				$("body.homepage #navigation .bottomLine").hide();

				var menuClasses = $(this).attr("class").split(" ");

				if (menuClasses[1]!="no-submenu") {
					var li_className = $(this).attr("class").split(" ");
					var li_pos = parseInt(li_className[0].substring(3,li_className[0].length));
					$("#navigation .secondaryNavs").show();
					$("#navigation .secondaryNavs .secondaryNav").hide();
					$("#navigation .secondaryNavs #subnav"+li_pos).fadeIn(300);
				} else {
					$("#navigation .secondaryNavs").hide();
				}

			},

			function() {
				$("#navigation .primaryNav li").eq(i).removeClass("current");
				$("#navigation .primaryNav li a").removeClass("active");

			}
		);

	});

	//contact Form
	$(".element:not('.terms') input:not('.focused'), textarea#userMessage").focus(function() {

		if ($(this).attr("id")!="company" && $(this).attr("id")!="phone") {
			$(this).addClass("focused");
		}

		})
		.blur(function() {
			if ($(this).attr("id")!="company" && $(this).attr("id")!="phone") {
				$(this).removeAttr("class");
			}
	});

	//fancybox la spoturi
	/* This is basic - uses default settings */
	$("a.fancyClass").fancybox({
			'frameWidth': 460,
			'frameHeight': 282,
			'overlayColor': "#000",
			'overlayOpacity': 0.8
	});


	//stylish select contest page
	$('select#sex').sSelect({ddMaxHeight: '50px'});
});