<?xml version="1.0" encoding="utf-8" ?>
<FacileFormsPackage id="FF" type="autoincrement" version="1.4 Stable (build 230)">
	<name>stdlib.english</name>
	<title>BreezingForms -Standard Piece and Script Libraries</title>
	<version>1.5.1</version>
	<creationDate>2013-08-26 15:15:39</creationDate>
	<author>Markus Bopp</author>
	<authorEmail>markus.bopp@crosstec.de</authorEmail>
	<authorUrl>http://www.crosstec.de</authorUrl>
	<description>These are the standard BreezingForms script and piece libraries.</description>
	<copyright>This BreezingForms package is released under the GNU/GPL license</copyright>
	<script id="1647">
		<package>FF</package>
		<name>ff_anychecked</name>
		<title>Any Checked</title>
		<type>Element Validation</type>
		<description>Validate that any radio button or checkbox of a group is checked.</description>
		<code>function ff_anychecked(element\x2C message)\r\n{\r\n    // get plain name\r\n   // alert(document.ff_form52[\x27ff_nm_bfQuickMode6303958[]\x27])\x3B\r\n   // alert(document.getElementById(element.id).id)\x3B\r\n    var name = \x27\x27\x3B\r\n    if(!element.name){\r\n    	if(element.length \x26\x26 element.length != 0){\r\n           name = element[0].name\x3B\r\n           var cnt = 0\x3B\r\n           for (var i = 0\x3B i \x3C element.length\x3B i++)\r\n             if (element[i].name==name) \r\n              if (element[i].checked) cnt++\x3B                      \r\n           if (cnt==0) {\r\n            ff_validationFocus(element[0].name)\x3B\r\n            if (message==\x27\x27) message = \x22Please check or select \x22+name+\x22.\x5Cn\x22\x3B\r\n            return message\x3B\r\n           } // if \r\n\r\n        } else {\r\n           return \x27\x27\x3B\r\n        }\r\n    } else {\r\n      name = element.name\x3B\r\n      if (name.substr(0\x2C6) == \x27ff_nm_\x27) name = name.substring(6\x2Cname.length-2)\x3B\r\n\r\n      // loop through elements and count selections\r\n      var cnt = 0\x3B\r\n      for (var i = 0\x3B i \x3C ff_elements.length\x3B i++)\r\n        if (ff_elements[i][2]==name) \r\n            if (ff_getElementByIndex(i).checked) cnt++\x3B\r\n\r\n      // if none selected\x2C emitt error\r\n      if (cnt==0) {\r\n        ff_validationFocus(element.name)\x3B\r\n        if (message==\x27\x27) message = \x22Please check or select \x22+name+\x22.\x5Cn\x22\x3B\r\n        return message\x3B\r\n      } // if\r\n    }\r\n    \r\n    return \x27\x27\x3B\r\n} // ff_anychecked</code>
	</script>
	<script id="1648">
		<package>FF</package>
		<name>ff_checked</name>
		<title>Checked</title>
		<type>Element Validation</type>
		<description>Validate that radio button or checkbox is checked.</description>
		<code>function ff_checked(element\x2C message)\r\n{\r\n    if (element.checked) \r\n        return \x27\x27\x3B \r\n    else {\r\n        if (message==\x27\x27) message = element.name+\x22 is not checked.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } \r\n}</code>
	</script>
	<script id="1649">
		<package>FF</package>
		<name>ff_checkedValue</name>
		<title>Get checked value</title>
		<description>Get value of the currently checked radiobutton.</description>
		<code>function ff_checkedValue(name)\r\n{\r\n    // loop through elements and find checked\r\n    for (i = 0\x3B i \x3C ff_elements.length\x3B i++)\r\n        if (ff_elements[i][2]==name) {\r\n            e = ff_getElementByIndex(i)\x3B\r\n            if (e.checked) return e.value\x3B\r\n        } // if \r\n    return \x27\x27\x3B\r\n} // ff_checkedValue</code>
	</script>
	<script id="1650">
		<package>FF</package>
		<name>ff_countQuerySelections</name>
		<title>Count Query Selections</title>
		<description>Counts how many checkboxes/radiobuttons are checked/selected in a query list element</description>
		<code>function ff_countQuerySelections(name)\r\n{\r\n    var id = ff_getIdByName(name)\x3B\r\n    var cnt = ff_queryRows[id].length\x3B\r\n    var pagesize = ff_queryPageSize[id]\x3B\r\n    if (pagesize\x3E0) {\r\n        var currpage = ff_queryCurrPage[id]\x3B\r\n        var p\x3B\r\n        for (p = 1\x3B p \x3C currpage\x3B p++) cnt -= pagesize\x3B\r\n        if (cnt \x3E pagesize) cnt = pagesize\x3B\r\n    } // if\r\n    var curr\x3B\r\n    var sels = 0\x3B\r\n    for (curr = 0\x3B curr \x3C cnt\x3B curr++)\r\n        if (document.getElementById(\x27ff_cb\x27+id+\x27_\x27+curr).checked) sels++\x3B\r\n    return sels\x3B\r\n} // ff_countQuerySelections</code>
	</script>
	<script id="1651">
		<package>FF</package>
		<name>ff_dollaramount2dp</name>
		<title>Dollar Amount with 2 Decimal Places</title>
		<type>Element Validation</type>
		<description>Validate that a dollar amount with two decimal places is entered.</description>
		<code>function ff_dollaramount2dp(element\x2C message)\r\n{\r\n    var ex  = /^\x5Cd+$|^\x5Cd+\x5C.\x5Cd{2}$/\x3B\r\n    if (!ex.test(element.value)) {\r\n        if (message==\x27\x27) message = element.name+\x22 must be a number with two decimal places.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_dollaramount2dp</code>
	</script>
	<script id="1652">
		<package>FF</package>
		<name>ff_expString</name>
		<title>String export</title>
		<description>Export string function: escapes special characters of a string</description>
		<code>function ff_expString(text)\r\n{\r\n    text = trim(text)\x3B\r\n    var i\x3B\r\n    var o = \x27\x27\x3B\r\n    for(i = 0\x3B i \x3C text.length\x3B i++) {\r\n        c = text.charAt(i)\x3B\r\n        switch(c) {\r\n            case \x27\x3B\x27 : o += \x27\x5C\x5Cx3B\x27\x3B break\x3B\r\n            case \x27\x2C\x27 : o += \x27\x5C\x5Cx2C\x27\x3B break\x3B\r\n            case \x27\x26\x27 : o += \x27\x5C\x5Cx26\x27\x3B break\x3B\r\n            case \x27\x3C\x27 : o += \x27\x5C\x5Cx3C\x27\x3B break\x3B\r\n            case \x27\x3E\x27 : o += \x27\x5C\x5Cx3E\x27\x3B break\x3B\r\n            case \x27\x5C\x27\x27: o += \x27\x5C\x5Cx27\x27\x3B break\x3B\r\n            case \x27\x5C\x5C\x27: o += \x27\x5C\x5Cx5C\x27\x3B break\x3B\r\n            case \x27\x22\x27 : o += \x27\x5C\x5Cx22\x27\x3B break\x3B\r\n            case \x27\x5Cn\x27: o += \x27\x5C\x5Cn\x27\x3B break\x3B\r\n            case \x27\x5Cr\x27: o += \x27\x5C\x5Cr\x27\x3B break\x3B\r\n            default: o += c\x3B\r\n        } // switch\r\n    } // for\r\n    return o\x3B\r\n} // expString</code>
	</script>
	<script id="1653">
		<package>FF</package>
		<name>ff_flashupload_not_empty</name>
		<title>Flash Upload Not Empty (QuickMode only!)</title>
		<type>Element Validation</type>
		<description>Validates if a flash upload is empty or not.</description>
		<code>function ff_flashupload_not_empty(element\x2C message)\r\n{\r\n    if(typeof bfSummarizers == \x22undefined\x22) { alert(\x22Flash upload validation only available in QuickMode!\x22)\x3B return \x27\x27}\r\n    if(JQuery(\x27#bfFlashFileQueue\x27+element.id.split(\x27ff_elem\x27)[1]).html() != \x27\x27) return \x27\x27\x3B\r\n    if (message==\x27\x27) message = \x22Please enter \x22+element.name+\x22.\x5Cn\x22\x3B\r\n    ff_validationFocus(element.name)\x3B\r\n    return message\x3B\r\n} // ff_valuenotempty</code>
	</script>
	<script id="1654">
		<package>FF</package>
		<name>ff_getfocus</name>
		<title>Get focus</title>
		<type>Element Init</type>
		<description>Get the focus. Usually this is for the first element of the form/page.</description>
		<code>function ff_getfocus(element\x2Ccondition)\r\n{\r\n    if(!element.name){\r\n    	if(element.length \x26\x26 element.length != 0){\r\n    		element[0].focus()\x3B\r\n    	}\r\n    }else{\r\n    	element.focus()\x3B\r\n    }\r\n}</code>
	</script>
	<script id="1655">
		<package>FF</package>
		<name>ff_getQuerySelectedRows</name>
		<title>Get Query Selected Rows</title>
		<description>Returns the selected rows in a 2-dimensional array</description>
		<code>function ff_getQuerySelectedRows(name)\r\n{\r\n    var id = ff_getIdByName(name)\x3B\r\n    var rcnt = ff_queryRows[id].length\x3B\r\n    var cnt = rcnt\x3B\r\n    var pagesize = ff_queryPageSize[id]\x3B\r\n    if (pagesize\x3E0) {\r\n        var currpage = ff_queryCurrPage[id]\x3B\r\n        var p\x3B\r\n        for (p = 1\x3B p \x3C currpage\x3B p++) cnt -= pagesize\x3B\r\n        if (cnt \x3E pagesize) cnt = pagesize\x3B\r\n    } // if\r\n    var curr\x2C r\x3B\r\n    var selcnt = 0\x3B\r\n    var sels = new Array\x3B\r\n    for (curr = 0\x3B curr \x3C cnt\x3B curr++) {\r\n        var elem = document.getElementById(\x27ff_cb\x27+id+\x27_\x27+curr)\x3B\r\n        if (elem.checked) {\r\n            var ident = elem.value\x3B\r\n            for (r = 0\x3B r \x3C rcnt\x3B r++)\r\n                if (ff_queryRows[id][r][0] == ident) {\r\n                    sels[selcnt++] = ff_queryRows[id][r]\x3B\r\n                    break\x3B\r\n                } // if\r\n        } // if\r\n    } // for\r\n    return sels\x3B\r\n} // ff_getQuerySelectedRows</code>
	</script>
	<script id="1656">
		<package>FF</package>
		<name>ff_getQuerySelections</name>
		<title>Get Query Selected ID\x27s</title>
		<description>Returns the column values of the checked/selected checkboxes/radiobuttons in an array</description>
		<code>function ff_getQuerySelections(name)\r\n{\r\n    var id = ff_getIdByName(name)\x3B\r\n    var cnt = ff_queryRows[id].length\x3B\r\n    var pagesize = ff_queryPageSize[id]\x3B\r\n    if (pagesize\x3E0) {\r\n        var currpage = ff_queryCurrPage[id]\x3B\r\n        var p\x3B\r\n        for (p = 1\x3B p \x3C currpage\x3B p++) cnt -= pagesize\x3B\r\n        if (cnt \x3E pagesize) cnt = pagesize\x3B\r\n    } // if\r\n    var curr\x3B\r\n    var selcnt = 0\x3B\r\n    var sels = new Array\x3B\r\n    for (curr = 0\x3B curr \x3C cnt\x3B curr++) {\r\n        var elem = document.getElementById(\x27ff_cb\x27+id+\x27_\x27+curr)\x3B\r\n        if (elem.checked) \r\n            sels[selcnt++] = elem.value\x3B\r\n    } // for\r\n    return sels\x3B\r\n} // ff_getQuerySelections</code>
	</script>
	<script id="1657">
		<package>FF</package>
		<name>ff_impString</name>
		<title>String import</title>
		<description>Import string function: unescapes c-coded characters of a string</description>
		<code>function ff_impString(text)\r\n{\r\n    var str = \x27\x27\x3B\r\n    var ss = 0\x3B\r\n    var s\x3B\r\n    var tl = text.length\x3B\r\n    var hexdigs = \x220123456789abcdefABCDEF\x22\x3B\r\n    while (ss \x3C tl) {\r\n        s = text.charAt(ss++)\x3B\r\n        if (s == \x27\x5C\x5C\x27) {\r\n            if (ss \x3C tl) s = text.charAt(ss++)\x3B else s = 0\x3B\r\n            switch (s) {\r\n                case 0   : break\x3B\r\n                case \x27e\x27 : str += \x27\x5C33\x27\x3B break\x3B\r\n                case \x27t\x27 : str += \x27\x5Ct\x27\x3B break\x3B\r\n                case \x27r\x27 : str += \x27\x5Cr\x27\x3B break\x3B\r\n                case \x27n\x27 : str += \x27\x5Cn\x27\x3B break\x3B\r\n                case \x27f\x27 : str += \x27\x5Cf\x27\x3B break\x3B\r\n                case \x27x\x27 : {\r\n                    if (ss \x3C tl) s = text.charAt(ss++)\x3B else s = 0\x3B\r\n                    var ch = \x27\x27\x3B\r\n                    while (hexdigs.indexOf(s)\x3E=0 \x26\x26 ch.length \x3C 2) {\r\n                        ch += s\x3B\r\n                        if (ss \x3C tl) s = text.charAt(ss++)\x3B else s = 0\x3B\r\n                    } // while\r\n                    while (ch.length \x3C 2) ch = \x270\x27+ch\x3B\r\n                    str += unescape(\x27%\x27+ch)\x3B\r\n                    if (s) ss--\x3B\r\n                    break\x3B\r\n                }\r\n                default:\r\n                    str += s\x3B\r\n            } // switch\r\n        } else\r\n            str += s\x3B\r\n    } // while\r\n    return str\x3B\r\n} // impString</code>
	</script>
	<script id="1658">
		<package>FF</package>
		<name>ff_integer</name>
		<title>Integer Number</title>
		<type>Element Validation</type>
		<description>Validate that an integer value is entered.</description>
		<code>function ff_integer(element\x2C message)\r\n{\r\n    var ex  = /(^-?\x5Cd\x5Cd*$)/\x3B\r\n    if (!ex.test(element.value)) {\r\n        if (message==\x27\x27) message = element.name+\x22 must be integer.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_integer</code>
	</script>
	<script id="1659">
		<package>FF</package>
		<name>ff_integeramount</name>
		<title>Positive Integer</title>
		<type>Element Validation</type>
		<description>Validate that an positive integer value is entered.</description>
		<code>function ff_integeramount(element\x2C message)\r\n{\r\n    var ex  = /(^-?\x5Cd\x5Cd*$)/\x3B\r\n    if (!ex.test(element.value)) {\r\n        if (message==\x27\x27) message = element.name+\x22 must be integer.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_integeramount</code>
	</script>
	<script id="1660">
		<package>FF</package>
		<name>ff_integer_or_empty</name>
		<title>Integer or empty</title>
		<type>Element Validation</type>
		<description>Validate that either an integer value or nothing is entered.</description>
		<code>function ff_integer_or_empty(element\x2C message)\r\n{\r\n    if (element.value != \x27\x27) {\r\n        var ex  = /(^-?\x5Cd\x5Cd*$)/\x3B\r\n        if (!ex.test(element.value)) {\r\n            if (message==\x27\x27) message = element.name+\x22 must be integer.\x5Cn\x22\x3B\r\n            ff_validationFocus(element.name)\x3B\r\n            return message\x3B\r\n        } // if\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_integer_or_empty</code>
	</script>
	<script id="1661">
		<package>FF</package>
		<name>ff_nextpage</name>
		<title>Next page</title>
		<type>Element Action</type>
		<description>Switchs to the next page.</description>
		<code>function ff_nextpage(element\x2C action)\r\n{\r\n    if (ff_currentpage \x3C ff_lastpage) {\r\n        ff_switchpage(ff_currentpage+1)\x3B\r\n        self.scrollTo(0\x2C0)\x3B\r\n    }\r\n} // ff_nextpage</code>
	</script>
	<script id="1662">
		<package>FF</package>
		<name>ff_page1</name>
		<title>Page 1</title>
		<type>Element Action</type>
		<description>Switches to the first page.</description>
		<code>function ff_page1(element\x2C action)\r\n{\r\n    ff_switchpage(1)\x3B\r\n} // ff_page1</code>
	</script>
	<script id="1663">
		<package>FF</package>
		<name>ff_page2</name>
		<title>Page 2</title>
		<type>Element Action</type>
		<description>Switches to the second page.</description>
		<code>function ff_page2(element\x2C action)\r\n{\r\n    if (ff_lastpage \x3E= 2) ff_switchpage(2)\x3B\r\n} // ff_page2</code>
	</script>
	<script id="1664">
		<package>FF</package>
		<name>ff_page3</name>
		<title>Page 3</title>
		<type>Element Action</type>
		<description>Switches to the third page.</description>
		<code>function ff_page3(element\x2C action)\r\n{\r\n    if (ff_lastpage \x3E= 3) ff_switchpage(3)\x3B\r\n} // ff_page3</code>
	</script>
	<script id="1665">
		<package>FF</package>
		<name>ff_previouspage</name>
		<title>Previous page</title>
		<type>Element Action</type>
		<description>Switches to the previous page.</description>
		<code>function ff_previouspage(element\x2C action)\r\n{\r\n    if (ff_currentpage \x3E 1){\r\n        ff_switchpage(ff_currentpage-1)\x3B\r\n        self.scrollTo(0\x2C0)\x3B\r\n    }\r\n} // ff_previouspage</code>
	</script>
	<script id="1666">
		<package>FF</package>
		<name>ff_real</name>
		<title>Real Number</title>
		<type>Element Validation</type>
		<description>Validate that a real number is entered.</description>
		<code>function ff_real(element\x2C message)\r\n{\r\n    var ex  = /(^-?\x5Cd\x5Cd*\x5C.?\x5Cd*$)/\x3B\r\n    if (!ex.test(element.value)) {\r\n        if (message==\x27\x27) message = element.name+\x22 must be a number.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_real</code>
	</script>
	<script id="1667">
		<package>FF</package>
		<name>ff_realamount</name>
		<title>Positive Real Number</title>
		<type>Element Validation</type>
		<description>Validate that a positive real number is entered.</description>
		<code>function ff_realamount(element\x2C message)\r\n{\r\n    var ex  = /(^\x5Cd\x5Cd*\x5C.?\x5Cd*$)/\x3B\r\n    if (!ex.test(element.value)) {\r\n        if (message==\x27\x27) message = element.name+\x22 must be a number.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_realamount</code>
	</script>
	<script id="1668">
		<package>FF</package>
		<name>ff_resetForm</name>
		<title>Reset form</title>
		<type>Element Action</type>
		<description>Reset all form inputs to the initial values.</description>
		<code>function ff_resetForm(element\x2C action)\r\n{\r\n    eval(\x27document.\x27+ff_processor.form_id).reset()\x3B\r\n} // ff_resetForm</code>
	</script>
	<script id="1669">
		<package>FF</package>
		<name>ff_securitycode_entered</name>
		<title>Security code entered</title>
		<type>Element Validation</type>
		<description>Check that a security code was entered.</description>
		<code>function ff_securitycode_entered(element\x2C message)\r\n{\r\n    var ex  = /(^\x5Cd{5}$)/\x3B\r\n    if (!ex.test(element.value)) {\r\n        if (message==\x27\x27) message = \x22Security code must be entered as five digits.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_securitycode_entered</code>
	</script>
	<script id="1670">
		<package>FF</package>
		<name>ff_securitycode_ok</name>
		<title>Security code ok</title>
		<type>Element Validation</type>
		<description>Check that a valid security code was entered.</description>
		<code>function ff_securitycode_ok(element\x2C message)\r\n{\r\n\x3C?php\r\n    global $ff_seccode\x3B\r\n    if (!isset($ff_seccode)) { \r\n        mt_srand((double)microtime()*1000000)\x3B\r\n        $ff_seccode = mt_rand(10000\x2C 99999)\x3B\r\n        JFactory::getSession()-\x3Eset(\x27ff_seccode\x27\x2C $ff_seccode)\x3B\r\n    } // if\r\n    $enc = array()\x3B\r\n    mt_srand((double)microtime()*1000000)\x3B\r\n    for ($i = 0\x3B $i \x3C 256\x3B $i++) $enc[] = mt_rand(0\x2C 255)\x3B\r\n    $seccode = (string)$ff_seccode\x3B\r\n    $hash = \x27\x27\x3B\r\n    $ini = $ff_seccode % 240\x3B\r\n    for ($i = 0\x3B $i \x3C 5\x3B $i++) {\r\n        $d = $ini+intval($seccode{$i})\x3B\r\n        for ($j = 0\x3B $j \x3C 7\x3B $j++) $d = $enc[$d]\x3B\r\n        $hash .= $d\x3B\r\n        $ini = ($ini+$d) % 240\x3B\r\n    } // for\r\n    return\r\n        \x22var enc = \x22.$this-\x3EexpJsValue($enc).\x22\x3B\x5Cn\x22.\r\n        \x22var seccode = new String(element.value)\x3B\x5Cn\x22.\r\n        \x22if (seccode.length==5) {\x5Cn\x22.\r\n        \x22    var hash = \x27\x27\x3B\x5Cn\x22.\r\n        \x22    var ini = parseInt(element.value) % 240\x3B\x5Cn\x22.\r\n        \x22    var i\x2C j\x3B\x5Cn\x22.\r\n        \x22    for (i = 0\x3B i \x3C 5\x3B i++) {\x5Cn\x22.\r\n        \x22        var d = ini+parseInt(seccode.charAt(i))\x3B\x5Cn\x22.\r\n        \x22        for (j = 0\x3B j \x3C 7\x3B j++) d = enc[d]\x3B\x5Cn\x22.\r\n        \x22        hash += d\x3B\x5Cn\x22.\r\n        \x22        ini = (ini+d) % 240\x3B\x5Cn\x22.\r\n        \x22    } // for\x5Cn\x22.\r\n        \x22    if (hash == \x27$hash\x27) return \x27\x27\x3B\x5Cn\x22. \r\n        \x22} // if\x5Cn\x22.\r\n        \x22if (message==\x27\x27) message = \x5C\x22Security code is missing or wrong.\x5C\x5Cn\x5C\x22\x3B\x5Cn\x22.\r\n        \x22ff_validationFocus(element.name)\x3B\x5Cn\x22.\r\n        \x22return message\x3B\x5Cn\x22\x3B\r\n?\x3E\r\n} // ff_securitycode_ok</code>
	</script>
	<script id="1671">
		<package>FF</package>
		<name>ff_selectedValues</name>
		<title>Get selected values as list</title>
		<description>Get values of selected options of a select list as list:\r\n\r\nx = ff_selectedValues(\x27myselectlist\x27)\x3B\r\n// x = green\x2Cred</description>
		<code>function ff_selectedValues(name)\r\n{\r\n    vals = \x27\x27\x3B\r\n    opts = ff_getElementByName(name).options\x3B\r\n    for (o = 0\x3B o \x3C opts.length\x3B o++)\r\n        if (opts[o].selected) {\r\n            if (vals != \x27\x27) vals += \x27\x2C\x27\x3B\r\n            vals += opts[o].value\x3B\r\n        } // if\r\n    return vals\x3B\r\n} // ff_selectedValues</code>
	</script>
	<script id="1672">
		<package>FF</package>
		<name>ff_setChecked</name>
		<title>Set radiobutton checked</title>
		<description>Set a radiobutton checked/unchecked</description>
		<code>function ff_setChecked(name\x2C value\x2C checked)\r\n{\r\n    if (arguments.length\x3C3) checked = true\x3B\r\n    for (var i = 0\x3B i \x3C ff_elements.length\x3B i++)\r\n        if (ff_elements[i][2]==name) {\r\n            var e = ff_getElementByIndex(i)\x3B\r\n            if (e.value == value) {\r\n                e.checked = checked\x3B\r\n                break\x3B\r\n            } // if\r\n        } // if\r\n} // ff_setChecked</code>
	</script>
	<script id="1673">
		<package>FF</package>
		<name>ff_setSelected</name>
		<title>Select options of  select list</title>
		<description>Select options in a Select List element.\r\n\r\nff_setSelected(\x27mylist\x27\x2C \x27green\x27)\x3B // select green in single or multi mode\x2C unselect all other options\r\nff_setSelected(\x27mylist\x27\x2C \x27red\x2Cgreen\x27)\x3B // select red and green in multi mode\x2C unselect all other options</description>
		<code>function ff_setSelected(name\x2C list)\r\n{\r\n    ids = list.split(\x27\x2C\x27)\r\n    opts = ff_getElementByName(name).options\x3B\r\n    for (o = 0\x3B o \x3C opts.length\x3B o++) {\r\n        state = false\x3B\r\n        for (i = 0\x3B i \x3C ids.length\x3B i++) \r\n            if (ids[i]==opts[o].value) {\r\n                state = true\x3B\r\n                break\x3B\r\n            } // if\r\n        opts[o].selected = state\x3B\r\n    } // for\r\n} // ff_setSelected</code>
	</script>
	<script id="1674">
		<package>FF</package>
		<name>ff_showaction</name>
		<title>Show action</title>
		<type>Element Action</type>
		<description>Displays the element action.</description>
		<code>function ff_showaction(element\x2C action)\r\n{\r\n   alert(\x27Action \x27+action+\x27 performed by element \x27+element.id)\x3B\r\n}</code>
	</script>
	<script id="1675">
		<package>FF</package>
		<name>ff_showelementinit</name>
		<title>Show element initialization</title>
		<type>Element Init</type>
		<description>Display the element initialization (mainly for debugging)</description>
		<code>function ff_showelementinit(element\x2Ccondition)\r\n{\r\n    if(!element.name)\r\n    	if(element.length \x26\x26 element.length != 0)\r\n    		alert(\x27Initialization of \x27+element[0].name+\x27 at \x27+condition)\x3B\r\n    else\r\n    	alert(\x27Initialization of \x27+element.name+\x27 at \x27+condition)\x3B\r\n}</code>
	</script>
	<script id="1676">
		<package>FF</package>
		<name>ff_showforminit</name>
		<title>Show form initialization</title>
		<type>Form Init</type>
		<description>Show when form initialization is run (for debugging)</description>
		<code>function ff_showforminit()\r\n{\r\n    alert(\x27Form initialization\x27)\x3B\r\n}</code>
	</script>
	<script id="1677">
		<package>FF</package>
		<name>ff_showsubmitted</name>
		<title>Show submitted status</title>
		<type>Form Submitted</type>
		<description>Display submit status as user feedback.</description>
		<code>function ff_showsubmitted(status\x2C message)\r\n{\r\n    alert(message)\x3B\r\n} // ff_showsubmitted</code>
	</script>
	<script id="1678">
		<package>FF</package>
		<name>ff_showvalidation</name>
		<title>Show element validation</title>
		<type>Element Validation</type>
		<description>Display element validation (for debugging)</description>
		<code>function ff_showvalidation(element\x2C message)\r\n{\r\n    alert(\x27Validation of \x27+element.name+\x22 with message: \x5Cn\x22+message)\x3B\r\n    return \x27\x27\x3B\r\n}</code>
	</script>
	<script id="1679">
		<package>FF</package>
		<name>ff_submittedhome</name>
		<title>Return to homepage</title>
		<type>Form Submitted</type>
		<description>Display submit status and then return to the home page of the site.</description>
		<code>function ff_submittedhome(status\x2C message)\r\n{\r\n    alert(message+\x22\x5CnYou will be redirected to the home page now.\x22)\x3B\r\n    ff_returnHome()\x3B\r\n} // ff_submittedhome</code>
	</script>
	<script id="1680">
		<package>FF</package>
		<name>ff_unchecked</name>
		<title>Unchecked</title>
		<type>Element Validation</type>
		<description>Validate that radio button or checkbox is unchecked.</description>
		<code>function ff_unchecked(element\x2C message)\r\n{\r\n    if (!element.checked) \r\n        return \x27\x27\x3B \r\n    else {\r\n        if (message==\x27\x27) message = element.name+\x22 is checked.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n} // ff_unchecked</code>
	</script>
	<script id="1681">
		<package>FF</package>
		<name>ff_validate_date_DDMMYYYY</name>
		<title>Validate Date DD/MM/YYYY format</title>
		<type>Element Validation</type>
		<description>Validates that the date in a textfield is correctly formatted in DD/MM/YYYY format.\r\nCan be used with a textfield element and/or the Calendar element.</description>
		<code>function ff_validate_date_DDMMYYYY(element\x2C message)\r\n{\r\n   // Regular expression used to check if date is in correct format\r\n   var pattern = /[0-3][0-9]\x5C/(0|1)[0-9]\x5C/(19|20)[0-9]{2}/\x3B\r\n   if(pattern.test(element.value))\r\n   {\r\n      var date_array = element.value.split(\x27/\x27)\x3B\r\n      var day = date_array[0]\x3B\r\n\r\n      // Attention! Javascript consider months in the range 0 - 11\r\n      var month = date_array[1] - 1\x3B\r\n      var year = date_array[2]\x3B\r\n\r\n      // This instruction will create a date object\r\n      source_date = new Date(year\x2Cmonth\x2Cday)\x3B\r\n\r\n      if(year != source_date.getFullYear())\r\n      {\r\n         return message == \x27\x27 ? \x27Element \x27 + element.name + \x27 failed my test\x27 : message\x3B\r\n      }\r\n\r\n      if(month != source_date.getMonth())\r\n      {\r\n         return message == \x27\x27 ? \x27Element \x27 + element.name + \x27 failed my test\x27 : message\x3B\r\n      }\r\n\r\n      if(day != source_date.getDate())\r\n      {\r\n         return message == \x27\x27 ? \x27Element \x27 + element.name + \x27 failed my test\x27 : message\x3B\r\n      }\r\n   }\r\n   else\r\n   {\r\n      return message == \x27\x27 ? \x27Element \x27 + element.name + \x27 failed my test\x27 : message\x3B\r\n   }\r\n\r\n   return \x27\x27\x3B\r\n}</code>
	</script>
	<script id="1682">
		<package>FF</package>
		<name>ff_validate_form</name>
		<title>Validate form</title>
		<type>Element Action</type>
		<description>Validates the form and displays the result.</description>
		<code>function ff_validate_form(element\x2C action)\r\n{\r\n    if(typeof bfUseErrorAlerts != \x27undefined\x27){\r\n     JQuery(\x22.bfErrorMessage\x22).html(\x27\x27)\x3B\r\n     JQuery(\x22.bfErrorMessage\x22).css(\x22display\x22\x2C\x22none\x22)\x3B\r\n    }\r\n    error = ff_validation(0)\x3B\r\n    if (error != \x27\x27) {\r\n        if(typeof bfUseErrorAlerts == \x27undefined\x27){\r\n           alert(error)\x3B\r\n        } else {\r\n           bfShowErrors(error)\x3B\r\n        }\r\n        ff_validationFocus(\x27\x27)\x3B\r\n    } else\r\n        alert(\x27All inputs are valid.\x27)\x3B\r\n} // ff_validate_form</code>
	</script>
	<script id="1683">
		<package>FF</package>
		<name>ff_validate_nextpage</name>
		<title>Validate and next page</title>
		<type>Element Action</type>
		<description>Validates the current page\x2C and if everything is ok is switches to the next page.</description>
		<code>function ff_validate_nextpage(element\x2C action)\r\n{\r\n    if(typeof bfUseErrorAlerts != \x27undefined\x27){\r\n     JQuery(\x22.bfErrorMessage\x22).html(\x27\x27)\x3B\r\n     JQuery(\x22.bfErrorMessage\x22).css(\x22display\x22\x2C\x22none\x22)\x3B\r\n    }\r\n\r\n    error = ff_validation(ff_currentpage)\x3B\r\n    if (error != \x27\x27) {\r\n       if(typeof bfUseErrorAlerts == \x27undefined\x27){\r\n           alert(error)\x3B\r\n        } else {\r\n           bfShowErrors(error)\x3B\r\n        }\r\n        ff_validationFocus(\x27\x27)\x3B\r\n    } else {\r\n        ff_switchpage(ff_currentpage+1)\x3B\r\n        self.scrollTo(0\x2C0)\x3B   \r\n    }\r\n} // ff_validate_nextpage</code>
	</script>
	<script id="1684">
		<package>FF</package>
		<name>ff_validate_page</name>
		<title>Validate page</title>
		<type>Element Action</type>
		<description>Validates the current page and displays the result.</description>
		<code>function ff_validate_page(element\x2C action)\r\n{\r\n    if(typeof bfUseErrorAlerts != \x27undefined\x27){\r\n     JQuery(\x22.bfErrorMessage\x22).html(\x27\x27)\x3B\r\n     JQuery(\x22.bfErrorMessage\x22).css(\x22display\x22\x2C\x22none\x22)\x3B\r\n    }\r\n    error = ff_validation(ff_currentpage)\x3B\r\n    if (error != \x27\x27) {\r\n        if(typeof bfUseErrorAlerts == \x27undefined\x27){\r\n           alert(error)\x3B\r\n        } else {\r\n           bfShowErrors(error)\x3B\r\n        }\r\n        ff_validationFocus(\x27\x27)\x3B\r\n    } else\r\n        alert(\x27All inputs are valid.\x27)\x3B\r\n} // ff_validate_page</code>
	</script>
	<script id="1685">
		<package>FF</package>
		<name>ff_validate_prevpage</name>
		<title>Validate previous page</title>
		<type>Element Action</type>
		<description>Validates the current page and switches to the previous page if all is ok</description>
		<code>function ff_validate_prevpage(element\x2C action)\r\n{\r\n    if(typeof bfUseErrorAlerts != \x27undefined\x27){\r\n     JQuery(\x22.bfErrorMessage\x22).html(\x27\x27)\x3B\r\n     JQuery(\x22.bfErrorMessage\x22).css(\x22display\x22\x2C\x22none\x22)\x3B\r\n    }\r\n\r\n    error = ff_validation(ff_currentpage)\x3B\r\n    if (error != \x27\x27) {\r\n       if(typeof bfUseErrorAlerts == \x27undefined\x27){\r\n           alert(error)\x3B\r\n        } else {\r\n           bfShowErrors(error)\x3B\r\n        }\r\n        ff_validationFocus(\x27\x27)\x3B\r\n    } else{\r\n    	if(ff_currentpage \x3E 1){\r\n	 ff_switchpage(ff_currentpage-1)\x3B\r\n	 self.scrollTo(0\x2C0)\x3B\r\n        }\r\n    }\r\n} // ff_validate_prevpage</code>
	</script>
	<script id="1686">
		<package>FF</package>
		<name>ff_validate_submit</name>
		<title>Validate and submit form</title>
		<type>Element Action</type>
		<description>Validates the whole form\x2C and if everything is ok it submits the form.</description>
		<code>function ff_validate_submit(element\x2C action)\r\n{\r\n    if(typeof bfUseErrorAlerts != \x27undefined\x27){\r\n     JQuery(\x22.bfErrorMessage\x22).html(\x27\x27)\x3B\r\n     JQuery(\x22.bfErrorMessage\x22).css(\x22display\x22\x2C\x22none\x22)\x3B\r\n    }\r\n    error = ff_validation(0)\x3B\r\n    if (error != \x27\x27) {\r\n\r\n        if(typeof bfUseErrorAlerts == \x27undefined\x27){\r\n           alert(error)\x3B\r\n        } else {\r\n           bfShowErrors(error)\x3B\r\n        }\r\n        ff_validationFocus()\x3B\r\n    } else\r\n        ff_submitForm()\x3B\r\n} // ff_validate_submit</code>
	</script>
	<script id="1687">
		<package>FF</package>
		<name>ff_validemail</name>
		<title>Valid email</title>
		<type>Element Validation</type>
		<description>Validate entry of a valid email (syntax check only)</description>
		<code>function ff_validemail(element\x2C message)\r\n{\r\n    var check =\r\n    /^([a-zA-Z0-9_\x5C.\x5C-])+\x5C@(([a-zA-Z0-9\x5C-])+\x5C.)+([a-zA-Z0-9]{2\x2C4})+$/\x3B\r\n    if (!check.test(element.value)){\r\n        if (message==\x27\x27) message = element.name+\x22 is no valid email address.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n    return \x27\x27\x3B\r\n} // ff_validemail</code>
	</script>
	<script id="1688">
		<package>FF</package>
		<name>ff_validemail_repeat</name>
		<title>Validate Email repeat</title>
		<type>Element Validation</type>
		<description>Checks if the field value is a valid email address and has a second counterpart that has an equal value.\r\nThe 2nd email field must be named \x22FIELDNAME_repeat\x22!</description>
		<code>function ff_validemail_repeat(element\x2C message)\r\n{\r\n    var check =\r\n    /^([a-zA-Z0-9_\x5C.\x5C-])+\x5C@(([a-zA-Z0-9\x5C-])+\x5C.)+([a-zA-Z0-9]{2\x2C4})+$/\x3B\r\n    if (!check.test(element.value)){\r\n        if (message==\x27\x27) message = element.name+\x22 is no valid email address.\x5Cn\x22\x3B\r\n        ff_validationFocus(element.name)\x3B\r\n        return message\x3B\r\n    } // if\r\n	\r\n    try{\r\n	    var repeat = element.name.split(\x22ff_nm_\x22)[1].split(\x22[]\x22)[0]\x3B\r\n	\r\n	    if(!ff_getElementByName(repeat + \x27_repeat\x27)){\r\n	     	if (message==\x27\x27) message = repeat+\x22 has no repeat email field.\x5Cn\x22\x3B\r\n	        ff_validationFocus(element.name)\x3B\r\n	        return message\x3B\r\n	    } else {\r\n	        if(ff_getElementByName(repeat + \x27_repeat\x27).value != element.value){\r\n	           if (message==\x27\x27) message = element.name+\x22 and \x22 + repeat + \x22_repeat do not match.\x5Cn\x22\x3B\r\n	           ff_validationFocus(repeat + \x27_repeat\x27)\x3B\r\n	           return message\x3B\r\n	        }\r\n	    }\r\n    }catch(e){\r\n        return e.description\x3B\r\n    }\r\n\r\n    return \x27\x27\x3B\r\n} // ff_validemail</code>
	</script>
	<script id="1689">
		<package>FF</package>
		<name>ff_valuenotempty</name>
		<title>Value not empty</title>
		<type>Element Validation</type>
		<description>Validate that value is not empty.</description>
		<code>function ff_valuenotempty(element\x2C message)\r\n{\r\n    if (element.value!=\x27\x27) return \x27\x27\x3B \r\n    if (message==\x27\x27) message = \x22Please enter \x22+element.name+\x22.\x5Cn\x22\x3B\r\n    ff_validationFocus(element.name)\x3B\r\n    return message\x3B\r\n} // ff_valuenotempty</code>
	</script>
	<piece id="728">
		<package>FF</package>
		<name>ff_addCustomCSSFile</name>
		<title>Add custom CSS File</title>
		<type>Before Form</type>
		<description>Adds a custom css file to the form. To choose a css file\x2C execute this piece and call the function ff_addCustomCSSFile(\x27path/to/css/file\x27) with the RELATIVE (not full!) path to your joomla installation.\r\nDo not forget to call $this-\x3EexecPieceByName(\x27ff_InitLib\x27) before!\r\n\r\nExample:\r\n\r\nglobal $mainframe\x3B\r\n\r\n$this-\x3EexecPieceByName(\x27ff_InitLib\x27)\x3B\r\n$this-\x3EexecPieceByName(\x27ff_addCustomCSSFile\x27)\x3B\r\n\r\nff_addCustomCSSFile(\x27templates/\x27 . $mainframe-\x3EgetTemplate() . \x27/css/template.css\x27)\x3B</description>
		<code>function ff_addCustomCSSFile($path){\r\n	if(file_exists(JPATH_SITE . \x27/\x27 . $path)){\r\n		JFactory::getDocument()-\x3EaddStyleSheet(JURI::root() . $path)\x3B\r\n	}\r\n}</code>
	</piece>
	<piece id="729">
		<package>FF</package>
		<name>ff_Constants</name>
		<title>Constansts definitions</title>
		<type>Before Form</type>
		<description>Library constants definitions</description>
		<code>define(\x27FF_DIE\x27\x2C       \x27_ff_die_on_errors_\x27)\x3B\r\ndefine(\x27FF_DONTDIE\x27\x2C   \x27_ff_stay_alive_\x27)\x3B\r\ndefine(\x27FF_IGNOREDIE\x27\x2C \x27_ff_ignore_if_dying_\x27)\x3B\r\n\r\ndefine(\x27FF_ARRAY\x27\x2C     \x27_ff_return_as_array_\x27)\x3B\r\ndefine(\x27FF_LIST\x27\x2C      \x27_ff_return_as_list_\x27)\x3B\r\ndefine(\x27FF_SLIST\x27\x2C     \x27_ff_return_as_slist_\x27)\x3B\r\ndefine(\x27FF_DLIST\x27\x2C     \x27_ff_return_as_dlist_\x27)\x3B\r\n\r\ndefine(\x27FF_NOTRIM\x27\x2C    1)\x3B\r\ndefine(\x27FF_ALLOWHTML\x27\x2C 2)\x3B\r\ndefine(\x27FF_ALLOWRAW\x27\x2C  4)\x3B</code>
	</piece>
	<piece id="730">
		<package>FF</package>
		<name>ff_die</name>
		<title>Terminate form gracefully</title>
		<description>Gracefully terminates the form and shows a message plus opionally a \r\nCONTINUE button for further redirection.\r\n\r\nCall:\r\n\r\n    ff_die($message=null\x2C $action=\x27stop\x27\x2C $target=\x27\x27\x2C $params=\x27\x27\x2C $label=\x27Continue\x27)\x3B\r\n    return\x3B\r\n\r\n    $message = A message to display. If no message is provided\x2C it will\r\n               display:\r\n\r\n                    Fatal error in $formname\x2C processing stopped.\r\n\r\n    $action  = \x27stop\x27 : Dont show a CONTINUE button (default)\r\n               \x27self\x27 : Redirect to the same form\r\n               \x27form\x27 : Redirect to another form \r\n               \x27page\x27 : Redirect to another page of this site\r\n               \x27home\x27 : Redirect to homepage of the site\r\n               \x27url\x27  : Redirect to a url\r\n\r\n    $target  = Target name/url for \x27form\x27\x2C \x27page\x27 and \x27url\x27\r\n\r\n    $params  = Additional parameters for \x27self\x27 and \x27form\x27\r\n\r\n    $label   = Text for the continue button\r\n\r\nExamples:\r\n\r\n    // Display standard message without continue button\r\n    ff_die()\x3B \r\n\r\n    // Display message without continue button\r\n    ff_die(\x27Sorry\x2C cannot continue for some reason.\x27)\x3B\r\n\r\n    // Display standard message and return to same form with a parameter\r\n    ff_die(null\x2C \x27self\x27\x2C \x27\x26ff_param_foo=bar\x27)\x3B\r\n\r\n    // Redirect to another form\r\n    ff_die(\x27Guess you are hungry now...\x27\x2C \x27form\x27\x2C \x27SamplePizzaShop\x27\x2C null\x2C \x27Order\x27)\x3B\r\n\r\n    // Redirect to another site page\r\n    ff_die(\r\n        \x27Something strange has happened!\x27\x2C \r\n        \x27page\x27\x2C \r\n        \x27index.php?option=com_content\x26task=section\x26id=1\x26Itemid=2\x27\r\n    )\x3B</description>
		<code>function ff_die($message=\x27\x27\x2C $action=\x27stop\x27\x2C $target=\x27\x27\x2C $params=\x27\x27\x2C $label=\x27Continue\x27)\r\n{\r\n    global $ff_processor\x3B\r\n    if ($ff_processor-\x3Edying) return\x3B\r\n\r\n    ob_end_clean()\x3B\r\n    $form =\x26 $ff_processor-\x3Eformrow\x3B\r\n    if (!$message) \r\n        $message = \r\n            \x22\x3Cstrong\x3EFatal error in $form-\x3Ename\x2C form processing halted.\x3C/strong\x3E\x22\x3B\r\n    switch ($action) {\r\n        case \x27self\x27: $url = ff_makeSelfUrl($params)\x3B break\x3B\r\n        case \x27form\x27: $url = ff_makeFormUrl($target\x2C $params)\x3B break\x3B\r\n        case \x27page\x27: $url = ff_makePageUrl($target)\x3B break\x3B\r\n        case \x27home\x27: $url = \x22{mossite}\x22\x3B break\x3B\r\n        case \x27url\x27 : $url = $target\x3B break\x3B\r\n        default    : $url = \x27\x27\x3B\r\n    } // switch\r\n    if ($form-\x3Eclass1 != \x27\x27) echo \x27\x3Cdiv class=\x22\x27.$form-\x3Eclass1.\x27\x22\x3E\x27.nl()\x3B\r\n    echo($message.\x27\x3Cbr/\x3E\x3Cbr/\x3E\x3Cbr/\x3E\x27.nl())\x3B\r\n    if ($url) {\r\n        if (!$ff_processor-\x3Einline) echo \x27\x3Cform action=\x22#redirect\x22\x3E\x27.nl()\x3B\r\n        if ($ff_processor-\x3Einframe) $t = \x27parent\x27\x3B else $t = \x27document\x27\x3B\r\n        echo \x27\x3Cinput type=\x22button\x22 class=\x22button\x22 value=\x22\x27.$label.\x27\x22\x27.\r\n             \x27 onClick=\x22\x27.$t.\x27.location.href=\x5C\x27\x27.htmlentities($url\x2CENT_QUOTES).\x27\x5C\x27\x3B\x22\x27.\r\n             \x27/\x3E\x27.nl()\x3B\r\n        if (!$ff_processor-\x3Einline) echo \x27\x3C/form\x3E\x27.nl()\x3B\r\n    } // if\r\n    if ($form-\x3Eclass1 != \x27\x27) echo \x27\x3C/div\x3E\x27.nl()\x3B\r\n    unset($form)\x3B\r\n    ob_start()\x3B\r\n    $ff_processor-\x3Esuicide()\x3B\r\n} // ff_die</code>
	</piece>
	<piece id="731">
		<package>FF</package>
		<name>ff_DisableFormTrace</name>
		<title>Disable tracing at view time</title>
		<type>Before Form</type>
		<description>Disables tracing for use as before form piece</description>
		<code>//+trace dis</code>
	</piece>
	<piece id="732">
		<package>FF</package>
		<name>ff_DisableSubmitTrace</name>
		<title>Disable tracing at submit time</title>
		<type>Begin Submit</type>
		<description>Disables tracing for use as begin submit piece</description>
		<code>//+trace dis</code>
	</piece>
	<piece id="733">
		<package>FF</package>
		<name>ff_dying</name>
		<title>Query live status</title>
		<description>Query if form is dying</description>
		<code>//+trace max none\r\nfunction ff_dying()\r\n{\r\n    global $ff_processor\x3B \r\n    return $ff_processor-\x3Edying\x3B\r\n} // ff_dying</code>
	</piece>
	<piece id="734">
		<package>FF</package>
		<name>ff_expString</name>
		<title>String export</title>
		<description>Export string function: escapes special characters in c-codes</description>
		<code>function ff_expString($text)\r\n{\r\n    return expstring($text)\x3B\r\n} // ff_expString</code>
	</piece>
	<piece id="735">
		<package>FF</package>
		<name>ff_getPageByNameX</name>
		<title>Get page # by element name</title>
		<description>Gets the page number by the name of an element. \r\nTypically used to redirect to a certain page in a before form piece \r\nas \r\n\r\n    $this-\x3Epage = ff_getPageByName(\x27elementname\x27)\x3B</description>
		<code>function ff_getPageByName($name)\r\n{\r\n    global $ff_processor\x3B\r\n    foreach($ff_processor-\x3Erows as $row)\r\n        if ($row-\x3Ename==$name)\r\n            return $row-\x3Epage\x3B\r\n    return null\x3B\r\n} // ff_getPageByName</code>
	</piece>
	<piece id="736">
		<package>FF</package>
		<name>ff_getParam</name>
		<title>Get GET/POST parameter</title>
		<description>Direct replacement for mosGetParam. ff_getParam will attempt to filter \r\nout parameters that are targeted to another form on the same page.</description>
		<code>function ff_getParam($name\x2C $default=null\x2C $mask=0)\r\n{\r\n    global $ff_request\x3B\r\n    if (substr($name\x2C0\x2C9)==\x27ff_param_\x27) {\r\n        if (!isset($ff_request[$name])) return $default\x3B\r\n        $val = $ff_request[$name]\x3B\r\n    } else {\r\n        if (!isset($_REQUEST[$name])) return $default\x3B\r\n        $val = $_REQUEST[$name]\x3B\r\n    } // if\r\n    $dotrim = ($mask \x26 FF_NOTRIM)==0\x3B\r\n    $dostrp = ($mask \x26 FF_ALLOWHTML)==0\x3B\r\n    $addsla = ($mask \x26 FF_ALLOWRAW)==0 \x26\x26 !get_magic_quotes_gpc()\x3B\r\n    $remsla = ($mask \x26 FF_ALLOWRAW)!=0 \x26\x26 get_magic_quotes_gpc()\x3B\r\n    if (is_array($val)) {\r\n        $cnt = count($val)\x3B\r\n        for ($v = 0\x3B $v \x3C $cnt\x3B $v++)\r\n            if (is_string($val[$v])) {\r\n                if ($dotrim) $val[$v] = trim($val[$v])\x3B\r\n                if ($dostrp) $val[$v] = strip_tags($val[$v])\x3B\r\n                if ($addsla) $val[$v] = addslashes($val[$v])\x3B\r\n                if ($remsla) $val[$v] = stripslashes($val[$v])\x3B\r\n            } // if\r\n    } else {\r\n        if (is_string($val)) {\r\n            if ($dotrim) $val = trim($val)\x3B\r\n            if ($dostrp) $val = strip_tags($val)\x3B\r\n            if ($addsla) $val = addslashes($val)\x3B\r\n            if ($remsla) $val = stripslashes($val)\x3B\r\n        } // if\r\n    } // if\r\n    return $val\x3B\r\n} // ff_getParam</code>
	</piece>
	<piece id="737">
		<package>FF</package>
		<name>ff_getSubmit</name>
		<title>Get submited data</title>
		<description>Returns submitdata either as scalar\x2C array or list. In case of list the values\r\nare returned as a string with the values concatenated by comma.\r\n\r\nExamples:\r\n\r\n// Get as scalar: Optionally pass a default value as second parameter.\r\n// If no default is provided\x2C it will return NULL if no value was submitted\r\n\r\n    $myval = ff_getSubmit(\x27myvar\x27)\x3B        // return NULL if not submitted\r\n\r\n    $myval = ff_getSubmit(\x27myvar\x27\x2C1)\x3B      // return 1 if not submitted\r\n\r\n    $myval = ff_getSubmit(\x27myvar\x27\x2C\x27foo\x27)\x3B  // return \x27foo\x27 if not submitted\r\n\r\n    ff_query(\r\n        \x22insert into #__mytable(id\x2C name) \x22.\r\n        \x22values (\x27\x22.\r\n            ff_getSubmit(\x27id\x27).\x22\x2C \x22.\r\n            ff_getSubmit(\x27name\x27\x2C\x27unknown\x27).\r\n        \x22\x27)\x22\r\n    )\x3B\r\n\r\n// Get as array: Pass FF_ARRAY as second Parameter\r\n\r\n    $myarr = $ff_getSubmit(\x27myarr\x27\x2C FF_ARRAY)\x3B\r\n\r\n    foreach ($myarr as $myval) ...\r\n\r\n// Get as list: Pass either FF_LIST\x2C FF_SLIST or FF_DLIST as 2nd parameter.\r\n\r\n    // FF_LIST will return numeric data unquoted and strings in single quotes:\r\n    //    1\x2C2\x2C\x27a\x27\x2C4\r\n\r\n    // FF_SLIST will return all data single quoted:\r\n    //    \x271\x27\x2C\x272\x27\x2C\x27a\x27\x2C\x274\x27\r\n\r\n    // FF_DLIST will return all data double quoted:\r\n    //    \x221\x22\x2C\x222\x22\x2C\x22a\x22\x2C\x224\x22\r\n\r\n    ff_query(\r\n        \x22delete from #__mytable \x22.\r\n        \x22where id in (\x22.ff_getSubmit(\x27itemlist\x27\x2CFF_LIST).\x22)\x22\r\n    )\x3B</description>
		<code>function ff_getSubmit($name\x2C $default=null)\r\n{\r\n    global $ff_processor\x3B\r\n\r\n    switch ((string)$default) {\r\n        case FF_ARRAY: $value = array()\x3B break\x3B\r\n        case FF_LIST : \r\n        case FF_SLIST:\r\n        case FF_DLIST: $value = \x27\x27\x3B break\x3B\r\n        default      : $value = $default\x3B\r\n    } // switch\r\n    foreach ($ff_processor-\x3Esubmitdata as $data)\r\n        if ($data[_FF_DATA_NAME]==$name) {\r\n            $q = \x27\x27\x3B\r\n            switch ((string)$default) {\r\n                case FF_ARRAY:\r\n                    $value[] = $data[_FF_DATA_VALUE]\x3B\r\n                    break\x3B\r\n                case FF_SLIST:\r\n                    $q = \x22\x27\x22\x3B\r\n                case FF_DLIST:\r\n                    if ($q==\x27\x27) $q = \x27\x22\x27\x3B\r\n                case FF_LIST:\r\n                    if ($q==\x27\x27 \x26\x26 !is_numeric($data[_FF_DATA_VALUE])) $q = \x22\x27\x22\x3B\r\n                    if ($value!=\x27\x27) $value.=\x27\x2C\x27\x3B\r\n                    $value .= $q.$data[_FF_DATA_VALUE].$q\x3B\r\n                    break\x3B\r\n                default:\r\n                    return $data[_FF_DATA_VALUE]\x3B\r\n            } // switch\r\n         } // if\r\n    return $value\x3B\r\n} // ff_getSubmit</code>
	</piece>
	<piece id="738">
		<package>FF</package>
		<name>ff_impString</name>
		<title>String import</title>
		<description>Import string function: unescapes c-coded characters of a string</description>
		<code>function ff_impString($text)\r\n{\r\n    return impstring($text)\x3B\r\n} // ff_impString</code>
	</piece>
	<piece id="739">
		<package>FF</package>
		<name>ff_InitLib</name>
		<title>Init Library</title>
		<type>Before Form</type>
		<description>A collection of useful functions for use in form pieces. \r\n\r\nInclude by: \r\n\r\n    $this-\x3EexecPieceByName(\x27ff_InitLib\x27)\x3B</description>
		<code>//+trace high none\r\nif (!defined(\x27FF_DIE\x27))                    $this-\x3EexecPieceByName(\x27ff_Constants\x27)\x3B\r\nif (!function_exists(\x27ff_expstring\x27))      $this-\x3EexecPieceByName(\x27ff_expstring\x27)\x3B\r\nif (!function_exists(\x27ff_makePageUrl\x27))    $this-\x3EexecPieceByName(\x27ff_makePageUrl\x27)\x3B\r\nif (!function_exists(\x27ff_makeFormUrl\x27))    $this-\x3EexecPieceByName(\x27ff_makeFormUrl\x27)\x3B\r\nif (!function_exists(\x27ff_makeSelfUrl\x27))    $this-\x3EexecPieceByName(\x27ff_makeSelfUrl\x27)\x3B\r\nif (!function_exists(\x27ff_die\x27))            $this-\x3EexecPieceByName(\x27ff_die\x27)\x3B\r\nif (!function_exists(\x27ff_dying\x27))          $this-\x3EexecPieceByName(\x27ff_dying\x27)\x3B\r\nif (!function_exists(\x27ff_redirect\x27))       $this-\x3EexecPieceByName(\x27ff_redirect\x27)\x3B\r\nif (!function_exists(\x27ff_redirectParent\x27)) $this-\x3EexecPieceByName(\x27ff_redirectParentX\x27)\x3B\r\nif (!function_exists(\x27ff_redirectPage\x27))   $this-\x3EexecPieceByName(\x27ff_redirectPage\x27)\x3B\r\nif (!function_exists(\x27ff_redirectForm\x27))   $this-\x3EexecPieceByName(\x27ff_redirectForm\x27)\x3B\r\nif (!function_exists(\x27ff_redirectSelf\x27))   $this-\x3EexecPieceByName(\x27ff_redirectSelf\x27)\x3B\r\nif (!function_exists(\x27ff_setChecked\x27))     $this-\x3EexecPieceByName(\x27ff_setCheckedX\x27)\x3B\r\nif (!function_exists(\x27ff_setSelected\x27))    $this-\x3EexecPieceByName(\x27ff_setSelectedX\x27)\x3B\r\nif (!function_exists(\x27ff_setValue\x27))       $this-\x3EexecPieceByName(\x27ff_setValueX\x27)\x3B\r\nif (!function_exists(\x27ff_getPageByName\x27))  $this-\x3EexecPieceByName(\x27ff_getPageByNameX\x27)\x3B\r\nif (!function_exists(\x27ff_getParam\x27))       $this-\x3EexecPieceByName(\x27ff_getParam\x27)\x3B\r\nif (!function_exists(\x27ff_getSubmit\x27))      $this-\x3EexecPieceByName(\x27ff_getSubmit\x27)\x3B\r\nif (!function_exists(\x27ff_impString\x27))      $this-\x3EexecPieceByName(\x27ff_impString\x27)\x3B\r\nif (!function_exists(\x27ff_expString\x27))      $this-\x3EexecPieceByName(\x27ff_expString\x27)\x3B\r\nif (!function_exists(\x27ff_securityImage\x27))  $this-\x3EexecPieceByName(\x27ff_securityImage\x27)\x3B\r\nif (!function_exists(\x27ff_select\x27))         $this-\x3EexecPieceByName(\x27ff_select\x27)\x3B\r\nif (!function_exists(\x27ff_selectValue\x27))    $this-\x3EexecPieceByName(\x27ff_selectValue\x27)\x3B\r\nif (!function_exists(\x27ff_query\x27))          $this-\x3EexecPieceByName(\x27ff_query\x27)\x3B\r\nif (!function_exists(\x27ff_markdown\x27))       $this-\x3EexecPieceByName(\x27ff_markdown\x27)\x3B</code>
	</piece>
	<piece id="740">
		<package>FF</package>
		<name>ff_makeFormUrl</name>
		<title>Make URL to other form</title>
		<description>Redirects to another facile form. \r\n\r\nCall: \r\n\r\n    $url = ff_makeFormUrl($name\x2C $params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n    $url = ff_makeFormUrl(\r\n       \x27OtherForm\x27\x2C \r\n       \x27\x26ff_param_email=\x27.urlencode($email)\r\n    )\x3B</description>
		<code>function ff_makeFormUrl($name\x2C $params=\x27\x27)\r\n{\r\n    global $ff_processor\x2C $ff_otherparams\x3B\r\n    $url = \x27\x27\x3B\r\n    switch ($ff_processor-\x3Erunmode) {\r\n        case 2: // preview\r\n        case 1: // backend\r\n            $url .= \x27administrator/index2.php?option=com_breezingforms\x26act=run\x27.\r\n                    \x27\x26ff_name=\x27.urlencode($name)\x3B\r\n            if ($ff_processor-\x3Einframe) $url .= \x27\x26ff_frame=1\x27\x3B\r\n            if ($ff_processor-\x3Eborder) $url .= \x27\x26ff_border=1\x27\x3B\r\n            break\x3B\r\n        default: // frontend\r\n            $url .= \x27index.php?ff_name=\x27.urlencode($name)\x3B\r\n            if ($ff_otherparams[\x27option\x27] == \x27com_breezingforms\x27) {\r\n                reset($ff_otherparams)\x3B\r\n                while (list($prop\x2C $val) = each($ff_otherparams))\r\n                    $url .= \x27\x26\x27.urlencode($prop).\x27=\x27.urlencode($val)\x3B\r\n            } else\r\n                $url .= \x27\x26option=com_breezingforms\x27\x3B\r\n            if ($ff_processor-\x3Etarget \x3E 1) $url .= \x27\x26ff_target=\x27.$ff_processor-\x3Etarget\x3B\r\n            if ($ff_processor-\x3Einframe) $url .= \x27\x26ff_frame=1\x27\x3B\r\n            if ($ff_processor-\x3Eborder) $url .= \x27\x26ff_border=1\x27\x3B\r\n            if ($ff_processor-\x3Ealign !=1) $url .= \x27\x26ff_align=\x27.$ff_processor-\x3Ealign\x3B\r\n            if ($ff_processor-\x3Etop\x3E0) $url .= \x27\x26ff_top=\x27.$ff_processor-\x3Etop\x3B\r\n    } // switch\r\n    return ff_makePageUrl($url. $params)\x3B\r\n} // ff_makeFormUrl</code>
	</piece>
	<piece id="741">
		<package>FF</package>
		<name>ff_makePageUrl</name>
		<title>Make URL to other page</title>
		<description>Builds an URL to another mambo page\r\n\r\nCall: \r\n\r\n    $url = ff_makePageUrl($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n    $url = ff_makePageUrl(\r\n        \x27index.php?option=com_content\x26task=blogsection\x26id=0\x26Itemid=39\x27\r\n    )\x3B</description>
		<code>function ff_makePageUrl($params=\x27\x27)\r\n{\r\n    $url = \x27{mossite}\x27\x3B\r\n    if ($params != \x27\x27) {\r\n        $len = strlen($url)\x3B\r\n        if ($len \x3E 0 \x26\x26 $url{$len-1} != \x27/\x27) $url .= \x27/\x27\x3B\r\n        $url .= $params\x3B\r\n    } // if\r\n    return $url\x3B\r\n} // ff_makePageUrl</code>
	</piece>
	<piece id="742">
		<package>FF</package>
		<name>ff_makeSelfUrl</name>
		<title>Make URL to same form</title>
		<description>Make an URL to the same form. \r\n\r\nCall: \r\n\r\n    $url = ff_makeSelfUrl($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n    $url = ff_makeSelfUrl(\x27\x26ff_param_email=\x27.urlencode($email))\x3B</description>
		<code>function ff_makeSelfUrl($params=\x27\x27)\r\n{\r\n    global $ff_processor\x3B\r\n    return ff_makeFormUrl($ff_processor-\x3Eformrow-\x3Ename\x2C $params)\x3B\r\n} // ff_makeSelfUrl</code>
	</piece>
	<piece id="743">
		<package>FF</package>
		<name>ff_markdown</name>
		<title>Markdown tagging for facile forms</title>
		<description>Convert text marked up by \x27Markdown\x27 into HTML.\r\n\r\nInclude by: \r\n\r\n    if (!function_exists(\x27ff_markdown\x27)) $this-\x3EexecPieceByName(\x27ff_markdown\x27)\x3B\r\n\r\nCall syntax: \r\n\r\n    $html = ff_markdown($text)\x3B</description>
		<code>function ff_markdown($text)\r\n{\r\n    global $ff_processor\x2C $ff_compath\x3B\r\n\r\n    // do the standard Markdown processing first\r\n    if (!function_exists(\x27Markdown\x27)) require_once($ff_compath.\x27/markdown.php\x27)\x3B\r\n    $html = Markdown($text)\x3B\r\n\r\n    // now fix \x3Ca href...\x3E tags\r\n    $html = preg_replace(\r\n        \x22/(\x5C\x5C\x3Ca href=[^\x5C\x5C\x3E]+)/i\x22\x2C    // search pattern\r\n        \x22\x5C${1} target=\x5C\x22_parent\x5C\x22\x22\x2C  // replacement\r\n        $html\r\n    )\x3B       \r\n    return $html\x3B\r\n} // ff_markdown</code>
	</piece>
	<piece id="744">
		<package>FF</package>
		<name>ff_query</name>
		<title>Non-select queries against db</title>
		<description>Execute a simple db query.\r\n\r\nInclude by one of:\r\n\r\n    $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n    $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n    if (!function_exists(\x27ff_query\x27)) $this-\x3EexecPieceByName(\x27ff_query\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n    [$newid = ] ff_query($sql [\x2C $insert = 0])\x3B\r\n\r\n    $sql:    Sql statement to call\r\n    $insert: 1 = return key of auto column when inserting rows\r\n    $newid:  The key of the new row.</description>
		<code>function ff_query($sql\x2C $insert=false\x2C $error=FF_DIE)\r\n{\r\n    global $ff_processor\x3B\r\n    $database = JFactory::getDBO()\x3B\r\n    if ($ff_processor-\x3Edying \x26\x26 $error!=FF_IGNOREDIE) return -1\x3B\r\n    $database-\x3EsetQuery($sql)\x3B\r\n    $database-\x3Equery()\x3B\r\n    if ($database-\x3EgetErrorNum()) {\r\n        $dienow = $error==FF_DIE\x3B\r\n        $error = $database-\x3Estderr()\x3B\r\n        if ($dienow) ff_die($error)\x3B\r\n    } else {\r\n        $error = null\x3B\r\n        if ($insert) return $database-\x3Einsertid()\x3B\r\n    } // if\r\n    return 0\x3B\r\n} // ff_query</code>
	</piece>
	<piece id="745">
		<package>FF</package>
		<name>ff_redirect</name>
		<title>Basic redirection</title>
		<description>Basic redirection routine supporting multiple targets and methods.\r\n\r\nCall:\r\n \r\nff_redirect($url [\x2C $target=\x27self\x27 \x2C $method=\x27post\x27])\r\n\r\n    $url    = The url to redirect to including the parameters appended.\r\n\r\n    $target = \x27top\x27\x2C \x27parent\x27\x2C \x27self\x27 or \x27blank\x27\r\n\r\n              \x27top\x27    = redirect to the top browser window\r\n              \x27parent\x27 = redirect to the parent frame\r\n              \x27self\x27   = redirect in the same frame (the default)\r\n              \x27blank\x27  = redirect to a new browser window \r\n                         (blank works with post method only)\r\n\r\n    $method = \x27post\x27 or \x27get\x27. The default is \x27post\x27.\r\n\r\n    Example:\r\n\r\n       ff_redirect(\r\n          \x27http://mysite.net/index.php?option=xxx\x26Itemid=33\x27\x2C\r\n          \x27top\x27\r\n       )\x3B</description>
		<code>function ff_redirect($url\x2C $target=\x27self\x27\x2C $method=\x27post\x27)\r\n{\r\n    global $ff_processor\x2C $ff_request\x3B\r\n    if ($ff_processor-\x3Edying) return\x3B\r\n\r\n    ob_end_clean()\x3B\r\n    switch (strtolower($method)) {\r\n        case \x27get\x27: {\r\n            switch (strtolower($target)) {\r\n                case \x27top\x27   :\r\n                case \x27parent\x27: break\x3B\r\n                default      : $target = \x27document\x27\x3B\r\n            } // switch\r\n            echo \x27\x3Cscript type=\x22text/javascript\x22\x3E\x27.nl().\r\n                 \x27\x3C!--\x27.nl().\r\n                 \x22onload=function() { \x22.$target.\x22.location.href=\x27\x22.$url.\x22\x27\x3B }\x22.nl().\r\n                 \x27--\x3E\x27.nl().\r\n                 \x27\x3C/script\x3E\x27.nl().\r\n                 \x27\x3C/body\x3E\x27.nl()\x3B\r\n            break\x3B\r\n        } // url\r\n        default: { // post\r\n            $pos = strpos($url\x2C\x27?\x27)\x3B\r\n            $ff_request = array()\x3B\r\n            if ($pos === false)\r\n                $action = $url\x3B\r\n            else {\r\n                $action = substr($url\x2C0\x2C$pos)\x3B\r\n                addRequestParams(substr($url\x2C $pos+1))\x3B\r\n            } // if\r\n            switch (strtolower($target)) {\r\n                case \x27blank\x27 : $target = \x27 target=\x22_blank\x22\x27\x3B  break\x3B\r\n                case \x27top\x27   : $target = \x27 target=\x22_top\x22\x27\x3B    break\x3B\r\n                case \x27parent\x27: $target = \x27 target=\x22_parent\x22\x27\x3B break\x3B\r\n                default      : $target = \x27 target=\x22_self\x22\x27\x3B\r\n            } // switch\r\n            echo \x27\x3Cscript language=\x22javascript\x22 type=\x22text/javascript\x22\x3E\x27.nl().\r\n                 \x27\x3C!--\x27.nl().\r\n                 \x27onload = function() { document.ff_redirect.submit()\x3B }\x27.nl().\r\n                 \x27--\x3E\x27.nl().\r\n                 \x27\x3C/script\x3E\x27.nl().\r\n                 \x27\x3Cform action=\x22\x27.$action.\x27\x22 \x27.\r\n                  \x27method=\x22post\x22 \x27.\r\n                  \x27name=\x22ff_redirect\x22 id=\x22ff_redirect\x22 \x27.\r\n                  \x27enctype=\x22multipart/form-data\x22\x27.\r\n                  $target.\r\n                 \x27\x3E\x27.nl()\x3B\r\n            while (list($prop\x2C $val) = each($ff_request))\r\n                echo \x27\x3Cinput type=\x22hidden\x22 name=\x22\x27.$prop.\x27\x22 \x27.\r\n                            \x27value=\x22\x27.htmlentities(urldecode($val)).\x27\x22/\x3E\x27.nl()\x3B\r\n            echo \x27\x3C/form\x3E\x27.nl().\r\n                 \x27\x3C/body\x3E\x27.nl()\x3B\r\n        } // post\r\n    } // switch\r\n    exit\x3B\r\n} // ff_redirect</code>
	</piece>
	<piece id="746">
		<package>FF</package>
		<name>ff_redirectForm</name>
		<title>Redirect to other form</title>
		<description>Redirects to another facile form. \r\n\r\nCall: \r\n\r\n    ff_redirectForm($name\x2C $params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n    ff_redirectForm(\r\n        $this\x2C \r\n       \x27SecondForm\x27\x2C \r\n       \x27\x26ff_param_email=\x27.urlencode($email)\r\n    )\x3B</description>
		<code>function ff_redirectForm($name\x2C $params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n    ff_redirectParent(ff_makeFormUrl($name\x2C $params)\x2C $method)\x3B\r\n} // ff_redirectForm</code>
	</piece>
	<piece id="747">
		<package>FF</package>
		<name>ff_redirectPage</name>
		<title>Redirect to other page</title>
		<description>Redirects to another mambo page. \r\n\r\nCall: \r\n\r\n    ff_redirectPage($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n    ff_redirectPage(\r\n        \x27index.php?option=com_content\x26task=blogsection\x26id=0\x26Itemid=39\x27\r\n    )\x3B</description>
		<code>function ff_redirectPage($params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n    ff_redirectParent(ff_makePageUrl($params)\x2C $method)\x3B\r\n} // ff_redirectPage</code>
	</piece>
	<piece id="748">
		<package>FF</package>
		<name>ff_redirectParentX</name>
		<title>Redirect to parent window</title>
		<description>Redirects to the parent window when runing in iframe\x2C otherwise to self. \r\n\r\nff_redirectParent($url [\x2C $method=\x27post\x27])\r\n\r\n    $url    = The url to redirect to including the parameters appended.\r\n\r\n    $method = \x27post\x27 or \x27url\x27. The default is \x27post\x27.\r\n\r\n    Example:\r\n\r\n       ff_redirectParent(\r\n          \x27http://mysite.net/index.php?option=xxx\x26Itemid=33\x27\x2C\r\n          \x27url\x27\r\n       )\x3B</description>
		<code>function ff_redirectParent($url\x2C $method = \x27post\x27)\r\n{\r\n    global $ff_processor\x3B\r\n    if ($ff_processor-\x3Einframe) $target = \x27parent\x27\x3B else $target = \x27self\x27\x3B \r\n    ff_redirect($url\x2C $target\x2C $method)\x3B\r\n} // ff_redirectParent</code>
	</piece>
	<piece id="749">
		<package>FF</package>
		<name>ff_redirectSelf</name>
		<title>Redirect to same form</title>
		<description>Redirects to the same form. \r\n\r\nCall: \r\n\r\n    ff_redirectSelf($params = \x27\x27)\x3B\r\n\r\nExample:\r\n\r\n    ff_redirectSelf(\x27\x26ff_param_email=\x27.urlencode($email))\x3B</description>
		<code>function ff_redirectSelf($params=\x27\x27\x2C $method=\x27post\x27)\r\n{\r\n    ff_redirectParent(ff_makeSelfUrl($params)\x2C $method)\x3B\r\n} // ff_redirectSelf</code>
	</piece>
	<piece id="750">
		<package>FF</package>
		<name>ff_securityImage</name>
		<title>Security Image</title>
		<description>Create code to display the security image</description>
		<code>global $ff_seccode\x3B\r\n\r\nif (!isset($this-\x3Erecord_id)) { $ff_seccode = null\x3B }\r\n\r\nfunction ff_securityImage()\r\n{\r\n    global $ff_comsite\x2C $ff_seccode\x3B\r\n    if (!isset($ff_seccode)) { \r\n        mt_srand((double)microtime()*1000000)\x3B\r\n        $ff_seccode = mt_rand(10000\x2C 99999)\x3B\r\n        JFactory::getSession()-\x3Eset(\x27ff_seccode\x27\x2C $ff_seccode)\x3B\r\n    } // if\r\n\r\n    return \x27\x3Cimg src=\x22\x27.JURI::root().\x27ff_secimage.php?option=com_breezingforms\x26showSecImage=true\x22 title=\x22\x22 alt=\x22\x22 /\x3E\x27\x3B\r\n} // ff_securityImage</code>
	</piece>
	<piece id="751">
		<package>FF</package>
		<name>ff_select</name>
		<title>Select rows from db</title>
		<description>Execute a select query\r\n\r\nInclude by one of:\r\n\r\n    $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n    $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n    if (!function_exists(\x27ff_select\x27)) $this-\x3EexecPieceByName(\x27ff_select\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n    $rows = ff_select($sql)\x3B\r\n\r\n    $sql:    Sql SELECT-statement to call\r\n    $rows:   List of row objects</description>
		<code>function ff_select($sql\x2C $error=FF_DIE)\r\n{\r\n    $database = JFactory::getDBO()\x3B\r\n    $database-\x3EsetQuery($sql)\x3B\r\n    $rows = $database-\x3EloadObjectList()\x3B\r\n    if ($database-\x3EgetErrorNum()) {\r\n        $dienow = $error==FF_DIE\x3B\r\n        $error = $database-\x3Estderr()\x3B\r\n        $rows = array()\x3B\r\n        if ($dienow) ff_die($error)\x3B\r\n    } else\r\n        $error = null\x3B\r\n    return $rows\x3B\r\n} // ff_select</code>
	</piece>
	<piece id="752">
		<package>FF</package>
		<name>ff_selectValue</name>
		<title>Select single value from db</title>
		<description>Execute query to read a single value\r\n\r\nInclude by one of:\r\n\r\n    $this-\x3EexecPieceByName(\x27ff_InitUtilities\x27)\x3B\r\n    $this-\x3EexecPieceByName(\x27ff_SubmitUtilities\x27)\x3B\r\n    if (!function_exists(\x27ff_selectValue\x27)) $this-\x3EexecPieceByName(\x27ff_selectValue\x27)\x3B\r\n\r\nCall syntax:\r\n\r\n    $value = ff_selectValue($sql)\x3B\r\n\r\n    $sql:    Sql SELECT-statement to call\r\n    $value:  The value returned by the database</description>
		<code>function ff_selectValue($sql\x2C $def=null\x2C $error=FF_DIE)\r\n{\r\n    $database = JFactory::getDBO()\x3B\r\n    $database-\x3EsetQuery($sql)\x3B\r\n    $value = $database-\x3EloadResult()\x3B\r\n    if ($database-\x3EgetErrorNum()) {\r\n        $dienow = $error==FF_DIE\x3B\r\n        $error = $database-\x3Estderr()\x3B\r\n        if ($dienow) ff_die($error)\x3B\r\n    } else {\r\n        $error = null\x3B\r\n        if ($value) return $value\x3B\r\n    } // if\r\n    return $def\x3B\r\n} // ff_selectValue</code>
	</piece>
	<piece id="753">
		<package>FF</package>
		<name>ff_setCheckedX</name>
		<title>Set checkbox/radiobutton checked</title>
		<description>Set a radio button or checkbox checked. \r\n\r\nCall: \r\n\r\n    ff_setChecked(\x27name\x27\x2C \x27value\x27)\x3B</description>
		<code>function ff_setChecked($name\x2C $value)\r\n{\r\n    global $ff_processor\x3B\r\n    for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n        $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n        if ($row-\x3Ename==$name \x26\x26 $row-\x3Edata1==$value)\r\n            $row-\x3Eflag1 = 1\x3B\r\n        unset($row)\x3B\r\n    } // for\r\n} // ff_setChecked</code>
	</piece>
	<piece id="754">
		<package>FF</package>
		<name>ff_setSelectedX</name>
		<title>Set a select list option to *selected*</title>
		<description>Sets a select list option to selected. \r\n\r\nCall: \r\n\r\n    ff_setSelected(\x27name\x27\x2C \x27value\x27)\x3B</description>
		<code>function ff_setSelected($name\x2C $value)\r\n{\r\n    global $ff_processor\x3B\r\n    for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n        $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n        if ($row-\x3Ename==$name)\r\n            $row-\x3Edata2 =\r\n                preg_replace(\r\n                    \x27/(^|\x5Cr\x5Cn|\x5Cn)(0|1)\x3B([^\x3B]*)\x3B(\x27.$value.\x27)($|\x5Cr\x5Cn|\x5Cn)/\x27\x2C\r\n                    \x27${1}1\x3B${3}\x3B${4}${5}\x27\x2C\r\n                    $row-\x3Edata2\r\n                )\x3B\r\n        unset($row)\x3B\r\n    } // for\r\n} // ff_setSelected</code>
	</piece>
	<piece id="755">
		<package>FF</package>
		<name>ff_setValueX</name>
		<title>Set text\x2C textarea\x2C hidden value</title>
		<description>Set value of a Static Text\x2C Text\x2C Textarea or Hidden Input. \r\n\r\nCall: \r\n\r\n    ff_setValue(\x27name\x27\x2C \x27value\x27)\x3B</description>
		<code>function ff_setValue($name\x2C $value)\r\n{\r\n    global $ff_processor\x3B\r\n    for ($r = 0\x3B $r \x3C $ff_processor-\x3Erowcount\x3B $r++) {\r\n        $row =\x26 $ff_processor-\x3Erows[$r]\x3B\r\n        if ($row-\x3Ename==$name)\r\n            $row-\x3Edata1 = $value\x3B\r\n        unset($row)\x3B\r\n    } // for\r\n} // ff_setValue</code>
	</piece>
	<piece id="756">
		<package>FF</package>
		<name>Markdown</name>
		<title>Original Markdown Processor</title>
		<description>Converts text marked up by \x27Markdown\x27 into HTML.\r\n\r\nPlease use ff_markdown() in forms instead of Markdown()</description>
		<code>#\r\n# Markdown  -  A text-to-HTML conversion tool for web writers\r\n#\r\n# Copyright (c) 2004-2005 John Gruber\r\n# \x3Chttp://daringfireball.net/projects/markdown/\x3E\r\n#\r\n# Copyright (c) 2004-2005 Michel Fortin - PHP Port\r\n# \x3Chttp://www.michelf.com/projects/php-markdown/\x3E\r\n#\r\n\r\nglobal	$MarkdownPHPVersion\x2C $MarkdownSyntaxVersion\x2C\r\n		$md_empty_element_suffix\x2C $md_tab_width\x2C\r\n		$md_nested_brackets_depth\x2C $md_nested_brackets\x2C\r\n		$md_escape_table\x2C $md_backslash_escape_table\x2C\r\n		$md_list_level\x3B\r\n\r\n$MarkdownPHPVersion    = \x271.0.1b\x27\x3B # Mon 6 Jun 2005\r\n$MarkdownSyntaxVersion = \x271.0.1\x27\x3B  # Sun 12 Dec 2004\r\n\r\n\r\n#\r\n# Global default settings:\r\n#\r\n$md_empty_element_suffix = \x22 /\x3E\x22\x3B     # Change to \x22\x3E\x22 for HTML output\r\n$md_tab_width = 4\x3B\r\n\r\n#\r\n# WordPress settings:\r\n#\r\n$md_wp_posts    = true\x3B  # Set to false to remove Markdown from posts.\r\n$md_wp_comments = true\x3B  # Set to false to remove Markdown from comments.\r\n\r\n\r\n# -- WordPress Plugin Interface -----------------------------------------------\r\n/*\r\nPlugin Name: Markdown\r\nPlugin URI: http://www.michelf.com/projects/php-markdown/\r\nDescription: \x3Ca href=\x22http://daringfireball.net/projects/markdown/syntax\x22\x3EMarkdown syntax\x3C/a\x3E allows you to write using an easy-to-read\x2C easy-to-write plain text format. Based on the original Perl version by \x3Ca href=\x22http://daringfireball.net/\x22\x3EJohn Gruber\x3C/a\x3E. \x3Ca href=\x22http://www.michelf.com/projects/php-markdown/\x22\x3EMore...\x3C/a\x3E\r\nVersion: 1.0.1b\r\nAuthor: Michel Fortin\r\nAuthor URI: http://www.michelf.com/\r\n*/\r\nif (isset($wp_version)) {\r\n	# More details about how it works here:\r\n	# \x3Chttp://www.michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/\x3E\r\n\r\n	# Post content and excerpts\r\n	if ($md_wp_posts) {\r\n		remove_filter(\x27the_content\x27\x2C  \x27wpautop\x27)\x3B\r\n		remove_filter(\x27the_excerpt\x27\x2C  \x27wpautop\x27)\x3B\r\n		add_filter(\x27the_content\x27\x2C     \x27Markdown\x27\x2C 6)\x3B\r\n		add_filter(\x27get_the_excerpt\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n		add_filter(\x27get_the_excerpt\x27\x2C \x27trim\x27\x2C 7)\x3B\r\n		add_filter(\x27the_excerpt\x27\x2C     \x27md_add_p\x27)\x3B\r\n		add_filter(\x27the_excerpt_rss\x27\x2C \x27md_strip_p\x27)\x3B\r\n\r\n		remove_filter(\x27content_save_pre\x27\x2C  \x27balanceTags\x27\x2C 50)\x3B\r\n		remove_filter(\x27excerpt_save_pre\x27\x2C  \x27balanceTags\x27\x2C 50)\x3B\r\n		add_filter(\x27the_content\x27\x2C  	  \x27balanceTags\x27\x2C 50)\x3B\r\n		add_filter(\x27get_the_excerpt\x27\x2C \x27balanceTags\x27\x2C 9)\x3B\r\n\r\n		function md_add_p($text) {\r\n			if (strlen($text) == 0) return\x3B\r\n			if (strcasecmp(substr($text\x2C -3)\x2C \x27\x3Cp\x3E\x27) == 0) return $text\x3B\r\n			return \x27\x3Cp\x3E\x27.$text.\x27\x3C/p\x3E\x27\x3B\r\n		}\r\n		function md_strip_p($t) { return preg_replace(\x27{\x3C/?[pP]\x3E}\x27\x2C \x27\x27\x2C $t)\x3B }\r\n	}\r\n\r\n	# Comments\r\n	if ($md_wp_comments) {\r\n		remove_filter(\x27comment_text\x27\x2C \x27wpautop\x27)\x3B\r\n		remove_filter(\x27comment_text\x27\x2C \x27make_clickable\x27)\x3B\r\n		add_filter(\x27pre_comment_content\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n		add_filter(\x27pre_comment_content\x27\x2C \x27md_hide_tags\x27\x2C 8)\x3B\r\n		add_filter(\x27pre_comment_content\x27\x2C \x27md_show_tags\x27\x2C 12)\x3B\r\n		add_filter(\x27get_comment_text\x27\x2C    \x27Markdown\x27\x2C 6)\x3B\r\n		add_filter(\x27get_comment_excerpt\x27\x2C \x27Markdown\x27\x2C 6)\x3B\r\n		add_filter(\x27get_comment_excerpt\x27\x2C \x27md_strip_p\x27\x2C 7)\x3B\r\n\r\n		global $md_hidden_tags\x3B\r\n		$md_hidden_tags = array(\r\n			\x27\x3Cp\x3E\x27	=\x3E md5(\x27\x3Cp\x3E\x27)\x2C		\x27\x3C/p\x3E\x27	=\x3E md5(\x27\x3C/p\x3E\x27)\x2C\r\n			\x27\x3Cpre\x3E\x27	=\x3E md5(\x27\x3Cpre\x3E\x27)\x2C	\x27\x3C/pre\x3E\x27=\x3E md5(\x27\x3C/pre\x3E\x27)\x2C\r\n			\x27\x3Col\x3E\x27	=\x3E md5(\x27\x3Col\x3E\x27)\x2C		\x27\x3C/ol\x3E\x27	=\x3E md5(\x27\x3C/ol\x3E\x27)\x2C\r\n			\x27\x3Cul\x3E\x27	=\x3E md5(\x27\x3Cul\x3E\x27)\x2C		\x27\x3C/ul\x3E\x27	=\x3E md5(\x27\x3C/ul\x3E\x27)\x2C\r\n			\x27\x3Cli\x3E\x27	=\x3E md5(\x27\x3Cli\x3E\x27)\x2C		\x27\x3C/li\x3E\x27	=\x3E md5(\x27\x3C/li\x3E\x27)\x2C\r\n			)\x3B\r\n\r\n		function md_hide_tags($text) {\r\n			global $md_hidden_tags\x3B\r\n			return str_replace(array_keys($md_hidden_tags)\x2C\r\n								array_values($md_hidden_tags)\x2C $text)\x3B\r\n		}\r\n		function md_show_tags($text) {\r\n			global $md_hidden_tags\x3B\r\n			return str_replace(array_values($md_hidden_tags)\x2C\r\n								array_keys($md_hidden_tags)\x2C $text)\x3B\r\n		}\r\n	}\r\n}\r\n\r\n\r\n# -- bBlog Plugin Info --------------------------------------------------------\r\nfunction identify_modifier_markdown() {\r\n	global $MarkdownPHPVersion\x3B\r\n	return array(\r\n		\x27name\x27			=\x3E \x27markdown\x27\x2C\r\n		\x27type\x27			=\x3E \x27modifier\x27\x2C\r\n		\x27nicename\x27		=\x3E \x27Markdown\x27\x2C\r\n		\x27description\x27	=\x3E \x27A text-to-HTML conversion tool for web writers\x27\x2C\r\n		\x27authors\x27		=\x3E \x27Michel Fortin and John Gruber\x27\x2C\r\n		\x27licence\x27		=\x3E \x27GPL\x27\x2C\r\n		\x27version\x27		=\x3E $MarkdownPHPVersion\x2C\r\n		\x27help\x27			=\x3E \x27\x3Ca href=\x22http://daringfireball.net/projects/markdown/syntax\x22\x3EMarkdown syntax\x3C/a\x3E allows you to write using an easy-to-read\x2C easy-to-write plain text format. Based on the original Perl version by \x3Ca href=\x22http://daringfireball.net/\x22\x3EJohn Gruber\x3C/a\x3E. \x3Ca href=\x22http://www.michelf.com/projects/php-markdown/\x22\x3EMore...\x3C/a\x3E\x27\r\n	)\x3B\r\n}\r\n\r\n# -- Smarty Modifier Interface ------------------------------------------------\r\nfunction smarty_modifier_markdown($text) {\r\n	return Markdown($text)\x3B\r\n}\r\n\r\n# -- Textile Compatibility Mode -----------------------------------------------\r\n# Rename this file to \x22classTextile.php\x22 and it can replace Textile anywhere.\r\nif (strcasecmp(substr(__FILE__\x2C -16)\x2C \x22classTextile.php\x22) == 0) {\r\n	# Try to include PHP SmartyPants. Should be in the same directory.\r\n	@include_once \x27smartypants.php\x27\x3B\r\n	# Fake Textile class. It calls Markdown instead.\r\n	class Textile {\r\n		function TextileThis($text\x2C $lite=\x27\x27\x2C $encode=\x27\x27\x2C $noimage=\x27\x27\x2C $strict=\x27\x27) {\r\n			if ($lite == \x27\x27 \x26\x26 $encode == \x27\x27)   $text = Markdown($text)\x3B\r\n			if (function_exists(\x27SmartyPants\x27)) $text = SmartyPants($text)\x3B\r\n			return $text\x3B\r\n		}\r\n	}\r\n}\r\n\r\n\r\n\r\n#\r\n# Globals:\r\n#\r\n\r\n# Regex to match balanced [brackets].\r\n# Needed to insert a maximum bracked depth while converting to PHP.\r\n$md_nested_brackets_depth = 6\x3B\r\n$md_nested_brackets =\r\n	str_repeat(\x27(?\x3E[^\x5C[\x5C]]+|\x5C[\x27\x2C $md_nested_brackets_depth).\r\n	str_repeat(\x27\x5C])*\x27\x2C $md_nested_brackets_depth)\x3B\r\n\r\n# Table of hash values for escaped characters:\r\n$md_escape_table = array(\r\n	\x22\x5C\x5C\x22 =\x3E md5(\x22\x5C\x5C\x22)\x2C\r\n	\x22`\x22 =\x3E md5(\x22`\x22)\x2C\r\n	\x22*\x22 =\x3E md5(\x22*\x22)\x2C\r\n	\x22_\x22 =\x3E md5(\x22_\x22)\x2C\r\n	\x22{\x22 =\x3E md5(\x22{\x22)\x2C\r\n	\x22}\x22 =\x3E md5(\x22}\x22)\x2C\r\n	\x22[\x22 =\x3E md5(\x22[\x22)\x2C\r\n	\x22]\x22 =\x3E md5(\x22]\x22)\x2C\r\n	\x22(\x22 =\x3E md5(\x22(\x22)\x2C\r\n	\x22)\x22 =\x3E md5(\x22)\x22)\x2C\r\n	\x22\x3E\x22 =\x3E md5(\x22\x3E\x22)\x2C\r\n	\x22#\x22 =\x3E md5(\x22#\x22)\x2C\r\n	\x22+\x22 =\x3E md5(\x22+\x22)\x2C\r\n	\x22-\x22 =\x3E md5(\x22-\x22)\x2C\r\n	\x22.\x22 =\x3E md5(\x22.\x22)\x2C\r\n	\x22!\x22 =\x3E md5(\x22!\x22)\r\n)\x3B\r\n# Create an identical table but for escaped characters.\r\n$md_backslash_escape_table\x3B\r\nforeach ($md_escape_table as $key =\x3E $char)\r\n	$md_backslash_escape_table[\x22\x5C\x5C$key\x22] = $char\x3B\r\n\r\n\r\nfunction Markdown($text) {\r\n#\r\n# Main function. The order in which other subs are called here is\r\n# essential. Link and image substitutions need to happen before\r\n# _EscapeSpecialCharsWithinTagAttributes()\x2C so that any *\x27s or _\x27s in the \x3Ca\x3E\r\n# and \x3Cimg\x3E tags get encoded.\r\n#\r\n	# Clear the global hashes. If we don\x27t clear these\x2C you get conflicts\r\n	# from other articles when generating a page which contains more than\r\n	# one article (e.g. an index page that shows the N most recent\r\n	# articles):\r\n	global $md_urls\x2C $md_titles\x2C $md_html_blocks\x3B\r\n	$md_urls = array()\x3B\r\n	$md_titles = array()\x3B\r\n	$md_html_blocks = array()\x3B\r\n\r\n	# Standardize line endings:\r\n	#   DOS to Unix and Mac to Unix\r\n	$text = str_replace(array(\x22\x5Cr\x5Cn\x22\x2C \x22\x5Cr\x22)\x2C \x22\x5Cn\x22\x2C $text)\x3B\r\n\r\n	# Make sure $text ends with a couple of newlines:\r\n	$text .= \x22\x5Cn\x5Cn\x22\x3B\r\n\r\n	# Convert all tabs to spaces.\r\n	$text = _Detab($text)\x3B\r\n\r\n	# Strip any lines consisting only of spaces and tabs.\r\n	# This makes subsequent regexen easier to write\x2C because we can\r\n	# match consecutive blank lines with /\x5Cn+/ instead of something\r\n	# contorted like /[ \x5Ct]*\x5Cn+/ .\r\n	$text = preg_replace(\x27/^[ \x5Ct]+$/m\x27\x2C \x27\x27\x2C $text)\x3B\r\n\r\n	# Turn block-level HTML blocks into hash entries\r\n	$text = _HashHTMLBlocks($text)\x3B\r\n\r\n	# Strip link definitions\x2C store in hashes.\r\n	$text = _StripLinkDefinitions($text)\x3B\r\n\r\n	$text = _RunBlockGamut($text)\x3B\r\n\r\n	$text = _UnescapeSpecialChars($text)\x3B\r\n\r\n	return $text . \x22\x5Cn\x22\x3B\r\n}\r\n\r\n\r\nfunction _StripLinkDefinitions($text) {\r\n#\r\n# Strips link definitions from text\x2C stores the URLs and titles in\r\n# hash references.\r\n#\r\n	global $md_tab_width\x3B\r\n	$less_than_tab = $md_tab_width - 1\x3B\r\n\r\n	# Link defs are in the form: ^[id]: url \x22optional title\x22\r\n	$text = preg_replace_callback(\x27{\r\n						^[ ]{0\x2C\x27.$less_than_tab.\x27}\x5C[(.+)\x5C]:	# id = $1\r\n						  [ \x5Ct]*\r\n						  \x5Cn?				# maybe *one* newline\r\n						  [ \x5Ct]*\r\n						\x3C?(\x5CS+?)\x3E?			# url = $2\r\n						  [ \x5Ct]*\r\n						  \x5Cn?				# maybe one newline\r\n						  [ \x5Ct]*\r\n						(?:\r\n							(?\x3C=\x5Cs)			# lookbehind for whitespace\r\n							[\x22(]\r\n							(.+?)			# title = $3\r\n							[\x22)]\r\n							[ \x5Ct]*\r\n						)?	# title is optional\r\n						(?:\x5Cn+|\x5CZ)\r\n		}xm\x27\x2C\r\n		\x27_StripLinkDefinitions_callback\x27\x2C\r\n		$text)\x3B\r\n	return $text\x3B\r\n}\r\nfunction _StripLinkDefinitions_callback($matches) {\r\n	global $md_urls\x2C $md_titles\x3B\r\n	$link_id = strtolower($matches[1])\x3B\r\n	$md_urls[$link_id] = _EncodeAmpsAndAngles($matches[2])\x3B\r\n	if (isset($matches[3]))\r\n		$md_titles[$link_id] = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $matches[3])\x3B\r\n	return \x27\x27\x3B # String that will replace the block\r\n}\r\n\r\n\r\nfunction _HashHTMLBlocks($text) {\r\n	global $md_tab_width\x3B\r\n	$less_than_tab = $md_tab_width - 1\x3B\r\n\r\n	# Hashify HTML blocks:\r\n	# We only want to do this for block-level HTML tags\x2C such as headers\x2C\r\n	# lists\x2C and tables. That\x27s because we still want to wrap \x3Cp\x3Es around\r\n	# \x22paragraphs\x22 that are wrapped in non-block-level tags\x2C such as anchors\x2C\r\n	# phrase emphasis\x2C and spans. The list of tags we\x27re looking for is\r\n	# hard-coded:\r\n	$block_tags_a = \x27p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|\x27.\r\n					\x27script|noscript|form|fieldset|iframe|math|ins|del\x27\x3B\r\n	$block_tags_b = \x27p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|\x27.\r\n					\x27script|noscript|form|fieldset|iframe|math\x27\x3B\r\n\r\n	# First\x2C look for nested blocks\x2C e.g.:\r\n	# 	\x3Cdiv\x3E\r\n	# 		\x3Cdiv\x3E\r\n	# 		tags for inner block must be indented.\r\n	# 		\x3C/div\x3E\r\n	# 	\x3C/div\x3E\r\n	#\r\n	# The outermost tags must start at the left margin for this to match\x2C and\r\n	# the inner nested divs must be indented.\r\n	# We need to do this before the next\x2C more liberal match\x2C because the next\r\n	# match will start at the first `\x3Cdiv\x3E` and stop at the first `\x3C/div\x3E`.\r\n	$text = preg_replace_callback(\x22{\r\n				(						# save in $1\r\n					^					# start of line  (with /m)\r\n					\x3C($block_tags_a)	# start tag = $2\r\n					\x5C\x5Cb					# word break\r\n					(.*\x5C\x5Cn)*?			# any number of lines\x2C minimally matching\r\n					\x3C/\x5C\x5C2\x3E				# the matching end tag\r\n					[ \x5C\x5Ct]*				# trailing spaces/tabs\r\n					(?=\x5C\x5Cn+|\x5C\x5CZ)	# followed by a newline or end of document\r\n				)\r\n		}xm\x22\x2C\r\n		\x27_HashHTMLBlocks_callback\x27\x2C\r\n		$text)\x3B\r\n\r\n	#\r\n	# Now match more liberally\x2C simply from `\x5Cn\x3Ctag\x3E` to `\x3C/tag\x3E\x5Cn`\r\n	#\r\n	$text = preg_replace_callback(\x22{\r\n				(						# save in $1\r\n					^					# start of line  (with /m)\r\n					\x3C($block_tags_b)	# start tag = $2\r\n					\x5C\x5Cb					# word break\r\n					(.*\x5C\x5Cn)*?			# any number of lines\x2C minimally matching\r\n					.*\x3C/\x5C\x5C2\x3E				# the matching end tag\r\n					[ \x5C\x5Ct]*				# trailing spaces/tabs\r\n					(?=\x5C\x5Cn+|\x5C\x5CZ)	# followed by a newline or end of document\r\n				)\r\n		}xm\x22\x2C\r\n		\x27_HashHTMLBlocks_callback\x27\x2C\r\n		$text)\x3B\r\n\r\n	# Special case just for \x3Chr /\x3E. It was easier to make a special case than\r\n	# to make the other regex more complicated.\r\n	$text = preg_replace_callback(\x27{\r\n				(?:\r\n					(?\x3C=\x5Cn\x5Cn)		# Starting after a blank line\r\n					|				# or\r\n					\x5CA\x5Cn?			# the beginning of the doc\r\n				)\r\n				(						# save in $1\r\n					[ ]{0\x2C\x27.$less_than_tab.\x27}\r\n					\x3C(hr)				# start tag = $2\r\n					\x5Cb					# word break\r\n					([^\x3C\x3E])*?			#\r\n					/?\x3E					# the matching end tag\r\n					[ \x5Ct]*\r\n					(?=\x5Cn{2\x2C}|\x5CZ)		# followed by a blank line or end of document\r\n				)\r\n		}x\x27\x2C\r\n		\x27_HashHTMLBlocks_callback\x27\x2C\r\n		$text)\x3B\r\n\r\n	# Special case for standalone HTML comments:\r\n	$text = preg_replace_callback(\x27{\r\n				(?:\r\n					(?\x3C=\x5Cn\x5Cn)		# Starting after a blank line\r\n					|				# or\r\n					\x5CA\x5Cn?			# the beginning of the doc\r\n				)\r\n				(						# save in $1\r\n					[ ]{0\x2C\x27.$less_than_tab.\x27}\r\n					(?s:\r\n						\x3C!\r\n						(--.*?--\x5Cs*)+\r\n						\x3E\r\n					)\r\n					[ \x5Ct]*\r\n					(?=\x5Cn{2\x2C}|\x5CZ)		# followed by a blank line or end of document\r\n				)\r\n			}x\x27\x2C\r\n			\x27_HashHTMLBlocks_callback\x27\x2C\r\n			$text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\nfunction _HashHTMLBlocks_callback($matches) {\r\n	global $md_html_blocks\x3B\r\n	$text = $matches[1]\x3B\r\n	$key = md5($text)\x3B\r\n	$md_html_blocks[$key] = $text\x3B\r\n	return \x22\x5Cn\x5Cn$key\x5Cn\x5Cn\x22\x3B # String that will replace the block\r\n}\r\n\r\n\r\nfunction _RunBlockGamut($text) {\r\n#\r\n# These are all the transformations that form block-level\r\n# tags like paragraphs\x2C headers\x2C and list items.\r\n#\r\n	global $md_empty_element_suffix\x3B\r\n\r\n	$text = _DoHeaders($text)\x3B\r\n\r\n	# Do Horizontal Rules:\r\n	$text = preg_replace(\r\n		array(\x27{^[ ]{0\x2C2}([ ]?\x5C*[ ]?){3\x2C}[ \x5Ct]*$}mx\x27\x2C\r\n			  \x27{^[ ]{0\x2C2}([ ]? -[ ]?){3\x2C}[ \x5Ct]*$}mx\x27\x2C\r\n			  \x27{^[ ]{0\x2C2}([ ]? _[ ]?){3\x2C}[ \x5Ct]*$}mx\x27)\x2C\r\n		\x22\x5Cn\x3Chr$md_empty_element_suffix\x5Cn\x22\x2C\r\n		$text)\x3B\r\n\r\n	$text = _DoLists($text)\x3B\r\n	$text = _DoCodeBlocks($text)\x3B\r\n	$text = _DoBlockQuotes($text)\x3B\r\n\r\n	# We already ran _HashHTMLBlocks() before\x2C in Markdown()\x2C but that\r\n	# was to escape raw HTML in the original Markdown source. This time\x2C\r\n	# we\x27re escaping the markup we\x27ve just created\x2C so that we don\x27t wrap\r\n	# \x3Cp\x3E tags around block-level tags.\r\n	$text = _HashHTMLBlocks($text)\x3B\r\n	$text = _FormParagraphs($text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _RunSpanGamut($text) {\r\n#\r\n# These are all the transformations that occur *within* block-level\r\n# tags like paragraphs\x2C headers\x2C and list items.\r\n#\r\n	global $md_empty_element_suffix\x3B\r\n\r\n	$text = _DoCodeSpans($text)\x3B\r\n\r\n	$text = _EscapeSpecialChars($text)\x3B\r\n\r\n	# Process anchor and image tags. Images must come first\x2C\r\n	# because ![foo][f] looks like an anchor.\r\n	$text = _DoImages($text)\x3B\r\n	$text = _DoAnchors($text)\x3B\r\n\r\n	# Make links out of things like `\x3Chttp://example.com/\x3E`\r\n	# Must come after _DoAnchors()\x2C because you can use \x3C and \x3E\r\n	# delimiters in inline links like [this](\x3Curl\x3E).\r\n	$text = _DoAutoLinks($text)\x3B\r\n	$text = _EncodeAmpsAndAngles($text)\x3B\r\n	$text = _DoItalicsAndBold($text)\x3B\r\n\r\n	# Do hard breaks:\r\n	$text = preg_replace(\x27/ {2\x2C}\x5Cn/\x27\x2C \x22\x3Cbr$md_empty_element_suffix\x5Cn\x22\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _EscapeSpecialChars($text) {\r\n	global $md_escape_table\x3B\r\n	$tokens = _TokenizeHTML($text)\x3B\r\n\r\n	$text = \x27\x27\x3B   # rebuild $text from the tokens\r\n#	$in_pre = 0\x3B  # Keep track of when we\x27re inside \x3Cpre\x3E or \x3Ccode\x3E tags.\r\n#	$tags_to_skip = \x22!\x3C(/?)(?:pre|code|kbd|script|math)[\x5Cs\x3E]!\x22\x3B\r\n\r\n	foreach ($tokens as $cur_token) {\r\n		if ($cur_token[0] == \x27tag\x27) {\r\n			# Within tags\x2C encode * and _ so they don\x27t conflict\r\n			# with their use in Markdown for italics and strong.\r\n			# We\x27re replacing each such character with its\r\n			# corresponding MD5 checksum value\x3B this is likely\r\n			# overkill\x2C but it should prevent us from colliding\r\n			# with the escape values by accident.\r\n			$cur_token[1] = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n				array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n				$cur_token[1])\x3B\r\n			$text .= $cur_token[1]\x3B\r\n		} else {\r\n			$t = $cur_token[1]\x3B\r\n			$t = _EncodeBackslashEscapes($t)\x3B\r\n			$text .= $t\x3B\r\n		}\r\n	}\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _DoAnchors($text) {\r\n#\r\n# Turn Markdown link shortcuts into XHTML \x3Ca\x3E tags.\r\n#\r\n	global $md_nested_brackets\x3B\r\n	#\r\n	# First\x2C handle reference-style links: [link text] [id]\r\n	#\r\n	$text = preg_replace_callback(\x22{\r\n		(					# wrap whole match in $1\r\n		  \x5C\x5C[\r\n			($md_nested_brackets)	# link text = $2\r\n		  \x5C\x5C]\r\n\r\n		  [ ]?				# one optional space\r\n		  (?:\x5C\x5Cn[ ]*)?		# one optional newline followed by spaces\r\n\r\n		  \x5C\x5C[\r\n			(.*?)		# id = $3\r\n		  \x5C\x5C]\r\n		)\r\n		}xs\x22\x2C\r\n		\x27_DoAnchors_reference_callback\x27\x2C $text)\x3B\r\n\r\n	#\r\n	# Next\x2C inline-style links: [link text](url \x22optional title\x22)\r\n	#\r\n	$text = preg_replace_callback(\x22{\r\n		(				# wrap whole match in $1\r\n		  \x5C\x5C[\r\n			($md_nested_brackets)	# link text = $2\r\n		  \x5C\x5C]\r\n		  \x5C\x5C(			# literal paren\r\n			[ \x5C\x5Ct]*\r\n			\x3C?(.*?)\x3E?	# href = $3\r\n			[ \x5C\x5Ct]*\r\n			(			# $4\r\n			  ([\x27\x5C\x22])	# quote char = $5\r\n			  (.*?)		# Title = $6\r\n			  \x5C\x5C5		# matching quote\r\n			)?			# title is optional\r\n		  \x5C\x5C)\r\n		)\r\n		}xs\x22\x2C\r\n		\x27_DoAnchors_inline_callback\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\nfunction _DoAnchors_reference_callback($matches) {\r\n	global $md_urls\x2C $md_titles\x2C $md_escape_table\x3B\r\n	$whole_match = $matches[1]\x3B\r\n	$link_text   = $matches[2]\x3B\r\n	$link_id     = strtolower($matches[3])\x3B\r\n\r\n	if ($link_id == \x22\x22) {\r\n		$link_id = strtolower($link_text)\x3B # for shortcut links like [this][].\r\n	}\r\n\r\n	if (isset($md_urls[$link_id])) {\r\n		$url = $md_urls[$link_id]\x3B\r\n		# We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n		$url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n						   array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n						   $url)\x3B\r\n		$result = \x22\x3Ca href=\x5C\x22$url\x5C\x22\x22\x3B\r\n		if ( isset( $md_titles[$link_id] ) ) {\r\n			$title = $md_titles[$link_id]\x3B\r\n			$title = str_replace(array(\x27*\x27\x2C     \x27_\x27)\x2C\r\n								 array($md_escape_table[\x27*\x27]\x2C\r\n									   $md_escape_table[\x27_\x27])\x2C $title)\x3B\r\n			$result .=  \x22 title=\x5C\x22$title\x5C\x22\x22\x3B\r\n		}\r\n		$result .= \x22\x3E$link_text\x3C/a\x3E\x22\x3B\r\n	}\r\n	else {\r\n		$result = $whole_match\x3B\r\n	}\r\n	return $result\x3B\r\n}\r\nfunction _DoAnchors_inline_callback($matches) {\r\n	global $md_escape_table\x3B\r\n	$whole_match	= $matches[1]\x3B\r\n	$link_text		= $matches[2]\x3B\r\n	$url			= $matches[3]\x3B\r\n	$title			=\x26 $matches[6]\x3B\r\n\r\n	# We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n	$url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n					   array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n					   $url)\x3B\r\n	$result = \x22\x3Ca href=\x5C\x22$url\x5C\x22\x22\x3B\r\n	if (isset($title)) {\r\n		$title = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $title)\x3B\r\n		$title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n							 array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n							 $title)\x3B\r\n		$result .=  \x22 title=\x5C\x22$title\x5C\x22\x22\x3B\r\n	}\r\n\r\n	$result .= \x22\x3E$link_text\x3C/a\x3E\x22\x3B\r\n\r\n	return $result\x3B\r\n}\r\n\r\n\r\nfunction _DoImages($text) {\r\n#\r\n# Turn Markdown image shortcuts into \x3Cimg\x3E tags.\r\n#\r\n	global $md_nested_brackets\x3B\r\n\r\n	#\r\n	# First\x2C handle reference-style labeled images: ![alt text][id]\r\n	#\r\n	$text = preg_replace_callback(\x27{\r\n		(				# wrap whole match in $1\r\n		  !\x5C[\r\n			(\x27.$md_nested_brackets.\x27)		# alt text = $2\r\n		  \x5C]\r\n\r\n		  [ ]?				# one optional space\r\n		  (?:\x5Cn[ ]*)?		# one optional newline followed by spaces\r\n\r\n		  \x5C[\r\n			(.*?)		# id = $3\r\n		  \x5C]\r\n\r\n		)\r\n		}xs\x27\x2C\r\n		\x27_DoImages_reference_callback\x27\x2C $text)\x3B\r\n\r\n	#\r\n	# Next\x2C handle inline images:  ![alt text](url \x22optional title\x22)\r\n	# Don\x27t forget: encode * and _\r\n\r\n	$text = preg_replace_callback(\x27{\r\n		(				# wrap whole match in $1\r\n		  !\x5C[\r\n			(\x27.$md_nested_brackets.\x27)		# alt text = $2\r\n		  \x5C]\r\n		  \x5C(			# literal paren\r\n			[ \x5Ct]*\r\n			\x3C?(\x5CS+?)\x3E?	# src url = $3\r\n			[ \x5Ct]*\r\n			(			# $4\r\n			  ([\x5C\x27\x22])	# quote char = $5\r\n			  (.*?)		# title = $6\r\n			  \x5C5		# matching quote\r\n			  [ \x5Ct]*\r\n			)?			# title is optional\r\n		  \x5C)\r\n		)\r\n		}xs\x27\x2C\r\n		\x27_DoImages_inline_callback\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\nfunction _DoImages_reference_callback($matches) {\r\n	global $md_urls\x2C $md_titles\x2C $md_empty_element_suffix\x2C $md_escape_table\x3B\r\n	$whole_match = $matches[1]\x3B\r\n	$alt_text    = $matches[2]\x3B\r\n	$link_id     = strtolower($matches[3])\x3B\r\n\r\n	if ($link_id == \x22\x22) {\r\n		$link_id = strtolower($alt_text)\x3B # for shortcut links like ![this][].\r\n	}\r\n\r\n	$alt_text = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $alt_text)\x3B\r\n	if (isset($md_urls[$link_id])) {\r\n		$url = $md_urls[$link_id]\x3B\r\n		# We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n		$url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n						   array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n						   $url)\x3B\r\n		$result = \x22\x3Cimg src=\x5C\x22$url\x5C\x22 alt=\x5C\x22$alt_text\x5C\x22\x22\x3B\r\n		if (isset($md_titles[$link_id])) {\r\n			$title = $md_titles[$link_id]\x3B\r\n			$title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n								 array($md_escape_table[\x27*\x27]\x2C\r\n									   $md_escape_table[\x27_\x27])\x2C $title)\x3B\r\n			$result .=  \x22 title=\x5C\x22$title\x5C\x22\x22\x3B\r\n		}\r\n		$result .= $md_empty_element_suffix\x3B\r\n	}\r\n	else {\r\n		# If there\x27s no such link ID\x2C leave intact:\r\n		$result = $whole_match\x3B\r\n	}\r\n\r\n	return $result\x3B\r\n}\r\nfunction _DoImages_inline_callback($matches) {\r\n	global $md_empty_element_suffix\x2C $md_escape_table\x3B\r\n	$whole_match	= $matches[1]\x3B\r\n	$alt_text		= $matches[2]\x3B\r\n	$url			= $matches[3]\x3B\r\n	$title			= \x27\x27\x3B\r\n	if (isset($matches[6])) {\r\n		$title		= $matches[6]\x3B\r\n	}\r\n\r\n	$alt_text = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $alt_text)\x3B\r\n	$title    = str_replace(\x27\x22\x27\x2C \x27\x26quot\x3B\x27\x2C $title)\x3B\r\n	# We\x27ve got to encode these to avoid conflicting with italics/bold.\r\n	$url = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n					   array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n					   $url)\x3B\r\n	$result = \x22\x3Cimg src=\x5C\x22$url\x5C\x22 alt=\x5C\x22$alt_text\x5C\x22\x22\x3B\r\n	if (isset($title)) {\r\n		$title = str_replace(array(\x27*\x27\x2C \x27_\x27)\x2C\r\n							 array($md_escape_table[\x27*\x27]\x2C $md_escape_table[\x27_\x27])\x2C\r\n							 $title)\x3B\r\n		$result .=  \x22 title=\x5C\x22$title\x5C\x22\x22\x3B # $title already quoted\r\n	}\r\n	$result .= $md_empty_element_suffix\x3B\r\n\r\n	return $result\x3B\r\n}\r\n\r\n\r\nfunction _DoHeaders($text) {\r\n	# Setext-style headers:\r\n	#	  Header 1\r\n	#	  ========\r\n	#\r\n	#	  Header 2\r\n	#	  --------\r\n	#\r\n	$text = preg_replace(\r\n		array(\x27{ ^(.+)[ \x5Ct]*\x5Cn=+[ \x5Ct]*\x5Cn+ }emx\x27\x2C\r\n			  \x27{ ^(.+)[ \x5Ct]*\x5Cn-+[ \x5Ct]*\x5Cn+ }emx\x27)\x2C\r\n		array(\x22\x27\x3Ch1\x3E\x27._RunSpanGamut(_UnslashQuotes(\x27\x5C\x5C1\x27)).\x27\x3C/h1\x3E\x5Cn\x5Cn\x27\x22\x2C\r\n			  \x22\x27\x3Ch2\x3E\x27._RunSpanGamut(_UnslashQuotes(\x27\x5C\x5C1\x27)).\x27\x3C/h2\x3E\x5Cn\x5Cn\x27\x22)\x2C\r\n		$text)\x3B\r\n\r\n	# atx-style headers:\r\n	#	# Header 1\r\n	#	## Header 2\r\n	#	## Header 2 with closing hashes ##\r\n	#	...\r\n	#	###### Header 6\r\n	#\r\n	$text = preg_replace(\x22{\r\n			^(\x5C\x5C#{1\x2C6})	# $1 = string of #\x27s\r\n			[ \x5C\x5Ct]*\r\n			(.+?)		# $2 = Header text\r\n			[ \x5C\x5Ct]*\r\n			\x5C\x5C#*			# optional closing #\x27s (not counted)\r\n			\x5C\x5Cn+\r\n		}xme\x22\x2C\r\n		\x22\x27\x3Ch\x27.strlen(\x27\x5C\x5C1\x27).\x27\x3E\x27._RunSpanGamut(_UnslashQuotes(\x27\x5C\x5C2\x27)).\x27\x3C/h\x27.strlen(\x27\x5C\x5C1\x27).\x27\x3E\x5Cn\x5Cn\x27\x22\x2C\r\n		$text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _DoLists($text) {\r\n#\r\n# Form HTML ordered (numbered) and unordered (bulleted) lists.\r\n#\r\n	global $md_tab_width\x2C $md_list_level\x3B\r\n	$less_than_tab = $md_tab_width - 1\x3B\r\n\r\n	# Re-usable patterns to match list item bullets and number markers:\r\n	$marker_ul  = \x27[*+-]\x27\x3B\r\n	$marker_ol  = \x27\x5Cd+[.]\x27\x3B\r\n	$marker_any = \x22(?:$marker_ul|$marker_ol)\x22\x3B\r\n\r\n	$markers = array($marker_ul\x2C $marker_ol)\x3B\r\n\r\n	foreach ($markers as $marker) {\r\n		# Re-usable pattern to match any entirel ul or ol list:\r\n		$whole_list = \x27\r\n			(								# $1 = whole list\r\n			  (								# $2\r\n				[ ]{0\x2C\x27.$less_than_tab.\x27}\r\n				(\x27.$marker.\x27)				# $3 = first list item marker\r\n				[ \x5Ct]+\r\n			  )\r\n			  (?s:.+?)\r\n			  (								# $4\r\n				  \x5Cz\r\n				|\r\n				  \x5Cn{2\x2C}\r\n				  (?=\x5CS)\r\n				  (?!						# Negative lookahead for another list item marker\r\n					[ \x5Ct]*\r\n					\x27.$marker.\x27[ \x5Ct]+\r\n				  )\r\n			  )\r\n			)\r\n		\x27\x3B // mx\r\n\r\n		# We use a different prefix before nested lists than top-level lists.\r\n		# See extended comment in _ProcessListItems().\r\n\r\n		if ($md_list_level) {\r\n			$text = preg_replace_callback(\x27{\r\n					^\r\n					\x27.$whole_list.\x27\r\n				}mx\x27\x2C\r\n				\x27_DoLists_callback_top\x27\x2C $text)\x3B\r\n		}\r\n		else {\r\n			$text = preg_replace_callback(\x27{\r\n					(?:(?\x3C=\x5Cn\x5Cn)|\x5CA\x5Cn?)\r\n					\x27.$whole_list.\x27\r\n				}mx\x27\x2C\r\n				\x27_DoLists_callback_nested\x27\x2C $text)\x3B\r\n		}\r\n	}\r\n\r\n	return $text\x3B\r\n}\r\nfunction _DoLists_callback_top($matches) {\r\n	# Re-usable patterns to match list item bullets and number markers:\r\n	$marker_ul  = \x27[*+-]\x27\x3B\r\n	$marker_ol  = \x27\x5Cd+[.]\x27\x3B\r\n	$marker_any = \x22(?:$marker_ul|$marker_ol)\x22\x3B\r\n\r\n	$list = $matches[1]\x3B\r\n	$list_type = preg_match(\x22/$marker_ul/\x22\x2C $matches[3]) ? \x22ul\x22 : \x22ol\x22\x3B\r\n\r\n	$marker_any = ( $list_type == \x22ul\x22 ? $marker_ul : $marker_ol )\x3B\r\n\r\n	# Turn double returns into triple returns\x2C so that we can make a\r\n	# paragraph for the last item in a list\x2C if necessary:\r\n	$list = preg_replace(\x22/\x5Cn{2\x2C}/\x22\x2C \x22\x5Cn\x5Cn\x5Cn\x22\x2C $list)\x3B\r\n	$result = _ProcessListItems($list\x2C $marker_any)\x3B\r\n\r\n	# Trim any trailing whitespace\x2C to put the closing `\x3C/$list_type\x3E`\r\n	# up on the preceding line\x2C to get it past the current stupid\r\n	# HTML block parser. This is a hack to work around the terrible\r\n	# hack that is the HTML block parser.\r\n	$result = rtrim($result)\x3B\r\n	$result = \x22\x3C$list_type\x3E\x22 . $result . \x22\x3C/$list_type\x3E\x5Cn\x22\x3B\r\n	return $result\x3B\r\n}\r\nfunction _DoLists_callback_nested($matches) {\r\n	# Re-usable patterns to match list item bullets and number markers:\r\n	$marker_ul  = \x27[*+-]\x27\x3B\r\n	$marker_ol  = \x27\x5Cd+[.]\x27\x3B\r\n	$marker_any = \x22(?:$marker_ul|$marker_ol)\x22\x3B\r\n\r\n	$list = $matches[1]\x3B\r\n	$list_type = preg_match(\x22/$marker_ul/\x22\x2C $matches[3]) ? \x22ul\x22 : \x22ol\x22\x3B\r\n\r\n	$marker_any = ( $list_type == \x22ul\x22 ? $marker_ul : $marker_ol )\x3B\r\n\r\n	# Turn double returns into triple returns\x2C so that we can make a\r\n	# paragraph for the last item in a list\x2C if necessary:\r\n	$list = preg_replace(\x22/\x5Cn{2\x2C}/\x22\x2C \x22\x5Cn\x5Cn\x5Cn\x22\x2C $list)\x3B\r\n	$result = _ProcessListItems($list\x2C $marker_any)\x3B\r\n	$result = \x22\x3C$list_type\x3E\x5Cn\x22 . $result . \x22\x3C/$list_type\x3E\x5Cn\x22\x3B\r\n	return $result\x3B\r\n}\r\n\r\n\r\nfunction _ProcessListItems($list_str\x2C $marker_any) {\r\n#\r\n#	Process the contents of a single ordered or unordered list\x2C splitting it\r\n#	into individual list items.\r\n#\r\n	global $md_list_level\x3B\r\n\r\n	# The $md_list_level global keeps track of when we\x27re inside a list.\r\n	# Each time we enter a list\x2C we increment it\x3B when we leave a list\x2C\r\n	# we decrement. If it\x27s zero\x2C we\x27re not in a list anymore.\r\n	#\r\n	# We do this because when we\x27re not inside a list\x2C we want to treat\r\n	# something like this:\r\n	#\r\n	#		I recommend upgrading to version\r\n	#		8. Oops\x2C now this line is treated\r\n	#		as a sub-list.\r\n	#\r\n	# As a single paragraph\x2C despite the fact that the second line starts\r\n	# with a digit-period-space sequence.\r\n	#\r\n	# Whereas when we\x27re inside a list (or sub-list)\x2C that line will be\r\n	# treated as the start of a sub-list. What a kludge\x2C huh? This is\r\n	# an aspect of Markdown\x27s syntax that\x27s hard to parse perfectly\r\n	# without resorting to mind-reading. Perhaps the solution is to\r\n	# change the syntax rules such that sub-lists must start with a\r\n	# starting cardinal number\x3B e.g. \x221.\x22 or \x22a.\x22.\r\n\r\n	$md_list_level++\x3B\r\n\r\n	# trim trailing blank lines:\r\n	$list_str = preg_replace(\x22/\x5Cn{2\x2C}\x5C\x5Cz/\x22\x2C \x22\x5Cn\x22\x2C $list_str)\x3B\r\n\r\n	$list_str = preg_replace_callback(\x27{\r\n		(\x5Cn)?							# leading line = $1\r\n		(^[ \x5Ct]*)						# leading whitespace = $2\r\n		(\x27.$marker_any.\x27) [ \x5Ct]+		# list marker = $3\r\n		((?s:.+?)						# list item text   = $4\r\n		(\x5Cn{1\x2C2}))\r\n		(?= \x5Cn* (\x5Cz | \x5C2 (\x27.$marker_any.\x27) [ \x5Ct]+))\r\n		}xm\x27\x2C\r\n		\x27_ProcessListItems_callback\x27\x2C $list_str)\x3B\r\n\r\n	$md_list_level--\x3B\r\n	return $list_str\x3B\r\n}\r\nfunction _ProcessListItems_callback($matches) {\r\n	$item = $matches[4]\x3B\r\n	$leading_line =\x26 $matches[1]\x3B\r\n	$leading_space =\x26 $matches[2]\x3B\r\n\r\n	if ($leading_line || preg_match(\x27/\x5Cn{2\x2C}/\x27\x2C $item)) {\r\n		$item = _RunBlockGamut(_Outdent($item))\x3B\r\n	}\r\n	else {\r\n		# Recursion for sub-lists:\r\n		$item = _DoLists(_Outdent($item))\x3B\r\n		$item = preg_replace(\x27/\x5Cn+$/\x27\x2C \x27\x27\x2C $item)\x3B\r\n		$item = _RunSpanGamut($item)\x3B\r\n	}\r\n\r\n	return \x22\x3Cli\x3E\x22 . $item . \x22\x3C/li\x3E\x5Cn\x22\x3B\r\n}\r\n\r\n\r\nfunction _DoCodeBlocks($text) {\r\n#\r\n#	Process Markdown `\x3Cpre\x3E\x3Ccode\x3E` blocks.\r\n#\r\n	global $md_tab_width\x3B\r\n	$text = preg_replace_callback(\x22{\r\n			(?:\x5C\x5Cn\x5C\x5Cn|\x5C\x5CA)\r\n			(	            # $1 = the code block -- one or more lines\x2C starting with a space/tab\r\n			  (?:\r\n				(?:[ ]\x5C{$md_tab_width} | \x5C\x5Ct)  # Lines must start with a tab or a tab-width of spaces\r\n				.*\x5C\x5Cn+\r\n			  )+\r\n			)\r\n			((?=^[ ]{0\x2C$md_tab_width}\x5C\x5CS)|\x5C\x5CZ)	# Lookahead for non-space at line-start\x2C or end of doc\r\n		}xm\x22\x2C\r\n		\x27_DoCodeBlocks_callback\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\nfunction _DoCodeBlocks_callback($matches) {\r\n	$codeblock = $matches[1]\x3B\r\n\r\n	$codeblock = _EncodeCode(_Outdent($codeblock))\x3B\r\n//	$codeblock = _Detab($codeblock)\x3B\r\n	# trim leading newlines and trailing whitespace\r\n	$codeblock = preg_replace(array(\x27/\x5CA\x5Cn+/\x27\x2C \x27/\x5Cs+\x5Cz/\x27)\x2C \x27\x27\x2C $codeblock)\x3B\r\n\r\n	$result = \x22\x5Cn\x5Cn\x3Cpre\x3E\x3Ccode\x3E\x22 . $codeblock . \x22\x5Cn\x3C/code\x3E\x3C/pre\x3E\x5Cn\x5Cn\x22\x3B\r\n\r\n	return $result\x3B\r\n}\r\n\r\n\r\nfunction _DoCodeSpans($text) {\r\n#\r\n# 	*	Backtick quotes are used for \x3Ccode\x3E\x3C/code\x3E spans.\r\n#\r\n# 	*	You can use multiple backticks as the delimiters if you want to\r\n# 		include literal backticks in the code span. So\x2C this input:\r\n#\r\n#		  Just type ``foo `bar` baz`` at the prompt.\r\n#\r\n#	  	Will translate to:\r\n#\r\n#		  \x3Cp\x3EJust type \x3Ccode\x3Efoo `bar` baz\x3C/code\x3E at the prompt.\x3C/p\x3E\r\n#\r\n#		There\x27s no arbitrary limit to the number of backticks you\r\n#		can use as delimters. If you need three consecutive backticks\r\n#		in your code\x2C use four for delimiters\x2C etc.\r\n#\r\n#	*	You can use spaces to get literal backticks at the edges:\r\n#\r\n#		  ... type `` `bar` `` ...\r\n#\r\n#	  	Turns to:\r\n#\r\n#		  ... type \x3Ccode\x3E`bar`\x3C/code\x3E ...\r\n#\r\n	$text = preg_replace_callback(\x27@\r\n			(?\x3C!\x5C\x5C\x5C)	# Character before opening ` can\x5C\x27t be a backslash\r\n			(`+)		# $1 = Opening run of `\r\n			(.+?)		# $2 = The code block\r\n			(?\x3C!`)\r\n			\x5C1			# Matching closer\r\n			(?!`)\r\n		@xs\x27\x2C\r\n		\x27_DoCodeSpans_callback\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\nfunction _DoCodeSpans_callback($matches) {\r\n	$c = $matches[2]\x3B\r\n	$c = preg_replace(\x27/^[ \x5Ct]*/\x27\x2C \x27\x27\x2C $c)\x3B # leading whitespace\r\n	$c = preg_replace(\x27/[ \x5Ct]*$/\x27\x2C \x27\x27\x2C $c)\x3B # trailing whitespace\r\n	$c = _EncodeCode($c)\x3B\r\n	return \x22\x3Ccode\x3E$c\x3C/code\x3E\x22\x3B\r\n}\r\n\r\n\r\nfunction _EncodeCode($_) {\r\n#\r\n# Encode/escape certain characters inside Markdown code runs.\r\n# The point is that in code\x2C these characters are literals\x2C\r\n# and lose their special Markdown meanings.\r\n#\r\n	global $md_escape_table\x3B\r\n\r\n	# Encode all ampersands\x3B HTML entities are not\r\n	# entities within a Markdown code span.\r\n	$_ = str_replace(\x27\x26\x27\x2C \x27\x26amp\x3B\x27\x2C $_)\x3B\r\n\r\n	# Do the angle bracket song and dance:\r\n	$_ = str_replace(array(\x27\x3C\x27\x2C    \x27\x3E\x27)\x2C\r\n					 array(\x27\x26lt\x3B\x27\x2C \x27\x26gt\x3B\x27)\x2C $_)\x3B\r\n\r\n	# Now\x2C escape characters that are magic in Markdown:\r\n	$_ = str_replace(array_keys($md_escape_table)\x2C\r\n					 array_values($md_escape_table)\x2C $_)\x3B\r\n\r\n	return $_\x3B\r\n}\r\n\r\n\r\nfunction _DoItalicsAndBold($text) {\r\n	# \x3Cstrong\x3E must go first:\r\n	$text = preg_replace(\x27{\r\n			(						# $1: Marker\r\n				(?\x3C!\x5C*\x5C*) \x5C*\x5C* |	#     (not preceded by two chars of\r\n				(?\x3C!__)   __		#      the same marker)\r\n			)\r\n			(?=\x5CS) 					# Not followed by whitespace\r\n			(?!\x5C1)					#   or two others marker chars.\r\n			(						# $2: Content\r\n				(?:\r\n					[^*_]+?			# Anthing not em markers.\r\n				|\r\n									# Balence any regular emphasis inside.\r\n					([*_]) (?=\x5CS) .+? (?\x3C=\x5CS) \x5C3	# $3: em char (* or _)\r\n				|\r\n					(?! \x5C1 ) .		# Allow unbalenced * and _.\r\n				)+?\r\n			)\r\n			(?\x3C=\x5CS) \x5C1				# End mark not preceded by whitespace.\r\n		}sx\x27\x2C\r\n		\x27\x3Cstrong\x3E\x5C2\x3C/strong\x3E\x27\x2C $text)\x3B\r\n	# Then \x3Cem\x3E:\r\n	$text = preg_replace(\r\n		\x27{ ( (?\x3C!\x5C*)\x5C* | (?\x3C!_)_ ) (?=\x5CS) (?! \x5C1) (.+?) (?\x3C=\x5CS) \x5C1 }sx\x27\x2C\r\n		\x27\x3Cem\x3E\x5C2\x3C/em\x3E\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _DoBlockQuotes($text) {\r\n	$text = preg_replace_callback(\x27/\r\n		  (								# Wrap whole match in $1\r\n			(\r\n			  ^[ \x5Ct]*\x3E[ \x5Ct]?			# \x22\x3E\x22 at the start of a line\r\n				.+\x5Cn					# rest of the first line\r\n			  (.+\x5Cn)*					# subsequent consecutive lines\r\n			  \x5Cn*						# blanks\r\n			)+\r\n		  )\r\n		/xm\x27\x2C\r\n		\x27_DoBlockQuotes_callback\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\nfunction _DoBlockQuotes_callback($matches) {\r\n	$bq = $matches[1]\x3B\r\n	# trim one level of quoting - trim whitespace-only lines\r\n	$bq = preg_replace(array(\x27/^[ \x5Ct]*\x3E[ \x5Ct]?/m\x27\x2C \x27/^[ \x5Ct]+$/m\x27)\x2C \x27\x27\x2C $bq)\x3B\r\n	$bq = _RunBlockGamut($bq)\x3B		# recurse\r\n\r\n	$bq = preg_replace(\x27/^/m\x27\x2C \x22  \x22\x2C $bq)\x3B\r\n	# These leading spaces screw with \x3Cpre\x3E content\x2C so we need to fix that:\r\n	$bq = preg_replace_callback(\x27{(\x5Cs*\x3Cpre\x3E.+?\x3C/pre\x3E)}sx\x27\x2C\r\n								\x27_DoBlockQuotes_callback2\x27\x2C $bq)\x3B\r\n\r\n	return \x22\x3Cblockquote\x3E\x5Cn$bq\x5Cn\x3C/blockquote\x3E\x5Cn\x5Cn\x22\x3B\r\n}\r\nfunction _DoBlockQuotes_callback2($matches) {\r\n	$pre = $matches[1]\x3B\r\n	$pre = preg_replace(\x27/^  /m\x27\x2C \x27\x27\x2C $pre)\x3B\r\n	return $pre\x3B\r\n}\r\n\r\n\r\nfunction _FormParagraphs($text) {\r\n#\r\n#	Params:\r\n#		$text - string to process with html \x3Cp\x3E tags\r\n#\r\n	global $md_html_blocks\x3B\r\n\r\n	# Strip leading and trailing lines:\r\n	$text = preg_replace(array(\x27/\x5CA\x5Cn+/\x27\x2C \x27/\x5Cn+\x5Cz/\x27)\x2C \x27\x27\x2C $text)\x3B\r\n\r\n	$grafs = preg_split(\x27/\x5Cn{2\x2C}/\x27\x2C $text\x2C -1\x2C PREG_SPLIT_NO_EMPTY)\x3B\r\n\r\n	#\r\n	# Wrap \x3Cp\x3E tags.\r\n	#\r\n	foreach ($grafs as $key =\x3E $value) {\r\n		if (!isset( $md_html_blocks[$value] )) {\r\n			$value = _RunSpanGamut($value)\x3B\r\n			$value = preg_replace(\x27/^([ \x5Ct]*)/\x27\x2C \x27\x3Cp\x3E\x27\x2C $value)\x3B\r\n			$value .= \x22\x3C/p\x3E\x22\x3B\r\n			$grafs[$key] = $value\x3B\r\n		}\r\n	}\r\n\r\n	#\r\n	# Unhashify HTML blocks\r\n	#\r\n	foreach ($grafs as $key =\x3E $value) {\r\n		if (isset( $md_html_blocks[$value] )) {\r\n			$grafs[$key] = $md_html_blocks[$value]\x3B\r\n		}\r\n	}\r\n\r\n	return implode(\x22\x5Cn\x5Cn\x22\x2C $grafs)\x3B\r\n}\r\n\r\n\r\nfunction _EncodeAmpsAndAngles($text) {\r\n# Smart processing for ampersands and angle brackets that need to be encoded.\r\n\r\n	# Ampersand-encoding based entirely on Nat Irons\x27s Amputator MT plugin:\r\n	#   http://bumppo.net/projects/amputator/\r\n	$text = preg_replace(\x27/\x26(?!#?[xX]?(?:[0-9a-fA-F]+|\x5Cw+)\x3B)/\x27\x2C\r\n						 \x27\x26amp\x3B\x27\x2C $text)\x3B\x3B\r\n\r\n	# Encode naked \x3C\x27s\r\n	$text = preg_replace(\x27{\x3C(?![a-z/?\x5C$!])}i\x27\x2C \x27\x26lt\x3B\x27\x2C $text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _EncodeBackslashEscapes($text) {\r\n#\r\n#	Parameter:  String.\r\n#	Returns:    The string\x2C with after processing the following backslash\r\n#				escape sequences.\r\n#\r\n	global $md_escape_table\x2C $md_backslash_escape_table\x3B\r\n	# Must process escaped backslashes first.\r\n	return str_replace(array_keys($md_backslash_escape_table)\x2C\r\n					   array_values($md_backslash_escape_table)\x2C $text)\x3B\r\n}\r\n\r\n\r\nfunction _DoAutoLinks($text) {\r\n	$text = preg_replace(\x22!\x3C((https?|ftp):[^\x27\x5C\x22\x3E\x5C\x5Cs]+)\x3E!\x22\x2C\r\n						 \x27\x3Ca href=\x22\x5C1\x22\x3E\x5C1\x3C/a\x3E\x27\x2C $text)\x3B\r\n\r\n	# Email addresses: \x3Caddress@domain.foo\x3E\r\n	$text = preg_replace(\x27{\r\n		\x3C\r\n        (?:mailto:)?\r\n		(\r\n			[-.\x5Cw]+\r\n			\x5C@\r\n			[-a-z0-9]+(\x5C.[-a-z0-9]+)*\x5C.[a-z]+\r\n		)\r\n		\x3E\r\n		}exi\x27\x2C\r\n		\x22_EncodeEmailAddress(_UnescapeSpecialChars(_UnslashQuotes(\x27\x5C\x5C1\x27)))\x22\x2C\r\n		$text)\x3B\r\n\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _EncodeEmailAddress($addr) {\r\n#\r\n#	Input: an email address\x2C e.g. \x22foo@example.com\x22\r\n#\r\n#	Output: the email address as a mailto link\x2C with each character\r\n#		of the address encoded as either a decimal or hex entity\x2C in\r\n#		the hopes of foiling most address harvesting spam bots. E.g.:\r\n#\r\n#	  \x3Ca href=\x22\x26#x6D\x3B\x26#97\x3B\x26#105\x3B\x26#108\x3B\x26#x74\x3B\x26#111\x3B:\x26#102\x3B\x26#111\x3B\x26#111\x3B\x26#64\x3B\x26#101\x3B\r\n#		x\x26#x61\x3B\x26#109\x3B\x26#x70\x3B\x26#108\x3B\x26#x65\x3B\x26#x2E\x3B\x26#99\x3B\x26#111\x3B\x26#109\x3B\x22\x3E\x26#102\x3B\x26#111\x3B\x26#111\x3B\r\n#		\x26#64\x3B\x26#101\x3Bx\x26#x61\x3B\x26#109\x3B\x26#x70\x3B\x26#108\x3B\x26#x65\x3B\x26#x2E\x3B\x26#99\x3B\x26#111\x3B\x26#109\x3B\x3C/a\x3E\r\n#\r\n#	Based by a filter by Matthew Wickline\x2C posted to the BBEdit-Talk\r\n#	mailing list: \x3Chttp://tinyurl.com/yu7ue\x3E\r\n#\r\n	$addr = \x22mailto:\x22 . $addr\x3B\r\n	$length = strlen($addr)\x3B\r\n\r\n	# leave \x27:\x27 alone (to spot mailto: later)\r\n	$addr = preg_replace_callback(\x27/([^\x5C:])/\x27\x2C\r\n								  \x27_EncodeEmailAddress_callback\x27\x2C $addr)\x3B\r\n\r\n	$addr = \x22\x3Ca href=\x5C\x22$addr\x5C\x22\x3E$addr\x3C/a\x3E\x22\x3B\r\n	# strip the mailto: from the visible part\r\n	$addr = preg_replace(\x27/\x22\x3E.+?:/\x27\x2C \x27\x22\x3E\x27\x2C $addr)\x3B\r\n\r\n	return $addr\x3B\r\n}\r\nfunction _EncodeEmailAddress_callback($matches) {\r\n	$char = $matches[1]\x3B\r\n	$r = rand(0\x2C 100)\x3B\r\n	# roughly 10% raw\x2C 45% hex\x2C 45% dec\r\n	# \x27@\x27 *must* be encoded. I insist.\r\n	if ($r \x3E 90 \x26\x26 $char != \x27@\x27) return $char\x3B\r\n	if ($r \x3C 45) return \x27\x26#x\x27.dechex(ord($char)).\x27\x3B\x27\x3B\r\n	return \x27\x26#\x27.ord($char).\x27\x3B\x27\x3B\r\n}\r\n\r\n\r\nfunction _UnescapeSpecialChars($text) {\r\n#\r\n# Swap back in all the special characters we\x27ve hidden.\r\n#\r\n	global $md_escape_table\x3B\r\n	return str_replace(array_values($md_escape_table)\x2C\r\n					   array_keys($md_escape_table)\x2C $text)\x3B\r\n}\r\n\r\n\r\n# _TokenizeHTML is shared between PHP Markdown and PHP SmartyPants.\r\n# We only define it if it is not already defined.\r\nif (!function_exists(\x27_TokenizeHTML\x27)) :\r\nfunction _TokenizeHTML($str) {\r\n#\r\n#   Parameter:  String containing HTML markup.\r\n#   Returns:    An array of the tokens comprising the input\r\n#               string. Each token is either a tag (possibly with nested\x2C\r\n#               tags contained therein\x2C such as \x3Ca href=\x22\x3CMTFoo\x3E\x22\x3E\x2C or a\r\n#               run of text between tags. Each element of the array is a\r\n#               two-element array\x3B the first is either \x27tag\x27 or \x27text\x27\x3B\r\n#               the second is the actual value.\r\n#\r\n#\r\n#   Regular expression derived from the _tokenize() subroutine in\r\n#   Brad Choate\x27s MTRegex plugin.\r\n#   \x3Chttp://www.bradchoate.com/past/mtregex.php\x3E\r\n#\r\n	$index = 0\x3B\r\n	$tokens = array()\x3B\r\n\r\n	$match = \x27(?s:\x3C!(?:--.*?--\x5Cs*)+\x3E)|\x27.	# comment\r\n			 \x27(?s:\x3C\x5C?.*?\x5C?\x3E)|\x27.				# processing instruction\r\n			 								# regular tags\r\n			 \x27(?:\x3C[/!$]?[-a-zA-Z0-9:]+\x5Cb(?\x3E[^\x22\x5C\x27\x3E]+|\x22[^\x22]*\x22|\x5C\x27[^\x5C\x27]*\x5C\x27)*\x3E)\x27\x3B\r\n\r\n	$parts = preg_split(\x22{($match)}\x22\x2C $str\x2C -1\x2C PREG_SPLIT_DELIM_CAPTURE)\x3B\r\n\r\n	foreach ($parts as $part) {\r\n		if (++$index % 2 \x26\x26 $part != \x27\x27)\r\n			$tokens[] = array(\x27text\x27\x2C $part)\x3B\r\n		else\r\n			$tokens[] = array(\x27tag\x27\x2C $part)\x3B\r\n	}\r\n\r\n	return $tokens\x3B\r\n}\r\nendif\x3B\r\n\r\n\r\nfunction _Outdent($text) {\r\n#\r\n# Remove one level of line-leading tabs or spaces\r\n#\r\n	global $md_tab_width\x3B\r\n	return preg_replace(\x22/^(\x5C\x5Ct|[ ]{1\x2C$md_tab_width})/m\x22\x2C \x22\x22\x2C $text)\x3B\r\n}\r\n\r\n\r\nfunction _Detab($text) {\r\n#\r\n# Replace tabs with the appropriate amount of space.\r\n#\r\n	global $md_tab_width\x3B\r\n\r\n	# For each line we separate the line in blocks delemited by\r\n	# tab characters. Then we reconstruct every line by adding the\r\n	# appropriate number of space between each blocks.\r\n\r\n	$lines = explode(\x22\x5Cn\x22\x2C $text)\x3B\r\n	$text = \x22\x22\x3B\r\n\r\n	foreach ($lines as $line) {\r\n		# Split in blocks.\r\n		$blocks = explode(\x22\x5Ct\x22\x2C $line)\x3B\r\n		# Add each blocks to the line.\r\n		$line = $blocks[0]\x3B\r\n		unset($blocks[0])\x3B # Do not add first block twice.\r\n		foreach ($blocks as $block) {\r\n			# Calculate amount of space\x2C insert spaces\x2C insert block.\r\n			$amount = $md_tab_width - strlen($line) % $md_tab_width\x3B\r\n			$line .= str_repeat(\x22 \x22\x2C $amount) . $block\x3B\r\n		}\r\n		$text .= \x22$line\x5Cn\x22\x3B\r\n	}\r\n	return $text\x3B\r\n}\r\n\r\n\r\nfunction _UnslashQuotes($text) {\r\n#\r\n#	This function is useful to remove automaticaly slashed double quotes\r\n#	when using preg_replace and evaluating an expression.\r\n#	Parameter:  String.\r\n#	Returns:    The string with any slash-double-quote (\x5C\x22) sequence replaced\r\n#				by a single double quote.\r\n#\r\n	return str_replace(\x27\x5C\x22\x27\x2C \x27\x22\x27\x2C $text)\x3B\r\n}\r\n\r\n\r\n/*\r\n\r\nPHP Markdown\r\n============\r\n\r\nDescription\r\n-----------\r\n\r\nThis is a PHP translation of the original Markdown formatter written in\r\nPerl by John Gruber.\r\n\r\nMarkdown is a text-to-HTML filter\x3B it translates an easy-to-read /\r\neasy-to-write structured text format into HTML. Markdown\x27s text format\r\nis most similar to that of plain text email\x2C and supports features such\r\nas headers\x2C *emphasis*\x2C code blocks\x2C blockquotes\x2C and links.\r\n\r\nMarkdown\x27s syntax is designed not as a generic markup language\x2C but\r\nspecifically to serve as a front-end to (X)HTML. You can use span-level\r\nHTML tags anywhere in a Markdown document\x2C and you can use block level\r\nHTML tags (like \x3Cdiv\x3E and \x3Ctable\x3E as well).\r\n\r\nFor more information about Markdown\x27s syntax\x2C see:\r\n\r\n\x3Chttp://daringfireball.net/projects/markdown/\x3E\r\n\r\n\r\nBugs\r\n----\r\n\r\nTo file bug reports please send email to:\r\n\r\n\x3Cmichel.fortin@michelf.com\x3E\r\n\r\nPlease include with your report: (1) the example input\x3B (2) the output you\r\nexpected\x3B (3) the output Markdown actually produced.\r\n\r\n\r\nVersion History\r\n---------------\r\n\r\nSee the readme file for detailed release notes for this version.\r\n\r\n1.0.1b - 6 Jun 2005\r\n\r\n1.0.1a - 15 Apr 2005\r\n\r\n1.0.1 - 16 Dec 2004\r\n\r\n1.0 - 21 Aug 2004\r\n\r\n\r\nAuthor \x26 Contributors\r\n---------------------\r\n\r\nOriginal Perl version by John Gruber\r\n\x3Chttp://daringfireball.net/\x3E\r\n\r\nPHP port and other contributions by Michel Fortin\r\n\x3Chttp://www.michelf.com/\x3E\r\n\r\n\r\nCopyright and License\r\n---------------------\r\n\r\nCopyright (c) 2004-2005 Michel Fortin\r\n\x3Chttp://www.michelf.com/\x3E\r\nAll rights reserved.\r\n\r\nCopyright (c) 2003-2004 John Gruber\r\n\x3Chttp://daringfireball.net/\x3E\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms\x2C with or without\r\nmodification\x2C are permitted provided that the following conditions are\r\nmet:\r\n\r\n*	Redistributions of source code must retain the above copyright notice\x2C\r\n	this list of conditions and the following disclaimer.\r\n\r\n*	Redistributions in binary form must reproduce the above copyright\r\n	notice\x2C this list of conditions and the following disclaimer in the\r\n	documentation and/or other materials provided with the distribution.\r\n\r\n*	Neither the name \x22Markdown\x22 nor the names of its contributors may\r\n	be used to endorse or promote products derived from this software\r\n	without specific prior written permission.\r\n\r\nThis software is provided by the copyright holders and contributors \x22as\r\nis\x22 and any express or implied warranties\x2C including\x2C but not limited\r\nto\x2C the implied warranties of merchantability and fitness for a\r\nparticular purpose are disclaimed. In no event shall the copyright owner\r\nor contributors be liable for any direct\x2C indirect\x2C incidental\x2C special\x2C\r\nexemplary\x2C or consequential damages (including\x2C but not limited to\x2C\r\nprocurement of substitute goods or services\x3B loss of use\x2C data\x2C or\r\nprofits\x3B or business interruption) however caused and on any theory of\r\nliability\x2C whether in contract\x2C strict liability\x2C or tort (including\r\nnegligence or otherwise) arising in any way out of the use of this\r\nsoftware\x2C even if advised of the possibility of such damage.\r\n\r\n*/</code>
	</piece>
</FacileFormsPackage>
