$(document).ready(function(){
   $("div[id^='regtype_']").hide();
   $("#regtype_1").show();
   $("#letter_ok").hide();
   $("a[class^='regtype_']").click(function(event){
		$("div[id^='regtype_']").hide();
		var a = this.className;
		$("#"+a).show('fast');
	});
	$("#lp-ok").hide();
	$("a[rel='cbox']").colorbox();
});

function register() {
	
	fields = new Array('contact_email','contact','contact_phone','company','company_url','company_email','regtype','cityid');
//	fields = new Array();
	e = 0;
	data = {};
	for(i=0;i<fields.length;i++) {
		var f = fields[i]+'_error';
		$("#"+f).hide();
		if(document.getElementById(fields[i]).value=='') {
			$("#"+f).show();
			e++;
		}
		data[fields[i]] = document.getElementById(fields[i]).value;
	}
	if(!e)
	{
		$.post('/process/ajax-register.php',data,function(d){
			if(d=='ok') {
				$("#reg_form").hide();
				$("#reg_ok").show('fast');
			}
		});
	}
	return false;
}

function sendmail() {
	
	fields = new Array('txt_name','txt_email','txt_tel','txt_frage');
	e = 0;
	var formdata = $("#lform").serializeArray();
	for(i=0;i<fields.length;i++) {
		if(document.getElementById(fields[i]).value=='') {
			e++;
		}
	}
	
	if(!e)
	{
		$.post('/process/ajax-sendmail.php',formdata,function(d){
			if(d=='ok') {
				$("#letter_form").hide();
				$("#letter_ok").show('fast');
			}
		});
	}
	return false;
}

function showemail(id) {
	$.post('/process/ajax-email.php',{id:id},function(d){
		document.getElementById('hidden_email').innerHTML = d;
	});
																
}

function lostpass() {
	$("#lp-error").hide();
	var formdata = $("#lpform").serializeArray();
		$.post('/process/ajax-lostpass.php',formdata,function(d) {
			if(d=='ok') {
				$("#lpform").hide();
				$("#lp-ok").show('fast');
			} else {
				$("#lp-error").show();
			}
		});
	return false;
}

