/**
 * @author Przemysław Jarząb
 * Copyright SPEED Bernard Szymczak 2010
 */

function deletePL(str) {
	
	str = str.split("ą").join("a");
	str = str.split("Ą").join("A");
	str = str.split("ź").join("z");
	str = str.split("ż").join("z");
	str = str.split("Ź").join("Z");
	str = str.split("Ż").join("Z");
	str = str.split("ć").join("c");
	str = str.split("Ć").join("C");
	str = str.split("ń").join("n");
	str = str.split("Ń").join("N");
	str = str.split("ł").join("l");
	str = str.split("Ł").join("L");
	str = str.split("ś").join("s");
	str = str.split("Ś").join("S");
	str = str.split("ę").join("e");
	str = str.split("Ę").join("E");
	str = str.split("ó").join("o");
	str = str.split("Ó").join("O");
	
	return str;
} 

function generateLink (title, link) {

	var text = document.getElementById(title).value;
	
	if(text) {
		text = deletePL(text);
		text = text.toLowerCase(text);
		text = text.split(" ").join("_");
		text = text.replace(/[^0-9a-zA-Z_-]/g, "");
		document.getElementById(link).value = text;
	} else {
		document.getElementById(link).value = '';
	}

}

function checkinput (id, outid, maxc) {

	var text = document.getElementById(id).value;
	if(text.length>maxc) {
		document.getElementById(id).value = document.getElementById(id).value.substr(0, maxc);
		text = document.getElementById(id).value;
	}
	document.getElementById(outid).innerHTML = maxc - text.length;
	
	text = text.replace("\n", "");
	text = text.replace("\n\r", "");
	text = text.replace("\r\n", "");
	text = text.replace("\r", "");
	document.getElementById(id).value = text;

}

function showInvoiceData() {
	$(document).ready(function(){
		if ($("#fvq").attr("checked") && $("#fvq").val() == 1) {
			$("#fv").show();
		} else {
			$("#fv").hide();
		}
	}
	);
}

function showPayMore() {
	$(document).ready(function(){
		if ($("#pay").css("display") == 'none') {
			$("#pay").show();
		} else {
			$("#pay").hide();
		}
	}
	);
}
