function bg_pos() {
	var stw = $("#main").width();
	var sth = $("#main").height();
	
	cur_y_ratio = sth / 800;
	cur_x_ratio = stw / 1000;
	if(cur_y_ratio > cur_x_ratio) {
		cur_ratio = cur_y_ratio;
	} else {
		cur_ratio = cur_x_ratio;
	}
	
	if (($.browser.msie) && ($.browser.version == "6.0")){
		$('#content_bg').css("height", sth);
		$('#change_bg').css("height", sth);
		$('#change_bg').css("width", stw);
		$('#letter_e').css("height", sth);
		$('#footer').css("top", sth-90);
	} else {
		$("#change_bg").css({"width":1000*cur_ratio, "height":800*cur_ratio, "left":(stw-(1000*cur_ratio))/2, "top":(sth-(800*cur_ratio))/2});
	}
	
	$('#right_menu').css("height", sth-5);
}

function show_flash(params) {
	document.write(params);
}

function getCatalogContent(page_id, el_id ,id,page_number) {
	document.getElementById('ajax').innerHTML = '<img src="/images/loading.gif">';
	JsHttpRequest.query(
		'/ajaxc/geturl/' + page_id + '/' + el_id + '/' + id + '/' + page_number + '/',
		null,
		function (result,errors) {
			document.getElementById('ajax').innerHTML = errors;
			bg_pos();
		},
		true
	);
}

function catalogPage(url) {
   url1 = url.split('/');
   getCatalogContent(url1[0],url1[1],url1[2],url1[3]);
}

function geturl2(id, nav){
	document.getElementById('ajax').innerHTML = '<img src="/images/loading.gif">';
	JsHttpRequest.query(
		'/ajaxc/geturl2/' + id + '/' + nav + '/',
		null,
		function (result,errors) {
			document.getElementById('ajax').innerHTML = errors;
			try {document.getElementById('pitem_'+current_item).className = '';} catch (e) { }
			document.getElementById('pitem_'+id).className = 'top_selected';
			current_item = id;
			bg_pos();
		},
		true
	);
}

function geturl2s(){
	id = document.getElementById('cities').value;
	if (id == 0) return;
	document.getElementById('ajax').innerHTML = '<img src="/images/loading.gif">';
	JsHttpRequest.query(
		'/ajaxc/geturl2/' + id + '/city/',
		null,
		function (result,errors) {
			document.getElementById('ajax').innerHTML = errors;
			try {document.getElementById('pitem_'+current_item).className = '';} catch (e) { }
			bg_pos();
		},
		true
	);
}

var current_item = 0;
