var cur_lang;
var path;
var param;
var interval;

// Выполняется при загрузке сайта
function loading (lang){
	var start = new Array();
	start["en"] = "News";
	start["ru"] = "Новости";

	cur_lang = lang;
	document.getElementById('top').style.background = ' url(images/width_table' + cur_lang + '.jpg) bottom left no-repeat'; 
	loadA (1, start[cur_lang]);
}

// Загрузка пунктов меню Ajax
//function load_menu(id){
//	lightAjax.send ('script.php', 'mode=' + id + '&lang=' + cur_lang, '#mainvmenu', '', 'GET', 0);
//}

function wait_links (){
	if (document.getElementById ("slider")){
		slider.init('slider', 1);
		clearInterval (interval);
	}
}

function wait_menu (){
	if (lightAjax.response != ""){
		lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
		clearInterval (interval);
	}
}

function loadA (index, name){
	switch (index){
		case 1:{
				path = 'news.php';
				param = 'lang=' + cur_lang;
				lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
		};break;
		case 2:{
				path = 'static/' + cur_lang + '/events.html';
				param = '';
				lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
		};break;
		case 3:{
				path = 'static/' + cur_lang + '/learnvideo.html';
				param = '';
				lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
		};break;	
		
		case 4:{
			path = 'links.php';
			param = '';
			lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
			interval = setInterval ('wait_links()', 100);
			
		};break;
		
		case 5:{
			path = 'static/video.php';
			param = '';
			lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
			interval = setInterval ('wait_links()', 100);
			
		};break;

		case 6:{
			path = 'static/' + cur_lang + '/reports.html';
			param = '';
			lightAjax.send (path, param, '#ccontent', '', 'GET', 0);
		};break;
	}
	document.getElementById ('info_panel').innerHTML = name;
}

// load - загрузка в главную область
function load (index, ChapterIndex, name){
	var sell = new Array();
	sell["en"] = "For sale";
	sell["ru"] = "Продается";
	if (ChapterIndex == 'general'){
		path = 'static/' + cur_lang + '/' + index + '.html';
		param = '';
	}
	else if (ChapterIndex == 'multilang'){
		path = 'static/' + index + '.html';
		param = '';
	}
	else if (ChapterIndex == 'puppies'){
		path = 'static/' + cur_lang + '/' + ChapterIndex + '.php';
		param = 'id=' + index;
	}
	else if (ChapterIndex == 'menu'){
		response = "";
		lightAjax.send ('script.php', 'mode=' + index + '&lang=' + cur_lang, '#mainvmenu', '', 'GET', 0);
		interval = setInterval ('wait_menu()', 100);
		path = 'static/' + cur_lang + '/' + index + '/index.html';
		param = '';
	}
	else
	{
		path = 'static/' + cur_lang + '/' + ChapterIndex +  '/' + index + '.html';
		param = '';
	}
	if (index == "sales") name = sell[cur_lang];

	if (ChapterIndex != 'menu')
		lightAjax.send (path, param, '#ccontent', '', 'GET', 0);

	document.getElementById ('info_panel').innerHTML = name;
	document.getElementById ('navselect').selectedIndex = 0;
}

// новости
function get_news (page){
	lightAjax.send ('news.php', 'page=' + page, '#ccontent', '', 'GET', 0);
}

// поиск
function dosearch (str){
	if (str != '')
	{
		lightAjax.send ('search.php', 'str=' + str, '#ccontent', '', 'GET', 0);
		document.getElementById ('info_panel').innerHTML = document.getElementById ('search').name;
	}
}

// загрузка видео
function get_video (cat_id, img, cat_name){
	lightAjax.send ('static/video.php', 'cat=' + cat_id+'&img='+img, '#ccontent', '', 'GET', 0);
}
