<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title><%site_title%>: Publish Link to Social Media</title>
<%include include_common_head.html%>
</head>
<body id="add_success">
<%include include_accessibility.html%>
  <div id="wrapper">
<%include include_header.html%>
<%include include_contentheader.html%>
    <div id="ocwrapper" class="clear">
      <div id="icwrapper" class="clear">
<%include include_leftsidebar.html%>
        <div id="contentwrapper" class="shadowleft">
<%include include_contentwrapper_top.html%>
          <div class="shadowtop"><div class="shadowtopleft"></div><div class="shadowtopright"></div></div>
          <div class="shadowright">
            <div id="content">
<%include include_content_top.html%>

<div class="crumb"><%Links::Utils::format_title($main_title_loop, separator => $crumb_separator, no_escape_separator => $no_escape_crumb_separator, include_home => 1, link_type => 2)%></div>
<%if success%>
<h2>Link Published to Social Media</h2>
<%else%>
<h2>Publish Link to Social Media</h2>
<%endif%>

<%set ID ||= 4031%>
<%Plugins::SocialMedia::format_link($ID)%>
<%--
<img src="<%Picture%>" />
--%>
<%if success%>

The build is successful! <br /><br />

<%if twitter_published%>It has been published to twitter.<%elsif twitter_published_message%>There is an error posting twitter: <span style="color: red"><%twitter_published_message%></span><%endif%>
<br /><br />
<%if facebook_published%>It has been published to facebook.<%elsif facebook_published_message%>There is an error posting facebook: <span style="color: red"><%facebook_published_message%></span><%endif%>
<br /><br />

<%else%>

<p>
  The following link has been created:
</p>

<div class="row clear">
  <label class="name">Title:</label>
  <div class="value wrappedtext"><%Title%></div>
</div>
<div class="row clear">
  <label class="name">Category:</label>
  <div class="value wrappedtext">
<%~if Category_loop.length > 1%>
    <ul><%loop Category_loop%><li><%loop_value%></li><%endloop%></ul>
<%~else%>
    <%Category%>
<%~endif%>
  </div>
</div>
<div class="row clear">
    <label class="name">Link Type:</label>
    <div class="value wrappedtext"><%if Link_Type eq 'photo'%>Photo Gallery<%elseif Link_Type eq 'video'%>Video<%else%>Article<%endif%></div>
</div>
<div class="row clear">
  <label class="name">Description:</label>
  <div class="value wrappedtext"><%escape_html Description%></div>
</div>
<div class="row clear">
  <label class="name">Contact Name:</label>
  <div class="value wrappedtext"><%escape_html Contact_Name%></div>
</div>
<div class="row clear">
  <label class="name">Contact E-mail:</label>
  <div class="value wrappedtext"><%escape_html Contact_Email%></div>
</div>

<p>
<%~if config.build_auto_validate%>
  Your link has been added to <%if Category_loop.length > 1%>the following categories: <%loop Category_loop%><%loop_value%><%unless last%>, <%endunless%><%endloop%><%else%><%Category%><%endif%>.
  You can preview the link at <a href="<%config.db_cgi_url%>/page.cgi?g=<%ID%>.html">here</a>. 
<%~else%>
  Thank you! We will send you an e-mail once your link has been validated.
<%~endif%>
</p>

<%--
<h2>Build it?</h2>
<p>
<form id="media_form" action="<%config.db_cgi_url%>/post_media.cgi" enctype="multipart/form-data" method="post">
  <div class="formsubmit">
    <input type="submit" name="build_it" value="Build" class="submit" />
  </div>
</form>
</p>
--%>

<h2>Publish it?</h2>
<p>
<div id="loading" style="display:none;">Loading ..... </div>

<form id="media_form" action="<%config.db_cgi_url%>/post_media.cgi" enctype="multipart/form-data" method="post">
<input type="hidden" name="linkid" value="<%ID%>">
<%--
<div class="row required clear">
  <label for="Title" class="name">Title: <span>*</span></label>
  <div class="value">
    <input type="text" id="Title" name="Title" value="<%if Title%><%escape_html Title%><%endif%>" class="text" />
  </div>
</div>
<div class="row clear">
  <label for="Title" class="name">Title: </label>
  <div class="value">
    <input type="text" id="Title" name="Title" value="<%if Title%><%escape_html Title%><%endif%>" class="text" />
  </div>
</div>
--%>

<div class="row clear">
  <label for="post_twitter" class="name">Post on Twitter? </label>
  <div class="value">
    <input type="checkbox" id="post_twitter" name="post_twitter" value="1" /> Yes
  </div>
</div>

<div class="row clear">
  <label for="Title" class="name">Twitter Status line: </label>
  <div class="value wrappedtext">
    <textarea id="twitter_status" name="twitter_status" rows="3" cols="25"><%if twitter_status%><%escape_html twitter_status%><%else%><%escape_html Description%><%endif%></textarea>
    <br />Use existing status line, or update as required. Link URL will be automatically appended to tweet.
  </div>
</div>

<div class="row clear">
  <label for="Title" class="name">Twitter Hash tags: </label>
  <div class="value wrappedtext">
    <textarea id="twitter_hash_tags" name="twitter_hash_tags" rows="3" cols="25"><%if twitter_hash_tags%><%escape_html twitter_hash_tags%><%endif%></textarea>
    <br /> Please separate each hash tag with comma.  <br />For example: bike, runner, slowtwitch.
  </div>
</div>

<div class="row clear">
  <label for="post_facebook" class="name">Post on Facebook? </label>
  <div class="value">
    <input type="checkbox" id="post_facebook" name="post_facebook" value="1" /> Yes
  </div>
</div>
<%--
<div class="row clear">
  <label for="post_facebook" class="name">Choose an image for Facebook post: </label>
  <div class="value">
<%loop image_paths.images_loop%>
<input type="radio" name="facebook_image" value="<%col_name%>" />
<img src="<%_thumbnail_path%>" />
<%endloop%>
  </div>
</div>
--%>

<%--DUMP image_paths.images_loop--%>

  <div class="formsubmit">
    <input type="submit" name="build" value="Build" class="submit" />
  </div>
</form>
</p>
<%endif%>

<%include include_content_bottom.html%>
            </div>
          </div>
          <div class="shadowbottom"><div class="shadowbottomleft"></div><div class="shadowbottomright"></div></div>
<%include include_contentwrapper_bottom.html%>
        </div>
<%include include_rightsidebar.html%>
      </div>
    </div>
<%include include_contentfooter.html%>
<%include include_footer.html%>
  </div>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(document).ready(function() {
    $('.submit').click(function() {
        $('#media_form').slideUp('fast',function(){
            $('#loading').slideDown();
        });
        return true;
    });
});
</script>
</body>
</html>
