//---------- [one.ngn] Content Managent System -------------- //---------- created by zerophobic.com -------------- //----------------------------------------------------------- // MODULE : misc javascript // FUNCTION : tools and snippets // AUTHOR : brett stanley // CREATED : 01/10/2001 // MODIFIED : 11/01/2002 //----------------------------------------------------------- //----------------------------------------------------------- //------------------------------------------------------------------------- // check the browser type //------------------------------------------------------------------------- var menuReadyState=false; var exclude=true; var agt=navigator.userAgent.toLowerCase(); var ie=false; var mac=false; var ie4=false; var ie5=false; var op5=false; var op7=false; var konqi=false; if (typeof document.all!="undefined"&&(agt.indexOf('msie')!=-1)){ ie=true; ie4=true; exclude=false; if (agt.indexOf('msie 4')==-1){ ie5=true; ie4=false; } if (agt.indexOf('opera')!=-1){ ie=false; ie4=false; ie5=false; op5=true; } } var ns6=false; var mz7=false; if (typeof document.getElementById!="undefined"&&!ie){ ns6=true; exclude=false; if (agt.indexOf('netscape6')==-1){ ns6=false; mz7=true; } if (typeof window.opera!="undefined"){ mz7=false; op5=true; if((agt.indexOf("opera 7")!=-1)||(agt.indexOf("opera/7")!=-1)){ op5=false; op7=true; } }else if (agt.indexOf('gecko')==-1){ mz7=false; exclude=true; } } if (agt.indexOf('opera 4')!=-1){ op5=false; mz7=false; exclude=true; } var ns4=false; if ((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)&&!ie&&!op5&&!ns6&&!mz7){ ns4=true; exclude=false; } if (agt.indexOf('webtv')!=-1){ ie=false; ie4=false; exclude=true; } var win=false; var mac=false; var lin=false; if (agt.indexOf('win')!=-1){ win=true; mac=false; lin=false; }else if (agt.indexOf('mac')!=-1){ win=false; mac=true; lin=false; }else{ win=false; mac=false; lin=true; } if (typeof navigator.vendor!="undefined"){ if (navigator.vendor =="KDE"){ ie=false; ie4=false; ie5=false; konqi = true; ns6=true; ns4 = false; exclude = false; var thisKDE=agt; var splitKDE=thisKDE.split("konqueror/"); var aKDE=splitKDE[1].split("; "); var KDEn=parseFloat(aKDE[0]); var oldKde=false; if(KDEn<2.2){ oldKde=true; exclude=true; ns6=false; konqi=false; } } } var op6=false; if((agt.indexOf("opera 6")!=-1)||(agt.indexOf("opera/6")!=-1)){ op6=true; op5=false; } var ie6=false; if(ie5&&agt.indexOf("msie 6")!=-1){ ie6=true; } var dcm,com; if(ie6){ dcm=document.compatMode; com=false; if(dcm!="BackCompat"){ com=true; } } var ice=false; if(typeof navigator.__ice_version!="undefined"){ ice=true; ie=false; ie5=false; ie4=true; ns4=false; } var ns7=false; if(agt.indexOf("netscape/7")!=-1){ mz7=false; ns6=true; ns7=true; } if(agt.indexOf("opera/3")!=-1){ ie4=false; ice=false; op5=false; exclude=true; } if(agt.indexOf("opera 4")!=-1){ ns4=false; exclude=true; } exclude = false; //------------------------------------------------------------------------- //window openers //------------------------------------------------------------------------- function openWindow(file){ window.open(file, 'image', config='width=150, height=150'); } // all your window popping needs function winPop(file,name,width,height){ win=window.open(file, name, "width="+width+", height="+height+",status=no,scrollbars=no,scrolling=no,toolbar=no,menubar=no,location=no,resizable=yes"); win.resizeTo(width,height); win.moveTo((screen.availWidth/2)-(width/2),(screen.availHeight/2)-(height/2)); win.focus(); return(win); } //------------------------------------------------------------------------- // Article select scripts //------------------------------------------------------------------------- function open_select_window(ids,field){ // opens the right window thisWin = winPop('dsp_article_select.php?field='+field+'&selected='+ids,'link',300,300); } function article_select(articles,field){ // this displays the articles in the Select Box //alert(articles); var article_ids = new Array(); var thisFieldList = eval("document.this_form."+field+"_list"); var thisField = eval("document.this_form."+field); var n=0; if (articles != ""){ for (i = 0; i < articles.length; i++){ var article = new Option(articles[i][1],articles[i][0]); thisFieldList.options.length = n; thisFieldList.options[n] = article; article_ids[n] = articles[i][0]+";"+articles[i][1]; n++; } }else{ thisFieldList.options.length = 1; thisFieldList.options[0].text = "---------No Linked Articles---------"; } thisField.value = article_ids; //alert(articles); } //------------------------------------------------------------------------- //Disable right click //------------------------------------------------------------------------- function right(e) { var msg = " [ONE.NGN]\n\nContent Management\n\n ©2002 Zerophobic"; if (navigator.appName == 'Netscape' && e.which == 3) { alert(msg); return false; } if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) { alert(msg); return false; } else return true; } function trap() { // trap right click on the page if(document){ document.onmousedown = right; document.onmouseup = right; } // trap right click on any images if(document.images){ for(i=0;i'); objWindow.document.write(''); objWindow.document.write(''+document.title+'\n'); objWindow.document.write(''); //objWindow.document.write(''); objWindow.document.write(''); objWindow.document.write(''); objWindow.document.write('
'); objWindow.document.write(''); objWindow.document.write('   '); objWindow.document.write(''); objWindow.document.write('
'); //objWindow.document.write('Print the page | Close this window

'); objWindow.document.write(innerContent); objWindow.document.write('

Printed from '+document.title+' '+document.location+''); objWindow.document.write(''); objWindow.document.write(''); objWindow.document.write(''); objWindow.document.close(); // objWindow.resizeTo(width,height); //objWindow.moveTo((screen.availWidth/2)-(width/2),(screen.availHeight/2)-(height/2)); objWindow.focus(); } else if(document.layers) { window.print(); } else { window.print(); window.close('print'); } } //------------------------------------------------------------------------- //html editor //------------------------------------------------------------------------- function bold(field) { var dark=prompt('Bold text','Text'); if (dark) { field.value+=(''+dark+''); } } function highlight(field) { var dark=prompt('highlight text','Text'); if (dark) { field.value+=(''+dark+''); } } function hrrule(field) { field.value+=('


') } function putemotion(field,emo) { field.value+=(emo); } function quote(field) { var quotet=prompt('Quote Text','Text'); if (quotet) { field.value+=('
'+quotet+'
'); } } function italic(field) { var ital=prompt('Italicized Text','Text'); if (ital) { field.value+=(''+ital+''); } } function underlined(field) { var underline=prompt('Underlined Text','Text'); if (underline) { field.value+=(''+underline+''); } } function link(field) { var hyper=prompt('URL for the link','http://'); var hypertwo=prompt('Text for the link','Text'); var hyperthree=prompt('Window for the link (leave empty for current window)','_blank'); if (hyper) { field.value+=(''+hypertwo+''); } } function ftplink(field) { var hyper=prompt('URL for the link','ftp://'); var hypertwo=prompt('Text for the link','Text'); var hyperthree=prompt('Window for the link (leave empty for current window)','_blank'); if (hyper) { field.value+=(''+hypertwo+''); } } function securelink(field) { var hyper=prompt('URL for the link','https://'); var hypertwo=prompt('Text for the link','Text'); var hyperthree=prompt('Window for the link (leave empty for current window)','_blank'); if (hyper) { field.value+=(''+hypertwo+''); } } function emaillink(field) { var emailit=prompt('Your E-Mail Address','nobody@nowhere.com'); var emailittwo=prompt('Text for the link','Text'); if (emailit) { field.value+=(''+emailittwo+''); } } function image(field) { var img=prompt('URL for the image',''); if (img) { field.value+=(''); } } function orderedl(field) { field.value+=('
    ') } function unorderedl(field) { field.value+=('') } function newlistentry(field) { var newentry=prompt('Text for new entry','Text') if (newentry) { field.value+=('
  1. '+newentry+'\r\n') } } //------------------------------------------------------------------------- //all the stuff for the resizer //------------------------------------------------------------------------- var d = document; var isNav = false, isNS6 = false, isIE = false; if(d.layers) { isNav = true; var range = ""; var styleObj = ""; } else if (d.all) { isIE = true; range = "all."; styleObj = ".style"; } else if(d.getElementById) { isNS6 = true; var range = "getElementById('"; var styleObj = "').style"; } //do the resize function erection(iw,ih) { if(isIE) { var cx = parseInt(top.document.body.clientWidth); var cy = parseInt(top.document.body.clientHeight); } else { var cx = (window.innerWidth); var cy = (window.innerHeight); } var speed = 2; //resize width if (cx < iw-10) { resizeBy(((iw-cx)/speed),0); } else if(cx > iw+10) { resizeBy(((iw-cx)/speed),0); } else { resizeBy(iw-cx,0); } //resize height if (cy < ih-10) { resizeBy(0,((ih-cy)/speed)); } else if (cy > ih+10) { resizeBy(0,((ih-cy)/speed)); } else { resizeBy(0,ih-cy); } if((cx != iw) || (cy != ih)) { setTimeout('erection('+iw+','+ih+')','20'); } else { if(isIE) { if(document.all)for(var i in document.links)document.links[i].onfocus=document.links[i].blur; hide('loadinglayer'); } } } function getObject(obj) { var theObj = eval("document." + range + obj + styleObj); return theObj; } function hide(layername) { if(isIE) eval("d.all['"+layername+"'].style.visibility = 'hidden'"); else if(isNS6) { eval("d.getElementById('"+layername+"').style.visibility = 'hidden'"); } else { eval("d."+layername+".visibility = 'hide'"); } } function show(layername) { if(isIE) eval("d.all['"+layername+"'].style.visibility = 'visible'"); else if(isNS6) { eval("d.getElementById('"+layername+"').style.visibility = 'visible'"); } else { eval("d."+layername+".visibility = 'show'"); } } //------------------------------------------------------------------------- // table Mouseover code //------------------------------------------------------------------------- /** * Sets/unsets the pointer and marker in browse mode * * @param object the table row * @param string the action calling this script (over, out or click) * @param string the default background color * @param string the color to use for mouseover * @param string the color to use for marking a row * * @return boolean whether pointer is set or not */ function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor) { var theCells = null; // 1. Pointer and mark feature are disabled or the browser can't get the // row -> exits if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') { return false; } // 2. Gets the current row and exits if the browser can't get it if (typeof(document.getElementsByTagName) != 'undefined') { theCells = theRow.getElementsByTagName('td'); } else if (typeof(theRow.cells) != 'undefined') { theCells = theRow.cells; } else { return false; } // 3. Gets the current color... var rowCellsCnt = theCells.length; var domDetect = null; var currentColor = null; var newColor = null; // 3.1 ... with DOM compatible browsers except Opera that does not return // valid values with "getAttribute" if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') { currentColor = theCells[0].getAttribute('bgcolor'); domDetect = true; } // 3.2 ... with other browsers else { currentColor = theCells[0].style.backgroundColor; domDetect = false; } // end 3 // 4. Defines the new color // 4.1 Current color is the default one if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) { if (theAction == 'over' && thePointerColor != '') { newColor = thePointerColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; } } // 4.1.2 Current color is the pointer one else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) { if (theAction == 'out') { newColor = theDefaultColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; } } // 4.1.3 Current color is the marker one else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) { if (theAction == 'click') { newColor = (thePointerColor != '') ? thePointerColor : theDefaultColor; } } // end 4 // 5. Sets the new color... if (newColor) { var c = null; // 5.1 ... with DOM compatible browsers except Opera if (domDetect) { for (c = 0; c < rowCellsCnt; c++) { theCells[c].setAttribute('bgcolor', newColor, 0); } // end for } // 5.2 ... with other browsers else { for (c = 0; c < rowCellsCnt; c++) { theCells[c].style.backgroundColor = newColor; } } } // end 5 return true; } // end of the 'setPointer()' function //------------------------------------------------------------------------- // Date Widget Code //------------------------------------------------------------------------- // build the date widget var month_array = [ { name:'January', days:31 }, { name:'February', days:28 }, { name:'March', days:31 }, { name:'April', days:30 }, { name:'May', days:31 }, { name:'June', days:30 }, { name:'July', days:31 }, { name:'August', days:31 }, { name:'September', days:30 }, { name:'October', days:31 }, { name:'November', days:30 }, { name:'December', days:31 } ]; function setLeapYear(year) { var isLeapYear = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); month_array[1].days = (isLeapYear) ? 29 : 28; return isLeapYear; } // display function for the date function date_widget(day_field, month_field, year_field, hour_field, minute_field, hidden_field, default_date) { // for reference if (default_date == null) default_date = new Date(); var output; setLeapYear(default_date.getFullYear()); // do days of the month output = ''; // do months output += ''; // and year, just do from a minimum of this year, or default year var today = new Date(); var start_date = today.getFullYear(); if (default_date.getFullYear() < start_date) { start_date = default_date.getFullYear(); } output += ''; // Do the hours bit first. output += '  '; // The divider (should probably be more locale specific) output += ":"; // And then the minutes output += ''; // This can be changed to a text field to check the value of the output += ''; document.write(output); return true; } // event functions function doDateChange(day_field, month_field, year_field, hour_field, minute_field, hidden_field) { // first set the leap year var year = year_field.options[year_field.selectedIndex].value, month = month_field.options[month_field.selectedIndex].value - 1, day = day_field.options[day_field.selectedIndex].value; hour = hour_field.options[hour_field.selectedIndex].value; minute = minute_field.options[minute_field.selectedIndex].value; // set the month_array up setLeapYear(year); // and then reset the days field day_field.options.length = month_array[month].days; // reset the day value if no longer valid if (day > month_array[month].days) day = month_array[month].days; for (var index = 0 ; index < month_array[month].days ; index++) { // options goes from 0 to day-1 day_field.options[index].text = day_field.options[index].value = index + 1; // and set the default if (index + 1 == day) day_field.options[index].selected = true; } // update the hidden field with the combined data from the drop-down select lists. hidden_field.value = year + '-' + (month + 1) + '-' + day + " " + hour + ":" + minute; return true; }