FilmLineNum = 0;


//var xmlhttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/

// Инициализация XMLHttpRequest
//

/*
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

*/

var xmlhttp=null;

	if (window.XMLHttpRequest) { 
		//Mozilla
		xmlhttp=new XMLHttpRequest();
	}
	else if (typeof ActiveXObject != "undefined") { 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	


function _request(id,in_production) {
	//add function to ready the upper part for transfer
	get_ready(id);
	if (in_production) {
		xmlhttp.open("GET", "/main_ajax_production?id="+id, true); 
		
	}
	else {
		xmlhttp.open("GET", "/main_ajax?id="+id, true); 
	}
	xmlhttp.onreadystatechange = function() { 
		if (xmlhttp.readyState == 4) {
			document.getElementById('cont').innerHTML = xmlhttp.responseText;
			document.getElementById('cont').className="grey_duble";
			//alert(xmlhttp.responseText);
			//fbtnclick();
		}
	}
	xmlhttp.send(null);
}


function _request_work(id) {
	get_ready(id);
	//xmlhttp.open("GET", "/main_ajax_work?id="+id, true);
	xmlhttp.open("GET", "/main_ajax_production?id="+id, true);
	xmlhttp.onreadystatechange = function() { 
		if (xmlhttp.readyState == 4) {
			document.getElementById('cont').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}


function _request_film_line_5(delta) {
		
	FilmLineNum += delta;
	
	xmlhttp.open("GET", "/main_prod_ajax_5?num=" + FilmLineNum, true);  
	xmlhttp.onreadystatechange = function() { 
		if (xmlhttp.readyState == 4) {
			document.getElementById('cont_film_line').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}




function _request_film_line_10(delta) { //alert(delta);
		
	FilmLineNum += delta;
	
	//alert(FilmLineID);
	//alert(id);
	
	xmlhttp.open("GET", "/main_prod_ajax_10?num=" + FilmLineNum, true);  
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {	//alert(xmlhttp.responseText);
			document.getElementById('cont_film_line').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}


// Для ленты новостей
//
function _request_news_line(delta) {
		
	FilmLineNum += delta;
	
	xmlhttp.open("GET", "/news_prod_ajax?num=" + FilmLineNum, true);  
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			document.getElementById('cont_film_line').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}


// Поиск по букве (нижний)
//
function _search_letter(letter) { 
	// Необходимо определить зачекан ли поиск по Новостям
	var in_news = 0;
	if (document.getElementById('news').checked == true) {
		in_news = 1;
	}
	
	// Для определения поступившей кодировки в скрипте.
	// Ибо по одной букве не хочет понимать.
	//
	var chars = letter + "ыч"; // А почему бы и не 'ыч'?

	if (letter == '*') {
		xmlhttp.open("GET", "/search/?n="+in_news, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				document.getElementById('search_bottom').innerHTML = xmlhttp.responseText;
			}
		}
	}
	else {
		xmlhttp.open("GET", "/search/?l="+letter+"&n="+in_news+"&chars="+chars, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				document.getElementById('search_bottom').innerHTML = xmlhttp.responseText;
			}
		}
	}
	xmlhttp.send(null);
}



// Поиск по букве (правый)
//
function _search_right_letter(letter) { 
	// Необходимо определить зачекан ли поиск по Новостям
	var in_news = 0;
	if (document.getElementById('news_r').checked == true) {
		in_news = 1;
	}
	
	// Для определения поступившей кодировки в скрипте.
	// Ибо по одной букве не хочет понимать.
	//
	var chars = letter + "ыч"; // А почему бы и не 'ыч'?

	if (letter == '*') {
		xmlhttp.open("GET", "/search/?n="+in_news+"&right=1", true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				document.getElementById('search_right').innerHTML = xmlhttp.responseText;
			}
		}
	}
	else {
		xmlhttp.open("GET", "/search/?l="+letter+"&n="+in_news+"&chars="+chars+"&right=1", true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				document.getElementById('search_right').innerHTML = xmlhttp.responseText;
			}
		}
	}
	xmlhttp.send(null);
}


// Поиск по тексту (нижний)
//
function _search_text(word) { 
	var word = window.document.getElementById('search').value;
	
	// Необходимо определить зачекан ли поиск по Новостям
	var in_news = 0;
	if (document.getElementById('news').checked == true) {
		in_news = 1;
	}
	
	xmlhttp.open("GET", "/search?w=" + word +"&n=" + in_news, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			document.getElementById('search_bottom').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}


// Поиск по тексту (правый)
//
function _search_right_text(word) { 
	var word = window.document.getElementById('search_r').value;
	
	// Необходимо определить зачекан ли поиск по Новостям
	var in_news = 0;
	if (document.getElementById('news').checked == true) {
		in_news = 1;
	}
	
	xmlhttp.open("GET", "/search?w=" + word +"&n=" + in_news+"&right=1", true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			document.getElementById('search_right').innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.send(null);
}





function _new_page(page) {
	// Необходимо определить зачекан ли поиск по Новостям
	var in_news = 0;
	if (document.getElementById('right').style.display == 'block') {
		if (document.getElementById('news_r').checked == true) {
			in_news = 1;
		}
	}
	else {
		if (document.getElementById('news').checked == true) {
			in_news = 1;
		}
	}

	// Если сайт широкий, посылаем в скрипт об этом упоминание и html выводим в другое место.
	if (document.getElementById('right').style.display == 'block') {
		xmlhttp.open("GET", "/search_ajax/?p="+page+"&right=1"+"&n="+in_news, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				document.getElementById('search_right').innerHTML = xmlhttp.responseText;
			}
		}
	}
	
	else {
		xmlhttp.open("GET", "/search_ajax/?p="+page+"&n="+in_news, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				document.getElementById('search_bottom').innerHTML = xmlhttp.responseText;
			}
		}
	}
	xmlhttp.send(null);
}




function onenter_search() {
	document.onkeydown = checkKeycode
	function checkKeycode(e) {
		var keycode;
		if (window.event)
			keycode = window.event.keyCode;
		else if (e) keycode = e.which;
			if (keycode == 13) _search_text();
	}
}


function onenter_right_search() {
	document.onkeydown = checkKeycode
	function checkKeycode(e) {
		var keycode;
		if (window.event)
			keycode = window.event.keyCode;
		else if (e) keycode = e.which;
			if (keycode == 13) _search_right_text();
	}
}


function _request_tags_line(tag) {
	
	xmlhttp.open("GET", "/tags_line?tag="+tag, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			document.getElementById('news_tags').innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.send(null);
}
