
var prev_popup = "-1";

function Dump(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
          for (var i=0; i<l; i++) s += "  ";
            s += k+": " + Dump(d[k],l+1);
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
    		if (String(d).indexOf ("function") == -1)
        	s += "" + d + "\n";
//        else 
//        	s += "function()\n";
    }
    return s;
}

function popupClose (el) {
	try {
		$("pop" + el).style.display = "none";
		$("t" + el).className = "otstup";
	} catch (e) {}
}
function popupOpen (el) {
	popupClose (prev_popup);
	$("pop" + el).style.display = "block";
	$("t" + el).className = "otstup alfa";
	$("pC" + el).innerHTML = generateBlockOptions(el);
	prev_popup = el;
//	alert (Dump (blocksArr));
}

function setAction( val )
{
	document.forms['sForm'].action = val;
}
function openRubricsWindow(tid) {
	//$("rWin_md").style.display = "block";
	getP ("rWin","/?page=get_rubrics&topic=" + tid + "&ajax", "Рубрики", 400); 
	return false;
}
function openCalendar() {
	var panel = PANEL ("cal", "Загрузка...", "Календарь", 150);
	$("cal_mess_div").innerHTML = panel
	$("calW_content").style.padding = "5px";
	$("calW_content").style.overflow = "hidden";
	$("calW_content").style.width = "140px";
	$("dates_block").className = "box alfa";
	make_cal ("changeCalendar" , "calW_content")
}
function OpenSearchCalendar( wich, handler ) {
	var panel = PANEL (wich, "Загрузка...", "Календарь", 150);
	$(wich + "_mess_div").innerHTML = panel
	$(wich + "W_content").style.padding = "5px";
	$(wich + "W_content").style.overflow = "hidden";
	$(wich + "W_content").style.width = "140px";
	make_cal (handler, wich + "W_content")
}
function cal_onclose () {
	$("cal_mess_div").innerHTML = "";
	$("dates_block").className = "box";
}
function changeCalendar(day,month,year) {
	var d = new Date (year, month-1, day, 23, 59, 59)
	window.location.href = pageURL + "&start=" + Math.round (d.getTime()/1000);
}

function set_search_to( day, month, year )
{
	document.getElementById( 'to_day' ).value   = day;
	document.getElementById( 'to_month' ).value = month;
	document.getElementById( 'to_year' ).value  = year;

	var str = "";
	str += (day < 10 ) ? "0" + day : day;
	str += ".";
	str += (month < 10 ) ? "0" + month : month;
	str += "." + year;

	document.getElementById( 'date_to_displ' ).innerHTML = str;
	closePanel( "scal" );
}

function set_search_from( day, month, year )
{
	document.getElementById( 'from_day' ).value   = day;
	document.getElementById( 'from_month' ).value = month;
	document.getElementById( 'from_year' ).value  = year;

	var str = "";
	str += (day < 10 ) ? "0" + day : day;
	str += ".";
	str += (month < 10 ) ? "0" + month : month;
	str += "." + year;

	document.getElementById( 'date_from_displ' ).innerHTML = str;
	closePanel( "scal" );
}

function clearToDate()
{
	document.getElementById( 'to_day' ).value   = "";
	document.getElementById( 'to_month' ).value = "";
	document.getElementById( 'to_year' ).value  = "";
	document.getElementById( 'date_to_displ' ).innerHTML = "";
}

function clearFromDate()
{
	document.getElementById( 'from_day' ).value   = "";
	document.getElementById( 'from_month' ).value = "";
	document.getElementById( 'from_year' ).value  = "";
	document.getElementById( 'date_from_displ' ).innerHTML = "";
}


