var flip_comm = 0;
	var flip_all = 0;
function initRoll() {
	var obj = document.getElementById("maincol");
	if (obj)
	{
		makeRoll(obj);
	}
	
	if(document.getElementById("post_info_user")) {
		$("#post_info_user").click ( function() {	
			$("#posts").toggle( flip_all++ % 2 == 0 );
		id = "#post_info_user";
		if($(id).html() == '<img src="/img/plus.gif" border="0">')
			$(id).html('<img src="/img/minus.gif" border="0">');
		else
			$(id).html('<img src="/img/plus.gif" border="0">');
			
	});
		$("#comment_info_user").click ( function() {	
			$("#comms").toggle( flip_comm++ % 2 == 0 );
		id = "#comment_info_user";
		if($(id).html() == '<img src="/img/plus.gif" border="0">')
			$(id).html('<img src="/img/minus.gif" border="0">');
		else
			$(id).html('<img src="/img/plus.gif" border="0">');
			
	});

		//link_id = "#comment_info_user";
	}
}

var _oroll = [];

function makeRoll(_obj) {
	var blocks = _obj.getElementsByTagName("div");
	for (i = 0; i < blocks.length; i++)
	{
		if (blocks[i].className.indexOf("roll-head") != -1)
		{
			var links = blocks[i].getElementsByTagName("a");

				for (var k=0; k<links.length; k++) {
					
					if (links[k].className.indexOf("but") != -1) {

						_oroll.push(links[k]);
							links[k].states = new Array();
							links[k].states[0] = document.getElementById('sv').innerHTML;
							links[k].states[1] = document.getElementById('razv').innerHTML;
							
							if (links[k].states.length > 1)
							{
								if ( links[k].parentNode.parentNode.parentNode.className.indexOf("close") != -1 ) 
								{
									links[k].innerHTML = links[k].states[1];
									if(links[k].parentNode.parentNode.parentNode.getElementsByTagName('span') != null){
										if(links[k].parentNode.parentNode.parentNode.getElementsByTagName('span')['min_ban'] != null)
										links[k].parentNode.parentNode.parentNode.getElementsByTagName('span')['min_ban'].style.display = 'block';				
											}										
								}
								else
								{
									links[k].innerHTML = links[k].states[0];
								}
							}

						links[k].onclick = function()
						{
							if ( this.parentNode.parentNode.parentNode.className.indexOf("close") != -1 ) 
									{
										
										for (i = 0; i < _oroll.length; i ++)
										{
											if (_oroll[i].states.length > 1)
											{
												_oroll[i].innerHTML = _oroll[i].states[0];
											}
											if (_oroll[i].parentNode.parentNode.parentNode.className.indexOf("close") == -1)
											{
												_oroll[i].parentNode.parentNode.parentNode.className += " close";
											}
										}
										
										this.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.parentNode.className.replace(" close", "");
											if (this.states.length > 1)
											{
												this.innerHTML = this.states[0];
												$.post(document.location.href, {svernut:0});
											if(this.parentNode.parentNode.parentNode.getElementsByTagName('span') != null){
												if(this.parentNode.parentNode.parentNode.getElementsByTagName('span')['min_ban'] != null)
												this.parentNode.parentNode.parentNode.getElementsByTagName('span')['min_ban'].style.display = 'none';				
											}													
											}
										
									}
									else
									{
										this.parentNode.parentNode.parentNode.className += " close";
										if (this.states.length >= 1)
										{
											this.innerHTML = this.states[1];
											$.post(document.location.href, {svernut:1});
											if(this.parentNode.parentNode.parentNode.getElementsByTagName('span') != null){
												if(this.parentNode.parentNode.parentNode.getElementsByTagName('span')['min_ban'] != null)
												this.parentNode.parentNode.parentNode.getElementsByTagName('span')['min_ban'].style.display = 'block';				
											}	
												
											//this.innerHTML = 'Развернуть';
										}
									}

							
							return false;
						}
				}
			}
		}
	}
}

if (window.addEventListener){
	window.addEventListener("load", initRoll, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", initRoll);
}


function showLoginForm() {
	with (document.getElementById('opacityDiv').style) {
		if (display != 'block')
			display = 'block';
		else
			display = 'none';
	}
	with (document.getElementById('enterDiv').style) {
		if (display != 'block')
			display = 'block';
		else
			display = 'none';
	}	
}

function showElement(element) {
	with (document.getElementById(element).style) {
		if (display != 'none')
			display = 'none';
		else
			display = 'block';
	}
}

function showCloser() {
	with (document.getElementById('advert_block').style) {
		if (display != 'none') {
			display = 'none';
			document.getElementById('closer').innerHTML = 'Развернуть';
		} else {
			display = 'block';
			document.getElementById('closer').innerHTML = 'Свернуть';
		}
	}
}

function showPhotoForm() {
	with (document.getElementById('opacityDiv').style) {
		if (display != 'block')
			display = 'block';
		else
			display = 'none';
	}
	with (document.getElementById('photoDiv').style) {
		if (display != 'block')
			display = 'block';
		else
			display = 'none';
	}	
}

function showSaveForm() {
	with (document.getElementById('opacityDiv').style) {
		if (display != 'block')
			display = 'block';
		else
			display = 'none';
	}
	with (document.getElementById('saveDiv').style) {
		if (display != 'block')
			display = 'block';
		else
			display = 'none';
	}	
	if(document.getElementById('saveDiv').style.display == "block"){
		 setTimeout("showSaveForm()",2000);

	}
}