

var widget_ggNumber;
window.addEvent( 'load', function(){

if( $( 'widget_gg_input' ) ) {

	

	new Okienko( {
		parentID: 'widget_email',
		contentID: 'cont_widget_email'
	} );
	new Okienko( {
		parentID: 'widget_gg',
		contentID: 'cont_widget_gg'
	} );

	new Request.HTML({
		async:true,
		url:"/_lib/komunikaty/_ajax/send_message.php",
		onSuccess: function( html ) {

			$( 'cont_widget_email' ).adopt( html );

			$$( '#cont_widget_email .form_body' ).setStyle( 'display', 'block' );
			$$( '#cont_widget_email .form_info' ).setStyle( 'display', 'none' );
		}
	}).send();

	var url = 'www.krakow.pl'+$$( '#cont_widget_gg a').get( 'href' );
	$( 'widget_gg_input' ).addEvent( 'keyup', function() {
		$$( '#cont_widget_gg a').set( 'href', "gg://"+$( 'widget_gg_input' ).value+"?text="+url );
		widget_ggNumber = $( 'widget_gg_input' ).value;
	} )

	$( 'widget_gg_a' ).addEvent( 'click', function( e ) {
		if( !widget_ggNumber ) {
			e.stop();
		}
	} )

	$( 'cont_widget_email' ).addEvent( 'submit', function( e ) {

		e.stop();

		new Request.HTML({
			async:true,
			url:"/_lib/komunikaty/_ajax/send_message.php",
			onSuccess: function( html ) {

				$( 'cont_widget_email' ).set( 'text', '' );
				$( 'cont_widget_email' ).adopt( html );
				$$( '#cont_widget_email .form_body' ).setStyle( 'display', 'block' );
				$$( '#cont_widget_email .form_info' ).setStyle( 'display', 'none' );
			},

			onRequest: function( ) {
				$$( '#cont_widget_email .form_body' ).setStyle( 'display', 'none' );
				$$( '#cont_widget_email .form_info' ).setStyle( 'display', 'block' );
			},

			onFailure: function() {
				
			}
		}).send( {
			method: 'post',
			data: 'widget_email_input='+$('widget_email_input').value+'&'+'widget_email_captcha='+$('widget_email_captcha').value
		} );

	} )

}
} )

