ck=false;
$(document).ready(function() {
    $('#photo').after('<ul id="photoicon">').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 0,
		before:  onBefore,
        pager:  '#photoicon',
        pagerAnchorBuilder: function(idx, slide) {
            return '<li class=""><a href="#"><img src="' + slide.src + '" width="75" /></a></li>';
        }
    });
	
	function onBefore() { 
    	var targetHeight = this.height;
		$('#photo').css({'height':targetHeight});
	}
	
	$('#movin').css({display: 'none', position: 'absolute'});

  $('#innocent_group').click(function () {
		var position = {};
		$('#innocent_group').position(position);
		if ($('#movin').css('display') == 'none'){
			$('#movin').fadeIn("normal", function(){ck=true;});
		}else{
			$('#movin').fadeOut("fast", function(){ck=false;});
		}
		$('#movin').height();
		$('#movin').css('left', position.left);
		$('#movin').css('top', position.top - $('#movin').height());
	});
  $('#baseblock').click(function () {
    if(ck)$('#movin').fadeOut("normal",function(){ck=false;});
  });
//swap img
var conf = {className : 'btn',postfix : 'on'};
  var image_cache = new Object();
  $('img.'+conf.className).each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) +  conf.postfix + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
});
