Ext.onReady(function(){	if (Ext.get('flash_header'))	{		Ext.get('header').addClass('nobackground');		Ext.get('flash_header').removeClass('noscreen');	}		/*Ext.select('a.frey').on('click', function(e){		e.stopEvent();		var thumbnail = Ext.get(e.target);		var anchor = thumbnail.parent();		var image = Ext.get('image').child('img');				if (image)		{			image.dom.src = anchor.dom.href;			image.dom.alt = thumbnail.dom.alt;			image.dom.width = 476;			if (anchor.dom.title !== '')			{				// vlozime popis fotky				Ext.get('description').update(anchor.dom.title);				// nastavime viditelnost				Ext.get('description').replaceClass('noscreen', 'screen');			}			else			{				Ext.get('description').update();				Ext.get('description').replaceClass('screen', 'noscreen');			}		}			});*/});$(function() {	/*$("#h_malevil").mouseover(function() {		$("#d_malevil").show();	}).mouseout(function() {		$("#d_malevil").hide();	});	$("#h_benatky").mouseover(function() {		$("#d_benatky").show();	}).mouseout(function() {		$("#d_benatky").hide();	});	$("#h_mstetice").mouseover(function() {		$("#d_mstetice").show();	}).mouseout(function() {		$("#d_mstetice").hide();	});	$("#h_zbraslav").mouseover(function() {		$("#d_zbraslav").show();	}).mouseout(function() {		$("#d_zbraslav").hide();	});	$("#h_motol").mouseover(function() {		$("#d_motol").show();	}).mouseout(function() {		$("#d_motol").hide();	});	$("#h_hamry").mouseover(function() {		$("#d_hamry").show();	}).mouseout(function() {		$("#d_hamry").hide();	});	$("#h_sokolov").mouseover(function() {		$("#d_sokolov").show();	}).mouseout(function() {		$("#d_sokolov").hide();	});	$("#h_mlazne").mouseover(function() {		$("#d_mlazne").show();	}).mouseout(function() {		$("#d_mlazne").hide();	});	$("#h_plzen").mouseover(function() {		$("#d_plzen").show();	}).mouseout(function() {		$("#d_plzen").hide();	});	$("#h_bechyne").mouseover(function() {		$("#d_bechyne").show();	}).mouseout(function() {		$("#d_bechyne").hide();	});	$("#h_hluboka").mouseover(function() {		$("#d_hluboka").show();	}).mouseout(function() {		$("#d_hluboka").hide();	});	$("#h_krumlov").mouseover(function() {		$("#d_krumlov").show('blind',{}, 200, "");	}).mouseout(function() {		$("#d_krumlov").hide();	});*/		$("#headersearchtext").click(function() {		if ($("#headersearchtext").val() == "Najdi hřiště, událost, výsledky...") {			$("#headersearchtext").val("");		}	});});var firm_optional_services_price = 0;var firm_optional_services_pricef = 0;var basic_price = 0;function basicPrice(elementId, price) {$(document).ready(function() {	firm_optional_services_price = 0;	var radio = Ext.get(elementId);	var price_container = Ext.get('final_price');		if (radio.dom.checked == true) {		basic_price = price;	}	cardId = elementId.split('card_type_');	cardType = cardId[1];	selectedCard = cardType;	updatePrices(cardType, personAge($('#player_birthdate').value));	$('input[name="order_person[services][1][clubs][]"]').attr('checked', false);	$('input[id="services_1_club_none_"]').attr('checked', true);	if (cardType == 3) {		if (document.getElementById('player_birthdate').value == "") {			price_container.dom.innerHTML = "Musíte nejprve zadat datum narození hráče";		}		else if (personAge(document.getElementById('player_birthdate').value) < 4) {			document.getElementById('player_age').innerHTML = "Neplatné datum narození";			price_container.dom.innerHTML = "Musíte nejprve zadat správné datum narození hráče";		}		else {			price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", " ") + " Kč";			cleanUp();			dateChange();		}		$("#lifetimemember").css("display", "block");		$("#optional").css("display", "none");		$("#clubreg").css("display", "none");		$("#customer_details").css("display", "block");		$("#firm_details").css("display", "none");	}	else if (cardType == 4) {		$("#customer_details").css("display", "none");		$("#firm_details").css("display", "block");	}	else {		price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", " ") + " Kč";		$("#lifetimemember").css("display", "none");		$("#optional").css("display", "block");		$("#clubreg").css("display", "block");		$("#customer_details").css("display", "block");		$("#firm_details").css("display", "none");	}	//alert(elementId);});}function personAge(birthDate) {	//alert(selectedCard);	var price_container = Ext.get('final_price');	age = 0;	today = new Date();	if (birthDate) {		birthDay = birthDate.split('-');	}	else {		birthDay = new Array();	}	if (birthDay.length == 3) {		//birth = new Date(birthDay[0], birthDay[1]*1-1, birthDay[2]);		birth = new Date(birthDay[0], 1, 1);		age = Math.floor((today.getTime() - birth.getTime()) / (365.25 * 24 * 60 * 60 * 1000));		//alert('Věk: '+age);		if (age < 4) {			document.getElementById('player_age').innerHTML = "Neplatné datum narození";			if (selectedCard == 3) {				price_container.dom.innerHTML = "Musíte nejprve zadat správné datum narození hráče";			}		}		else {			document.getElementById('player_age').innerHTML = age;		}	}	else {		//document.getElementById('player_age').innerHTML = "Neplatné datum narození";		$("#player_age").html("Neplatné datum narození");		if (selectedCard == 3) {			$("#price_container").html("Musíte nejprve zadat správné datum narození hráče");		}	}	return age;}function countPrice(elementId, price){	//console.log("\n");	//console.log("countPrice("+elementId+", "+price+")");	//alert("countPrice");	var checkbox = Ext.get(elementId);	var price_container = Ext.get('final_price');	var price_input = Ext.get('final_price_input');		if (checkbox.dom.checked == true) {		firm_optional_services_price = firm_optional_services_price + price;	}	else {		firm_optional_services_price = firm_optional_services_price - price;	}	if (selectedCard == 3) {		if (document.getElementById('player_birthdate').value == "") {			price_container.dom.innerHTML = "Musíte nejprve zadat datum narození hráče";		}		else if (personAge(document.getElementById('player_birthdate').value) < 4) {			document.getElementById('player_age').innerHTML = "Neplatné datum narození";			price_container.dom.innerHTML = "Musíte nejprve zadat správné datum narození hráče";		}		else {			price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", " ") + " Kč";			price_input.dom.value = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", "");		}	}	else {		price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", " ") + " Kč";		price_input.dom.value = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", "");	}	updatePrices(cardType, personAge(document.getElementById('player_birthdate').value));}function updatePrices(cardType, age, elementId) {	if (!elementId) {		elementId = 1;	}	if ($("#services_1_club_praha_").attr("checked") == true) {		elementId = 1;		price_life = getPrice1_(1);	}	if ($("#services_1_club_telc_").attr("checked") == true) {		elementId = 2;		price_life = getPrice2_(1);	}	if ($("#services_1_club_pisek_").attr("checked") == true) {		elementId = 3;		price_life = getPrice3_(1);	}	if ($("#services_1_club_usti_").attr("checked") == true) {		elementId = 4;		price_life = getPrice3_(1);	}	var add = 1;	cardType = parseInt(cardType);		if (age == 0) {		add = 1;		if (cardType == 3) {			add = 2;		}	}	else if (age <= 18 && cardType == 3) {		add = 3;	}	else if (age > 64 && cardType == 3) {		add = 4;	}	else {		add = 1;		if (cardType == 3) {			add = 2;		}	}$(document).ready(function() {	/*document.getElementById('club_price_1').innerHTML = club_price_1[1+add];	document.getElementById('club_price_2').innerHTML = club_price_2[1+add];	document.getElementById('club_price_3').innerHTML = club_price_3[1+add];	document.getElementById('club_price_4').innerHTML = club_price_4[1+add];*/	$("#club_price_1_").html(club_price_1_[1+add]);	$("#club_price_2_").html(club_price_2_[1+add]);	$("#club_price_3_").html(club_price_3_[1+add]);	$("#club_price_4_").html(club_price_4_[1+add]);	/*document.getElementById('club_price_1_').innerHTML = club_price_1_[1+add];	document.getElementById('club_price_2_').innerHTML = club_price_2_[1+add];	document.getElementById('club_price_3_').innerHTML = club_price_3_[1+add];	document.getElementById('club_price_4_').innerHTML = club_price_4_[1+add];*/	add++;	$("#club_price_life").html(club_price_life[2*elementId+add*elementId]);	//document.getElementById('club_price_life').innerHTML = club_price_life[2*elementId+add*elementId];	//if (!price_life) {		price_life = club_price_life[2*elementId+add*elementId];	//}	//alert(2*elementId+add*elementId);	//alert(cardType+add);	});}function dateChange() {if (selectedCard == 3) {	firm_optional_services_price = 0;	basic_price = 0;	var isempty = 0;	var price_container = Ext.get('final_price');	var price_input = Ext.get('final_price_input');	price1_ = getPrice1_();	price2_ = getPrice2_();	price3_ = getPrice3_();	price4_ = getPrice4_();	if ($("#services_1_club_praha_").attr("checked") == true) {		price_life = getPrice1_(1);	}	if ($("#services_1_club_telc_").attr("checked") == true) {		price_life = getPrice2_(1);	}	if ($("#services_1_club_pisek_").attr("checked") == true) {		price_life = getPrice3_(1);	}	if ($("#services_1_club_usti_").attr("checked") == true) {		price_life = getPrice3_(1);	}	if ($('#services_1_club_praha_').attr('checked') == true) {		countPriceRadio('services_1_club_praha_', price1_, 1);	}	else {		isempty++;	}	//alert(firm_optional_services_price);	if ($('#services_1_club_telc_').attr('checked') == true) {		countPriceRadio('services_1_club_telc_', price2_, 2);	}	else {		isempty++;	}	//alert(firm_optional_services_price);	if ($('#services_1_club_pisek_').attr('checked') == true) {		countPriceRadio('services_1_club_pisek_', price3_, 3);	}	else {		isempty++;	}	//alert(firm_optional_services_price);	if ($('#services_1_club_usti_').attr('checked') == true) {		countPriceRadio('services_1_club_usti_', price4_, 4);	}	else {		isempty++;	}	if (isempty == 4) {		price_container.dom.innerHTML = number_format(""+0+"", 0, ",", " ") + " Kč";		price_input.dom.value = number_format(""+0+"", 0, ",", "");	}	if ($('#services_lifetime').attr('checked') == true) {		if (price_input.dom.value == "0") {			countPrice('services_lifetime', price_life);		}	}	else {		isempty++;	}	//alert(firm_optional_services_price);}}previousPrice = 0;priceUsed = 0;function countPriceRadio(elementId, price, number) {	cleanUp();	//console.log("\n");	//console.log("countPriceRadio("+elementId+", "+price+", "+number+")");	//alert("countPrice");	var checkbox = Ext.get(elementId);	var price_container = Ext.get('final_price');	var price_input = Ext.get('final_price_input');		//alert(elementId);	//alert($('#'+elementId).attr('checked'));	if (price == previousPrice && priceUsed == 0) {		previousPrice = 0;		priceUsed = 1;	}	else if (priceUsed == 1) {		//previousPrice = price;	}	if (checkbox.dom.checked == true) {		firm_optional_services_price = firm_optional_services_price + price;// - previousPrice;		//console.log("firm_optional_services_price = "+firm_optional_services_price+"; previousPrice = "+previousPrice);	}	/*else {		firm_optional_services_price = firm_optional_services_price - price;	}*/	previousPrice = price;	//console.log("previousPrice: "+previousPrice);		if (selectedCard == 3) {		if (document.getElementById('player_birthdate').value == "") {			price_container.dom.innerHTML = "Musíte nejprve zadat datum narození hráče";		}		else if (personAge(document.getElementById('player_birthdate').value) < 4) {			document.getElementById('player_age').innerHTML = "Neplatné datum narození";			price_container.dom.innerHTML = "Musíte nejprve zadat správné datum narození hráče";		}		else {			price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", " ") + " Kč";			price_input.dom.value = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", "");		}	}	else {		price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", " ") + " Kč";		price_input.dom.value = number_format(""+(basic_price + firm_optional_services_price)+"", 0, ",", "");	}	//oldpricelife = price_life;	updatePrices(cardType, personAge(document.getElementById('player_birthdate').value), number);	if ($("#services_lifetime").attr("checked") == true) {		countPrice('services_lifetime', price_life);	}}function isNumberKey(evt){	var charCode = (evt.which) ? evt.which : event.keyCode	if (charCode > 31 && (charCode < 48 || charCode > 57))		return false;	else		return true;}function cleanUp() {	//console.log("\ncleanUp();");	previousPrice = 0;	firm_optional_services_price = 0;	var price_container = Ext.get('final_price');	var price_input = Ext.get('final_price_input');	price_container.dom.innerHTML = number_format(""+0+"", 0, ",", " ") + " Kč";	price_input.dom.value = number_format(""+0+"", 0, ",", "");}function countPricef(elementId, price){	//console.log("\n");	//console.log("countPrice("+elementId+", "+price+")");	//alert("countPrice");	var checkbox = Ext.get(elementId);	var price_container = Ext.get('final_pricef');	var price_input = Ext.get('final_pricef_input');		if (checkbox.dom.checked == true) {		firm_optional_services_pricef = firm_optional_services_pricef + price;	}	else {		firm_optional_services_pricef = firm_optional_services_pricef - price;	}	price_container.dom.innerHTML = number_format(""+(basic_price + firm_optional_services_pricef)+"", 0, ",", " ") + " Kč";	price_input.dom.value = number_format(""+(basic_price + firm_optional_services_pricef)+"", 0, ",", "");	//updatePrices(cardType, personAge(document.getElementById('player_birthdate').value));}function loadContent(config) {	if(config.autoGetParams && config.autoGetParams == true) {		var postParams = getParams(Ext.get(config.formId).dom);	}	else {			var postParams = config.params;	}		config.preloader = config.preloader || false;	config.formId = config.formId || '';	// zobrazime loading	if (config.preloader) {		// vytvorime loading container		Ext.get(config.targetId).createChild({			tag: 'div',			id: 'loading'		});		Ext.get('loading').setOpacity(.5);		// nastavime zpozdeni		config.timeOut = config.timeOut || 1000;	}			setTimeout(function(){		Ext.Ajax.request({			url: config.url			,method: 'POST'			,success: function(result,request){				var res = Ext.util.JSON.decode(result.responseText);				// pokud nastala chyba				if (res.success == false)				{					// odstranime predchozi elementy s chybovyma zpravama z DOMu					Ext.select('p.message-bad').remove();										// vlozime chybovou zpravu do DOMu					Ext.DomHelper.insertHtml(						'afterBegin', 						Ext.get(config.targetId).dom, 						'<p class="message-bad">' + res.error +'</p>'					);										// odebereme loading container					Ext.get('loading').remove();				}				// po uspesnem zpracovani				else				{					// vlozime vysledek vraceny skriptem					Ext.DomHelper.overwrite(Ext.get(config.targetId).dom, res.data);					if(config.callback)					{						eval(config.callback);					}				}			}			,failure: function(){				// odstranime predchozi elementy s chybovyma zpravama z DOMu				Ext.select('p.message-bad').remove();								// vlozime chybovou zpravu do DOMu				Ext.DomHelper.insertHtml(					'afterBegin', 					Ext.get(config.targetId).dom, 					'<p class="message-bad">Nepodařilo se načíst data</p>'				);								// odebereme loading container				Ext.get('loading').remove();			}			,params: ''+postParams+''		});}		,config.timeOut);	//return false;}function deleteRecord(config){		var postParams = config.params;		Ext.Ajax.request({			url: config.url			,method: 'POST'			,success: function(result,request){				var res = Ext.util.JSON.decode(result.responseText);				// pokud nastala chyba				if (res.success == false)				{					Ext.get(config.targetId).dom.innerHTML = '<p class="message-bad">' + res.errors + '</p>' + Ext.get(config.targetId).dom.innerHTML;				}				// po uspesnem zpracovani				else				{					if (config.hideElement && config.hideElement == true && config.hideId && config.hideId != '')					{						// skryjeme prvek						Ext.get(config.hideId).fadeOut({remove:true});					}				}			}			,failure: function(){				Ext.get(config.targetId).dom.innerHTML = '<p class="message-bad">Nepodařilo se načíst data</p>' + Ext.get(config.targetId).dom.innerHTML;			}			,params: ''+postParams+''		});}function simple_tooltip(target_items, name){	Ext.select(target_items+'.'+name).on('mouseover', function(e)	{		var anchor = Ext.get(e.target);		var tooltip_id = "tooltip" + anchor.dom.id;		//var my_tooltip = Ext.get(tooltip_id);		//alert(my_tooltip.toSource());                                var my_tooltip = $("#" + tooltip_id);                my_tooltip.parent().css("z-index", "999999");                my_tooltip.fadeIn();                		//my_tooltip.applyStyles({display:"block"});                //$(e.target).parent().css("z-index", "9999").css("filter", "alpha(opacity=100)");		//alert($('#'+my_tooltip.id).width()); // margin-left: -179px;	}).on('mouseout', function(e)	{		var anchor = Ext.get(e.target);		var tooltip_id = "tooltip" + anchor.dom.id;                                var my_tooltip = $("#" + tooltip_id);                my_tooltip.parent().css("z-index", "999");                my_tooltip.fadeOut();                		//var my_tooltip = Ext.get(tooltip_id);		//my_tooltip.applyStyles({display:"none"});                //$(e.target).parent().css("z-index", "999");	});}function getPosition(obj){  var topValue = 0, leftValue = 0;  while (obj)  {    leftValue += obj.offsetLeft;    topValue += obj.offsetTop;    obj = obj.offsetParent;  }  finalvalue = leftValue + "," + topValue;  return finalvalue;}function toogleCheckbox(checkboxID){	if(Ext.get(checkboxID).dom.checked)	{		Ext.get(checkboxID).dom.checked = false;	}	else	{		Ext.get(checkboxID).dom.checked = true;	}}// zobrazi/skryje prvekfunction toogleDisplay(config){	if (!config.displayId)	{		alert('Nezadáno ID prvku, který se má skrýt/zobrazit');	} 	else	{		// pokud chceme menit ikonu prepinatka		if (config.toogleIcon && config.toogleIcon == true)		{			if (!config.switcherId)			{				alert('Nezadáno ID přepínátka');			}			else			{				var switcher = Ext.get(config.switcherId).dom;			}		}		var element = Ext.get(config.displayId).dom;		switch(element.style.display)		{			case 'block':				// skryjeme prvek				element.style.display = 'none';				// zmenime prepinatko				if (config.toogleIcon && config.toogleIcon == true)				{					switcher.className = 'expand';				}				break;			case 'none':				element.style.display = 'block';				// zmenime prepinatko				if (config.toogleIcon && config.toogleIcon == true)				{					switcher.className = 'collapse';				}				break;			default: 				element.style.display = 'block';				// zmenime prepinatko				if (config.toogleIcon && config.toogleIcon == true)				{					switcher.className = 'collapse';				}		}	}}// zobrazi/skryje radek tabulkyfunction toogleRowDisplay(config){	if (!config.displayId)	{		alert('Nezadáno ID prvku, který se má skrýt/zobrazit');	} 	else	{		// pokud chceme menit ikonu prepinatka		if (config.toogleIcon && config.toogleIcon == true)		{			if (!config.switcherId)			{				alert('Nezadáno ID přepínátka');			}			else			{				var switcher = Ext.get(config.switcherId).dom;			}		}		var element = Ext.get(config.displayId).dom;		if (document.all)		{			displayValue = 'inline';		}		else		{			displayValue = 'table-row';		}		if (!element.style.display)		{			element.style.display = 'none';		}		switch(element.style.display)		{			case 'inline':			case 'table-row':				// skryjeme prvek				element.style.display = 'none';				// zmenime prepinatko				if (config.toogleIcon && config.toogleIcon == true)				{					switcher.className = 'expand';				}				break;			case 'none':				element.style.display = displayValue;				// zmenime prepinatko				if (config.toogleIcon && config.toogleIcon == true)				{					switcher.className = 'collapse';				}				break;			default:				element.style.display = displayValue;				// zmenime prepinatko				if (config.toogleIcon && config.toogleIcon == true)				{					switcher.className = 'collapse';				}		}	}}// zobrazi kalendarfunction showDatePicker(targetID){	}// fce sestavi retezec parametru z formularovych polifunction getParams(obj){	var getstr = '';	var ele = obj.elements;	for ( i = 0; i < ele.length; i++ ) {		if ( ele[i].type && ele[i].type.length > 0 ) {			switch ( ele[i].type ) { 				case "text" :					getstr += ele[i].name + '=' + ele[i].value + '&';					break;				case "password" :					getstr += ele[i].name + '=' + ele[i].value + '&';					break;				case "hidden" :					getstr += ele[i].name + '=' + ele[i].value + '&';					break;				case "textarea" :					getstr += ele[i].name + '=' + ele[i].value + '&';					break;				case "radio" :					if ( ele[i].checked ) 						getstr += ele[i].name + '=' + ele[i].value + '&';					break;				case "checkbox" :					if ( ele[i].checked )					{ 						getstr += ele[i].name + '=' + ele[i].value + '&';					}						break;				case "select-one" :					for ( var x = 0 ; x < ele[i].length; x++ ) {						if ( ele[i].options[x].selected ) 							getstr += ele[i].name + '=' + ele[i].options[x].value + '&';					}					break;				case "select-multiple" :					for ( var x =0 ; x < ele[i].length; x++ ) {						if ( ele[i].options[x].selected ) 							getstr += ele[i].name + '=' + ele[i].options[x].value + '&';					}					break;			}		}	}    return getstr;}/*var targetID;function BrowseServer(fieldID){	targetID = fieldID || 'xFilePath';	// You can use the "CKFinder" class to render CKFinder in a page:    //var finder = new CKFinder() ;    //finder.BasePath = '/js/fckeditor/editor/filemanager/browser/ckfinder/' ;    // The path for the installation of CKFinder (default = "/ckfinder/").    //finder.SelectFunction = SetFileField ;    //finder.Popup() ;        // It can also be done in a single line, calling the "static"    // Popup( basePath, width, height, selectFunction ) function:    CKFinder.Popup('/libs/ckfinder/', null, null, SetFileField) ;}*/function BrowseServer(field){  window.KCFinder = {};  window.KCFinder.callBack = function(url)   {    window.KCFinder = null;    $(field).val(url);  };  window.open('/libs/kcfinder/browse.php?type=images&lang=cs', 'kcfinder');}// This is a sample function which is called when a file is selected in CKFinder.function SetFileField(fileUrl){	Ext.get(targetID).dom.value = fileUrl ;}// formatovani ciselfunction number_format(a, b, c, d) {	// number_format(number, decimals, comma, formatSeparator)	var k = "";	if(a.indexOf("-") == 0) {		k = "-";		a = a * -1;	}	a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);	var e = a + "";	var f = e.split(".");	if(!f[0]) f[0] = "0";	if(!f[1]) f[1] = "";	if(f[1].length < b){		var g = f[1];		for(var i = f[1].length + 1; i <= b; i++) {			g += "0";		}		f[1] = g;	}	if(d != "" && f[0].length > 3) {		var h = f[0];		f[0] = "";		for(var j = 3; j < h.length; j += 3) {			i = h.slice(h.length - j, h.length - j + 3);			f[0] = d + i +  f[0] + "";		}		j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));		f[0] = j + f[0];	}	c = (b <= 0) ? "" : c;	return k + f[0] + c + f[1];}
