/*
 * SimpleModal Contact Form
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2010 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: contact.js 236 2010-03-09 06:04:40Z emartin24 $
 *
 */

var function_popup = false;

jQuery(function ($) {
	var contact = {
		message: null,
		init: function () {
			
			function_popup = function (e) {
				e.preventDefault();
				
				// load the contact form using ajax
				$.get("ajax.php?modul=infoPopup", function(data){
					// create a modal dialog with the data
					$(data).modal({
						closeHTML: "<a href='#' title='Zavřít' class='modal-close modal-close-button'></a>",
						position: ["15%",],
						overlayId: 'contact-overlay',
						containerId: 'contact-container',
						onOpen: contact.open,
						onShow: contact.show,
						onClose: contact.close
                    });
				});
			};
		},      
		open: function (dialog) {
            
			dialog.overlay.fadeIn(200, function () {
				dialog.container.fadeIn(200, function () {
					dialog.data.fadeIn(200, function () {
                        
						var h = 295; //$('#contact-container .contact-content div.obal').height() + 100;
						
						$('#contact-container').height(h);
						      
						$('#contact-container .contact-content').animate({
							height: h
						}, function () {
							$('#contact-container div').fadeIn(200, function () {
								$('#btn_close_id').click(function(){
									$.modal.close();
									return false;
								});
							});
						});
					});
				});
			});
		},
		show: function (dialog) {
            $('#btn_ne_id').click(function(){

                $('.modal-close-button').hide();
                
                $('#contact-container .contact-content').animate({
                    height: 40
                }, function () {
                    $.modal.close();
                });
            });
		},
		close: function (dialog) {

            $('.modal-close-button').hide();
            
			$('#contact-container .contact-content').animate({
				height: 40
			}, function () {

                $.get("ajax.php?modul=infoPopup_onclose&test=1", function(data){
                    
                    dialog.data.fadeOut(200, function () {
                        dialog.container.fadeOut(200, function () {
                            dialog.overlay.fadeOut(200, function () {
                                $.modal.close();
                            });
                        });
                    });
                });

			});
		},
		error: function (xhr) {
			//
		}
	};

	contact.init();


	//----------------------------------------------------------------------------------------

});

