function chb(src,bg){ src.style.backgroundImage='url(/files/extern/'+bg+')'; } function chs(obj,img){ obj.src='/files/extern/'+img; } function showmbox(id){ var box=document.getElementById('mbox'+id); var plus=document.getElementById('plus'+id); if(box.style.display=='none'){ box.style.display=''; plus.src='/files/extern/mines.png'; } else { box.style.display='none'; plus.src='/files/extern/plus.png'; } } // возвращает cookie если есть или undefined function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )) return matches ? decodeURIComponent(matches[1]) : undefined } // уcтанавливает cookie function setCookie(name, value, props) { props = props || {} var exp = props.expires if (typeof exp == "number" && exp) { var d = new Date() d.setTime(d.getTime() + exp*1000) exp = props.expires = d } if(exp && exp.toUTCString) { props.expires = exp.toUTCString() } value = encodeURIComponent(value) var updatedCookie = name + "=" + value for(var propName in props){ updatedCookie += "; " + propName var propValue = props[propName] if(propValue !== true){ updatedCookie += "=" + propValue } } document.cookie = updatedCookie } // удаляет cookie function deleteCookie(name) { setCookie(name, null, { expires: -1 }) } /*function setCookie(name, value, expires, path, domain, secure) { document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); }*/ function hidePanel(type){ if(type=='top'){ panel=document.getElementById('toppanel'); icon=document.getElementById('toparrow'); if(panel.style.display==''){ panel.style.display='none'; icon.src='/files/extern/down.png'; setCookie('toppanel','hidden'); } else { panel.style.display=''; icon.src='/files/extern/up.png'; setCookie('toppanel',''); } } if(type=='left'){ panel=document.getElementById('leftpanel'); icon=document.getElementById('leftarrow'); if(panel.style.display==''){ panel.style.display='none'; icon.src='/files/extern/right.png'; setCookie('leftpanel','hidden'); } else { panel.style.display=''; icon.src='/files/extern/left.png'; setCookie('leftpanel',''); } reposition(); } } inArray = Array.prototype.indexOf ? function (arr, val) { return arr.indexOf(val) != -1 } : function (arr, val) { var i = arr.length while (i--) { if (a[i] === val) return true } return false } function rgbToHex(R,G,B) { return toHex(R)+toHex(G)+toHex(B); } function toHex(n) { n = parseInt(n,10); if (isNaN(n)) return "00"; n = Math.max(0,Math.min(n,255)); return "0123456789ABCDEF".charAt((n-n%16)/16) + "0123456789ABCDEF".charAt(n%16); } var curcoli=0; var tcolors=Array('DBF3FF','FFFEDB','FEDBFF','DEFFDB',/*'FFE5DB',*/'EFDBFF','DBE3FF','FFECDB','FFDBEA','EFFFDB'); function getrndcolor(min,max,fix){ if(fix==1){ res='#'+tcolors[curcoli]; curcoli++; if (curcoli>tcolors.length) curcoli=0; return res; } var r=Math.floor((Math.random()*(max-min)))+min; var g=Math.floor((Math.random()*(max-min)))+min; var b=Math.floor((Math.random()*(max-min)))+min; return '#'+rgbToHex(r,g,b); } var drag=false; var dodrag=true; function jsmo(obj){ if(obj.parentNode.id=='kurs') return; if(drag)return; var aleft=document.getElementById(obj.id+'al'); var aright=document.getElementById(obj.id+'ar'); var pos=seekRowCol(obj.parentNode.id); //if(pos.col>1 && (tbls[pos.row]==null || tbls[pos.row][pos.col-1]==null || tbls[pos.row][pos.col-1]=='')) aleft.style.display=''; /*if(pos.col<10 && (tbls[pos.row]==null || tbls[pos.row][pos.col+1]==null || tbls[pos.row][pos.col+1]==''))*/ aright.style.display=''; //var pos=getOffset(obj); aleft.style.left=/*pos.left-*/-7; aleft.style.top=/*pos.top+*/1; aleft.style.zIndex=2000; var bw=108; bw=obj.offsetWidth; bh=obj.offsetHeight; aright.style.left=/*pos.left+*/bw-Math.round(bw/2)-11; aright.style.top=/*pos.top+*/bh-8; aright.style.zIndex=2000; } function jsmo2(obj){ var aleft=document.getElementById(obj.id+'al'); var aright=document.getElementById(obj.id+'ar'); aleft.style.display='none'; aright.style.display='none'; } function jsmm(obj,type){ dodrag=false; if(type==1) obj.src='/files/extern/aright2.png'; if(type==2) obj.src='/files/extern/aleft2.png'; } function jsmm2(obj,type){ dodrag=true; if(type==1) obj.src='/files/extern/aright.png'; if(type==2) obj.src='/files/extern/aleft.png'; } var adirection=0; aobj=0; ax=0; astartAt=0; mask=0; atype=0; aleft=0; function jsmm3(obj,type){//type 1-right, 2-left var block=obj.parentNode; adirection=type; aobj=obj; aleft=block.offsetLeft; e=fixEvent(e); ax=e.pageX; if(block.parentNode.id=='d1') var row=1; if(block.parentNode.id=='d2') var row=2; atype=type; if(type==1){ astartAt=1; for(i=1;i<=20;i++) if(tbls[row]!=null && tbls[row][i]==block.id){astartAt=i;break;} } else { astartAt=10; for(i=20;i>=1;i--) if(tbls[row]!=null && tbls[row][i]==block.id){astartAt=i;break;} } //mask=document.getElementById('mask'); //mask.style.display=''; document.onmousemove = jsmm5; document.ondragstart = document.body.onselectstart = function() {return false} document.onmouseup = jsmm4; } function jsmm4(e){ document.onmousemove = document.onmouseup = document.ondragstart = document.body.onselectstart = null //document.getElementById('mask').style.display='none'; } function jsmm5(e){ e = fixEvent(e) var block=aobj.parentNode; jsmo(aobj.parentNode); if(block.parentNode.id=='d1') var row=1; if(block.parentNode.id=='d2') var row=2; if(atype==1){//сдвиг вправо xoffset=Math.floor(22/3*2); var npos=seekRowCol(block.parentNode.id); var nx=npos.col-astartAt; } if(atype==2){//сдвиг влево xoffset=-Math.floor(22/3*2); var npos=seekRowCol(block.parentNode.id); var nx=astartAt-npos.col; } xoffset=0; if(nx>3) nx=3; if(nx>0){ for(i=1;i<=20;i++) if(tbls[row][i]==block.id) tbls[row][i]=''; tbls[row][astartAt]=block.id; if(atype==1){ if(nx>1 && tbls[row][astartAt+1]!='' && tbls[row][astartAt+1]!=null && tbls[row][astartAt+1]!=block.id) nx=1; if(nx>2 && tbls[row][astartAt+2]!='' && tbls[row][astartAt+2]!=null && tbls[row][astartAt+2]!=block.id) nx=2; if(astartAt==20 && nx>1) nx=1; if(astartAt==19 && nx>2) nx=2; if(nx>=2) tbls[row][astartAt+1]=block.id; if(nx>=3) tbls[row][astartAt+2]=block.id; } if(atype==2){ if(nx>1 && tbls[row][astartAt-1]!='' && tbls[row][astartAt-1]!=null && tbls[row][astartAt-1]!=block.id) nx=1; if(nx>2 && tbls[row][astartAt-2]!='' && tbls[row][astartAt-2]!=null && tbls[row][astartAt-2]!=block.id) nx=2; if(astartAt==1 && nx>1) nx=1; if(astartAt==2 && nx>2) nx=2; if(nx>=2) tbls[row][astartAt-1]=block.id; if(nx>=3) tbls[row][astartAt-2]=block.id; } var wb=0; var left=0; var xx=14; var ie='\v'=='v'; if(ie)xx=xx+10; var yy=8; var pad=3; if(nx==1) wb=xx; if(nx==2){ wb=xx*2+4; left=-xx-4; pad=xx+3-4;} if(nx==3){ wb=xx*3+yy*2; left=-xx*2-yy*2; pad=xx*2+3-4;} wb=wb-pad+3; block.style.height=wb; block.style.paddingTop=pad; if(atype==2){ block.style.left=aleft+left; } } /*mask.style.left=e.pageX-5; mask.style.top=e.pageY-5;*/ } function addKurs(name,clas,color,key){ document.getElementById('kurs').innerHTML+='
'+name+'
'; } function reposition(){ if(typeof(tbls)!='undefined') for(i=1;i<=2;i++){ if(tbls[i]!=null) for(i2=1;i2<=20;i2++){ if(tbls[i][i2]!=null && tbls[i][i2]!=''){ //alert(tbls[i][i2]); var element=document.getElementById(tbls[i][i2]); var dropTarget=element.parentNode.id; element.style.left=getOffset(document.getElementById(dropTarget)).left+3; element.style.top=mlb+getOffset(document.getElementById(dropTarget)).top+(i2-1)*ew; } } } } function rebuildKurs(obj){ var cls=obj.options[obj.selectedIndex].value; var limit=document.getElementById(obj.id+'2').options[document.getElementById(obj.id+'2').selectedIndex].value; tbls=[]; document.getElementById('kurs').innerHTML=''; for(i=1;i<=2;i++) document.getElementById('d'+i).innerHTML=' '; if(cls=='...') return; var min=1; var max=11; min=cls; max=cls-1+limit*2/2; for (var key in kurs) { var key1=key; var ckurs = kurs[key]; for (var key in ckurs.clas) { var cclas = ckurs.clas[key]; if(cclas>=min && cclas<=max){ addKurs(ckurs.name,cclas,ckurs.color,key1); break;}// else if(key==0 && cclas>max) break; } } var dragObjects = document.getElementById('kurs').getElementsByTagName('div') for(var i=0; i