<?php
/**
 * Avalanche for Magento 1.8+
 * Designed by Fast Division (http://fastdivision.com)
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file license.txt.
 * It is also available through the world-wide-web at this URL:
 * http://fastdivision.com/legal/license.txt
 *
 * @author     Fast Division
 * @version    1.5.0
 * @copyright  Copyright 2013 Fast Division
 * @license    http://fastdivision.com/legal/license.txt
 */
?>
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<?php $url = 'http' . ((!empty($_SERVER['HTTPS'])) ? 's' : '') . '://'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>

<?php if(Mage::getStoreConfig('avalanche_social/general/button_location') == 'social-media-box'): ?>
<div id="extended-features" class="white-box">
    <h3><?php echo $this->__('Share Product') ?></h3>
    <div class="white-box-inner">
<?php endif; ?>

<div id="social-media-buttons" class="<?php echo Mage::getStoreConfig('avalanche_social/general/button_location') ?> clearfix">
	<?php if(Mage::getStoreConfigFlag('avalanche_social/facebook/facebook_enabled')): ?>
        <?php
            if(Mage::getStoreConfig('avalanche_social/facebook/facebook_count') == 'button_count'):
                $facebookButtonWidth = '99px';
            else:
                $facebookButtonWidth = '48px';
            endif;
        ?>
    	<div id="facebook-like" style="width: <?php echo $facebookButtonWidth ?>">
            <?php
                if(Mage::getStoreConfig('avalanche_social/facebook/facebook_count') == 'standard'):
                    $facebookLayout = 'button_count';
                else:
                    $facebookLayout = Mage::getStoreConfig('avalanche_social/facebook/facebook_count');
                endif;
            ?>
            <div class="fb-like" data-send="false" data-layout="<?php echo $facebookLayout ?>" data-width="<?php echo $facebookButtonWidth ?>" data-show-faces="false" style="width: <?php echo $facebookButtonWidth ?>; overflow: hidden"></div>
            <script>
                window.fbAsyncInit = function() {
                    FB.XFBML.parse();
                };
            </script>
    	</div>
	<?php endif; ?>
    <?php if(Mage::getStoreConfigFlag('avalanche_social/twitter/twitter_enabled')): ?>
        <div id="twitter-tweet">
            <a href="https://twitter.com/share" class="twitter-share-button" data-via="<?php echo Mage::getStoreConfig('avalanche_social/twitter/twitter_username') ?>" data-count="<?php echo Mage::getStoreConfig('avalanche_social/twitter/twitter_count') ?>"<?php if(Mage::getStoreConfigFlag('avalanche_social/twitter/twitter_hashtag')): ?> data-hashtags="<?php echo Mage::getStoreConfigFlag('avalanche_social/twitter/twitter_hashtag') ?>"<?php endif; ?>>Tweet</a>
            <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
        </div>
    <?php endif; ?>
    <?php if(Mage::getStoreConfigFlag('avalanche_social/google/google_enabled')): ?>
        <div id="google-plusone">
            <div class="g-plusone" data-size="<?php echo Mage::getStoreConfig('avalanche_social/google/google_size') ?>"<?php if(!Mage::getStoreConfigFlag('avalanche_social/google/google_showcount')): ?> data-annotation="none"<?php endif; ?>></div>
            <script type="text/javascript">
              (function() {
                var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                po.src = 'https://apis.google.com/js/plusone.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
              })();
            </script>
        </div>
    <?php endif; ?>
    <?php if(Mage::getStoreConfigFlag('avalanche_social/pinterest/pinterest_enabled')): ?>
        <div id="pinterest-pin">
            <a href="http://pinterest.com/pin/create/button/?url=<?php echo $url ?>&amp;media=<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>&amp;description=<?php echo strip_tags($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description')) ?>" class="pin-it-button" count-layout="<?php echo Mage::getStoreConfig('avalanche_social/pinterest/pinterest_count') ?>">Pin It</a>
            <script type="text/javascript">
                (function() {
                    var s = document.createElement("script"); s.type = "text/javascript"; s.async = true;
                    s.src = "//assets.pinterest.com/js/pinit.js";
                    var x = document.getElementsByTagName("script")[0]; x.parentNode.insertBefore(s, x);
                })();
            </script>
        </div>
    <?php endif; ?>
</div>

<?php if(Mage::getStoreConfig('avalanche_social/general/button_location') == 'social-media-box'): ?>
    </div>
</div>
<?php endif; ?>