/*
 * Ajaxify - jQuery Plugin
 * version: 2.00 (11/12/2008)
 * Created by: MaX
 * Examples and documentation at: http://max.jsrhost.com/ajaxify/
 * licensed under and GPL licenses:
 * http://www.gnu.org/licenses/gpl.html
 */

(function($){


jQuery.AjaxifyDefaults = {  
		event:'click', /*specify the event*/
		link:false, /* specify the link, priority is for the href attr.*/
		target:'#container', /*the data loaded via ajax will be placed here*/
		animateOut:false,
		animateIn:false,
		animateOutSpeed:'normal',
		animateInSpeed:'normal',
		method: 'GET', /* the request method GET or POST*/
		tagToload:false, /* inserts just the tag from the data loaded, it can be specified as t a second argument in the 'target' attr(#box,#result)*/
		loading_txt:'',
		loading_img:"images/loading.gif",
		loading_target: false,
		loading_fn:function(options){
			jQuery.ajaxifyLoading(options);
		},
		loadHash:false,	/* for use this to resolve bookmarking issues, see example for more details*/
		title:false, /* change page title along with the request. */
		forms:false, /* send form data along with th request (forms, input , radio ... etc jquery selector) */
		params:'ajax=true',/*extend parameters for the webpage. it can be set to function since v2*/
		timeout:false, /*in ms.  there is a problem in this option on linux servers*/
		contentType:"application/x-www-form-urlencoded",
		dataType:'html',
		cache:false, /* force the browser not to cache*/
		username:false, /*username HTTP access authentication*/
		password:false, /*password HTTP access authentication*/
		onStart:function(op){}, /* a callback function before start requesting.*/
		onError:function(op){
			jQuery.ajaxifyManip(op,"<font style='color: #CC0000'>Error: </font> Couldn't open the page.");		
		}, /* a callback function if error happened while requesting*/
		onSuccess:function(op){},/* a callback function if the request finished successfuly*/
		onComplete:function(op){}//*a callback function when the request finished weather it was a successful one or not.*/
	};
jQuery.AjaxifyFirstLoad = true;
jQuery.AjaxifyhistorySet = new Object();
jQuery.AjaxifyPageTitle = document.title;
jQuery.AjaxifyDebug = false;



jQuery.fn.ajaxify = function(options) {  
	

	/*jQuery.ajaxifylog('fn.ajaxify');
	jQuery.ajaxifylog(options.loading_img);
	jQuery.each(options, function(key, value) {
		jQuery.ajaxifylog(key + ': ' + value);		
	});*/
	
	if(!jQuery(this).size()){
		jQuery.ajaxifylog('Error: No matched element/s for your ajaxify selector " '+jQuery(this).selector+' ".');
		return false;
	}
	var ver = jQuery.fn.jquery.split('.');
	if(ver[0] < 1 || ver[1] < 2 || ver[2] < 6){
		jQuery.ajaxifylog('Error: Your jQuery version is old. Version 1.2.6 or newer is required.');
		return false;
	}
	return this.each(function() {
	var current = jQuery.extend({},jQuery.AjaxifyDefaults, options);
	if(jQuery.metadata){
	current = jQuery.extend(current,jQuery(this).metadata());
	}
	
	
	if(current.event){
		jQuery(this).bind(current.event,function(){		
			jQuery(this).ajaxifyAnalyse(current);
			if(!current.hash)
				jQuery.ajaxifyLoad(current);
			else{
				jQuery.ajaxifyHash(current);
			}
			 //stop browser
			if(jQuery(this).is('a') || jQuery(this).is('form')) return false;
		});
	}else{
		jQuery(this).ajaxifyAnalyse(current);
		jQuery.ajaxifyLoad(current);		
	}	
		//for bookmarking	
		if(current.loadHash && jQuery.AjaxifyFirstLoad){
			jQuery(this).ajaxifyAnalyse(current);
			if(document.location.hash.replace(/^#/, '') == current.hash	&& current.hash){
				jQuery.ajaxifyHash(current);
				jQuery.AjaxifyFirstLoad = false;
			}
		}
		
  }); // end each fn 
}; // end ajaxify fn


 

 
jQuery.fn.ajaxifyAnalyse = function(current){
	
	//jQuery.ajaxifylog('ajaxifyAnalyse');
	
	current.object = this;
	if(jQuery(this).is('a')){
		if(jQuery(this).attr('href') && jQuery(this).attr('href')!='javascript://'){
			//if(jQuery.browser.msie)
				//var link = jQuery(this).attr('href').replace(/^#/, "");
			//else
				var link = jQuery(this).attr('href').replace(/^#/, "");
				//alert(link);
			current.link = link || current.link;
		}else 
			current.link;
			
		if(typeof current.tagToload != 'object')
			if(jQuery(this).attr('target'))
				current.target = jQuery(this).attr('target');
			else
				current.target;
		else
			current.target = current.loading_target || '#AjaxifyTemp';
	}
	   
	if(!current.loading_target)
	   current.loading_target = current.target;
	   

	if(current.forms){
		var text = jQuery(current.forms).serialize();
		current.paramres = text;
	}
	
	if(typeof current.params == 'function')
		var params = current.params(current);
	else
		var params = current.params;

	if(typeof params == 'string'){
		if(text)
		current.paramres +='&'+params;
		else
		current.paramres = params;
	}
	
	var len = current.target.length-1;
	if(typeof current.tagToload !='object')
		if(current.target.charAt(len) == '+' || current.target.charAt(len)=='-'){
			current.manip = current.target.charAt(len);
			current.target = current.target.substr(0,len);
		}

   	if(current.loadHash){
		if(!jQuery.historyInit){
			jQuery.ajaxifylog('Error: loadHash is enabled but history plugin couldn\'t be found.');
		return false;
		}
		
		if(current.loadHash === true){
			jQuery.ajaxifylog('Info: It seemes you are upgrading from v1.0. Please see the new documentation about loadHash. "attr:href" will be used instead of "true".');
			current.loadHash = "attr:href";
		}
		if(current.loadHash.toLowerCase() == 'attr:href' || 
			current.loadHash.toLowerCase() == 'attr:rel' ||
			current.loadHash.toLowerCase() == 'attr:title'){
			
			current.loadHash = current.loadHash.toLowerCase();
			current.hash = jQuery(this).attr(current.loadHash.replace('attr:',''));
			if(jQuery.browser.opera){
				current.hash = current.hash.replace('?','%3F');
				current.hash = current.hash.replace('&','%26');
				current.hash = current.hash.replace('=','%3D');
			}
		}else
			current.hash = current.loadHash;
		
		if(!current.hash)
			jQuery.ajaxifylog('Warning: You have specified loadHash, but its empty or attribute couldn\'t be found.');
	}
	
	if(!jQuery(current.target).size() && typeof current.tagToload !='object')
		jQuery.ajaxifylog('Warning: Target " '+current.target+' " couldn\'t be found.');
 	

};

 


jQuery.ajaxifyLoading = function(options){
	
//	jQuery.ajaxifylog('ajaxifyLoading');
	
	var html = "<div id='AjaxifyLoading'>" + ( options.loading_img ? "<img src='"+options.loading_img+"' alt='Loading...' title='Loading...' >" : "" ) + options.loading_txt + "</div>";
	if(options.loading_target)
		jQuery.ajaxifyManip(options.loading_target,html);
	else
		jQuery.ajaxifyManip(options,html);
};





jQuery.ajaxifyHash = function(current){
	
	jQuery.ajaxifylog('ajaxifyHash');
	
	var ob = new Object();
	jQuery.each(current, function(key, value) {
		ob[key] = value;
	});
	jQuery.AjaxifyhistorySet[ob.hash] = ob;
	location.hash = ob.hash;
	//if(jQuery.AjaxifyFirstLoad.history){
	//alert(ob.hash);
		jQuery.historyInit(jQuery.ajaxifyHistory);
		jQuery.AjaxifyFirstLoad = false;
	//}
};





jQuery.ajaxifyLoad = function(current) {
	
	jQuery.ajaxifylog('ajaxifyLoad');
	jQuery.ajaxifylog(current);
	jQuery.ajaxifylog(jQuery.AjaxifyhistorySet);
	
	// turn off globals 
	jQuery.ajaxSetup({global:false});	
	//start calling  jQuery.ajax function. thank you jquery for making this easy
	jQuery.ajax({
		type: current.method,
		url: current.link,
		dataType: current.dataType,
		data: current.paramres,
		contentType:current.contentType,
		processData:true,
		timeout:current.timeout,
		cache:current.cache,
		username:current.username,
		password:current.password,
		complete: function(){
			current.onComplete(current)
		},
		beforeSend: function(){
				current.onStart(current);
			
			if(current.animateOut){
				if(current.loading_target != current.target);//diff target? fire before start anim
					current.loading_fn(current);
				jQuery(current.target).animate(current.animateOut,current.animateOutSpeed,function(){
					//alert('hr');
					if(!current.loading_target)//already fired
					current.loading_fn(current);		
				});
			}else
				current.loading_fn(current);
			},
		success: function(data){
			
	//		jQuery.ajaxifylog('success:');		

		jQuery(current.target).stop();
		jQuery('#AjaxifyLoading').remove();
		
		var regex = /<title>(.*)<\/title>/i;
	
		if (current.title === true && data.search(regex)!=-1)
			document.title = html_entity_decode(data.match(regex)[1]);
		else if(typeof current.title == 'string') 
			document.title = html_entity_decode(current.title);
		else if (document.title != jQuery.AjaxifyPageTitle)
			document.title = html_entity_decode(jQuery.AjaxifyPageTitle);
		
		if(current.tagToload){
			
	 	 		var regex = /<body[^>]*>((.|\n|\r)*)<\/body>/i;
				if (data.search(regex)!=-1)
					data = data.match(regex)[1];
					
				data = jQuery('<div>' + data + '</div>');
					
				if(typeof current.tagToload == 'string'){
					jQuery.ajaxifyManip(current,(current.tagToload==current.target ? data.find(current.tagToload).html() : data.find(current.tagToload)) );				
				}else if(typeof current.tagToload == 'object') {
									
					jQuery.each(current.tagToload, function(tag, target) {					
 					
						if(data.find(tag).length) {
							if (tag==target) {
								jQuery.ajaxifyManip(target,data.find(tag).contents());
							} else {
								jQuery.ajaxifyManip(target,data.find(tag).get());
							}
						} else {
							jQuery.ajaxifylog('Warning: Tag "'+tag+'" couldn\'t be found. (ajaxifyLoad)');
						}
											
					} );
											
				}
		
		}else{
		 jQuery.ajaxifyManip(current,data);
		  }
		current.onSuccess(current,data);
		if(current.animateIn)
			jQuery(current.target).animate(current.animateIn,current.animateInSpeed);
		  
		  },
		  error:function(msg){  	
			  jQuery(current.target).stop();
			  current.onError(current,msg);
			  if(current.animateIn)
		  jQuery(current.target).animate(current.animateIn,current.animateInSpeed);
		  }
		});
		
		
};

jQuery.ajaxifylog = function(message) {
	if(jQuery.AjaxifyDebug)
		if(window.console) {
			 console.debug(message);
		} else {
			 alert(message);
		}
};

jQuery.ajaxifyHistory = function(hash){
	
	jQuery.ajaxifylog('ajaxifyHistory');
	
	if(hash){
		if(jQuery.browser.safari){
			var options = jQuery.AjaxifyhistorySet[location.hash.replace(/^#/,'')]; //fix bug in history.js
		}else
			var options = jQuery.AjaxifyhistorySet[hash];
		
		if(options)
			jQuery.ajaxifyLoad(options);
		else
			jQuery.ajaxifylog('History Fired. But I couldn\'t find hash. Most propabley, the hash is empty. If so, its normal.');
	}
};





jQuery.ajaxifyManip = function(current,data){

if(typeof current != 'object'){
	var target = current;
	var current = new Object;
	var len = target.length-1;
	if(target.charAt(len) == '+' || target.charAt(len)=='-'){
		current.manip = target.charAt(len);
		current.target = target.substr(0,len);
	}
	else{
		current.manip = '';
		current.target = target;
	}
	if(!jQuery(current.target).size())
		jQuery.ajaxifylog('Warning: Target "'+current.target+'" couldn\'t be found. (ajaxifyManip)');
}
	
		
	if(current.manip == '+')
		jQuery(current.target).append(data);
	else if(current.manip == '-')
		jQuery(current.target).prepend(data);
	else
		jQuery(current.target).html(data);
};

})(jQuery);





/* 
 * More info at: http://phpjs.org
 * 
 * This is version: 2.78
 * php.js is copyright 2009 Kevin van Zonneveld.
 * 
 * Portions copyright Brett Zamir (http://brett-zamir.me), Kevin van Zonneveld
 * (http://kevin.vanzonneveld.net), Onno Marsman, Michael White
 * (http://getsprink.com), Waldo Malqui Silva, Paulo Ricardo F. Santos, Jack,
 * Philip Peterson, Jonas Raoni Soares Silva (http://www.jsfromhell.com),
 * Legaev Andrey, Ates Goral (http://magnetiq.com), Martijn Wieringa, Nate,
 * Enrique Gonzalez, Philippe Baumann, Theriault, Webtoolkit.info
 * (http://www.webtoolkit.info/), Ole Vrijenhoek, Carlos R. L. Rodrigues
 * (http://www.jsfromhell.com), travc, Ash Searle (http://hexmen.com/blog/),
 * Jani Hartikainen, Michael Grier, Johnny Mast (http://www.phpvrouwen.nl),
 * Alex, stag019, d3x, Erkekjetter, GeekFG (http://geekfg.blogspot.com),
 * Andrea Giammarchi (http://webreflection.blogspot.com), marrtins, Steve
 * Hilder, Marc Palau, Oleg Eremeev, Steven Levithan
 * (http://blog.stevenlevithan.com), Public Domain
 * (http://www.json.org/json2.js), David, T.J. Leahy, Arpad Ray
 * (mailto:arpad@php.net), gettimeofday, gorthaur, Breaking Par Consulting Inc
 * (http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7),
 * Thunder.m, Kankrelune (http://www.webfaktory.info/), Caio Ariede
 * (http://caioariede.com), KELAN, Mirek Slugen, AJ, Alfonso Jimenez
 * (http://www.alfonsojimenez.com), Tyler Akins (http://rumkin.com), Aman
 * Gupta, mdsjack (http://www.mdsjack.bo.it), Josh Fraser
 * (http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/),
 * Lars Fischer, Karol Kowalski, Sakimori, Pellentesque Malesuada, Ole
 * Vrijenhoek (http://www.nervous.nl/), Hyam Singer
 * (http://www.impact-computing.com/), Raphael (Ao RUDLER), J A R, Paul,
 * kenneth, john (http://www.jd-tech.net), T. Wild, noname, Douglas Crockford
 * (http://javascript.crockford.com), Marco, madipta, class_exists, David
 * James, nobbler, marc andreu, ger, Steve Clay, mktime, Tim Wiel, Marc
 * Jansen, djmix, Lincoln Ramsay, Linuxworld, Thiago Mata
 * (http://thiagomata.blog.com), Pyerre, Jon Hohle, Bayron Guevara, duncan,
 * sankai, Denny Wardhana, Sanjoy Roy, 0m3r, Gilbert, Subhasis Deb, Felix
 * Geisendoerfer (http://www.debuggable.com/felix), Soren Hansen, T0bsn, echo
 * is bad, XoraX (http://www.xorax.info), Der Simon
 * (http://innerdom.sourceforge.net/), Eugene Bulkin (http://doubleaw.com/),
 * Francesco, LH, JB, Ozh, pilus, MeEtc (http://yass.meetcweb.com), Peter-Paul
 * Koch (http://www.quirksmode.org/js/beat.html), Brad Touesnard, Nathan,
 * http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript,
 * David Randall, Bryan Elliott, vlado houba, Arno, Mick@el, rezna, Eric
 * Nagel, Rick Waldron, Kirk Strobeck, Saulo Vallory, Kristof Coomans (SCK-CEN
 * Belgian Nucleair Research Centre), Pierre-Luc Paour, Martin Pool, Bobby
 * Drake, Pul, Christian Doebler, setcookie, YUI Library:
 * http://developer.yahoo.com/yui/docs/YAHOO.util.DateLocale.html, Blues at
 * http://hacks.bluesmoon.info/strftime/strftime.js, penutbutterjelly, Gabriel
 * Paderni, Luke Godfrey, Blues (http://tech.bluesmoon.info/), Anton Ongson,
 * Simon Willison (http://simonwillison.net), Daniel Esteban, Jason Wong
 * (http://carrot.org/), sowberry, hitwork, Norman "zEh" Fuchs, Yves Sucaet,
 * johnrembo, Nick Callen, ejsanders, Aidan Lister (http://aidanlister.com/),
 * Philippe Jausions (http://pear.php.net/user/jausions), dptr1988, Pedro
 * Tainha (http://www.pedrotainha.com), Alan C, uestla, Wagner B. Soares,
 * Valentina De Rosa, T.Wild, strcasecmp, strcmp, DxGx, Alexander Ermolaev
 * (http://snippets.dzone.com/user/AlexanderErmolaev), ChaosNo1, metjay,
 * Andreas, DtTvB (http://dt.in.th/2008-09-16.string-length-in-bytes.html),
 * Tim de Koning, taith, Robin, Luis Salazar (http://www.freaky-media.com/),
 * FremyCompany, FGFEmperor, baris ozdil, Greg Frazier, Tod Gentille, Matt
 * Bradley, Manish, Scott Cariss, Slawomir Kaniecki, ReverseSyntax, Mateusz
 * "loonquawl" Zalega, Francois, date, Cord, Victor, stensi, Jalal Berrami,
 * gabriel paderni, Yannoo, Ben Bryan, booeyOH, Cagri Ekin, Leslie Hoare,
 * mk.keck, Russell Walker (http://www.nbill.co.uk/), Garagoth, Andrej
 * Pavlovic, Dino, Amir Habibi (http://www.residence-mixte.com/), Jay Klehr,
 * Benjamin Lupton, davook, Atli Þór, jakes, Allan Jensen
 * (http://www.winternet.no), Howard Yeend, Kheang Hok Chin
 * (http://www.distantia.ca/), Luke Smith (http://lucassmith.name), Rival,
 * Diogo Resende
 * 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */ 

function get_html_translation_table(table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 906.401
    // discuss at: http://phpjs.org/functions/get_html_translation_table
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';

    useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';

    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');
        // return false;
    }

    if (useTable === 'HTML_ENTITIES') {
        entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';
        entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';
        entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';
        entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';
        entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';
        entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';
        entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';
        entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';
        entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';
        entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';
        entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';
        entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';
        entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';
        entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';
        entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';
        entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';
        entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';
        entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';
        entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';
        entities['255'] = '&yuml;';
    }

    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';
    entities['62'] = '&gt;';

    // ascii decimals for better compatibility
    entities['38'] = '&amp;';

    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}

function html_entity_decode( string, quote_style ) {
    // Convert all HTML entities to their applicable characters  
    // 
    // version: 906.401
    // discuss at: http://phpjs.org/functions/html_entity_decode
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');
    // *     returns 2: '&lt;'
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    tmp_str = tmp_str.split('&#039;').join("'");
    
    return tmp_str;
}