function showForm(elem, action) {
	if (action == 1) {
		document.getElementById(elem).style.display = "block";
	} else if (action == 2) {
		document.getElementById(elem).style.display = "none";
	} else {
		document.getElementById(elem).style.display = "none";
	}
}

function changeBgcolor(elem, color) {
	document.getElementById(elem).style.backgroundColor = color;
}

function changeBorder(elem, color, bgColor) {
	document.getElementById(elem).style.borderColor = color;
	document.getElementById(elem).style.backgroundColor = bgColor;
}

var allHTMLTags = new Array();
function getElementByClass(elem, color, bgColor) {

	//Create Array of All HTML Tags
	var allHTMLTags=document.getElementsByTagName("*");
	
	//Loop through all tags using a for loop
	for (i=0; i<allHTMLTags.length; i++) {
		
		//Get all tags with the specified class name.
		if (allHTMLTags[i].className==elem) {
		
			//Place any code you want to apply to all
			//pages with the class specified.
			//In this example is to “display:none;” them
			//Making them all dissapear on the page.
			
			//allHTMLTags[i].style.display=’none’;
			allHTMLTags[i].style.borderColor = color;
			allHTMLTags[i].style.backgroundColor = bgColor;
		}
	}
}

function lengthTitle() {
	document.getElementById('title').maxLength = 100;	
}

function changeSection(elem, elem2, elem3, hodnota, z) {
	
	section = document.getElementById('sectionGal' + z + '_' + hodnota ).value;
	idSection = document.getElementById('sectionId' + z + '_' + hodnota ).value;
	url = document.getElementById('sectionUrl' + z + '_' + hodnota ).value;
	
	document.getElementById(elem).value = section;
	document.getElementById(elem2).value = idSection;
	document.getElementById(elem3).value = url;
}

function chars(arr) {
	hodnota = document.getElementById('positionMenu').selectedIndex;
	
	document.getElementById('titleMenu').maxLength = arr[hodnota];
	document.getElementById('tipMax').innerHTML = '<span class="povinne">' + arr[hodnota] + '</span> povolených znaků.';
	
}

function showSort(arr) {
	hodnota = document.getElementById('positionMenu').selectedIndex;
	
	if (arr[hodnota] > 0) {
		max = arr[hodnota];
		endMax = '';
		document.getElementById('sortPage').range = [1, max];
		document.getElementById('sortPage').min = false;
	} else {
		max = '?';
		endMax = ' (nemá konečnou hranici)';
		document.getElementById('sortPage').range = false;
		document.getElementById('sortPage').min = 1;
	}
	document.getElementById('showSort').innerHTML = 'Rozmezí hodnot je <span class="povinne">1 až ' + max + '</span>' + endMax + '.';
}

function showPass(arr) {
	hodnota = document.getElementById('statusPage').selectedIndex;
	
	if (arr[hodnota] == 1) {
		document.getElementById('showPass').innerHTML = '<span class="addInput">Vložit heslo:</span><input type="password" class="middleText" name="password" />'
		
	} else {
		document.getElementById('showPass').innerHTML = ''
	}
}

function count(arr) {
	lengthTitle = document.getElementById('titleMenu').value.length;

	document.getElementById('tip').innerHTML = 'Je napsáno <span class="povinne">' + (lengthTitle) + '</span> znaků z ';
	
}

function checkSubmit(elem) {
	hodnota = document.getElementById(elem).value;
	
	//alert(hodnota);
	
	//hodnota = document.getElementById('reg_send_cond').value;
	
	if (hodnota == 0) {
		alert('Musíte souhlasit s podmínkami užití.');	
	}
	
}

function sArrow(arrow, elem, icon, max) {
	if (max >1) {
		actSld = document.getElementById('actSld').value;
		prevSld = actSld;
		if (arrow == "L") {
			if (actSld == 1) {
				actSld = max;
			} else {
				actSld--;
			}		
		} else if (arrow == "R") {
			if (actSld == max) {
				actSld = 1;
			} else {
				actSld++;
			}
		}
		document.getElementById('actSld').value = actSld;
		
		document.getElementById(elem + actSld).style.display = 'block';
		document.getElementById(elem + prevSld).style.display = 'none';
		
		$(document).ready(function() {
			$('span.' + icon + actSld).addClass("active");
			$('span.' + icon + actSld).removeClass("icon");
			
			$('span.' + icon + prevSld).addClass("icon");
			$('span.' + icon + prevSld).removeClass("active");
		});
	} else {
		$(document).ready(function() {
			$('span.' + icon + actSld).addClass("active");
			$('span.' + icon + actSld).addClass("active");
		});
	}
}


