<!-- Code that adds a "Print with Photobox or Shutterfly" link to slide images.
     These services prints images and delivers them to your door.
-->

<%!
	String productUrl;
	String postUrl;
	if (printing.equals("photobox")) {
		productUrl = "www.photobox.co.uk";
	}
	else if (printing.equals("digibug")) {
		productUrl = "www.digibug.com";
	}
	else {
		productUrl = "shutterfly.com";
	}
%>

<ja:if test="<%=printing.equals("shutterfly")%>">

	<script type="text/javascript">
	function submitOrderForm()
	{
		if (location.protocol != 'http:') alert("Ordering prints on-line requires this album to be hosted on a public web server.\n" +
		 "Use the JAlbum publish section to publish this album.");
		else if (confirm("You will now be transferred to <%=productUrl%> where you may order prints of this image.\n<%=productUrl%> will shortly grab your selected images (originals if published)\nfrom this web site for printing. Make sure they are available on-line!\n\nDisclaimer:\nJAlbum assumes no responsibility for the fulfillment of this printing service.")) {
			form = document.forms['orderform'];
			location = window.location;
			form.returl.value = location.href;
			href = location.href;
			form["imraw-1"].value = href.substring(0,href.lastIndexOf("slides/")) + form.toImage.value;
			form["imthumb-1"].value = href.substring(0,href.lastIndexOf("slides/")) + form.toThumb.value;
			form.submit();
		}
	}
	</script>

	<form name="orderform" action="http://www.shutterfly.com/c4p/UpdateCart.jsp" method="post">
		<p>
		<input type="hidden" name="addim" value="1">
		<input type="hidden" name="protocol" value="SFP,100">
		<input type="hidden" name="pid" value="C4PP">
		<input type="hidden" name="psid" value="JALB">
		<input type="hidden" name="imnum" value="1">
		<input type="hidden" name="imraw-1" value="REPLACE_ME">
		<ja:if exists="originalPath">
		<input type="hidden" name="imrawwidth-1" value="$originalWidth">
		<input type="hidden" name="imrawheight-1" value="$originalHeight">
		<input type="hidden" name="toImage" value="$fileName">
		</ja:if>
		<ja:else>
		<input type="hidden" name="imrawwidth-1" value="$imageWidth">
		<input type="hidden" name="imrawheight-1" value="$imageHeight">
		<ja:if test="<%= engine.getImageLinking().equals("LinkOriginals") %>">
			<input type="hidden" name="toImage" value="$fileName">
		</ja:if>
		<ja:else>
			<input type="hidden" name="toImage" value="slides/$fileName">

		</ja:else>
		</ja:else>
		<input type="hidden" name="imthumb-1" value="REPLACE_ME">
		<input type="hidden" name="imthumbwidth-1" value="$thumbWidth">
		<input type="hidden" name="imthumbheight-1" value="$thumbHeight">
		<input type="hidden" name="returl" value="REPLACE_ME">

		<input type="hidden" name="fromSlides" value="slides/$currentPage">
		<input type="hidden" name="toThumb" value="thumbs/$fileName">
		</p>
	</form>
</ja:if>


<ja:if test="<%=printing.equals("digibug")%>">
  <% if (companyId == void) {
 		window.messageBox("Please define companyId as a user defined variable under the Advanced tab");
 		companyId = 0;
     }
  %>

    <script type="text/javascript">
    function submitOrderForm()
    {
        if (location.protocol != 'http:') alert("Ordering prints on-line requires this album to be hosted on a public web server.\n" +
         "Use the JAlbum publish section to publish this album.");
        else if (confirm("You will now be transferred to <%=productUrl%> where you may order prints of this image.\n<%=productUrl%> will shortly grab your selected images (originals if published)\nfrom this web site for printing. Make sure they are available on-line!\n\nDisclaimer:\nJAlbum assumes no responsibility for the fulfillment of this printing service.")) {
            form = document.forms['orderform'];
            location = window.location;
            form.return_url.value = location.href;
            href = location.href;
            form["image_1"].value = href.substring(0,href.lastIndexOf("slides/")) + form.toImage.value;
            form["thumb_1"].value = href.substring(0,href.lastIndexOf("slides/")) + form.toThumb.value;
            form.submit();
        }
    }
    </script>

    <form action="http://www.digibug.com/dapi/order.php" method="post" name="orderform">
        <p>
        <input type="hidden" name="digibug_api_version" value="100">
        <input type="hidden" name="partner_code" value="67">
        <input type="hidden" name="company_id" value="$companyId">
        <input type="hidden" name="event_id" value="$eventId">
        <input type="hidden" name="cmd" value="addimg">
        <input type="hidden" name="num_images" value="1">
        <input type="hidden" name="image_1" value="REPLACE_ME">
        <ja:if exists="originalPath">
        <input type="hidden" name="image_width_1" value="$originalWidth">
        <input type="hidden" name="image_height_1" value="$originalHeight">
        <input type="hidden" name="toImage" value="$fileName">
        </ja:if>
        <ja:else>
        <input type="hidden" name="image_width_1" value="$imageWidth">
        <input type="hidden" name="image_height_1" value="$imageHeight">
        <ja:if test="<%= engine.getImageLinking().equals("LinkOriginals") %>">
            <input type="hidden" name="toImage" value="$fileName">
        </ja:if>
        <ja:else>
            <input type="hidden" name="toImage" value="slides/$fileName">
        </ja:else>
        </ja:else>
        <input type="hidden" name="thumb_1" value="REPLACE_ME">
        <input type="hidden" name="thumb_width_1" value="$thumbWidth">
        <input type="hidden" name="thumb_height_1" value="$thumbHeight">
        <input type="hidden" name="return_url" value="REPLACE_ME">
        <input type="hidden" name="fromSlides" value="slides/$currentPage">
        <input type="hidden" name="toThumb" value="thumbs/$fileName">
        </p>
    </form>
</ja:if>


<ja:if test="<%=printing.equals("photobox")%>">

<%
	int width = originalWidth;
	int height = originalHeight;
	if (orientation != void && !"normal".equals(orientation) && originalWidth > originalHeight) {
		width = originalHeight;
		height = originalWidth;
	}
	String key = se.datadosen.util.IO.urlEncode(fileName); // PhotoBox requirement
%>

	<script type="text/javascript">
	function submitOrderForm()
	{
		if (location.protocol != 'http:') alert("Ordering prints on-line requires this album to be hosted on a public web server.\n" +
		 "Use the JAlbum publish section to publish this album.");
		else if (confirm("You will now be transferred to <%=productUrl%> where you may order prints of this image.\n<%=productUrl%> will shortly grab your selected images (originals if published)\nfrom this web site for printing. Make sure they are available on-line!\n\nDisclaimer:\nJAlbum assumes no responsibility for the fulfillment of this printing service.")) {
			form = document.forms['orderform'];
			location = window.location;
			href = location.href;
			var s = href.substring(0,href.lastIndexOf("slides/")) + form.toImage.value;
			form["photo_url_${key}"].value = s.substring(0,7) + escape(s.substring(7));
			var s2 = href.substring(0,href.lastIndexOf("slides/")) + form.toThumb.value;
			form["thumbnail_url_${key}"].value = s2.substring(0,7) + escape(s2.substring(7));
			form.submit();
		}
	}
	</script>


	<form name="orderform" action="http://printbutton.photobox.co.uk/printbutton.html" method="post" target="printbutton" onSubmit="window.open('','printbutton','width=200,height=350')">

		<input type="hidden" name="v_id" value="1010432">
		<input type="hidden" name="buy" value="${key}">
		<input type="hidden" name="subvendor_${key}" value="$skin">
		<input type="hidden" name="notfromcache" value="true">
		
		<input type="hidden" name="photo_url_${key}" value="REPLACE_ME">
		<input type="hidden" name="thumbnail_url_${key}" value="REPLACE_ME">
		<ja:if exists="originalPath">
			<input type="hidden" name="photo_width_${key}" value="${width}">
			<input type="hidden" name="photo_height_${key}" value="${height}">
			<input type="hidden" name="toImage" value="$fileName">
		</ja:if>
		<ja:else>
			<input type="hidden" name="photo_width_${key}" value="$imageWidth">
			<input type="hidden" name="photo_height_${key}" value="$imageHeight">
			<ja:if test="<%= engine.getImageLinking().equals("LinkOriginals") %>">
				<input type="hidden" name="toImage" value="$fileName">
			</ja:if>
			<ja:else>
				<input type="hidden" name="toImage" value="slides/$fileName">
			</ja:else>
		</ja:else>

		<input type="hidden" name="toThumb" value="thumbs/$fileName">
		</p>
	</form>
	
</ja:if>
