﻿var Blocks =
	{
		currentPath: '',

		Click: function(hyperlink) {
			var id = this.GetClass(hyperlink)
			this.CloseOthers(id)
			this.ShowBlock(id)

			$('.CAO_HH').show()
			
			var lastCharUrl = hyperlink.href.substring(hyperlink.href.length - 1, hyperlink.href.length)
			if (lastCharUrl == "#")
			{
				$('.faqserviceQuestions').hide()
			}
		},

		GetClass: function(hyperlink) {
			var classes = hyperlink.className.split(' ')
			for (var i = 0; i < classes.length; i++) {
				if (classes[i].substring(0, 3) == 'li-') {
					return classes[i].substring(3, classes[i].length)
				}
			}
		},

		CloseOthers: function(path) {
			if (path.indexOf(this.currentPath) != 0) {
				// Hide current folders
				var folders = this.currentPath.split('_')
				var folderPath = ''
				for (var i = 0; i < folders.length; i++) {
					folderPath += folders[i]
					this.HideBlock(folderPath)
					folderPath += '_'
				}

				// Show current
				var folders = path.split('_')
				var folderPath = ''
				for (var i = 0; i < folders.length; i++) {
					folderPath += folders[i]
					this.ShowBlock(folderPath)
					folderPath += '_'
				}

			}
			this.currentPath = path
		},

		HideBlock: function(folderPath) {
			$('.' + folderPath).hide()
			$('.li-' + folderPath).removeClass('true')
		},

		ShowBlock: function(folderPath) {
			$('.' + folderPath).show()
			$('.li-' + folderPath).addClass('true')
		}
	}
