/**
  * Function to be used from TypoScript to add Javascript after the jquery.js
  *
  * This is a small wrapper for adding javascripts script after the jQuery Library.
  * This is needed in some situations because headerdata added with "page.headerData"
  * is placed BEFORE the headerdata which is added using PHP.
  *
  * Usage:
  *
  * includeLibs.t3jquery = EXT:t3jquery/class.tx_t3jquery.php
  * page.10 = USER
  * page.10.userFunc = tx_t3jquery->addJS
  * page.10.jsfile = fileadmin/testscript.js
  * page.10.jsurl = http://www.example.com/script.js
  * page.10.jsdata = alert('Hello World!');
  * page.10.forceOnTop = 0
  * page.10.compress = 0
  * page.10.type = text/javascript
  * page.10.allWrap = 
  * page.10.jsinline = 0
  * page.10.tofooter = 1
  * 
  * @param	string		$content: Content input, ignore (just put blank string)
  * @param	array		$conf: TypoScript configuration of the plugin!
  * @return	void
  */
 function addJS($content, $conf)
 {
     // set the cObj from TSFE
     $cObj = $GLOBALS['TSFE']->cObj;
     // Set the tofooter to TRUE if integrateToFooter is set
     $confArr = tx_t3jquery::getConf();
     if ($confArr['integrateToFooter']) {
         $conf['tofooter'] = 'footer';
     }
     // If the jQuery lib is not added to page yet, add it!
     tx_t3jquery::addJqJS();
     // where should be the data stored (footer or header) / Fix moveJsFromHeaderToFooter (add all scripts to the footer)
     $conf['tofooter'] = $conf['tofooter'] || $GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter'] ? 'footer' : 'header';
     $conf['compress'] = $conf['compress'] || $conf['jsminify'];
     $conf['type'] = $conf['type'] ? $conf['type'] : 'text/javascript';
     // Append JS file
     if ($conf['jsfile'] || $conf['jsfile.']) {
         $jsfile = preg_replace('|^' . PATH_site . '|i', '', t3lib_div::getFileAbsFileName($cObj->stdWrap($conf['jsfile'], $conf['jsfile.'])));
         // Add the Javascript if file exists
         if ($jsfile != '' && file_exists(PATH_site . $jsfile)) {
             tx_t3jquery::addJsFile($jsfile, $conf);
         } else {
             t3lib_div::devLog('\'' . $jsfile . '\' does not exists!', 't3jquery', 2);
         }
     }
     // add JS URL
     if ($conf['jsurl'] || $conf['jsurl.']) {
         tx_t3jquery::addJsFile($cObj->stdWrap($conf['jsurl'], $conf['jsurl.']), $conf);
     }
     // add JS data
     if ($conf['jsdata'] || $conf['jsdata.']) {
         $jsdata = trim($cObj->stdWrap($conf['jsdata'], $conf['jsdata.']));
         if ($jsdata != '') {
             tx_t3jquery::addJsInlineCode(md5($jsdata), $jsdata, $conf);
         }
     }
     // add JS ready code
     if ($conf['jsready'] || $conf['jsready.']) {
         $jsready = trim($cObj->stdWrap($conf['jsready'], $conf['jsready.']));
         if ($jsready != '') {
             $temp_js = 'jQuery(document).ready(function() {' . $jsready . '});';
             tx_t3jquery::addJsInlineCode(md5($jsready), $temp_js, $conf);
         }
     }
 }