

function submitForm(formID) {
	$('#'+formID).submit();
}

function resetForm(formName) {
	Form.reset(formName);
//	$(formName).reset();
}

//zapisanie do tiny_mce
function parentSetFormInput(input, value) {
	var formInput = opener.document.getElementById(input);
	if (formInput != null) {
		formInput.value = value;
	}
	else {
		alert('[ERROR] Field not found: ' + input);
	}
}

//wybranie pliku i zapis 
function chooseFile(input, path) {
	parentSetFormInput(input, path);
	window.close();
	return false;
}

// przejscie do dokumentu jezeli pozytywne
function confirmLocation( tinfo, url ) {
	if(confirm(tinfo)) {
		document.location=url;
	}
}


// wykonanie jezeli pozytywne
function confirmLocationEval( tinfo, _command ) {
	if(confirm(tinfo)) {
		eval(_command);
	}
}



function winPopUp(name, url, width, height) {
	var popup=window.open(url,name,'width='+width+', height='+height+', scrollbars=yes,resizable=yes,status=yes');
}


function showBuyTicket(id) {
	$('buyTicketDiv'+id).show();
}


function changePostText(text) {
	var textneu = text.replace(/&/,".");
	textneu = textneu.replace(/</,".");
	textneu = textneu.replace(/>/,".");
	textneu = textneu.replace(/\r\n/,".");
	textneu = textneu.replace(/\n/,".");
	textneu = textneu.replace(/\r/,".");
	textneu = textneu.replace(/\~/,".");
	textneu = textneu.replace(/\`/,".");
	textneu = textneu.replace(/\!/,".");
	textneu = textneu.replace(/\@/,".");
	textneu = textneu.replace(/\#/,".");
	textneu = textneu.replace(/\$/,".");
	textneu = textneu.replace(/\%/,".");
	textneu = textneu.replace(/\^/,".");
	textneu = textneu.replace(/\(/,".");
	textneu = textneu.replace(/\)/,".");
	textneu = textneu.replace(/\[/,".");
	textneu = textneu.replace(/\{/,".");
	textneu = textneu.replace(/\}/,".");
	textneu = textneu.replace(/\]/,".");
	textneu = textneu.replace(/\?/,".");
	textneu = textneu.replace(/\|/,".");
	
	return(textneu);
}

function buyFormSubmit(id) {
		if($('userName'+id).value == '' || $('userSurname'+id).value == '' || $('pay_type'+id).value == '') {
			alert('Prosimy o uzupelnienie wszystkich pol.')
		}
		else {

	        var paramsF = 'id='+id+'&pay_type='+$('pay_type'+id).value+'&name='+changePostText($('userName'+id).value)+'&surname='+changePostText($('userSurname'+id).value);

			var tmpInner = $('buyTicketDiv'+id).innerHTML;
			
	        $('buyTicketDiv'+id).innerHTML = '<img src="img/p_snake.gif" />';
	
	        var url = 'index.php?_templateForce=emptyTotal&_mod=15';
			
			 
			
	        new Ajax.Request(url, {
	            parameters: paramsF,
	            onSuccess: function(transport) {
	                $('buyTicketDiv'+id).innerHTML = transport.responseText;
	            },
	            onFailure: function(transport) {
	            	alert('Wyst�pil problem w systemie transakcyjnym prosimy o kontakt poprzez e-mail.');
	            	$('buyTicketDiv'+id).innerHTML = tmpInner + '<img src="/img/error.gif" />';
	            }
	        });
	    }
}


function showMail(hd,dom){
	document.write('<'+'a '+'href'+'="mailto'+':'+hd+'@'+dom+'">'+hd+'@'+dom+'<'+'/a'+'>');
}


