

// перерисовка страницы - чтобы браузеры не перло при динамическом изменении контента

function reloadPage() {

	document.body.style.display="inline";

	document.body.style.display="block";
	
	var h = jQuery('#wrap').height();
	if (h <= jQuery('body').height()) {
		h = jQuery('body').height();
	}
	jQuery("#shadow").height(h);

//	Object.style.zIndex=32;

}

jQuery(document).ready(function() {
	jQuery( "#slider" ).accessNews({
		speed : "normal",
		slideBy : 2
	});
});

// выбор страниц для отображения

function selectPage(current) {

	if (current.parentNode.className!="active") {

		var pos = current.href.lastIndexOf("#");

		where=current.href.slice(pos+1);

		where = document.getElementById(where);



		var nav = current.parentNode.parentNode.getElementsByTagName('li');

		for(var i=0; i<nav.length; i++) nav[i].className="";

		current.parentNode.className="active";



		nav = document.getElementById("parameters").getElementsByTagName('div');

		for(var i=0; i<nav.length; i++) {

			var navClass=nav[i].className;

			if (nav[i]==where) where.className+=" on";

			if (navClass.indexOf("object-page")!=-1) if(navClass.indexOf("on")!=-1) nav[i].className=navClass.replace("on", "");

		}

		reloadPage();

	}

	return false;

}





// выбор страниц для отображения

function selectPage1(current) {

	if (current.parentNode.className!="active") {

		var pos = current.href.lastIndexOf("#");

		where=current.href.slice(pos+1);

		where = document.getElementById(where);



		var nav = current.parentNode.parentNode.getElementsByTagName('li');

		for(var i=0; i<nav.length; i++) nav[i].className="";

		current.parentNode.className="active";



		nav = document.getElementById("parameters-model").getElementsByTagName('div');

		for(var i=0; i<nav.length; i++) {

			var navClass=nav[i].className;

			if (nav[i]==where) where.className+=" on";

			if (navClass.indexOf("object-page")!=-1) if(navClass.indexOf("on")!=-1) nav[i].className=navClass.replace("on", "");

		}

		reloadPage();

	}

	return false;

}

jQuery(document).ready(function() {
	var h = jQuery('#wrap').height();
	if (h <= jQuery('body').height()) {
		h = jQuery('body').height();
	}
	jQuery("#shadow").height(h);
});

jQuery(document).ready(function() {
  jQuery( "#tags-show" ).click(function() {
    if (jQuery(this).hasClass('opened')) {
      jQuery('.cloud .tag-hidden').hide();
      jQuery(this).text('Все темы');
    } else {
      jQuery('.cloud .tag-hidden').show();
      jQuery(this).text('Популярные темы');
    }
    jQuery(this).toggleClass('opened');
    return false;
  });
}); 

function showPopup(id,class_name) {


    if (id==0) {var sec_id=$('r_op').value;}



	var req = new JsHttpRequest();

	req.open(null, '/js/_ajax/popup.php', true);

	data = { id: id, class_name: class_name, sec_id: sec_id }

	req.send(data);

	req.onreadystatechange = function() {

		if (req.readyState == 4) {

			opened = $('opened_popup');

			if (id>0)
			if (opened!=null && opened.value > 0) {

				$('showpopup_'+opened.value).style.display = 'none';

				$('showpopup_'+opened.value).innerHTML = '';

			}

			opened.value = id;
			$('showpopup'+(id>0 ? '_'+id : '')).innerHTML = req.responseJS.html;

			$('showpopup'+(id>0 ? '_'+id : '')).style.display = 'block';

			//$('opened_popup').value = id;

		}

	}


 	





	/*

	var new_height = document.getElementById(who).offsetHeight;

	var new_width = document.getElementById(who).offsetWidth;

	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;

	document.getElementById(who).style.top = (parseInt(top,10)+(document.body.clientHeight/2)-(new_height/2)-500)+'px';

   	document.getElementById(who).style.left = ((document.body.clientWidth/2)-(new_width/2)-400)+'px';

	document.getElementById(who).style.display = "block";



	return false;

	*/

}

/*

showPopup2 = function(who, id) {

	var new_height = document.getElementById(who).offsetHeight;

	var new_width = document.getElementById(who).offsetWidth;

	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;

	document.getElementById(who).style.top = (parseInt(top,10)+(document.body.clientHeight/2)-(new_height/2)-500)+'px';

   	document.getElementById(who).style.left = ((document.body.clientWidth/2)-(new_width/2)-400)+'px';

	document.getElementById(who).style.display = "block";

	$('answer').value = id;

	return false;

}

*/

closePopup = function(who) {

	$(who).style.display = "none";

	return false;

}

function set_op(id) {
	$('r_op').value=id;
}



