<?php

/*
 * $RCSfile: $
 *
 * Digibug4CPG - a plugin for Coppermine gallery to create photo prints, and print product gift items
 * Copyright (C) 2006 Digibug Express, Inc. 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 */
/**
 * @version $Revision: $ $Date: $
 * @package Digibug4CPG
 * @author James Andrews <jandrews@digibug.com> for Digibug Express, Inc. http://www.digibug.com/
 */

    require_once($digibugPluginHome.'/Digibug4CPG.conf.php');

    // Global variables needed.
    if(!$_SESSION['digibug']){
        $_SESSION['digibug'] = Array();
        $_SESSION['digibug']['cart'] = Array();
    }

    $_SESSION['digibug']['companyId'] = $digibugCompanyId;
    $_SESSION['digibug']['eventId'] = $digibugEventId;
    $_SESSION['digibug']['postUrl'] = $digibugPostUrl;

    /** 
     *  Function to create the div containers for the image cart, and the product view.
     */
    function digibugCartAndViewDivElements(){
        $html="<div id=\"digibug-hidden-divs\">";
        $html.="  <div id=\"digibug-cartview\">";
        $html.="    <div id=\"digibug-carthead\"><div class=\"digibug-left\">Currently In Your Cart</div><div class=\"digibug-right\"><a href=\"javascript:digibugCloseViewDivs('digibug-cartview');\">Hide Cart</a></div><div class=\"digibug-clear\"></div></div>";
        $html.="    <div id=\"digibug-cartarea\"></div>";
        $html.="    <div id=\"digibug-cartfoot\"><div class=\"digibug-right\"><a href=\"javascript:digibugCheckout();\">Checkout</a></div><div class=\"digibug-clear\"></div></div>";
        $html.="</div>";

        // Now that the cart has been build we will build the item view.
        $html.="    <div id=\"digibug-itemview\">";
        $html.="    <div id=\"digibug-itemhead\"><div class=\"digibug-left\">Gift Item Preview</div><div class=\"digibug-right\"><a href=\"javascript:digibugCloseViewDivs('digibug-itemview');\">Hide Gift Item Preview</a></div><div class=\"digibug-clear\"></div></div>";
        $html.="  </div>";
        $html.="</div>";

        return  $html;
    } // end: function digibugCartAndViewDivElements()

    function digibugCSSandJavascriptIncludes(){
        global $CONFIG;

        $html = '<link rel="stylesheet" href="'.$CONFIG['site_url'].'plugins/Digibug4CPG/includes/DigibugAPI.css" type="text/css" />'."\n";
        $html .= '<script language="javascript"> var digibugCustomerId='.$_SESSION['digibug']['companyId'].'; var digibugListId='.$_SESSION['digibug']['eventId'].'; digibugPostUrl="'.$_SESSION['digibug']['postUrl'].'"; digibugSiteUrl="'.$CONFIG['site_url'].'"; </script>';
        $html .= '<script src="'.$CONFIG['site_url'].'plugins/Digibug4CPG/includes/DigibugAPIControls.js" language="javascript"></script>';
        return $html;
    } // end: function digibugCartAndViewDivElements()

    function digibugViewAddRemoveButtons($thumb,$tWidth,$tHeight,$raw,$rWidth,$rHeight,$inCartStatus){
        $html='<div align="center"><div style="width: 20%;">'; 
        if(array_key_exists($raw,$_SESSION['digibug']['cart'])){
            $html.="<a class=\"digibugButtonAdd\" name=\"".$raw."\" href=\"#\" onclick=\"digibugProcessImageInCart('".$thumb."','".$tWidth."','".$tHeight."','".$raw."','".$rWidth."','".$rHeight."',this.firstChild.data); return false;\">- Cart</a>";
        }else{
            $html.="<a class=\"digibugButtonAdd\" name=\"".$raw."\" href=\"#\" onclick=\"digibugProcessImageInCart('".$thumb."','".$tWidth."','".$tHeight."','".$raw."','".$rWidth."','".$rHeight."',this.firstChild.data); return false;\">+ Cart</a>";
        }
 //       $html.="<a class=\"digibugButtonView\" href=\"#\" onclick=\"digibugOpenViewImageOnItem('".$thumb."'); return false;\">View On...</a>";
        $html.='<div class="clear"></div>';
        $html.='</div></div>'; 
        return $html;
    } // end: function digibugViewAddRemoveButtons($thumb,$tWidth,$tHeight,$raw,$rWidth,$rHeight)


?>
