function subscribeToNewsletter () {
	var ajaxResponse = 
		$.ajax ({
			url: "/v2/classes/omdb_ajax.php",
			type: "POST",
			dataType: "json",
			data: $("#newsletterSubscribe").serialize (),
			success: function (json) {
				if (json.status == 0) { 
					$("#newsletterSubscribe div").hide ();
					$("#newsletterSuccess").html (json.success);
					$("#newsletterSuccess").fadeIn ("slow").delay (5000).fadeOut ("slow");
				} else {
					var errorString = "";
					for (i = 0; i < (json.error.length - 1); i++) {
						errorString += json.error [i] + "<br />";
					}
					errorString += json.error [json.error.length - 1];
				
					$("#newsletterError").html (errorString);
					$("#newsletterError").fadeIn ('slow');
				}
			}
   		}).responseText;
		
	return false;
}


var popupStatus = 0; 

function openPopup () {
    centerPopup ();
    loadPopup ();
}

//centering popup  
function centerPopup(){  
//request data for centering  
    var windowWidth = document.documentElement.clientWidth;  
    var windowHeight = document.documentElement.clientHeight;  
    var popupHeight = $("#popupContent").height();  
    var popupWidth = $("#popupContent").width();  
    //centering  
    $("#popupContent").css({  
        "position": "fixed",  
        "top": windowHeight/2-popupHeight/2,  
        "left": windowWidth/2-popupWidth/2  
    });  
//only need force for IE6  
  
    $("#backgroundPopup").css({  
    "height": windowHeight  
    });  
  
}

//loading popup with jQuery magic!  
function loadPopup(){  
//loads popup only if it is disabled  
    if(popupStatus==0){  
        $("#backgroundPopup").css({  
            "opacity": "0.7"  
        });  
        $("#popupContent").css({  
            "opacity": "1.0"  
        });  
        $("#backgroundPopup").fadeIn ("slow");  
        $("#popupContent").fadeIn ("slow", function () {
	        $.fx.off = true;
        });  
        popupStatus = 1;  
    }  
}

//disabling popup with jQuery magic!  
function closePopup(){  
    //disables popup only if it is enabled  
    if(popupStatus==1){  
       	$.fx.off = false;
        $("#backgroundPopup").fadeOut("slow");  
        $("#popupContent").fadeOut("slow");
        popupStatus = 0;  
    }
}
