<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<div class="product-view" itemscope itemtype="http://schema.org/Product" itemid="#product_base">
<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>

<?php if (Mage::getStoreConfig('roltasettings/roltasettings_products/nextprevious_product')): ?>

    <?php // Previous and Next product links in product page
     
    $_product = $this->getProduct();
     
    if(!$_product->getCategoryIds())
    return; // Don't show Previous and Next if product is not in any category
     
    $cat_ids = $_product->getCategoryIds(); // get all categories where the product is located
    $cat = Mage::getModel('catalog/category')->load( $cat_ids[0] ); // load first category, you should enhance this, it works for me
     
    $order = Mage::getStoreConfig('catalog/frontend/default_sort_by');
    $direction = 'asc'; // asc or desc
     
    $category_products = $cat->getProductCollection()->addAttributeToSort($order, $direction);
    $category_products->addAttributeToFilter('status',1); // 1 or 2
    $category_products->addAttributeToFilter('visibility',4); // 1.2.3.4
     
    $cat_prod_ids = $category_products->getAllIds(); // get all products from the category
    $_product_id = $_product->getId();
     
    $_pos = array_search($_product_id, $cat_prod_ids); // get position of current product
    $_next_pos = $_pos+1;
    $_prev_pos = $_pos-1;
     
    // get the next product url
    if( isset($cat_prod_ids[$_next_pos]) ) {
    $_next_prod = Mage::getModel('catalog/product')->load( $cat_prod_ids[$_next_pos] );
    } else {
    $_next_prod = Mage::getModel('catalog/product')->load( reset($cat_prod_ids) );
    }
    // get the previous product url
    if( isset($cat_prod_ids[$_prev_pos]) ) {
    $_prev_prod = Mage::getModel('catalog/product')->load( $cat_prod_ids[$_prev_pos] );
    } else {
    $_prev_prod = Mage::getModel('catalog/product')->load( end($cat_prod_ids) );
    }

    ?>
         
<?php endif; ?>  <!-- Endif Next Previous Product -->
  <div class="product-next-prev">
      <?php if($_next_prod != NULL): ?>
         <a class="product-next" title="Next" href="<?php print $_next_prod->getProductUrl(); ?>"><span></span></a>
      <?php endif; ?>  
      <?php if($_prev_prod != NULL): ?>
         <a class="product-prev" title="Previous" href="<?php print $_prev_prod->getProductUrl(); ?>"><span></span></a>
      <?php endif; ?>    
  </div> <!--product-next-prev-->


  <div class="product-essential">

    <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
        <div class="no-display">
            <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
            <input type="hidden" name="related_product" id="related-products-field" value="" />
        </div>
       
          <div class="product-img-box">            
              <?php echo $this->getChildHtml('media') ?>           
          </div>

          <div class="product-shop">
             <div class="product-name">
               <h1 itemprop="name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
             </div>
             <?php if ($_product->getShortDescription()):?>
               <div class="short-description">                
                 <div class="std" itemprop="description"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
               </div>
             <?php endif;?> 

            <?php echo $this->getReviewsSummaryHtml($_product, false, true)?> 
  
            <?php echo $this->getChildHtml('alert_urls') ?>
            <?php echo $this->getChildHtml('product_type_data') ?>
            <?php echo $this->getTierPriceHtml() ?>
            <?php echo $this->getChildHtml('extrahint') ?>             
        
            <?php if (!$this->hasOptions()):?>                        
                    <?php if($_product->isSaleable()): ?>
                        <?php echo $this->getChildHtml('addtocart') ?>
                        <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>                           
                        <?php endif; ?>
                    <?php endif; ?>                
                <?php echo $this->getChildHtml('addto') ?>
                <?php echo $this->getChildHtml('extra_buttons') ?>              
            <?php elseif (!$_product->isSaleable()): ?>                
                    <?php echo $this->getChildHtml('addto') ?>                
            <?php endif; ?>
            
            <?php echo $this->getChildHtml('other');?>
        
            <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
            <?php endif;?>
                    
            <?php if ($_product->isSaleable() && $this->hasOptions()):?>
               <?php echo $this->getChildChildHtml('container2', '', true, true) ?>  
            <?php endif;?>

            <?php if (Mage::getStoreConfig('roltasettings/roltasettings_social/social_link')) { ?>
                <ul class="social-links">
                       <?php if (Mage::getStoreConfig('roltasettings/roltasettings_social/facebook_social_link')) {  ?>
          <li class="fb"><a  target="_blank" rel="nofollow" href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/facebook_social_link_path') ?>" title="<?php echo $this->__('Facebook');?>"></a></li>
        <?php } 
              if (Mage::getStoreConfig('roltasettings/roltasettings_social/twitter_social_link')) {
        ?>
  <li class="tw"><a target="_blank" rel="nofollow"  href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/twitter_social_link_path') ?>" title="<?php echo $this->__('Twitter');?>"></a></li>
        <?php } 
              if (Mage::getStoreConfig('roltasettings/roltasettings_social/googleplus_social_link')) {
        ?>
   <li class="googleplus"><a target="_blank" rel="nofollow" href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/googleplus_social_link_path') ?>" title="<?php echo $this->__('GooglePlus');?>"></a></li>
        <?php } 
              if (Mage::getStoreConfig('roltasettings/roltasettings_social/rss_social_link')) {
        ?>
  <li class="rss"><a target="_blank" rel="nofollow" href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/rss_social_link_path') ?>" title="<?php echo $this->__('RSS');?>"></a></li>
        <?php } 
              if (Mage::getStoreConfig('roltasettings/roltasettings_social/pinterest_social_link')) {
        ?>
  <li class="pintrest"><a target="_blank" rel="nofollow" href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/pinterest_social_link_path') ?>" title="<?php echo $this->__('PInterest');?>"></a></li>
        <?php } 
              if (Mage::getStoreConfig('roltasettings/roltasettings_social/linkedin_social_link')) {
        ?>
   <li class="linkedin"><a  target="_blank" rel="nofollow" href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/linkedin_social_link_path') ?>" title="<?php echo $this->__('Linkedin');?>"></a></li>
        <?php } 
              if (Mage::getStoreConfig('roltasettings/roltasettings_social/youtube_social_link')) {
        ?>
  <li class="youtube"><a target="_blank" rel="nofollow" href="<?php echo Mage::getStoreConfig('roltasettings/roltasettings_social/youtube_social_link_path') ?>" title="<?php echo $this->__('Youtube');?>"></a></li>
        <?php } ?>
                </ul>
            <?php } ?>

       </div> <!--product-rolta-->       
</form>
</div> <!--product-essential-->

    <script type="text/javascript">
    //<![CDATA[
        var productAddToCartForm = new VarienForm('product_addtocart_form');
        productAddToCartForm.submit = function(button, url) {
            if (this.validator.validate()) {
                var form = this.form;
                var oldUrl = form.action;

                if (url) {
                   form.action = url;
                }
                var e = null;
                try {
                    this.form.submit();
                } catch (e) {
                }
                this.form.action = oldUrl;
                if (e) {
                    throw e;
                }

                if (button && button != 'undefined') {
                    button.disabled = true;
                }
            }
        }.bind(productAddToCartForm);

        productAddToCartForm.submitLight = function(button, url){
            if(this.validator) {
                var nv = Validation.methods;
                delete Validation.methods['required-entry'];
                delete Validation.methods['validate-one-required'];
                delete Validation.methods['validate-one-required-by-name'];
                // Remove custom datetime validators
                for (var methodName in Validation.methods) {
                    if (methodName.match(/^validate-datetime-.*/i)) {
                        delete Validation.methods[methodName];
                    }
                }

                if (this.validator.validate()) {
                    if (url) {
                        this.form.action = url;
                    }
                    this.form.submit();
                }
                Object.extend(Validation.methods, nv);
            }
        }.bind(productAddToCartForm);
    //]]>
    </script>

<div class="product-collateral">
        <!-- ADDITIONAL -->
          <?php echo $this->getChildHtml('product_additional_data') ?>
        <!-- ADDITIONAL -->
</div> <!--product-collateral-->
</div> <!--product-view-->
