﻿function check() {
	if (document.getElementById('v2').value == '') {
		document.getElementById('v2').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не написали сообщение');
	}
	else if (document.getElementById('v3').value == '') {
		document.getElementById('v3').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Введите код подтверждения');
	}
	else return true;
	return false;
}
function check2() {
	if (document.getElementById('v1').value == '') {
		document.getElementById('v1').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали фамилию');
	}
	else if (document.getElementById('v2').value == '') {
		document.getElementById('v2').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали имя');
	}
	else if (document.getElementById('v3').value == '') {
		document.getElementById('v3').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали телефон');
	}
	else return true;
	return false;
}
function check3() {
	if (document.getElementById('v1').value == '') {
		document.getElementById('v1').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали телефон');
	}
	else return true;
	return false;
}
function check4() {
	if (document.getElementById('v1').value == '') {
		document.getElementById('v1').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали имя');
	}
	else if (document.getElementById('v2').value == '') {
		document.getElementById('v2').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали время');
	}
	else if (document.getElementById('v3').value == '') {
		document.getElementById('v3').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Вы не указали телефон');
	}
	else return true;
	return false;
}
function done(id) {
	document.getElementById(id).setAttribute('style', '');
}

function get_http(){
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new
                ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    @else
        xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

/** Ajax **/
function ajax(fileway, select_id, data, value) {
    this.http = get_http();
	this.working = false;
	var url = '/css/inc/ajax/' + fileway + '.php';
	if (!this.working && this.http) {
	   	var http = this.http;
	    url = url + '?';
	    var arr_data = data.split('::');
	    var arr_value = value.split('::');
	    for(i=0; i<arr_data.length; i=i+1) {
        	url = url + arr_data[i] + '=';
        	if(arr_value[i]) url = url + encodeURIComponent(arr_value[i]);
        	url = url + '&';
    	}
		this.http.open("GET", url, true);
	    this.http.onreadystatechange = function() {
			if (http.readyState == 4) {
				fill(select_id, http.responseText);
                this.working = false;
	        }
    	}
        this.working = true;
	    this.http.send(null);
	}
	if(!this.http) {
    	alert('Ошибка при создании XMLHTTP объекта!')
	}
}
function fill (select_id, data) {
	var insert = document.getElementById(select_id);
	insert.innerHTML = data;
}
function page(id) {
	ajax('page', 'drax', 'id::', id+'::');
}
function page_eng(id) {
	ajax('page_eng', 'drax', 'id::', id+'::');
}