function checkForm(form)
{
    for (var i=0; i < form.elements.length; i++)
    {
        if(form.elements[i].value == "")
        {
            alert('Пожалуйста, заполните все поля.');
            return false;
        }
    }
    document.forms[0].submit();
    return true;
}


function showIMG(id)
{
    if(id == "oneBox")
    {        
        onePict('stop');        
    }
    
    if(id == "twoBox")
    {
       twoPict('stop');
    }
    
    if(id == "threeBox")
    {
       threePict('stop');
    }
}

var result = 0;
var gresult = 0;

var oFFresult = 0;
var oFFgresult = 0;


function onePict(sst)
{
        document.getElementById('threeBox').style.backgroundColor = 'silver';
        document.getElementById('threeBox').style.color = '#426286';
        document.getElementById('threeBox').style.textDecoration = 'none';
    
        document.getElementById('oneBox').style.backgroundColor = 'red';
        document.getElementById('oneBox').style.color = 'white';
        document.getElementById('oneBox').style.textDecoration = 'underline';
        document.getElementById('onePict').style.zIndex = "1";
        document.getElementById('twoPict').style.zIndex = "0";
        document.getElementById('threePict').style.zIndex = "0";
        
        if(result <= 100 && gresult <= 1.0)
        {  
        result = result + 10;
        gresult = gresult + 0.1;
        document.getElementById('onePict').style.filter = "alpha(opacity="+result+")";
        document.getElementById('onePict').style.opacity = ""+ gresult +""; 
        
        document.getElementById('twoPict').style.filter = "alpha(opacity="+oFFresult+")";
        document.getElementById('twoPict').style.opacity = ""+ oFFgresult +""; 
        document.getElementById('threePict').style.filter = "alpha(opacity="+oFFresult+")";
        document.getElementById('threePict').style.opacity = ""+ oFFgresult +""; 
        
        setTimeout(onePict, 40);
        
        }
        else
        {
            result = 0;
            gresult = 0;
            if(sst == 'stop')
            {
                return;    
            }
            else
            {
                
                setTimeout(twoPict, 5000);    
            }
            
            
        }
}

function twoPict(sst)
{
        document.getElementById('oneBox').style.backgroundColor = 'silver';
        document.getElementById('oneBox').style.color = '#426286';
        document.getElementById('oneBox').style.textDecoration = 'none';
    
        document.getElementById('twoBox').style.backgroundColor = 'red';
        document.getElementById('twoBox').style.color = 'white';
        document.getElementById('twoBox').style.textDecoration = 'underline';
         
                
        document.getElementById('onePict').style.zIndex = "0";
        document.getElementById('twoPict').style.zIndex = "1";
        document.getElementById('threePict').style.zIndex = "0";

        if(result <= 100 && gresult <= 1.0)
        {  
        result = result + 10;
        gresult = gresult + 0.1;
        document.getElementById('twoPict').style.filter = "alpha(opacity="+result+")";
        document.getElementById('twoPict').style.opacity = ""+ gresult +"";
        
        document.getElementById('onePict').style.filter = "alpha(opacity="+oFFresult+")";
        document.getElementById('onePict').style.opacity = ""+ oFFgresult +""; 
        document.getElementById('threePict').style.filter = "alpha(opacity="+oFFresult+")";
        document.getElementById('threePict').style.opacity = ""+ oFFgresult +""; 
        
         
        setTimeout(twoPict, 40);
        }
        else
        {
            result = 0;
            gresult = 0;
            if(sst == 'stop')
            {
                return;    
            }
            else
            {
                setTimeout(threePict, 5000);    
            }
        }
}

function threePict(sst)
{
        document.getElementById('twoBox').style.backgroundColor = 'silver';
        document.getElementById('twoBox').style.color = '#426286';
        document.getElementById('twoBox').style.textDecoration = 'none';
    
        document.getElementById('threeBox').style.backgroundColor = 'red';
        document.getElementById('threeBox').style.color = 'white';
        document.getElementById('threeBox').style.textDecoration = 'underline';
    
                
        document.getElementById('onePict').style.zIndex = "0";
        document.getElementById('twoPict').style.zIndex = "0";
        document.getElementById('threePict').style.zIndex = "1";

        if(result <= 100 && gresult <= 1.0)
        {  
        result = result + 10;
        gresult = gresult + 0.1;
        document.getElementById('threePict').style.filter = "alpha(opacity="+result+")";
        document.getElementById('threePict').style.opacity = ""+ gresult +""; 
        
        document.getElementById('onePict').style.filter = "alpha(opacity="+oFFresult+")";
        document.getElementById('onePict').style.opacity = ""+ oFFgresult +""; 
        document.getElementById('twoPict').style.filter = "alpha(opacity="+oFFresult+")";
        document.getElementById('twoPict').style.opacity = ""+ oFFgresult +""; 
        
        setTimeout(threePict, 40);
        }
        else
        {
            result = 0;
            gresult = 0;
            if(sst == 'stop')
            {
                return;    
            }
            else
            {
                setTimeout(onePict, 5000);    
            }
        }
}
