$(document).ready(function() {   
  $('dl.a-to-z_list:eq(0)> dd').hide();   
  $('dl.a-to-z_list:eq(0)> dt').click(function() {   
    $(this).next().slideToggle('fast');   
  });   
}); 


$(function() {  
     $("#secondary ul").each(function() {  
         $("li:first-child").css('border', 'none');  
     });  
 }); 

//inputAreaColor
function inputAreaColor() {
	var inputAreaID="s";
	var inputStr="Search";
	var OnColor="#999999";
	var OffColor="#999999";
	var OnBgColor="#FFFFFF";
	var OffBgColor="#FFFFFF";
	if(document.getElementById(inputAreaID)) {
	 
		//initialize
		document.getElementById(inputAreaID).value=inputStr;
		document.getElementById(inputAreaID).style.color=OffColor;
		document.getElementById(inputAreaID).style.backgroundColor=OffBgColor;
		
		//onfocus
		document.getElementById(inputAreaID).onfocus =function() {
			if(this.value==inputStr){
				this.value='';
			}
			this.style.color=OnColor;
			this.style.backgroundColor=OnBgColor;
		}
		
		//onblur
		document.getElementById(inputAreaID).onblur =function() {
		this.style.backgroundColor=OnBgColor;
			if(this.value==''){
				this.value=inputStr;
				this.style.color=OffColor;
				this.style.backgroundColor=OffBgColor;
			}else{
				this.style.color=OnColor;
				this.style.backgroundColor=OnBgColor;
			}
		}
	}
}
//Rollover img change
function smartRollover() {
 if(document.getElementsByTagName) {
					
  var images = document.getElementsByTagName("img");
  for(var i=0; i < images.length; i++) {
   if(images[i].className.match("over"))
   {
    images[i].onmouseover = function() {
     this.setAttribute("src", this.getAttribute("src").replace(".gif", "_on.gif"));
     this.setAttribute("src", this.getAttribute("src").replace(".jpg", "_on.jpg"));
     this.setAttribute("src", this.getAttribute("src").replace(".png", "_on.png"));
    }
    images[i].onmouseout = function() {
     this.setAttribute("src", this.getAttribute("src").replace("_on.gif", ".gif"));
     this.setAttribute("src", this.getAttribute("src").replace("_on.jpg", ".jpg"));
	 this.setAttribute("src", this.getAttribute("src").replace("_on.png", ".png"));
    }
   }
  }
 }
}

(function($) {
	$(function() {
	
		$('ul#share').share();
		
	});
	
	$.fn.share = function(options) {
		var o = $.extend({
			docUri: document.URL,
			docTitle: document.title,
			twitter: '#twitter',
			facebook: '#facebook',
			hatena: '#hatena',
			hLayout: 'simple',
			yahoo: '#yahoo',
			google: '#google',
			livedoor: '#livedoor',
			charset: 'utf-8',
			delicious: '#delicious',
			linkedin: '#linkedin',
			evernote: '#evernote',
			clipID: '#screen',
			suggestTags: 'tag1,tag2,tag3'
		}, options);
		
		
		$(o.twitter).each(function() {
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				var openurl =
				//'http://twitter.com/home?status=' + encodeURIComponent(o.docTitle) + ' ' + encodeURIComponent(o.docUri);
				'http://twitter.com/share?&text=' + encodeURIComponent(o.docTitle) + '&url=' + encodeURIComponent(o.docUri);
				window.open(openurl,'twitter','width=636, height=507, menubar=no, toolbar=no, scrollbars=yes');
			});
		});
		
		$(o.facebook).each(function() {
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				var openurl =
				'http://www.facebook.com/sharer.php?u=' + o.docUri;
				window.open(openurl,'twitter','width=636, height=507, menubar=no, toolbar=no, scrollbars=yes');
			});
		});
		
		$(o.hatena).each(function() {
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'http://b.hatena.ne.jp/entry/' + o.docUri,
				'data-hatena-bookmark-title': o.docTitle,
				'data-hatena-bookmark-layout': o.hLayout,
				'title': ''
			})
			.addClass('hatena-bookmark-button')
		});
		
		$(o.yahoo).each(function(){
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				var openurl =
					'http://bookmarks.yahoo.co.jp/action/bookmark?t=' + encodeURIComponent(o.docTitle) + '&u=' + encodeURIComponent(o.docUri);
				window.open(openurl);
			});
		});
		
		$(o.google).each(function(){
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'https://www.google.com/bookmarks/mark?op=add&bkmk=' + o.docurl + '&title=' + o.doctitle,
				'title': ''
			});
		});
		
		$(o.livedoor).each(function(){
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				var openurl =
				'http://clip.livedoor.com/redirect?link=' + encodeURIComponent(o.docUri) + '&title=' + o.docTitle + '&ie=' + o.charset
				window.open(openurl);
			});
		});
		
		$(o.delicious).each(function(){
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				var openurl =
					'http://www.delicious.com/save?url=' + encodeURIComponent(o.docUri) + '&title=' + encodeURIComponent(o.docTitle);
				window.open(openurl);
			});
		});

		$(o.linkedin).each(function(){
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				var openurl =
					'http://www.linkedin.com/shareArticle?mini=true&url=' + encodeURIComponent(o.docUri) + '&title=' + encodeURIComponent(o.docTitle);
				window.open(openurl,'linkedin','width=636, height=507, menubar=no, toolbar=no, scrollbars=yes');
			});
		});

		$(o.evernote).each(function(){
			$(this).wrapInner('<a></a>')
			.children()
			.attr({
				'href': 'javascript:;',
				'title': ''
			})
			.click(function(){
				Evernote.doClip({
					providerName: o.doctitle,
					contentId: o.clipID,
					suggestTags: o.suggestTags
				}); return false;
			});
		});
	return this;
	};

})(jQuery);

if (window.addEventListener) {
window.addEventListener("load", inputAreaColor, false);
window.addEventListener("load", smartRollover, false);
}
if (window.attachEvent) {
window.attachEvent("onload", inputAreaColor);
window.attachEvent("onload", smartRollover);
}
