<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JJ Is Me</title>
	<atom:link href="http://jjis.me/feed" rel="self" type="application/rss+xml" />
	<link>http://jjis.me</link>
	<description>Me And My Code</description>
	<lastBuildDate>Wed, 01 Sep 2010 21:52:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Sneak Peak of OKcommerce.gov&#8217;s Engineering Marketing</title>
		<link>http://jjis.me/a/391</link>
		<comments>http://jjis.me/a/391#comments</comments>
		<pubDate>Wed, 01 Sep 2010 17:22:16 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=391</guid>
		<description><![CDATA[Here are 3 videos that have been developed as marketing engineering to the youngsters. It&#8217;s primarily to help bring to light that a lot of the things they may like can always one day be their job. As it&#8217;s been pointed out to me, Nar is supposedly a dead ringer for me. What do you [...]]]></description>
			<content:encoded><![CDATA[<p>Here are 3 videos that have been developed as marketing engineering to the youngsters. It&#8217;s primarily to help bring to light that a lot of the things they may like can always one day be their job.</p>
<p>As it&#8217;s been pointed out to me, Nar is supposedly a dead ringer for me.  What do you guys think?</p>
<p><span id="more-391"></span></p>
<h2>Nar</h2>
<p><object width="853" height="505"><param name="movie" value="http://www.youtube.com/v/3ZszCaFFewE?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/3ZszCaFFewE?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="853" height="505"></embed></object></p>
<p>&nbsp;</p>
<h2>Tori</h2>
<p><object width="853" height="505"><param name="movie" value="http://www.youtube.com/v/BzJACwaTWMo?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/BzJACwaTWMo?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="853" height="505"></embed></object></p>
<p>&nbsp;</p>
<h2>Mick</h2>
<p><object width="853" height="505"><param name="movie" value="http://www.youtube.com/v/3wqzOqlD0eA?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/3wqzOqlD0eA?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="853" height="505"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/391/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Digg v4 Is A Fail</title>
		<link>http://jjis.me/a/382</link>
		<comments>http://jjis.me/a/382#comments</comments>
		<pubDate>Sat, 28 Aug 2010 03:17:27 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=382</guid>
		<description><![CDATA[So, the new Digg has launched and there&#8217;s quite a bit of an uproar over the way stories rise to the top of the news page. This is a simple example of the Technology page without logging in to the Digg (logging in doesn&#8217;t change Top News, just My News). I mean, I love Mashable, [...]]]></description>
			<content:encoded><![CDATA[<p>So, the new Digg has launched and there&#8217;s quite a bit of an uproar over the way stories rise to the top of the news page. This is a simple example of the Technology page without logging in to the Digg (logging in doesn&#8217;t change Top News, just My News).</p>
<p>I mean, I love Mashable, but come on.</p>
<p>Click the image to enlarge.</p>
<p><span id="more-382"></span></p>
<p><a href="http://jjis.me/wp-content/uploads/2010/08/Digg-Screenshot.png"><img class="aligncenter size-large wp-image-383" title="Digg-Screenshot" src="http://jjis.me/wp-content/uploads/2010/08/Digg-Screenshot-767x1024.png" alt="Why Digg v4 is a Fail" width="767" height="1024" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/382/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline Images With Data URLs</title>
		<link>http://jjis.me/a/362</link>
		<comments>http://jjis.me/a/362#comments</comments>
		<pubDate>Wed, 11 Aug 2010 22:16:49 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=362</guid>
		<description><![CDATA[This particular trick comes in very handy for the mobile platforms. Instead of linking to your CSS and your images, you can use this method to embed the images inline within the CSS. This keeps the browser from having to make multiple calls, thus speeding up the load time of your application. You can also [...]]]></description>
			<content:encoded><![CDATA[<p>This particular trick comes in very handy for the mobile platforms. Instead of linking to your CSS and your images, you can use this method to embed the images inline within the CSS. This keeps the browser from having to make multiple calls, thus speeding up the load time of your application. You can also use this method within an IMG tag as well.</p>
<pre class="brush: php; wrap-lines: false;">
	/* ***********************************************************
	* START :::
	*	64bit encodes images for CSS embedding
        *      Alternatively, if you are not using PNGs, you can specify the Mime Type
        *      PNG is the default mime
	*********************************************************** */
	function data_url($file, $mime='') {  

		$mime = empty($mime) ? 'image/png' : $mime;

		$contents = file_get_contents($file);
		$base64   = base64_encode($contents);
		return ('data:' . $mime . ';base64,' . $base64);
	}
	/* ***********************************************************
	* END :::
	*********************************************************** */
</pre>
<h2>In the CSS style sheet</h2>
<p>You would need to either tell your server to process files with the .css extension or save your CSS files with the .php extension. It&#8217;s your call.</p>
<pre class="brush: css; wrap-lines: true;">

 body { background-image: url('&lt;?php echo data_url('http://domain.com/images/file.png'); ?&gt;') no-repeat; }

/* output code would be something like */
body { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFQAAABUCAIAAACTCYeWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAI5JREFUeNrs2sENACEIRUF1LY0mqRbb2OQPHUwexIu7qlbq3JmJxZ8VPMorr7zy8NZeeXhrrzw8vJtXHh4eHh7eU6c8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8fMj4kAQPDw8P76lTHh7ezSsPb+2Vh7f2yiv/7/mS8dHlo2d3dyz+CTAAYEXI+4xG4igAAAAASUVORK5CYII=') no-repeat; }
</pre>
<h2>Within HTML img tags</h2>
<pre class="brush: xml; wrap-lines: true;">

&lt;img src=&quot;&lt;?php echo data_url('http://domain.com/images/file.png'); ?&gt;&quot; border=0 /&gt;

&lt;!-- output code would be something like --&gt; &lt;img src=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFQAAABUCAIAAACTCYeWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAI5JREFUeNrs2sENACEIRUF1LY0mqRbb2OQPHUwexIu7qlbq3JmJxZ8VPMorr7zy8NZeeXhrrzw8vJtXHh4eHh7eU6c8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8fMj4kAQPDw8P76lTHh7ezSsPb+2Vh7f2yiv/7/mS8dHlo2d3dyz+CTAAYEXI+4xG4igAAAAASUVORK5CYII=&quot; border=0 /&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/362/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make print_r() Pretty</title>
		<link>http://jjis.me/a/350</link>
		<comments>http://jjis.me/a/350#comments</comments>
		<pubDate>Wed, 11 Aug 2010 21:01:10 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=350</guid>
		<description><![CDATA[This is literally print_r() dressed up. I normally run this within my general $app object so to call it, I would use $app->debug($var). As with print_r(), it loops indefinitely using lists to format a readable layout in HTML. This helps the developer avoid having to view source and scroll&#8230;and scroll&#8230;and scroll to find the output [...]]]></description>
			<content:encoded><![CDATA[<p>This is literally print_r() dressed up.  I normally run this within my general $app object so to call it, I would use $app->debug($var). As with print_r(), it loops indefinitely using lists to format a readable layout in HTML. This helps the developer avoid having to view source and scroll&#8230;and scroll&#8230;and scroll to find the output of an array or object.</p>
<p><span id="more-350"></span></p>
<pre class="brush: php;">
class System_Application {

	/* ***********************************************************
	* START :::
	*	Used for writing variables and arrays to screen
	*	for debugging. If array, it will place a line break
	*	after each value for easy on-screen viewing
	*
	*	$app-&gt;debug($var);
	*
	*	if var is empty, it will display &quot;Hello World&quot;
	*	$show defaults to true. setting this false will wrap the
	*	output in a div with a display:none so it won't show
	*	except if you view HTML source
	*********************************************************** */
	function debug($var=false,$show=true) {

		$display=(!$show)?' style=&quot;display: none;&quot;':'';

		echo '&lt;div class=&quot;light-font&quot;'.$display.'&gt;&amp;nbsp;';
		if ( is_array($var) || is_object($var) ):
			foreach ($var as $key=&gt;$val) :
				echo $key;
				if (is_array($val) || is_object($val)) :
					echo '&lt;ul style=&quot;margin:0;padding:0 0 0 15px;list-style:none;&quot;&gt;';
					foreach ($val as $key1=&gt;$val1) :
						echo '&lt;li&gt;'.$key . '['.$key1.']' . ' = ';
							if (is_array($val1) || is_object($val1)) :
								$this-&gt;debug_array($val1);
							else :
								echo $val1.'&lt;/li&gt;';
							endif;
					endforeach;
					echo '&lt;/ul&gt;';
				else :
					echo ' = ' . $val.'&lt;br /&gt;';
				endif;
			endforeach;
		else:
			echo $var;
		endif;

		if (empty($var)) :
			echo 'Hello World ';
		endif;

		echo '&lt;/div&gt;';
	}

		function debug_array($var) {
			echo '&lt;ul style=&quot;margin:0;padding:0 0 0 25px;list-style:none;&quot;&gt;';
			foreach ($var as $key1=&gt;$val1) :

				echo '&lt;li&gt;[' . $key1 . '] = ';

				if (is_array($val1) || is_object($val1)) :
					$this-&gt;debug_array($val1);
				else :
					echo $val1.'&lt;/li&gt;';
				endif;

			endforeach;
			echo '&lt;/ul&gt;';
		}

	/* ***********************************************************
	* END :::
	*********************************************************** */
}

$app = new System_Application;
</pre>
<h2>Use:</h2>
<pre class="brush: php;">

/* an example of an icon array I have for twitter app icons */
	var $icon = array(
		'toolbar' =&gt; array(
			'logout'    =&gt; 'hi-res/Logout.png',
		     'compose'   =&gt; 'hi-res/Compose.png',
		     'reload'    =&gt; 'hi-res/Reload.png',
		     'scrolltop' =&gt; 'hi-res/Scroll-Top-Alt.png'
		),
		'tweet'     =&gt; array(
			'profile'   =&gt; 'hi-res/Profile.png',
			'reply'     =&gt; 'hi-res/Reply.png',
			'dm'        =&gt; 'hi-res/DM.png',
			'links'     =&gt; 'hi-res/Links.png',
			'favorite'  =&gt; 'hi-res/Favorite-Alt.png'
		)
	);

$app-&gt;debug($icon);
</pre>
<h2>Results:</h2>
<pre class="brush: xml;">
&lt;p class=&quot;light-font&quot;&gt;
        toolbar&lt;ul style=&quot;margin:0;padding:0 0 0 15px;list-style:none;&quot;&gt;
                        &lt;li&gt;toolbar[logout] = hi-res/Logout.png&lt;/li&gt;
                        &lt;li&gt;toolbar[compose] = hi-res/Compose.png&lt;/li&gt;
                        &lt;li&gt;toolbar[reload] = hi-res/Reload.png&lt;/li&gt;
                        &lt;li&gt;toolbar[scrolltop] = hi-res/Scroll-Top-Alt.png&lt;/li&gt;
                &lt;/ul&gt;
        tweet&lt;ul style=&quot;margin:0;padding:0 0 0 15px;list-style:none;&quot;&gt;
                        &lt;li&gt;tweet[profile] = hi-res/Profile.png&lt;/li&gt;
                        &lt;li&gt;tweet[reply] = hi-res/Reply.png&lt;/li&gt;
                        &lt;li&gt;tweet[dm] = hi-res/DM.png&lt;/li&gt;
                        &lt;li&gt;tweet[links] = hi-res/Links.png&lt;/li&gt;
                        &lt;li&gt;tweet[favorite] = hi-res/Favorite-Alt.png&lt;/li&gt;
                &lt;/ul&gt;
&lt;/p&gt;
</pre>
<h2>Which translates to: </h2>
<div class="light-font">toolbar
<ul style="margin:0;padding:0 0 0 15px;list-style:none;">
<li>toolbar[logout] = hi-res/Logout.png</li>
<li>toolbar[compose] = hi-res/Compose.png</li>
<li>toolbar[reload] = hi-res/Reload.png</li>
<li>toolbar[scrolltop] = hi-res/Scroll-Top-Alt.png</li>
</ul>
<p>tweet
<ul style="margin:0;padding:0 0 0 15px;list-style:none;">
<li>tweet[profile] = hi-res/Profile.png</li>
<li>tweet[reply] = hi-res/Reply.png</li>
<li>tweet[dm] = hi-res/DM.png</li>
<li>tweet[links] = hi-res/Links.png</li>
<li>tweet[favorite] = hi-res/Favorite-Alt.png</li>
</ul>
</div>
<p>&nbsp;<br />
&nbsp;<br />
There ya go. That&#8217;s all there is too it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/350/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Error Handling</title>
		<link>http://jjis.me/a/327</link>
		<comments>http://jjis.me/a/327#comments</comments>
		<pubDate>Wed, 11 Aug 2010 04:44:17 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=327</guid>
		<description><![CDATA[In the world of the Internet, as a developer, we need to protect ourselves from prying eyes. One of the easiest ways a hacker can crack your code is if you tell them what they did wrong. For that reason, it&#8217;s important to suppress errors from the public. But, this doesn&#8217;t mean we should eliminate [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of the Internet, as a developer, we need to protect ourselves from prying eyes. One of the easiest ways a hacker can crack your code is if you tell them what they did wrong. For that reason, it&#8217;s important to suppress errors from the public. But, this doesn&#8217;t mean we should eliminate the knowledge when an error occurs and what triggered it.  For that reason, I have written a fairly simple class that will allow for error suppression, error debugging and error reporting.</p>
<p><span id="more-327"></span></p>
<p>When in debug mode, the error is displayed on screen in a fairly elegant manner. Barring CSS overrides and surrounding DOM elements, the error is output in a legible manner so that it can be easily read.</p>
<p>When errors are suppressed, the error is caught and handled elegantly and then emailed to the specified email address.</p>
<p><strong><em>The one drawback: </em></strong> if there is a parse error in the file that includes the Error.Handling.Class.php file, it will not call this class. It will use PHP&#8217;s internal error handler and print the error to screen. If anyone knows a way around this, let me know and I will implement it.</p>
<h2>Examples:</h2>
<ul>
<li class="none"><a href="http://jjis.me/error.static.parse.php" target="_new">Parse error in debug mode</a></li>
<li class="none"><a href="http://jjis.me/error.static.exception.php" target="_new">Exception errors in debug mode</a></li>
<li class="none"><a href="http://jjis.me/error.static.suppressed.php" target="_new">Both errors when suppressed</a></li>
</ul>
<h2>Code:</h2>
<pre class="brush: php; wrap-lines: false;">
&lt;?php
/*
	*	Script Name: Forms
	*	Author: JJ Jiles
	*	Website: http://jjis.me
	*	Version: 1
	*	Copyright (C) March 31 2010
	*
	*	Error Catching and Debugging
	*
*/

class Error_Debug {
	#
	# a couple of basic settings
	#
	# Display Errors?:
	#	True|False
	#	This is overridden should there be a $config-&gt;show_errors var
	#
	# Email To:
	#	email for the person who needs to receive the error
	#
	# Style Sheet:
	#	Set the link to the style sheet.
	#	Exclude from the server path ( http://domain.com )
	#
	# Suppressed Error Message
	#	This is the error message that will be displayed if error reporting is turned off
	#
	var $errors = array(
			'display'     =&gt; false,
			'email_to'    =&gt; 'email@domain.com',
			'email_from'  =&gt; 'email@domain.com',
			'style_sheet' =&gt; 'css/error-reports.css',
			'suppressed_error_message' =&gt; '&lt;div align=&quot;center&quot;&gt;&lt;b style=&quot;font-size: 150%;&quot;&gt;lnnl&lt;b style=&quot;font-size: 200%;&quot;&gt; (-_-) &lt;/b&gt;lnnl&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;aw snap! something broke!&lt;/div&gt;'
		);

	function Error_Debug() { return true; }

	/* ***********************************************************************
	* START :::
	*
	*	Initial error catching method
	*	This will determine if it's a parse error, or other
	*	types of errors.
	*
	*	PARSE:
	*		stops everything dead in its tracks. If display
	*		errors is allowed, then show the error message
	*		otherwise suppress the error and email it
	*
	*
	*	ALL OTHERS:
	*		Run the backtrace through the previous called
	*		functions and display the information for debugging
	*		If display errors is false, suppress the error
	*		and email the error
	*********************************************************************** */
	function catch_error($n='', $s='', $f='', $l='') {
		global $security, $config;	

		#
		# check to see if the $config object exists. if so, use it's setting
		$this-&gt;errors['display'] = (isset($config-&gt;show_errors) ) ? $config-&gt;show_errors : $this-&gt;errors['display'];

		#
		# if this is a parse error, we need to handle it differently
		# because it completely stops all PHP parsing, we catch it immediately
		# and display a simple output
		if( empty($n) &amp;&amp; false === is_null($aError = error_get_last()) ) :

			#
			# suppress the error and show something entertaining
			if ( !$this-&gt;errors['display'] ) :
				echo $this-&gt;errors['suppressed_error_message'];

			#
			# for debugging, display the information about the error
			else :
				$err = error_get_last();
				$this-&gt;echo_css();
				echo &quot;&lt;div id=\&quot;error-container\&quot;&gt;&quot;
					. &quot;&lt;div id=\&quot;error-wrapper\&quot;&gt;&quot;
					. &quot;&lt;table id=\&quot;primary-error\&quot;&gt;\n&quot;
					. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Error Type: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $err['type'] . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
					. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Message: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $err['message'] . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
					. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;File: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $err['file'] . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
					. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;On line: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot;.$err['line'].&quot;&lt;/td&gt;&lt;/tr&gt;\n&lt;/table&gt;\n&quot;;

			endif;

		#
		# exception errors get sent to either backtracing or suppression
		else :

			#
			# backtrace the error and display the information for debugging
			if ( @$this-&gt;errors['display'] ) : $this-&gt;error_backtrace($n, $s, $f, $l);

			#
			# suppress the error and email it
			else : $this-&gt;error_thrown($n, $s, $f, $l); 

			endif;

			return true;

		endif;
		exit();
	}
	/* ***********************************************************************
	* END :::
	*********************************************************************** */

	/* ***********************************************************************
	* START :::
	*
	*	Backtraces through the errors and displays a nice
	*	It's pretty simple. Not a lot that needs explaining
	*
	*********************************************************************** */
	function error_backtrace($errno, $errstr, $error_file, $error_line) {
		global $css;

		$errorsThrown = debug_backtrace();

		#
		# we skip the first two errors
		# they are the initial calls from error catching
		# we can ignore them
		#
		if ( isset($errorsThrown[2]) ) :
			$errorThrown  = $errorsThrown[2];

			#
			# echo css
			$this-&gt;echo_css();

			#
			# this is the primary error that started it all
			echo &quot;&lt;div id=\&quot;error-container\&quot;&gt;&quot;
				. &quot;&lt;div id=\&quot;error-wrapper\&quot;&gt;&quot;
				. &quot;&lt;table id=\&quot;primary-error\&quot;&gt;\n&quot;
				. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Error: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $errstr . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
				. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Line: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $error_line . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
				. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;File: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $error_file . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
				. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Calling Function: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $errorThrown['function'] . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
				. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;File Name: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot;.$errorThrown['file'].&quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
				. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;On line: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot;.$errorThrown['line'].&quot;&lt;/td&gt;&lt;/tr&gt;\n&lt;/table&gt;\n&quot;;

			#
			# for additional debugging, loop through all previous function calls
			# this assists in debugging if you call a method multiple times
			# now we can figure out which instance caused the error
			#
			echo &quot;&lt;p&gt;All previously executed functions: &lt;/p&gt;\n&quot;;

			echo &quot;&lt;table id=\&quot;previous-errors\&quot; cellpadding=5 cellspacing=0 border=0 style=\&quot;border: 1px solid #333;\&quot;&gt;&quot;
				. &quot;&lt;tr style=\&quot;background: #d3d3d3;\&quot;&gt;&quot;
				. &quot;&lt;th&gt;order&lt;/th&gt;&quot;
				. &quot;&lt;th&gt;function name&lt;/th&gt;&quot;
				. &quot;&lt;th&gt;file name&lt;/th&gt;&quot;
				. &quot;&lt;th&gt;line&lt;/th&gt;&quot;
				. &quot;&lt;/tr&gt;&quot;;

			$count = 0;
			array_reverse($errorsThrown);

			#
			# loop thu the backtrace and output
			foreach ($errorsThrown as $error) :
				$is_db = (bool) strchr($error['file'], 'Database.php');
				if ($count &gt; 1 &amp;&amp; !$is_db) :
					echo '&lt;tr&gt;'
					. '&lt;td&gt;' . ($count-1) . '&lt;/td&gt;'
					. '&lt;td&gt;' . $error['function'] . '()&lt;/td&gt;'
					. '&lt;td&gt;' . $error['file'] . '&lt;/td&gt;'
					. '&lt;td&gt;' . $error['line'] . '&lt;/td&gt;'
					. '&lt;/tr&gt;';
				endif;
				$count++;

			endforeach;

			#
			# close it all up
			echo '&lt;/table&gt;'
				. '&lt;p&gt;&amp;nbsp;&lt;/p&gt;'
				. '&lt;/div&gt;&lt;/div&gt;';
		exit();
		endif;
	}
	/* ***********************************************************************
	* END :::
	*********************************************************************** */

	/* ***********************************************************************
	* START :::
	*
	*	Backtraces through the errors and displays a nice
	*	It's pretty simple. Not a lot that needs explaining
	*
	*********************************************************************** */
	function error_thrown($errno, $errstr, $error_file, $error_line) {
		global $security;

		$errorThrown = debug_backtrace();
		$errorFunction = '';

		#
		# we skip the first two errors
		# they are the initial calls from error catching
		# we can ignore them
		#
		if (isset($errorThrown[2])) :
			$errorThrown = $errorThrown[2];
			$errorFunction = &quot;\n&quot;.'Calling Function: '.$errorThrown['function'];

			$referer = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';

			$server_r = '';
			$server_out = $_SERVER;
			foreach ($server_out as $key=&gt;$val) {
				$server_r .= $key.' ::: '.$val.&quot;\n\r&quot;;
			}

			$message = '';
			$message .= &quot;Error Thrown: [{$errno}] {$errstr}{$errorFunction}\n&quot;
					. &quot;File Name: {$error_file}\n&quot;
					. &quot;On line: {$error_line}\n&quot;
					. &quot;Server: &quot; . $_SERVER['SERVER_NAME'] . &quot;\n&quot;
					. &quot;URL: &quot; . $_SERVER['REQUEST_URI'] . &quot;\n&quot;
					. &quot;Referer: {$referer}&quot;
					. &quot;\n\n\n&quot;
					. &quot;Server Output: \n&quot;
					. $server_r
					. &quot;\n&quot;;

			if ( !error_log(
				$message, 1,
				$this-&gt;errors['email_to'],
				&quot;From: &quot; . $this-&gt;errors['email_from']
				)
			) :

				echo $this-&gt;errors['suppressed_error_message'];

			endif;
		endif;
	}
	/* ***********************************************************************
	* END :::
	*********************************************************************** */

	/* ***********************************************************************
	* START :::
	*
	*	echo the css style sheet so the error reporting is pretty
	*
	*********************************************************************** */
	function echo_css() {
		$css_url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this-&gt;errors['style_sheet'];

		echo '&lt;link rel=&quot;stylesheet&quot; id=&quot;mainstyle&quot; type=&quot;text/css&quot; href=&quot;' . $css_url . '&quot; /&gt;';
	}
	/* ***********************************************************************
	* END :::
	*********************************************************************** */

}

	# Upon All Errors, call the error handling function
	 	set_error_handler(array(new Error_Debug(),'catch_error'));

	# Register function to execute at the end of the script
		register_shutdown_function(array(new Error_Debug(),'catch_error'));

	# Hide error messages
		error_reporting(0);
?&gt;
</pre>
<h2>Some CSS styling for you: </h2>
<pre class="brush: php; wrap-lines: false;">
#error-container { width: 100%; color: #333!important; position: relative; background-color: #f3f3f3; border-bottom: 1px dotted #333; }
#error-wrapper { font: 110%/0.8em arial!important; letter-spacing: 0.02em; width: 850px!important; background-color: #f3f3f3!important; padding: 10px!important; }
#error-wrapper a { color: #cc6600; }
#primary-error td { color: #333!important; padding: 4px!important; border: 1px solid #f3f3f3!important; }
#primary-error td.left { width: 120px; text-align: right; padding: 8px 4px 8px 8px!important; margin: 0 8px 1px 0!important; background-color: #d3d3d3!important; }
#error-wrapper p { text-align: left; padding: 18px; clear: both!important; }
#previous-errors th { color: #333!important; padding: 6px; }
#previous-errors td { color: #333!important; padding: 4px; border-top: 1px solid #666; border-right: 1px solid #666; }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/327/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tabs &amp; Lists With Selectability</title>
		<link>http://jjis.me/a/313</link>
		<comments>http://jjis.me/a/313#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:04:26 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=313</guid>
		<description><![CDATA[I&#8217;ve recently come up with a need to allow users to view a list of options from which to choose. Do to screen restraints and readability, I opted to use the tabbing functionality I wrote about previously. In the process, however, I wrote some javascript that allows me to add the &#8216;pick and choose&#8217; functionality [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently come up with a need to allow users to view a list of options from which to choose.  Do to screen restraints and readability, I opted to use the <a href="http://jjis.me/a/280">tabbing functionality I wrote about previously</a>. In the process, however, I wrote some javascript that allows me to add the &#8216;pick and choose&#8217; functionality to any pair of lists, or single list, I choose.</p>
<p><strong>Single List Mode: </strong>This is real simple. The user has a list of items to select from. When the select the item, the &#8216;selected&#8217; class is added to that item. When they de-select the item, the &#8216;selected&#8217; class is removed. This is tracked with a hidden input element with the id &#8216;ls_update_list_array&#8217;.</p>
<p><strong>Dual List Mode: </strong>When the user views &#8216;Categories Selected&#8217; (in this case, shown by default), they will see a list of categories currently selected.  Under &#8216;All Available Categories&#8217;, they get a complete list of categories to selected from (in this case, minus those categories already selected). We want the user to be able to either add to the list of &#8216;Currently Selected&#8217; by clicking on the &#8216;All Categories&#8217; list, or remove items by clicking on them under &#8216;Currently Selected&#8217;. When they click on an item in either list, it is moved from list to the other. This is tracked with a hidden input element with the id &#8216;ls_update_list_array&#8217;.</p>
<p><strong>ls_update_list_array: </strong>This is provided simply to allow for an easy form post action. Rather than having Javascript determine when the form is posted and then grabbing the list as an array and blah, blah, blah, you get the list automatically on post.</p>
<p><span id="more-313"></span></p>
<p>&nbsp;</p>
<h2>The HTML</h2>
<pre class="brush: xml; wrap-lines: false;">
&lt;div id=&quot;tabs&quot;&gt;&lt;b class=&quot;active&quot;&gt;&lt;a href=&quot;#selected-categories&quot;&gt;Currently Selected Categories&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;inactive&quot;&gt;&lt;a href=&quot;#all-categories&quot;&gt;All Available Categories&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul id=&quot;selected-categories&quot; class=&quot;tab&quot;&gt;
	&lt;li id=&quot;item1&quot; class=&quot;li-item selected&quot;&gt;Item 1 text&lt;/li&gt;
	&lt;li id=&quot;item3&quot; class=&quot;li-item selected&quot;&gt;Item 3 text&lt;/li&gt;
	&lt;li id=&quot;item7&quot; class=&quot;li-item selected&quot;&gt;Item 7 text&lt;/li&gt;
	&lt;li id=&quot;item8&quot; class=&quot;li-item selected&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
&lt;ul id=&quot;all-categories&quot; class=&quot;tab&quot;&gt;
	&lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 1 text&lt;/li&gt;
	&lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 2 text&lt;/li&gt;
	&lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 3 text&lt;/li&gt;
	&lt;li id=&quot;item4&quot; class=&quot;li-item&quot;&gt;Item 4 text&lt;/li&gt;
	&lt;li id=&quot;item5&quot; class=&quot;li-item&quot;&gt;Item 5 text&lt;/li&gt;
	&lt;li id=&quot;item6&quot; class=&quot;li-item&quot;&gt;Item 6 text&lt;/li&gt;
	&lt;li id=&quot;item7&quot; class=&quot;li-item&quot;&gt;Item 7 text&lt;/li&gt;
	&lt;li id=&quot;item8&quot; class=&quot;li-item&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>&nbsp;</p>
<h2>The CSS</h2>
<p>You do not need to use this. You can use your own CSS.</p>
<pre class="brush: css; wrap-lines: false;">
#tabs { margin: 0 0 -2px 0; height: 45px; }
	#tabs b { display: block; float: left; margin: 0px; background: #fff; font-weight: normal; }
		#tabs b.active { background: #e0d3e3; }
		#tabs b.active a { color: #663366; }
		#tabs b.inactive a:hover { background: #f5edf6; }

	#tabs b a { display: block; color: #a989b0; padding: 10px; border: 1px solid #d3d3d3; text-decoration: none; }
	#tabs b a:hover { background: #f5edf6; }

.tab { clear: both; width: 100%; height: 250px; margin: 0; padding: 0!important; overflow: hidden; overflow-y: scroll; background: #fff; border: 1px solid #d3d3d3; }
	.tab li { font-weight: normal; padding: 10px!important; margin: 0!important; border-bottom: 1px dotted #d3d3d3; cursor: pointer; color: #663366; background-image: none!important; }
		.tab li:hover { background: #e0d3e3; }
	.tab li.selected { background: #956a99; color: #fff; }
		.tab li.selected:hover { background: #b592b8; color: #fff; }
</pre>
<p>&nbsp;</p>
<h2>The Javascript</h2>
<p>bind events to the lists</p>
<p><strong>Dual Lists Mode:</strong></p>
<pre class="brush: jscript; wrap-lines: false;">
        if ( $('#selected-categories').length &gt; 0 ) {
                ls.init({
                        variable      : '#selected-categories',  // the list that is updated to reflect user's selections
                        clickable     : 'li',                             // the element on which to bind the click event
                        update_list  : true,
                        constant     : '#all-categories'          // the list the user makes selections from
                });
        }
</pre>
</p>
<p><strong>Single List Mode:</strong></p>
<pre class="brush: jscript; wrap-lines: false;">
        if ( $('#selected-categories').length &gt; 0 ) {
                ls.init({
                        variable      : '#selected-categories',  // the list that is updated to reflect user's selections
                        clickable     : 'li',                             // the element on which to bind the click event
                        update_list  : false
                });
        }
</pre>
</p>
<p>&nbsp;</p>
<p>the code that makes it work</p>
<pre class="brush: jscript; wrap-lines: false;">
ls = {

	/* *************************************************************************
	*
	* start the initial binding of the list columns
	*
	************************************************************************* */
	init : function( params ) {

		var p = params;

		$(p._variable + &quot; &quot; + p._clickable).unbind('click');
		$(p._variable + &quot; &quot; + p._clickable).bind('click', function() {
			ls.move_left( p, $(this) );
		});

		if ( p._update_list ) {
			$(p._constant + &quot; &quot; + p._clickable).unbind('click');
			$(p._constant + &quot; &quot; + p._clickable).bind('click', function() {
				ls.move_right( p, $(this) );
			});
		}

		// update the list array field
		ls.track_selected_elements( p );

	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* Moves selected element from the variable list to the constant list
	*
	************************************************************************* */
	move_left : function( p, obj ) {

		var p = p;

		if ( p._update_list ) {

			obj_id = $( obj ).attr('id');

			// this object exists in the other list
			// just remove it from existing list
			if ( $( p._constant ).find( '#' + obj_id ).length &gt; 0 ) {
				obj.remove();
				$( p._constant ).find( '#' + obj_id ).removeClass('selected');

			} else {
				$(p._constant).append( obj );
				obj.removeClass( 'selected' );

				ls.sort_list( p, p._constant );
				obj.unbind('click');
				obj.bind('click', function() {
					ls.move_right( p, $(this) );
				});
			}

		} else {
			if ( obj.hasClass('selected') ) {
				obj.removeClass( 'selected' );
			} else {
				obj.addClass( 'selected' );
			}
		}

		// update the list array field
		ls.track_selected_elements( p );
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* Moves selected element from the contstant list to the variable list
	*
	************************************************************************* */
	move_right : function( p, obj ) {

		var p = p;

		obj_id = $( obj ).attr('id');

		// this object exists in the other list
		// just remove it from existing list
		if ( $( p._variable ).find( '#' + obj_id ).length &gt; 0 ) {
			obj.remove();

		} else {
			$(p._variable).append( obj );
			obj.addClass( 'selected' );

			ls.sort_list( p, p._variable );
			obj.unbind('click');
			obj.bind('click', function() {
				ls.move_left( p, $(this) );
			});
		}

		// update the list array field
		ls.track_selected_elements( p );
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* When append to the list(s), the ordering is off. This alphabetically
	* sort the list items
	*
	************************************************************************* */
	sort_list : function ( p, obj ) {

		var parent = obj;

		var items = $(obj + ' ' + p._clickable).get();
		items.sort(function(a,b){
			var keyA = $(a).text();
			var keyB = $(b).text();

			if (keyA &lt; keyB) return -1;
			if (keyA &gt; keyB) return 1;
			return 0;
		});
			var ul = $(parent);
			$.each(items, function(i, li){
				ul.append(li);
			});
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* appends the list of selected LI elements in a hidden input box. will
	* allow you to get the values on form post without any jquery or javascript
	*
	************************************************************************* */
	track_selected_elements : function( p ) {
			var p = p;
			var ls_list_array = [];

			_class = ( p._update_list ) ? '' : '.selected';

			/* *******************************************
			* remove the old list to null it out        */
				$('#ls_update_list_array').remove();

			/* ******************************************
			* get the complete list of selected li's   */
				$(p._variable + ' li' + _class).each(function() { ls_list_array.push($(this).attr('id')) });

			/* *******************************************
			* append the array list as an hidden input  */
				var ls_input = '&lt;input type=&quot;hidden&quot;'
							+ 'id=&quot;ls_update_list_array&quot; '
							+ 'name=&quot;ls_update_list_array&quot; '
							+ 'value=&quot;' + ls_list_array + '&quot; /&gt;'

				$(p._variable).append(ls_input)
	}
}
</pre>
<p>&nbsp;</p>
<h2>Dual List Example</h2>
<div id="tabs"><b class="active"><a href="#selected-categories">Currently Selected Categories</a></b><b class="inactive"><a href="#all-categories">All Available Categories</a></b></div>
<ul id="selected-categories" class="tab">
<li id="item1" class="li-item selected">Item 1 text</li>
<li id="item3" class="li-item selected">Item 3 text</li>
<li id="item7" class="li-item selected">Item 7 text</li>
<li id="item8" class="li-item selected">Item 8 text</li>
</ul>
<ul id="all-categories" class="tab">
<li id="item2" class="li-item">Item 2 text</li>
<li id="item4" class="li-item">Item 4 text</li>
<li id="item5" class="li-item">Item 5 text</li>
<li id="item6" class="li-item">Item 6 text</li>
</ul>
<p>&nbsp;</p>
<h2>Single List Eample</h2>
<div id="sel-cat-tab"><b class="active"><a href="#">Currently Selected Categories</a></b></div>
<ul id="selected-categories-single">
<li id="item1" class="li-item">Item 1 text</li>
<li id="item2" class="li-item">Item 2 text</li>
<li id="item3" class="li-item selected">Item 3 text</li>
<li id="item4" class="li-item">Item 4 text</li>
<li id="item5" class="li-item selected">Item 5 text</li>
<li id="item6" class="li-item selected">Item 6 text</li>
<li id="item7" class="li-item">Item 7 text</li>
<li id="item8" class="li-item">Item 8 text</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Tabs With Ease</title>
		<link>http://jjis.me/a/280</link>
		<comments>http://jjis.me/a/280#comments</comments>
		<pubDate>Sat, 03 Jul 2010 01:50:19 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=280</guid>
		<description><![CDATA[As usual, I always need something special in jQuery. I&#8217;m always able to find plugins out there, but they never everything I want, the way I want it done. Each always falls short somewhere. It either limits my design flexibility, is buggy or is just flat-out bloated with way more code than is necessary. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>As usual, I always need something special in jQuery. I&#8217;m always able to find plugins out there, but they never everything I want, the way I want it done. Each always falls short somewhere. It either limits my design flexibility, is buggy or is just flat-out bloated with way more code than is necessary.</p>
<p>I&#8217;ve written a tabs script for jQuery that is short and to the point while still allowing for design flexibility and ease. There&#8217;s nothing to it. Simply establish the tabs settings with your appropriate IDs and classes and you&#8217;re good to go. I&#8217;ve used on a few occasions and it has yet to fail me.</p>
<p>As usual, however, let me know if you have problems. I&#8217;ve supplied complete code for HTML, CSS and, of course, the jQuery/JavaScript.</p>
<p><span id="more-280"></span></p>
<h2></h2>
<h2>Let&#8217;s Start With The HTML</h2>
<pre class="brush: xml; wrap-lines: false;">
&lt;div id=&quot;tabs&quot;&gt;
	&lt;b class=&quot;active&quot;&gt;&lt;a href=&quot;#selected-categories&quot;&gt;Currently Selected Categories&lt;/a&gt;&lt;/b&gt;
	&lt;b class=&quot;inactive&quot;&gt;&lt;a href=&quot;#all-categories&quot;&gt;All Available Categories&lt;/a&gt;&lt;/b&gt;
&lt;/div&gt;

&lt;ul id=&quot;selected-categories&quot; class=&quot;tab&quot;&gt;
        &lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 1 text&lt;/li&gt;
        &lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 3 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 7 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
&lt;ul id=&quot;all-categories&quot; class=&quot;tab&quot;&gt;
        &lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 1 text&lt;/li&gt;
        &lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 2 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 3 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 4 text&lt;/li&gt;
        &lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 5 text&lt;/li&gt;
        &lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 6 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 7 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
</pre>
<h2>The CSS</h2>
<pre class="brush: css; wrap-lines: false;">
/* *****
* tab header properties
***** */
#tabs { margin: 0 0 -2px 0; height: 45px; }
	#tabs b { display: block; float: left; margin: 0px; background: #fff; font-weight: normal; }
	#tabs b.active { background: #e0d3e3; }
		#tabs b a { display: block; color: #a989b0; padding: 10px; border: 1px solid #d3d3d3; text-decoration: none; }
		#tabs b a:hover { background: #f5edf6; }

		#tabs b.active a { color: #663366; }
		#tabs b.inactive a:hover { background: #f5edf6; }

/* *****
* tab content
***** */
.tab { clear: both; width: 100%; height: 250px; margin: 0; padding: 0; overflow: hidden; overflow-y: scroll; background: #fff; border: 1px solid #d3d3d3; }
	.tab li { font-weight: normal; padding: 10px; border-bottom: 1px dotted #d3d3d3; cursor: pointer; color: #663366; }
	.tab li:hover { background: #e0d3e3; }
</pre>
<h2></h2>
<h2>The jQuery Code</h2>
<pre class="brush: jscript; wrap-lines: false;">

/* *************************************************
*
* configuration: settings for class &amp; ids of tab
* elements
************************************************* */
var tabs = {
	default_tab    : 0,                    // the # of the tab that should be shown on page load
	// the tab itself
	tab : {
		wrapper   : '#tabs',          // parent that wraps around each tab header
		container : 'b',                // the container that wraps around the clickable tab text
		clickable : 'a',                 // the clickable tab text
		_class     : {
			active   : 'active',   // class for the active tab
			inactive : 'inactive' // class for all inactive tabs
		}
	},
	// the content for each tab
	content : {
		_class  : '.tab'                 // class of the content for the tabs
	},

	/* *************************************************
	*
	* bind tabbing events
	*
	************************************************* */
	init : function() {
		$( tabs.tab.wrapper + ' ' + tabs.tab.clickable ).click(function() {
			var id 	= $(this).attr('href');
			var par 	= $(this).parent();

			// hide all tab content
			$.each( $( tabs.content._class ), function(i) {
				$( this ).css( 'display','none' );
			});

			// display the tab content chosen
			$( id ).css('display','block');

			// show the tab as clicked
			$.each( $( tabs.tab.wrapper + ' ' + tabs.tab.container ), function() {
				$( this ).removeClass( tabs.tab._class.active );
				$( this ).addClass( tabs.tab._class.inactive );
			});

			par.removeClass( tabs.tab._class.inactive );
			par.addClass( tabs.tab._class.active );

			return false;
		});

		// hide all tab content except the first tab
		$.each( $( tabs.content._class ), function(i) {
			if (i &gt; tabs.default_tab) {
				$( this ).css('display','none');
			}
		});
	}

};
</pre>
<h2></h2>
<h2>Now Initiate the Code</h2>
<pre class="brush: jscript; wrap-lines: false;">
$(document).ready(function() {
        /* ************************************
        * only initiate the tab function if tabs are preset */
	        if ( $('#tabs').length &gt; 0 ) {
		        tabs.init();
	        }
});
</pre>
<p>There you go. That&#8217;s all there is to it. The code is definitely portable and you could make it a plugin yourself if you wanted. I will get it setup to allow multiple sets of tabs per page and update when it&#8217;s completed.</p>
<h2>Example</h2>
<div id="tabs"><b class="active"><a href="#tab-a">Tab A</a></b><b class="inactive"><a href="#tab-b">Tab B</a></b></div>
<ul id="tab-a" class="tab">
<li id="item1" class="li-item">Item 1 text</li>
<li id="item3" class="li-item">Item 3 text</li>
<li id="item7" class="li-item">Item 7 text</li>
<li id="item8" class="li-item">Item 8 text</li>
</ul>
<ul id="tab-b" class="tab">
<li id="item2" class="li-item">Item 2 text</li>
<li id="item4" class="li-item">Item 4 text</li>
<li id="item5" class="li-item">Item 5 text</li>
<li id="item6" class="li-item">Item 6 text</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/280/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database PHP Class</title>
		<link>http://jjis.me/a/253</link>
		<comments>http://jjis.me/a/253#comments</comments>
		<pubDate>Tue, 15 Jun 2010 17:38:25 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=253</guid>
		<description><![CDATA[I&#8217;m back with another chunk of code. This time, it&#8217;s my database class. I got sick of coming across classes that didn&#8217;t have everything I needed, or didn&#8217;t do it correctly. One of my biggest problems was an inability to nest query calls within another query result&#8217;s output. Example: &#60;?php // main query // gets [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m back with another chunk of code.  This time, it&#8217;s my database class.</p>
<p>I got sick of coming across classes that didn&#8217;t have everything I needed, or didn&#8217;t do it correctly.  One of my biggest problems was an inability to nest query calls within another query result&#8217;s output.</p>
<p><span id="more-253"></span></p>
<h2>Example:</h2>
<pre class="brush: php; wrap-lines: false;">
&lt;?php

// main query
// gets a list of companies from the companies table
$a = &quot;SELECT id, company_name FROM companies&quot;;
$a = $db-&gt;query($a);

while  ($aa = $db-&gt;fetch_object($a) ) :

     echo '&lt;div class=&quot;company_name&quot;&gt;' . $aa-&gt;company_name . '&lt;/div&gt;';

     // get the contacts for each company
     $b = &quot;SELECT contact_name, phone1 FROM contacts WHERE company_id = $aa-&gt;id&quot;; // because we've already used $a, we can't use it again during $a's output
     $b = $db-&gt;query($b);

     // output all contacts for the each company
     while ( $bb = $db-&gt;fetch_object($b) ) : // the same thing as $a, we can not use $aa again during its output
          echo '&lt;div class=&quot;contact_name&quot;&gt;' . $bb-&gt;contact_name . '&lt;/div&gt;';
          echo '&lt;div class=&quot;contact_phone&quot;&gt;' . $bb-&gt;phone1 . '&lt;/div&gt;';
     endwhile;

endwhile;

?&gt;
</pre>
<p>With this class, that is not a problem. The only requirement is that you can&#8217;t name your $sql and $results ($row) variables the same (noted in the code above). Other than that, there&#8217;s nothing to it. It&#8217;s just a way to provide clean, and efficient database interaction.</p>
<h2>Database.Core.php Code</h2>
<ul>
<li>
<p><strong>Updated 06-23-2010: </strong></p>
<ul>
<li>Renamed main database class file to Database.Core.php</li>
<li>Removed the $connection settings and placed them in the Database.Connect.Config.php file. Helps keep hands out of the core file.</li>
<li><strong>show_mysql_error(): </strong>edited so it only receives and passes the original SQL statement, to the error_backtrace() method, upon error.</li>
<li><strong>query(): </strong> no longer fires the die() function and close_db() method. Send the erroring SQL statement to show_mysql_error() method for handling of error output.</li>
<li><strong>multi_query(): </strong> no longer fires the die() function and close_db() method. Send the erroring SQL statement to show_mysql_error() method for handling of error output.</li>
<li><strong>error_backtrace(): </strong>replaced previous method with cleaner code. The error now has formattting for easier readability.</li>
</ul>
</li>
</ul>
<pre class="brush: php; wrap-lines: false;">

&lt;?php
/* **********************************************************************
*
* 	DB connection variables
*	Must be set in order to establish a connection to the database
*
********************************************************************** */

$connection = (object) array();
require ( 'Database.Connect.Config.php' );

/* **********************************************************************
* END :::
********************************************************************** */

/* **********************************************************************
*	DatabaseFunctions is a class created to manage database functions
*
*	The class manages all database interraction for purpose of allowing certain things to be
*	turned on and off.  An example would be Error Reporting.  Once the application is on the live
*	server, we can set $config-&gt;ShowErrors to false and error reporting for database erros will no
*	be shown.
*
*	This is real simply to use
*
*	Examples:
*
**********
*
*		Get number of rows returned in a query (you can also nest this:
*			$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;; // would return 4 rows
*			$sql = $db-&gt;fetch_object($sql);
*			$rows = $db-&gt;num_rows();
*			echo $rows; // 4
*
*		Nested num_rows();
*			$a = &quot;SELECT fieldA FROM tableA&quot;; // would return 2 rows
*			$a = $db-&gt;fetch_object($a);
*			$a_rows = $db-&gt;num_rows();
*			echo $a_rows; // 2
*
*			while ($aa = $db-&gt;fetch_object($a) ) :
*				$b = &quot;SELECT fieldA FROM tableA&quot;; // would return 6 rows
*				$b = $db-&gt;fetch_object($b);
*				$b_rows = $db-&gt;num_rows();
*					echo $b_rows; // 6
*			endwhile;
*
*
**********
*
*
*		Results as Object:
*			$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;;
*			$sql = $db-&gt;fetch_object($sql);
*
*			while ($row = $db-&gt;fetch_object($sql) ) :
*				echo $row-&gt;fieldA . ': ' . $row-&gt;fieldB;
*			endwhile;
*
*
**********
*
*
*		Results as Array:
*			$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;;
*			$sql = $db-&gt;fetch_object($sql);
*
*			while ($row = $db-&gt;fetch_array($sql) ) :
*				echo $row['fieldA'] . ': ' . $row['fieldB'];
*			endwhile;
*
*
**********
*
*
*		Return value of a row or field in a row ( uses the rather inefficient mysql_fetch_row() )
*			$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;;
*			$val = $db-&gt;fetch_row(1);        // would return fieldB's value
*				-- OR --
*			$val = $db-&gt;fetch_row('fieldA'); // would obviously return fieldA's value
*
*
**********
*
*
*		Return value of a query more efficiently (avoids the inefficient mysql_fetch_row() function)
*			$sql = &quot;SELECT fieldA FROM tableA&quot;;
*			$fieldA = $db-&gt;fetch_value($sql); // would return fieldA's value
*
*
**********
*
*
*		 Return the query result set as an array:
*			$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;; // returns 4 rows
*			$results = $db-&gt;to_array($sql);
*
*			$results[0]['fieldA'] = 'valueA 1';
*			$results[0]['fieldB'] = 'valueB 1';
*
*			$results[1]['fieldA'] = 'valueA 2';
*			$results[1]['fieldB'] = 'valueB 2';
*
*			$results[2]['fieldA'] = 'valueA 3';
*			$results[2]['fieldB'] = 'valueB 3';
*
*			$results[3]['fieldA'] = 'valueA 4';
*			$results[3]['fieldB'] = 'valueB 4';
*
*
********************************************************************** */

class System_Database {

	# set whether errors should be displayed or not
	# probably want to turn off once site is live
	var $displayErrors = false;

	/* ****************************************************************
	*
	* Establish connection to the database
	* Be sure to set the connection info above
	*
	**************************************************************** */
	function connect() {
		global $connection;
		$connection-&gt;mysqlLink = mysql_connect($connection-&gt;host, $connection-&gt;user, $connection-&gt;password);

		# The connection failed for some reason
		if ( !isset($connection-&gt;mysqlLink) ) :
			die(&quot;Error connecting to the server&quot;);

		# The connection is good so lets get the Application Config Settings
		# and create the $config object
		elseif ( isset($connection-&gt;mysqlLink) ) :
			$db_selected = mysql_select_db($connection-&gt;db);

		endif;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Run the query
	*
	**************************************************************** */
	function sqlId() {
		$id = rand();
		$uniqueId[] = 'sql' . $id;
		$uniqueId[] = 'row' . $id;
		return $uniqueId;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* If $showErrors is set to true or $config-&gt;ShowErrors
	* is set and is true display the error that has occurred
	*
	**************************************************************** */
	function show_mysql_error( $sql ) {
		$this-&gt;error_backtrace( $sql );
		die();
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Run the query
	*
	**************************************************************** */
	function query( $sql ) {
		$this-&gt;result=mysql_query( $sql );
		if ( !$this-&gt;result ) :

			$this-&gt;show_mysql_error( $sql );

		else :

			return $this-&gt;result;

		endif;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Connect to the server using the mysqli extension
	* This is used automatically during multi_query()
	*
	**************************************************************** */
	function mySqliConnect() {
		global $connection;
		$connection-&gt;mySqli = new mysqli($connection-&gt;host, $connection-&gt;user,  $connection-&gt;password, $connection-&gt;db);
		return $connection-&gt;mySqli;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Close the mysqli connection once we have finished
	* using the multi_query() method
	*
	**************************************************************** */
	function mySqliClose() {
		global $connection;
		mysqli_close($connection-&gt;mySqli);
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Execture the multi-query
	*
	**************************************************************** */
	function multi_query( $sql ) {

		$mysqli = $this-&gt;mySqliConnect();

		$this-&gt;result=mysqli_multi_query( $mysqli, $sql );

		if ( !$this-&gt;result ) :
			$this-&gt;show_mysql_error( $sql );
		else :
			$this-&gt;mySqliClose();
			return $this-&gt;result;
		endif;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Returns the results of the query as an object
	*
	* Example:
	*	$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;;
	*	$sql = $db-&gt;fetch_object($sql);
	*
	*	while ($row = $db-&gt;fetch_object($sql) ) :
	*		echo $row-&gt;fieldA . ': ' . $row-&gt;fieldB;
	*	endwhile;
	*
	**************************************************************** */
	function fetch_object( $sql ) {
		$uniqueIdentifier=rand();
		$$uniqueIdentifier=mysql_fetch_object( $sql );
		return $$uniqueIdentifier;
		unset( $$uniqueIdentifier );
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Returns the results of the query as an array
	*
	* Example:
	*	$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;;
	*	$sql = $db-&gt;fetch_object($sql);
	*
	*	while ($row = $db-&gt;fetch_object($sql) ) :
	*		echo $row['fieldA'] . ': ' . $row['fieldB'];
	*	endwhile;
	*
	**************************************************************** */
	function fetch_array( $sql ) {
		$uniqueIdentifier=rand();
		$$uniqueIdentifier=mysql_fetch_array( $sql );
		return $$uniqueIdentifier;
		unset( $$uniqueIdentifier );
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Returns the number of rows returned in a query
	*
	**************************************************************** */
	function num_rows($result='') {
		$uniqueIdentifier=rand();
		if (empty($result)) $result = $this-&gt;result;
		$$uniqueIdentifier=mysql_num_rows( $result );
		return $$uniqueIdentifier;
		unset( $$uniqueIdentifier );
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Returns the number of rows affected by a query
	*
	**************************************************************** */
	function rows_affected($result='') {
		$uniqueIdentifier=rand();
		if (empty($result)) $result = $this-&gt;result;
		$$uniqueIdentifier = mysql_rows_affected( $result );
		return $$uniqueIdentifier;
		unset( $$uniqueIdentifier );
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Runs the mysql_result() function, but a little differently
	*
	* if $this-&gt;fetch_row(1), it will return the second field
	* of the first row
	*
	* if $this-&gt;fetch_row('field_name'), it will return the value
	* for 'field_name' in the first row
	*
	**************************************************************** */
	function fetch_row ( $fieldName ) {
		if (is_numeric( $fieldName )) {
			$fieldValue=mysql_result( $this-&gt;result, $fieldName );
		} else {
			$fieldValue=mysql_result( $this-&gt;result, 0, $fieldName );
		}
		return $fieldValue;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Returns the value of the specified field, in the specified
	* row.
	*
	* If no field or row is specified, it will default to first
	* row, first field
	*
	**************************************************************** */
	function fetch_value ( $sql='', $fieldName='', $row='' ) {
		$i=0;
		$fieldValue = false;

		if (empty($fieldName)) { $fieldName = 0; }
		if (empty($row)) { $row = 0; }
		$ret = array();
		$sql = $this-&gt;query($sql);
		if ($this-&gt;num_rows() &gt; 0) {
			while ($rec = mysql_fetch_array( $sql )) {
				for ($a=0; $a &lt; count($rec); $a++) {
					$ret[$i] = $rec;
				}
				$i++;
			}

			$fieldValue=$ret[$row][$fieldName];
		}

		return ($fieldValue);
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Returns the results of the query as an array
	*
	* Example:
	*	$sql = &quot;SELECT fieldA, fieldB FROM tableA&quot;; // returns 4 rows
	*	$results = $db-&gt;to_array($sql);
	*
	*	$results[0]['fieldA'] = 'valueA 1';
	*	$results[0]['fieldB'] = 'valueB 1';
	*
	*	$results[1]['fieldA'] = 'valueA 2';
	*	$results[1]['fieldB'] = 'valueB 2';
	*
	*	$results[2]['fieldA'] = 'valueA 3';
	*	$results[2]['fieldB'] = 'valueB 3';
	*
	*	$results[3]['fieldA'] = 'valueA 4';
	*	$results[3]['fieldB'] = 'valueB 4';
	*
	**************************************************************** */
	function to_array ( $sql='' ) {
		$i=0;
		$ret = array();
		$sql = $this-&gt;query($sql);
		while ($row = mysql_fetch_assoc( $sql )) {
			for ($a=0; $a &lt; count($row); $a++) {
				$ret[$i] = $row;
			}
			$i++;
		}
		return ($ret);
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* closes the database connection
	*
	* PHP nowadays does a really good job of trashing these connection
	* automatically. However, just to be safe, I typically call this
	* method in an include that is loaded after everything else
	*
	**************************************************************** */
	function close_db() {
		global $connection;
		if ($connection-&gt;mysqlLink) :
			mysql_close( $connection-&gt;mysqlLink );
		endif;
	}
	/* ****************************************************************
	* end :::
	**************************************************************** */

	/* ****************************************************************
	*
	* Will format system errors and display them
	*
	**************************************************************** */
	function error_backtrace( $sql ) {

		$errorsThrown = debug_backtrace();
		$errorThrown = $errorsThrown[2];

		echo &quot;
		&lt;style&gt;
			#error-container { width: 100%; color: #333!important; position: relative; background-color: #f3f3f3; border-bottom: 1px dotted #333; }
			#error-wrapper { font: 110%/0.8em arial!important; letter-spacing: 0.02em; width: 850px!important; background-color: #f3f3f3!important; padding: 10px!important; }
			#error-wrapper a { color: #cc6600; }
			#primary-error td { color: #333!important; padding: 4px!important; border: 1px solid #f3f3f3!important; }
			#primary-error td.left {
				width: 120px;
				text-align: right;
				padding: 8px 4px 8px 8px!important;
				margin: 0 8px 1px 0!important;
				background-color: #d3d3d3!important;
			}
			#error-wrapper p { text-align: left; padding: 18px; clear: both!important; }

			#previous-errors th { color: #333!important; padding: 6px; }
			#previous-errors td { color: #333!important; padding: 4px; border-top: 1px solid #666; border-right: 1px solid #666; }
		&lt;/style&gt;
		&quot;;

		echo &quot;&lt;div id=\&quot;error-container\&quot;&gt;&quot;
			. &quot;&lt;div id=\&quot;error-wrapper\&quot;&gt;&quot;
			. &quot;&lt;table id=\&quot;primary-error\&quot;&gt;\n&quot;
			. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Error: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Database error&lt;/td&gt;&lt;/tr&gt;\n&quot;
			. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;SQL: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $sql . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
			. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;MySQL Error: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . mysql_error() . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
			. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;Calling Function: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot; . $errorThrown['function'] . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
			. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;File Name: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot;.$errorThrown['file'].&quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;
			. &quot;&lt;tr&gt;&lt;td class=\&quot;left\&quot;&gt;&lt;strong&gt;On line: &lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot;.$errorThrown['line'].&quot;&lt;/td&gt;&lt;/tr&gt;\n&lt;/table&gt;\n&quot;
			. '&lt;p&gt;&amp;nbsp;&lt;/p&gt;'
			. '&lt;/div&gt;&lt;/div&gt;';
	}
	/* ****************************************************************
	* END :::
	**************************************************************** */

}
/* *********************************************************************************
* END :::
********************************************************************************* */

$db = new System_Database;
?&gt;
</pre>
<h2>Database.Connect.Config.php Code</h2>
<p><em>used for establishing the connection information for your database. this file is automatically included in the Database.Core.php file. just drop it in the same folder and you&#8217;re good to go.</em></p>
<pre class="brush: php; wrap-lines: false;">

&lt;?php
	$connection-&gt;host           = 'localhost';
	$connection-&gt;user           = 'user_name';
	$connection-&gt;password    = 'your_password';
	$connection-&gt;db             = 'your_database';
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/253/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Accordian without plug-ins &amp; with a bit of design freedom</title>
		<link>http://jjis.me/a/209</link>
		<comments>http://jjis.me/a/209#comments</comments>
		<pubDate>Sun, 13 Jun 2010 14:47:40 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=209</guid>
		<description><![CDATA[So you have a design and you have decided you want to use a jQuery accordion. You start to layout your design and implement the accordion only to find out that your design is going to cause problems with the standard accordion plug-ins. The problem with the standard accordion is that they require the child [...]]]></description>
			<content:encoded><![CDATA[<p>So you have a design and you have decided you want to use a jQuery accordion. You start to layout your design and implement the accordion only to find out that your design is going to cause problems with the standard accordion plug-ins.</p>
<p>The problem with the standard accordion is that they require the child and header elements to be nested within a parent.</p>
<p><span id="more-209"></span></p>
<h2>Example:</h2>
<pre class="brush: xml; wrap-lines: false;">
&lt;div id=&quot;accordion-wrapper&quot;&gt;
     &lt;h1&gt;Clickable Header 1&lt;/h1&gt;
          &lt;p&gt;Collapsible child 1&lt;/p&gt;
     &lt;h1&gt;Clickable Header 2&lt;/h1&gt;
          &lt;p&gt;Collapsible child 2&lt;/p&gt;
     &lt;h1&gt;Clickable Header 3&lt;/h1&gt;
          &lt;p&gt;Collapsible child 3&lt;/p&gt;
&lt;/div&gt;
</pre>
<p>Where this limits us in our design is when we want to add some extra style to the accordion list. I tend to use lists when building a list. So, if we take the code above and wrap each header and collapsible child with an &lt;li&gt;, we would completely break the accordion.</p>
<h2>Let&#8217;s break it down</h2>
<p>The standard jQuery accordion would prohibit this because the layout would throw off the jQuery plugin. The plugins look at the wrapping element (in this case &#8220;accordion-wrapper&#8221;). It then finds all header (&lt;h1&gt;) elements and binds the click event. This click event finds the first occurrence of the collapsible element (&lt;p&gt;) and will either expand or collapse it depending on it&#8217;s current state.</p>
<h2>Let&#8217;s fix this</h2>
<p>With the following script, you simply specify what the header class is going to be and what the collapsible class is going to be. What this allows us to do is place our accordion headers and collapsible elements within structured list, thus allowing more design/layout freedom.</p>
<h2>Example:</h2>
<pre class="brush: xml; wrap-lines: false;">
&lt;ul id=&quot;accordion-list&quot;&gt;
	&lt;li class=&quot;accordion-item&quot;&gt;
		&lt;h1 class=&quot;accordion-header&quot;&gt;Clickable Header 1&lt;/h1&gt;
		&lt;p&gt;Just placed here for an example of how we don't have our header and collapsible elements stacked&lt;/p&gt;
			&lt;ul class=&quot;accordion-collapsible&quot;&gt;
				&lt;li&gt;Collapsible child 1&lt;/li&gt;
				&lt;li&gt;Collapsible child 2&lt;/li&gt;
				&lt;li&gt;Collapsible child 3&lt;/li&gt;
				&lt;li&gt;Collapsible child 4&lt;/li&gt;
			&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li class=&quot;accordion-item&quot;&gt;
		&lt;h1 class=&quot;accordion-header&quot;&gt;Clickable Header 2&lt;/h1&gt;
		&lt;p&gt;Just placed here for an example of how we don't have our header and collapsible elements stacked&lt;/p&gt;
			&lt;ul class=&quot;accordion-collapsible&quot;&gt;
				&lt;li&gt;Collapsible child 1&lt;/li&gt;
				&lt;li&gt;Collapsible child 2&lt;/li&gt;
				&lt;li&gt;Collapsible child 3&lt;/li&gt;
				&lt;li&gt;Collapsible child 4&lt;/li&gt;
			&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li class=&quot;accordion-item&quot;&gt;
		&lt;h1 class=&quot;accordion-header&quot;&gt;Clickable Header 3&lt;/h1&gt;
		&lt;p&gt;Just placed here for an example of how we don't have our header and collapsible elements stacked&lt;/p&gt;
			&lt;ul class=&quot;accordion-collapsible&quot;&gt;
				&lt;li&gt;Collapsible child 1&lt;/li&gt;
				&lt;li&gt;Collapsible child 2&lt;/li&gt;
				&lt;li&gt;Collapsible child 3&lt;/li&gt;
				&lt;li&gt;Collapsible child 4&lt;/li&gt;
			&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>&nbsp;</p>
<h2>The jQuery Code:</h2>
<pre class="brush: jscript; wrap-lines: false;">
$(document).ready(function() {
	/* ***
	* REQUIRED
	* set you classes accordingly below. */
	var accordion = {
		parent      : '.accordion-item',        // parent element containing the clickable header and collapsible
		header      : '.accordion-header',      // clickable header
		collapsible : '.accordion-collapsible'  // collapsible element
	};

	/* ***
	* hide all collapsible items */
	$(accordion.collapsible).css('display','none');

	/* ****
	* bind the accordion header click event */
	$(accordion.header).unbind('click');
	$(accordion.header).bind('click', function() {
		var header_obj      = $(this);          // The current header
		var next_parent_obj = $(this).parent(); // The parent of the header

		var content_obj = $(this).siblings(accordion.collapsible); // find the collapsible element

		if(content_obj.is(&quot;:hidden&quot;)) {
			// collapse all collapsible elements
			next_parent_obj.siblings(accordion.parent).each(function() {
				$(this).children(accordion.collapsible).slideUp('fast');
			});
			// show the content of the clicked header
			content_obj.slideDown('fast');
		} else {
			content_obj.slideUp('fast');
		}
	});
});
</pre>
<p>&nbsp;</p>
<h2>Seeing it in action</h2>
<p><span><br /></span></p>
<ul id="accordion-list">
<li class="accordion-item">
<h1 class="accordion-header">Clickable Header 1</h1>
<p>Just placed here for an example of how we don&#8217;t have our header and collapsible elements stacked</p>
<ul class="accordion-collapsible">
<li>Collapsible child 1</li>
<li>Collapsible child 2</li>
<li>Collapsible child 3</li>
<li>Collapsible child 4</li>
</ul>
</li>
<li class="accordion-item">
<h1 class="accordion-header">Clickable Header 2</h1>
<p>Just placed here for an example of how we don&#8217;t have our header and collapsible elements stacked</p>
<ul class="accordion-collapsible">
<li>Collapsible child 1</li>
<li>Collapsible child 2</li>
<li>Collapsible child 3</li>
<li>Collapsible child 4</li>
</ul>
</li>
<li class="accordion-item">
<h1 class="accordion-header">Clickable Header 3</h1>
<p>Just placed here for an example of how we don&#8217;t have our header and collapsible elements stacked</p>
<ul class="accordion-collapsible">
<li>Collapsible child 1</li>
<li>Collapsible child 2</li>
<li>Collapsible child 3</li>
<li>Collapsible child 4</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/209/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>tnyb.it twitter UI</title>
		<link>http://jjis.me/a/191</link>
		<comments>http://jjis.me/a/191#comments</comments>
		<pubDate>Tue, 01 Jun 2010 06:08:26 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[tnyb.it]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=191</guid>
		<description><![CDATA[This is a new Twitter app I am currently building for http://tnyb.it. It should be online soon. I will be making mobile browser compatible as well. I would make an iPhone version, but since I don&#8217;t have a Mac, that&#8217;s not going to happen (maybe one day).]]></description>
			<content:encoded><![CDATA[<p>This is a new Twitter app I am currently building for <a href="http://tnyb.it">http://tnyb.it</a>. It should be online soon. I will be making mobile browser compatible as well. I would make an iPhone version, but since I don&#8217;t have a Mac, that&#8217;s not going to happen (maybe one day).</p>
<p><a href="http://jjis.me/wp-content/uploads/twitter-app-screenshot.png"><img class="alignnone size-full wp-image-202" title="http://tnyb.it Twitter app screenshot" src="http://jjis.me/wp-content/uploads/twitter-app-screenshot.png" alt="" width="447" height="821" /></a><br class="spacer_" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/191/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
