// JavaScript Document

function CheckInput(x){
	if(x.length < 3	){
		alert("Pre vyhladávanie musíte zadat minimálne 3 znaky!");
		return false;
	}else{
		return true;
	}
}

function checkEmail(adresa)
{
	var pozice_zavinace = adresa.indexOf("@");
	if (pozice_zavinace < 0)
		return false;
	var cast_pred_zavinacem = adresa.substring(0,pozice_zavinace);
	var cast_po_zavinaci = adresa.substring(pozice_zavinace+1,adresa.length);
	if (cast_po_zavinaci.indexOf("@") >= 0)
		return false;
	if (cast_pred_zavinacem.length <= 0)
		return false;
	if (cast_po_zavinaci.length <= 0)
		return false;
	var pozice_posledni_tecky = cast_po_zavinaci.lastIndexOf(".");
	if (pozice_posledni_tecky < 0)
		return false;
	var pocet_znaku_za_posledni_teckou = cast_po_zavinaci.length - pozice_posledni_tecky - 1;
	if (pocet_znaku_za_posledni_teckou < 2  ||  pocet_znaku_za_posledni_teckou > 3)
		return false;
	var pozice_dvou_tecek_vedle_sebe = adresa.indexOf("..");
	if (pozice_dvou_tecek_vedle_sebe >= 0)
		return false;
	if (cast_pred_zavinacem.charAt(0) == "."  ||  cast_pred_zavinacem.charAt(cast_pred_zavinacem.length-1) == ".")
		return false;
	if (cast_po_zavinaci.charAt(0) == "."  ||  cast_po_zavinaci.charAt(cast_po_zavinaci.length-1) == ".")
		return false;
	return true;
}
 
function checkBulletin(form){
	if(checkEmail(form.mail.value)){
		return true;
	}
	else{
		alert("Zadali ste neplatnú emailovú adresu!");
		return false;
	}
}

function loginCheck(thisForm){
	if(thisForm.login.value	== '' || thisForm.pwd.value	== '')
	{
		alert('Aby ste sa mohli prihlásiť musíte zadať meno a heslo.');
		return false;
	}
}

function searchFocus(id)
{
	id.style.color = '#4a4a4a';
	id.value = '';
}

function menuEvent(id){
	// zobrazi polozku podla indexu
	if ($.browser.msie && ($.browser.version == '7.0' || $.browser.version == '6.0'))
	{
		$(".ddsmoothmenu-v:eq(" + id + ")").find("ul:first").show();
		$(".ddsmoothmenu-v:lt(" + id + ")").find("ul:first").hide();		// skryje polozky pred indexom		
		$(".ddsmoothmenu-v:gt(" + id + ")").find("ul:first").hide();		// skryje polozky za indexom
	}
	else{
		$(".ddsmoothmenu-v:eq(" + id + ")").find("ul:first").slideDown(1300, menuHide(id));	
	}
}

function menuHide(id){	
	$(".ddsmoothmenu-v:lt(" + id + ")").find("ul:first").slideUp(300);		// skryje polozky pred indexom		
	$(".ddsmoothmenu-v:gt(" + id + ")").find("ul:first").slideUp(300);		// skryje polozky za indexom
}

$(document).ready(function () {
	$("a[rel^='lightbox']").prettyPhoto({
		animationSpeed: 'fast', /* fast/slow/normal */
		padding: 50, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
		modal: false, /* If set to true, only the close button will close the window */
		changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
		callback: function(){} /* Called when prettyPhoto is closed */
	});
});
