function change_button(id,src)
{
var button=document.getElementById(id);
button.src=src+id+'.png';
//alert(src+'');
document.write(document.body.innerHTML+'<EMBED TYPE="audio/wav" SRC="'+src+'snd.wav" WIDTH=0 HEIGHT=0></EMBED>');
}

function init_clock(path,path1)
{
					var fl = new SWFObject(path, "movie", "151", "151", "6");



					fl.addParam("quality", "high");



					fl.addParam("menu", "false");



					fl.addParam("wmode", "transparent"); <!--параметр отвечающий за прозрачность-->



					fl.addParam("wmode", "opaque"); <!--параметр позволяющий сделать флеш фоном-->


					fl.write("flash");
}

function getElementsByClass(searchClass,node,tag,colapse) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	var i=0;
	var j=0;
	for (i in els) {
		if ( pattern.test(els[i].className)) {
			if((navigator.appName=="Opera"&&i<els.length)||(navigator.appName!="Opera"))
			{
			classElements[j] = els[i];
			j++;
			}
		}
	}
	return classElements;
}


function tree(id,src)
{
var tree=document.getElementById("tree");	
var img=document.getElementById(id);

		var col=getElementsByClass(id,tree);
 				var i=0;
				var r='';
				for(i in col) 
				{
				if(col[i].style.display=='block')
				{
				 col[i].style.display='none';
				 img.src=src+"plus.gif";
				}
				 else
				 if(col[i].style.display=='none')
				 {
				 col[i].style.display='block';
				 img.src=src+"minus.gif";
				 }
				}

	
}



	function DHTMLSound(surl,id,src) {
		document.getElementById(id).src=src+id+'.png';
		if(surl!='')
	  document.getElementById("dummyspan").innerHTML="<embed src='"+surl+"' hidden='true' autostart='true' loop='false' height='0px'></embed>";
	}

function menu_change(surl,id)
{
	document.getElementById(id).style.background="'url("+surl+")'";
	//alert(document.getElementById(id).bgColor);
}

function play(surl)
{
	  document.getElementById("dummyspan").innerHTML="<embed src='"+surl+"' hidden=true autostart=true loop=false>";	
	
}



function addRubriks(href) {
  var PopLeft = (window.screen.width-800)/2;
  var PopTop = (window.screen.height-600)/2;

  nw=window.open(href, 'Rubriks', 'menubar=0,toolbar=0,height=600,width=800,resizable=yes,scrollbars=yes,location=yes');
  nw.moveTo(PopLeft,PopTop);
}


function openCard(container) {
  var PopLeft = (window.screen.width-800)/2;
  var PopTop = (window.screen.height-600)/2;

  nw=window.open('', 'Rubriks', 'menubar=0,toolbar=0,height='+window.screen.height+'width=1024,resizable=yes,scrollbars=yes,location=yes');
  nw.document.body.innerHTML="<center>"+document.getElementById(container).innerHTML+"</center>";
  nw.document.body.style.border='none';
  nw.document.body.style.backgroundColor='#FFFFFF';
  nw.document.body.style.padding='0';
  nw.document.body.style.margin='0';
  nw.moveTo(PopLeft,PopTop);
}

function resp()
{
	var tree=document.getElementById("tree");
	var col=getElementsByClass('rubrics',tree);
	var container=window.opener.document.getElementById('resp');
	var cont= new String(container.innerHTML);
	var delete_button=window.opener.document.getElementById('remove');
	
	for(i in col) 
	{
	 if(col[i].checked==true)
	 {
	  cont=cont+"<li id='d_"+col[i].id+"' ><table cellpadding='0' cellspacing='0' border='0' width='100%' id='tab_"+col[i].id+"'><tr valign='middle'><td><input type='hidden' name='vd_"+col[i].id+"' value='1'/><input type='checkbox' id='"+col[i].id+"' class='remove' name='cb_remove_"+col[i].id+"'  /><a>Удалить</a></td><td width='40%'><a>"+col[i].alt+"</a></td><td><p><input type='checkbox' onclick='match_rubrics(this.checked);' name='cb_"+col[i].id+"_f3'/><a>Розница</a></p><p><input type='checkbox' onclick='match_rubrics(this.checked);' name='cb_"+col[i].id+"_f4'/><a>Опт</a></p><p><input type='checkbox' onclick='match_rubrics(this.checked);' name='cb_"+col[i].id+"_f5'/><a>Производство</a></p></td></tr></table></li>";
	 }
	}
	container.innerHTML=cont;
	
	if(cont!=null)
	delete_button.style.display='block';
	
	window.close();
	
}


function delete_selected()
{
	var tree=document.getElementById("resp");
	var del=getElementsByClass('remove',tree,'INPUT');
	var button=document.getElementById('remove');
	var elsLen = del.length;
	
	var j=0;
	var i=0;
	
	var remove=null;
	for(i in del) 
	{
	 if(del[i].checked==true)
	 {
		if(i<del.length)
			{
		 //alert('d_'+del[i].id);
	   remove=document.getElementById('d_'+del[i].id);
		//remove.innerHTML="";
	  tree.removeChild(remove);
	j++;
			}
	 }
	}

	
	if(j==elsLen)
	button.style.display='none';


}

function match_rubrics(state)
{
var rubr=document.getElementById("rubr");

if(state==false)	
rubr.value=parseInt(rubr.value)-1;
	
if(state==true)	
rubr.value=parseInt(rubr.value)+1;

	
}


function show_form(id)
{
	var form=document.getElementById(id);
	var visible=document.getElementById("vis_"+id);
	
	if(visible.value=='none')
	{
	form.style.display='block';
	visible.value='block';
	}
	else
	{
	form.style.display='none';
	visible.value='none';	
	}
	
}

