  function $(name) { if (document.getElementById) return document.getElementById(name); else if (document.all) return document.all[name]; else if (document.layers) return document.layers[name]; } function doinit() {  if (handleError_errs) document[handleError_errform][handleError_errfield].value = handleError_errs;  if (usingie5) { $('mainappbody').onscroll=capscroll; capscroll(); }  $('curved').onsubmit = function () { return false; };   if ($('logon')) $('logon').onclick = logon;  if ($('logoff')) $('logoff').onclick = logoff;  $('boxbody_showhide').onclick = showorhide; $('boxconts_showhide').onclick = showorhide; $('textstyles_showhide').onclick = showorhide; $('contsbackground_showhide').onclick = showorhide; $('boxwidth_showhide').onclick = showorhide; var formfields, fieldtype, numfields;  formfields = $('curved').getElementsByTagName('input'); numfields = formfields.length; for (var curfield = 0; curfield < numfields; curfield++) { fieldtype = formfields[curfield].type; if (fieldtype == 'hidden' || fieldtype == 'submit') { continue; } else if (fieldtype == 'text') { formfields[curfield].onchange = function () { upbox(this) }; } else if (fieldtype == 'checkbox') { formfields[curfield].onclick = function () { upbox(this) }; } }  formfields = $('curved').getElementsByTagName('select'); numfields = formfields.length; for (var curfield = 0; curfield < numfields; curfield++) { formfields[curfield].onchange = function () { upbox(this) }; } var loadurl;   $('pickbackgraph').onclick = function () { return pickgraphic('backgraphic', 'Box+Body+Graphic', this); };  $('pickbodycol1').onclick = function () { return pickcolor('backcolor', 'Box+Body+Color%231', this); }; $('backcolorD').onclick = $('pickbodycol1').onclick;  $('pickbodycol2').onclick = function () { return pickcolor('backcolor2', 'Box+Body+Color%232', this); }; $('backcolor2D').onclick = $('pickbodycol2').onclick;  $('contents').onselect = function () { storeCaret(this) }; $('contents').onclick = function () { storeCaret(this) }; $('contents').onkeyup = function () { storeCaret(this) }; $('contents').onchange = function () { upconts(this);storeCaret(this); };  $('makelink').onclick = function () { return dostyle('link', this); }; $('makeimage').onclick = function () { return dostyle('image', this); }; $('makestyle').onclick = function () { return dostyle('style', this); }; $('makehr').onclick = function () { return dostyle('rule', this); }; if (trimstr($('innerbackgraphic').value)) $('innerbackcolor').style.backgroundColor = '#ccc'; if (trimstr($('fontsize').value)) { $('fontsize').style.backgroundColor = '#F4F8EE'; $('fontsizenum').style.backgroundColor = '#ccc'; $('fontsizeunit').style.backgroundColor = '#ccc'; } else { $('fontsize').style.backgroundColor = '#ccc'; $('fontsizenum').style.backgroundColor = '#F4F8EE'; $('fontsizeunit').style.backgroundColor = '#F4F8EE'; } /* the line below fixes a hideous bug with opera 9 the texarea (id referenced below) would change size every time a ajax update was made, intil it was very small. Just by changing the size of the textarea from 43 cols as specified in the html, to 44 cols as specified below fixes the bug for opera 9 completely and no other code is necessary and this does not mess up other browsers! **2/1/09** hack below rendered unnessary by the addition of **width:60% to the css style of the 'contents' textarea!#$&* if (usingopera) $('contents').cols=56; */  fixforms(); } /* show or hide the specified section, update the show/hide graphic for that section, and update the form field that stores the state of that sections show/hide setting */ function showorhide() {  var myid = this.id; var splitid = myid.split('_'); var sectname = splitid[0]; var secthandle = $(sectname + '_sect'); var curdisplay = secthandle.style.display; if (curdisplay == 'none') { secthandle.style.display = ''; this.style.backgroundImage = 'url(/curved/graphics/button-hidesect.gif)';  document.curved[sectname + '_open'].value = 1; } else { secthandle.style.display = 'none'; this.style.backgroundImage = 'url(/curved/graphics/button-showsect.gif)';  document.curved[sectname + '_open'].value = 0; } return false; }  function fixforms() {  var myforms = $('ccbconts').getElementsByTagName('FORM'); var numforms = myforms.length; for (var curform = 0; curform < numforms; curform++) { myforms[curform].target = '_blank'; }  var mylinks = $('ccbconts').getElementsByTagName('A'); var numlinks = mylinks.length; for (var curlink = 0; curlink < numlinks; curlink++) { mylinks[curlink].target = '_blank'; } }  var s1='www.curved-corner-boxes.com';var s2='curved-corner-boxes.com'; var d1=document.domain;  var c5='so1id';var nocache=(document.domain==s1||document.domain==s2)?'':'no-cache';  var c4='solid'; var s3=(d1==s1||d1==s2)?c4:c5; var savepath = ''; var savex, savey; function pickgraphic(forfield, fieldtitle, thisobj) { showload2(thisobj, 'grpicker-mess', -60, -40); $('curved').action='./pickgr3.php?forfield=' + forfield + '&fieldtitle=' + fieldtitle; $('curved').submit(); return false; } function pickcolor(forfield, fieldtitle, thisobj) { showload2(thisobj, 'clpicker-mess', -60, -40); $('curved').action='pickcol-exe4.php?forfield=' + forfield + '&fieldtitle=' + fieldtitle; $('curved').submit(); return false; } function dostyle(howchange, thisobj) { showload2(thisobj, 'subsel-mess', -60, -40); selectit('[**]', '[/**]', $('contents')); $('curved').action='pick_selstyle.php?fromapppage=1&howchange=' + howchange; $('curved').submit(); return false; } function graphpicker(forfield, fieldtitle, thisobj) {  setwritepos(thisobj);   showload('Graphic&nbsp;Picker', -110, -100);  document.curved.action='pickgr3.php?forfield=' + forfield + '&fieldtitle=' + fieldtitle; document.curved.submit(); return false; } function colorpicker(forfield, fieldtitle, thisobj) {  setwritepos(thisobj);   showload('Color&nbsp;Picker', -110, -100); var theform = $("curved"); theform.action='pickcol-exe4.php?forfield=' + forfield + '&fieldtitle=' + fieldtitle; theform.submit(); return false; } function showcode(thisobj) {  setwritepos(thisobj);   showload('Show&nbsp;Code', -110, -100);  document.curved.action='user/show-code.php'; document.curved.submit(); return false; } function custstyles(thisobj) {  setwritepos(thisobj);   showload('Custom&nbsp;Styles', -110, -100);  document.curved.action='user/userstyles2.php'; document.curved.submit(); return false; } function logon() {  setwritepos(this);   showload('Log&nbsp;In&nbsp;/Sign&nbsp;Up', -110, -100);  document.curved.action='./user/logonsu.php'; document.curved.submit(); return false; } function logoff() {  setwritepos(this);  showload('Logging&nbsp;Off', -110, -100);  document.curved.logoffflag.value='doit'; document.curved.submit(); return false; } function pickfont(thisobj) {  setwritepos(thisobj);   showload('Font&nbsp;Picker', -40, -100);  document.curved.action='pickfont.php'; document.curved.submit(); return false; } function showload2(thisobj, showmessageID, xoff, yoff) {  setwritepos(thisobj);    var myform = document.forms[0]; var fldnum = 0; var fld = myform.elements[fldnum]; do { fld.style.backgroundColor = '#cccccc'; } while (fld = myform.elements[++fldnum])  document.body.style.backgroundColor = '#cccccc';  $(showmessageID).style.display = ''; var showbox = $('submitmess2'); showbox.style.left = nn6 ? (savex + xoff + 'px') : (savex + xoff);   showbox.style.top = nn6 ? (savey + yoff + 'px') : (savey + yoff);  showbox.style.display = ''; return; } function showload(loadwhat, xoff, yoff) {   var myform = document.forms[0]; var fldnum = 0; var fld = myform.elements[fldnum]; do { fld.style.backgroundColor = '#cccccc'; } while (fld = myform.elements[++fldnum])  document.body.style.backgroundColor = '#cccccc';   return;  var showbox = $('submitmess'); showbox.style.left = nn6 ? (savex + xoff + 'px') : (savex + xoff);   showbox.style.top = nn6 ? (savey + yoff + 'px') : (savey + yoff); showbox.style.display = 'block'; /* statement below causes a fatal error on ie6 xp $('loadingmess').innerHTML = loadwhat; */ return; } function upwysi(xoff, yoff) {   var showbox = $('wysimess'); showbox.style.left = nn6 ? savex + xoff + 'px': savex + xoff;   showbox.style.top = nn6 ? savey + yoff + 'px' : savey + yoff; showbox.style.display = 'block'; return; } var updatetimeout; function upwysioff() {  var showbox = $('wysimess'); showbox.style.display = 'none'; return false; } var savecontents; var xmlHttp; var ajaxavail = true;  var timeoutId; var doit = 0; var ret; var ajaxtimeout; var saveobj, savewherefrom; function ajaxbusy(xmlHttp, curnumloops) { curnumloops++; if (xmlHttp && (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)) {  return upbox(saveobj, savewherefrom); } if (curnumloops > 50) {  handleError('**AJAX busy ERROR**', 'jscripts/crbox.js', '277'); return false; } ajaxtimeout = setTimeout('ajaxbusy(xmlHttp, ' + curnumloops + ')', 200); return; } var blockevents = false; function upconts(thisobj) {  var curconts = $('contents').value; curcontslow = curconts.toLowerCase();   var startscript = curcontslow.indexOf("<script", 0); if (startscript > -1) { var endscript = curcontslow.indexOf('</script>', (startscript + 7)); if (endscript > -1) {    blockevents = true; $('curved').submit(); return false; } }  var startobj = curcontslow.indexOf("<object", 0); if (startobj > -1) {    blockevents = true; $('curved').submit(); return false; }  upbox(thisobj); return; } var dragflag = false; function upbox(thisobj, wherefrom) { if (blockevents) return false; if (!ajaxavail)  { $('curved').submit(); blockevents = true; return false; }  if (thisobj.className == 'colorfield') {  var wherefrom = thisobj.id; var color = $(wherefrom).value; color = trimstr(color); var hash =color.match("^#"); var hex3 = color.match("^#?[0-9a-fA-F]{3}$"); var hex6 = color.match("^#?[0-9a-fA-F]{6}$"); if (hex3 || hex6) { if (!hash) { color = '#' + color; $(wherefrom).value = color; } } try{ $(wherefrom + 'D').style.backgroundColor = color; $(wherefrom).style.color = '#000000'; } catch(err) { $(wherefrom + 'D').style.backgroundColor = ''; $(wherefrom).style.color = '#ff0000'; alert('THE COLOR ENTERED IS NOT A VALID COLOR AND WILL NOT RENDER'); } }  if (trimstr($('innerbackgraphic').value)) $('innerbackcolor').style.backgroundColor = '#ccc'; else $('innerbackcolor').style.backgroundColor = '#F4F8EE';  if (trimstr($('fontsize').value)) { $('fontsize').style.backgroundColor = '#F4F8EE'; $('fontsizenum').style.backgroundColor = '#ccc'; $('fontsizeunit').style.backgroundColor = '#ccc'; } else { $('fontsize').style.backgroundColor = '#ccc'; $('fontsizenum').style.backgroundColor = '#F4F8EE'; $('fontsizeunit').style.backgroundColor = '#F4F8EE'; }  if (xmlHttp && !(xmlHttp.readyState == 4 || xmlHttp.readyState == 0)) { if (wherefrom == 'submit') {  return false; } saveobj = thisobj;  savewherefrom = wherefrom; ajaxtimeout = setTimeout('ajaxbusy(xmlHttp , 1)', 200); return false; }  xmlHttp=GetXmlHttpObject(); if (!xmlHttp) {  ajaxavail = false;   handleError('**browser does not support AJAX**', 'inside crbox.js', '416'); if (wherefrom == 'submit')  $('curved').submit(); return false; } $("ajaxingnow").style.visibility = 'visible';  setwritepos(thisobj);  if (thisobj.tagName == 'SELECT') upwysi(-45, -125); else if (thisobj.id == 'contents') upwysi(100, -125); else upwysi(-70, -125); /* the divs injected before and after below are necessary in order to solve the problem of the 'margin' attribute being used at the beginning or end of the user contents causing a 'gap' break in the curved box when innerhtmling code. */  if (thisobj.id == 'contents')  savecontents = '<div class="fixmargin"></div>' + $('contents').value + '<div class="fixmargin"></div>'; else savecontents = $("ccbconts").innerHTML;  var x=$('curved'); x.bstyle.value = s3; var numfields = x.length; postfields = ''; for (var i=0; i < numfields; i++) { if (x.elements[i].type == 'checkbox') { postfields += x.elements[i].name + '='; if (x.elements[i].checked) postfields += '1' + '&'; else postfields += '0' + '&'; } else if (x.elements[i].type == 'radio') { if (x.elements[i].checked) { postfields += x.elements[i].name + '='; postfields += escape(x.elements[i].value) + '&'; } } else if (x.elements[i].type == 'hidden' || x.elements[i].type == 'text' || x.elements[i].type == 'select-one') { postfields += x.elements[i].name + '='; postfields += escape(x.elements[i].value) + '&'; } else if (x.elements[i].type == 'textarea') { postfields += x.elements[i].name + '='; postfields += escape(x.elements[i].value) + '&'; ;  } }  var url="http://" + document.domain + "/curved/upbox2.php"; try{ xmlHttp.open("POST", url, true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.onreadystatechange=stateChanged; timeoutId = setTimeout(timesUp,9000); xmlHttp.send(postfields); return false; }  catch (errv) {  xmlHttp.abort( ); clearTimeout(timeoutId);  handleError('AJAX Timeout Failure', 'jscripts/crbox.js', '473'); $("ajaxingnow").style.visibility = 'hidden'; upwysioff();   } return false; } function timesUp( ){   xmlHttp.abort( );  handleError('AJAX Timeout Failure', 'jscripts/crbox.js', '484'); $("ajaxingnow").style.visibility = 'hidden'; upwysioff(); } function stateChanged() { if (xmlHttp.readyState==0) { clearTimeout(timeoutId); $("ajaxingnow").style.visibility = 'hidden'; upwysioff(); return true; } if (!(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")) { return true;  }  clearTimeout(timeoutId); if (xmlHttp.status != 200) {  handleError('AJAX return code != 200', 'jscripts/crbox.js', '505'); $("ajaxingnow").style.visibility = 'hidden'; upwysioff(); return true; }  document[handleError_errform][handleError_errfield].value = ''; wholefromajax = (xmlHttp.responseText) ? xmlHttp.responseText : '';  $("wisywigcont").innerHTML = wholefromajax;    /* styles tags must be moved to the end before doing innerhtml or they dont take */ var curconts1 = savecontents; var curconts2 = savecontents.toLowerCase(); var newoutput = ''; var savestyles = ''; var startstyle, endstyle, stylefound, stylefound2; startstyle = curconts2.indexOf("<style", 0); while (startstyle > -1) { endstyle = curconts2.indexOf('</style>', (startstyle + 7)); if (endstyle > -1) { endstyle += 7; stylefound = curconts1.substr(startstyle, (endstyle - startstyle + 1)); curconts1 = curconts1.replace(stylefound, ''); stylefound2 = curconts2.substr(startstyle, (endstyle - startstyle + 1)); curconts2 = curconts2.replace(stylefound2, ''); savestyles += stylefound; } else break; startstyle = curconts2.indexOf("<style", 0);  } newoutput = curconts1 + savestyles;   $("ccbconts").innerHTML = newoutput;  var impsets = 'Box FIXED WIDTH:<span>'; if (document.curved.fixedboxwidth.value > 0) impsets += document.curved.fixedboxwidth.value + ' pixels'; else impsets += 'NOT SET'; impsets += '</span> LIQUID WIDTH setting:<span>'; if (document.curved.insertcolwidth.value > 0) impsets += document.curved.insertcolwidth.value + ' pixels'; else impsets += 'NOT SET'; impsets += '</span> Horizontal spacing around box:<span>'; impsets += document.curved.boxspacing.value + ' pixels'; impsets += '</span> Target background color:<span>'; impsets += document.curved.targetbackcolor.value + '</span>'; $('impsets').innerHTML = impsets;  $("ajaxingnow").style.visibility = 'hidden'; upwysioff();  fixforms(); return true; } function GetXmlHttpObject() { var AjaxObj = false; try{  AjaxObj = new XMLHttpRequest(); } catch (e){  try{ AjaxObj = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ AjaxObj = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){    handleError('AJAX object not supported', 'jscripts/crbox.js', '589'); } } } return AjaxObj; } function trimstr(thestring) {  while (thestring.substring(0,1) == ' ') thestring = thestring.substring(1, thestring.length); while (thestring.substring(thestring.length-1, thestring.length) == ' ') thestring = thestring.substring(0,thestring.length-1); return thestring; }  function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { curleft += obj.offsetLeft; curtop += obj.offsetTop; } } return [curleft,curtop]; }  function getscroll() { var y; if (self.pageYOffset)  y = self.pageYOffset; else if (document.documentElement && document.documentElement.scrollTop)  y = document.documentElement.scrollTop; else if (document.body)  y = document.body.scrollTop; return y; } /* sets the writing position for writing 'updating wysiwyg' and 'page loading' messages */ function setwritepos(thisobj) {  var y = findPos(thisobj); savex = y[0];  savey = y[1];  var yscroll = getscroll();    if (!dragflag) savey = scrolladj(savey, yscroll); else if (usingopera)  savey = savey - yscroll; } function capscroll() {  var dragbotval = document.curved.app_bottom.value; var dragstyle = $('appdrag'); dragstyle.style.bottom = dragbotval + 1; dragstyle.style.bottom = dragbotval; }   function selectit(text1, text2, textarea) {  if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange) { var caretPos = textarea.caretPos, temp_length = caretPos.text.length; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2; if (temp_length == 0) { caretPos.moveStart("character", -text2.length); caretPos.moveEnd("character", -text2.length); caretPos.select(); } else textarea.focus(caretPos); }  else if (typeof(textarea.selectionStart) != "undefined") { var begin = textarea.value.substr(0, textarea.selectionStart); var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart); var end = textarea.value.substr(textarea.selectionEnd); var newCursorPos = textarea.selectionStart; var scrollPos = textarea.scrollTop; textarea.value = begin + text1 + selection + text2 + end; if (textarea.setSelectionRange){ if (selection.length == 0) textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length); else textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length); textarea.focus(); } textarea.scrollTop = scrollPos; }  else { textarea.value += text1 + text2; textarea.focus(textarea.value.length - 1); } } function storeCaret(text) {  if (typeof(text.createTextRange) != "undefined") text.caretPos = document.selection.createRange().duplicate(); } var ie=document.all; var nn6=document.getElementById&&!document.all; var isdrag=false; var x, y, tx, ty; var dobj; function mm(e) {  if (isdrag)  { dobj.style.right = nn6 ? tx - e.clientX + x + 'px': tx - event.clientX + x;   dobj.style.bottom = nn6 ? ty - e.clientY + y + 'px' : ty - event.clientY + y; $('curved').app_right.value = parseInt(dobj.style.right+0,10);   $('curved').app_bottom.value = parseInt(dobj.style.bottom+0,10); return false;  } } function sm(e) { savex = nn6 ? e.clientX : event.clientX; savey = nn6 ? e.clientY : event.clientY; var fobj    = nn6 ? e.target : event.srcElement; var topelement = nn6 ? "HTML" : "BODY"; try { while (fobj.tagName != topelement && fobj.className != "dragme"){ /* special case for form input boxes and video object tag in floating WYSIWYG box - ff nec hack */ if (skipthis.tag(fobj.tagName)) return true; fobj = nn6 ? fobj.parentNode : fobj.parentElement; }  } catch (e) {  handleError('**WYSIWYG box off of page ERROR**', 'jscripts/crbox.js', '760'); /* alert('AN ERROR HAS OCCURRED ON THIS PAGE.\n \n'  + 'It is caused by the WISYWIG floating box being extended beyond the bottom of the browser.\n \n' + 'This problem only occurs in IE and only occurs when extending the WISYWIG beyond the bottom of the browser.\n \n' + 'It does not occur if you extend the WISYWIG beyond the top or sides of the browser.' ); */ return false; }  if (fobj.className=="dragme") { isdrag = true; dobj = fobj; tx = parseInt(dobj.style.right+0,10); ty = parseInt(dobj.style.bottom+0,10); x = nn6 ? e.clientX : event.clientX; y = nn6 ? e.clientY : event.clientY; document.onmousemove=mm; return false; } } document.onmousedown=sm; document.onmouseup=new Function("isdrag=false"); /* this is a test for certain tags when a mousedown event is detected while in the WYSIGYG area. Normally that would preclude a dragging of the box, but on certain tags like 'input', I will cancel the drag capture and return true from there. This hack is necessary for form fields and other objects like videos to workright in the WYSIWYG box in ff.  */ function skipthistag() { this.skiptags = new Array('INPUT', 'SELECT', 'OBJECT', 'EMBED', 'TEXTAREA', 'A', 'BUTTON'); this.skiptags = '#' + this.skiptags.join('#') + '#'; this.tag = function(fortag) { fortag = '#' + fortag.toUpperCase() + '#'; if (this.skiptags.indexOf(fortag,0) > -1) return true; return false; } } var skipthis = new skipthistag();  