function up(id){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;pos_from=p_in_l[id];if(pos_from==1){return}onImgs();id_to=l_in_p[pos_from-1];p_in_l[id_to]=pos_from;p_in_l[id]=pos_from-1;l_in_p[pos_from-1]=id;l_in_p[pos_from]=id_to;var arg1=eval("document.getElementById('row_"+id_to+"')");var arg2=eval("document.getElementById('row_"+id+"')");if(arg1!=null&&arg2!=null){arg1.swapNode(arg2)}offImgs();return true}function down(id){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;pos_from=p_in_l[id];if(pos_from==last_pos){return}onImgs();id_to=l_in_p[pos_from+1];p_in_l[id_to]=pos_from;p_in_l[id]=pos_from+1;l_in_p[pos_from+1]=id;l_in_p[pos_from]=id_to;var arg1=eval("document.getElementById('row_"+id_to+"')");var arg2=eval("document.getElementById('row_"+id+"')");if(arg1!=null&&arg2!=null){arg1.swapNode(arg2)}offImgs();return true}function remove(id){if(confirm("Вы действительно хотите удалить этот пункт меню?")){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;y=p_in_l[id];while(y<last_pos){down(l_in_p[y]);y++}var remove_elm=eval("document.getElementById('row_"+id+"')");if(remove_elm!=null){IdRow=document.getElementById("rm_menu_id");IdRow.value=id+";"+IdRow.value;remove_elm.removeNode(true);l_in_p.pop();p_in_l[id]=null;val[id]=null;offImgs()}}return true}function onImgs(){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;if(l_in_p[1]!=null){var img=eval("document.getElementById('up_img_"+l_in_p[1]+"')");img.src=img_up_url;img.style.cursor="hand"}if(l_in_p[last_pos]!=null){var img=eval("document.getElementById('down_img_"+l_in_p[last_pos]+"')");img.src=img_down_url;img.style.cursor="hand"}return true}function offImgs(){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;if(l_in_p[1]!=null){var img=eval("document.getElementById('up_img_"+l_in_p[1]+"')");img.src=img_up_na_url;img.style.cursor=""}if(l_in_p[last_pos]!=null){var img=eval("document.getElementById('down_img_"+l_in_p[last_pos]+"')");img.src=img_down_na_url;img.style.cursor=""}return true}function addElement(){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;onImgs();var a=document.myForm.page_id.selectedIndex;id=document.myForm.page_id.options[a].value;if(id==0||id==""){alert("Выберите страницу");return false}else{if(p_in_l[id]!=null){alert("Эта страница уже добавлена в меню");return false}}title=document.myForm.page_id.options[a].text;new_elm_id=id;last_pos=last_pos+1;l_in_p[last_pos]=new_elm_id;p_in_l[new_elm_id]=last_pos;val[new_elm_id]=title;drawElement(last_pos);offImgs();return true}function drawBlock(){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;for(i=1;i<l_in_p.length;i++){if(l_in_p[i]&&l_in_p[i]>max_id){max_id=l_in_p[i]}drawElement(i)}offImgs()}function drawElement(d){var h=l_in_p[d];var c="row_"+h;var f="img_"+h;var a='<img src="'+img_remove_url+'" alt="Удалить" title="Удалить" border="0" vspace="1" hspace="1" align="absmiddle" onClick="remove('+h+');" style="cursor:hand";>';var e='<img src="'+img_up_url+'" alt="Вверх" title="Вверх" border="0" vspace="1" hspace="1" align="absmiddle" id="up_'+f+'" onClick="up('+h+');" style="cursor:hand";>';var g='<img src="'+img_down_url+'" alt="Вниз" title="Вниз" border="0" vspace="1" hspace="1" align="absmiddle" id="down_'+f+'" onClick="down('+h+');" style="cursor:hand";>';var b='<div id="'+c+'"><table cellpadding="0" cellspacing="1" width="100%"><tr><td width="98%" class="tableheader3"><input type="hidden" name="items[]" value="'+h+'">'+val[h]+'</td><td class="tableheader3">'+e+g+a+"</td></tr></table></div>";document.all.items.innerHTML=document.all.items.innerHTML+b;return true}function showList(){last_pos=(l_in_p.length==0)?0:l_in_p.length-1;var a="";for(i=1;i<=last_pos;i++){a=a+" место="+p_in_l[l_in_p[i]]+" ид="+l_in_p[i]+" значение="+val[l_in_p[i]]+"\n"}if(a){alert(a)}return true};
