
function isValidEmail(email, required) {
    if (required==undefined) {   
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
        return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
        return false;
    }
    return true;
}

function ps_site_checkremind()
{
 return true;
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}


function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
}

function isIE()
{
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}




function blendimage(divid, imageid, imagefile, millisec) { 


    var speed = Math.round(millisec / 100);     

    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 

//    if (isIE())
//    {
        changeOpac(100,imageid);
//    }
//    else
//    {

//     for(i = 0; i <= 100; i++) { 
//        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
//        timer++; 
//     }
//    } 
}

function f_online3_s()
{
                        if (document.getElementById('fio').value=="") 
                        {
                                alert('Укажите ФИО');
                                return false;
                        }
                        else if (document.getElementById('f_age_b').value=="")
                        {
                                alert('Укажите дату Вашего рождения');
                                return false;
                        }
                        else if (!isValidPhone(document.getElementById('tel').value,1))
                        {
                                alert('Укажите контактный номер телефона');
                                return false;
                        }
                        else if (!isValidEmail(document.getElementById('email').value,0))
                        {
                                alert('Укажите контактный E-mail');
                                return false;
                        }
                        else if (document.getElementById('secret').value=="")
                        {
                                alert('Код проверки не указан');
                                return false;
                        }

                        return true;
}

function isValidAge(age)
{
                        var i;
                        i = 0+parseFloat(age);
                        if (isNaN(i)) i=0;
                        if (i<=0||i>=130) return 0;
                        else return 1;

}
