	function cms_show(id) {
		if (document.getElementById('cms_' + id) && document.getElementById('cms_' + id + '_shell')) {
			if(document.getElementById('cms_' + id).checked == false) {
				document.getElementById('cms_' + id).checked = true;
			}
			document.getElementById('cms_' + id + '_shell').style.display = 'block';
		}
	}
	
	function cms_hide(id) {
		if (document.getElementById('cms_' + id) && document.getElementById('cms_' + id + '_shell')) {
			if(document.getElementById('cms_' + id).checked == true) {
				document.getElementById('cms_' + id).checked = false;
			}
			document.getElementById('cms_' + id + '_shell').style.display = 'none';
		}
	}
		
	function order_maincheck(id) {
		var checkarray = eval('document.getElementsByName(\'' + id + '[]\')');
		var checklength = checkarray.length - 1;
		if(document.getElementById(id + '_main').checked == true) {
			for (var i=0;i<=checklength;i++) {
				if (checkarray[i].disabled == true) {
					checkarray[i].checked = true;	
				}
			}
			if (document.getElementById(id + '_body').style.display == 'none') {
				order_show(id);
			}
			cms_show(id);
//			PROBLEM AKTIVIRA SE VINAGI PRI REFRESH NA STRANICATA			
//			if (id == 'custom' && document.getElementById('custom_description')) {
//				document.getElementById('custom_description').focus();
//			}
		}
		else {
			for (var i=0;i<=checklength;i++) {
				checkarray[i].checked = false;	
			}
			if (document.getElementById(id + '_body').style.display == 'block') {
				order_hide(id);
			}
			cms_hide(id);
		}
	}

	function order_optioncheck(id,option) {
		var checkarray = eval('document.getElementsByName(\'' + id + '[]\')');
		var checklength = checkarray.length - 1;
		if(option.checked == true) {
			if(document.getElementById(id + '_main').checked == false) {
				document.getElementById(id + '_main').checked = true;
				for (var i=0;i<=checklength;i++) {
					if (checkarray[i].disabled == true) {
						checkarray[i].checked = true;	
					}
				}
				cms_show(id);
			}
		}
	}

	function order_checkall(id) {
		var checkarray = eval('document.getElementsByName(\'' + id + '[]\')');
		var checklength = checkarray.length - 1;
		for (var i=0;i<=checklength;i++) {
			checkarray[i].checked = true;	
		}
		cms_show(id);		
	}
	
	function order_control(id) {
		if (document.getElementById(id + '_body').style.display == 'block') {
			order_hide(id);
		}
		else {
			order_show(id);
		}
	}
	
	function hideAll() {
		parts = new Array('design', 'products', 'ecommerce', 'users', 'features', 'seo', 'cms', 'custom');
		for (i = 0; i < parts.length; i++) {
			if (document.getElementById(parts[i] + '_body').style.display == 'block') {
				order_hide(parts[i]);
			}
		}
	}
	
	function order_hide(id) {
		document.getElementById(id + '_body').style.display = 'none';
		document.getElementById(id + '_title').style.color = '#0E78C6';
		document.getElementById(id + '_control').innerHTML = '<span class="text">отвори</span>';
		document.getElementById(id + '_control').style.backgroundPosition = 'top right';
		document.getElementById(id + '_control').parentNode.style.backgroundPosition = 'top right';
	}
	
	function showAll() {
		parts = new Array('design', 'products', 'ecommerce', 'users', 'features', 'seo', 'cms', 'custom');
		for (i = 0; i < parts.length; i++) {
			if (document.getElementById(parts[i] + '_body').style.display == 'none') {
				order_show(parts[i]);
			}
		}
	}
	
	function order_show(id) {
		document.getElementById(id + '_body').style.display = 'block';
		document.getElementById(id + '_title').style.color = '#39B54A';
		document.getElementById(id + '_control').innerHTML = '<span class="text">затвори</span>';
		document.getElementById(id + '_control').style.backgroundPosition = 'bottom right';
		document.getElementById(id + '_control').parentNode.style.backgroundPosition = 'bottom right';
	}

	var ajaxInterval;
	window.onload = function() {
		ajaxInterval = window.setInterval(function() {
			ajaxSessionPut(document.getElementById('order_form'));
		}, 300000);
	}
	
	function clearSessionInterval() {
		if (ajaxInterval) {
			window.clearInterval(ajaxInterval);
		}
	}
	
	doubleclick = false;
	function orderFormCheckAndSubmit() {
		if (document.getElementById('name').value == '') {
			alert('Моля, въведете Вашето име!');
			return false;
		}
		else if (document.getElementById('phone').value == '') {
			alert('Моля, въведете мобилен или стационарен телефон!');
			return false;
		}
		else if (!doubleclick) {
			clearSessionInterval();
			doubleclick = true;
			document.getElementById('order_form').submit();
			return false;
		}
		else {
			return false;
		}
	}
	
	function orderRemoveOptions(id) {
		if (document.getElementById(id)) {
			document.getElementById(id).value = 'true';
		}
	}