function getCookie(c_name) {
	if (document.cookie.length>0) {
		var c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			var c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
	    	return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function launchSite(){
	setCookie("hp",1,365);
	var els = $('body > div');
	els.each(function(i,d){
		setTimeout(function(){
			$(d).slideDown(800);
		}, i*680);
	});
	$("#womanPlayer").remove();
	$("#skipIntro").hide().remove();
	$("#HomepageSlider").hide();
	$("#Indicators").hide();
	$("#ArrowContainer").hide();
	setTimeout(function(){
		$("#HomepageSlider").fadeIn(800);
		$("#Indicators").fadeIn(600);
		$("#ArrowContainer").fadeIn(800);
	}, 1000 );

}
function launchWomanFlash() {
	var els = $('body > div').hide();
	$("<div/>").attr('id','womanPlayer').insertAfter( els.eq(0) );
	jwplayer("womanPlayer").setup({
        flashplayer: "/wp-content/themes/bossa_nova/javascript/player.swf",
        file: "/wp-content/uploads/2011/videos/BN_Intro-H264.mp4",
        height: 352,
        width: 616,
        backcolor:	 "EDF5F7",
        frontcolor: "EDF5F7",
        lightcolor: "EDF5F7",
        screencolor: "EDF5F7",
        controlbar: "none",
        autostart: true,
        stretching: "fill",
        icons: false,
        logo: {
            hide: false,
			timeout: 1,
			position: "top-right"
        },
		events: {
            onComplete: function() {
				launchSite();
            },
			onError: function() {
				launchSite();
            }
        }
    });

	$("<a/>").addClass("moreinfo").attr("id","skipIntro").html("Skip Intro").click(function(e){
		e.preventDefault();
		launchSite();
	}).insertAfter("#womanPlayer");
	els.eq(0).fadeIn(300);
}
$(document).ready(function(){
	//if (getCookie("hp")=="") {
		launchWomanFlash();
	//}
});
