function execChild(event,cellId){ var cellObj = document.getElementById(cellId); var rowObj = cellObj.parentNode; var rowIndex = rowObj.sectionRowIndex + 1; var newCellId = rowObj.cells[0].id + '_child_0'; var newCellObj = document.getElementById(newCellId); if(newCellObj){ if(event) { closeChild(cellId, 0); } }else{ var cellInfoArr = colInfo(cellId); var childCellId = openChild(event, cellId, 0); listCat(cellInfoArr['id'], childCellId); var childCellId = openChild(event, cellId, 1); listProd(cellInfoArr['id'], childCellId); } } function closeChild(cellId, childCnt){ var cellObj = document.getElementById(cellId); if(childCnt == 0) { var curClass = cellObj.parentNode.cells[0].className; var newClass = curClass.replace('odragger', 'dragger'); cellObj.parentNode.cells[0].className = newClass; } var rowObj = cellObj.parentNode; var rowIndex = rowObj.sectionRowIndex + 1; var newCellId = rowObj.cells[0].id + '_child_' + childCnt; var newCellObj = document.getElementById(newCellId); if(newCellObj) { var newCellRow = newCellObj.parentNode; newCellRow.parentNode.deleteRow(newCellRow.sectionRowIndex); var cellInfoArr = colInfo(cellId); var cookieVar = 'cookie_' + cellInfoArr['table'] + '_open'; var cookieVal = cellInfoArr['table'] + '_id_' + cellInfoArr['id']; var openCookie = getCookie(cookieVar); if(openCookie){ if(openCookie.indexOf(cookieVal) >= 0){ openCookie = openCookie.replace('|' + cookieVal, ''); document.cookie = cookieVar + '=' + openCookie + '; path=/'; } } childCnt++; closeChild(cellId, childCnt); }else{ return 1; } } function openChild(event,cellId, childCnt){ var cellObj = document.getElementById(cellId); if(childCnt == 0) { var curClass = cellObj.parentNode.cells[0].className; var newClass = curClass.replace('dragger', 'odragger'); cellObj.parentNode.cells[0].className = newClass; } var rowObj = cellObj.parentNode; var rowIndex = rowObj.sectionRowIndex + 1 + childCnt; var newCellId = rowObj.cells[0].id + '_child_' + childCnt; var newRow = rowObj.parentNode.insertRow(rowIndex); var newCell= newRow.insertCell(0); newCell.className = 'listCell whiteBg'; newCell.innerHTML = ' '; var newCell= newRow.insertCell(1); newCell.innerHTML = 'Loading....'; newCell.colSpan = rowObj.cells.length - 1; var cellInfoArr = colInfo(cellId); newCell.id = newCellId; var cookieVar = 'cookie_' + cellInfoArr['table'] + '_open'; var cookieVal = cellInfoArr['table'] + '_id_' + cellInfoArr['id']; var openCookie = getCookie(cookieVar); if(openCookie){ if(openCookie.indexOf(cookieVal) < 0){ document.cookie = cookieVar + '=' + openCookie + '|' + cookieVal + '; path=/'; } }else{ document.cookie = cookieVar + '=' + openCookie + '|' + cookieVal + '; path=/'; } return newCellId; } function setCookie(name, value, expires, path, domain, secure) { var today = new Date(); today.setTime( today.getTime() ); if ( expires ){ expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function getCookie(name) { var start = document.cookie.indexOf( name + "=" ); var len = start + name.length + 1; if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { return null; } if ( start == -1 ) return null; var end = document.cookie.indexOf( ";", len ); if ( end == -1 ) end = document.cookie.length; return unescape( document.cookie.substring( len, end ) ); } function deleteCookie(name, path, domain) { if ( getCookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; }