/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/
new function(){function a(){this.className="heightLine";this.parentClassName="heightLineParent";reg=new RegExp(this.className+"-([a-zA-Z0-9-_]+)","i");objCN=new Array();var m=document.getElementsByTagName?document.getElementsByTagName("*"):document.all;for(var h=0;h<m.length;h++){var c=m[h].className.split(/\s+/);for(var g=0;g<c.length;g++){if(c[g]==this.className){if(!objCN["main CN"]){objCN["main CN"]=new Array()}objCN["main CN"].push(m[h]);break}else{if(c[g]==this.parentClassName){if(!objCN["parent CN"]){objCN["parent CN"]=new Array()}objCN["parent CN"].push(m[h]);break}else{if(c[g].match(reg)){var f=c[g].match(reg);if(!objCN[f]){objCN[f]=new Array()}objCN[f].push(m[h]);break}}}}}var l=document.createElement("div");var k=document.createTextNode("S");l.appendChild(k);l.style.visibility="hidden";l.style.position="absolute";l.style.top="0";document.body.appendChild(l);var d=l.offsetHeight;changeBoxSize=function(){for(var r in objCN){if(objCN.hasOwnProperty(r)){if(r=="parent CN"){for(var q=0;q<objCN[r].length;q++){var p=0;var s=objCN[r][q].childNodes;for(var o=0;o<s.length;o++){if(s[o]&&s[o].nodeType==1){s[o].style.height="auto";p=p>s[o].offsetHeight?p:s[o].offsetHeight}}for(var o=0;o<s.length;o++){if(s[o].style){var n=s[o].currentStyle||document.defaultView.getComputedStyle(s[o],"");var e=p;if(n.paddingTop){e-=n.paddingTop.replace("px","")}if(n.paddingBottom){e-=n.paddingBottom.replace("px","")}if(n.borderTopWidth&&n.borderTopWidth!="medium"){e-=n.borderTopWidth.replace("px","")}if(n.borderBottomWidth&&n.borderBottomWidth!="medium"){e-=n.borderBottomWidth.replace("px","")}s[o].style.height=e+"px"}}}}else{var p=0;for(var q=0;q<objCN[r].length;q++){objCN[r][q].style.height="auto";p=p>objCN[r][q].offsetHeight?p:objCN[r][q].offsetHeight}for(var q=0;q<objCN[r].length;q++){if(objCN[r][q].style){var n=objCN[r][q].currentStyle||document.defaultView.getComputedStyle(objCN[r][q],"");var e=p;if(n.paddingTop){e-=n.paddingTop.replace("px","")}if(n.paddingBottom){e-=n.paddingBottom.replace("px","")}if(n.borderTopWidth&&n.borderTopWidth!="medium"){e-=n.borderTopWidth.replace("px","")}if(n.borderBottomWidth&&n.borderBottomWidth!="medium"){e-=n.borderBottomWidth.replace("px","")}objCN[r][q].style.height=e+"px"}}}}}};checkBoxSize=function(){if(d!=l.offsetHeight){changeBoxSize();d=l.offsetHeight}};changeBoxSize();setInterval(checkBoxSize,1000);window.onresize=changeBoxSize}function b(g,d,c){try{g.addEventListener(d,c,false)}catch(f){g.attachEvent("on"+d,c)}}b(window,"load",a)};

/**
 * jQuery.rollover
 *
 * @version  1.0.2
 * @author   rew <rewish.org@gmail.com>
 * @link     http://rewish.org/javascript/jquery_rollover_plugin
 * @license  http://rewish.org/license/mit The MIT License
 *
 * Inspired by:
 * Telepath Labs (http://dev.telepath.co.jp/labs/article.php?id=15)
 *
 * Usage:
 * jQuery(document).ready(function($) {
 *   // <img>
 *   $('#nav a img').rollover();
 *
 *   // <input type="image">
 *   $('form input:image').rollover();
 *
 *   // set suffix
 *   $('#nav a img').rollover('_over');
 * });
 */
jQuery.fn.rollover = function(suffix) {
  suffix = suffix || '_1';
  return this.not('[src*="'+ suffix +'."]').each(function() {
      var img = jQuery(this);
      var src = img.attr('src');
      var _on = [
      src.substr(0, src.lastIndexOf('.')),
      src.substring(src.lastIndexOf('.'))
      ].join(suffix);
      jQuery('<img>').attr('src', _on);
      img.hover(
        function() { img.attr('src', _on); },
        function() { img.attr('src', src); }
        );
      });
};

/*
 * jQuery Watermark Plugin (v1.0.0)
 *   http://updatepanel.net/2009/04/17/jquery-watermark-plugin/
 *
 * Copyright (c) 2009 Ting Zwei Kuei
 *
 * Dual licensed under the MIT and GPL licenses.
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.opensource.org/licenses/gpl-3.0.html
 */
(function($) {
 $.fn.updnWatermark = function(options) {
 options = $.extend({}, $.fn.updnWatermark.defaults, options);
 return this.each(function() {
   var $input = $(this);
   // Checks to see if watermark already applied.
   var $watermark = $input.data("updnWatermark");
   // Only create watermark if title attribute exists
   if (!$watermark && this.title) {
   // Inserts a span and set as positioning context
   var $watermark = $("<span/>")
   .addClass(options.cssClass)
   .insertBefore(this)
   .hide()
   .bind("show", function() {
     $(this).children().fadeIn("fast");
     })
   .bind("hide", function() {
     $(this).children().hide();
     });
   // Positions watermark label relative to positioning context
   $("<label/>").appendTo($watermark)
   .text(this.title)
   .attr("for", this.id);
   // Associate input element with watermark plugin.
   $input.data("updnWatermark", $watermark);
   }
   // Hook up blur/focus handlers to show/hide watermark.
   if ($watermark) {
     $input
       .focus(function(ev) {
           $watermark.trigger("hide");
           })
     .blur(function(ev) {
         if (!$(this).val()) {
         $watermark.trigger("show");
         }
         });
     // Sets initial watermark state.
     if (!$input.val()) {
       $watermark.show();
     }
   }
 });
 };
 $.fn.updnWatermark.defaults = {
cssClass: "updnWatermark"
 };
 $.updnWatermark = {
attachAll: function(options) {
             $("input:text[title!=''],input:password[title!=''],textarea[title!='']").updnWatermark(options);
           }
 };
})(jQuery);


/*
 * common.js
 * @requires jQuery v1.2 or later
 *
 * Copyright (c) 2009 Masami Asai
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 */

$(document).ready(function(){
    /* --------------------------------------
     *  rollover設定
     * -------------------------------------- */
    $("form input:image").rollover();
    $("^#download-dialog a img,form input:image, a.photo-download img").rollover();

    /* --------------------------------------
     *  lighboxクリック後画像ID設定関数
     * -------------------------------------- */

    if(typeof jQuery.fn.updnWatermark !== "undefined") {
      jQuery.updnWatermark.attachAll()
    }

    /* --------------------------------------
     *  lighboxクリック後画像ID設定関数
     * -------------------------------------- */
    var _setImageID = function(el) {
      var _link = $(el.target).parent().parent().siblings("a");
      var _container = $("#lightbox-secNav");
      $(_link).clone(true).insertAfter(_container);
      return false;
    }

    if (typeof jQuery.fn.lightBox !== "undefined") {
      $("a[rel^=facebox]").lightBox({
        fixedNavigation: true,
        imageLoading: '/img/lightbox/loading.gif',
        imageBtnClose: '/img/btn_close.png',
        imageBtnPrev: '/img/lightbox/prev.gif',
        imageBtnNext: '/img/lightbox/next.gif',
        imageBlank: '/img/lightbox/blank.gif',
        txtImage: '画像',
        txtOf: ' / ',
        containerResizeSpeed: 250
      }).click(function(e){
        $("#lightbox-secNav").prepend('<a href="#" class="open-dialog photo-download" onclick="return false;"><img src="/img/btn_download.png" width="127" height="31" alt="ダウンロード" /></a>');
        $("#lightbox-secNav a img").rollover();
      });
    }

    /* --------------------------------------
     * ボタン処理 
     * -------------------------------------- */
    $('.button').hover(
      function(){
        $(this).addClass("ui-state-hover");
      },
      function(){
        $(this).removeClass("ui-state-hover");
      }
    ).mousedown(function(){
      $(this).addClass('ui-state-active');
    }).mouseup(function(){
      $(this).removeClass('ui-state-active');
    });

    /* --------------------------------------
     *  select変化時のoption処理の関数
     * -------------------------------------- */
    var _chOptVal = function(target, name) {
    target.children('option:selected').each(function(){
      i = target.val();
      $('#' + name + ' *:not(:first)').remove();
      for(var k in dataAray[i]) {
      $('#' + name).append('<option value=' + k + '>' + dataAray[i][k] + '</option>');
      }
      });
    }

    /* --------------------------------------
     *  select変化の処理
     * -------------------------------------- */
    $('#SearchLocationId').bind('change', function(){
      _chOptVal($(this), 'SearchLocationCityId');
      $(this).bind('changedAfter', function(e){
        var defVal = $('#SearchLocationCityIdAlt').val();
        $('#SearchLocationCityId > option').each(function(){
          if ($(this).val() == defVal) {
          $(this).attr('selected', 'selected');
          }
          });
        });
      }).trigger('change').trigger('changedAfter');

    $('#AddLocationId').change(function(){
        _chOptVal($(this), 'AddLocationCityId');
        $(this).bind('changedAfter', function(e){
          var defVal = $('#LocationCityIdAlt').val();
          $('#AddLocationCityId > option').each(function(){
            if ($(this).val() == defVal) {
            $(this).attr('selected', 'selected');
            }
            });
          });
      }).trigger('change').trigger('changedAfter');

    /* --------------------------------------
     *  ダウンロードダイアログの処理
     * -------------------------------------- */
    if(typeof jQuery.fn.dialog !== "undefined") {
      $("#download-dialog").dialog({
        bgiframe: true,
        autoOpen: false,
        width: 560,
        height: 550,
        modal: true,
        title: false,
        open: function(e, ui) {
          var _self = $(this);
          $("#download-dialog-send").bind("click", function(){
            _self.children('form').submit();
            _self.dialog('close');
            return false;
          });
          $("#download-dialog-cancel").bind("click", function(){
            _self.dialog('close');
            return false;
          });
        },
        close: function(e, ui) {
          $("#download-dialog-send, #download-dialog-cancel").unbind("click");
        }
    });

          $(".ui-dialog-titlebar").remove();
    /* --------------------------------------
     *  lightboxとダウンロードされる写真IDの動作紐付け
     * -------------------------------------- */
    var tmpArr, idArr, _id;
    tmpArr = $("#content ul li[id^=pd]");
    idArr = new Array();
    $.each(tmpArr, function(i){
        idArr[i] = $(tmpArr[i]).attr("id").split("_")[1];
    });

    // ダウンロードボタンの処理
    $(".photo-download,a[rel^=facebox]").click(function(e){
      _id  = $(this).parents("li").attr("id").split("_")[1];
      $("#tmbShowcase").empty().append($("#pd_" + _id + " img:first").clone());
    });

    $("#lightbox-nav a").live('mouseup', function(e){
      var _val, _index;
      _index = $.inArray(_id, idArr);
      if ($(this).attr("id") == "lightbox-nav-btnNext") {
        _id = idArr[_index + 1];
      } else {
        _id = idArr[_index - 1];
      };
      $("#tmbShowcase").empty().append($("#pd_" + _id + " img:first").clone());
      return false;
    });

    var _dialogHandle = $.browser.msie ? "mouseup" : "click";
    $(".open-dialog").live(_dialogHandle, function(e){
      $("#download-dialog #PhotoPhotoId").val(_id);
      $("#download-dialog").dialog('open');
      return false;
    });
  }
});



