
arg = false;
function addCommentForm(){
	if(arg == false){
		arg = "show";
	}else{
		arg = "hide";
	}
	
	switch(arg){
	case "show":
		document.getElementById("coment_form").style.display = 'inline';
		break;
	
	case "hide":
		document.getElementById("coment_form").style.display = 'none';
		arg = false;
		break;
		
	}
}

function random_color(){
	var COLORS = Array("#fff2e1","#ffe1e1","#e1ffe2","#e1ffff","#e3e1ff","#ffe1f1","#ffe1e1");
	//alert(Math.floor(Math.random()*COLORS.length+1))
	var rand = Math.floor(Math.random()*COLORS.length);
	return COLORS[rand];
}


function submitComment(){
 
		re=/^[\w\.\-]+\@[\w\.\-]+/;
		if(document.comm.comment_name.value == "" || document.comm.comment_text.value == "")
		{
			alert("Ну написать то что-то нужно то!");
			return false;
		}

		document.comm.action="/misc/add_comment.php";
		document.comm.submit();
}

function toMenu(el)
{
	document.getElementById("submenu").innerHTML = document.getElementById(el).innerHTML;
}


function setSelectedValue(srcListName, value) {
	//var srcList = document.all[srcListName];
	var srcList = document.getElementById(srcListName);
	if (srcList) {
		var srcLen = srcList.length;

		for (var i=0; i<srcLen; i++) 
		{
			srcList.options[i].selected = false;
			if (srcList.options[i].value == value) 
			{
				srcList.options[i].selected = true;
			}
		}
	}
}

function doHiddenLinks(){
	//$(".hidden-text-link").attr("onclick","$('#"+$(".hidden-text-link").attr("id")+"-text').slideToggle(); return false;");
	$(".hidden-text-link").each(function(){

		var text_id = $(this).attr("id") + "-text";
		this.onclick = function(){
				$("#"+text_id).slideToggle(); 
				return false;
			}
			
	});
}

$(document).ready(function(){
	doHiddenLinks();
});