//(c) E-TECH.NET.PL 
//efotosport fx 
var slideshowstarted=0;
var intval;
var slideshowlink=document.getElementById("slideshowlink");
var slideshowpause=document.getElementById("slideshowpause");
var slideshowtime=4000;
var bnumber=1;


function banner_rotator()
{
var banner=document.getElementById("banner");
bnumber=bnumber+1;
if (bnumber>4) { bnumber=1; }
banner.src='/images/'+bnumber+'.png';
if (bnumber==1) { setTimeout("banner_rotator()",2400); }
if (bnumber==2) { setTimeout("banner_rotator()",2400); }
if (bnumber==3) { setTimeout("banner_rotator()",4800); }
if (bnumber==4) { setTimeout("banner_rotator()",9600); }
}


function banner_rotator_start()
{
setTimeout("banner_rotator()",2400);
}


function nextimagess_fx()
{

fade('photorow');
setTimeout("nextimagess()",TimeToFade+100);
}

function nextimagess()
{
var numphotospan=document.getElementById("numphotospan");
var photorow=document.getElementById("photorow");
var hiddenimage=document.getElementById("hiddenimage");
cIndex=cIndex+1;
if (cIndex>maxIndex) { cIndex=1; }
numphotospan.innerHTML="Zdjęcie "+cIndex+' z '+maxIndex;
photorow.style.width=photos[1][cIndex]+"px";
photorow.style.height=photos[2][cIndex]+"px";
photorow.style.opacity="1";
photorow.style.filter="alpha(Opacity=100)";
hiddenimage.width=photos[1][cIndex]+"px";
hiddenimage.height=photos[2][cIndex]+"px";
photorow.style.backgroundImage="url(/data/photo/full/"+photos[0][cIndex]+")";
photorow.FadeState=null;
}

function slideshowstartstop()
{
var slideshowlink=document.getElementById("slideshowlink");
var slideshowpause=document.getElementById("slideshowpause");
if (slideshowstarted==0) 
{ 
intval=setInterval("nextimagess_fx()",slideshowtime); 
slideshowstarted=1; 
slideshowlink.innerHTML="Zakończ pokaz"; 
slideshowpause.style.display="block"; 
} 
else 
{ 
clearInterval(intval); 
slideshowstarted=0; 
slideshowlink.innerHTML="Pokaz slajdów";
slideshowpause.style.display="none"; 
}
}


function slideshowpausedo()
{
var slideshowlink=document.getElementById("slideshowlink");
var slideshowpause=document.getElementById("slideshowpause");
if (slideshowstarted==0) 
{ 
intval=setInterval("nextimagess_fx()",slideshowtime); 
slideshowstarted=1; 
slideshowpause.style.display="block"; 
slideshowpause.innerHTML="Pokaz slajdów - pauza"; 
} 
else 
{ 
clearInterval(intval); 
slideshowstarted=0; 
slideshowpause.innerHTML="Pokaz slajdów - wznów"; 
}
}


var TimeToFade = 400.0;

function fade(eid)
{
var element = document.getElementById(eid);
if(element == null)
return;

if(element.FadeState == null)
{
if(element.style.opacity == null
|| element.style.opacity == ''
|| element.style.opacity == '1')
{
element.FadeState = 2;
}
else
{
element.FadeState = -2;
}
}

if(element.FadeState == 1 || element.FadeState == -1)
{
element.FadeState = element.FadeState == 1 ? -1 : 1;
element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
}
else
{
element.FadeState = element.FadeState == 2 ? -1 : 1;
element.FadeTimeLeft = TimeToFade;
setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
}
}

function animateFade(lastTick, eid)
{
var curTick = new Date().getTime();
var elapsedTicks = curTick - lastTick;

var element = document.getElementById(eid);
if(element.FadeTimeLeft <= elapsedTicks)
{
element.style.opacity = element.FadeState == 1 ? '1' : '0';
element.style.filter = 'alpha(opacity = '
+ (element.FadeState == 1 ? '100' : '0') + ')';
element.FadeState = element.FadeState == 1 ? 2 : -2;
return;
}
element.FadeTimeLeft -= elapsedTicks;
var newOpVal = element.FadeTimeLeft/TimeToFade;
if(element.FadeState == 1)
newOpVal = 1 - newOpVal;

element.style.opacity = newOpVal;
element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}


function is_valid_email(email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(email) == false) {
return false;
}
else
{
return true;
}

}

function validateNewUser()
{
login=document.getElementById("formNewUserLogin");
login.style.backgroundColor="#444444"
if (login.value.length<3) { login.style.backgroundColor="#FF0000"; alert('Login musi składać się z co najmniej 3 znaków!'); return false; }
haslo=document.getElementById("formNewUserHaslo");
haslo.style.backgroundColor="#444444"
if (haslo.value.length<6) { haslo.style.backgroundColor="#FF0000"; alert('Hasło musi składać się z co najmniej 6 znaków!'); return false; }
haslo2=document.getElementById("formNewUserHaslo2");
haslo2.style.backgroundColor="#444444"
if (haslo2.value!=haslo.value) { haslo.style.backgroundColor="#FF0000"; haslo2.style.backgroundColor="#FF0000"; alert('Wprowadzone hasła nie zgadzają się!'); return false; }
femail=document.getElementById("formNewUserEmail");
femail.style.backgroundColor="#444444"
if (femail.value.length<6) { femail.style.backgroundColor="#FF0000"; alert('Podaj prawidłowy adres email!'); return false; }
if (!is_valid_email(femail.value)) { femail.style.backgroundColor="#FF0000"; alert('Podaj prawidłowy adres email!'); return false; }
nuform=document.getElementById("formNewUser");
nuform.submit();
}
