scrollingInWorkshop = false;
workshop_id = null;
jQuery(document).ready(function()
{
	 
	jQuery( '#registration-link' ).bind( 'click', function( e )
    {
		scrollingInWorkshop = true;
		workshop_id = jQuery('#ctools_workshop_id').val();
		
		
		if(workshop_id == '0099') {
			frnnetzwerk_anmeldung(workshop_id);
		} else {		
	        jQuery.ez( 'ezjscajax::showConfirmXingMembership', {'workshop_id': workshop_id}, function( data )
	        {
		        if ( data.error_text ) {
		            jQuery( '#error' ).html( data.error_text );
			    } else {
					
					showRegistration( data.content.template );
			    }
			});
    	}
    });
});

function frnnetzwerk_show_div(elementToShowId, elementToHideId) {
	jQuery(elementToShowId).show();
	jQuery(elementToHideId).hide();
}

function showRegistration( template )
{
	
	if(scrollingInWorkshop) {
		scrollTo(0, 500);
	} else {
		scrollTo(0, 200);
	}
	
	jQuery('#registration-link').addClass('current');
	jQuery('#body-link').removeClass('current');
	jQuery( '#form-link' ).bind( 'click', function( e )
	{
		frnnetzwerk_anmeldung_workshop();
	});

	
	jQuery('#registration').html( template ).show();
	//document.getElementById('registration').innerHTML = template;
	//document.getElementById('registration').style.display = "block";
	jQuery('#body').hide();
	
}


function frnnetzwerk_anmeldung(workshop_id) {
	
	jQuery.ez( 'ezjscajax::frnnetzwerk_anmeldung', {'workshop_id': workshop_id}, function( data ) {
		
        if ( data.error_text ) {
            jQuery( '#error' ).html( data.error_text );
        } else {
        	if(data.content.template) {
        		showRegistration( data.content.template );
        	} 
        }
    });
}


function frnnetzwerk_anmeldung_workshop() {
	
	jQuery.ez( 'ezjscajax::frnnetzwerk_anmeldung_workshop', {}, function( data ) {
		
        if ( data.error_text ) {
            jQuery( '#error' ).html( data.error_text );
        } else {
        	if(data.content.template) {
        		showRegistration( data.content.template );
        	} 
        }
    });
}



function frnnetzwerk_post_workshop() {
	
	jQuery.ez( 'ezjscajax::frnnetzwerk_post_workshop', {
			   'workshop': jQuery('input:radio[name=workshop]:checked').val(),
			   'company': jQuery('#company').val(),
			   'anrede': jQuery('#anrede').val(),
			   'vorname': jQuery('#vorname').val(),
			   'nachname': jQuery('#nachname').val(),
			   'strasse': jQuery('#strasse').val(),
			   'plz': jQuery('#plz').val(),
			   'ort': jQuery('#ort').val(),
			   'country_id': jQuery('#country_id').val(),
			   'telephone': jQuery('#telephone').val(),
			   'fax': jQuery('#fax').val(),
			   'companysize_id': jQuery('#companysize_id').val(),
			   'branchen_id': jQuery('#branchen_id').val(),
			   'function_id': jQuery('#function_id').val(),
			   'aufmerksam_durch': jQuery('#aufmerksam_durch').val(),
			   'email': jQuery('#email').val(),
			   'bemerkung': jQuery('#bemerkung').val(),
			   'abo_agb': jQuery('input:checkbox[name=abo_agb]:checked').val(),
			   'abo_agb_veranstaltung': jQuery('input:checkbox[name=abo_agb_veranstaltung]:checked').val(),
			   'abo_informationen': jQuery('input:checkbox[name=abo_informationen]:checked').val(),
			   'schnupperpreis': jQuery('input:checkbox[name=schnupperpreis]:checked').val()
			}, function( data ) {
				
        if ( data.error_text ) {
            jQuery( '#error' ).html( data.error_text );
        } else {
        	if(data.content.template) {
        		showRegistration( data.content.template );
        	} 
        }
    });
}

function frnnetzwerk_post() {
	
	jQuery.ez( 'ezjscajax::frnnetzwerk_post', {
			   'company': jQuery('#company').val(),
			   'anrede': jQuery('#anrede').val(),
			   'vorname': jQuery('#vorname').val(),
			   'nachname': jQuery('#nachname').val(),
			   'strasse': jQuery('#strasse').val(),
			   'plz': jQuery('#plz').val(),
			   'ort': jQuery('#ort').val(),
			   'country_id': jQuery('#country_id').val(),
			   'telephone': jQuery('#telephone').val(),
			   'fax': jQuery('#fax').val(),
			   'companysize_id': jQuery('#companysize_id').val(),
			   'branchen_id': jQuery('#branchen_id').val(),
			   'function_id': jQuery('#function_id').val(),
			   'email': jQuery('#email').val(),
			   'bemerkung': jQuery('#bemerkung').val(),
			   'abo_agb': jQuery('input:checkbox[name=abo_agb]:checked').val(),
			   'datenschutz': jQuery('input:checkbox[name=datenschutz]:checked').val(),
			   'abo_informationen': jQuery('input:checkbox[name=abo_informationen]:checked').val()
			}, function( data ) {
				
        if ( data.error_text ) {
            jQuery( '#error' ).html( data.error_text );
        } else {
        	if(data.content.template) {
        		showRegistration( data.content.template );
        	} 
        }
    });
}


