/* ===========================================
    Common Javascript 

============================================= */

(function($) {

	//===================================== Main Routine		
	$(function() {
		initScrollLinkPagetop();
		initEntryMoreShowHide();
		initSelectOnFocusTextField();
		setRollovers();
	});

	//==================================== Functions
	var initScrollLinkPagetop = function() {
		$("div.link_pagetop").localScroll({speed: 800, easing: "easeOutExpo"});
	};

	//show hide entry more
	var initEntryMoreShowHide = function() {
		$("div.section_link_readmore").each(function(idx){
			var $this = $(this);
			var $target = $this.parent().find("div.entry_more");
			var $anc = $this.find("a");
			var $showHide = $anc.find("span");
			var $show = $showHide.eq(0);
			var $hide = $showHide.eq(1);
			if($target.filter(":visible").size()){
				$show.hide();
				$hide.show();
			}else{
				$show.show();
				$hide.hide();
			}
			$anc.click(function(evnt){
				if($target.filter(":visible").size()){
					$target.hide();
					$show.show();
					$hide.hide();
				}else{
					$target.show();
					$show.hide();
					$hide.show();
				}
				evnt.preventDefault();
				return false;
			});
			
		});
	};

	//auto select on click
	var initSelectOnFocusTextField = function() {
		$("input#field_url_entry, textarea#field_code_blogparts_01").click(function(evnt){
			var $target = $(this);
			setTimeout(function(){
				$target.focus();
				$target.select();
			}, 0);
			evnt.preventDefault();
			return false;
		});
	};

})(jQuery);

