var webshop_cnt_onsubmit_errors = 0;

function ws_cnt_billingdata_init() {
	/*
	var i;
	var obj;

	var elements = getElementsByClass("ws_cnt_required");
	for (i=0;i<elements.length;i++) {
		obj = elements[i];
		if (obj.type == "text" && obj.value == "") obj.style.background = 'red';
	}
	*/
}

function ws_cnt_billingdata_check() {
	var isOk = true;
	var i;
	var obj;
	var first = false;

	var elements = getElementsByClass("ws_cnt_required");
	for (i=0;i<elements.length;i++) {
		obj = elements[i];
		if (obj.type == "text" && obj.value == "") {
			isOk = false;
			obj.style.background = "red";
			if (first == false) {
				first = true;
				obj.focus();
			}
		}
		else obj.style.background = "white";
	}

	if (!isOk) alert('A pirossal megjelölt mezők kitöltése kötelező!');

	return isOk;
}

function ws_cnt_design_prepare() {
	var top = getY(document.getElementById('design_top'));
	var go_to_prev_and_next = getY(document.getElementById('go_to_prev_and_next'));
	var design_footer = getY(document.getElementById('design_footer'));
	var tmp = getElementsByClass('cart');
	var content = tmp[0];
	if (go_to_prev_and_next > design_footer) {
		var bottom = go_to_prev_and_next + 80;
	}
	else {
		var bottom = design_footer + 20;
	}
	content.style.height = bottom - top;
}

function ws_cnt_design_prepare_init() {
	/*setTimeout('ws_cnt_design_prepare()', 500);*/
	return true;
}

function getY(object) {
	var iReturnValue = 0;
	while(object != null ) {
		iReturnValue += object.offsetTop;
		object = object.offsetParent;
	}
	return iReturnValue;
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if (node == null) node = document;
	if (tag == null) tag = '*';
	var elems = node.getElementsByTagName(tag);
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	var i = 0;
	for (var j = 0; j < elems.length; j++) {
		if ( pattern.test(elems[j].className) ) {
			classElements[i++] = elems[j];
		}
	}
	return classElements;
}

/* config, predeclaration */

var ws_cnt_pricebox_id = 'ws_cnt_pricebox';
var ws_cnt_pricebox_type = 'span'; // span | div | input

var ws_cnt_fullpricebox_aftertable_id = 'ws_cnt_fullpricebox_aftertable';
var ws_cnt_fullpricebox_aftertable_type = 'span'; // span | div | input

var ws_cnt_fullprice = 0;
var ws_cnt_fullpricebox_id = 'ws_cnt_fullpricebox';
var ws_cnt_fullpricebox_type = 'span'; // span | div | input

var ws_cnt_summaprice = 0;
var ws_cnt_summapricebox_id = 'ws_cnt_summapricebox';
var ws_cnt_summapricebox_type = 'span'; // span | div | input
var ws_cnt_price_starting = true;
var ws_cnt_price_temp = 0;
var ws_cnt_price_max_ = 0;
var ws_cnt_price_alert_nulla = '';

var ws_cnt_wasModify = false;
var ws_cnt_backgo_confirm = '';

/* config, predeclaration - részvételi díj */
var ws_cnt_price_reg = 0;
var ws_cnt_price_escort = new Array();
var ws_cnt_price_escort_price = new Array();
var ws_cnt_price_max_escort = 0;
var ws_cnt_price_max_escort_alerttext = '';

/* config, predeclaration - szállás */
var ws_cnt_price_szallas = 0;
var ws_cnt_price_kiseroszallasdij = 0;
var ws_cnt_price_szallas_alert_no_more_place = '';

/* config, predeclaration - program */
var ws_cnt_price_program = new Array();
var ws_cnt_price_program_price = new Array();
var ws_cnt_price_program_alert_no_more_place = '';

/* config, predeclaration - pricedata */
var ws_cnt_pricedata_type_regdij = '';
var ws_cnt_pricedata_type_kisero = '';
var ws_cnt_pricedata_type_szallas = '';
var ws_cnt_pricedata_type_kiseroszallasdij = '';
var ws_cnt_pricedata_type_tarsasag = '';
var ws_cnt_pricedata_type_fakultativ = '';
var ws_cnt_pricedata_type_szakmai = '';
var ws_cnt_pricedata_sum_en = 0;
var ws_cnt_pricedata_sum_ceg = 0;
var ws_cnt_pricedata_sum_szponzor = 0;
var ws_cnt_pricedata_alert_fillall = '';
var ws_cnt_pricedata_types = Array();

/* onSubmit */
function ws_cnt_onSubmit() {
	var inputs = document.delivery.getElementsByTagName('input');
	var input;
	var i;
	var isOk = true;
	for (i=0;i<inputs.length;i++) {
		input = inputs[i];
		if ((substr(input.name,0,8) == "szallas_" || substr(input.name,0,8) == "program_") && input.value == '') isOk = false;
	}
	if (!isOk) {
		alert(ws_cnt_price_alert_nulla);
	}
	return isOk;
}

function ws_cnt_pricebox_onSumbit() {
	document.delivery.onsubmit = ws_cnt_onSubmit;
}

/* ws_cnt_wasModify */
function ws_cnt_set_wasModify() {
	//alert('ejnye');
	ws_cnt_wasModify = true;
}

function ws_cnt_prev_next_button_onClick(link) {
	if (link.substr(0,6) == "alert:") {
		alert(link.substr(6));
	}
	else {
		var isGoToLink = true;
		if (ws_cnt_wasModify) {
			isGoToLink = window.confirm(ws_cnt_backgo_confirm);
		}
		if (isGoToLink) window.location.href = link;
	}
}

function ws_cnt_veglegesites(text) {
	if (window.confirm(text)) {
		document.veglegesito_form.submit();
	}
}

function ws_cnt_set_onblurs(confirm_text) {
	ws_cnt_backgo_confirm = confirm_text;

	var inputs = document.getElements('input',document.delivery);
	var i = 0;
	for (i=0;i<inputs.length;i++) {
		if (inputs[i].type == "radio") {
			addEvent(inputs[i],"click",ws_cnt_set_wasModify);
		}
		if (inputs[i].type == "text") {
			addEvent(inputs[i],"change",ws_cnt_set_wasModify);
		}
	}

	var selects = document.getElements('select',document.delivery);
	var i = 0;
	for (i=0;i<selects.length;i++) {
		addEvent(selects[i],"change",ws_cnt_set_wasModify);
	}
}

/* fullpricebox */

function set_ws_cnt_fullpricebox_info() {
	var price_full = ws_cnt_fullprice;

	price_full = number_format(price_full,0,"."," ");
	if (document.getElementById(ws_cnt_fullpricebox_id)) {
		if (ws_cnt_fullpricebox_type == 'div' || ws_cnt_fullpricebox_type == 'span') document.getElementById(ws_cnt_fullpricebox_id).innerHTML = price_full;
		else if (ws_cnt_fullpricebox_type == 'input') document.getElementById(ws_cnt_fullpricebox_id).value = price_full;
	}
	else {
		if (document.getElementById('ws_cnt_fullpricebox')) {
			if (ws_cnt_fullpricebox_type == 'div' || ws_cnt_fullpricebox_type == 'span') document.getElementById('ws_cnt_fullpricebox').innerHTML = price_full;
			else if (ws_cnt_fullpricebox_type == 'input') document.getElementById('ws_cnt_fullpricebox').value = price_full;
		}
		else {
			if (document.getElementById('ws_cnt_summapricebox')) {
				if (ws_cnt_fullpricebox_type == 'div' || ws_cnt_fullpricebox_type == 'span') document.getElementById('ws_cnt_summapricebox').innerHTML = price_full;
				else if (ws_cnt_fullpricebox_type == 'input') document.getElementById('ws_cnt_summapricebox').value = price_full;
			}
			//else alert('a');
		}
	}
}

function set_ws_cnt_fullpricebox(price) {
	var price_full = ws_cnt_fullprice;
	price_full = number_format(price_full,0,"."," ");
	if (document.getElementById(ws_cnt_fullpricebox_id)) {
		if (ws_cnt_fullpricebox_type == 'div' || ws_cnt_fullpricebox_type == 'span') document.getElementById(ws_cnt_fullpricebox_id).innerHTML = price_full;
		else if (ws_cnt_fullpricebox_type == 'input') document.getElementById(ws_cnt_fullpricebox_id).value = price_full;
	}

	var price_summa = ws_cnt_fullprice - ws_cnt_price_temp + price;
	price_summa = number_format(price_summa,0,"."," ");
	if (document.getElementById(ws_cnt_summapricebox_id)) {
		if (ws_cnt_summapricebox_type == 'div' || ws_cnt_summapricebox_type == 'span') document.getElementById(ws_cnt_summapricebox_id).innerHTML = price_summa;
		else if (ws_cnt_summapricebox_type == 'input') document.getElementById(ws_cnt_summapricebox_id).value = price_summa;
	}
}

function get_ws_cnt_fullprice() {

}

function set_ws_cnt_fullpricebox_() {
	var price = get_ws_cnt_fullprice();
	price = number_format(price,0,"."," ");
	if (document.getElementById(ws_cnt_fullpricebox_id)) {
		if (ws_cnt_fullpricebox_type == 'div' || ws_cnt_fullpricebox_type == 'span') document.getElementById(ws_cnt_fullpricebox_id).innerHTML = price;
		else if (ws_cnt_fullpricebox_type == 'input') document.getElementById(ws_cnt_fullpricebox_id).value = price;
	}
}

/* részvételi díj */
function set_ws_cnt_price_reg(num) {
	ws_cnt_price_reg = num;
	if (ws_cnt_price_starting) ws_cnt_price_temp = ws_cnt_price_temp + num;
	set_ws_cnt_pricebox();
}

function set_ws_cnt_price_escort(obj,num) {
	var tmp = obj.id.replace('regdij_kisero_','');

	var i = 0;
	for (i=0;i<tmp;i++) if (!ws_cnt_price_escort[i]) {
		ws_cnt_price_escort[i] = 0;
		ws_cnt_price_escort_price[i] = 0;
	}

	ws_cnt_price_escort[tmp] = obj.value;
	ws_cnt_price_escort_price[tmp] = num;
	if (ws_cnt_price_starting) ws_cnt_price_temp = ws_cnt_price_temp + (num * parseInt(ws_cnt_price_escort[i] * 1));

	var escort_prices = 0;
	for (i=0;i<ws_cnt_price_escort.length;i++) {
		escort_prices = parseInt(escort_prices * 1) + parseInt(ws_cnt_price_escort[i] * 1);
	}

	if (escort_prices > ws_cnt_price_max_escort) {
		alert(ws_cnt_price_max_escort_alerttext);
		obj.value = 0;
		ws_cnt_price_escort[tmp] = 0;
		if (ws_cnt_price_starting) ws_cnt_price_temp = ws_cnt_price_temp - num;
	}

	set_ws_cnt_pricebox();
}

function get_ws_cnt_price() {
	var price = 0;
	price = price + ws_cnt_price_reg;

	for (var i=0;i<ws_cnt_price_escort.length;i++) {
		price = price + (parseInt(ws_cnt_price_escort[i] * ws_cnt_price_escort_price[i]));
	}

	return price;
}

function set_ws_cnt_pricebox() {
	var price = get_ws_cnt_price();
	var price_out = number_format(price,0,"."," ");
	if (document.getElementById(ws_cnt_pricebox_id)) {
		if (ws_cnt_pricebox_type == 'div' || ws_cnt_pricebox_type == 'span') document.getElementById(ws_cnt_pricebox_id).innerHTML = price_out;
		else if (ws_cnt_pricebox_type == 'input') document.getElementById(ws_cnt_pricebox_id).value = price_out;
	}


	if (document.getElementById(ws_cnt_fullpricebox_aftertable_id)) {
		if (ws_cnt_fullpricebox_aftertable_type == 'div' || ws_cnt_fullpricebox_aftertable_type == 'span') document.getElementById(ws_cnt_fullpricebox_aftertable_id).innerHTML = price_out;
		else if (ws_cnt_fullpricebox_aftertable_type == 'input') document.getElementById(ws_cnt_fullpricebox_aftertable_id).value = price_out;
	}
	set_ws_cnt_fullpricebox(price);
}

/* szállás */

function set_ws_cnt_price_szallas(num) {
	ws_cnt_price_szallas = num;

	if (ws_cnt_price_starting) ws_cnt_price_temp = ws_cnt_price_temp + num;

	set_ws_cnt_pricebox_szallas();
}

function set_ws_cnt_pricebox_szallas() {
	var price = ws_cnt_price_szallas;
	var price_out = number_format(price,0,"."," ");
	if (document.getElementById(ws_cnt_pricebox_id)) {
		if (ws_cnt_pricebox_type == 'div' || ws_cnt_pricebox_type == 'span') document.getElementById(ws_cnt_pricebox_id).innerHTML = price_out;
		else if (ws_cnt_pricebox_type == 'input') document.getElementById(ws_cnt_pricebox_id).value = price_out;
	}


	if (document.getElementById(ws_cnt_fullpricebox_aftertable_id)) {
		if (ws_cnt_fullpricebox_aftertable_type == 'div' || ws_cnt_fullpricebox_aftertable_type == 'span') document.getElementById(ws_cnt_fullpricebox_aftertable_id).innerHTML = price_out;
		else if (ws_cnt_fullpricebox_aftertable_type == 'input') document.getElementById(ws_cnt_fullpricebox_aftertable_id).value = price_out;
	}
	set_ws_cnt_fullpricebox(price);
}

/* program */

function set_ws_cnt_price_program(obj,num,maxnum,program_type,maxfo) {
	if (!maxnum) maxnum = parseInt(obj.value) + 1;

	if (!maxfo) maxfo = 0;
	if (!program_type) program_type = '';
	if (program_type == "szakmai") maxnum = 1; // 0/1

	if (maxnum >= obj.value || maxnum == 0) {
		if (maxfo == 0 || maxfo >= obj.value) {
			var tmp = obj.id.replace('program_','');

			//alert(tmp + ' ' + num);
			var i = 0;
			for (i=0;i<tmp;i++) if (!ws_cnt_price_program[i]) {
				ws_cnt_price_program[i] = 0;
				ws_cnt_price_program_price[i] = 0;
			}

			ws_cnt_price_program[tmp] = obj.value;
			ws_cnt_price_program_price[tmp] = num;
			if (ws_cnt_price_starting) ws_cnt_price_temp = ws_cnt_price_temp + (num * parseInt(ws_cnt_price_program[i] * 1));

			var program_prices = 0;
			for (i=0;i<ws_cnt_price_program.length;i++) {
				program_prices = parseInt(program_prices * 1) + parseInt(ws_cnt_price_program[i] * 1);
			}
		}
		else {
			//alert(ws_cnt_price_program_alert_no_more_place);
			obj.value = maxfo;
		}
	}
	else {
		alert(ws_cnt_price_program_alert_no_more_place);
		obj.value = ''; // 0/1
	}

	set_ws_cnt_pricebox_program();
}

function get_ws_cnt_price_program() {
	var price = 0;

	//alert(ws_cnt_price_program);
	for (var i=0;i<ws_cnt_price_program.length;i++) {
		price = price + (parseInt(ws_cnt_price_program[i] * ws_cnt_price_program_price[i]));
	}

	return price;
}

function set_ws_cnt_pricebox_program() {
	var price = get_ws_cnt_price_program();
	var price_out = number_format(price,0,"."," ");
	if (document.getElementById(ws_cnt_pricebox_id)) {
		if (ws_cnt_pricebox_type == 'div' || ws_cnt_pricebox_type == 'span') document.getElementById(ws_cnt_pricebox_id).innerHTML = price_out;
		else if (ws_cnt_pricebox_type == 'input') document.getElementById(ws_cnt_pricebox_id).value = price_out;
	}

	if (document.getElementById(ws_cnt_fullpricebox_aftertable_id)) {
		if (ws_cnt_fullpricebox_aftertable_type == 'div' || ws_cnt_fullpricebox_aftertable_type == 'span') document.getElementById(ws_cnt_fullpricebox_aftertable_id).innerHTML = price_out;
		else if (ws_cnt_fullpricebox_aftertable_type == 'input') document.getElementById(ws_cnt_fullpricebox_aftertable_id).value = price_out;
	}

	set_ws_cnt_fullpricebox(price);
}

/* pricedata */

function ws_cnt_pricedata_onSumbit_fg() {
	var ret = true;

	for (var key in ws_cnt_pricedata_types) {
		if (ws_cnt_pricedata_types[key] == 0) ret = false;
	}

	if (!ret) alert(ws_cnt_pricedata_alert_fillall);

	return ret;
}

function ws_cnt_pricedata_onSumbit() {
	document.delivery.onsubmit = ws_cnt_pricedata_onSumbit_fg;
}

function set_ws_pricedata_sum(type,set,num) {

	if (ws_cnt_price_starting) {
		ws_cnt_pricedata_types[type] = 0;
	}
	else {
		ws_cnt_pricedata_types[type] = 1;
	}

	if (type == 'reszvetelidij') {
		if (ws_cnt_pricedata_type_regdij == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_regdij == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_regdij == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_regdij = set;
		if (ws_cnt_pricedata_type_regdij == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_regdij == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_regdij == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	if (type == 'kisero') {
		if (ws_cnt_pricedata_type_kisero == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_kisero == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_kisero == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_kisero = set;
		if (ws_cnt_pricedata_type_kisero == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_kisero == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_kisero == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	if (type == 'szallas') {
		if (ws_cnt_pricedata_type_szallas == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_szallas == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_szallas == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_szallas = set;
		if (ws_cnt_pricedata_type_szallas == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_szallas == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_szallas == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	if (type == 'kiseroszallasdij') {
		if (ws_cnt_pricedata_type_kiseroszallasdij == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_kiseroszallasdij == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_kiseroszallasdij == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_kiseroszallasdij = set;
		if (ws_cnt_pricedata_type_kiseroszallasdij == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_kiseroszallasdij == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_kiseroszallasdij == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	if (type == 'tarsasag') {
		if (ws_cnt_pricedata_type_tarsasag == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_tarsasag == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_tarsasag == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_tarsasag = set;
		if (ws_cnt_pricedata_type_tarsasag == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_tarsasag == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_tarsasag == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	if (type == 'fakultativ') {
		if (ws_cnt_pricedata_type_fakultativ == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_fakultativ == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_fakultativ == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_fakultativ = set;
		if (ws_cnt_pricedata_type_fakultativ == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_fakultativ == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_fakultativ == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	if (type == 'szakmai') {
		if (ws_cnt_pricedata_type_szakmai == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en - num;
		if (ws_cnt_pricedata_type_szakmai == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg - num;
		if (ws_cnt_pricedata_type_szakmai == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor - num;
		ws_cnt_pricedata_type_szakmai = set;
		if (ws_cnt_pricedata_type_szakmai == 'en') ws_cnt_pricedata_sum_en = ws_cnt_pricedata_sum_en + num;
		if (ws_cnt_pricedata_type_szakmai == 'ceg') ws_cnt_pricedata_sum_ceg = ws_cnt_pricedata_sum_ceg + num;
		if (ws_cnt_pricedata_type_szakmai == 'szponzor') ws_cnt_pricedata_sum_szponzor = ws_cnt_pricedata_sum_szponzor + num;
	}
	var span_en = document.getElementById('summa_en');
	var span_ceg = document.getElementById('summa_ceg');
	var span_szponzor = document.getElementById('summa_szponzor');

	span_en.innerHTML = number_format(ws_cnt_pricedata_sum_en,0,"."," ");
	span_ceg.innerHTML = number_format(ws_cnt_pricedata_sum_ceg,0,"."," ");
	span_szponzor.innerHTML = number_format(ws_cnt_pricedata_sum_szponzor,0,"."," ");
}

function ws_cnt_toggle(id) {
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'block' ? "none" : "block");
}

function proform_open(proform_id) {
	popup_up('proform_'+proform_id,'index.php?mod=webshop_cnt&cla=webshop_cnt&fun=adminList&ajax=proform&proform='+proform_id+'&temp=cnt.hu',800,800,'no','yes')
}

function ws_cnt_veglegesites_open(cnt_id,user_id,unix_time) {
	popup_up('datapage_'+cnt_id,'index.php?mod=webshop_cnt&cla=webshop_cnt&fun=adminList&ajax=veglegesites_datapage&cnt_id='+cnt_id+'&user_id='+user_id+'&utime='+unix_time+'&temp=cnt.hu',800,800,'no','yes')
}

var ws_cnt_proform_id = 0;

function delete_proform_erkeztetes(proform_id,erkeztetes_id) {
	ws_cnt_proform_id = proform_id;
	ws_cnt_makeRequest("index.php?mod=webshop_cnt&cla=webshop_cnt&fun=adminList&ajax=delproformekreztetes&proform="+proform_id+"&erkeztetes="+erkeztetes_id+"&temp=cnt.hu",'delete_proform_erkeztetes',erkeztetes_id);
}
/**/

function popup_up(name,file,width,height,scrollbar,modal) {
	childWindow=window.open(file,name,"modal=yes,width="+width+", height="+height+",scrollbars="+scrollbar);
	if (childWindow.opener == null) childWindow.opener = self;
	childWindow.focus();
}

/**/

var ws_cnt_ajax_answer;
function ws_cnt_makeRequest(url,event,id) { // kérelem
 var http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
   http_request = new XMLHttpRequest();
   if (http_request.overrideMimeType) {
    http_request.overrideMimeType('text/xml'); // ha nem xml alapú lapot töltünk be, és hibát ír, akkor ezt kell kikommentezni
   }
  } else if (window.ActiveXObject) { // IE
   try {
    http_request = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
       http_request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
     }
   }

   if (!http_request) {
    alert('Feladtam :( Nem tudok XMLHTTP példányt létrehozni');
            return false;
   }
    http_request.onreadystatechange = function() { ws_cnt_alertContents(http_request,event,id); };
    http_request.open('GET', url, true);
    http_request.send(null);
}

/* feldolgozás */
function ws_cnt_alertContents(http_request,event,id) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var ws_cnt_ajax_answer=http_request.responseText;
			if (event == 'delete_proform_erkeztetes') {
				document.getElementById('proform_erkeztetes_'+id).style.display = 'none';
				document.getElementById('beerkezett_osszeg_'+ws_cnt_proform_id).innerHTML = ws_cnt_ajax_answer;
			}
		}
	}
}

/* php.js */

function number_format( number, decimals, dec_point, thousands_sep ) {
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;

    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function substr( f_string, f_start, f_length ) {
    f_string += '';

    if(f_start < 0) {
        f_start += f_string.length;
    }

    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }

    if(f_length < f_start) {
        f_length = f_start;
    }

    return f_string.substring(f_start, f_length);
}

document.getElements = function(e, elem) {
	if (!e || !e.length || e.length == 0) return [];
	var store = [elem||document.body];
	var store_t = [];
	e = e.split(" ");
	for (var i=0; i<e.length; i++) {
		var r = {
			id:  "",
			tag: "*",
			clas:[]
		};
		var c, s, t=e[i];
		while (t.length > 0) {
			s = t.search(/.[#\.]/) + 1 || t.length;
			c = t.substr(0, s);

			if (c.substr(0, 1) == "#")		r.id = c.substr(1);
			else if (c.substr(0, 1) == ".")	r.clas.push(c.substr(1));
			else							r.tag = c;

			t = t.substr(s);
		}
		while (store.length > 0) {
			var curr = [], temp = store.shift().getElementsByTagName(r.tag);
			for (var j=0; j<temp.length; j++) {
				curr.push(temp[j]);
			}
			while (curr.length > 0) {
				var ok = true, ce = curr.shift();
				if (r.id && ce.id!=r.id) ok = false;
				for (j=0; j<r.clas.length; j++) {
					if ((" "+ce.className+" ").indexOf(" "+r.clas[j]+" ") == -1) {
						ok = false;
						break;
					}
				}
				if (ok) store_t.push(ce);
			}
		}
		store = store_t;
		store_t = [];
	}
	return store;
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}

function webshop_cnt_onSubmitForm() {
	webshop_cnt_check_required_all();

	if (webshop_cnt_onsubmit_errors == 0) return true;
	else {
		alert("Kérem töltsön ki minden mezőt, ami mellett felkiáltójel található!");
		//window.confirm("Kérem töltsön ki minden mezőt, ami mellett felkiáltójel található!");
		return false;
	}
}

function webshop_cnt_check_required_all() {
	var inputs = getElementsByClass('required');

	webshop_cnt_onsubmit_errors = 0;
	var elozo_webshop_cnt_onsubmit_errors = 0;

	var i;
	for (i=0;i<inputs.length;i++) {
		elozo_webshop_cnt_onsubmit_errors = webshop_cnt_onsubmit_errors;
		if (inputs[i].className == "number required") webshop_cnt_check_required_number(inputs[i]);
		else if (inputs[i].className == "file required") webshop_cnt_check_required_file(inputs[i]);
		else if (inputs[i].className == "password required") webshop_cnt_check_required_password(inputs[i]);
		else if (inputs[i].className == "email required") webshop_cnt_check_required_email(inputs[i]);
		else if (inputs[i].className == "input required") webshop_cnt_check_required_input(inputs[i]);
		else if (inputs[i].className == "textarea required") webshop_cnt_check_required_textarea(inputs[i]);
		else if (inputs[i].className == "select required") webshop_cnt_check_required_select(inputs[i]);
		else if (inputs[i].className == "multiselect required") webshop_cnt_check_required_multiselect(inputs[i]);
		else if (inputs[i].className == "radio required") webshop_cnt_check_required_radio(inputs[i]);
		else if (inputs[i].className == "checkbox required") webshop_cnt_check_required_checkbox(inputs[i]);
		else if (inputs[i].className == "checkboxgroup required") webshop_cnt_check_required_checkboxgroup(inputs[i]);

		if (webshop_cnt_onsubmit_errors == 1 && elozo_webshop_cnt_onsubmit_errors == 0) {
			inputs[i].focus();
		}
	}

	return true;
}

function webshop_cnt_check_required_number(obj) {
	obj.value = obj.value.replace(/[^0-9,-\.\/]/gi,'');

	return webshop_cnt_check_required_input(obj);
}


function webshop_cnt_check_required_input(obj) {
	if (obj.value == '') {
		webshop_cnt_onsubmit_errors++;
		webshop_cnt_showErrorPicture(obj);
		return true;
	}
	else {
		webshop_cnt_hideErrorPicture(obj);
		return false;
	}
}

function webshop_cnt_check_required_select(obj) {
	if (obj.value <= 0) {
		webshop_cnt_onsubmit_errors++;
		webshop_cnt_showErrorPicture(obj);
		return true;
	}
	else {
		webshop_cnt_hideErrorPicture(obj);
		return false;
	}
}

function webshop_cnt_hideErrorPicture(obj) {
	var pictureid = "errorPictureDiv_" + obj.id;

	if (document.getElementById(pictureid)) {
		document.getElementById(pictureid).style.display = 'none';
	}
}

function webshop_cnt_showErrorPicture(obj) {
	var pictureid = "errorPictureDiv_" + obj.id;

	var obi = document.getElementById(obj.id).parentNode.childNodes[1];
	obi.style.color='red';

	if (document.getElementById(pictureid)) {
		document.getElementById(pictureid).style.display = 'block';
	}
	else {
		var bodyNode = document.getElementsByTagName("body").item(0);

		var errorPictureDiv = document.createElement("div");
		with (errorPictureDiv.style){
			position = "absolute";
			zIndex = 0;
			border = "0px";
			color = "red";
			top = webshop_cnt_getY(obj) + "px";
			left = webshop_cnt_getX(obj) + 407 + "px";
			width = "50px";
			height = "50px";
		}
		//errorPictureDiv.innerHTML = "<img src='/images/felkialtojel.jpg' />";
		errorPictureDiv.innerHTML = "<b>!</b>";
		//bodyNode.appendChild(errorPictureDiv);
		errorPictureDiv.id = pictureid;
	}
}

function webshop_cnt_getX(object) {
	var iReturnValue = 0;
	while(object != null ) {
		iReturnValue += object.offsetLeft;
		object = object.offsetParent;
	}
	return iReturnValue;
}

function webshop_cnt_getY(object) {
	var iReturnValue = 0;
	while(object != null ) {
		iReturnValue += object.offsetTop;
		object = object.offsetParent;
	}
	return iReturnValue;
}


var last_set_active_szallas_szoba_num = -1;
function set_active_szallas_szoba_num(obj){
	if (obj != last_set_active_szallas_szoba_num) {
		if (document.getElementById(obj)) {
			document.getElementById(obj).disabled = false;
			if (last_set_active_szallas_szoba_num != "-1") {
				document.getElementById(last_set_active_szallas_szoba_num).disabled = true;
			}
		}
		last_set_active_szallas_szoba_num = obj;
	}
}

function ws_cnt_szallas_datumvalasztva() {
	document.getElementById("js_submit").click();

	var erkezes = new Date();
	erkezes.setFullYear(document.getElementById('szallas_arrive_year').value);
	erkezes.setMonth(document.getElementById('szallas_arrive_month').value);
	erkezes.setDate(document.getElementById('szallas_arrive_day').value);

	var tavozas = new Date();
	tavozas.setFullYear(document.getElementById('szallas_departure_year').value);
	tavozas.setMonth(document.getElementById('szallas_departure_month').value);
	tavozas.setDate(document.getElementById('szallas_departure_day').value);

	var delta = tavozas.getTime() - erkezes.getTime();
	var eredmeny = Math.round(delta / 86400 / 1000);
	document.getElementById('szallas_ejszakakszama').innerHTML = eredmeny;
}




