/* Vars */
var current_hash = false;
gapi.plusone.go();

/* Loads View Master */
function loadBlogPost(postPermalink) {
	$('#slider3').fadeOut(500);
	$('#artist-video').hide();
	$('#artist-video').attr('src', '');
	
	$('#artist-wrapper').css('background-image', "url('"+wp_template_url+"/images/ajax-loader.gif')");
	
	$.getJSON(postPermalink, function(json) {
		$('#artist-wrapper').css('background-image', "");
		
		//Remove old slider fully. Livequery will rehook new slider
		$('#slider3').remove();
		$('#moreInfoSliderControls').remove();
		$('#postControls').remove();
		
		share_url = encodeURIComponent(wp_site_url+'/blog/#!'+json.post.post_name);
		striped_share = htmlentities(json.post.post_title.replace(/(<([^>]+)>)/ig,""));
		
		theSouceButton = '';
		if(json.postSource != '') {
			theSouceButton = '<div class="source-button">Links</div>';
		}
		sliderObject = $('\
		<div id="slider3" style="display: none;">\
			<ul>\
				<li>\
					<div class="artist" style="background-image: url('+json.bgImage+');">\
					    <div class="slidecontainer">\
	    			    	<div class="slidecontent">\
	    			    		<div class="moreInfoSlider">\
	    			    			<div class="firstslide">\
	    			        			<div class="firstslidetext">\
	    			        				<h2>'+json.post.post_title+'</h2>\
	    			        				'+json.post.post_content+'\
	    			        			</div>\
	    			        			<div class="firstsliderightcontent">\
	    			        				<div class="firstslidebuttons">\
	    			        					<div class="twitter-url">\
	    			   	    						<a href="http://twitter.com/share" class="twitter-share-button" data-url="'+wp_site_url+'/blog/#!'+json.post.post_name+'" data-text="'+striped_share+'" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>\
	    			   	    					</div>\
	    			   	    					\
	    			   	    					<div class="facebook-url">\
	    			        						<iframe src="http://www.facebook.com/plugins/like.php?app_id=171418662915080&amp;href='+share_url+'&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>\
	    			        					</div>\
	    			        					<div style="float:right; width:90px; overflow:hidden;">\
	    			        						<g:plusone size="medium" href="'+share_url+'"></g:plusone>\
	    			        					</div>\
	    			        					<a href="http://www.tumblr.com/share/link?url='+share_url+'&name='+striped_share+'" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_1.png\') top left no-repeat transparent; float: right; margin-right: 10px;"></a>\
	    			   	    				</div>\
	    			   	    				\
	    			   	    				<div class="post-source">\
	    				        		    	<div class="post-source-wrapper">\
	    				        		    		'+json.postSource+'\
	    				        		   		</div>\
	    				        		   		<div class="close-box-source"></div>\
		    			        		   	</div>\
		    			        		   	'+theSouceButton+'\
		    			        		   	\
	    			   	    				<div class="view-more" style="display: none;">\
	    				   	    				<a href="javascript:void(0);">View More</a>\
		    			        		    </div>\
	    			   	    				\
	    			   	    			</div>\
	    			   	    			\
	    			   	    		</div>\
								</div>\
					    			\
							</div>\
						</div>\
					</div>\
				</li>\
				\
			</ul>\
	    </div>\
	    <p id="postControls">\
	    	<span id="postControlsPrev"><a href="javascript:goToPrev();" style="display: none; ">Previous</a></span>\
	    	<span id="postControlsNext"><a href="javascript:goToNext();" style="display: none; ">Next</a></span>\
	    </p>');
	    
		
		$('#artist-wrapper').append(sliderObject);

		if(json.postInfos) {

		$('.view-more').css('display', 'block');
		s=1;
		$.each(json.postInfos, function(key, postInfo) {
			musicCode = null;
			theSource = null;
			theContent = null;
			if(postInfo.hasOwnProperty('music_player')) {
				if(postInfo.music_player != null) {
					musicCode = '<div class="mp3player">'+ postInfo.music_player +'</div>';
				}
			}
			if(musicCode === null) {
				musicCode = '';
			}
			
			//----
			if(postInfo.hasOwnProperty('source')) {
				theSource = postInfo.source;
			}
			if(theSource === null) {
				theSource = '';
			}
			
			//----
			if(postInfo.hasOwnProperty('content')) {
				theContent = postInfo.content;
			}
			if(theContent === null) {
				theContent = '';
			}
			
			theSouceButton = '';
			if(theSource != '') {
				theSouceButton = '<div class="source-button">Links</div>';
			}
			
			embed_code = '';
			i=0;
			if(postInfo.embed_video != '') {
				embed_code += '\
					<div style="position: absolute; left:0;">\
						<div class="artist-video">';
				
				$.each(postInfo.embed_video, function(key, embed) {
					embed_code += '\
					<div class="video-embed '+s+'_video_'+(i+1)+'" style="display:none;">\
						'+embed+'\
					</div>';
					i++;
				});
				embed_code += '</div></div>';

			}
			s++;
			
			
			if(postInfo.title != null) {
			
			$('#slider3 ul').append('\
			<li>\
				<div class="artist" style="background-image: url('+postInfo.background_image+'); ">\
		    	    <div class="slidecontainer">\
	        	        <div class="slidecontent">\
	        	        	<div class="moreInfoSlider">\
	        	        	\
	        	        		<div class="firstslide">\
	        	        		    <div class="firstslidetext">\
	        	        		    	<h2>'+postInfo.title+'</h2>\
	        	        		    	'+theContent+'\
	        	        		    </div>\
	        	        		    <div class="firstsliderightcontent">\
	        	        		    	<div class="firstslidebuttons">\
	        	        		    		<div class="twitter-url">\
	    			   	    					<a href="http://twitter.com/share" class="twitter-share-button" data-url="'+wp_site_url+'/blog/#!'+json.post.post_name+'" data-text="'+postInfo.title+'" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>\
	    			   	    				</div>\
	    			   	    					\
	    			   	    				<div class="facebook-url">\
	    			        					<iframe src="http://www.facebook.com/plugins/like.php?app_id=171418662915080&amp;href='+share_url+'&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe>\
	    			        				</div>\
    			        					<div style="float:right; width:90px; overflow:hidden;">\
		    			        				<g:plusone size="medium" href="'+share_url+'"></g:plusone>\
	    			        				</div>\
	    			        				<a href="http://www.tumblr.com/share/link?url='+share_url+'&name='+postInfo.title+'" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_1.png\') top left no-repeat transparent; float: right; margin-right: 10px;"></a>\
	        	        		    	</div>\
	        	        		    	\
	        	        		    	<div class="post-source">\
	    			        		    	<div class="post-source-wrapper">\
	    			        		    		'+theSource+'\
	    			        		   		</div>\
	    			        		   		<div class="close-box-source"></div>\
	    			        		   	</div>\
	    			        		   	'+theSouceButton+'\
	        	        		    	'+ musicCode +'\
	        	        		    </div>\
	        	        		</div>\
		    		    	</div>\
		    	        	\
		    		    </div>\
		    		</div>\
		    	</div>\
		    </li>\
		    '+embed_code);
		    
		} else {
		$('#slider3 ul').append('\
			<li>\
				<div class="artist" style="background-image: url('+postInfo.background_image+'); ">\
		    	</div>\
		    </li>');

		}
		    
		});
		
		}
		

		//Rehook source boxes
		$('.close-box-source').click(function(){
			$(this).parent().parent().children('.source-button').css('background-image', 'url('+wp_template_url+'/images/plus.png)');
			closeBox($(this).parent());
		});
	
		$('.source-button').click(function(){
			if($(this).parent().children('.post-source').is(":visible")) {
				closeBox($(this).parent().children('.post-source'));
				$(this).css('background-image', 'url('+wp_template_url+'/images/plus.png)');
			} else {
				$(this).css('background-image', 'url('+wp_template_url+'/images/minus.png)');
				openBox($(this).parent().children('.post-source'));
			}
		});
		
/* 		$('#firstslidetext').html(json.post.post_content); */
		
/* 		$('#mp3player').html(json.artist.bandcamp_code); */

/*
		$('#facebook-url').attr('href', json.artist.facebook_url);
		$('#twitter-url').attr('href', json.artist.twitter_url);
*/		
		//This is the first one, show next only
		
		//No arrows
		if(allHashes.length <= 1) {
			$('#postControlsNext a').css('display', 'none');
			$('#postControlsPrev a').css('display', 'none');
		} else {
			if(currentHash == 0) {
				$('#postControlsNext a').css('display', 'block');
				$('#postControlsPrev a').css('display', 'none');
			//This is the last one, show prev only
			} else if (allHashes.length - 1 == currentHash) {
				$('#postControlsNext a').css('display', 'none');
				$('#postControlsPrev a').css('display', 'block');
			//Show both arrows
			} else {
				$('#postControlsNext a').css('display', 'block');
				$('#postControlsPrev a').css('display', 'block');
			}
		}

		gapi.plusone.go();
		$('#slider3').fadeIn('500');
		
		
		/* Refreshes comments if they are there */
		if (typeof DISQUS != 'undefined') {
			DISQUS.reset({
				reload: true,
				config: function () {
					this.page.identifier = '/'+json.post.post_name+'/';
					this.page.url = wp_template_url+"/blog/#!"+json.post.post_name;
				}
			});
		}
		
		window.location.hash = '!'+json.post.post_name;
		
	});
	
	$('html, body').animate({scrollTop:220}, 'slow');
}


/* Loads JW Player */
function loadJWVideo(video_url) {
	jwplayer("artist-video").setup({
        file: video_url,
        autostart: true,
        modes: [
            { type: "flash", src: wp_template_url+"/jwplayer/player.swf" },
            { type: "html5" }
        ],
        skin: wp_template_url+"/jwplayer/digitalxv2.zip",
        logo: wp_template_url+"/images/logowowhitesmall.png",
        'logo.hide': false,
        'logo.link': wp_site_url
    });
}


function loadCategories(beginDateId) {
	$('#posts p').fadeOut(500);
	urlToGet = wp_template_url+'/ajax-get-catigories.php?begin_month_id='+beginDateId+'&cat_id='+cat_id;
	
	splitDate = beginDateId.split('_');	
	updatedDate = splitDate[2]+'-'+splitDate[3]+'-'+splitDate[1];
		
	$.getJSON(urlToGet, function(json) {
		$('#posts p').remove();
		allHashes.length = 0;
		$.each(json, function(i, item) {
			allHashes[i] = item.post_name;
			$('#posts').append('<p><a href="'+item.permalink+'">'+item.post_title+'</a></p>');
		});
	});
	
	$('#posts p').fadeIn(500);
	
	$('.post-date > span').text(updatedDate);
}




function goToNext() {
	
	jwplayer("artist-video").remove();
	
	if(allHashes.length - 1 > currentHash) {
		currentHash++;
		window.location.hash = '!'+allHashes[currentHash];
	} else {
		
	}
}

function goToPrev() {

	jwplayer("artist-video").remove();

	if(currentHash != 0) {
		currentHash--;
		window.location.hash = '!'+allHashes[currentHash];
	} else {
		
	}
}

function checkHash() {
	if(window.location.hash != current_hash) {
		current_hash = window.location.hash;
		//Remove hashbang (#!)
		url_hash = current_hash.substring(2);
		
		$.get(wp_template_url+'/ajax-get-permalink.php?name='+url_hash, function(data) {
			postPermalink = data;
			loadBlogPost(postPermalink);
		});
	}
}

function closeBox(jqueryBoxObject) {
    jqueryBoxObject.fadeOut();
}

function openBox(jqueryBoxObject) {
    jqueryBoxObject.fadeIn();
}

function showVideo(slideNumber, videoNumber) {
	hideAllVideos();
	$('.'+slideNumber+'_video_'+videoNumber).show();
}

function hideVideo(slideNumber, videoNumber) {
	$('.'+slideNumber+'_video_'+videoNumber).hide();
}

function hideAllVideos() {
/* 	videos = $('.artist-video').children(); */
/* 	$('.artist-video').children().remove(); */
	if($(".artist-video").children().is(':visible')) {
		var clone = $(".artist-video").children().clone(true);
		$(".artist-video").children().remove();
		$(".artist-video").html(clone);
		$(".artist-video").children().hide();
	}

}


//All jQuery hooks
//Loads when DOM is ready
$(document).ready(function() {
	
	setInterval("checkHash()", 100);
	
	//Example 1
	var oScroll1 = $('#scrollbar1');
	if(oScroll1.length > 0){
		oScroll1.tinyscrollbar();
	}
	
	$(document).keydown(function(e) {
		//39 right
		//37 left
		//38 up
		//40 down
		if (e.keyCode == 27) {
			hideAllVideos();
			sliderWidth = parseInt($('#slider3').children('ul').css('width'));
			slideCount = sliderWidth/980;
			currentSlideMargin = Math.abs(parseInt($('#slider3').children('ul').css('margin-left')));
			currentSlideNumber = (currentSlideMargin/980) + 1;
			theSourceObject = $('#slider3').children('ul').children('li:nth-child('+currentSlideNumber+')');
			
			theSourceObject.children().children().children().children().children().children('.firstsliderightcontent').children('.source-button').trigger('click');
			
		}   // esc
		if (e.keyCode == 107 || e.keyCode == 187) {
			sliderWidth = parseInt($('#slider3').children('ul').css('width'));
			slideCount = sliderWidth/980;
			currentSlideMargin = Math.abs(parseInt($('#slider3').children('ul').css('margin-left')));
			currentSlideNumber = (currentSlideMargin/980) + 1;
			theSourceObject = $('#slider3').children('ul').children('li:nth-child('+currentSlideNumber+')');
			
			theSourceObject.children().children().children().children().children().children('.firstsliderightcontent').children('.source-button').trigger('click');
			
/* 			$('.source-button').click(); */
		}   // plus, + firefox/webkit different
		
		if(e.keyCode == 39) {
			e.preventDefault();
			$('.view-more a').click();
		}
		
		if(e.keyCode == 37) {
			$('#moreInfoNextBtn a').click();
		}
		
/*
		if(e.keyCode == 40) {
			goToNext();
		}
*/
	});
	
	$('.close-box-source').click(function(){
		$(this).parent().parent().children('.source-button').css('background-image', 'url('+wp_template_url+'/images/plus.png)');
		closeBox($(this).parent());
	});
	
	$('.source-button').click(function(){
		if($(this).parent().children('.post-source').is(":visible")) {
			closeBox($(this).parent().children('.post-source'));
			$(this).css('background-image', 'url('+wp_template_url+'/images/plus.png)');
		} else {
			$(this).css('background-image', 'url('+wp_template_url+'/images/minus.png)');
			openBox($(this).parent().children('.post-source'));
		}
	});
	
	$('.view-more').livequery(function() {
		$('.view-more').click(function() {
			hideAllVideos();
			return false;
		});
	});
	
	$('#moreInfoSliderControls').livequery(function() {
		$('#moreInfoNextBtn a, #moreInfoPrevBtn a').click(function () {
			hideAllVideos();
			
			
			mp3_players = $('.mp3player p');
			mp3_players.remove();
			
			mp3_players_containers = $('.mp3player');
			mp3_players.each(function(index){
				$(mp3_players_containers[index]).append(this);
			})
		});
	});
	
	$('.firstslidetext a').livequery(function() {
		$('.firstslidetext a').click(function () {
			
/*
			if($(this).attr('href').match(/uploads/) || $(this).attr('href').match(/youtube.com/)  || $(this).attr('href').match(/youtu.be/)) {
				loadJWVideo($(this).attr('href'));
				
				return false;
			}
*/

		})
	});
	
	$('#posts>p>a, .lab-entry>.lab-logo>a, #teamhomecontent .team-slot > a').livequery(function() {
		$('#posts>p>a, .lab-entry>.lab-logo>a, #teamhomecontent .team-slot > a').click(function() {
			var segments = $(this).attr('href');
		    segments = segments.split('/');
			window.location.hash = '!'+segments[segments.length-2];
			return false;
		});
	});
	
	
	$('#teamhomecontent .team-slot').hover(
		
		function() {
		    $('.inner-shadow', this).fadeIn(200);
		},
		function() {
	    	$('.inner-shadow', this).fadeOut(200);
		}
	);
	
	$('#wp-calendar table:not(.nav) tbody a').click(function() {
		if($(this).parent().attr('id') != 'today') {
			loadCategories($(this).parent().attr('id'));
		}
		return false;
	});
	$('#today, #today a').click(function() {
		createId = ec3_today.substring(0, 10);
		createId = createId.split('-');
		createId = 'ec3_'+createId[0]+'_'+trimNumber(createId[1])+'_'+trimNumber(createId[2]);
		loadCategories(createId);
		return false;
	});
	
	$('.home-slot').hover(function() {
		if($('a > img.display-image', this).css('display') == 'block') {		
			$('a > img.display-image', this).css('display', 'none');
			$('a > img.hover-image', this).css('display', 'block');
		} else {
			$('a > img.display-image', this).css('display', 'block');
			$('a > img.hover-image', this).css('display', 'none');
		}
	});
	
	$('.work-slot').hover(function() {
		if($('a > img.display-image', this).css('display') == 'block') {		
			$('a > img.display-image', this).css('display', 'none');
			$('a > img.hover-image', this).css('display', 'block');
		} else {
			$('a > img.display-image', this).css('display', 'block');
			$('a > img.hover-image', this).css('display', 'none');
		}
	});
	
	$('#about-link').click(function() {		
		$('#about-slider').animate({
			height: '220px'
		}, 300 );
		return false;
	});
	
	$('#creative-link').click(function() {		
		$('#creative-slider').animate({
			height: '220px'
		}, 300 );
		return false;
	});
	
	$('#contact-link').click(function() {		
		$('#contact-slider').animate({
			height: '220px'
		}, 300 );
		return false;
	});
	
	$('#search-link').click(function() {		
		$('#search-slider').animate({
			height: '220px'
		}, 300 );
		return false;
	});
	
	$('.close-box').click(function() {
		$('.close-box').parent().animate({
			height: '0px'
		}, 300 );
		return false;
	});
	
	$('#searchformajax').submit(function() {
		$('.overview').empty();
		search_query = $('#sajax').attr('value');
		if(search_query.replace(/\s/g,"") != "") {
			$.getJSON(wp_site_url+'/?s='+search_query, function(json) {
				if(json == null) {
					//Query has no results
				} else {
					//Query has results
					$.each(json, function(key, postLink) {
						$('.overview').append('<p><a href="#!'+postLink.name+'">'+postLink.title+'</a></p>');
						oScroll1.tinyscrollbar_update();
					});
				}
			});
		}
		return false;
	});
	
});


function trimNumber(s) {
	while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,9999); }
	return s;
}

//phpjs
function htmlentities (string, quote_style) {
    // Convert all applicable characters to HTML entities  
    // 
    // version: 1103.1210
    // discuss at: http://phpjs.org/functions/htmlentities
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
    var hash_map = {},
        symbol = '',
        tmp_str = '',
        entity = '';
    tmp_str = string.toString();
 
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    hash_map["'"] = '&#039;';
    for (symbol in hash_map) {
        entity = hash_map[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
 
    return tmp_str;
}

function get_html_translation_table (table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 1103.1210
    // 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)
    // +      input by: Frank Forte
    // +   bugfixed by: T.Wild
    // +      input by: Ratheous
    // %          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 = {},
        hash_map = {},
        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;
    }
 
    entities['38'] = '&amp;';
    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 to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        hash_map[symbol] = entities[decimal];
    }
 
    return hash_map;
}
