// JavaScript Document
document.observe('dom:loaded', function() {
	$('ajanlo').observe('click', showAjaxFormDemonstration);
});


function showAjaxFormDemonstration(event) {
	Event.stop(event);
	Lightview.show({
		href: 'ajanlas.php',
		rel: 'ajax',
		options: {
			autosize: true,
			topclose: true,
			ajax: {
				onComplete: function(){
				// once the request is complete we observe the form for a submit
				$('ajaxForm').observe('submit', submitAjaxFormDemonstration);
				}
			}
		}
	});
}

function submitAjaxFormDemonstration(event) {
  // block default form submit
  Event.stop(event);
  
  // if there's no text in the box, don't do anything
  var text = $('ajaxForm').down('input').value.strip();

  if (!text) return;
	  
  Lightview.show({
    href: 'ajanlo2mail.php',
    rel: 'ajax',
    options: {
      title: 'results',
	  menubar: false,
	  topclose: true,
	  autosize: true,
      ajax: {
        parameters: Form.serialize('ajaxForm') // the parameters from the form
      }
    }
  });
}
/**/

// Regisztracio

document.observe('dom:loaded', function() {
	$('ajax_reg').observe('click', showAjaxRegForm);
});

/*
// Here we observe an element and call Lightview.show, the lightview:loaded event
// is used here to make sure Lightview.show is available.
document.observe("lightview:loaded", function() {
  $("ajax_reg").observe('click', function() {
    Lightview.show({ href: 'anotherElementId', rel: 'inline' });
  });
});
*/

function showAjaxRegForm(event) {
	Event.stop(event);
	Lightview.show({
		href: 'reg_first.php',
		rel: 'iframe',
		options: {
			width:650,
			height:550,

//			autosize: true,
			topclose: true,
			ajax: {
				onComplete: function(){
				// once the request is complete we observe the form for a submit
				$('reg').observe('submit', submitAjaxRegForm);
				}
			}
		}
	});
}

function submitAjaxRegForm(event) {
  // block default form submit
  Event.stop(event);
  
  // if there's no text in the box, don't do anything
  var text = $('reg').down('input').value.strip();

  if (!text) return;
	  
  Lightview.show({
    href: 'reg_success.php',
    rel: 'iframe',
    options: {
      title: 'results',
	  menubar: false,
	  topclose: true,
			width:600,
			height:450,

//	  autosize: true,
      ajax: {
        parameters: Form.serialize('reg') // the parameters from the form
      }
    }
  });
}



// reg end
//lost pw
document.observe('dom:loaded', function() {
	$('ajax_lost').observe('click', showAjaxLostForm);
});
function showAjaxLostForm(event) {
	Event.stop(event);
	Lightview.show({
		href: 'lost_pw.php',
		rel: 'iframe',
		options: {
			width:550,
			height:300,

//			autosize: true,
			topclose: true,
			ajax: {
				onComplete: function(){
				// once the request is complete we observe the form for a submit
				$('lost').observe('submit', submitAjaxLostForm);
				}
			}
		}
	});
}

// lost pw end

//profile
document.observe('dom:loaded', function() {
	$('ajax_profile').observe('click', showAjaxProfileForm);
});
function showAjaxProfileForm(event) {
	Event.stop(event);
	Lightview.show({
		href: 'profil_info.php',
		rel: 'iframe',
		options: {
			width:550,
			height:650,

//			autosize: true,
			topclose: true,
			ajax: {
				onComplete: function(){
				// once the request is complete we observe the form for a submit
				$('profile').observe('submit', submitAjaxProfileForm);
				}
			}
		}
	});
}

// profile end


// show the code for the Ajax Demo
function showAjaxAdatkezeles(event) {
	Event.stop(event);
	Lightview.show({
		href: 'adatkezeles.php',
		rel: 'iframe',
		options: {
			width:600,
			height:450,
//			autosize: true,
			topclose: true
		}
	});
	
}

// hide 
function HideAjaxForm(event) {
//	Event.stop(event);
//	Lightview.hide();

document.observe('lightview:opened', function(event) {
	Lightview.hide();

});	
}