var cur = '';
var cur_info = '';
var cur_info_open = 0;


function showInfo(id){

	$(".hide_content").hide("fast");

	if(id != cur_info || cur_info_open == 0){	
		$("#"+id+" .hide_content").show("fast");
		cur_info_open = 1;
	}
	else{
		cur_info_open = 0;
	}
    
	cur_info = id;
}

function checkEmail(str) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) {
        return true;
    }else {
        return false;
    }
}

function validate_opinion_form(){
	var isError = false;
	var errorString = '';

	var numericExpression = /^[0-9]+$/;

	if($('#opinion-topic-select :selected').val() == 0){
		 isError = true;
		 errorString = "-> wybierz temat opinii\r\n";
	}
	
	if($("#opinionForm #opinion-content").val() == "" ){
        isError = true;
		errorString = errorString + "-> wpisz treść opinii\r\n";
    }


	if(isError){
		alert("Formularz został niepoprawnie wypełniony:\r\n"+errorString);
		return false;	
	}
	else{
		$("#opinion-form-content").hide();
		$("#opinion-form-loader").show();
		
		$("#opinion-reciever").val($('#opinion-topic-select :selected').val());
		$("#opinion-topic").val($('#opinion-topic-select :selected').text());
		
	
			parent._gaq.push(['_trackPageview','/skrzynka-inicjatyw-wyslane']);
			

		return true;
	}
}


function validate_contact_form(){
	var isError = false;
	var errorString = '';

	var numericExpression = /^[0-9]+$/;
	var emailFilter = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	if($("#contactForm #company").val() == "" ){
        isError = true;
		errorString = errorString + "-> Nazwę firmy\r\n";
    }

	if($("#contactForm #city").val() == "" ){
        isError = true;
		errorString = errorString + "-> Miasto\r\n";
    }

	if(!$("#contactForm #zip1").val().match(numericExpression) || !$("#contactForm #zip2").val().match(numericExpression) ||
	   $("#contactForm #zip1").val().length != 2 || $("#contactForm #zip2").val().length != 3){
        isError = true;
		errorString = errorString + "-> Kod pocztowy\r\n";
    }
	
	if($("#contactForm #street").val() == "" ){
        isError = true;
		errorString = errorString + "-> Ulicę\r\n";
    }
	
	if(!$("#contactForm #nip").val().match(numericExpression) || $("#contactForm #nip").val().length != 10){
        isError = true;
		errorString = errorString + "-> Nip\r\n";
    }
	
	if($("#contactForm #contact_person").val() == "" ){
        isError = true;
		errorString = errorString + "-> Nazwisko osoby do kontaktu\r\n";
    }
	
	if(!$("#contactForm #phone").val().match(numericExpression)){
        isError = true;
		errorString = errorString + "-> Numer telefonu\r\n";
    }
    
    	if(!$("#contactForm #email").val().match(emailFilter)){
        isError = true;
		errorString = errorString + "-> E-mail\r\n";
    }
	
	//if($("#contactForm #email").val() != "" && !checkEmail($("#contactForm #email").val())){
	//	isError = true;
	//	errorString = errorString + "-> Email\r\n";
	//}

	
	if(isError){
		alert("Wpisz poprawnie:\r\n"+errorString);
		return false;	
	}
	else{
		return true;
	}

}

$(document).ready(function() {
			$("#peoples-opinion-div").bind("click", function() {
					
						_gaq.push(['_trackPageview','/skrzynka-inicjatyw']);
						
			});
			

			var max_height = 0;
			$(".press_logos li").each(function(index) {
				if (Number(max_height) < $(this).height()){
					max_height = $(this).height();
				}
			});
			$(".press_logos li").each(function(index) {
				$(this).height(max_height+"px");
			});

});

