function pesachCheckRegister(which){
//setCookie("pesachregister","1","0");

var thecookie=jQuery.cookie('pesachregister');


  if (thecookie!=null && thecookie!="")
  {
		files = new Array();
		files["instructions"] = "directions.pdf";
		files["collage"] = "Modern%20Miracle%20Collage.pdf";
		files["trigger_children"] = "afikomen%20cards.pdf";
		files["trigger_adults"] = "GUIDED%20CONVERSATIONS.pdf";
		files["four_questions"] = "4%20Questions%20for%203%20People.pdf";
	  //jQuery.post("/wp-content/jquery_functions.php",{'fetchfile':'1','file':files[which]});

		jQuery().remove('#fade');
		jQuery().remove('#popupBlock');

	location.href="/wp-content/uploads/"+files[which];
  }else{

width = 600;
height = 400;

fadediv = "<div id=fade></div>";
popupBlockdiv = "<div id=popupBlock></div>";

jQuery("body").append(fadediv,popupBlockdiv);
jQuery("#popupBlock").html("<div style='width:100%;height:100%;margin:0 auto'>One moment...</div>");

//Define margin for center alignment (vertical + horizontal)
var popMargTop = height / 2;
var popMargLeft = width / 2;

//Apply Margin to Popup
jQuery('#popupBlock').css({
'width' : width,
'height' : height,
'margin-top' : -popMargTop,
'margin-left' : -popMargLeft,
'padding' : 10
});

jQuery("#fade").show();
jQuery("#popupBlock").show();

jQuery("#fade").live('click',function(){
		jQuery().remove('#fade');
		jQuery().remove('#popupBlock');
	});


jQuery.get("/wp-content/jquery_functions.php",{'pesachcheckregister':'1','file':which},function(data){

			response = jQuery.parseJSON(data);

//alert(response.code);

			if(response.code < 1){

				jQuery("#popupBlock").empty();
				jQuery("#popupBlock").html(response.content);

			}else{
				jQuery().remove('#fade');
				jQuery().remove('#popupBlock');
				alert(response.content);

			}
		});

	}
}

jQuery(document).ready(function(){
	if(window.location.search.indexOf("success")!=-1){
			setCookie("pesachregister","1","0");
		}
	});


//////////////////////////////////////////////////////

function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + 45);
	var c_value=escape(value) + ((exdays==null) ? "" : "; path=/;expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
	var rawcookie = document.cookie.split(";");
	for(i=0;i<rawcookie.length;i++){
		alert(rawcookie[i]);
	}
}



/*jslint browser: true */ /*global jQuery: true */

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

// TODO JsDoc

/**
 * Create a cookie with the given key and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String key The key of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given key.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String key The key of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

