function teleManagerClick ( button )
	if button == "left" then
		if source == teleManagerClose then
			guiSetVisible ( teleManager, false )
			showCursor ( false )
			guiGridListClear ( list )
		elseif source == teleManagerAddTele then
			if getElementData ( getLocalPlayer(), "allowedToCreateTele" ) == true then
				guiSetVisible ( teleManager, false )
				guiSetVisible ( teleWizard, true )
				guiSetText ( teleWizardXBox, "" )
				guiSetText ( teleWizardYBox, "" )
				guiSetText ( teleWizardZBox, "" )
				guiSetText ( teleWizardRotBox, "" )
			else
				outputChatBox ( "#F5F5F5: Вы не можете создовать телепорты", 255, 0, 0, true )
			end
		elseif source == teleManagerDeleteTele then
			local selRow, selColumn = guiGridListGetSelectedItem ( list )
			if selRow == -1 then
				outputChatBox ( "#F5F5F5: Вы не выбрали телепорт для удаления", 255, 0, 0, true )
			else
				if getElementData ( getLocalPlayer(), "allowedToDestroyTele" ) == true then
					triggerServerEvent ( "client_DestroyTeleport", getLocalPlayer(), selRow + 1 )
					guiGridListClear ( list )
				else
					outputChatBox ( "#F5F5F5: Вы не можете удалять телепорты", 255, 0, 0, true )
				end
			end
		elseif source == teleManagerUseTele then
			local selRow, selColumn = guiGridListGetSelectedItem ( list )
			if selRow == -1 then
				outputChatBox ( "#F5F5F5: Вы должны выбрать телепорт для использования", 255, 0, 0, true )
			else
				triggerServerEvent ( "client_CallSpecificTeleport", getLocalPlayer(), selRow + 1 )
			end
		end
	end
end

function teleWizardClick ( button )
	if button == "left" then
		guiSetInputEnabled ( true )
		if source == teleWizardClose then
			guiSetVisible ( teleWizard, false )
			guiSetVisible ( teleManager, true )
			guiSetInputEnabled ( false )
		elseif source == teleWizardAddTele then
			local xInput = guiGetText ( teleWizardXBox )
			local yInput = guiGetText ( teleWizardYBox )
			local zInput = guiGetText ( teleWizardZBox )
			local descInput = guiGetText ( teleWizardDescBox )
			local teleRotation = guiGetText ( teleWizardRotBox )
			local teleTypeSelection
			local footOnlyState = guiRadioButtonGetSelected ( teleWizardFootOnly )
			local vehOnlyState = guiRadioButtonGetSelected ( teleWizardVehOnly )
			local bothState = guiRadioButtonGetSelected ( teleWizardBoth )
			if bothState == true then teleTypeSelection = "Для всех" end
			if footOnlyState == true then teleTypeSelection = "Пешком" end
			if vehOnlyState == true then teleTypeSelection = "На авто" end
			if tonumber(xInput) and tonumber(yInput) and tonumber(zInput) and tonumber(teleRotation) then
				if tostring(descInput) == "" then
					outputChatBox ( "#F5F5F5: Вы должна написать имя для вашего телепорта", 255, 0, 0, true )
				else
					if teleTypeSelection == false or teleTypeSelection == nil then
						outputChatBox ( "#F5F5F5: Вам нужно выбрать тип телепорта", 255, 0, 0, true )
					else
						triggerServerEvent ( "client_CreateNewTeleport", getLocalPlayer(), tonumber(xInput), tonumber(yInput), tonumber(zInput), tostring(descInput), tonumber(teleRotation), tostring(teleTypeSelection) )
						guiGridListClear ( list )
						guiSetVisible ( teleWizard, false )
						guiSetVisible ( teleManager, true )
						processAvailableTeleports()
						guiSetInputEnabled ( false )
					end
				end
			else
				outputChatBox ( "#F5F5F5: Ошибка значений телепорта", 255, 0, 0, true )
			end
		elseif source == teleWizardGetPos then
			local cX, cY, cZ = getElementPosition ( getLocalPlayer() )
			local cRot = getPedRotation ( getLocalPlayer() )
			guiSetText ( teleWizardXBox, cX )
			guiSetText ( teleWizardYBox, cY )
			guiSetText ( teleWizardZBox, cZ )
			guiSetText ( teleWizardRotBox, cRot )
		end
	end
end