function fakeClick(fn) {
	var $a = $('<a href="#" id="fakeClick"></a>');
		$a.bind("click", function(e) {
			e.preventDefault();
			fn();
		});
	
	$("body").append($a);
			
	var evt, 
		el = $("#fakeClick").get(0);
	
	if (document.createEvent) {
		evt = document.createEvent("MouseEvents");
		if (evt.initMouseEvent) {
			evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
			el.dispatchEvent(evt);
		}
	}
	
	$(el).remove();
}

function openVideo(url, w, h) {
	Shadowbox.open({
        content:    url,
        player:     "iframe",
        height:     h,
        width:      w
    });
}

function openMessagePopup(videop) {
	if (videop) {
		videop.pause();
	}
	$("#message-popup-wrapper").show();
	$(".content").hide();
	$("#message-popup-wrapper .close").hide();
	$("#message-popup-wrapper .message-popup").css("overflow", "hidden");
	$(".message-popup").width(0).height(0).animate({width: "754px", height: "396px"},{queue: false, duration: 1000, step: function() {
		$("#message-popup-wrapper .message-popup").vAlign();
	}, complete: function() {
		$("#message-popup-wrapper .close").show();
		$("#message-popup-wrapper .message-popup").css("overflow", "visible");
	}});
}

function closeMessagePopup(videop) {
	$("#message-popup-wrapper .close").hide();
	$(".message-popup").animate({width: "0", height: "0"},{queue: false, duration: 1000, step: function() {
		$("#message-popup-wrapper .message-popup").vAlign();
	}, complete: function() {
		$("#message-popup-wrapper").hide();
		$(".content").show();
		$(".popup .form-arrow").hide();
		$(".popup").css("overflow", "hidden");
		$(".popup").css("height", "0px").animate({height: "336px"}, {queue: false, duration: 1000, complete: function() {
			$(".popup").css("overflow", "visible");
			$(".popup .form-arrow").show();
			if (videop) {
				videop.play();
			}
		}, step: function(){
			$(window).resize();
		}});
	}});
}

$(document).ready(function(){
	jQuery.easing.def = 'easeInOutExpo';
	
	$(".text-input").each(function() {
		$(this).attr("rel", $(this).val());
	});
	
	$(".text-input").focus(function(){
		if ($(this).val() == $(this).attr("rel")) {
			$(this).val("");
		}
	});
	
	$(".text-input").blur(function(){
		if ($(this).val() == "") {
			$(this).val($(this).attr("rel"));
		}
	});
	
	$(window).resize(function() {
		var w = $(window).width();

		w = (w > 1124) ? w : 1124;

		$("#wrapper").width(w);
		
		$("#content-wrapper").width(w);

		$("#message-popup-wrapper").width(w);
		
		$(".content").width(w);
		
		$("#background").width(w);
		
		$("#header-wrapper").width(w);
		$("#footer-full-wrapper").width(w);
		$("#footer-wrapper").width(w);
	});
	
	$("#background img").load(function() {
		$(window).resize();
	});
	
	$(".menu li a").hover(function() {
		$(this).find(".bg-fill").animate({ width: $(this).outerWidth()+"px" }, {duration: 250, queue: false, ease: 'easeInOutLinear'});
	},function() {
		$(this).find(".bg-fill").animate({ width: "0px" }, {duration: 250, queue: false, ease: 'easeInOutLinear'});
	});
	
	$(".menu li").hover(function() {
		$(this).find("ul").eq(0).show();
	},function() {
		$(this).find("ul").eq(0).hide();
	});
	
	$(".side-nav li a").hover(function() {
		$(this).find(".bg-fill").animate({ width: $(this).outerWidth()+"px" }, {duration: 250, queue: false, ease: 'easeInOutLinear'});
	},function() {
		$(this).find(".bg-fill").animate({ width: "0px" }, {duration: 250, queue: false, ease: 'easeInOutLinear'});
	});
	
	//$("#header-wrapper").css("top", "-"+$("#header-wrapper").height()+"px");

});

