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 rate(value,goods) {
	this.http = get_http();
	this.working = false;
	var url = 'inc/rate.php?id='+value+'&g='+goods;
	if (!this.working && this.http) {
	   	var http = this.http;
    	this.http.open("GET", url, true);
	    this.http.onreadystatechange = function() {
			if (http.readyState == 4) {
        	   	fill(http.responseText,goods);
                this.working = false;
	        }
    	}
        this.working = true;
	    this.http.send(null);
	}
	if(!this.http) {
    	alert('Ошибка при создании XMLHTTP объекта!')
	}
}
function fill (data,goods) {
	var insert = document.getElementById('rating'+goods);
	insert.innerHTML = data;
}
function comment() {
	if (document.getElementById("r1").value == '') {
		document.getElementById("r1").setAttribute('style', 'background-color:#fff0f0; border:1px solid red');
		return false;
	}
    if (document.getElementById("r2").value == '') {
    	document.getElementById("r2").setAttribute('style', 'background-color:#fff0f0; border:1px solid red');
    	return false;
	}
    if (document.getElementById("r3").value != 5) {
    	document.getElementById("r3").setAttribute('style', 'background-color:#fff0f0; border:1px solid red');
    	return false;
	}
	return true;
}

function check_1() {
	if (document.getElementById('r1').value == '') {
		document.getElementById('r1').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваше имя');
	}
	else if (document.getElementById('r2').value == '') {
		document.getElementById('r2').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваш контактный телефон');
	}
	else if (document.getElementById('r3').value == '') {
		document.getElementById('r3').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваш контакный e-mail');
	}
	else if (document.getElementById('r4').value == '') {
		document.getElementById('r4').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите адрес доставки');
	}
	else return true;
	return false;
}
function check_2() {
	if (document.getElementById('r1').value == '') {
		document.getElementById('r1').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваш email');
	}
	else if (document.getElementById('r2').value == '') {
		document.getElementById('r2').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Введите пароль');
	}
	else if (document.getElementById('r3').value == '') {
		document.getElementById('r3').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Повторите пароль');
	}
	else if (document.getElementById('r4').value == '') {
		document.getElementById('r4').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваше имя');
	}
	else if (document.getElementById('r5').value == '') {
		document.getElementById('r5').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваш телефон');
	}
	else if (document.getElementById('r6').value == '') {
		document.getElementById('r6').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите адрес доставки');
	}
	else return true;
	return false;
}
function check_4() {
	if (document.getElementById('r1').value == '') {
		document.getElementById('r1').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите название вашей фирмы');
	}
	else if (document.getElementById('r2').value == '') {
		document.getElementById('r2').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваше имя');
	}
	else if (document.getElementById('r3').value == '') {
		document.getElementById('r3').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваш контакный e-mail');
	}
	else if (document.getElementById('r4').value == '') {
		document.getElementById('r4').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ваш контактный телефон');
	}
	else if (document.getElementById('r5').value == '') {
		document.getElementById('r5').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите Юр. адрес вашей фирмы');
	}
	else if (document.getElementById('r6').value == '') {
		document.getElementById('r6').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите ИНН');
	}
	else if (document.getElementById('r7').value == '') {
		document.getElementById('r7').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите КПП');
	}
	else if (document.getElementById('r8').value == '') {
		document.getElementById('r8').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите р/сч');
	}
	else if (document.getElementById('r9').value == '') {
		document.getElementById('r9').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите к/сч');
	}
	else if (document.getElementById('r10').value == '') {
		document.getElementById('r10').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите БИК');
	}
	else if (document.getElementById('r11').value == '') {
		document.getElementById('r11').setAttribute('style', 'border:1px solid red; background-color:#ffebeb');
		alert('Укажите адрес доставки');
	}
	else return true;
	return false;
}
