function showSubsections(sid)
{
	var sects = sub_array();
	var submenu = document.getElementById("sub_" + sid);
	
	for (var i = 0; i < sects.length; i++)
	{
		if (sects[i] == sid)
		{
			if (submenu.style.display != 'block')
			{
				//submenu.style.display = 'block';
				$("#sub_" + sid).slideDown("fast");
			}
			else
			{
				//submenu.style.display = 'none';
				$("#sub_" + sid).slideUp("fast");
			}
		}
		else
		{
			if (document.getElementById("sub_" + sects[i]).style.display == 'block')
			{
				//document.getElementById("sub_" + sects[i]).style.display = 'none';
				$("#sub_" + sects[i]).slideUp("fast");
			}
		}
	}
}

function checkForm(f, lng)
{
	var txt;
	var error = 0;
	if (lng == 'lv') txt = 'Aizpildiet visus nepieciešamos laukus';
	if (lng == 'ru') txt = 'Заполните все необходимые поля';
	if (lng == 'en') txt = 'Fill all required fields';
	
	if (f['name']) {if (f['name'].value == '') error++;}
	if (f['email']) {if (f['email'].value == '') error++;}
	if (f['message']) {if (f['message'].value == '') error++;}
	
	if (error > 0)
	{
		alert(txt);
		return false;
	}
	else return true;
	
}

$(document).ready(function() {

	$("div#makeMeScrollable").smoothDivScroll({
		autoScroll: "onstart", 
		autoScrollDirection: "backandforth", 
		autoScrollStep: 1, 
		autoScrollInterval: 15, 
		startAtElementId: "startAtMe", 
		visibleHotSpots: "always"
	});
	
	$('#bg_slides').cycle({
		fx:    'fade',
		speed: 10000, 
		timeout: 5000, 
		delay: -8000,
		random: 1
	});


	$("a[rel=fb_gall]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity' 	: '0.7',
		'overlayColor' 		: '#000', 
		'speedIn'			: 200, 
		'speedOut'			: 0, 
		'padding'			: 0,
		'titlePosition' 	: 'over',
		'centerOnScroll' 	: true
	});
	
	
	$("a.fbox").fancybox({
		'transitionIn'		:	'fade',
		'transitionOut'		:	'fade',
		'overlayOpacity'	:   '0.7',
		'overlayColor' 		:   '#000',
		'titleShow' 		:   false,
		'speedIn'			:	200, 
		'speedOut'			:	0,
		'padding'			:	0,
		'showCloseButton'	:	false,
		'hideOnContentClick':	true,
		'centerOnScroll' 	:	true
	});
});
