/**
 * reflection.js v2.0
 * http://cow.neondragon.net/stuff/reflection/
 * Freely distributable under MIT-style license.
 */
 
/* From prototype.js */
if (!document.myGetElementsByClassName) {
	document.myGetElementsByClassName = function(className) {
		var children = document.getElementsByTagName('*') || document.all;
		var elements = new Array();
	  
		for (var i = 0; i < children.length; i++) {
			var child = children[i];
			var classNames = child.className.split(' ');
			for (var j = 0; j < classNames.length; j++) {
				if (classNames[j] == className) {
					elements.push(child);
					break;
				}
			}
		}
		return elements;
	}
}

var Reflection = {
	defaultHeight : 0.5,
	defaultOpacity: 0.5,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}

			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			var reflectionWidth = p.width;
			
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
                if(p.parentElement.tagName == 'A') {
	                var d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
                    
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.display = 'block';
				reflection.style.height = p.height+"px";
				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				
				d.appendChild(p);
				d.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
				
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					
					d.style.width = reflectionWidth+'px';
					d.style.height = divHeight+'px';
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					
					context.translate(0,image.height-1);
					context.scale(1,-1);
					
					context.drawImage(image, 0, 0, reflectionWidth, image.height);
	
					context.restore();
					
					context.globalCompositeOperation = "destination-out";
					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
					
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
		
					context.fillStyle = gradient;
					context.rect(0, 0, reflectionWidth, reflectionHeight*2);
					context.fill();
				}
			}
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.myGetElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
	}
}

// H_O var previousOnload = window.onload;
// H_O window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }

/*
 Class: ProtoFlow
 License:
 Copyright (c) 2008 DeenSoft.com - You are free to use this file wherever you wish but please do let us know at blog.deensoft.com
 so that we can showcase it. You can even post your bugs on our blog and we will fix them asap.
 This code is being release under open-terms. Use at your own risk. Give us feedback. Help us fix bugs and implement new features. :)
 <contact@deensoft.com>
 You can follow up with more comments and suggestions on our blog <http://blog.deensoft.com>
 Description:
 ProtoFlow v0.8 is a very early preview release that simulates Apples CoverFlow effect using Prototype/Scriptaculous lib.
 ChangeLog:
 July 7, 2008:
 * Fixed z-index issue - Thanks to Xavvier (http://www.euclide.org/) for the fix.
 March 26, 2008:
 * Fixed major issue with IE7 and z-index for scrollbar (Thanks to all those who contributed on the blog)
 March 19, 2008
 * Fixed issues with IE
 * Fixed major bug with images and links...
 Initial:
 * Added Reflection
 * Fixed Captions
 How to use:
 (start code)
 var myFlow = new ProtoFlow($('myElem'),{captions: 'captionsList'});
 (end)
*/
var MWProtoFlow = Class.create({
 initialize: function(elem, opt) {
  opt = opt || {};
  this.options = {
   startIndex: 2,
   captionColor: 'black',
   useBox: false,
   interval: 60,
   slider: true,
   flex: 110,
   captions: false,
   autoplay: false,
   autoplayInterval: 5,
   useReflection: true,
   enableOnClickScroll: true,
   enableKeyboard: true,
   enableMouse: true
  };
  Object.extend(this.options, opt);
  this.useCaptions = this.options.captions;
  this.elem = $(elem);
  if (!this.elem) {return;}
  this.elem.setStyle({
   overflow: 'hidden',
   position: 'relative'
  });
  this.imageStack = this.elem.select('img');
  if (this.options.captions != false) {
   this.captions = this.imageStack.pluck("alt");
   this.captionsCount = this.captions.size();
  }
  if (this.options.useReflection) {
   this.imageStack.each(function(elem){Reflection.add(elem,{opacity:2/3});}.bind(this));
   this.stack = this.elem.childElements();
  } else {
   this.stack = this.imageStack;
  }
  this.centerWidth = this.imageStack[0].width;
  this.centerHeight = this.imageStack[0].height;
  this.stackCount = (this.stack).size();
  if (this.useCaptions) {
   this.captionHolder = new Element('div');
   this.captionHolder.className = 'captionHolder';
   this.captionHolder.setStyle({
    width: '100%',
    color: this.options.captionColor,
    textAlign: 'center',
    position: 'absolute',
    left: '0px',
    top: (Element.getHeight(this.elem) - 80) + 'px'
   });
   this.elem.appendChild(this.captionHolder);
  }
  this.currPos = this.options.startIndex - 1;
  this.currIndex = this.currPos;
  if (this.options.slider) {
   this.sliderContainer = new Element('div');
   this.sliderContainer.setStyle({
    width: '200px',
    height: '10px',
    position: 'absolute',
    top: (Element.getHeight(this.elem) - 30) + 'px',
    left: (Element.getWidth(this.elem) / 2 - (137 / 2)) + 'px',
    zIndex: 99999999
   });
   if (!(this.useCaptions)) {
    this.sliderContainer.setStyle({top:(Element.getHeight(this.elem) - 60) + 'px'});
   }
   this.sliderTrack = new Element('div');
   this.sliderTrack.className = 'sliderTrack';
   this.sliderHandle = new Element('div');
   this.sliderHandle.className = 'sliderHandle';
   this.sliderTrack.appendChild(this.sliderHandle);
   this.sliderContainer.appendChild(this.sliderTrack);
   this.elem.appendChild(this.sliderContainer);
   this.slider = new Control.Slider(this.sliderHandle, this.sliderTrack, {
    range: $R(0, this.getStackCount() - 1),
    sliderValue: this.getCurrentPos(),
    onSlide: this.handleSlider.bind(this),
    onChange: this.handleSlider.bind(this)
   });
  }
  this.timer = 0;
  this.stack.each(function(elem){
   elem.identify();
   if(this.options.enableOnClickScroll){elem.observe('click', this.handleClick.bind(this));}
  }.bind(this));
  this.goTo(this.currPos);
  if (this.options.enableOnClickScroll) {this.disableLinks();}
  this.autoplayer = null;
  if(this.options.autoplay){this.autoplayer = new PeriodicalExecuter(this.autoPlay.bind(this), this.options.autoplayInterval);}
  if(this.options.enableKeyboard) {
   document.observe('keyup',(function(e){
    var code = e.keyCode;
    if(37 == code) this.previous();
    if(39 == code) this.next();
   }).bind(this));
  }
  if(this.options.enableMouse){
   var eventType = Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel';
   Event.observe(this.elem,eventType,(function(e){this.enableMouse(e);}).bind(this),false);
   if(this.useCaptions){Event.observe(this.captionHolder,eventType,(function(e){this.enableMouse(e);}).bind(this),false);}
  }
  Event.observe(window,'resize',this.handleWindowResize.bind(this));
 },
 disableLinks: function(){
  this.elem.select('a').each(function(a){
   a.hrefOrg = a.href;
   a.href = 'javascript:void(0);';
  });
 },
 autoPlay: function(){
  if((this.currIndex + 2)>this.stackCount){this.currIndex=0;}
  this.currIndex = this.currIndex + 1
  this.goTo(this.currIndex);
 },
 handleWindowResize: function(event){},
 handleWheel: function(event){
  v = Event.wheel(event);
  this.goTo(this.currIndex + v);
  this.slider.setValue(this.currIndex + v);
 },
 handleSliderChange: function(index){this.goTo(index);},
 handleSlider: function(index){if (index) {this.goTo(index);}},
 handleClick: function(e){
  var elem = Event.element(e);
  var v = elem.getAttribute('index');
  var link = elem.hrefOrg;
  Event.stop(e);
  if (!link) {
   link = elem.up('a').hrefOrg;
  }
  if (!v && this.options.useReflection) {
   elem = elem.up('a');
   v = elem.getAttribute('index');
  }
  var ov = this.currIndex;
  if ( ov == v ) {
   location.href = link;
   return true;
  } else {
   this.currIndex = v;
   this.goTo(v);
   this.updateSlider(v);
  }
 },
 getCurrentPos: function(){return this.currPos;},
 goTo: function(index){
  this.slideTo(index * this.options.flex * -1);
  if (this.options.useBox) {
   var centerid = Math.floor(Math.abs(index))+1;
   var obj; 
   var resizer = 1; 
   for(var boxid=1; boxid<=this.stackCount; boxid++){
    obj = $(this.elem.id + boxid);
    if (boxid==centerid) {
      $(this.elem.id + boxid + '-box').style.display = 'block';
      Element.setOpacity(obj.parentNode,1);
      obj.width = this.centerWidth;
      obj.parentNode.style.width = this.centerWidth + 'px';
      obj.nextSibling.style.width = this.centerWidth + 'px';
      obj.height = this.centerHeight;
      obj.parentNode.style.height = this.centerHeight + 'px';
      // obj.nextSibling.style.height = this.centerHeight + 'px';
    }else if (Math.abs(centerid-boxid)<=4){
      $(this.elem.id + boxid + '-box').style.display = 'none';
      resizer = (9 - Math.abs(centerid-boxid))/10;
      Element.setOpacity(obj.parentNode,1);
      obj.width = this.centerWidth * resizer;
      obj.parentNode.style.width = this.centerWidth * resizer + 'px';
      obj.nextSibling.style.width = this.centerWidth * resizer + 'px';
      obj.height = this.centerHeight * resizer;
      obj.parentNode.style.height = this.centerHeight * resizer + 'px';
      //  obj.nextSibling.style.height = this.centerHeight * resizer + 'px';
    }else{
      $(this.elem.id + boxid + '-box').style.display = 'none';
      resizer = 0.5;
      Element.setOpacity(obj.parentNode,0.1);
      obj.width = this.centerWidth * resizer;
      obj.parentNode.style.width = this.centerWidth * resizer + 'px';
      obj.nextSibling.style.width = this.centerWidth * resizer + 'px';
      obj.height = this.centerHeight * resizer;
      obj.parentNode.style.height = this.centerHeight * resizer + 'px';
      // obj.nextSibling.style.height = this.centerHeight * resizer + 'px';
    }
   }
  }
  if (this.useCaptions) {this.captionHolder.innerHTML = this.captions[Math.round(index)];}
 },
 updateSlider: function(index){if(this.options.slider){this.slider.setValue(index);}},
 step: function(){
  if (this.target < this.currPos - 1 || this.target > this.currPos + 1) {
   this.moveTo(this.currPos + (this.target - this.currPos) / 5);
   window.setTimeout(this.step.bind(this), this.options.interval);
   this.timer = 1;
  }else{
   this.timer = 0;
  }
 },
 slideTo: function(x){
  this.target = x;
  if (this.timer == 0) {
   window.setTimeout(this.step.bind(this), this.options.interval);
   this.timer = 1;
  }
 },
 moveTo: function(currentPos){
  var x = currentPos;
  this.currPos = currentPos;
  var width = Element.getWidth(this.elem);
  var height = Element.getHeight(this.elem);
  var top = this.elem.offsetTop;
  var zIndex = this.stackCount;
  var flex = this.options.flex;
  this.stack.each(function(elem, index){
   Element.absolutize(elem);
   elem.setAttribute('index', index);
   var wsize=300;
   var hsize=300;
   if (this.options.useReflection) {
    wsize=elem.select('img')[0].width;
    hsize=elem.select('img')[0].height;
   } else {
    wsize=elem.width;
    hsize=elem.height;
   }
   if (this.options.useReflection) {
    elem.down(1).setAttribute('index', index);
   }
   var sign=1;
   if(x<0) {sign=-1;}
   var mvt=Math.abs(x/flex/this.stackCount);
   if(mvt>0.2){
    mvt=Math.min(1, Math.pow(mvt, 0.1));
   } else if(mvt > 0.01) {
    mvt=mvt*4;
   }
   var nx=(width - wsize)/2 + sign * (width - wsize - 20) * mvt / 2;
   var ny= (20 + height - hsize)/2 - (height - hsize - 10) * mvt / 2;
   elem.setStyle({
    left: nx+'px',
    top: ny+'px',
    textAlign: 'center'
   });
   elem.style.zIndex = zIndex;
   if (x < - (flex/2)) {
    zIndex++;
   }else {
    zIndex--;
   }
   x += this.options.flex;
  }.bind(this));
 },
 getStackCount: function(){return this.stackCount;},
 decreaseIndex: function(e){if(this.currIndex>0){this.currIndex--;}},
 increaseIndex: function(e){if(this.currIndex<this.getStackCount()-1){this.currIndex++;}},
 previous: function(e){
  this.decreaseIndex();
  this.toCurrentIndex();
 },
 next: function(e){
  this.increaseIndex();
  this.toCurrentIndex();
 },
 enableMouse: function(e) {
  Event.wheel(e)< 0 ? this.next() : this.previous();
  Event.stop(e);
 },
 toCurrentIndex: function(e) {
  this.goTo(this.currIndex);
  this.updateSlider(this.currIndex);
 } 
});
Object.extend(Event, {
 wheel: function(event){
  var delta = 0;
  if (!event) {event = window.event};
  if (event.wheelDelta) {
   delta = event.wheelDelta/120;
   if (window.opera){delta = -delta;}
  } else if (event.detail) {
   delta = -event.detail/3;
  }
  return Math.round(delta);
 }
});
// --------------------------------------------------
Function.prototype.later=function(ms){
 var s=this;
 return function(){
  var a=arguments;
  var o=this;
  var r={complete:false,cancel:function(){clearTimeout(Me);},notify:function(){clearTimeout(Me);f();}};
  var f=function(){s.apply(o,a);r.complete=true;};
  var Me=setTimeout(f,ms);
  return r;
 };
};

// Namespace
if(typeof(ISMEDIAns)=='undefined'){
 var ISMEDIAns={
  util:{},	// Other Utility Function
  cls:{},	// Class
  show:{},	// Element show Function
  mv:{},	// Element move Function
  cb:{},	// Callback Function
  eom:null	// End Mark
 };
}

// 動的ロードスクリプトカウンター
ISMEDIAns.util.scriptCounter=1;
// ドメイン外スクリプトローダー
ISMEDIAns.util.outerScript=function(_url){
 this.url=_url;
 this.s=document.createElement('script');
 this.s.setAttribute('type','text/javascript');
 this.s.setAttribute('charset','utf-8');
 this.s.setAttribute('id','outer'+ISMEDIAns.util.scriptCounter++);
 this.s.setAttribute('src',this.url);
 this.h=document.getElementsByTagName('head').item(0);
 this.h.appendChild(this.s);
};
ISMEDIAns.util.outerScript.prototype.remove=function(){this.h.removeChild(this.s);};

// ドメイン内スクリプトローダー
ISMEDIAns.util.simpleScript=function(_name){
 this.url='/common/js/'+_name+'.js';
 this.s=document.createElement('script');
 this.s.setAttribute('type','text/javascript');
 this.s.setAttribute('charset','utf-8');
 this.s.setAttribute('id','simple'+ISMEDIAns.util.scriptCounter++);
 this.s.setAttribute('src',this.url);
 this.h=document.getElementsByTagName('head').item(0);
 this.h.appendChild(this.s);
};
ISMEDIAns.util.simpleScript.prototype.remove=function(){this.h.removeChild(this.s);};

// JSON スクリプトローダー
ISMEDIAns.util.jsonScript=function(_action,_callback,_searchword){
 this.url='http://www.ismedia.jp/json/'+_action+'/'+_callback+'/'+_searchword;
 this.s=document.createElement('script');
 this.s.setAttribute('type','text/javascript');
 this.s.setAttribute('charset','utf-8');
 this.s.setAttribute('id','jsonp'+ISMEDIAns.util.scriptCounter++);
 this.s.setAttribute('src',this.url);
 this.h=document.getElementsByTagName('head').item(0);
 this.h.appendChild(this.s);
};
ISMEDIAns.util.jsonScript.prototype.remove=function(){this.h.removeChild(this.s);};

// Amazon スクリプトローダー
ISMEDIAns.util.awsScript=function(__key,__pub){
 this.url='http://ecs.amazonaws.jp/onca/xml?';
 this.url+='Service=AWSECommerceService&';
 this.url+='AWSAccessKeyId='+'0ABQT5QYX0EQKC8GEH02'+'&';
 this.url+='Version=2008-08-19&';
 this.url+='Operation=ItemSearch&';
 this.url+='SearchIndex=Books&';
 this.url+='ResponseGroup=Small%2CImages%2COffers&';
 this.url+='ContentType=text%2fjavascript&';
 this.url+='Style=http%3a%2f%2fjbpress%2eismedia%2ejp%2foo%2faws%2exsl&';
 if(__pub!=''){this.url+='Publisher='+encodeURIComponent(__pub)+'&';}
 this.url+='Keywords='+encodeURIComponent(__key);
 this.s=document.createElement('script');
 this.s.setAttribute('type','text/javascript');
 this.s.setAttribute('charset','utf-8');
 this.s.setAttribute('id','AWSjson'+ISMEDIAns.util.scriptCounter++);
 this.s.setAttribute('src',this.url);
 this.h=document.getElementsByTagName('head').item(0);
 this.h.appendChild(this.s);
};
ISMEDIAns.util.awsScript.prototype.remove=function(){this.h.removeChild(this.s);};

// エレメントのハイライト
ISMEDIAns.util.elementsHighlight=function(){
 var os=$$('.highlight-element');
 try{
  os.each(function(o){(o!=undefined)?new Effect.Highlight(o,{startcolor:'#ffffff'}):null;});
 }catch(e){}
};

// エレメントのリフレッシュ
ISMEDIAns.util.elementRefresh = function(){
 var os = $$('.refresh-element');
 var pq = 'time=' + parseInt((new Date)/1000);
 for (var i=0; i<os.length; i++) {
  try{
  if (os[i].src != undefined) {
   if (os[i].longdesc == undefined){
    os[i].longdesc = '';
    Event.observe(os[i],'load',function(event){Event.element(event).longdesc = '';},false);
   }
   if (os[i].longdesc == '') {
    os[i].longdesc = 'http://www.ismedia.jp/common/images/v1/loading.gif';
    var org = os[i].src.split('time=');
    var newUrl = '';
    if (org[1] == undefined){
     if (org[0].match(/\?/)) {
      newUrl = org[0] + '&amp;' + pq;
     } else {
      newUrl = org[0] + '?' + pq;
     }
    } else {
     newUrl = org[0] + pq;
    }
    os[i].src = newUrl;
   } else {
    os[i].longdesc = '';
   }
  }
  }catch(e){}
 }
};

// エレメントの非表示
ISMEDIAns.util.elementsConceal=function(){
 var os=$$('.conceal-element');
 try{
  os.each(function(o){(o!=undefined)?o.hide():null;});
 }catch(e){}
};

// FQDNからのメディア略称取得
ISMEDIAns.util.getMediaName=function(_fqdn){
 try{
  // ドメイン削除
  var media = _fqdn.replace(/\.ismedia\.jp/,'');
  // 投稿系プレフィックス削除
  media = media.replace(/post\./,'').toUpperCase();
  return media;
 }catch(e){
  return '';
 }
};

// Cookie Read
ISMEDIAns.util.getCookieValue = function(_name){
 var neq = _name + '=';
 var ca = document.cookie.split(';');
 for(var i=0; i<ca.length; i++) {
  var c = ca[i];
  while (c.charAt(0)==' ') {
   c = c.substring(1,c.length);
  }
  if (c.indexOf(neq) == 0) {
   return c.substring(neq.length,c.length);
  }
 }
 return null;
};

// Font Style Switch
ISMEDIAns.util.setFontStyleSheet = function(_title){
 var a;	// スタイルシートエレメント
 // フォント大
 if ($('altstylel') != undefined) {
  a = $('altstylel');
  a.disabled = (a.getAttribute('title') == _title) ? false : true;
 }
 // フォント小
 if ($('altstyles') != undefined) {
  a = $('altstyles');
  a.disabled = (a.getAttribute('title') == _title) ? false : true;
 }
 var d = new Date();
 d.setTime(d.getTime()+(365*24*60*60*1000));
 var expires = '; expires=' + d.toGMTString();
 var domain = '; domain=' + location.hostname;
 document.cookie = 'im-style=' + _title + expires + domain + '; path=/';
};

// Font Style Initialize
ISMEDIAns.util.initFontStyle = function(){
 if (($('altstylel') != undefined)&&($('altstyles') != undefined)) {
  var v = ISMEDIAns.util.getCookieValue('im-style');
  var f = v ? v : 'Small';
  ISMEDIAns.util.setFontStyleSheet(f);
 }
};

// Social Book Mark
ISMEDIAns.util.bm = {
 'delicious': function(_url,_title){
  var f='http://delicious.com/save?url='+_url+'&title='+_title+'&v=5&';
  var a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv5','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};
  if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0);}else{a()}
 },
 'digg': function(_url,_title){
  var w=window.open('http://digg.com/submit?phase=2&url='+_url+'&title='+_title, 'DiggSubmit','');
 },
 'hatena': function(_url,_title){
  var w=window.open('http://b.hatena.ne.jp/append?'+_url, 'HatenaBookmark','');
 },
 'newsing': function(_url,_title){
  var w=window.open('http://newsing.jp/add?url='+_url, 'newsingIt','');
 },
 'yahoo': function(_url,_title){
  var w=window.open('http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?u='+_url+'&t='+_title+'&ei=UTF-8', 'YahooBookmark','width=550,height=480,left=100,top=50,scrollbars=1,resizable=1');
 },
 'mixi': function(_url,_key){
  var w=window.open('http://mixi.jp/share.pl?u='+_url+'&k='+_key, 'mixi check',['width=632','height=456','location=yes','resizable=yes','toolbar=no','menubar=no','scrollbars=no','status=no'].join(','));
 },
 'goo': function(_url,_title){
  var w=window.open('http://bookmark.goo.ne.jp/add/detail?url='+_url, 'Gooブックマーク','');
 },
 'livedoor': function(_url,_title){
  var w=window.open('http://clip.livedoor.com/clip/add?link='+_url+'&title='+_title, 'livedoorClip','');
 },
 'furl': function(_url,_title){
  var w=window.open('http://www.furl.net/items/new?u='+_url+'&t='+_title, 'FurlThisPage','');
 },
 'stumpleupon': function(_url,_title){
  var w=window.open('http://www.stumbleupon.com/submit?url='+_url+'&title='+_title, 'StumbleIt','');
 },
 'google': function(){
  var a=document,b=a.createElement('script'),w=window,g={};
  g.altWindow=w.open('','_blank','height=370px,width=720px,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
  setTimeout(function(){g.altWindow.focus()},1000);
  function f(o){
   try{
    var d=new google.share.EmailWidget(g);
    d.display();
   }catch(e){
    if(o>20) return;
    setTimeout(function(){f(o+1)},o<10?1<<o:1000);
   }
  }
  b.src='http://www.google.com/s2/sharing/js?script=socialsharing&key=&hl=ja';
  a.body.appendChild(b);
  f(0);
 },
 'googleR': function(){
  var b=document.body;
  window.GR________bookmarklet_domain='http://www.google.co.jp';
  if(b&&!document.xmlVersion){
   void(z=document.createElement('script'));
   void(z.src='http://www.google.co.jp/reader/ui/link-bookmarklet.js');
   void(b.appendChild(z));
  }else{}
 },
 'friendfeed': function(_url,_title){
  try{
   var a=document.createElement('script');
   a.setAttribute('type','text/javascript');
   a.setAttribute('src','http://friendfeed.com/share/bookmarklet/javascript?url='+_url+'&title='+_title);
   document.body.appendChild(a);
  }catch(e){}
 }
};

// Open Window
ISMEDIAns.util.openWindow = function(_url,_w,_h){
 var opt = 'width=' + _w + ',height=' + _h + 'location=yes,menubar=no,status=no,scrollbars=yes';
 var w = window.open(_url,null,opt);
};

// Cover Body
ISMEDIAns.cls.bodyCover = Class.create({
 options:{},
 initialize:function(options){
  this.options = options||{};
  this.body = $$('body')[0];
  this.duration = this.options['duration']||0.5;
  this.opacity = this.options['opacity']||0.7;
  this.afterShowing = this.options['afterShowing']||function(){};
  this.afterFinish = this.options['afterFinish']||function(){};
  this.beforeShowing = this.options['beforeShowing']||function(){};
  this.beforeFinish = this.options['beforeFinish']||function(){};
  this.cover = document.createElement('div');
  this.zIndex = this.options['zIndex']||10000;
  Element.setStyle(this.cover,{
   backgroundColor:this.options['backgroundColor']||'black',
   width:'100%',
   height:'100%',
   left:'0px',
   top:'0px',
   position:'fixed',
   zIndex:this.zIndex,
   display:'none'
  });
  if (Prototype.Browser.IE) {
   $$('select').each(function(a){a.style.visibility = 'hidden';});
   if (navigator.appVersion.toLowerCase().indexOf("msie 6.0") > -1) {
    this.fix();
    this.cover.style.position = 'absolute';
    this.eventFix = this.fix.bindAsEventListener(this);
    Event.observe(window,'scroll',this.eventFix,true);
    Event.observe(window,'resize',this.eventFix,true);
   }
  }
  this.body.appendChild(this.cover);
  this.eventHide = this.hide.bindAsEventListener(this);
  Event.observe(this.cover,'click',this.eventHide,true);
 },
 fix:function(){
  var _top = document.documentElement.scrollTop || document.body.scrollTop || 0;
  var _left = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
  var _d = document.viewport.getDimensions();
  this.cover.style.height = (_d.height != 0)?_d.height + 'px':document.body.clientHeight + 'px' ;
  this.cover.style.width = (_d.width !=0)?_d.width + 'px':document.body.clientWidth + 'px';
  this.cover.style.top = _top + 'px';
  this.cover.style.left = _left + 'px';
 },
 show:function(){
  var _e=this;
  new Effect.Appear(this.cover,{
   from:0.1,
   to:this.opacity,
   duration:this.duration,
   afterFinishInternal:function(effect){
    _e.afterShowing();
   }
  });
 },
 hide:function(){
  var _e=this;
  _e.beforeFinish();
  new Effect.Fade(this.cover,{
   from:this.opacity,
   to:0.0,
   duration:this.duration,
   afterFinishInternal:function(effect){
    _e.finish();
    _e.afterFinish();
   }
  });
 },
 finish:function(){
  this.cover.style.display = 'none';
  if (Prototype.Browser.IE) {
   $$('select').each(function(a){a.style.visibility = 'visible';});
   Event.stopObserving(window,'scroll',this.eventFix);
  }
  this.body.removeChild(this.cover);
 },
 eom:null
});

// タブグループ( 非推奨（Deprecated）)
ISMEDIAns.cls.tabGroup=Class.create({
 taskActive:null,	// 実行タスク
 taskInActive:null,	// 実行タスク
 options:{},	// 引数
 activeid:1,	// アクティブインデックス
 beforeid:1,	// アクティブ前インデックス
 activating: function(){},	// オーバライド用Active関数
 inactivating: function(){},	// オーバライド用InActive関数
/* 初期化
   tab:タブグループエレメントのIDプレフィックス,
   detail:同ディテールのIDプレフィックス,
   detail:同ディテールのIDサフィックス,
   count:タブ数,
   delay:感知ms,
   useVisible:displayスタイルではなくvisibilityスタイルを利用する場合に指定,
   useContinue:表示したディテールエレメントのマウス操作時にもイベントを継続する場合に指定,
   activeid:デフォルトでセットされているタブインデックス
*/
 initialize: function(options){
  this.options = options||{};	// 引数
  this.tab = this.options['tab'];	// タブプレフィクス
  this.detail = this.options['detail'];	// ディテールプレフィックス
  this.detailsuffix = this.options['detailsuffix'] || '';	// ディテールサフィックス
  this.count = this.options['count'];	// タブ数
  this.delay = this.options['delay'] || 300;	// マウス通過時の感知ms
  this.useVisible = this.options['useVisible'] || false;	// エレメント枠を残すかどうか
  this.useContinue = this.options['useContinue'] || false;	// ディテールボックスをマウス操作対象にするかどうか
  this.activeid = this.options['activeid']||1;	// 初期インデックス
  this.activating = this.options['activating']||(function(){});	// アクティブ終了時関数
  this.inactivating = this.options['inactivating']||(function(){});	// インアクティブ終了時関数
  // タブにイベントセット
  for(var i=1;i<=this.count;i++){
   this.eventActive = this.active.bindAsEventListener(this,i);	// イベント
   this.eventInActive = this.inactive.bindAsEventListener(this,i);	// イベント
   Event.observe($(this.tab + i),'mouseover',this.eventActive,true);	// マウスオーバイベント
   Event.observe($(this.tab + i),'mouseout',this.eventInActive,true);	// マウスアウトイベント
   // ディテールボックスマウスオーバ時に表示を継続する設定
   if (this.useContinue) {
    if ( this.detailsuffix == '' ){
     Event.observe($(this.detail + i),'mouseover',this.eventActive,true);     // マウスオーバイベント
     Event.observe($(this.detail + i),'mouseout',this.eventInActive,true);      // マウスアウトイベント
    } else {
     Event.observe($(this.tab + i + this.detailsuffix),'mouseover',this.eventActive,true);    // マウスオーバイベント
     Event.observe($(this.tab + i + this.detailsuffix),'mouseout',this.eventInActive,true);     // マウスアウトイベント
    }
   }
  }
 },
 // マウスオーバーイベント
 active: function(event){
  try{this.taskInActive.cancel();}catch(e){}
  this.taskActive = this.activate(arguments[1]).later(this.delay)();
 },
 // アクティブタブに対応するディテールエレメントのBlock化
 activate: function(index){
  this.activeid = index;
  var _e = this;
  return function(){
   for (var i=1; i<=_e.count; i++){
    if ( _e.detailsuffix == '' ){
     if (_e.useVisible) {
      $(_e.detail + i).style.visibility = (i==_e.activeid)?'visible':'hidden';
     } else {
      $(_e.detail + i).style.display = (i==_e.activeid)?'block':'none';
     }
    } else {
     if (_e.useVisible) {
      $(_e.tab + i + _e.detailsuffix).style.visibility = (i==_e.activeid)?'visible':'hidden';
     } else {
      $(_e.tab + i + _e.detailsuffix).style.display = (i==_e.activeid)?'block':'none';
     }
    }
   }
   _e.activating();
   _e.beforeid = _e.activeid;
  };
 },
 // マウスアウトイベント
 inactive: function(event){
  try{this.taskActive.cancel();}catch(e){}
  if (this.useContinue) {
   this.taskInActive=this.inactivate(arguments[1]).later(this.delay)();
  } else {
   this.activeid=this.beforeid;
   this.inactivating();
  }
 },
 inactivate: function(index){
  this.activeid = index;
  var _e = this;
  return function(){
   var aid=(_e.detailsuffix=='')?_e.detail+_e.activeid:_e.tab+_e.activeid+_e.detailsuffix;
   var bid=(_e.detailsuffix=='')?_e.detail+_e.beforeid:_e.tab+_e.beforeid+_e.detailsuffix;
   if (_e.useVisible) {
    $(aid).style.visibility='hidden';
    $(bid).style.visibility='hidden';
   } else {
    $(aid).style.display='none';
    $(bid).style.display='none';
   }
   $(_e.tab+_e.activeid).style.backgroundImage='url('+_e.bgImagePathPrefix+_e.activeid+_e.bgImagePathJoint+'a'+_e.bgImageType+')';
   $(_e.tab+_e.beforeid).style.backgroundImage='url('+_e.bgImagePathPrefix+_e.beforeid+_e.bgImagePathJoint+'a'+_e.bgImageType+')';
   _e.inactivating();
   _e.activeid=0;
  };
 },
 eom:null
});

// タブグループ
ISMEDIAns.cls.tabGrouping=Class.create({
 taskActive:null,
 taskInActive:null,
 beforeid:0,
 initialize: function(options){
  this.options = options||{};
  this.tab = this.options['tab'];
  this.detail = this.options['detail'];
  this.detailsuffix = this.options['detailsuffix']||'';
  this.count = this.options['count'];
  this.sensitivity = this.options['sensitivity'] || 300;
  this.useVisible = this.options['useVisible'] || false;
  this.useLoaded = this.options['useLoaded'] || false;
  this.useDetailOver = this.options['useDetailOver'] || false;
  this.activeid = this.options['activeid']||0;
  this.activating = this.options['activating']||(function(){});
  this.inactivating = this.options['inactivating']||(function(){});
  for(var i=1;i<=this.count;i++){
   this.eventActive = this.active.bindAsEventListener(this,i);
   this.eventInActive = this.inactive.bindAsEventListener(this,i);
   Event.observe($(this.tab + i),'mouseover',this.eventActive,true);
   Event.observe($(this.tab + i),'mouseout',this.eventInActive,true);
   if (this.useDetailOver) {
    if ( this.detailsuffix == '' ){
     Event.observe($(this.detail + i),'mouseover',this.eventActive,true);
     Event.observe($(this.detail + i),'mouseout',this.eventInActive,true);
    } else {
     Event.observe($(this.tab + i + this.detailsuffix),'mouseover',this.eventActive,true);
     Event.observe($(this.tab + i + this.detailsuffix),'mouseout',this.eventInActive,true);
    }
   }
  }
  if ((this.activeid != 0)&&(this.useLoaded)){
   this.activate(this.activeid)();
  }
 },
 active: function(event){
  if (this.taskInActive != null){
   this.taskInActive.cancel();
   this.taskInActive = null;
  }
  this.taskActive = this.activate(arguments[1]).later(this.sensitivity)();
 },
 activate: function(index){
  var _e = this;
  _e.activeid = index;
  return function(){
   if (_e.activeid != _e.beforeid ) {
    if (_e.beforeid != 0) {
     if (_e.useVisible) {
      if ( _e.detailsuffix == '' ){
       $(_e.detail + _e.beforeid).style.visibility = 'hidden';
      } else {
       $(_e.tab + _e.beforeid + _e.detailsuffix).style.visibility = 'hidden';
      }
     } else {
      if ( _e.detailsuffix == '' ){
       $(_e.detail + _e.beforeid).style.display = 'none';
      } else {
       $(_e.tab + _e.beforeid + _e.detailsuffix).style.display = 'none';
      }
     }
    }
    if (_e.useVisible) {
     if ( _e.detailsuffix == '' ){
      $(_e.detail + _e.activeid).style.visibility = 'visible';
     } else {
      $(_e.tab + _e.activeid + _e.detailsuffix).style.visibility = 'visible';
     }
    } else {
     if ( _e.detailsuffix == '' ){
      $(_e.detail + _e.activeid).style.display = 'block';
     } else {
      $(_e.tab + _e.activeid + _e.detailsuffix).style.display = 'block';
     }
    }
    _e.activating();
   }
   _e.beforeid = _e.activeid;
  };
 },
 inactive: function(event){
  if (this.taskActive != null ) {
   this.taskActive.cancel();
   this.taskActive = null;
  }
  if (this.useDetailOver) {
   this.taskInActive=this.inactivate(arguments[1]).later(this.sensitivity)();
  } else {
   if (this.useLoaded) {
    this.inactivating();
    this.activeid=this.beforeid;
   }else {
    if (this.beforeid != 0) {
     if (this.useVisible) {
      if ( this.detailsuffix == '' ){
       $(this.detail + this.beforeid).style.visibility = 'hidden';
      } else {
       $(this.tab + this.beforeid + this.detailsuffix).style.visibility = 'hidden';
      }
     } else {
      if ( this.detailsuffix == '' ){
       $(this.detail + this.beforeid).style.display = 'none';
      } else {
       $(this.tab + this.beforeid + this.detailsuffix).style.display = 'none';
      }
     }
    }
    this.inactivating();
    this.beforeid = 0;
   }
  }
 },
 inactivate: function(index){
  var _e = this;
  _e.activeid = index;
  return function(){
   if ( _e.detailsuffix == '' ){
    var aid = _e.detail+_e.activeid;
   } else {
    var aid = _e.tab+_e.activeid+_e.detailsuffix;
   }
   if (_e.useVisible) {
    $(aid).style.visibility='hidden';
   } else {
    $(aid).style.display='none';
   }
   if (_e.beforeid != 0) {
    if ( _e.detailsuffix == '' ){
     var bid = _e.detail+_e.beforeid;
    } else {
     var bid = _e.tab+_e.beforeid+_e.detailsuffix;
    }
    if (_e.useVisible) {
     $(bid).style.visibility='hidden';
    } else {
     $(bid).style.display='none';
    }
   }
   _e.inactivating();
   _e.beforeid=0;
  };
 },
 eom:null
});
// シンプルタブグループ
ISMEDIAns.cls.simpleTabGrouping = Class.create(ISMEDIAns.cls.tabGrouping,{
 initialize: function($super,options){
  $super(options);
  this.useLoaded = this.options['useLoaded']||true;
  this.activeid = this.options['activeid']||1;
  this.beforeid = this.activeid;
  this.bgImagePathPrefix = this.options['bgImagePathPrefix'];
  this.bgImagePathJoint = this.options['bgImagePathJoint'] || '';
  this.bgImageType = this.options['bgImageType'] || '.gif';
  if (this.options['activating']) {
   this.activating = (function(){this.changeBackground();this.options['activating']();});
  } else {
   this.activating = this.changeBackground;
  }
  this.inactivating =this.options['inactivating']||function(){};
 },
 changeBackground:function(){
  var aid = $(this.tab+this.activeid);
  aid.style.backgroundImage='url('+this.bgImagePathPrefix+this.activeid+this.bgImagePathJoint+'b'+this.bgImageType+')';
  if (this.beforeid>0) {
   var bid = $(this.tab+this.beforeid);
   bid.style.backgroundImage='url('+this.bgImagePathPrefix+this.beforeid+this.bgImagePathJoint+'a'+this.bgImageType+')';
  }
 },
 eom:null
});

// シンプルタブグループ( 非推奨（Deprecated）)
ISMEDIAns.cls.simpleTabGroup = Class.create(ISMEDIAns.cls.tabGroup,{
 initialize: function($super,options){
  $super(options);
  this.bgImagePathPrefix = this.options['bgImagePathPrefix'];
  this.bgImagePathJoint = this.options['bgImagePathJoint'] || '';
  this.bgImageType = this.options['bgImageType'] || '.gif';
  if (this.options['activating']) {
   this.activating = (function(){this.changeBackground();this.options['activating']();});
  } else {
   this.activating = this.changeBackground;
  }
  this.inactivating =this.options['inactivating']||function(){};
 },
 changeBackground:function(){
  for (var i=1; i<=this.count; i++){
   if (i==this.activeid) {
    $(this.tab+i).style.backgroundImage='url('+this.bgImagePathPrefix+i+this.bgImagePathJoint+'b'+this.bgImageType+')';
   } else {
    $(this.tab+i).style.backgroundImage='url('+this.bgImagePathPrefix+i+this.bgImagePathJoint+'a'+this.bgImageType+')';
   }
  }
 },
 eom:null
});

// タブグループオートプレイヤー
ISMEDIAns.cls.autoPlayer = Class.create({
 task:null,
 initialize: function(options){
  this.options = options||{};
  this.tabs = this.options['tabs'];
  this.interval = this.options['interval']||3;
  this.button = $(this.options['button'])||$$('body')[0];
  this.afterStart = this.options['afterStart']||function(){};
  this.afterStop = this.options['afterStop']||function(){};
  this.eventPlay = this.play.bindAsEventListener(this);
  Event.observe(this.button,'click',this.eventPlay,true);
 },
 move: function(_this){
  var _e = _this;
  return function(){
   var next = _e.tabs.activeid;
   next = (next==_e.tabs.count) ? 1: next+1;
    _e.tabs.activate(next)();
  };
 },
 start: function(){
  this.task = new PeriodicalExecuter(this.move(this),this.interval);
  this.afterStart();
 },
 stop: function(){
  try{
   this.task.stop();
   this.task = null;
   this.afterStop();
  } catch(e){}
 },
 play: function(event){
  (this.task == null ) ? this.start() : this.stop();
 },
 eom:null
});

var jsonScriptCounter=1;
function OuterScript(_url){
this.url= _url;
this.scriptObj=document.createElement('script');
this.scriptObj.setAttribute('type','text/javascript');
this.scriptObj.setAttribute('charset','utf-8');
this.scriptObj.setAttribute('id','simple'+jsonScriptCounter++);
this.scriptObj.setAttribute('src',this.url);
this.header=document.getElementsByTagName('head').item(0);
this.header.appendChild(this.scriptObj);
function remover(){this.header.removeChild(this.scriptObj);}
OuterScript.prototype.remove=remover;
}
function SimpleScript(_name){
this.url='/common/js/'+_name+'.js';
this.scriptObj=document.createElement('script');
this.scriptObj.setAttribute('type','text/javascript');
this.scriptObj.setAttribute('charset','utf-8');
this.scriptObj.setAttribute('id','simple'+jsonScriptCounter++);
this.scriptObj.setAttribute('src',this.url);
this.header=document.getElementsByTagName('head').item(0);
this.header.appendChild(this.scriptObj);
function remover(){this.header.removeChild(this.scriptObj);}
SimpleScript.prototype.remove=remover;
}
function MWjsonScript(_action,_callback,_searchword){
this.url='http://www.ismedia.jp/json/'+_action+'/'+_callback+'/'+_searchword;
this.scriptObj=document.createElement('script');
this.scriptObj.setAttribute('type','text/javascript');
this.scriptObj.setAttribute('charset','utf-8');
this.scriptObj.setAttribute('id','MWjson'+jsonScriptCounter++);
this.scriptObj.setAttribute('src',this.url);
this.header=document.getElementsByTagName('head').item(0);
this.header.appendChild(this.scriptObj);
function remover(){this.header.removeChild(this.scriptObj);}
MWjsonScript.prototype.remove=remover;
}
function AWSjsonScript(__key,__pub){
this.url='http://ecs.amazonaws.jp/onca/xml?';
this.url+='Service=AWSECommerceService&';
this.url+='AWSAccessKeyId='+'0ABQT5QYX0EQKC8GEH02'+'&';
this.url+='Version=2008-08-19&';
this.url+='Operation=ItemSearch&';
this.url+='SearchIndex=Books&';
this.url+='ResponseGroup=Small%2CImages%2COffers&';
this.url+='ContentType=text%2fjavascript&';
this.url+='Style=http%3a%2f%2fjbpress%2eismedia%2ejp%2foo%2faws%2exsl&';
if(__pub!=''){this.url+='Publisher='+encodeURIComponent(__pub)+'&';}
this.url+='Keywords='+encodeURIComponent(__key);
this.scriptObj=document.createElement('script');
this.scriptObj.setAttribute('type','text/javascript');
this.scriptObj.setAttribute('charset','utf-8');
this.scriptObj.setAttribute('id','AWSjson'+jsonScriptCounter++);
this.scriptObj.setAttribute('src',this.url);
this.header=document.getElementsByTagName('head').item(0);
this.header.appendChild(this.scriptObj);
function remover(){this.header.removeChild(this.scriptObj);}
AWSjsonScript.prototype.remove=remover;
}

Event.observe(window,'load',function(e){
 // ページ内リンク移動スクロール処理
 $$('a[href^="#"]:not([href="#"])').each(function(a){
  a.observe('click',function(e){
   try{
    new Effect.ScrollTo(this.hash.substr(1));
    Event.stop(e);
   }catch(err){}
  }.bindAsEventListener(a))
 });

 // 会員登録状態によるリード文追加
 (function(){
  add = function(_id){
   var l=$(_id).innerHTML+'\n';
   var url=location.href;
   if (document.cookie.indexOf('ismss')!=-1) {
    l+='<li><a href="http://www.ismedia.jp/category/info/regist" target="_blank">登録情報に関して<\/a><\/li>\n';
   } else {
    l+='<li><a href="http://www.ismedia.jp/category/info/regist" target="_blank">会員登録<\/a><\/li>\n';
    l+='<li><a href="https://www.ismedia.jp/auth/login/' + url + '">ログイン<\/a><\/li>\n';
   }
   $(_id).innerHTML=l;
  };
  if ($('registline-element-id') != undefined) {add('registline-element-id');}
  if ($('registline-element-id2') != undefined) {add('registline-element-id2');}
 })();

 // 非表示エレメント
 ISMEDIAns.util.elementsConceal();

 // ハイライトエレメント
 new PeriodicalExecuter(ISMEDIAns.util.elementsHighlight,5);
},true);

