<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<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>
<div class="product-view">
<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_1" value="" />
</div>
<!--Prev/Next Code Start-->
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$prev_url = $next_url = $url = $_product->getProductUrl();
if ($this->helper('catalog/data')->getCategory()) {
$category = $this->helper('catalog/data')->getCategory();
} else {
$_ccats = $this->helper('catalog/data')->getProduct()->getCategoryIds();
$category = Mage::getModel('catalog/category')->load($_ccats[0]);
}
$children = $category->getProductCollection();
$_count = is_array($children) ? count($children) : $children->count();
if ($_count) {
foreach ($children as $product) {
$plist[] = $product->getId();
}
/**
* Determine the previous/next link and link to current category
*/
$current_pid = $this->helper('catalog/data')->getProduct()->getId();
$curpos = array_search($current_pid, $plist);
// get link for prev product
$previd = isset($plist[$curpos+1])? $plist[$curpos+1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($previd);
$prevpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$prevpos += 1;
$nextid = isset($plist[$prevpos])? $plist[$prevpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$prev_url = $product->getProductUrl();
// get link for next product
$nextid = isset($plist[$curpos-1])? $plist[$curpos-1] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
$nextpos = $curpos;
while (!$product->isVisibleInCatalog()) {
$nextpos -= 1;
$nextid = isset($plist[$nextpos])? $plist[$nextpos] : $current_pid;
$product = Mage::getModel('catalog/product')->load($nextid);
}
$next_url = $product->getProductUrl();
}
?>
<!--Prev/Next Code End-->
<div class="upsell_pro"> <?php echo $this->getChildHtml('upsell_products') ?>
</div>
<div class="product-shop">
<div class="f-fix mb-10">
<?php if ($url <> $next_url):?>
<a class="prod-prev" href="<?php echo $next_url; ?>">пред.</a>
<?php endif; ?>
<?php if ($url <> $prev_url):?>
<a class="prod-next" href="<?php echo $prev_url; ?>">след.</a>
<?php endif; ?>
</div>
<div class="product-name">
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
<!--<div class="sku">Sku: <?php //echo $this->htmlEscape($_product->getSku()) ?></div>-->
</div>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<div class="pro-left">
<div class="product-collateral"> <?php echo $this->getChildHtml('info_tabs') ?> </div>
</div>
</div>
<div class="product-img-box"> <?php echo $this->getChildHtml('media') ?> </div>
<div class="clearer"></div>
</form>
</div>
</div>
<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;
// Start of our new ajax code
if (!url) {
url = jQuery('#product_addtocart_form').attr('action');
}
url = url.replace("checkout/cart","ajax/index"); // New Code
var data = jQuery('#product_addtocart_form').serialize();
data += '&isAjax=1';
jQuery('#ajax_loader').show();
try {
jQuery.ajax( {
url : url,
dataType : 'json',
type : 'post',
data : data,
success : function(data) {
jQuery('#ajax_loader').hide();
if(data.status == 'ERROR'){
alert(data.message);
}else{
if(jQuery('.block-cart')){
jQuery('.block-cart').replaceWith(data.sidebar);
}
if(jQuery('.header .links')){
jQuery('.header .links').replaceWith(data.toplink);
}
}
}
});
} catch (e) {
}
// End of our new ajax code
this.form.action = oldUrl;
if (e) {
throw e;
}
}
}.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'];
if (this.validator.validate()) {
if (url) {
this.form.action = url;
}
this.form.submit();
}
Object.extend(Validation.methods, nv);
}
}.bind(productAddToCartForm);
//]]>
</script>