var GaleryCasovac = null;

function GaleryStart(posun)
{
	if (GaleryCasovac != null)
	{
		clearInterval(GaleryCasovac);
	}
	GaleryCasovac = setInterval('GaleryPosun('+posun+')',30);
}

function GaleryPosun(posun)
{
	var floatObj = document.getElementById('galery-content');

	if (posun > 0 && floatObj.offsetTop>=0)
	{
		GaleryStop();
		return;
	}
	
	if (posun < 0 && 660 - floatObj.offsetTop >= floatObj.offsetHeight)
	{
		GaleryStop();
		return;
	}

	floatObj.style.top = (floatObj.offsetTop + posun) + 'px';
}

function GaleryStop()
{
	if (GaleryCasovac != null)
	{
		clearInterval(GaleryCasovac);
		GaleryCasovac = null;
	}
}

function GaleryAutomatStart(posun)
{
	if (GaleryCasovac != null)
	{
		clearInterval(GaleryCasovac);
	}
	GaleryCasovac = setInterval('GaleryAutomatPosun('+posun+')',99950);
}

function GaleryAutomatPosun(posun)
{
	var floatObj = document.getElementById('galery-content');

	if (posun > 0 && floatObj.offsetTop>=0)
	{
		GaleryAutomatStart(posun*(-1))
		return;
	}

	if (posun < 0 && 660 - floatObj.offsetTop >= floatObj.offsetHeight)
	{
		GaleryAutomatStart(posun*(-1))
		return;
	}

	floatObj.style.top = (floatObj.offsetTop + posun) + 'px';
}

function ChangeBigPicture(source, descr)
{
	$j("#big-image").attr("src", source);
	$j(".box-navigace").html(getPrevButton() + getNextButton() + '<div class="nav-center">' + descr + '</div>');
	
}



function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Vypňte prosím platný e-mail!");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Vypňte prosím platný e-mail!");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Vypňte prosím platný e-mail!");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Vypňte prosím platný e-mail!");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Vypňte prosím platný e-mail!");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Vypňte prosím platný e-mail!");
		    return false;
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Vypňte prosím platný e-mail!");
		    return false;
		 }

 		 return true;
	}

function ValidateForm(){
	var emailID=document.login.email;

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Vypňte prosím platný e-mail!");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.focus();
		return false;
	}
	return true
}

function getPictNumb()
{
    for (i=0;i<arrThumbSrc.length;i++)
    {
		if (arrThumbSrc[i] == $j('#big-image').attr('src'))
		{
			return i;
		}
 	}
}

function getPrevButton()
{
	var intPictNumb = getPictNumb();
	if(intPictNumb == 0)
	    return "";
	else
		//return '<a onclick="ChangeBigPicture(\''+ arrThumbSrc[intPictNumb-1] +'\', \''+ arrThumbDescr[intPictNumb-1] +'\');" href="javascript: void(0);"><img src="/assets/templates/nobis/img/prev.gif" /></a> ';
		return  '<div class="nav-button-prev"><a href="javascript: void(0);" onclick="ChangeBigPicture(\''+ arrThumbSrc[intPictNumb-1] +'\', \''+ arrThumbDescr[intPictNumb-1] +'\');"><img class="nav-img" src="'+baseUrl+'assets/templates/nobis/img/prev.gif" alt="" /></a></div>';
}

function getNextButton()
{
	var intPictNumb = getPictNumb();
	if(intPictNumb == arrThumbSrc.length-1)
	    return "";
	else
	    //return ' <a onclick="ChangeBigPicture(\''+ arrThumbSrc[intPictNumb+1] +'\', \''+ arrThumbDescr[intPictNumb+1] +'\');" href="javascript: void(0);"><img src="/assets/templates/nobis/img/next.gif" /></a>';
		return '<div class="nav-button-next"><a href="javascript: void(0);" onclick="ChangeBigPicture(\''+ arrThumbSrc[intPictNumb+1] +'\', \''+ arrThumbDescr[intPictNumb+1] +'\');"><img class="nav-img" src="'+baseUrl+'assets/templates/nobis/img/next.gif" alet="" /></a></div>';
}

function getBase()
{

}
