<?php
//This code is copyright (c) ViciSoft SL, all rights reserved.
//The contents of this file are protected under law as the intellectual property 
//of ViciSoft SL. Any use, reproduction, disclosure or copying of any kind 
//without the express and written permission of ViciSoft SL is forbidden.
//Author: Vince Reid, vincereid@gmail.com
if(!@$GLOBALS['incfunctionsdefined']){print 'No incfunctions.php file';exit;}
global $productindb,$reviewsshown,$topsectionids,$catid,$alldiscounts,$prodid,$prodlist,$longdesc,$defimagejs,$explicitid,$tslist,$countryTaxRate,$thetax,$optionshtml,$prodoptions,$optjs,$allimages,$allgiantimages,$numallimages,
		$numallgiantimages,$psmallimage,$extraimages,$Count,$isinstock,$isbackorder,$atcmu,$rs,$usedetailbodyformat,$seocategoryurls,$seourlsthrow301,$seocaturlpattern,$seoprodurlpattern,$thesessionid,$detlinkspacechar,$usecsslayout,
		$detailpagelayout,$articlepagelayout,$dateformatstr,$imgcheckoutbutton,$numcustomerratings,$wishlistondetail,$usepnamefordetaillinks,$redirecttostatic,$WSP,$OWSP,$TWSP,$previousid,$nextid,
		$sSQL1,$sSQL2,$disabledsection,$newqs,$optionshavestock,$previousidname,$previousidstatic,$previousstaticurl,$previousidcat,$nextidname,$nextidstatic,$nextstaticurl,$nextidcat,$thecatid;
if(trim_(@$explicitid)!='') $prodid=trim_($explicitid); else $prodid=str_replace(@$detlinkspacechar,' ',getget('prod'));
if(@$GLOBALS['iswordpress'] && get_query_var( 'ectprod' ) != '') $prodid=str_replace(@$detlinkspacechar,' ',urldecode(get_query_var('ectprod')));
if(@$GLOBALS['autoencodeslashes']) $prodid=strreplace(array('&#47;','&#92;'),array('/','\\'),$prodid);
$GLOBALS['catname']=$analyticsoutput=$WSP=$OWSP=$tslist=$thecatid=$optionshtml=$previousid=$nextid='';
$TWSP='pPrice';
if(@$dateformatstr=='')$dateformatstr='m/d/Y';
if(@$GLOBALS['skuschemaidentifier']=='')$GLOBALS['skuschemaidentifier']='sku';
get_wholesaleprice_sql();
$Count=0;
$hasmultipurchase=FALSE;
$isarticle=FALSE;
$GLOBALS['hascustomlayout']=FALSE;
if(@$detailpagelayout=='' || ! @$usecsslayout) $detailpagelayout='productimage,productid,manufacturer,sku,productname,discounts,instock,description,listprice,price,currency,options,addtocart,previousnext,emailfriend'.(@$GLOBALS['showsearchwords']?',searchwords':''); else $GLOBALS['hascustomlayout']=TRUE;
$customlayoutarray=explode(',',$detailpagelayout);
if(@$GLOBALS['socialmediabuttons']==''){
	if($GLOBALS['hascustomlayout']&&strpos(@$GLOBALS['detailpagelayout'],'socialmedia')!==FALSE)
		$GLOBALS['socialmediabuttons']='facebook,linkedin,twitter,askaquestion';
	elseif(@$GLOBALS['useemailfriend'] || @$GLOBALS['useaskaquestion'])
		$GLOBALS['socialmediabuttons']=(@$GLOBALS['useemailfriend']?'emailfriend':'').(@$GLOBALS['useaskaquestion']?(@$GLOBALS['useemailfriend']?',':'').'askaquestion':'');
}
if(strpos($detailpagelayout,'review')!==FALSE) $enablecustomerratings=TRUE;
if(strpos($detailpagelayout,'quantity')!==FALSE||strpos($detailpagelayout,'addtocartquant')!==FALSE) $GLOBALS['showquantondetail']=TRUE;
$nopreviousnextlinks=strpos($detailpagelayout,'previousnext')===FALSE;
$emailfriendoraskquestion=strpos(@$GLOBALS['socialmediabuttons'],'emailfriend')!==FALSE || strpos(@$GLOBALS['socialmediabuttons'],'askaquestion')!==FALSE;
if(@$numcustomerratings=='') $numcustomerratings=6;
$reviewsshown=FALSE;
if(@$GLOBALS['wishlistonproducts']) $wishlistondetail=TRUE;
if(@$_SESSION['clientID']=='' || @$GLOBALS['enablewishlists']==FALSE || @$wishlistondetail=='') $wishlistondetail=FALSE;
if(@$_SESSION['clientID']!='' && @$_SESSION['clientLoginLevel']!='') $minloglevel=$_SESSION['clientLoginLevel']; else $minloglevel=0;
if(@$GLOBALS['seodetailurls'])$GLOBALS['usepnamefordetaillinks']=TRUE;
if(@$GLOBALS['bmlbannerdetails']!='' && @$GLOBALS['paypalpublisherid']!='') displaybmlbanner($GLOBALS['paypalpublisherid'],$GLOBALS['bmlbannerdetails']);
$GLOBALS['noschemamarkup']=@$GLOBALS['noschemamarkup']==TRUE;
function displaytabs($thedesc){
	global $ecttabs,$ecttabsspecials,$reviewsshown,$prodid,$languageid,$relatedtabtemplate,$shortdescriptionlimit,$nostripshortdescription,$defaultdescriptiontab,$thetax,$ratingslanguages,$WSP,$usepnamefordetaillinks,$detlinkspacechar,$nocatid,$sSortBy,$isdesc;
	$hasdesctab=(strpos($thedesc, '<ecttab')!==FALSE);
	$hasdesschema=TRUE;
	if(@$ecttabsspecials=='')$ecttabsspecials='';
	if($hasdesctab || @$ecttabsspecials!='' || @$ecttabs!='' || @$defaultdescriptiontab!=''){
		if(@$defaultdescriptiontab=='')
			$defaultdescriptiontab='<ecttab title="'.$GLOBALS['xxDescr'].'" special="ectdescription">';
		elseif(strpos($defaultdescriptiontab,' special="ectdescription"')===FALSE)
			$defaultdescriptiontab=preg_replace('/>/',' special="ectdescription">',$defaultdescriptiontab,1);
		if(! $hasdesctab && $thedesc!='')
			$thedesc=$defaultdescriptiontab . $thedesc;
		elseif(strpos($thedesc,' itemprop="description"')===FALSE&&!$GLOBALS['noschemamarkup'])
			$hasdesschema=FALSE;
		if(strpos(@$ecttabsspecials, '%tabs%')!==FALSE) $thedesc=str_replace('%tabs%', $thedesc, $ecttabsspecials); else $thedesc.=@$ecttabsspecials;
		if($ecttabs=='slidingpanel'){
			$displaytabs='<div class="slidingTabPanelWrapper"><ul class="slidingTabPanel">';
			$tabcontent='<div id="slidingPanel"><div'.($hasdesschema?'':' itemprop="description"').'>';
		}else{
			$displaytabs='<div class="TabbedPanels" id="TabbedPanels1"><ul class="TabbedPanelsTabGroup">';
			$tabcontent='<div class="TabbedPanelsContentGroup"'.($hasdesschema?'':' itemprop="description"').'>';
		}
		$dind=strpos($thedesc, '<ecttab');
		$tabindex=1;
		while($dind!==FALSE){
			$dind+=8;
			$dind2=strpos($thedesc, '>', $dind);
			if($dind2!==FALSE){
				$dclass=$did=$dtitle=$dimage=$dimageov=$dspecial='';
				$tproperties=substr($thedesc,$dind,$dind2-$dind);
				$pind=strpos($tproperties, 'title=');
				if($pind!==FALSE){
					$pind=strpos($tproperties, '"', $pind)+1;
					$pind2=strpos($tproperties, '"', $pind+1);
					$dtitle=substr($tproperties,$pind,$pind2-$pind);
				}
				$pind=strpos($tproperties, 'img=');
				if($pind!==FALSE){
					$pind=strpos($tproperties, '"', $pind)+1;
					$pind2=strpos($tproperties, '"', $pind+1);
					$dimage=substr($tproperties,$pind,$pind2-$pind);
				}
				$pind=strpos($tproperties, 'imgov=');
				if($pind!==FALSE){
					$pind=strpos($tproperties, '"', $pind)+1;
					$pind2=strpos($tproperties, '"', $pind+1);
					$dimageov=substr($tproperties,$pind,$pind2-$pind);
				}
				$pind=strpos($tproperties, 'special=');
				if($pind!==FALSE){
					$pind=strpos($tproperties, '"', $pind)+1;
					$pind2=strpos($tproperties, '"', $pind+1);
					$dspecial=substr($tproperties,$pind,$pind2-$pind);
				}
				$pind=strpos($tproperties, 'id=');
				if($pind!==FALSE){
					$pind=strpos($tproperties, '"', $pind)+1;
					$pind2=strpos($tproperties, '"', $pind+1);
					$did=substr($tproperties,$pind,$pind2-$pind);
				}
				$pind=strpos($tproperties, 'class=');
				if($pind!==FALSE){
					$pind=strpos($tproperties, '"', $pind)+1;
					$pind2=strpos($tproperties, '"', $pind+1);
					$dclass=substr($tproperties,$pind,$pind2-$pind);
				}
				$dind2++;
				$dind=strpos($thedesc, '<ecttab', $dind2);
				if($dind===FALSE) $dcontent=substr($thedesc,$dind2); else $dcontent=substr($thedesc,$dind2,$dind-$dind2);
				$hascontent=TRUE;
				$isdescriptiontab=FALSE;
				if($dspecial=='reviews'){
					if(@$GLOBALS['enablecustomerratings']){
						$sSQL="SELECT rtID,rtRating,rtPosterName,rtHeader,rtDate,rtComments FROM ratings WHERE " . $GLOBALS['reviewsearchsql'];
						if(@$ratingslanguages!='') $sSQL.=' AND rtLanguage+1 IN ('.$ratingslanguages.')'; elseif(@$languageid!='') $sSQL.=' AND rtLanguage='.((int)$languageid-1); else $sSQL.=' AND rtLanguage=0';
						$sSQL.=' ORDER BY rtDate DESC,rtRating DESC';
						$dcontent='<div class="reviewtab">' . showreviews($sSQL,FALSE) . '</div>';
						$reviewsshown=TRUE;
					}else
						$hascontent=FALSE;
				}elseif($dspecial=='quantitypricing'){
					$quantpri=pddquantitypricing();
					if($quantpri!='') $dcontent.=$quantpri; else $hascontent=FALSE;
				}elseif($dspecial=='related'){
					$dcontent='<div class="reltab">';
					if(@$relatedtabtemplate==''){
						$relatedtabtemplate='<div class="reltabproduct"><div class="reltabimage">%img%</div><div class="reltabname">%name%' . ($GLOBALS['noprice']?'':' - %price%') . '</div>' .
							'<div class="reltabdescription">%description%</div></div>';
					}
					$sSQL='SELECT pId,pSKU,pSection,'.getlangid('pName',1).','.$WSP.'pPrice,pStaticPage,'.getaltlang('pStaticURL',8388608).',pDateAdded,pExemptions,pOrder,'.getlangid('pDescription',2).' FROM products INNER JOIN relatedprods ON products.pId=relatedprods.rpRelProdID WHERE ' . (@$GLOBALS['ectsiteid']!='' ? 'pSiteID='.$GLOBALS['ectsiteid'].' AND ' : '') . "pDisplay<>0 AND rpProdID='".$prodid."'";
					if(@$GLOBALS['relatedproductsbothways']) $sSQL.=' UNION SELECT pId,pSKU,pSection,'.getlangid('pName',1).','.$WSP.'pPrice,pStaticPage,'.getaltlang('pStaticURL',8388608).',pDateAdded,pExemptions,pOrder,'.getlangid('pDescription',2).' FROM products INNER JOIN relatedprods ON products.pId=relatedprods.rpProdID WHERE ' . (@$GLOBALS['ectsiteid']!='' ? 'pSiteID='.$GLOBALS['ectsiteid'].' AND ' : '') . "pDisplay<>0 AND rpRelProdID='".$prodid."'";
					if(@$sSortBy!='') $sSQL.=' ORDER BY ' . $sSortBy . (@$isdesc?' DESC':'');
					$result=ect_query($sSQL) or ect_error();
					if(ect_num_rows($result)==0)
						$hascontent=FALSE;
					else{
						while($rs2=ect_fetch_assoc($result)){
							$rpsmallimage=''; $rplargeimage='';
							$sSQL="SELECT imageSrc,imageType FROM productimages WHERE imageProduct='" . $rs2['pId'] . "' AND (imageType=0 OR imageType=1) AND imageNumber=0";
							$result3=ect_query($sSQL) or ect_error();
							while($rs3=ect_fetch_assoc($result3)){
								if($rs3['imageType']==0) $rpsmallimage=$rs3['imageSrc']; else $rplargeimage=$rs3['imageSrc'];
							}
							ect_free_result($result3);
							$thedetailslink=getdetailsurl($rs2['pId'],$rs2['pStaticPage'],$rs2[getlangid('pName',1)],$rs2['pStaticURL'],(@$catid!='' && @$catid!='0' && $catid!=$rs2['pSection'] && @$nocatid!=TRUE ? '?cat=' . $catid : ''),@$GLOBALS['pathtohere']);
							if(@$detailslink!=''){
								$startlink=str_replace('%pid%', $rs2['pId'], str_replace('%largeimage%', $rplargeimage, $detailslink));
								$endlink=@$detailsendlink;
							}else{
								$startlink='<a class="ectlink" href="'. htmlspecials($thedetailslink) .'">';
								$endlink='</a>';
							}
							$rtc=str_replace('%img%', ($rpsmallimage!='' ? $startlink . '<img class="reltabimage" src="' . $rpsmallimage . '" style="border:0" alt="'.htmlspecials(strip_tags($rs2[getlangid('pName',1)])).'">' . $endlink : '&nbsp;'), $relatedtabtemplate);
							$rtc=str_replace('%name%', $startlink . $rs2[getlangid('pName',1)] . $endlink, $rtc);
							$rtc=str_replace('%id%', $startlink . $rs2['pId'] . $endlink, $rtc);
							$rtc=str_replace('%price%', ($rs2['pPrice']==0 && @$pricezeromessage!='' ? $pricezeromessage : FormatEuroCurrency(@$GLOBALS['showtaxinclusive']===2 && ($rs2['pExemptions'] & 2)!=2 ? $rs2['pPrice']+($rs2['pPrice']*$thetax/100.0) : $rs2['pPrice'])), $rtc);
							$shortdesc=$rs2[getlangid('pDescription',2)];
							if(@$shortdescriptionlimit!=''){ if(@$nostripshortdescription!=TRUE)$shortdesc=strip_tags($shortdesc); $shortdesc=substr($shortdesc, 0, $shortdescriptionlimit) . (strlen($shortdesc)>$shortdescriptionlimit && $shortdescriptionlimit!=0 ? '...' : ''); }
							$rtc=str_replace('%description%', $shortdesc, $rtc);
							$dcontent.=$rtc;
						}
					}
					ect_free_result($result);
					$dcontent.='</div>';
				}elseif($dspecial=='ectdescription')
					$isdescriptiontab=TRUE;
				if($hascontent){
					if(@$ecttabs=='slidingpanel')
						$displaytabs.='<li><a href="#" id="ecttab'.$tabindex.'" class="tab'.($tabindex==1?'Active':'').'" title="'.$dtitle.'">';
					else
						$displaytabs.='<li class="' . trim_($dclass.' TabbedPanelsTab') . '" tabindex="0"' . ($did!=''?' id="'.$did.'"':'') . '>';
					if($dimage!=''){
						$displaytabs.='<img src="'.$dimage.'" alt="'.htmlspecials($dtitle).'"';
						if($dimageov!='') $displaytabs.=' onmouseover="this.src=\''.$dimageov.'\'" onmouseout="this.src=\''.$dimage.'\'"';
						$displaytabs.='>';
					}else
						$displaytabs.=str_replace(' ','&nbsp;',$dtitle);
					if(@$ecttabs=='slidingpanel'){
						$displaytabs.='</a></li>';
						$tabcontent.='<div id="ecttab'.$tabindex.'Panel" class="tabpanelcontent"'.($isdescriptiontab&&!$GLOBALS['noschemamarkup']?' itemprop="description"':'').'>'.$dcontent.'</div>';
					}else{
						$displaytabs.='</li>';
						$tabcontent.='<div class="tabpanelcontent"'.($isdescriptiontab&&!$GLOBALS['noschemamarkup']?' itemprop="description"':'').'>'.$dcontent.'</div>';
					}
				}
				$tabindex++;
			}
		}
		if(@$ecttabs=='slidingpanel'){
			$displaytabs.='</ul></div>'.$tabcontent.'</div></div>';
			$displaytabs.='<script>var sp2;var quotes;var lastTab="ecttab1";';
			$displaytabs.='function switchTab(tab){if(tab!=lastTab){document.getElementById(tab).className=("tabActive");document.getElementById(lastTab).className=("tab");sp2.showPanel(tab+"Panel");lastTab=tab;}}';
			$displaytabs.='Spry.Utils.addLoadListener(function(){';
			$displaytabs.="	Spry.$$('.slidingTabPanelWrapper').setStyle('display: block');";
			$displaytabs.="	Spry.$$('#ecttab1";
			for($i=2;$i<=$tabindex-1;$i++){
				$displaytabs.=',#ecttab'.$i;
			}
			$displaytabs.="').addEventListener('click', function(){ switchTab(this.id); return false; }, false);";
			$displaytabs.="	Spry.$$('#slidingPanel').addClassName('SlidingPanels').setAttribute('tabindex', '0');";
			$displaytabs.="	Spry.$$('#slidingPanel > div').addClassName('SlidingPanelsContentGroup');";
			$displaytabs.="	Spry.$$('#slidingPanel .SlidingPanelsContentGroup > div').addClassName('SlidingPanelsContent');";
			$displaytabs.="	sp2=new Spry.Widget.SlidingPanels('slidingPanel');";
			$displaytabs.='});</script>';
		}else{
			$displaytabs.='</ul>'.$tabcontent.'</div></div>';
			$displaytabs.='<script>var TabbedPanels1=new Spry.Widget.TabbedPanels("TabbedPanels1");</script>';
		}
		return('>' . $displaytabs);
	}else
		return(($GLOBALS['noschemamarkup']?'':' itemprop="description"') . '>' . $thedesc);
}
if(@$GLOBALS['magictoolbox']!=''){ $GLOBALS['magictoolboxjs']=$GLOBALS['magictoolbox']; $GLOBALS['magictoolbox']=str_replace('MagicZoomPlus','MagicZoom',$GLOBALS['magictoolbox']); $GLOBALS['magictool']=$GLOBALS['magictoolbox']; $GLOBALS['giantimageinpopup']=FALSE; }
function showdetailimages(){
	global $Count,$rs,$extraimages,$magictoolbox,$magictooloptionsjs,$magictooloptions,$magictoolthumbnailoptions,$magic360images,$allimages,$allgiantimages,$numallimages,$numallgiantimages,$psmallimage,$thumbnailstyle,$usecsslayout,$magicscrollthumbnails,$magicscrollthumbnailsjs;
	if(@$thumbnailstyle=='') $thumbnailstyle='width:75px;padding:3px';
	if($numallimages>0){
		if(@$magictoolbox!='' && ($numallgiantimages>0 || strtolower($magictoolbox)=='magic360')){
			print '<script src="' . strtolower($GLOBALS['magictoolboxjs']) . '/' . strtolower($GLOBALS['magictoolboxjs']) . '.js"></script>' . @$magictooloptionsjs;
			if(@$magicscrollthumbnails) print '<script src="magicscroll/magicscroll.js"></script>' . @$magicscrollthumbnailsjs;
			if($magictoolbox=='MagicSlideshow' || $magictoolbox=='MagicScroll'){
				print '<div class="' . $magictoolbox . '" ' . @$magictooloptions . '>';
				for($index=0;$index<$numallimages;$index++){
					if($index<$numallgiantimages) $giantimage=$allgiantimages[$index]['imageSrc']; else $giantimage='';
					print '<img ' . ($GLOBALS['noschemamarkup']?'':'itemprop="url" ') . 'src="' . $allimages[$index]['imageSrc'] . '" alt=""'.($giantimage!=''&&$magictoolbox=='MagicSlideshow'?' data-fullscreen-image="'.$giantimage.'"':'').'>';
				}
				print '</div>';
			}elseif(strtolower($magictoolbox)=='magic360'){
				$magictoolbox=replace($magictoolbox,'magic360','Magic360');
				if(@$magic360images=='') $magic360images=18;
				if(($thepos=strrpos($allimages[0]['imageSrc'],'01'))!==FALSE)
					$imgpattern=substr_replace($allimages[0]['imageSrc'],'{col}',$thepos,2);
				if(strpos($imgpattern,'/')!==FALSE) $imgpattern=substr($imgpattern,strrpos($imgpattern,'/')+1);
				if($numallgiantimages>0) $giantimage=$allgiantimages[0]['imageSrc']; else $giantimage='#';
				print '<a href="'.$giantimage.'" class="'.$magictoolbox.'" data-magic360-options="columns:'.$magic360images.';filename:'.$imgpattern.';"><img ' . ($GLOBALS['noschemamarkup']?'':'itemprop="url" ') . 'src="'.$allimages[0]['imageSrc'].'" alt=""></a>';
			}elseif($magictoolbox=='MagicZoom' || $magictoolbox=='MagicZoomPlus' || $magictoolbox=='MagicThumb'){
				if($numallimages>1 && ! @$usecsslayout) print '<table class="detailimage allprodimages" border="0" cellspacing="1" cellpadding="1"><tr><td class="mainimage">';
				if($magictoolbox=='MagicThumb') $magictooloptions=strreplace('data-options=','rel=',@$magictooloptions); else $magictooloptions=strreplace('rel=','data-options=',@$magictooloptions);
				print '<a href="' . $allgiantimages[0]['imageSrc'] . '" class="' . $magictoolbox . '" ' . @$magictooloptions . ' id="zoom1"><img ' . ($GLOBALS['noschemamarkup']?'':'itemprop="url" ') . 'id="prodimage'.$Count.'" class="detailimage allprodimages" src="' . $allimages[0]['imageSrc'] . '" alt="' . htmlspecials(strip_tags($rs[getlangid('pName',1)])) . '"></a>';
				if($magictoolbox=='MagicThumb') $relid=' rel="thumb-id:zoom1"'; else $relid='';
				if($magictoolbox=='MagicZoom' || $magictoolbox=='MagicZoomPlus') $relid=' data-zoom-id="zoom1"';
				if($numallimages>1){
					if(@$usecsslayout) print '<div class="thumbnailimage detailthumbnailimage">'; else print '</td></tr><tr><td class="thumbnailimage detailthumbnailimage" align="center">';
					if(@$magicscrollthumbnails) print '<div class="MagicScroll" ' . @$magicscrollthumbnailoptions . '>';
					for($index=0;$index<$numallimages;$index++){
						if($index<$numallgiantimages) print '<a href="' . $allgiantimages[$index]['imageSrc'] . '" rev="' . $allimages[$index]['imageSrc'] . '"' . $relid . '><img src="' . $allimages[$index]['imageSrc'] . '" style="' . $thumbnailstyle . '" alt="' . htmlspecials(strip_tags($rs[getlangid('pName',1)])) . ' #' . ($index+1) . '"></a>';
					}
					if(@$magicscrollthumbnails) print '</div>';
					if(@$usecsslayout) print '</div>'; else print '</td></tr></table>';
				}
			}else
				print 'Magic Toolbox Option Not Recognized : ' . $magictoolbox . '<br>';
		}else{
			$imgextension=strtolower(pathinfo($allimages[0]['imageSrc'],PATHINFO_EXTENSION));
			$isvideo=($imgextension=='mp4');
			if(($numallimages>1 || $numallgiantimages>0) && ! @$usecsslayout) print '<table class="detailimage allprodimages" border="0" cellspacing="1" cellpadding="1"><tr><td class="mainimage">';
			print '<' . ($isvideo?'video controls ':'img ') . ($GLOBALS['noschemamarkup']?'':'itemprop="url" ') . 'id="prodimage'.$Count.'" class="detailimage allprodimages" src="' . $allimages[0]['imageSrc'] . '" alt="'.htmlspecials(strip_tags($rs[getlangid('pName',1)])).'">' . ($isvideo?'</video>':'');
			$showimagelink=($numallgiantimages>0 ? '<span class="extraimage extraimgnumof"><a class="ectlink" href="javascript:showgiantimage()">'.$GLOBALS['xxEnlrge'].'</a></span>' : '');
			if($numallimages>1 || $numallgiantimages>0) print (@$usecsslayout ? '<div class="imagenavigator detailimagenavigator">' : '</td></tr><tr><td class="imagenavigator detailimagenavigator" align="center">') . ($numallimages>1 ? imageorbutton(@$GLOBALS['imgdetailprevimg'],@$GLOBALS['xxPrImTx'],'detailprevimg','updateprodimage('.$Count.',false)',TRUE) : '&nbsp;').' '.($numallimages>1 ? '<span class="extraimage extraimagenum" id="extraimcnt'.$Count.'">1</span> <span class="extraimage">'.$GLOBALS['xxOf'].' '.$extraimages.'</span> ' : ''). $showimagelink . ' '.($numallimages>1 ? imageorbutton(@$GLOBALS['imgdetailnextimg'],@$GLOBALS['xxNeImTx'],'detailnextimg','updateprodimage('.$Count.',true)',TRUE) : '&nbsp;') . (@$usecsslayout ? '</div>' : '</td></tr></table>');
		}
	}elseif($psmallimage!='')
		print '<img ' . ($GLOBALS['noschemamarkup']?'':'itemprop="url" ') . 'id="prodimage'.$Count.'" class="detailimage allprodimages" src="' . $psmallimage . '" alt="'.htmlspecials(strip_tags($rs[getlangid('pName',1)])).'">';
	elseif(@$GLOBALS['defaultproductimage']!=''||@$GLOBALS['defaultdetailimage']!='')
		print '<img ' . ($GLOBALS['noschemamarkup']?'':'itemprop="url" ') . 'id="prodimage'.$Count.'" class="detailimage allprodimages" src="' . (@$GLOBALS['defaultdetailimage']!=''?@$GLOBALS['defaultdetailimage']:@$GLOBALS['defaultproductimage']) . '" alt="'.htmlspecials(strip_tags($rs[getlangid('pName',1)])).'">';
	else
		print '&nbsp;';
}
function writepreviousnextlinks(){
	global $previousid,$previousidname,$previousidstatic,$previousstaticurl,$previousidcat,$nextid,$nextidname,$nextidstatic,$nextstaticurl,$nextidcat,$thecatid,$catid,$nocatid;
	$currcat=(int)($thecatid!='' ? $thecatid : $catid);
	if($previousid!='') print '<a class="ectlink" href="' . getdetailsurl($previousid,$previousidstatic,$previousidname,$previousstaticurl,($previousidcat!=$currcat && @$nocatid!=TRUE?'cat='.$currcat:''),@$GLOBALS['pathtohere']).'">';
	print '<strong>&laquo; ' . $GLOBALS['xxPrev'] . '</strong>';
	if($previousid!='') print '</a>';
	print ' | ';
	if($nextid!='') print '<a class="ectlink" href="' . getdetailsurl($nextid,$nextidstatic,$nextidname,$nextstaticurl,($nextidcat!=$currcat && @$nocatid!=TRUE?'cat='.$currcat:''),@$GLOBALS['pathtohere']).'">';
	print '<strong>' . $GLOBALS['xxNext'] . ' &raquo;</strong>';
	if($nextid!='') print '</a>';
}
function detailpageurl($params){
	global $hasstaticpage,$rs,$prodid;
	$detailpageurl='';
	if($prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid'])
		$detailpageurl=getdetailsurl($prodid,$hasstaticpage,$rs[getlangid('pName',1)],$rs['pStaticURL'],$params,@$GLOBALS['pathtohere']);
	return($detailpageurl);
}
function showreviews($theSQL,$showall){
	global $prodid,$thecatid,$numcustomerratings,$customerratinglength,$onlyclientratings,$allreviewspagesize,$languageid,$dateformatstr,$rs,$catid,$ratingslanguages,$usecsslayout,$isarticle;
	$savenoschemamarkup=$GLOBALS['noschemamarkup'];
	if($isarticle) $GLOBALS['noschemamarkup']=TRUE;
	$srv='';
	$numreviews=0; $totrating=0;
	$totSQL="SELECT COUNT(*) as numreviews, SUM(rtRating) AS totrating FROM ratings WHERE " . $GLOBALS['reviewsearchsql'];
	// if(@$ratingslanguages!='') $totSQL.=' AND rtLanguage+1 IN ('.$ratingslanguages.')'; elseif(@$languageid!='') $totSQL.=' AND rtLanguage='.((int)$languageid-1); else $totSQL.=' AND rtLanguage=0';
	$result=ect_query($totSQL) or ect_error();
	$rs2=ect_fetch_assoc($result);
	if(! is_null($rs2['numreviews'])){
		$numreviews=$rs2['numreviews'];
		$totrating=$rs2['totrating'];
	}
	ect_free_result($result);
	$srv=(@$usecsslayout ? '<div' : '<tr><td') . ' class="reviews" id="reviews">';
	$srv.='<div class="reviewtotals"><span class="numreviews"' . ($numreviews<>0&&!$GLOBALS['noschemamarkup'] ? ' itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"' : '') . '>' . ($numreviews<>0 ? '<span class="count"' . ($GLOBALS['noschemamarkup']?'':' itemprop="reviewCount"') . '>' . $numreviews . '</span> ' : '') . $GLOBALS['xxRvPrRe'];
	if($numreviews > 0)
		$srv.=' - '.$GLOBALS['xxRvAvRa'].' <span class="rating average" ' . ($GLOBALS['noschemamarkup']?'':' itemprop="ratingValue"') . '>'.round(($totrating/$numreviews)/2,1).'</span> / 5';
	$srv.='</span><span class="showallreview">';
	if($showall){
		$srv.=' (<a class="ectlink readreview" rel="nofollow" href="' . detailpageurl('review=all' . ($thecatid!='' ? '&amp;cat='.$thecatid : '').'&amp;ro=1') . '">'.$GLOBALS['xxRvBest'].'</a>';
		$srv.=' | <a class="ectlink readreview" rel="nofollow" href="' . detailpageurl('review=all' . ($thecatid!='' ? '&amp;cat='.$thecatid : '').'&amp;ro=2') . '">'.$GLOBALS['xxRvWors'].'</a>';
		$srv.=' | <a class="ectlink readreview" rel="nofollow" href="' . detailpageurl('review=all' . ($thecatid!='' ? '&amp;cat='.$thecatid : '')) . '">'.$GLOBALS['xxRvRece'].'</a>';
		$srv.=' | <a class="ectlink readreview" rel="nofollow" href="' . detailpageurl('review=all' . ($thecatid!='' ? '&amp;cat='.$thecatid : '').'&amp;ro=3') . '">'.$GLOBALS['xxRvOld'].'</a>)';
	}elseif($numreviews > 0)
		$srv.=' (<a class="ectlink showallreview" rel="nofollow" href="' . detailpageurl('review=all' . ($thecatid!='' ? '&amp;cat='.$thecatid : '')) . '">'.$GLOBALS['xxShoAll'].'</a>)';
	$srv.='</span></div>';
	if(@$allreviewspagesize=='') $allreviewspagesize=30;
	if($showall) $thepagesize=$allreviewspagesize; else $thepagesize=$numcustomerratings;
	$iNumOfPages=ceil($numreviews/$thepagesize);
	if(! is_numeric(getget('pg'))) $CurPage=1; else $CurPage=max(1, (int)getget('pg'));
	$recordcount=0;
	if($numreviews > 0){
		$theSQL.= ' LIMIT ' . ($thepagesize*($CurPage-1)) . ', ' . $thepagesize;
		$result=ect_query($theSQL) or ect_error();
		if(! (@$onlyclientratings && @$_SESSION['clientID']=='')) $srv.='<div class="clickreview">' . imageorbuttontag(@$GLOBALS['imgclicktoreview'],$GLOBALS['xxClkRev'],'clickreview',detailpageurl('review=true' . ($thecatid!='' ? '&amp;cat='.$thecatid : '')), FALSE) . '</div>';
		if(@$GLOBALS['imgreviewcart']=='') displayreviewicons();
		$srv.='<div class="reviewscontainer">';
		while($rs2=ect_fetch_assoc($result)){
			$srv.='<div class="ecthreview"' . ($GLOBALS['noschemamarkup']?'':' itemprop="review" itemscope itemtype="http://schema.org/Review"') . '>';
				$srv.='<div class="reviewstarsheader largereviewstars"><span class="rating"' . ($GLOBALS['noschemamarkup']?'':' itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"') . '>' . ($GLOBALS['noschemamarkup']?'':'<meta itemprop="worstRating" content="1"><meta itemprop="bestRating" content="5"><meta itemprop="ratingValue" content="' . round($rs2['rtRating']/2) . '">');
				for($index=1; $index <= (int)$rs2['rtRating'] / 2; $index++)
					if(@$GLOBALS['imgreviewcart']!='')
						$srv.='<img src="images/'.$GLOBALS['imgreviewcart'].'" alt="">';
					else
						$srv.='<svg viewBox="0 0 24 24" class="icon" style="max-width:30px"><use xlink:href="#review-icon-full"></use></svg>';
				$ratingover=$rs2['rtRating'];
				if($ratingover / 2 > (int)($ratingover / 2)){
					if(@$GLOBALS['imgreviewcart']!='')
						$srv.='<img src="images/'.str_replace('.','hg.',$GLOBALS['imgreviewcart']).'" alt="">';
					else
						$srv.='<svg viewBox="0 0 24 24" class="icon" style="max-width:30px"><use xlink:href="#review-icon-half"></use></svg>';
					$ratingover++;
				}
				for($index=((int)$ratingover / 2) + 1; $index <= 5; $index++)
					if(@$GLOBALS['imgreviewcart']!='')
						$srv.='<img src="images/'.str_replace('.','g.',$GLOBALS['imgreviewcart']).'" alt="">';
					else
						$srv.='<svg viewBox="0 0 24 24" class="icon" style="max-width:30px"><use xlink:href="#review-icon-empty"></use></svg>';
				$srv.='</span> <span class="reviewheader"' . ($GLOBALS['noschemamarkup']?'':' itemprop="name"') . '>' . htmlspecials($rs2['rtHeader']) . '</span></div>';
				$srv.='<div class="reviewname"><span class="reviewer"' . ($GLOBALS['noschemamarkup']?'':' itemprop="author" itemscope itemtype="http://schema.org/Person"') . '>' . ($GLOBALS['noschemamarkup']?'':'<meta itemprop="name" content="' . htmlspecials($rs2['rtPosterName']) . '">') . htmlspecials($rs2['rtPosterName']) . '</span> - <span class="dtreviewed">' . date($dateformatstr, strtotime($rs2['rtDate'])) . ($GLOBALS['noschemamarkup']?'':'<meta itemprop="datePublished" content="' . $rs2['rtDate'] . '">') . '</span></div>';
				$thecomments=$rs2['rtComments'];
				if(!@$GLOBALS['allowhtmlinreviews']) $thecomments=htmlspecials($thecomments);
				$hasextracomments=FALSE;
				if(! $showall){
					if(@$customerratinglength=='') $customerratinglength=255;
					if(strlen($thecomments)>$customerratinglength){
						$thecomments=substr($thecomments, 0, $customerratinglength) . '<span class="extracommentsdots" id="extracommentsdots' . $recordcount . '">' . $GLOBALS['xxReaMor'] . '</span><span id="extracomments' . $recordcount . '" style="display:none">' . substr($thecomments, $customerratinglength) . '</span>';
						$hasextracomments=TRUE;
					}
				}
				$srv.='<div class="reviewcomments"' . ($GLOBALS['noschemamarkup']?'':' itemprop="reviewBody"') . ($hasextracomments?' onclick="ectexpandreview(' . $recordcount . ');this.style.cursor=\'auto\'" style="cursor:pointer"':'') . '>' . str_replace(array("\r","\n"), array('','<br>'), $thecomments) . '</div>';
			$srv.='</div>';
			$recordcount++;
		}
		ect_free_result($result);
		$srv.='</div>';
	}else
		$srv.='<div class="noreview">' . $GLOBALS['xxRvNone'] . '</div>';
	if(! (@$onlyclientratings && @$_SESSION['clientID']=='')) $srv.='<div class="clickreview">' . imageorbuttontag(@$GLOBALS['imgclicktoreview'],$GLOBALS['xxClkRev'],'clickreview',detailpageurl('review=true' . ($thecatid!='' ? '&amp;cat='.$thecatid : '')), FALSE) . '</div>';
	$srv.=(@$usecsslayout ? '</div>' : '</td></tr>');
	$pblink='';
	foreach(@$_GET as $objQS => $objValue)
		if(gettype($objValue)=='string')
			if($objQS!='cat' && $objQS!='id' && $objQS!='pg' && $objQS!='mux' && $objQS!='prod') $pblink.=urlencode($objQS) . '=' . urlencode($objValue) . '&amp;';
	$pblink='<a class="vrectlink" href="'.detailpageurl($pblink . 'pg=');
	if($showall && $iNumOfPages > 1) $srv.=(@$usecsslayout ? '<div' : '<tr><td align="center"') . ' class="pagenumbers">' . writepagebar($CurPage,$iNumOfPages,$GLOBALS['xxPrev'],$GLOBALS['xxNext'],$pblink,TRUE) . (@$usecsslayout ? '</div>' : '</td></tr>');
	$GLOBALS['noschemamarkup']=$savenoschemamarkup;
	return($srv);
}
function schemaconditionavail(){
	global $rs,$optionshavestock;
	if(@$GLOBALS['setschemacondition']&&!$GLOBALS['noschemamarkup']) print '<meta itemprop="itemCondition" content="http://schema.org/'.(@$GLOBALS['schemaitemcondition']!=''?$GLOBALS['schemaitemcondition']:'NewCondition').'">';
	if(@$GLOBALS['setschemaavailability']&&!$GLOBALS['noschemamarkup']){
		$isinstock=($rs['pSell']!=0);
		if($GLOBALS['useStockManagement']){
			if($rs['pStockByOpts']!=0) $isinstock=$optionshavestock; else $isinstock=$rs['pInStock']>$rs['pMinQuant'];
		}
		print '<meta itemprop="availability" content="http://schema.org/'.($isinstock?'InStock':'OutOfStock').'">';
	}
}
function pddsearchwords(){
	global $usecsslayout,$showproductid,$rs,$searchwordsseparator;
	if(trim_($rs[getlangid('pSearchParams',4194304)])!=''){
		$searchprms=explode(@$searchwordsseparator!=''?$searchwordsseparator:' ',$rs[getlangid('pSearchParams',4194304)]);
		print '<div class="searchwords">';
		if(@$GLOBALS['searchwordsheading']!='') print '<div class="searchwordsheading">' . $GLOBALS['searchwordsheading'] . '</div>';
		foreach($searchprms as $key=>$val){
			print ($key==0?'':' ') . '<a class="ectlink searchwords" href="search'.$GLOBALS['extension'].'?pg=1&amp;stext='.urlencode($val).(@$GLOBALS['searchwordsnobox']?'&amp;nobox=true':'').'">'.htmlspecials($val).'</a>';
		}
		print '</div>';
	}
}
function pddquantitypricing(){
	global $rs,$WSP;
	$retval='';
	$numquantprices=0;
	$sSQL='SELECT '.$WSP.'pPrice,pbQuantity,'.($WSP!=''?'pbWholesalePercent AS ':'')."pbPercent FROM pricebreaks WHERE pbProdID='".escape_string($rs['pId'])."' ORDER BY pbQuantity";
	$result2=ect_query($sSQL) or ect_error();
	if(ect_num_rows($result2)>0){
		$retval='<div class="detailquantpricingwrap"><div class="detailquantpricing" style="display:table">';
		if(@$GLOBALS['xxQuaPri']!='') $retval.='<div class="detailqpheading" style="display:table-caption">' . $GLOBALS['xxQuaPri'] . '</div>';
		$retval.='<div class="detailqpheaders" style="display:table-row"><div class="detailqpheadquant" style="display:table-cell">' . $GLOBALS['xxQuanti'] . '</div><div class="detailqpheadprice" style="display:table-cell">' . $GLOBALS['xxPriQua'] . '</div></div>';
		while($rs2=ect_fetch_assoc($result2))
			$quantpricearray[$numquantprices++]=$rs2;
		for($index=0;$index<$numquantprices;$index++){
			if($index<$numquantprices-1){
				$nextquant=$quantpricearray[$index+1]['pbQuantity']-1;
				$nextquant=$nextquant>$quantpricearray[$index]['pbQuantity']?'-'.$nextquant:'';
			}else
				$nextquant='+';
			$retval.='<div class="detailqprow" style="display:table-row"><div class="detailqpquant" style="display:table-cell">' . $quantpricearray[$index]['pbQuantity'] . $nextquant . '</div><div class="detailqpprice" style="display:table-cell">' . FormatEuroCurrency($quantpricearray[$index]['pbPercent']!=0?$rs['pPrice']-(($rs['pPrice']*$quantpricearray[$index]['pPrice'])/100):$quantpricearray[$index]['pPrice']) . '</div></div>';
		}
		$retval.='</div></div>';
	}
	ect_free_result($result2);
	return($retval);
}
function pddreviewstars($issmall){
	global $rs;
	if($rs['pNumRatings']>0){
		$therating=(int)($rs['pTotRating']/$rs['pNumRatings']);
		if(@$GLOBALS['imgreviewcart']=='') displayreviewicons();
		print '<div class="' . ($issmall?'small':'large') . 'reviewstars detailreviewstars" aria-label="Rating ' . round($therating/2,1) . ' out of 5 stars"><a href="' . detailpageurl('') . '#reviews" aria-label="All reviews">';
		for($index=1; $index <= (int)($therating / 2); $index++){
			if(@$GLOBALS['imgreviewcart']!='')
				print '<img class="detailreviewstars" src="images/'.($issmall?'s':'').$GLOBALS['imgreviewcart'].'" alt="">';
			else
				print '<svg viewBox="0 0 24 24" class="icon" style="max-width:30px"><use xlink:href="#review-icon-full"></use></svg>';
		}
		$ratingover=$therating;
		if($ratingover / 2 > (int)($ratingover / 2)){
			if(@$GLOBALS['imgreviewcart']!='')
				print '<img class="detailreviewstars" src="images/'.($issmall?'s':'').str_replace('.','hg.',$GLOBALS['imgreviewcart']).'" alt="">';
			else
				print '<svg viewBox="0 0 24 24" class="icon" style="max-width:30px"><use xlink:href="#review-icon-half"></use></svg>';
			$ratingover++;
		}
		for($index=(int)($ratingover / 2) + 1; $index <= 5; $index++){
			if(@$GLOBALS['imgreviewcart']!='')
				print '<img class="detailreviewstars" src="images/'.($issmall?'s':'').str_replace('.','g.',$GLOBALS['imgreviewcart']).'" alt="">';
			else
				print '<svg viewBox="0 0 24 24" class="icon" style="max-width:30px"><use xlink:href="#review-icon-empty"></use></svg>';
		}
		print '</a>';
		if(@$GLOBALS['detailreviewstarstext']!='') print '<div class="detailratingtext">' . str_replace(array('%numratings%','%totrating%','%reviewlink%'),array($rs['pNumRatings'],round($rs['pTotRating']/$rs['pNumRatings']/2,1),detailpageurl('')),$GLOBALS['detailreviewstarstext']) . '</div>';
		print '</div>';
	}else
		print @$GLOBALS['detailreviewnoratings'];
}
function pddsreviews(){
	global $rs;
	if($rs['pNumRatings']>0) print showproductreviews(1,'detailrating');
}
function pddreviews(){
	global $usecsslayout,$prodid,$ratingslanguages,$reviewsshown,$productindb,$thecatid,$onlyclientratings;
	if(getpost('review')=='true' || getget('review')=='all'){
		// Do nothing
	}elseif(@$GLOBALS['enablecustomerratings'] && getget('review')=='true'){
		if(@$onlyclientratings && @$_SESSION['clientID']=='')
			print '<tr><td align="center">Only logged in customers can review products.</td></tr>';
		else{
			if(! @$usecsslayout) print '<tr><td>' ?>
	<script>
	/* <![CDATA[ */
	function checkratingform(frm){
	if(frm.ratingstars.selectedIndex==0){
		alert("<?php print jscheck($GLOBALS['xxRvPlsS'])?>.");
		frm.ratingstars.focus();
		return(false);
	}
	if(frm.reviewposter.value==""){
		alert("<?php print jscheck($GLOBALS['xxPlsEntr'] . ' "' . $GLOBALS['xxRvPosb'])?>\".");
		frm.reviewposter.focus();
		return(false);
	}
	if(frm.reviewheading.value==""){
		alert("<?php print jscheck($GLOBALS['xxPlsEntr'] . ' "' . $GLOBALS['xxRvHead'])?>\".");
		frm.reviewheading.focus();
		return(false);
	}
<?php
	if(@$GLOBALS['reviewcommentsminlength']!=''){ ?>
	if(frm.reviewcomments.value.length<<?php print $GLOBALS['reviewcommentsminlength']?>){
		alert("<?php print jscheck(str_replace('%s',$GLOBALS['reviewcommentsminlength'],$GLOBALS['xxMinLen']) . ' "' . $GLOBALS['xxRvComm'])?>\".");
		frm.reviewcomments.focus();
		return(false);
	}
<?php
	}
	if(recaptchaenabled(32)) print 'if(!reviewcaptchaok){ alert("' . jscheck($GLOBALS['xxRecapt']) . '");return(false); }' ?>
	document.getElementById('rfsectgrp1').value=document.getElementById('ratingstars')[document.getElementById('ratingstars').selectedIndex].value;
	document.getElementById('rfsectgrp2').value=document.getElementById('reviewposter').value.length;
	return(true);
	}
	/* ]]> */
	</script>
		<form method="post" action="<?php print detailpageurl($thecatid!='' ? 'cat='.$thecatid : '')?>" style="margin:0px;padding:0px;" onsubmit="return checkratingform(this)">
		<input type="hidden" name="review" value="true">
		<input type="hidden" name="rfsectgrp1" id="rfsectgrp1" value="6344">
		<input type="hidden" name="rfsectgrp2" id="rfsectgrp2" value="923">
		<div class="reviewformblock">
<?php		$reviewimage='';
			$sSQL="SELECT imageSrc FROM productimages WHERE imageType IN (0,1) AND imageProduct='" . escape_string($prodid) . "' ORDER BY imageType DESC,imageNumber LIMIT 0,1";
			$result2=ect_query($sSQL) or ect_error();
			if($rs2=ect_fetch_assoc($result2)) $reviewimage=$rs2['imageSrc'];
			if($reviewimage!='')
				print '<div class="reviewimage"><div class="reviewimagecontainer"><img src="' . $reviewimage . '"></div></div>';
?>			<div class="ectformline reviewformline"><div class="reviewlabels"><?php print $GLOBALS['redstar'] . $GLOBALS['xxRvRati']?>:</div><div class="reviewfields"><select size="1" name="ratingstars" id="ratingstars" class="ectselectinput reviewform"><option value=""><?php print $GLOBALS['xxPlsSel']?></option><?php
				for($index=1; $index<=5; $index++){
					print '<option value="'.$index.'">'.$index.' '.$GLOBALS['xxStars'].'</option>';
				} ?></select></div></div>
			<div class="ectformline reviewformline"><div class="reviewlabels"><?php print $GLOBALS['redstar'] . $GLOBALS['xxRvPosb']?>:</div><div class="reviewfields"><input type="text" size="20" name="reviewposter" id="reviewposter" maxlength="64" value="<?php print htmlspecials(@$_SESSION['clientUser'])?>" class="ecttextinput reviewform"></div></div>
			<div class="ectformline reviewformline"><div class="reviewlabels"><?php print $GLOBALS['redstar'] . $GLOBALS['xxRvHead']?>:</div><div class="reviewfields"><input type="text" size="40" name="reviewheading" maxlength="253" class="ecttextinput reviewform"></div></div>
			<div class="ectformline reviewformline"><div class="reviewlabels"><?php if(@$GLOBALS['reviewcommentsminlength']!='') print $GLOBALS['redstar']; print $GLOBALS['xxRvComm']?>:</div><div class="reviewfields"><textarea name="reviewcomments" cols="38" rows="8" class="ecttextinput reviewform"></textarea></div></div>
<?php		if(recaptchaenabled(32)){ ?>
				<div class="ectformline reviewformline"><div class="reviewlabels">&nbsp;</div><div class="reviewfields"><?php displayrecaptchajs('reviewcaptcha',TRUE,FALSE) ?><div id="reviewcaptcha"></div></div></div>
<?php		} ?>
			<div class="ectformline reviewformline"><div class="reviewlabels"></div><div class="reviewfields"><input type="submit" value="<?php print $GLOBALS['xxSubmt']?>" class="ectbutton reviewsubmit"></div></div>
		</div>
		</form>
	<?php	if(! @$usecsslayout) print '</td></tr>';
		}
	}elseif(@$GLOBALS['enablecustomerratings']){
		$sSQL="SELECT rtID,rtRating,rtPosterName,rtHeader,rtDate,rtComments FROM ratings WHERE " . $GLOBALS['reviewsearchsql'];
		if(@$ratingslanguages!='') $sSQL.=' AND rtLanguage+1 IN ('.$ratingslanguages.')'; elseif(@$languageid!='') $sSQL.=' AND rtLanguage='.((int)$languageid-1); else $sSQL.=' AND rtLanguage=0';
		$sSQL.=' ORDER BY rtDate DESC,rtRating DESC';
		if(! $reviewsshown && $productindb) print showreviews($sSQL,FALSE);
	}
}
function pddprodnavigation(){
	global $tslist;
	if(! (@$GLOBALS['nobuyorcheckout'] || @$GLOBALS['nocheckoutbutton'])) print '<div class="catnavandcheckout catnavdetail">';
	print '<div class="catnavigation catnavdetail">' . $tslist . "</div>\n";
	if(! (@$GLOBALS['nobuyorcheckout'] || @$GLOBALS['nocheckoutbutton'])) print '<div class="catnavcheckout">' . imageorbutton(@$GLOBALS['imgcheckoutbutton'],@$GLOBALS['xxCOTxt'],'checkoutbutton','cart'.$GLOBALS['extension'], FALSE) . "</div></div>\n";
}
function pddcheckoutbutton(){
	// Not used now
}
function pddproductimage(){
	global $usecsslayout;
	if(! @$usecsslayout) print '<table width="100%" border="0" cellspacing="3" cellpadding="3"><tr>';
	print (@$usecsslayout ? '<div' : '<td width="30%" align="center"') . ' itemprop="image" itemscope itemtype="https://schema.org/ImageObject" class="detailimage allprodimages' . (@$GLOBALS['magictoolbox']==''?' ectnomagicimage':'') . '">';
	showdetailimages();
	print (@$usecsslayout ? '</div>' : '</td>');
}
function pddproductid(){
	global $usecsslayout,$showproductid,$rs;
	if(! @$usecsslayout) print '<td>&nbsp;</td><td width="70%" valign="top" class="detail">';
	if(@$showproductid || $GLOBALS['hascustomlayout']) print '<div class="detailid">' . ($GLOBALS['xxPrId']!=''?'<span class="prodidlabel detailidlabel">' . $GLOBALS['xxPrId'] . '</span> ':'') . ($GLOBALS['noschemamarkup']?'':'<span itemprop="productID">') . $rs['pId'] . ($GLOBALS['noschemamarkup']?'':'</span>') . '</div>';
}
function pddmanufacturer($islinked){
	global $rs;
	if(! is_null($rs[getlangid('scName',131072)])){
		$startlink=$endlink='';
		if($islinked){
			if(trim_($rs['scURL'])!='')
				$newloc=getcatid($rs['scURL'],$rs['scURL'],@$GLOBALS['seomanufacturerpattern']);
			else
				$newloc=(!@$GLOBALS['seocategoryurls'] ? 'products' . $GLOBALS['extension'] . '?man=' : '') . getcatid($rs['scID'],$rs[getlangid('scName',131072)],@$GLOBALS['seomanufacturerpattern']);
			$startlink='<a href="' . $newloc . '">';
			$endlink='</a>';
		}
		print '<div class="detailmanufacturer">' . (@$GLOBALS['xxManLab']!=''?'<span class="detailmanufacturerlabel">' . $GLOBALS['xxManLab'] . '</span> ':'') . ($GLOBALS['noschemamarkup']?'':'<span itemprop="manufacturer">') . $startlink . $rs[getlangid('scName',131072)] . $endlink . ($GLOBALS['noschemamarkup']?'':'</span>') . '</div>';
	}
}
function pddsku(){
	global $showproductsku,$rs;
	if((@$showproductsku!='' || $GLOBALS['hascustomlayout']) && $rs['pSKU']!='') print '<div class="detailsku">' . ($showproductsku!=''?'<span class="prodskulabel detailskulabel">' . $showproductsku . '</span> ':'') . ($GLOBALS['noschemamarkup']?'':'<span itemprop="' . $GLOBALS['skuschemaidentifier'] . '">') . $rs['pSKU'] . ($GLOBALS['noschemamarkup']?'':'</span>') . '</div>';
}
function pddcustom($custid){
	global $detailcustomlabel1,$detailcustomlabel2,$detailcustomlabel3,$rs;
	eval('$customlabel=@$detailcustomlabel' . $custid . ';');
	if(trim_($rs['pCustom'.$custid])!='') print '<div class="detailcustom'.$custid.'">' . $customlabel . $rs['pCustom'.$custid] . '</div>';
}
function pdddateadded(){
	global $rs,$dateformatstr,$isarticle;
	if(trim_($rs['pDateAdded'])!='') print '<div class="detaildateadded">' . (@$GLOBALS['xxDatLab']!=''?'<div class="detaildateaddedlabel">' . $GLOBALS['xxDatLab'] . '</div>':'') . '<div class="detaildateaddeddate">' . ($GLOBALS['noschemamarkup']||!$isarticle?'':'<meta itemprop="datePublished dateModified" content="' . date('Y-m-d',strtotime($rs['pDateAdded'])) . '">') . date($dateformatstr,strtotime($rs['pDateAdded'])) . '</div></div>';
}
function pdddetailname(){
	global $rs,$alldiscounts,$isarticle;
	print '<div class="detailname"><h1' . ($GLOBALS['noschemamarkup']?'':' itemprop="name' . ($isarticle?' headline':'') . '"') . '>' . $rs[getlangid('pName',1)] . '</h1>' . $GLOBALS['xxDot'];
	if($alldiscounts!='') print ' <span class="discountsapply detaildiscountsapply">' . $GLOBALS['xxDsApp'] . '</span>';
	print '</div>';
}
function pdddiscounts(){
	global $alldiscounts;
	if($alldiscounts!='') print '<div class="detaildiscounts">' . $alldiscounts . '</div>';
}
function pddinstock(){
	global $showinstock,$rs,$optionshavestock;
	if($GLOBALS['useStockManagement'] && (@$showinstock || $GLOBALS['hascustomlayout']) && ($rs['pInStock']<=@$GLOBALS['stockdisplaythreshold'] || @$GLOBALS['stockdisplaythreshold']=='')){ if((int)$rs['pStockByOpts']==0) print '<div class="detailinstock">' . ($GLOBALS['xxInStoc']!=''?'<span class="detailinstocklabel">' . $GLOBALS['xxInStoc'] . '</span> ':'') . max(0,$rs['pInStock']) . '</div>'; }
}
function pddinstockmsg(){
	global $showinstock,$rs,$optionshavestock;
	if($GLOBALS['useStockManagement'] && (($rs['pStockByOpts']==0 && $rs['pInStock']>0) || ($rs['pStockByOpts']!=0 && $optionshavestock))) print '<div class="detailinstock">' . str_replace('%s',max(0,$rs['pInStock']),$GLOBALS['xxInStoc']) . '</div>';
}
function pddshortdescription(){
	global $rs;
	print '<div class="detailshortdescription">'.$rs[getlangid('pDescription',2)].'</div>';
}
function pdddescription(){
	global $usecsslayout,$usedetailbodyformat,$rs,$longdesc;
	if(! @$usecsslayout) print '<br>';
	$longdesc.=@$GLOBALS['ectextralongdescription'];
	if(@$usedetailbodyformat==3){
	}elseif($longdesc!='')
		print '<div class="detaildescription detaildescriptiontabs"' . displaytabs($longdesc) . '</div>';
	elseif(trim_($rs[getlangid('pDescription',2)])!='')
		print '<div class="detaildescription"' . ($GLOBALS['noschemamarkup']?'':' itemprop="description"') . '>' . $rs[getlangid('pDescription',2)] . '</div>';
}
function pddlistprice(){
	global $Count,$noprice,$rs,$thetax;
	if(@$noprice==TRUE)
		print '&nbsp;';
	elseif((float)$rs['pListPrice']!=0.0){
		$plistprice=(@$GLOBALS['showtaxinclusive']===2 && ($rs['pExemptions'] & 2)!=2?$rs['pListPrice']+($rs['pListPrice']*$thetax/100.0):$rs['pListPrice']);
		$yousaveprice=$plistprice-(@$GLOBALS['showtaxinclusive']===2 && ($rs['pExemptions'] & 2)!=2 ? $rs['pPrice']+($rs['pPrice']*$thetax/100.0) : $rs['pPrice']);
		print '<div class="detaillistprice" id="listdivec' . $Count . '"' . ($yousaveprice<=0?' style="display:none"':'') . '>' . str_replace('%s', FormatEuroCurrency($plistprice), $GLOBALS['xxListPrice']) . (@$GLOBALS['yousavetext']!=''&&$yousaveprice>0?str_replace('%s', FormatEuroCurrency($yousaveprice), $GLOBALS['yousavetext']):'') . '</div>';
	}
		
}
function pddprice(){
	global $Count,$rs,$pricezeromessage,$thetax,$ssIncTax,$noprice,$countryCurrency;
	if(@$noprice!=TRUE){
		$separatetaxinc=@$GLOBALS['showtaxinclusive']==1 && ($rs['pExemptions'] & 2)!=2;
		$displayprice=(@$GLOBALS['showtaxinclusive']===2 && ($rs['pExemptions'] & 2)!=2 ? $rs['pPrice']+($rs['pPrice']*$thetax/100.0) : $rs['pPrice']);
		print '<div class="detailprice"' . ($rs['pPrice']!=0&&!$GLOBALS['noschemamarkup']?' itemprop="offers" itemscope itemtype="http://schema.org/Offer"><meta itemprop="priceCurrency" content="'.$countryCurrency.'"':'') . '><strong>' . $GLOBALS['xxPrice'].($GLOBALS['xxPrice']!=''?':':'') . '</strong> <span class="price" id="pricediv' . $Count . '"'.($rs['pPrice']!=0&&!$GLOBALS['noschemamarkup']&&!$separatetaxinc?' itemprop="price" content="' . number_format($displayprice,2,'.','') . '"':'').'>' . ($rs['pPrice']==0 && @$pricezeromessage!='' ? $pricezeromessage : FormatEuroCurrency($displayprice)) . '</span><link itemprop="url" href="' . detailpageurl('') . '"> ';
		if($separatetaxinc) printf('<span class="inctax" id="taxmsg' . $Count . '"' . ($rs['pPrice']==0 ? ' style="display:none"' : '') . '>' . $ssIncTax . '</span>','<span id="pricedivti' . $Count . '"' . ($GLOBALS['noschemamarkup']?'':' itemprop="price" content="' . number_format($rs['pPrice']+($rs['pPrice']*$thetax/100.0),2,'.','') . '"') . '>' . ($rs['pPrice']==0 ? '-' : FormatEuroCurrency($rs['pPrice']+($rs['pPrice']*$thetax/100.0))) . '</span> ');
		schemaconditionavail();
		if(($GLOBALS['adminPayLater'] & 4)==4){
			print '<div data-pp-message data-pp-amount="' . $displayprice . '" class="paylaterquote detailpaylaterquote"></div>'."\n";
		}
		print '</div>';
	}
}
function pddextracurrency(){
	global $currRate1,$currRate2,$currRate3,$currSymbol1,$currSymbol2,$currSymbol3,$currFormat1,$currFormat2,$currFormat3,$rs,$Count,$usecsslayout,$noprice,$showquantitypricing;
	if(@$noprice!=TRUE || $GLOBALS['hascustomlayout']){
		$extracurr='';
		if($currRate1!=0 && $currSymbol1!='') $extracurr=str_replace('%s',number_format($rs['pPrice']*$currRate1,checkDPs($currSymbol1),$GLOBALS['currDecimalSep'],$GLOBALS['currThousandsSep']),$currFormat1) . $GLOBALS['currencyseparator'];
		if($currRate2!=0 && $currSymbol2!='') $extracurr.=str_replace('%s',number_format($rs['pPrice']*$currRate2,checkDPs($currSymbol2),$GLOBALS['currDecimalSep'],$GLOBALS['currThousandsSep']),$currFormat2) . $GLOBALS['currencyseparator'];
		if($currRate3!=0 && $currSymbol3!='') $extracurr.=str_replace('%s',number_format($rs['pPrice']*$currRate3,checkDPs($currSymbol3),$GLOBALS['currDecimalSep'],$GLOBALS['currThousandsSep']),$currFormat3);
		if($extracurr!='') print '<div class="detailcurrency"><span class="extracurr" id="pricedivec' . $Count . '">' . ($rs['pPrice']==0 ? '' : $extracurr) . '</span></div>';
		if(@$GLOBALS['showquantitypricing']&&!$GLOBALS['hascustomlayout'])
			print pddquantitypricing();
		if(! @$usecsslayout) print '<hr width="80%" class="detailhr detailcurrencyhr currencyhr">';
	}
}
function pddquantity($wantquanttext){
	global $Count,$isinstock,$isbackorder,$nobuyorcheckout,$showquantondetail,$hasmultipurchase,$quantityupdown;
	if($GLOBALS['hascustomlayout']){
		if(($isinstock || $isbackorder) && @$nobuyorcheckout!=TRUE && (@$showquantondetail==TRUE || ! @isset($showquantondetail)) && $hasmultipurchase==0){
			print '<div class="detailquantity">' . ($wantquanttext ? '<div class="detailquantitytext">' . $GLOBALS['xxQuant'] . '</div>' : '') . quantitymarkup(FALSE,$Count,TRUE,'',FALSE) . '</div>';
		}
	}
}
function pddoptions(){
	global $Count,$prodoptions,$optjs,$optionshtml,$usecsslayout,$isinstock,$isbackorder,$nobuyorcheckout,$showquantondetail,$hasmultipurchase,$quantityupdown;
	displayformvalidator();
	if($optjs!=''){
		print '<script>/* <![CDATA[ */'.$optjs.'/* ]]> */</script>';
		if($GLOBALS['mustincludepopcalendar'] && !$GLOBALS['hasincludedpopcalendar']){ print '<script>var ectpopcalisproducts=1;' . @$GLOBALS['ectpopcalendarjs'] . ($GLOBALS['storelang']!='en' && $GLOBALS['storelang']!=''?"var ectpopcallang='".$GLOBALS['storelang']."'":'') . "\r\n" . '</script><script src="vsadmin/popcalendar.js"></script>'; $GLOBALS['hasincludedpopcalendar']=TRUE; }
	}
	if(count($prodoptions)>0){
		if($prodoptions[0]['optType']==4) $thestyle=''; else $thestyle=' width="100%"';
		if($optionshtml!='') $optionshtml='<div class="detailoptions"' . (@$usecsslayout?'':' style="float:left;width:98%;"') . '>' . $optionshtml . '</div>';
		if(! $GLOBALS['hascustomlayout'] && ($isinstock || $isbackorder) && @$nobuyorcheckout!=TRUE && (@$showquantondetail==TRUE || ! @isset($showquantondetail)) && $hasmultipurchase==0){
			$optionshtml.='<div class="detailquantity"><div class="detailquantitytext">' . $GLOBALS['xxQuant'] . ':' . '</div>' . quantitymarkup(FALSE,$Count,TRUE,'',FALSE) . '</div>';
		}
	}elseif(! $GLOBALS['hascustomlayout']){
		if(($isinstock || $isbackorder) && @$nobuyorcheckout!=TRUE && (@$showquantondetail==TRUE || ! @isset($showquantondetail))){
			$optionshtml.=(@$usecsslayout ? '<div class="detailquantity"><div class="detailquantitytext">' : '<table border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td align="right">');
			$optionshtml.=$GLOBALS['xxQuant'] . ':';
			$optionshtml.=(@$usecsslayout ? '</div>' : '</td><td>');
			$optionshtml.=quantitymarkup(FALSE,$Count,TRUE,'',FALSE) . (@$usecsslayout ? '</div>' : '</td></tr></table>');
		}
	}
}
function pddcatcontentregion(){
	global $catid;
	$sSQL='SELECT contentID,contentName,'.getlangid('contentData',32768)." FROM contentregions WHERE contentName='catcontentregion".escape_string($catid)."'";
	$result=ect_query($sSQL) or ect_error();
	if($rs=ect_fetch_assoc($result)){
		print '<div class="detailcontentregion detailregioncatid' . $catid . '">' . $rs[getlangid("contentData",32768)] . "</div>\n";
		ect_free_result($result);
	}
}
function pddcontentregion($contentid){
	if(is_numeric($contentid)){
		$sSQL="SELECT ".getlangid('contentData',32768)." FROM contentregions WHERE contentID='".escape_string($contentid)."'";
		$result=ect_query($sSQL) or ect_error();
		if($rs=ect_fetch_assoc($result)){
			print '<div class="detailcontentregion detailregionid' . $contentid . '">' . $rs[getlangid("contentData",32768)] . "</div>\n";
		}
	}
}
$GLOBALS['isfirstaddtocart']=TRUE;
function pddaddtocart(){
	global $usecsslayout,$nobuyorcheckout,$rs,$nosellzeroprice,$isinstock,$isbackorder,$wishlistondetail,$imgbackorderbutton,$custombuybutton,$atcmu;
	global $imgbuybutton,$imgaddtolist,$Count,$notifybackinstock,$optionshavestock,$prodoptions;
	$atcmu=(! @$usecsslayout ? '<p align="center">' : '');
	if(@$nobuyorcheckout==TRUE)
		$atcmu.='&nbsp;';
	else{
		if($rs['pPrice']==0 && @$nosellzeroprice==TRUE){
			$atcmu.='&nbsp;';
		}elseif($isinstock || $isbackorder){
			if($GLOBALS['isfirstaddtocart']){
				writehiddenvar('id', $rs['pId']);
				writehiddenvar('mode', 'add');
				if($wishlistondetail) writehiddenvar('listid', '');
			}
			if(@$usecsslayout) $atcmu.='<div class="addtocart detailaddtocart">';
			if($isbackorder){
				if(@$GLOBALS['usehardaddtocart']) $atcmu.=imageorsubmit(@$imgbackorderbutton,$GLOBALS['xxBakOrd'],'buybutton backorder detailbuybutton detailbackorder'); else $atcmu.=imageorbuttontag(@$imgbackorderbutton,$GLOBALS['xxBakOrd'],'buybutton backorder detailbuybutton detailbackorder','subformid('.$Count.",'','')",TRUE);
			}else{
				if(@$custombuybutton!='')
					$atcmu.=$custombuybutton;
				else{
					if(@$GLOBALS['usehardaddtocart']) $atcmu.=imageorsubmit(@$imgbuybutton,$GLOBALS['xxAddToC'],'buybutton detailbuybutton'); else $atcmu.=imageorbuttontag(@$imgbuybutton,$GLOBALS['xxAddToC'],'buybutton detailbuybutton ectaddcart'.$Count,'subformid('.$Count.",'','')",TRUE);
				}
			}
			if($wishlistondetail) $atcmu.='<div class="wishlistcontainer detailwishlist">' . imageorbuttontag(@$imgaddtolist,$GLOBALS['xxAddLis'],'detailwishlist','gtid='.$Count.';return displaysavelist(this,event,window)',TRUE) . '</div>';
			if(@$usecsslayout) $atcmu.='</div>';
		}else{
			if(@$usecsslayout) $atcmu.='<div class="addtocart detailaddtocart detailoutofstock">';
			if(@$notifybackinstock)
				$atcmu.=imageorbuttontag(@$GLOBALS['imgnotifyinstock'],$GLOBALS['xxNotBaS'],'notifystock detailnotifystock',count($prodoptions)>0 && $GLOBALS['useStockManagement'] ? 'subformid('.$Count.",'','')" : "return notifyinstock(false,'".str_replace("'","\\'",$rs['pId'])."','".str_replace("'","\\'",$rs['pId'])."',".($rs['pStockByOpts']!=0&&!@$optionshavestock?'-1':'0').")", TRUE);
			else
				$atcmu.='<button class="ectbutton outofstock detailoutofstock" type="button" disabled>' . $GLOBALS['xxOutStok'] . '</button>';
			if(@$usecsslayout) $atcmu.='</div>'; else $atcmu.='<br>';
		}
	}
	$GLOBALS['isfirstaddtocart']=FALSE;
}
function pddpreviousnext(){
	global $previousid,$nextid,$usecsslayout;
	if($previousid!='' || $nextid!=''){
		print (@$usecsslayout ? '<div class="previousnext">' : '</p><p class="pagenumbers" align="center">');
		writepreviousnextlinks();
		print (@$usecsslayout ? '</div>' : '<br>');
	}
}
function pddemailfriend(){
	global $usecsslayout,$longdesc,$rs,$usedetailbodyformat,$emailfriendoraskquestion;
	if(@$usedetailbodyformat==3 && @$emailfriendoraskquestion){ print '<br>'; pddsocialmedia(); }
	if(@$usedetailbodyformat==4 && @$emailfriendoraskquestion){ print '<div class="emailfriend">'; pddsocialmedia(); print '</div>'; }
	if(! @$usecsslayout) print '</p><hr width="80%" class="detailhr detailhrbottom">';
	if(@$usedetailbodyformat==2 && @$emailfriendoraskquestion){ print '<p align="center">'; pddsocialmedia(); print '</p>'; }
	if(! @$usecsslayout) print '</td></tr>';
	if(@$usedetailbodyformat==2 || @$usedetailbodyformat==4){
	}elseif($longdesc!='')
		print (! @$usecsslayout ? '<tr><td colspan="3" class="detaildescription">' : '') . '<div class="detaildescription"' . displaytabs($longdesc) . '</div>' . (! @$usecsslayout ? '</td></tr>' : '');
	elseif(trim_($rs[getlangid('pDescription',2)])!='')
		print (! @$usecsslayout ? '<tr><td colspan="3" class="detaildescription">' : '') . '<div class="detaildescription"' . ($GLOBALS['noschemamarkup']?'':' itemprop="description"') . '>' . $rs[getlangid('pDescription',2)] . '</div>' . (! @$usecsslayout ? '</td></tr>' : '');
	if(! @$usecsslayout) print '</table>';
}
function pddsocialmedia(){
	global $storelang,$rs,$prodid;
	$socialmediaarray=explode(',',strtolower(str_replace(' ','',$GLOBALS['socialmediabuttons'])));
	if(!@isset($GLOBALS['smallsocialbuttons'])) $GLOBALS['smallsocialbuttons']=TRUE;
	$buttonlang='en_US';
	if($storelang=='fr') $buttonlang='fr_FR';
	if($storelang=='es') $buttonlang='es_ES';
	if($storelang=='de') $buttonlang='de_DE';
	if($storelang=='es') $buttonlang='es_ES';
	if($storelang=='dk') $buttonlang='da_DK';
	if($storelang=='it') $buttonlang='it_IT';
	if($storelang=='nl') $buttonlang='nl_NL';
	if($storelang=='pt') $buttonlang='pt_BR';
	$addand=$newqs='';
	foreach($_GET as $key=>$val){
		if($key!='prod' && $key!='cat' && gettype($val)=='string'){ $newqs.=$addand.urlencode($key).'='.urlencode($val); $addand='&amp;'; }
	}
	$thisurl=getfullurl(getdetailsurl($rs['pId'],$rs['pStaticPage'],$rs[getlangid('pName',1)],$rs['pStaticURL'],$newqs,@$GLOBALS['pathtohere']));
	print '<div class="socialmediabuttons">';
	$hasdisplayedone=FALSE;
	foreach($socialmediaarray as $layoutoption){
		if($hasdisplayedone && @$GLOBALS['socialmediaseparator']!='') print $GLOBALS['socialmediaseparator'];
		$hasdisplayedone=TRUE;
		if($layoutoption=='facebook'){
		print '<div class="socialmediabutton smfacebook">';
		print '<div id="fb-root"></div><script>(function(d,s,id){var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "https://connect.facebook.net/' . $buttonlang . '/sdk.js#xfbml=1&version=v3.0";fjs.parentNode.insertBefore(js, fjs);}(document, \'script\', \'facebook-jssdk\'));</script>';
		if(@$GLOBALS['sbfacebook']!='') print str_replace('%pageurl%',$thisurl,@$GLOBALS['sbfacebook']); else print '<div class="fb-like" data-href="' . $thisurl . '" data-layout="button_count" data-action="like" data-size="' . (@$GLOBALS['smallsocialbuttons']?'small':'large') . '" data-show-faces="false" data-share="true"></div>';
		print '</div>';
		}elseif($layoutoption=='linkedin'){
		print '<div class="socialmediabutton smlinkedin">' . (@$GLOBALS['smallsocialbuttons']?'':'<div class="smlinkedininner">');
		print '<script src="//platform.linkedin.com/in.js">lang:' . $buttonlang . '</script>';
		if(@$GLOBALS['sblinkedin']!='') print str_replace('%pageurl%',$thisurl,@$GLOBALS['sblinkedin']); else print '<script type="IN/Share" data-url="' . $thisurl . '" data-counter="right"></script>';
		print '</div>' . (@$GLOBALS['smallsocialbuttons']?'':'</div>');
		}elseif($layoutoption=='twitter'){
		print '<div class="socialmediabutton smtwitter">';
		print '<script async src="https://platform.twitter.com/widgets.js"></script>';
		if(@$GLOBALS['sbtwitter']!='') print str_replace('%pageurl%',$thisurl,@$GLOBALS['sbtwitter']); else print '<a class="twitter-share-button" ' . ($storelang!='en'?'lang="'.$storelang.'" ':'') . 'href="https://twitter.com/intent/tweet" data-size="' . (@$GLOBALS['smallsocialbuttons']?'default':'large') . '" data-url="' . $thisurl . '">Tweet</a>';
		print '</div>';
		}elseif($layoutoption=='pinterest'){
		print '<div class="socialmediabutton smpinterest">';
		print '<a data-pin-do="buttonBookmark" ' . (@$GLOBALS['smallsocialbuttons']?'':'data-pin-tall="28px" ') . 'data-pin-save="true" href="https://www.pinterest.com/pin/create/button/"></a>';
		print '<script async defer src="//assets.pinterest.com/js/pinit.js"></script>';
		print '</div>';
		}elseif($layoutoption=='askaquestion'){
		print '<div class="socialmediabutton smaskaquestion">';
		print imageorbutton(@$GLOBALS['imgaskaquestion'],@$GLOBALS['useaskaquestion']?$GLOBALS['xxAskQue']:'DISABLED',(@$GLOBALS['smallsocialbuttons']?'sm':'lg').'askaquestion',(@$GLOBALS['useaskaquestion']?'display':'disabled')."ectcontact('askquestion','".urlencode($prodid)."')",TRUE);
		print '</div>';
		}elseif($layoutoption=='emailfriend'){
		print '<div class="socialmediabutton smemailfriend">';
		print imageorbutton(@$GLOBALS['imgemailfriend'],@$GLOBALS['useemailfriend']?$GLOBALS['xxEmFrnd']:'DISABLED',(@$GLOBALS['smallsocialbuttons']?'sm':'lg').'emailfriend',(@$GLOBALS['useemailfriend']?'display':'disabled')."ectcontact('emailfriend','".urlencode($prodid)."')",TRUE);
		print '</div>';
		}elseif($layoutoption=='custom'){
		if(@$GLOBALS['sbcustom']!='') print '<div class="socialmediabutton smcustom">' . $GLOBALS['sbcustom'] . '</div>';
		}
	}
	print '</div>';
}
$GLOBALS['alreadygotadmin']=getadminsettings();
$thesessionid=getsessionid();
$hasextracurrency=$GLOBALS['wantmanufacturer']=FALSE;
foreach($customlayoutarray as $layoutoption){
	if(strtolower(trim_($layoutoption))=='currency') $hasextracurrency=TRUE;
	if(strtolower(trim_($layoutoption))=='manufacturer' || strtolower(trim_($layoutoption))=='manufacturerlink' || stripos($layoutoption,'%brand%')!==FALSE) $GLOBALS['wantmanufacturer']=TRUE;
	if(strtolower(trim_($layoutoption))=='instock') $showinstock=TRUE;
}
if($hasextracurrency)
	checkCurrencyRates($GLOBALS['currConvUser'],$GLOBALS['currConvPw'],$GLOBALS['currLastUpdate'],$GLOBALS['currRate1'],$GLOBALS['currSymbol1'],$GLOBALS['currRate2'],$GLOBALS['currSymbol2'],$GLOBALS['currRate3'],$GLOBALS['currSymbol3']);
else{
	$currRate1=0; $currRate2=0; $currRate3=0;
}
$psmallimage='';
$allimages=$allgiantimages=[];
$numallimages=$numallgiantimages=0;
$pSchemaType=0;
$pCustomCSS='';
$sSQL1='SELECT pId,pSKU,'.getlangid('pName',1).','.getlangid('pDescription',2).','.$WSP.'pPrice,pSection,pListPrice,pSell,pStockByOpts,pStaticPage,'.getaltlang('pStaticURL',8388608).',pInStock,pBackOrder,pExemptions,'.(@$detailslink!='' ? "'' AS " : '').'pTax,pTotRating,pNumRatings,pOrder,pDateAdded,'.getlangid('pSearchParams',4194304).',pMinQuant,pSchemaType,pCustomCSS,';
foreach($customlayoutarray as $layoutoption){
	if(substr(strtolower(trim_($layoutoption)),0,6)=='custom'){
		if(strpos($sSQL1,str_replace('custom','pCustom',$layoutoption).',')===FALSE)$sSQL1.=str_replace('custom','pCustom',$layoutoption).',';
	}elseif(substr(trim_($layoutoption),0,1)=='<'&&preg_match('/%custom(\d+)%/i',$layoutoption,$matchnum)){
		if(strpos($sSQL1,'pCustom'.$matchnum[1].',')===FALSE)$sSQL1.='pCustom'.$matchnum[1].',';
	}
}
$sSQL1.=($GLOBALS['wantmanufacturer']?getlangid('scName',131072).',scID,scURL,':'').getlangid('pLongDescription',4).' FROM products '.($GLOBALS['wantmanufacturer']?'LEFT OUTER JOIN searchcriteria on products.pManufacturer=searchcriteria.scID ':'').'WHERE ' . (@$GLOBALS['ectsiteid']!='' ? 'pSiteID='.$GLOBALS['ectsiteid'].' AND ' : '') . 'pDisplay<>0 AND ((';
$sSQL2=(@$usepnamefordetaillinks && trim_(@$explicitid)==''?getlangid('pName',1):'pId') . "='" . escape_string($prodid) . "')";
$sSQL3=(@$GLOBALS['seodetailurls']?" OR BINARY ".getlangid('pStaticURL',8388608)."='".escape_string($prodid)."'":'') . ')';
$result=ect_query($sSQL1.(trim_(@$explicitid)==''?getlangid('pStaticURL',8388608)."='' AND BINARY ":'').$sSQL2.$sSQL3) or ect_error();
$productindb=ect_num_rows($result)>0;
$disabledsection=TRUE;
if($productindb){
	$origprodid=$prodid;
	while(($rs=ect_fetch_assoc($result))&&$disabledsection){
		$longdesc=trim_($rs[getlangid('pLongDescription',4)]);
		$prodid=$rs['pId'];
		$sectionid=$rs['pSection'];
		$pSchemaType=$rs['pSchemaType'];
		$pCustomCSS=$rs['pCustomCSS'];
		$sSQL="SELECT sectionDisabled,topSection FROM sections WHERE sectionID='" . escape_string($sectionid) . "'";
		$result2=ect_query($sSQL) or ect_error();
		if($rs2=ect_fetch_assoc($result2))
			$disabledsection=$rs2['sectionDisabled']>$minloglevel;
		else
			$disabledsection=FALSE;
		ect_free_result($result2);
		if(!$disabledsection) break;
	}
}else
	$disabledsection=FALSE;
$GLOBALS['reviewsearchsql']="rtApproved<>0 AND rtProdID='" . escape_string($prodid) . "'";
$prodlist="'" . escape_string($prodid) . "'";
$sSQL="SELECT imageSrc FROM productimages WHERE imageType=0 AND imageProduct='" . escape_string($prodid) . "' ORDER BY imageNumber LIMIT 0,1";
$result2=ect_query($sSQL) or ect_error();
if($rs2=ect_fetch_assoc($result2)) $psmallimage=$rs2['imageSrc'];
ect_free_result($result2);
$sSQL="SELECT imageSrc FROM productimages WHERE imageType=1 AND imageProduct='" . escape_string($prodid) . "' ORDER BY imageNumber";
$result2=ect_query($sSQL) or ect_error();
while($rs2=ect_fetch_assoc($result2)) $allimages[$numallimages++]=$rs2;
ect_free_result($result2);
$sSQL="SELECT imageSrc FROM productimages WHERE imageType=2 AND imageProduct='" . escape_string($prodid) . "' ORDER BY imageNumber";
$result2=ect_query($sSQL) or ect_error();
while($rs2=ect_fetch_assoc($result2)) $allgiantimages[$numallgiantimages++]=$rs2;
ect_free_result($result2);
if((! $productindb && $prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid']) || $disabledsection){
	$addand=$newqs='';
	foreach($_GET as $key=>$val){
		if($key!='prod' && gettype($val)=='string'){ $newqs.=$addand.urlencode($key).'='.urlencode($val); $addand='&'; }
	}
	notfoundmarkup($GLOBALS['xxSryNA'],TRUE);
}else{
	$prodoptions=[];
	if($pSchemaType==1){
		$isarticle=TRUE;
		$GLOBALS['skuschemaidentifier']='author';
		$GLOBALS['hascustomlayout']=TRUE;
		if(@$articlepagelayout=='') $detailpagelayout='productimage,sku,productname,description,dateadded,previousnext'; else{ $GLOBALS['hascustomlayout']=TRUE; $detailpagelayout=$articlepagelayout; }
		$customlayoutarray=explode(',',$detailpagelayout);
		$enablecustomerratings=strpos($detailpagelayout,'review')!==FALSE;
		if(@isset($GLOBALS['ecttabsspecialsarticle'])) $GLOBALS['ecttabsspecials']=$GLOBALS['ecttabsspecialsarticle'];
		if(@isset($GLOBALS['defaultdescriptiontabarticle'])) $GLOBALS['defaultdescriptiontab']=$GLOBALS['defaultdescriptiontabarticle'];
	}else{
		if(($GLOBALS['adminPayLater'] & 12)!=0){
			if(getpayprovdetx(27,$data1,$data2,$data3,$data4,$data5,$data6,$ppflag1,$ppflag2,$ppflag3,$ppbits,$demomode,$ppmethod)){
				print '<script src="https://www.paypal.com/sdk/js?client-id=' . $data1 . '&currency=' . $GLOBALS['countryCurrency'] . '&components=messages" data-partner-attribution-id="EcommerceTemplates_Ecom_PPCP"></script>'."\n";
				if(($GLOBALS['adminPayLater'] & 8)==8){
					print '<div data-pp-message data-pp-placement="product" data-pp-amount="" data-pp-style-layout="flex" data-pp-style-ratio="20x1" class="paylaterbanner detailpaylaterbanner"></div>';
				}
			}
		}
	}
	if($prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid']){
		if(getget('prod')!='' && @$GLOBALS['seodetailurls'] && @$seourlsthrow301 && ((@$_SERVER['REDIRECT_URL'].@$_SERVER['HTTP_X_ORIGINAL_URL'])=='' || ($origprodid!=trim_($rs['pStaticURL']) && trim_($rs['pStaticURL'])!=''))){
			$addand=$newqs='';
			foreach($_GET as $key=>$val){
				if($key!='prod'){ $newqs.=$addand.urlencode($key).'='.urlencode($val); $addand='&'; }
			}
			ob_end_clean();
			header('HTTP/1.1 301 Moved Permanently');
			header('Location: '.getfullurl(getdetailsurl($rs['pId'],$rs['pStaticPage'],$rs[getlangid('pName',1)],$rs['pStaticURL'],$newqs,@$GLOBALS['pathtohere'])));
			exit;
		}
		if(getget('prod')!='' && $rs['pStaticPage']!=0 && @$redirecttostatic==TRUE){
			ob_end_clean();
			header('HTTP/1.1 301 Moved Permanently');
			header('Location: '.getfullurl(cleanforurl($rs[getlangid('pName',1)]) . $GLOBALS['extension']));
			exit;
		}
		$hasstaticpage=($rs['pStaticPage']!=0);
		$catid=$rs['pSection'];
		if(@$GLOBALS['ectsiteid']!=''&&@$_SESSION['savecatid']!=''){
			if(strpos(@$_SESSION['saveprodlist'],$rs['pId'].' ')!==FALSE) $catid=$_SESSION['savecatid'];
		}
		if(getget('cat')!='' && is_numeric(getget('cat')) && getget('cat')!='0') $catid=getget('cat');
		if(getget('cat')!='' && is_numeric(getget('cat')) && getget('cat')!='0') $thecatid=getget('cat');
		$thetopts=$catid;
		$topsectionids=$catid;
		$isrootsection=FALSE;
		$GLOBALS['currcaturl']='';
		for($index=0; $index <= 10; $index++){
			if($thetopts==$GLOBALS['catalogroot']){
				$caturl=$GLOBALS['storehomeurl'];
				$sSQL='SELECT sectionID,topSection,'.getlangid('sectionName',256).',rootSection,sectionDisabled,'.getlangid('sectionurl',2048)." AS sectionurl FROM sections WHERE sectionID='" . escape_string($GLOBALS['catalogroot']) . "'";
				$result2=ect_query($sSQL) or ect_error();
				if($rs2=ect_fetch_assoc($result2)){
					$GLOBALS['xxHome']=$rs2[getlangid('sectionName',256)];
					if(trim_($rs2['sectionurl'])!='') $caturl=$rs2['sectionurl'];
				}
				ect_free_result($result2);
				$tslist='<a class="ectlink" href="'.$caturl.'">' . $GLOBALS['xxHome'] . '</a>' . $tslist;
				break;
			}elseif($index==10){
				$tslist='<strong>Loop</strong>' . $tslist;
			}else{
				$sSQL='SELECT sectionID,topSection,'.getlangid('sectionName',256).',rootSection,'.getlangid('sectionurl',2048)." AS sectionurl FROM sections WHERE sectionID='" . escape_string($thetopts) . "'";
				$result2=ect_query($sSQL) or ect_error();
				if(ect_num_rows($result2) > 0){
					$rs2=ect_fetch_assoc($result2);
					if(@$GLOBALS['dynamicbreadcrumbs'])
						$tslist='<div class="ectbreadcrumb">&raquo; ' . breadcrumbselect($rs2['sectionID'],$rs2['topSection']) . '</div>' . $tslist;
					else
						$tslist='<div class="ectbreadcrumb">&raquo; <a class="ectlink" href="' . getcategoryurl($rs2['sectionID'],$rs2[getlangid('sectionName',256)],$rs2['sectionurl'],$rs2['rootSection']) . '">' . $rs2[getlangid('sectionName',256)] . '</a></div>' . $tslist;
					if($thetopts==$catid) $GLOBALS['catname']=$rs2[getlangid('sectionName',256)];
					$thetopts=$rs2['topSection'];
					$topsectionids.=',' . $thetopts;
				}else{
					if(@$GLOBALS['ectsiteid']!=''){
						$thetopts=$GLOBALS['catalogroot'];
						$tslist='';
					}else{
						$tslist='Top Section Deleted' . $tslist;
						break;
					}
				}
				ect_free_result($result2);
			}
		}
		if(@$GLOBALS['dynamicbreadcrumbs']&&$GLOBALS['currcaturl']!=''&&@$GLOBALS['xxAlProd']!='') $tslist.='<div class="ectbreadcrumb">&raquo; <a class="ectlink" href="' . htmlspecials($GLOBALS['currcaturl']) . '">' . $GLOBALS['xxAlProd'] . '</a></div>';
		$nextid='';
		$previousid='';
		$sectionids=getsectionids($catid, FALSE);
		if(@$_SESSION['sortby']!='') $dosortby=$_SESSION['sortby'];
		if(@$dosortby==2 || @$dosortby==12 || @$dosortby==5)
			$sSortBy='';
		elseif(@$dosortby==14 || @$dosortby==15){
			$sSortBy='pSKU';
			$sSortValue="'".$rs['pSKU']."'";
		}elseif(@$dosortby==3 || @$dosortby==4){
			$sSortBy=$TWSP;
			$sSortValue=$rs['pPrice'];
		}elseif(@$dosortby==6 || @$dosortby==7){
			$sSortBy='pOrder';
			$sSortValue=$rs['pOrder'];
		}elseif(@$dosortby==8 || @$dosortby==9){
			$sSortBy='pDateAdded';
			$sSortValue="'".$rs['pDateAdded']."'";
		}else{
			$sSortBy=getlangid('pName',1);
			$sSortValue="'".escape_string($rs[getlangid('pName',1)])."'";
		}
		if(@$dosortby==4 || @$dosortby==7 || @$dosortby==9 || @$dosortby==11 || @$dosortby==12 || @$dosortby==15) $isdesc=TRUE; else $isdesc=FALSE;
		if(@$nopreviousnextlinks!=TRUE){
			$sSQL='SELECT products.pId,'.getlangid('pName',1).',pStaticPage,'.getaltlang('pStaticURL',8388608).',products.pSection FROM products LEFT JOIN multisections ON products.pId=multisections.pId WHERE (products.pSection IN (' . $sectionids . ') OR multisections.pSection IN (' . $sectionids . '))' . ($GLOBALS['useStockManagement'] && @$GLOBALS['noshowoutofstock'] ? ' AND pInStock>pMinQuant' : '') . (@$GLOBALS['ectsiteid']!='' ? ' AND pSiteID='.$GLOBALS['ectsiteid'] : '') . ' AND pDisplay<>0 AND (' . ($sSortBy!='' ? '(('.$sSortBy.'='.$sSortValue." AND products.pId>'" . escape_string($prodid) . "') OR " . $sSortBy . ($isdesc?'<':'>') . $sSortValue . ')' : 'products.pId'.($isdesc?'<':'>')."'" . escape_string($prodid) . "'") . ") AND products.pId NOT IN ('".escape_string($GLOBALS['giftcertificateid'])."','".escape_string($GLOBALS['donationid'])."') ORDER BY " . ($sSortBy!='' ? $sSortBy . ($isdesc?' DESC,':' ASC,'):'') . 'products.pId ASC LIMIT 1';
			$result2=ect_query($sSQL) or ect_error();
			if($rs2=ect_fetch_assoc($result2)){
				$nextid=@$usepnamefordetaillinks?str_replace(' ',@$detlinkspacechar,$rs2[getlangid('pName',1)]):$rs2['pId'];
				$nextidname=$rs2[getlangid('pName',1)];
				$nextidstatic=$rs2['pStaticPage'];
				$nextstaticurl=$rs2['pStaticURL'];
				$nextidcat=$rs2['pSection'];
			}
			ect_free_result($result2);
			$sSQL='SELECT products.pId,'.getlangid('pName',1).',pStaticPage,'.getaltlang('pStaticURL',8388608).',products.pSection FROM products LEFT JOIN multisections ON products.pId=multisections.pId WHERE (products.pSection IN (' . $sectionids . ') OR multisections.pSection IN (' . $sectionids . '))' . ($GLOBALS['useStockManagement'] && @$GLOBALS['noshowoutofstock'] ? ' AND pInStock>pMinQuant' : '') . (@$GLOBALS['ectsiteid']!='' ? ' AND pSiteID='.$GLOBALS['ectsiteid'] : '') . ' AND pDisplay<>0 AND (' . ($sSortBy!='' ? '(('.$sSortBy.'='.$sSortValue." AND products.pId<'" . escape_string($prodid) . "') OR " . $sSortBy . ($isdesc?'>':'<') . $sSortValue . ')' : 'products.pId'.($isdesc?'>':'<')."'" . escape_string($prodid) . "'") . ") AND products.pId NOT IN ('".escape_string($GLOBALS['giftcertificateid'])."','".escape_string($GLOBALS['donationid'])."') ORDER BY " . ($sSortBy!='' ? $sSortBy . ($isdesc?' ASC,':' DESC,'):'') . 'products.pId DESC LIMIT 1';
			$result2=ect_query($sSQL) or ect_error();
			if($rs2=ect_fetch_assoc($result2)){
				$previousid=@$usepnamefordetaillinks?str_replace(' ',@$detlinkspacechar,$rs2[getlangid('pName',1)]):$rs2['pId'];
				$previousidname=$rs2[getlangid('pName',1)];
				$previousidstatic=$rs2['pStaticPage'];
				$previousstaticurl=$rs2['pStaticURL'];
				$previousidcat=$rs2['pSection'];
			}
			ect_free_result($result2);
		}
		$extraimages=0;
		productdisplayscript(TRUE,TRUE);
		if(@$perproducttaxrate==TRUE && ! is_null($rs['pTax'])) $thetax=$rs['pTax']; else $thetax=$countryTaxRate;
		updatepricescript();
		if($emailfriendoraskquestion) displaysoftlogin();
		if(@$GLOBALS['magictoolbox']==''&&$numallgiantimages>0&&getget('review')!='true'){ ?>
<script>
/* <![CDATA[ */<?php
			print "pIX[999]=0;pIM[999]=[";
			for($index=0;$index<$numallgiantimages;$index++)
				print ($index>0?',':'')."'".encodeimage($allgiantimages[$index]['imageSrc'])."'";
			print '];'; ?>
function showgiantimage(){
<?php		if(@$GLOBALS['giantimageinpopup']){ ?>
document.getElementById('giantimgspan').style.display='';
document.getElementById('mainbodyspan').style.display='none';
displayprodimagenum(999,pIX[0]?pIX[0]:0);
document.getElementById('prodimage999').style.width='auto';
document.getElementById('prodimage999').style.maxWidth='100%';
<?php		}else{ ?>
document.getElementById('giantimgspan').style.display='';
document.getElementById('mainbodyspan').style.display='none';
displayprodimagenum(999,pIX[0]?pIX[0]:0);
<?php		} ?>
}
function hidegiantimage(){
document.getElementById('giantimgspan').style.display='none';
document.getElementById('mainbodyspan').style.display='';
return(false);
}
function showgiantrightleft(doshow){
	document.getElementById('giantimgleft').style.display=document.getElementById('giantimgright').style.display=doshow?'':'none';
}
function displayprodimagenum(theitem,imagenum){
var imlist=pIM[theitem];
pIX[theitem]=imagenum;
if(document.getElementById("prodimage"+theitem)){
	var telem=document.getElementById("prodimage"+theitem);
	var imgsrc=vsdecimg(altimage_large!=''?altimage_large:imlist[pIX[theitem]]);
	var fileext=imgsrc.split('.').pop().toLowerCase();
	telem.src='';
	if(ectisvideoext(fileext)){
		if(telem.nodeName.toUpperCase()!='VIDEO') telem=swapimgandvideoelem(telem,'video');
	}else{
		if(telem.nodeName.toUpperCase()!='IMG') telem=swapimgandvideoelem(telem,'img');
	}
	telem.src=imgsrc;
}
if(document.getElementById("extraimcnt"+theitem))document.getElementById("extraimcnt"+theitem).innerHTML=pIX[theitem]+1;
return false;
}
/* ]]> */
</script>
<?php		if(!@$GLOBALS['nogiantimagepopup']){ ?>
<div id="giantimgspan" class="ectopaque" style="display:none" onclick="if(event.target==this)hidegiantimage()" tabindex="0">
	<div class="giantimgdiv" style="display:flex;background-color:#FFFFFF;width:98%;height:97%;margin:1%;border-radius:8px;box-shadow:5px 5px 2px #666;overflow-x:auto">
<?php			if($numallgiantimages>1&&!$GLOBALS['mobilebrowser']){ ?>
		<div id="giantthumbcontainer" class="giantthumbcontainer">
			<div style="margin:13px"><span class="extraimage extraimagenum" id="extraimcnt999">1</span> <span class="extraimage"><?php print $GLOBALS['xxOf'] . ' ' . $numallgiantimages?></span></div>
			<div class="giantthumbs" style="border:1px solid grey">
				<div class="giantthumbsclose scclose" role="img" onclick="document.getElementById('giantthumbcontainer').style.display='none'" title="<?php print htmlspecials($GLOBALS['xxClsWin'])?>"></div>
<?php				for($index=0;$index<$numallgiantimages;$index++){
						if($index<$numallgiantimages){
							$imgextension=strtolower(pathinfo(($index<$numallimages?$allimages[$index]['imageSrc']:'images/ectquestionmark.png'),PATHINFO_EXTENSION));
							$isvideo=ectisvideoext($imgextension);
							print '<div class="giantthumb"><' . ($isvideo?'video ':'img ') . 'class="giantthumb" src="' . ($index<$numallimages?$allimages[$index]['imageSrc']:'images/ectquestionmark.png') . '" alt="" onclick="displayprodimagenum(999,'.$index.')"></div>';
						}
					} ?>
			</div>
		</div>
<?php			} ?>
		<div class="giantimg" style="margin:3px 10px 4px 4px;flex-grow:1">
			<div class="giantimgheader">
				<div class="giantimgclose scclose" role="img" onclick="hidegiantimage()" title="<?php print htmlspecials($GLOBALS['xxClsWin'])?>"></div>
				<div class="giantimgname" style="text-align:center;margin:9px;font-size:1.3em"><a href="#" onclick="return hidegiantimage()"><?php print $rs[getlangid('pName',1)]?></a></div>
			</div>
			<div style="position:relative;display:inline-block">
				<img class="giantimage allprodimages" id="prodimage999" src="" alt="<?php print str_replace('"', '&quot;', strip_tags($rs[getlangid('pName',1)]))?>" <?php if($numallgiantimages>1) print 'onmouseover="showgiantrightleft(true)" onmouseout="showgiantrightleft(false)" '; ?>>
<?php			if($numallgiantimages>1){ ?>
				<img id="giantimgright" src="images/ectimageright.png" style="display:none;position:absolute;bottom:40%;right:0;height:20%" onmouseover="this.style.cursor='pointer';showgiantrightleft(true)" onmouseout="showgiantrightleft(false)" onclick="return updateprodimage(999,true);" alt="PREV">
				<img id="giantimgleft" src="images/ectimageleft.png" style="display:none;position:absolute;bottom:40%;left:0;height:20%" onmouseover="this.style.cursor='pointer';showgiantrightleft(true)" onmouseout="showgiantrightleft(false)" onclick="return updateprodimage(999,false);" alt="NEXT">
<?php			} ?>
			</div>
		</div>
		<div style="clear:both;margin-bottom:10px"></div>
	</div>
</div>
<?php		}else{ ?>
<div id="giantimgspan" style="width:98%;text-align:center;display:none">
	<div><span class="giantimgname detailname"><?php print $rs[getlangid('pName',1)] . ' </span> <span class="giantimgback"><a class="ectlink" href="' . detailpageurl($thecatid!='' ? 'cat='.$thecatid : '') . '" onclick="return hidegiantimage();" >' . $GLOBALS['xxRvBack'] . '</a></span>'; ?></div>
	<div class="giantimg" style="margin:0 auto;display:inline-block">
<?php			if($numallgiantimages>1){ ?>
		<div style="text-align:center;margin-bottom:3px"><?php print imageorbutton(@$GLOBALS['imgdetailprevimg'],@$GLOBALS['xxPrImTx'],'giantprevimg','updateprodimage(999,false)',TRUE)?> <span class="extraimage extraimagenum" id="extraimcnt999">1</span> <span class="extraimage"><?php print $GLOBALS['xxOf'] . ' ' . $numallgiantimages?></span> <?php print imageorbutton(@$GLOBALS['imgdetailnextimg'],@$GLOBALS['xxNeImTx'],'giantnextimg','updateprodimage(999,true)',TRUE)?></div>
<?php			} ?>
		<div style="text-align:center"><img id="prodimage999" class="giantimage allprodimages" src="" alt="<?php print str_replace('"', '&quot;', strip_tags($rs[getlangid('pName',1)]))?>" <?php if($numallgiantimages>1) print 'onclick="return updateprodimage(999,true);" onmouseover="this.style.cursor=\'pointer\'"'; ?> style="margin:0px;"></div>
<?php			if($numallgiantimages>1){ ?>
		<div><?php print imageorbutton(@$GLOBALS['imgdetailprevimg'],@$GLOBALS['xxPrImTx'],'giantprevimg','updateprodimage(999,false)',TRUE) . '&nbsp;' . imageorbutton(@$GLOBALS['imgdetailnextimg'],@$GLOBALS['xxNeImTx'],'giantnextimg','updateprodimage(999,true)',TRUE)?></div>
<?php			} ?>
	</div>
</div>
<?php		}
		}
	}
	$optionshavestock=TRUE;
	$optjs='';
	if(count($prodoptions)>0 && @$_REQUEST['review']==''){
		if(@$usedetailbodyformat==1 || @$usedetailbodyformat=='')
			$optionshtml=displayproductoptions($optdiff,$thetax,TRUE,$hasmultipurchase,$optjs);
		else
			$optionshtml=displayproductoptions($optdiff,$thetax,TRUE,$hasmultipurchase,$optjs);
	}
	if($prodid==$GLOBALS['giftcertificateid'] || $prodid==$GLOBALS['donationid']){
		$isinstock=TRUE; $isbackorder=FALSE;
	}else{
		if($GLOBALS['useStockManagement'])
			if($rs['pStockByOpts']!=0) $isinstock=$optionshavestock; else $isinstock=$rs['pInStock']>$rs['pMinQuant'];
		else
			$isinstock=($rs['pSell']!=0);
		$isbackorder=! $isinstock && $rs['pBackOrder']!=0;
	}
	$theuagent=strtolower(@$_SERVER['HTTP_USER_AGENT']);
	$iswebbot=FALSE;
	if(strpos($theuagent,'baiduspider')!==FALSE || strpos($theuagent,'bingbot')!==FALSE || strpos($theuagent,'crawler')!==FALSE || strpos($theuagent,'duckduckbot')!==FALSE || strpos($theuagent,'exabot')!==FALSE || strpos($theuagent,'ezooms')!==FALSE 
		|| strpos($theuagent,'facebook')!==FALSE || strpos($theuagent,'googlebot')!==FALSE || strpos($theuagent,'gulliver')!==FALSE || strpos($theuagent,'ia_archiver')!==FALSE || strpos($theuagent,'infoseek')!==FALSE || strpos($theuagent,'inktomi')!==FALSE 
		|| strpos($theuagent,'mj12bot')!==FALSE || strpos($theuagent,'scooter')!==FALSE || strpos($theuagent,'sogou')!==FALSE || strpos($theuagent,'speedy spider')!==FALSE || strpos($theuagent,'yahoo!')!==FALSE || strpos($theuagent,'yandexbot')!==FALSE)
		$iswebbot=TRUE;
	if($iswebbot)
		$GLOBALS['recentlyviewed']=FALSE;
	else{
		$sSQL="UPDATE products SET pPopularity=pPopularity+1 WHERE pID='".escape_string($prodid)."'";
		ect_query($sSQL) or ect_error();
	}
	if(@$GLOBALS['recentlyviewed'] && ! ($prodid==$GLOBALS['giftcertificateid'] || $prodid==$GLOBALS['donationid'])){
		$tcnt=NULL;
		if(@$numrecentlyviewed=='') $numrecentlyviewed=6;
		$sSQL="DELETE FROM recentlyviewed WHERE rvDate<'".date('Y-m-d', time()-(60*60*24*3))."'";
		ect_query($sSQL) or ect_error();
		$sSQL="SELECT rvID FROM recentlyviewed WHERE rvProdID='".escape_string($prodid)."' AND " . (@$_SESSION['clientID']!='' ? 'rvCustomerID=' . escape_string(@$_SESSION['clientID']) : "(rvCustomerID=0 AND rvSessionID='".$thesessionid."')");
		$result2=ect_query($sSQL) or ect_error();
		if(! ($rs2=ect_fetch_assoc($result2))){
			$sSQL="INSERT INTO recentlyviewed (rvProdID,rvProdName,rvProdSection,rvProdURL,rvSessionID,rvCustomerID,rvDate) VALUES ('".escape_string($prodid)."','".escape_string($rs[getlangid('pName',1)])."',".(@$catid!=''?$catid:'0').",'".escape_string(detailpageurl((@$thecatid!=''?'cat='.$thecatid:'')))."','".$thesessionid."',".(@$_SESSION['clientID']!=''?$_SESSION['clientID']:0).",'".date('Y-m-d H:i:s')."')";
			ect_query($sSQL) or ect_error();
		}else{
			$sSQL="UPDATE recentlyviewed SET rvDate='".date('Y-m-d H:i:s')."' WHERE rvID=".$rs2['rvID'];
			ect_query($sSQL) or ect_error();
		}
		ect_free_result($result2);
		$sSQL='SELECT COUNT(*) AS tcnt FROM recentlyviewed WHERE ' . (@$_SESSION['clientID']!='' ? 'rvCustomerID=' . escape_string(@$_SESSION['clientID']) : "(rvCustomerID=0 AND rvSessionID='".$thesessionid."')");
		$result2=ect_query($sSQL) or ect_error();
		if($rs2=ect_fetch_assoc($result2)) $tcnt=$rs2['tcnt'];
		ect_free_result($result2);
		if(!is_null($tcnt)){
			if($tcnt>$numrecentlyviewed){
				$sSQL='SELECT rvID,MIN(rvDate) FROM recentlyviewed WHERE ' . (@$_SESSION['clientID']!='' ? 'rvCustomerID=' . escape_string(@$_SESSION['clientID']) : "(rvCustomerID=0 AND rvSessionID='".$thesessionid."')").' GROUP BY rvID';
				$result2=ect_query($sSQL) or ect_error();
				if($rs2=ect_fetch_assoc($result2)){
					ect_query('DELETE FROM recentlyviewed WHERE rvID='.$rs2['rvID']) or ect_error();
				}
				ect_free_result($result2);
			}
		}
	}
	if(@$usecsslayout) print '<div id="mainbodyspan" class="proddetail ' . ($pSchemaType==1?'detailarticle ':'') . trim_($pCustomCSS . ' ' . $prodid) . (getget('review')=='true'?' detailaddreview"':($GLOBALS['noschemamarkup']?'"':'" itemscope itemtype="http://schema.org/' . ($isarticle ? 'Article' : 'Product') . '"')) . '><link itemprop="mainEntityOfPage" href="' . detailpageurl('') . '">'; else print '<table id="mainbodyspan" border="0" cellspacing="0" cellpadding="0" width="100%" align="center"' . ($GLOBALS['noschemamarkup']?'':' itemscope itemtype="http://schema.org/' . ($isarticle ? 'Article' : 'Product') . '"') . '><tr><td width="100%">';
	if(getget('review')!='true' && $prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid']) print '<form method="post" id="ectform0" action="' . ($prodid==$GLOBALS['giftcertificateid'] || $prodid==$GLOBALS['donationid'] ? str_replace('"','',strip_tags(@$_SERVER['REQUEST_URI'])) : 'cart'.$GLOBALS['extension']) . '" onsubmit="return formvalidator' . $Count . '(this)" style="margin:0;padding:0">';
	if(! $GLOBALS['hascustomlayout'] && ! (@isset($showcategories) && @$showcategories==FALSE) && ! ($prodid==$GLOBALS['giftcertificateid'] || $prodid==$GLOBALS['donationid'])){
		pddprodnavigation();
		pddcheckoutbutton();
	}
	$alldiscounts='';
	if(@$nowholesalediscounts==TRUE && @$_SESSION["clientUser"]!='')
		if((($_SESSION["clientActions"] & 8)==8) || (($_SESSION["clientActions"] & 16)==16)) $GLOBALS['noshowdiscounts']=TRUE;
	if(@$GLOBALS['noshowdiscounts']!=TRUE && $prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid'] && !$isarticle){
		if(($rs['pExemptions']&64)!=64){
			$attributelist='';
			$sSQL="SELECT mSCscID FROM multisearchcriteria WHERE mSCpID='".escape_string($rs['pId'])."'";
			$result2=ect_query($sSQL) or ect_error();
			while($rs2=ect_fetch_assoc($result2)) $attributelist.=$rs2['mSCscID'].' ';
			ect_free_result($result2);
			$attributelist=str_replace(' ',"','",trim_($attributelist));
			$sSQL="SELECT DISTINCT ".getlangid("cpnName",1024)." FROM coupons LEFT OUTER JOIN cpnassign ON coupons.cpnID=cpnassign.cpaCpnID WHERE cpnNumAvail>0 AND cpnStartDate<='" . date("Y-m-d",time()) ."' AND cpnEndDate>='" . date("Y-m-d",time()) ."' AND cpnIsCoupon=0 AND " .
				"((cpnSitewide=1 OR cpnSitewide=2) OR ((cpnSitewide=0 OR cpnSitewide=4) AND cpaType=2 AND cpaAssignment='" . $rs['pId'] . "') " .
				"OR ((cpnSitewide=0 OR cpnSitewide=3 OR cpnSitewide=4) AND ((cpaType=1 AND cpaAssignment IN ('" . str_replace(',',"','",$topsectionids) . "'))" . ($attributelist!=''?" OR (cpaType=3 AND cpaAssignment IN ('".$attributelist."'))":'') . ")))" .
				' AND ((cpnLoginLevel>=0 AND cpnLoginLevel<='.$minloglevel.') OR (cpnLoginLevel<0 AND -1-cpnLoginLevel='.$minloglevel.'))';
			if(($rs['pExemptions'] & 16)==16) $sSQL.=' AND cpnType<>0';
			$result2=ect_query($sSQL) or ect_error();
			while($rs2=ect_fetch_assoc($result2))
				$alldiscounts.='<div>' . $rs2[getlangid("cpnName",1024)] . '</div>';
			ect_free_result($result2);
		}
	}
	if(@$GLOBALS['enablecustomerratings'] && getpost('review')=='true'){
		$hitlimit=FALSE;
		print '<table border="0" cellspacing="2" cellpadding="2" width="100%" align="center">';
		$sSQL="SELECT COUNT(*) as thecount FROM ratings WHERE rtDate='" . date('Y-m-d', time()) . "' AND rtIPAddress='" . escape_string(getipaddress()) . "'";
		$result=ect_query($sSQL) or ect_error();
		if($rs2=ect_fetch_assoc($result)){
			if(@$dailyratinglimit=='') $dailyratinglimit=10;
			if(! is_null($rs2['thecount'])){
				if($rs2['thecount']>$dailyratinglimit) $hitlimit=TRUE;
			}
		}
		ect_free_result($result);
		$theip=@$_SERVER['REMOTE_ADDR'];
		if($theip=='') $theip='none';
		if($theip=='none' || ip2long($theip)==FALSE)
			$sSQL='SELECT dcid FROM ipblocking LIMIT 0,1';
		else{
			$theip=ip2signedlong($theip);
			$sSQL='SELECT dcid FROM ipblocking WHERE (dcip1=' . $theip . ' AND dcip2=0) OR (dcip1 <= ' . $theip . ' AND ' . $theip . '<=dcip2 AND dcip2<>0)';
		}
		$result=ect_query($sSQL) or ect_error();
		if(ect_num_rows($result) > 0)
			$hitlimit=TRUE;
		$referer=@$_SERVER['HTTP_REFERER'];
		$host=@$_SERVER['HTTP_HOST'];
		if(strpos($referer, $host)===FALSE){
			print '<tr><td align="center">Sorry but your review could not be sent at this time.</td></tr>';
		}elseif($hitlimit)
			print '<tr><td><div class="nosearchresults">'.$GLOBALS['xxRvLim'].'</div></td></tr>';
		elseif(@$onlyclientratings && @$_SESSION['clientID']=='')
			print '<tr><td align="center">Only logged in customers can review products.</td></tr>';
		elseif(is_numeric(getpost('ratingstars')) && is_numeric(getpost('rfsectgrp1')) && is_numeric(getpost('rfsectgrp2')) && getpost('reviewposter')!='' && getpost('reviewheading')!=''){
			if((int)getpost('ratingstars')==(int)getpost('rfsectgrp1') && (int)getpost('rfsectgrp2')==strlen(@$_POST['reviewposter'])){
				$sSQL='INSERT INTO ratings (rtProdID,rtRating,rtPosterName,rtHeader,rtIPAddress,rtApproved,rtLanguage,rtDate,rtPosterLoginID,rtComments) VALUES ('
					. "'" . escape_string(strip_tags($prodid)) . "','" . (is_numeric(getpost('ratingstars')) ? escape_string((int)getpost('ratingstars') * 2) : 0) . "','" . escape_string(strip_tags(getpost('reviewposter'))) . "','" . escape_string(strip_tags(getpost('reviewheading'))) . "','" . escape_string(strip_tags(getipaddress())) . "',0,";
				if(@$languageid!='') $sSQL.=((int)$languageid-1).','; else $sSQL.='0,';
				$sSQL.="'" . date('Y-m-d', time()) . "'," . (@$_SESSION['clientID']!='' ? @$_SESSION['clientID'] : 0) . ",'" . escape_string(strip_tags(getpost('reviewcomments'))) . "')";
				ect_query($sSQL) or ect_error();
				if(($GLOBALS['adminEmailConfirm'] & 8)==8){
					$emailmessage='There has been a new customer review at your store: ' . $emlNl .
						'Product ID: ' . strip_tags($prodid) . $emlNl .
						'Rating: ' . strip_tags(getpost('ratingstars')) . $emlNl .
						'Poster: ' . strip_tags(getpost('reviewposter')) . $emlNl .
						'IP: ' . strip_tags($GLOBALS['REMOTE_ADDR']) . $emlNl .
						'Heading: ' . strip_tags(getpost('reviewheading')) . $emlNl .
						'Comments: ' . strip_tags(getpost('reviewcomments')) . $emlNl;
					dosendemail($emailAddr,$emailAddr,'','New Customer Review',$emailmessage);
				}
			}else
				$xxRvThks='Error, I\'m sorry but your review could not be recorded at this time.';
			print '<tr><td align="center">&nbsp;<br>&nbsp;<br>'.$GLOBALS['xxRvThks'].'<br>&nbsp;<br>&nbsp;';
			print $GLOBALS['xxRvRet'].' <a class="ectlink" href="' . detailpageurl($thecatid!='' ? 'cat='.$thecatid : '') . '">' . $GLOBALS['xxClkHere'] . '</a>';
			print '<br>&nbsp;<br>&nbsp;';
			print '<script>setTimeout(function(){document.location=\'' . jsescape(detailpageurl($thecatid!='' ? 'cat='.$thecatid : '')) . "'},10000)</script>";
			print '</td></tr>';
		}
		print '</table>';
	}elseif(@$GLOBALS['enablecustomerratings'] && getget('review')=='all'){
		print (@$usecsslayout ? '<div class="reviews">' : '<table border="0" cellspacing="2" cellpadding="2" width="100%" align="center"><tr><td>');
		if($psmallimage!='')
			print '<img align="middle" id="prodimage0" class="prodimage detailreviewimage allprodimages" src="'.str_replace('%s','',$psmallimage).'" alt="'.strip_tags($rs[getlangid('pName',1)]).'">&nbsp;';
		print '<span class="reviewsforprod">'.$GLOBALS['xxRvRevP'].' - </span><span class="reviewprod"' . ($GLOBALS['noschemamarkup']?'':' itemprop="name"') . '>' . $rs[getlangid('pName',1)] . '</span> - ' . imageorbuttontag(@$GLOBALS['imgreviewback'],$GLOBALS['xxRvBack'],'reviewback',detailpageurl($thecatid!='' ? 'cat='.$thecatid : ''), FALSE);
		$sSQL="SELECT rtID,rtRating,rtPosterName,rtHeader,rtDate,rtComments FROM ratings WHERE " . $GLOBALS['reviewsearchsql'];
		if(@$ratingslanguages!='') $sSQL.=' AND rtLanguage+1 IN ('.$ratingslanguages.')'; elseif(@$languageid!='') $sSQL.=' AND rtLanguage='.((int)$languageid-1); else $sSQL.=' AND rtLanguage=0';
		if(getget('ro')=='1')
			$sSQL.=' ORDER BY rtRating DESC';
		elseif(getget('ro')=='2')
			$sSQL.=' ORDER BY rtRating';
		elseif(getget('ro')=='3')
			$sSQL.=' ORDER BY rtDate';
		else
			$sSQL.=' ORDER BY rtDate DESC';
		print showreviews($sSQL,TRUE);
		print (@$usecsslayout ? '</div>' : '</table>');
	}elseif(@$GLOBALS['enablecustomerratings'] && getget('review')=='true'){
		print (@$usecsslayout ? '<div class="reviewprod">' : '<table border="0" cellspacing="2" cellpadding="2" width="100%" align="center"><tr><td>');
		print '<span class="reviewing">'.$GLOBALS['xxRvAreR'].' - </span><span class="reviewprod"' . ($GLOBALS['noschemamarkup']?'':' itemprop="name"') . '>' . $rs[getlangid('pName',1)] . '</span> - ' . imageorbuttontag(@$GLOBALS['imgreviewback'],$GLOBALS['xxRvBack'],'reviewback',detailpageurl($thecatid!='' ? 'cat='.$thecatid : ''), FALSE);
		print (@$usecsslayout ? '</div>' : '<br>&nbsp;</td></tr></table>');
	}elseif($prodid==$GLOBALS['giftcertificateid'] || $prodid==$GLOBALS['donationid']){
		$isincluded=TRUE;
		include './vsadmin/inc/incspecials.php';
	}elseif(@$usedetailbodyformat==1 || @$usedetailbodyformat==''){ ?>
			<table width="100%" border="0" cellspacing="3" cellpadding="3">
			  <tr> 
				<td width="100%" colspan="4" class="detail"> 
<?php	if(@$showproductid==TRUE) print '<div class="detailid"><strong>' . $GLOBALS['xxPrId'] . ':</strong> ' . ($GLOBALS['noschemamarkup']?'':'<span itemprop="productID">') . $rs['pId'] . ($GLOBALS['noschemamarkup']?'':'</span>') . '</div>';
		if(@$GLOBALS['xxManLab']!='' && ! is_null($rs[getlangid('scName',131072)])) print '<div class="detailmanufacturer"><strong>' . $GLOBALS['xxManLab'] . ':</strong> ' . ($GLOBALS['noschemamarkup']?'':'<span itemprop="manufacturer">') . $rs[getlangid('scName',131072)] . ($GLOBALS['noschemamarkup']?'':'</span>') . '</div>';
		if(@$showproductsku!='' && $rs['pSKU']!='') print '<div class="detailsku"><strong>' . $showproductsku . ':</strong> ' . ($GLOBALS['noschemamarkup']?'':'<span itemprop="' . $GLOBALS['skuschemaidentifier'] . '">') . $rs['pSKU'] . '' . ($GLOBALS['noschemamarkup']?'':'</span>') . '</div>';
		print '<div class="detailname"><h1' . ($GLOBALS['noschemamarkup']?'':' itemprop="name"') . '>' . $rs[getlangid('pName',1)] . '</h1>' . $GLOBALS['xxDot'];
		if($alldiscounts!='') print ' <span class="discountsapply detaildiscountsapply">' . $GLOBALS['xxDsApp'] . '</span></div><div class="detaildiscounts">' . $alldiscounts . '</div>'; else print '</div>';
		if($GLOBALS['useStockManagement'] && @$showinstock==TRUE && ($rs['pInStock']<=@$GLOBALS['stockdisplaythreshold'] || @$GLOBALS['stockdisplaythreshold']=='')){ if((int)$rs["pStockByOpts"]==0) print '<div class="detailinstock"><strong>' . $GLOBALS['xxInStoc'] . ':</strong> ' . max(0,$rs['pInStock']) . '</div>'; } ?>
				</td>
			  </tr>
			  <tr><td width="100%" colspan="4" align="center" class="detailimage allprodimages"><?php showdetailimages(); ?></td></tr>
			  <tr> 
				<td width="100%" colspan="4" class="detaildescription"><?php
		$longdesc=trim_($rs[getlangid("pLongDescription",4)]);
		if($longdesc!='')
			print '<div class="detaildescription"' . displaytabs($longdesc) . '</div>';
		elseif(trim_($rs[getlangid("pDescription",2)])!='')
			print '<div class="detaildescription"' . ($GLOBALS['noschemamarkup']?'':' itemprop="description"') . '>' . $rs[getlangid("pDescription",2)] . '</div>';
		else
			print '&nbsp;';
		print '&nbsp;<br>';
		if(count($prodoptions)>0){
			$rs['pPrice']+=$optdiff;
			if($optionshtml!='') print '<div class="detailoptions">' . $optionshtml . '</div>';
		}
		displayformvalidator();
		if($optjs!=''){
			print '<script>/* <![CDATA[ */'.$optjs.'/* ]]> */</script>';
			if($GLOBALS['mustincludepopcalendar'] && !$GLOBALS['hasincludedpopcalendar']){ print '<script>var ectpopcalisproducts=1;' . @$GLOBALS['ectpopcalendarjs'] . ($GLOBALS['storelang']!='en' && $GLOBALS['storelang']!=''?"var ectpopcallang='".$GLOBALS['storelang']."'":'') . "\r\n" . '</script><script src="vsadmin/popcalendar.js"></script>'; $GLOBALS['hasincludedpopcalendar']=TRUE; }
		}
?>				</td>
			  </tr>
			</table>
			<table width="100%" border="0" cellspacing="3" cellpadding="3">
			  <tr>
				<td><?php if(@$GLOBALS['socialmediabuttons']!='') pddsocialmedia(); else print '&nbsp;' ?></td>
				<td align="center"><?php
		if(@$noprice==TRUE){
			print '&nbsp;';
		}else{
			if((float)$rs['pListPrice']!=0.0){
				$plistprice=(@$GLOBALS['showtaxinclusive']===2 && ($rs['pExemptions'] & 2)!=2?$rs['pListPrice']+($rs['pListPrice']*$thetax/100.0):$rs['pListPrice']);
				$yousaveprice=$plistprice-(@$GLOBALS['showtaxinclusive']===2 && ($rs['pExemptions'] & 2)!=2 ? $rs['pPrice']+($rs['pPrice']*$thetax/100.0) : $rs['pPrice']);
				print '<div class="detaillistprice" id="listdivec' . $Count . '"' . ($yousaveprice<=0?' style="display:none"':'') . '>' . str_replace('%s', FormatEuroCurrency($plistprice), $GLOBALS['xxListPrice']) . (@$GLOBALS['yousavetext']!=''&&$yousaveprice>0?str_replace('%s', FormatEuroCurrency($yousaveprice), $GLOBALS['yousavetext']):'') . '</div>';
			}
			$displayprice=(@$GLOBALS['showtaxinclusive']===2 && ($rs['pExemptions'] & 2)!=2 ? $rs['pPrice']+($rs['pPrice']*$thetax/100.0) : $rs['pPrice']);
			print '<div class="detailprice"' . ($GLOBALS['noschemamarkup']?'':' itemprop="offers" itemscope itemtype="http://schema.org/Offer"><meta itemprop="priceCurrency" content="'.$GLOBALS['countryCurrency'].'">') . '<strong>' . $GLOBALS['xxPrice'].($GLOBALS['xxPrice']!=''?':':'') . '</strong> <span class="price" id="pricediv' . $Count . '"'.($rs['pPrice']!=0&&!$GLOBALS['noschemamarkup']?' itemprop="price" content="' . number_format($displayprice,2,'.','') . '"':'').'>' . ($rs['pPrice']==0 && @$pricezeromessage!='' ? $pricezeromessage : FormatEuroCurrency($displayprice)) . '</span><link itemprop="url" href="' . detailpageurl('') . '"> ';
			if(@$GLOBALS['showtaxinclusive']==1 && ($rs['pExemptions'] & 2)!=2) printf('<span class="inctax" id="taxmsg' . $Count . '"' . ($rs['pPrice']==0 ? ' style="display:none"' : '') . '>' . $GLOBALS['ssIncTax'] . '</span>','<span id="pricedivti' . $Count . '">' . ($rs['pPrice']==0 ? '-' : FormatEuroCurrency($rs['pPrice']+($rs['pPrice']*$thetax/100.0))) . '</span> ');
			schemaconditionavail();
			print '</div>';
			$extracurr='';
			if($GLOBALS['currRate1']!=0 && $GLOBALS['currSymbol1']!='') $extracurr=str_replace('%s',number_format($rs['pPrice']*$GLOBALS['currRate1'],checkDPs($GLOBALS['currSymbol1']),$GLOBALS['currDecimalSep'],$GLOBALS['currThousandsSep']),$GLOBALS['currFormat1']) . $GLOBALS['currencyseparator'];
			if($GLOBALS['currRate2']!=0 && $GLOBALS['currSymbol2']!='') $extracurr.=str_replace('%s',number_format($rs['pPrice']*$GLOBALS['currRate2'],checkDPs($GLOBALS['currSymbol2']),$GLOBALS['currDecimalSep'],$GLOBALS['currThousandsSep']),$GLOBALS['currFormat2']) . $GLOBALS['currencyseparator'];
			if($GLOBALS['currRate3']!=0 && $GLOBALS['currSymbol3']!='') $extracurr.=str_replace('%s',number_format($rs['pPrice']*$GLOBALS['currRate3'],checkDPs($GLOBALS['currSymbol3']),$GLOBALS['currDecimalSep'],$GLOBALS['currThousandsSep']),$GLOBALS['currFormat3']);
			if(@$GLOBALS['showquantitypricing']&&!$GLOBALS['hascustomlayout'])
				print pddquantitypricing();
			if($extracurr!='') print '<div class="detailcurrency"><span class="extracurr" id="pricedivec' . $Count . '">' . ($rs['pPrice']==0 ? '' : $extracurr) . '</span></div>';
		} ?>
				</td><td align="right">
<?php	if(@$nobuyorcheckout==TRUE)
			print '&nbsp;';
		else{
			if($rs['pPrice']==0 && @$nosellzeroprice==TRUE){
				print '&nbsp;';
			}elseif($isinstock || $isbackorder){
				writehiddenvar('id', $rs['pId']);
				writehiddenvar('mode', 'add');
				if($wishlistondetail) writehiddenvar('listid', '');
				if(@$showquantondetail && $hasmultipurchase==0) print '<table><tr><td align="center">' . quantitymarkup(FALSE,$Count,TRUE,'',FALSE) . '</td><td align="center">';
				if($isbackorder){
					if(@$GLOBALS['usehardaddtocart']) print imageorsubmit(@$imgbackorderbutton,$GLOBALS['xxBakOrd'],'buybutton backorder detailbuybutton detailbackorder'); else print imageorbutton(@$imgbackorderbutton,$GLOBALS['xxBakOrd'],'buybutton backorder detailbuybutton detailbackorder','subformid('.$Count.",'','')",TRUE);
				}else{
					if(@$custombuybutton!='')
						print $custombuybutton;
					else{
						if(@$GLOBALS['usehardaddtocart']) print imageorsubmit(@$imgbuybutton,$GLOBALS['xxAddToC'],'buybutton detailbuybutton'); else print imageorbutton(@$imgbuybutton,$GLOBALS['xxAddToC'],'buybutton detailbuybutton','subformid('.$Count.",'','')",TRUE);
					}
				}
				if($wishlistondetail) print '<div class="wishlistcontainer detailwishlist">' . imageorlink(@$imgaddtolist,$GLOBALS['xxAddLis'],'','gtid='.$Count.';return displaysavelist(this,event,window)',TRUE) . '</div>';
				if(@$showquantondetail && $hasmultipurchase==0) print '</td></tr></table>';
			}else{
				if(@$notifybackinstock)
					print '<div class="notifystock detailnotifystock">' . imageorbutton(@$GLOBALS['imgnotifyinstock'],$GLOBALS['xxNotBaS'],'notifystock detailnotifystock',"return notifyinstock(false,'".str_replace("'","\\'",$rs['pId'])."','".str_replace("'","\\'",$rs['pId'])."',".($rs['pStockByOpts']!=0&&!@$optionshavestock?'-1':'0').")", TRUE) . '</div>';
				else
					print '<div class="outofstock detailoutofstock">' . $GLOBALS['xxOutStok'] . '</div>';
			}
		}	  ?></td>
			  </tr>
<?php	if($previousid!='' || $nextid!=''){
			print '<tr><td align="center" colspan="4" class="pagenumbers"><p class="pagenumbers">&nbsp;<br>';
			writepreviousnextlinks();
			print '</p></td></tr>';
		} ?>
			</table>
<?php
	}else{ // if($usedetailbodyformat==2/3/4)
		if(count($prodoptions)>0){
			$rs['pPrice']+=$optdiff;
		}
		$hasformvalidator=FALSE;
		$atcmu='';
		pddoptions();
		pddaddtocart();
		foreach($customlayoutarray as $layoutoption){
			$layoutoptioncase=trim_($layoutoption);
			$layoutoption=strtolower($layoutoptioncase);
			if($layoutoption=='minquantity'){
				if($rs['pMinQuant']>0) print '<div class="detailminquant">' . str_replace('%quant%',$rs['pMinQuant']+1,$GLOBALS['xxMinQua']) . '</div>';
			}elseif($layoutoption=='navigation') pddprodnavigation();
			elseif($layoutoption=='checkoutbutton') pddcheckoutbutton();
			elseif($layoutoption=='productimage') pddproductimage();
			elseif($layoutoption=='productid') pddproductid();
			elseif($layoutoption=='manufacturer') pddmanufacturer(FALSE);
			elseif($layoutoption=='manufacturerlink') pddmanufacturer(TRUE);
			elseif($layoutoption=='sku') pddsku();
			elseif($layoutoption=='productname') pdddetailname();
			elseif($layoutoption=='discounts') pdddiscounts();
			elseif($layoutoption=='instock') pddinstock();
			elseif($layoutoption=='instockmsg') pddinstockmsg();
			elseif($layoutoption=='shortdescription') pddshortdescription();
			elseif($layoutoption=='description') pdddescription();
			elseif(substr($layoutoption,0,13)=='contentregion') pddcontentregion(substr($layoutoption,13));
			elseif($layoutoption=='catcontentregion') pddcatcontentregion();
			elseif($layoutoption=='listprice') pddlistprice();
			elseif($layoutoption=='price') pddprice();
			elseif($layoutoption=='currency') pddextracurrency();
			elseif($layoutoption=='options'){ print $optionshtml; $hasformvalidator=TRUE;
			}elseif($layoutoption=='addtocartquant'){
				print '<div class="addtocartquant detailaddtocartquant">';
				pddquantity(FALSE);
				print $atcmu . '</div>';
			}elseif($layoutoption=='quantity') pddquantity(TRUE);
			elseif($layoutoption=='addtocart') print $atcmu;
			elseif($layoutoption=='previousnext') pddpreviousnext();
			elseif($layoutoption=='emailfriend') pddemailfriend();
			elseif($layoutoption=='reviews') pddreviews();
			elseif($layoutoption=='sreviews') pddsreviews();
			elseif($layoutoption=='reviewstars') pddreviewstars(TRUE);
			elseif($layoutoption=='reviewstarslarge') pddreviewstars(FALSE);
			elseif($layoutoption=='searchwords') pddsearchwords();
			elseif($layoutoption=='quantitypricing') print pddquantitypricing();
			elseif(substr($layoutoption,0,6)=='custom') pddcustom(substr($layoutoption,6));
			elseif(substr($layoutoption,0,7)=='include') pddinclude($layoutoption);
			elseif($layoutoption=='dateadded') pdddateadded();
			elseif($layoutoption=='socialmedia') pddsocialmedia();
			elseif(trim_($layoutoption)!=''&&trim_($layoutoption)[0]=='<'){
				$layoutoption=str_replace(array('%pid%','%sku%'),array($rs['pId'],$rs['pSKU']),$layoutoptioncase);
				if($GLOBALS['wantmanufacturer']) $layoutoption=str_ireplace('%brand%',trim_($rs[getlangid('scName',131072)]),$layoutoption);
				if(preg_match('/%custom(\d+)%/i',$layoutoption,$matchnum)){
					if($rs['pCustom' . $matchnum[1]]!='')$layoutoption=preg_replace('/%custom(\d+)%/i',$rs['pCustom' . $matchnum[1]],$layoutoption);else continue;
				}
				print $layoutoption;
			}elseif(trim_($layoutoption)!='') print 'UNKNOWN LAYOUT OPTION:'.$layoutoption.'<br>';
		}
		if($isarticle&&@$GLOBALS['publisher']!='') print $GLOBALS['publisher'];
		if(! $hasformvalidator){
			$prodoptions=[];
			$optjs=$defimagejs='';
			displayformvalidator();
			if($optjs!=''){
				print '<script>/* <![CDATA[ */'.$optjs.'/* ]]> */</script>';
				if($GLOBALS['mustincludepopcalendar'] && !$GLOBALS['hasincludedpopcalendar']){ print '<script>var ectpopcalisproducts=1;' . @$GLOBALS['ectpopcalendarjs'] . ($GLOBALS['storelang']!='en' && $GLOBALS['storelang']!=''?"var ectpopcallang='".$GLOBALS['storelang']."'":'') . "\r\n" . '</script><script src="vsadmin/popcalendar.js"></script>'; $GLOBALS['hasincludedpopcalendar']=TRUE; }
			}
		}
	}
	if(getget('review')!='true' && $prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid']) print '</form>';
	if(! @$usecsslayout) print '</td></tr>';
	if(! $GLOBALS['hascustomlayout'] || @$_REQUEST['review']!='') pddreviews();
	if(@$usecsslayout) print '</div>'; else print '</table>';
	if($prodid!=$GLOBALS['giftcertificateid'] && $prodid!=$GLOBALS['donationid'])
		addtogoogleanalyticsplist($rs,$analyticsoutput,$Count+1);
} // EOF
ect_free_result($result);
if(@$GLOBALS['googletagid']!=''&&$analyticsoutput!=''){
	print '<script>gtag("event","view_item",{ currency:"' . $GLOBALS['countryCurrency'] . '",value:' . $rs['pPrice'] . ',items:[' . $analyticsoutput . ']});</script>'."\n";
}
if($defimagejs!='') print '<script>'.$defimagejs.'</script>'; ?>