// podpiecie wysylania formualrzan na nacisniecie entera
$('#pojNewsletterInput').live('keydown', function(e){
	var keycode;
	if (window.event){ 
		keycode = window.event.keyCode;
	} else if (e){ 
			keycode = e.which;
	}
	if (13 == keycode){
		fSendSignUpForm();
		return false;
	}	
})


/**
 * @desc wyslanie formularza newslettera - dodawanie adresu email
 */
function fSendNewsletterSignUpAddEmail(){	
		$('#pojNewsletterSignUpFormAction').val('doSignUpAction');	
		fSendSignUpForm();	
}


/**
 * @desc wyslanie formularza newslettera - usuwanie adresu email
 */
function fSendNewsletterSignUpDelEmail(){	
		$('#pojNewsletterSignUpFormAction').val('doSignOutAction');	
		fSendSignUpForm();	
}


/**
 * @desc usuniecie domyslnej wartosci pola input dla formularza dodawania do newslettera
 */
function fRemoveNewsletterDefaultInputValue(){
	
		sValue = $('#pojNewsletterInput').val();
	
		if( ('Twój adres e-mail' == sValue) || ('Twoj adres e-mail' == sValue) || ('Your email address' == sValue)|| ('Vaše e-mailová adresa' == sValue) ){
				$('#pojNewsletterInput').val('');	
		}
}


/**
 * @desc wyslanie formularza zapisu/wypisania z newslettera
 * @return
 */
function fSendSignUpForm(){
	
	var sQueryString = $('#formNewsletterSignUp').formSerialize();
	
	$.ajax({
		type: 'GET',
		url: 'index.php',
		dataType : 'xml',
		data: sQueryString,
		success: function(oXml){
		
				var iStatus = $(oXml).find('iStatus').text();
				
				$("#pojNewsletterSignUp").html(($(oXml).find('content').text()));
				
				if(iStatus == 1){
				//	location.href = $(oXml).find('sRedirect').text();
				}else{
			
					//$("#pojNewsletterSignUp").html(($(oXml).find('content').text()));
					
					//Cufon.replace('#pojNewsletterLogin h2',{ fontFamily: 'DINPro' });
				
				}
				
				Cufon.replace('#pojNewsletterFormSignUp h2 .lightCufonReplace',{ fontFamily: 'DINProLight' });
				Cufon.replace('#pojNewsletterFormSignUp h2 .cufonReplace',{ fontFamily: 'DINPro' });
				
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
				oReturn =  { status: 0, error : 'bladPolaczenia'};
		}
	});
	
}


/**
 * @desc pokazanie formularza rejestracji dla newslettera
 */
function fShowNewsletterRegisterForm(){
	
	$('#btnZalozProfil').hide();
	$('#pojNewsletterRegisterFormForm').show();
	
}
