var isReady = false;

function readyCheck() {
	return isReady;
}

//works with readyCheck()
function loaded() {
	isReady = true;
}

function openPopup(path) {
	window.open(path,'Budcamp','menubar=no,scrollbars=yes,resizable=no,width=645,height=500');
}

function shareOnFacebook(path, title) {
	var fullPath = 'http://www.facebook.com/sharer.php?u='+ path +'&t='+ title;
	window.open(fullPath,'Budcamp','menubar=no,scrollbars=yes,resizable=no,width=645,height=500');
}

function makecookie(prov) {
	$.cookie('lda', 'set');
	$.cookie('camp_province', prov);
	$('#likeButton').css('display', 'block');
}

function checkcookie() {
	if($.cookie('lda') == 'set') {
		$('#likeButton').css('display', 'block');
		return true;
	}else {
		return false;
	}
}

// gets the current hash from the window location
function getURLParam(strHref){
	var strReturn = "";
	//var strHref = window.location.href;
	if ( strHref.indexOf("#") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("#")).toUpperCase();
		strReturn = strQueryString;
	}
	return strReturn;
}


function flashReady() {
	$('select').css('display', 'none');
	$('#instantWin')[0].animateIn(isWinner);
}

function closeFlash(param) {
	$('#instantWin').css('display', 'none');
	$.ajax({
	  url: 'includes/'+param+'.php',
	  success: function(data) {
	    $('#ajax').fadeOut('slow', function() {
			$('#ajax').html(data);
		});
		$('#ajax').fadeIn('slow', function() {});
	  }
	});
}

$(document).ready(function () {
	loaded();
	
	
	var locationObj = window.location.pathname;
	if((checkcookie() == false) && (locationObj.indexOf('index') == -1)){
		window.location.href = 'index.php';
	}
	
	if($('#ajax')[0] != undefined){
		$.metadata.setType("attr", "validate");
		errors = 0;
		isWinner = '';
		
	
		
		//alert('ready');
	}
});