function hideMessage(div_id)
{
    if (div_id==null) div_id='tmp';  
   with (document.getElementById('message'))
   {
        min_opacity(div_id);
       
   }
}

function add_opacity(div_id)
{
    
   with (document.getElementById('message'))
   {
   //alert(div_id);
        opacity += 5;
        
        style.width = 55*(opacity/5);
        style.left -= 28;
        if (opacity==75) {
            innerHTML = document.getElementById(div_id).innerHTML;
            document.getElementById(div_id).innerHTML='';
        }
        if (opacity<85) {
            fun2run="add_opacity('"+div_id+"')"; 
            //alert (fun2run); 
            setTimeout(fun2run, 10);    
        }
        else {
            style.left  = screen.width/2-479;
            opacity=95;
        }
   }
}

function min_opacity(div_id)
{        
   with (document.getElementById('message'))
   {
        opacity -= 5;
        style.width = 55*(opacity/5);
        style.left += 25;
        if (opacity==75) {
            document.getElementById(div_id).innerHTML=innerHTML;
            innerHTML = '';
                 
        }
        if (opacity>0) {
            fun2run="min_opacity('"+div_id+"')"; 
            //alert (fun2run); 
            setTimeout(fun2run, 10);    
        }
        else style.visibility = "hidden";     
        
   }
}

function createMessage(text, color, time_to_show, div_id)
{
    //alert(div_id);
    if (div_id==null) div_id='tmp';
    //alert(div_id);
    with(document.getElementById('message'))
    {
        style.visibility = "visible";
        opacity = 0;
        style.height=480;
        //alert(opacity);
        style.left = screen.width/2-479;
        add_opacity(div_id);
    }
    
    //alert(document.getElementById('message').opacity);  
}

function checkform() {

if ( (document.form.tel.value=='Введите Ваш телефон') && (document.form.mail.value=='Введите Ваш e-mail') ) {
    alert('Укажите пожалуйста Ваш телефон или e-mail по которому с Вами можно будет связаться.');
    return false;
}


p_sender = document.form.tel.value.toString();
if(p_sender != "") { 
    if(p_sender.length<7 ) {
        alert ("В номере телефона менее 7 символов (возможно Вы не указали код города).");
        document.form.tel.focus();
        return false;
    }
    
    digits="0123456789"
    digs=0;
    for(i=0; i<p_sender.length; i++){
        if (digits.indexOf(p_sender.charAt(i))<0){
            //alert(digs);
        }
        else {
            digs++;
            //alert(digs);
        }
    }
    if (digs<7) {
        alert ("В номере телефона менее 7 цифр (возможно Вы не указали код города).");
        document.form.tel.focus();
        return false;
    }
    
    
} else { 
    alert("Необходимо ввести телефон!");
    document.form.tel.focus();
    return false;
}

p_email = document.form.mail.value.toString();
if ((p_email != "") && (p_email!='Введите Ваш e-mail')) {
    t = p_email.indexOf("@");
    if((p_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > p_email.length - 5) || (p_email.charAt(t - 1) == '.') || (p_email.charAt(t + 1) == '.')) {
        alert("Некорректно указан E-mail !");
        document.form.mail.focus();
        return false;
    }
}

if (p_email=='Введите Ваш e-mail') document.form.mail.value='не указан'; 
if (p_sender=='Введите Ваш телефон') document.form.tel.value='не указан'; 

return true;

}

function change_img(img, source){

//alert (document.getElementById(img).src);
document.getElementById(img).src=source;
//alert (document.getElementById(img).src);

}

function setfilter100(){
    document.getElementById('message').opacity=100;
}

function create_info(w ,h)
{

if (document.getElementById('tmp').style.visibility == "visible"){
    document.getElementById('tmp').style.visibility = "hidden";
}
else{    
    with(document.getElementById('tmp'))
    {
        if ((h > 1023) && (w > 1279)) {
            style.left = 410; 
            style.top = 221;
        }
        else if ((h < 1023) && (w > 1279)) {
            style.left = 400; 
            style.top = 147;                 
        }
        else {
            style.left = 190; 
            style.top = 149;                 
        }
        style.visibility = "visible";
        style.width=203;
        style.height=406;
    }
}
}

function hide_info()
{
    with(document.getElementById('tmp'))
    {
        style.visibility = "hidden";
    }
}
