<% require 'cgi' %>

<% content_for :head do %>
  <%= stylesheet_link_tag "front/item" %>
  <%= stylesheet_link_tag "thickbox" %>
  <%= javascript_include_tag :defaults %>
  <%= javascript_include_tag "jquery" %>
  <%= javascript_include_tag "no_confrict" %>
  <%= javascript_include_tag js_url(:action => "thickbox") %>
  <%= javascript_include_tag "recommender_details" %>
  <%= javascript_include_tag js_url(:action => "application") %>

  <% if @social_flag %>
    <% if @social.gree || @social.facebook -%>
      <meta property="og:title" content="<%= content_title_tag(["K&B style", @product_name, @categoly_name, @campaign_name]) %>"/>
      <meta property="og:url" content="<%= request.url %>"/>
      <meta property="og:image" content="<%= url_for(:only_path => false, :controller => "/image_resource", :action => "show", :id => (@product.large_resource_id || @product.medium_resource_id),:format => "png", :height => 640, :width => 480) %>" /> 
      <meta property="og:site_name" content="K&B style"/>
    <% end %>
    <% if @social.mixi_check || @social.mixi_like -%>
      <meta property="og:description" content="<%= @social.mixi_description %>"/>
    <% end %>
    <% if @social.google -%>
      <script type="text/javascript" src="https://apis.google.com/js/plusone.js">{lang: 'ja'}</script>
    <% end %>
  <% end %>
<% end %>

<div id="left_box" class="clearfix">
  <%= render :partial => '/base/left_sidebar' %>

  <!-- メイン -->
  <div id="main">

  <ol id="bread_list" class="m_btm"><li class="bread_top"><%= link_to "トップページ", :controller => :portal, :action => :show %></li><li><%= link_to("商品一覧", { :controller => "/products", :action => "index"}) %></li><li><%= @product.name %></li></ol>

  <!-- 商品詳細 -->
  <div><%= image_tag("common/box_bg_top.gif", :width => "530", :height => "5", :alt => "") %></div>
  <div id="item_box" class="main_box">
  <div id="item_box_top" class="clearfix">
    <div class="item_pic">
      <%= link_to((product_image_tag(@product, :medium, :width=>250)), { :controller => "/image_resource", :action => "show", :id => (@product.large_resource_id || @product.medium_resource_id),:format => "png", :height => 640, :width => 480 }, {:title => "#{@product.name}", :class => "thickbox"} ) %>
      <%- unless @product.medium_resource_comment.blank? %>
      <p>
      <%= h_br @product.medium_resource_comment unless @product.medium_resource_comment.blank? %>
      </p>
      <%- end %>
    <br />
  </div>
  <div class="item_data">
  <% @product.product_statuses.each do | product_status | %>
    <span id="appeal"><%= h_br product_status.status && product_status.status.name %></span>
  <% end %>
    <dl>
      <dt><%=@product.url.blank? ? h( @product.name ) : link_to(@product.name, @product.url) %></dt>
      <dd>価格：<%=h @product.price_label %>円</dd>
      <dd>販売期間：<%=h print_date(@product.sale_start_at) %> ～ <%=h print_date(@product.sale_end_at) %></dd>
            <% if @product.product_styles && @product.product_styles.detect(nil){ |p_s| p_s.orderable_count.to_i > 0} -%>
              <%- unless @product.delivery_dates_label.blank? %>
              <dd>お届け：<%= @product.delivery_dates_label %></dd>
              <%- end %>
            <% else %>
              <% if @product.arrival_expected_date && @product.arrival_expected_date < Date.today %>
                <dd>入荷未定</dd>
            <% else %>
                <dd>入荷予定日：<%= date_jp(@product.arrival_expected_date) %></dd>
              <% end %>
          <% end %>
          <dd>販売元: <%= show_retailer_shop(@product) %></dd>
    </dl>
    <%- if @product.have_zaiko? -%>
    <%= render :partial => "base/add_cart", :locals => {:product => @product} %>
   　　   <%have_style = @product.product_styles.any?(&:style_category1)%>
     <%if have_style%>
	 <dl><dd><%= link_to_remote( "在庫一覧を見る",
						:update => "stock_table",
						:url =>{ :action=>"stock_table",:id=>@product,:partial=>true }) %></dd></dl>
     <div id="stock_table" align="right">
	   <%= render :action => 'stock_table', :method=>:get %>
	 </div>
	 <%end%>						
    <%- else -%>
    品切れ中<br />
    <%- end -%>
  </div>
  </div><!-- /item_pic_box -->

  <%- if blank_check(@product.sub_products) %>
  <table id="thumb">
    <tr>
      <% @product.sub_products.each do | sub_product | %>
      <td>
        <%= link_to (sub_product_image_tag(sub_product, :width=>60)), { :controller => "/image_resource", :action => "show", :id => (sub_product.large_resource_id || sub_product.medium_resource_id ) ,:format => "png", :height => 640, :width => 480 }, {:title => "#{@product.name}", :class => "thickbox"} if sub_product.medium_resource_id %>
        <p><%= sub_product.name %></p>
        <p><%= sub_product.description %></p>
      </td>
      <% end %>
    </tr>
  </table>
  <%- end %>


  <div class="main_hr"><hr /></div>

  <p class="description">
  <%=h_br @product.description %>
  <br />
  <%= ("【サイズ】<br />" + h_br(@product.size_txt) + "<br />" ) unless @product.size_txt.blank? %>
  <%= ("【素材】<br />" + h_br(@product.material) + "<br />" ) unless @product.material.blank? %>
  <%= ("【原産国】<br />" + h_br(@product.origin_country) + "<br />" ) unless @product.origin_country.blank? %>
  <%= ("【重さ】<br />" + h_br(@product.weight) + "<br />" ) unless @product.weight.blank? %>
  <%= ("【その他、仕様】<br />" + h_br(@product.other) + "<br />" ) unless @product.other.blank? %>
  <%= ("【入荷日】<br />" + h_br(@product.arrival_date) + "<br />" ) unless @product.arrival_date.blank? %>
  </p>

  <% if @social_flag %>
  <div class="main_hr"><hr /></div>

  <div class="social">
  <% if @social.google %>
    <g:plusone size="medium"></g:plusone>
  <% end %>

  <% if @social.twitter %>
    <a href="http://twitter.com/share" class="twitter-share-button" data-count="harizon" data-lang="ja" data-via="<%= @social.twitter_user %>">ツイート</a>
    <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
  <% end %>

  <% if @social.hatena %>
    <a href="http://b.hatena.ne.jp/entry/<%= request.url %>" class="hatena-bookmark-button" data-hatena-bookmark-title="<%= content_title_tag(['K&B style', @product_name, @categoly_name, @campaign_name]) %>"  data-hatena-bookmark-layout="standard" title="このエントリーをはてなブックマークに追加"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a>
    <script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async"></script>
  <% end %>

  <% if @social.gree %>
    <iframe src="http://share.gree.jp/share?url=<%= CGI.escape(request.url) %>&type=0&height=20" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" style="border:none; overflow:hidden; width:70px; height:20px;" allowTransparency="true"></iframe>
  <% end %>

  <% if @social.evernote %>
    <script type="text/javascript" src="http://static.evernote.com/noteit.js"></script>
    <a href="#" onclick="Evernote.doClip({contentId:'main', styling:'full'}); return false;"><img src="http://static.evernote.com/article-clipper.png" alt="Clip to Evernote" /></a>
  <% end %>

  <% if @social.facebook %>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/ja_JP/all.js#xfbml=1"></script>
    <fb:like href="<%= request.url %>" send="true" layout="button_count" width="130" show_faces="false" action="like" font=""></fb:like>
  <% end %>

  <% if @social.mixi_check %>
    <a href="http://mixi.jp/share.pl" class="mixi-check-button" data-key="<%= @social.mixi_key %>">mixiチェック</a>
    <script type="text/javascript" src="http://static.mixi.jp/js/share.js"></script>
  <% end %>

  <% if @social.mixi_like %>
    <iframe src="http://plugins.mixi.jp/favorite.pl?href=<%= CGI.escape(request.url) %>&service_key=<%= @social.mixi_key %>" scrolling="no" frameborder="0" allowTransparency="true" style="border:0; overflow:hidden; width:450px; height:80px;"></iframe>
  <% end %>

  </div>
  <% end %>

  </div><!-- /item_box -->
  <div class="m_btm"><%= image_tag("common/box_bg_btm.gif", :width => "530", :height => "5", :alt => "") %></div>

  <div id="under_line"></div>
  <% @reco_no = 0 %>
  <%= render :partial => '/base/recommend_asp', :locals => {:size=>4} %>

  </div><!-- /main -->
</div>
<%= render :partial => '/base/right_sidebar' %>
