var flagOK = false;
var closed_flag = true;
var film_id = '';
var this_num = '';
var closeCancel = '';
function idnumSet(id, number) {
	film_id = id;
	this_num = number;
}
function closeHint() {
	if (closeCancel !== true) {
		document.getElementById('hintBox').style.display = 'none';
		closed_flag = true;
	}
}
function makeClosed(value) {
	if (value == 1) closed_flag = false;
	else closed_flag = true;
}
function makeRequest(film_id, num) {
	var hint_id = 'hintBox';
	document.getElementById(hint_id).innerHTML = '';
        var hint_url = 'http://www.romanov-cinema.ru/film_detail.php?FILM_ID='+film_id;
	document.getElementById(hint_id).innerHTML = '<div style="width:435px; text-align:center !important; margin:0 auto; padding:80px 0 ;"><h3>Загрузка</h3><img src="/bitrix/templates/romanov/i/ajax-loader.gif" alt="Загрузка"></div>';
	document.getElementById(hint_id).style.display = 'block';
	if (num == 0) document.getElementById(hint_id).className = 'hintBox preDetailBox FilmBox1';
	else if (num == 1) document.getElementById(hint_id).className = 'hintBox preDetailBox FilmBox2';
	else if (num == 2) document.getElementById(hint_id).className = 'hintBox preDetailBox FilmBox3';
	else if (num == 3) document.getElementById(hint_id).className = 'hintBox preDetailBox FilmBox4';
	else if (num == 4) document.getElementById(hint_id).className = 'hintBox preDetailBox FilmBox5';
	else document.getElementById(hint_id).className = 'hintBox preDetailBox FilmBox5';
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Не вышло  Невозможно создать экземпляр класса XMLHTTP ');
		return false;
	}
	http_request.onreadystatechange = function() { contentAction(http_request, hint_id); };
	http_request.open('GET', hint_url, true);
	http_request.send(null);
	var old_id = film_id;
}
	
function contentAction(http_request, hint_id) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(hint_id).innerHTML = http_request.responseText;
			closed_flag = false;
		} else {
			document.getElementById(hint_id).style.display = 'none';
			closed_flag = true;
		}
	}
}
function flagSet(flag) {
	if (flag == true) flagOK = true;
	else flagOK = false;
}
function check(id, number) {
	if (flagOK == true) {
		makeRequest(film_id, this_num);
		flagOK = false;
		clearTimeout(tempVar);
	} else {		
	}
}
function showWindow(id, number) {
	idnumSet(id, number);
	if (closed_flag == true) {
		tempVar = setTimeout(check, 1000)
	}
}
