<script type="text/javascript">
    $(document).ready(function(){
        $(".jqRate").live("click",function(){

           var starNo = $(this).attr("rateVal");
       //alert(starNo)    ;return false;
           $.ajax({
            url:  "<?php echo ConfigUrl::base(); ?>index/renderRate/",
            data: {
                product_id: <?php echo $this->listData[0]->nBusId;?>,
                starNo: starNo
            },
            success: function() {

               //$("#renderRate_"+starNo).text(ret);
               alert("You have successfully rated this product");
               window.location.reload();
               //$('.raterender')
               //$('.raterender').attr('disabled', true);
            }


        });
      });
        
    });
</script>

<?php
//print_r($_SESSION);echo $_SESSION['business_hit_'.$this->listData[0]->nBusId];

    if(isset($_SESSION['business_hit_'.$this->listData[0]->nBusId]) && $_SESSION['business_hit_'.$this->listData[0]->nBusId]=='Y'){
        $classToCall = 'jqNoRate';
        $cursorStyle = 'cursor: default';
    }else{
        $classToCall = 'jqRate';
        $cursorStyle = 'cursor: pointer';
        }
    
    $imagePath = '';

    if(file_exists(BASE_PATH.'uploads/image/'.$this->listData[0]->Image)==false)
    {
        $imagePath = ConfigUrl::root().'uploads/image/noimage.png';
    }
    else
    {
        $imagePath = ConfigUrl::root().'uploads/image/'.$this->listData[0]->Image;
    }


    if($this->listData[0]->Image=='')
    {
        $imagePath = ConfigUrl::root().'uploads/image/noimage.png';
        $this->listData[0]->Image = 'noimage.png';
    }
?>

<?php if(isset($this->updateMessage) && $this->updateMessage!='') { ?>

<div class="success_message"><?php echo $this->updateMessage;?></div>
<?php } ?>
<script type="text/javascript" src="<?php echo BASE_URL;?>public/js/library/swfobject.js"></script>

<?php 
if($this->listData[0]->Video <> ''){
    $video_extn     = "";
    $arrVideoExtn   = explode(".",trim($this->listData[0]->Video));
    if(is_array($arrVideoExtn) && count($arrVideoExtn) > 0){
        $video_extn     = strtolower($arrVideoExtn[count($arrVideoExtn)-1]);
    }
    
    $video      = ConfigUrl::root().'uploads/video/'.$this->listData[0]->Video;
    $swf        = 'AS3_Javascript';
    $showFlag   = true;
}else if($this->listData[0]->VideoURL!=''){
    $video  = explode("=",$this->listData[0]->VideoURL);
    $video  = $video[sizeof($video)-1];
    $swf    = 'videoplayeryoutube';
    $showFlag =true;
}
?>
<script src="<?php echo BASE_URL; ?>public/js/library/jRating.jquery.min.js" type="text/javascript"></script>
<script src="<?php echo BASE_URL; ?>public/js/library/jRating.jquery.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css"  href="<?php echo ConfigUrl::style('default');?>jRating.jquery.css" media="all" />
<script language="javascript" >
<?php if(trim($video_extn) == "flv"){ ?>
window.onload = function(){
  sendTextToAS3();
};
<?php } ?>             

    var flashvars = {};


	function sendToAS3(elem){
		var Txt = elem.value;


		var flash =	document.getElementById("as3_js");

		flash.sendTextFromJS(Txt);

	//document.getElementById('sendToFlash').value = "";
	}
	function sendTextToAS3(){
	      // var Txt = document.getElementById('htmlText').value;
               flashvars.videoid = "<?php echo $video;?>";
               var params = {};
               params.allowfullscreen = "true";
	       var attributes = {};
	       attributes.id = "as3_js";
	       swfobject.embedSWF("<?php echo BASE_URL;?>uploads/<?php echo $swf; ?>.swf", "alt", "100%", "329", "9.0.0", false, flashvars, params, attributes);
        }
</script>

<div class="cont_outer">

<div class="content_area_div">
<div>
<div class="content_area">

<div class="details_page">

	<?php if($this->listData[0]->Image=="")
	{
    ?>
	
<div  class="details_wrap2">

<div class="product_details_div_wrp2">
<h2 style="float:left "><?php echo $this->listData[0]->Title; ?></h2>

	<div style="float:right; width:108px">
		<div class="date_div">
			Posted On :<?php echo date('m/d/Y', strtotime($this->listData[0]->dPostDate)); ?> &nbsp;
		<div class="clear"></div>
		</div>
		<div>
			<?php
			 if(PRODUCT_RATE_MODE=="Y") {
			  $productRating = $this->productRating;
				if ($productRating > 0) {
					?><!--<div class="rating_<?php //echo $productRating; ?>" id="tmprate"></div>--> <?php
				} 
			} ?>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
<div class="clear"></div>

<p><?php echo $this->listData[0]->Description; ?></p>

<div class="details_controlls_wrp2">


<?php
if($this->listData[0]->nFeatured=='0')
{
?>

<div class="details_cntr_btns">

<ul>
<li><a href="<?php echo ConfigUrl::base(); ?>index/payment/">Make Featured</a></li>


</ul>
<div class="clear"></div>
</div>
    <div class="full_width">
        <p>Pay <?php echo CURRENCY.FEATURED_AMOUNT ?> to make your listing featured.</p>
        <p><em>Featured listings appear on the first page of search results , always placed above basic listings. The higher up your listing are the quicker the customers can view it.</em></p>
    </div>

<?php
}
?>

<div class="details_ratings_date lft">

<?php if(PRODUCT_RATE_MODE=="Y") {
	?>
	<!--<div class="rating_div" style="width:200px;">
		<div class="left"><strong class="rate-nw">Rating : </strong></div>
		rate-nw
		<div class="exemple">
		<!--<div class="exemple3" id="18_<?php echo $this->listData[0]->nBusId;?>?>"></div>
	</div>-->
<div class="rate_div" >
        <div class="left"><strong> Rating &nbsp;:&nbsp;</strong></div>
        <?php for($i=1;$i<=5;$i++) { ?>

            <?php if($i <= $this->productRating ) {
                $image = "star_on.png";
            } else {?>
            <?php $image = "star_off.png"; ?>
             <?php } ?>

        <span  class="renderRate <?php echo $classToCall?>" style="<?php echo $cursorStyle;?>;" id="renderRate_"<?php echo $i;?> rateVal="<?php echo $i;?>" ><img src="<?php echo ConfigUrl::images('business').$image;?>"  /></span>

            <?php } ?>
    </div>
<?php
    if ($productRating > 0) {
      ?>
	  <!--<div class="rating_<?php echo $productRating; ?>" id="tmprate"></div>--><?php } ?>

<div class="clear"></div>
<?php } ?>


<div class="clear"></div>
</div>

<div class="clear"></div>
</div>

<div class="clear"></div>
</div>

<div class="clear"></div>
</div>
<?php } else{




    ?>
<div class="full_width">
<div class="detail_cont_outer">
	<div class="row">
		<div class="col-xs-12 col-sm-5 col-md-5">
			<div class="detail_cont_L"><img alt="" src="<?php echo $imagePath;?>" class="img-responsive" ></div>
		</div>
		<div class="col-xs-12 col-sm-7 col-md-7">
			<div class="detail_cont_R">
				<h2><?php echo $this->listData[0]->Title; ?></h2>
				<div class="Posted_on">Posted On :<?php echo date('m/d/Y', strtotime($this->listData[0]->dPostDate)); ?></div>
				<div class="desc">
					<?php echo $this->listData[0]->Description; ?>
				</div>
				<div class="details_ratings_date lft">
					<?php if(PRODUCT_RATE_MODE=="Y") {
						
				   ?>
				
					<!--<div class="rating_div">
						<div class="left"> Rate &nbsp;:&nbsp;</div>
						<div class="exemple"><div class="exemple3" id="18_<?php echo $this->listData[0]->nBusId;?>?>"></div></div>
						<div class="clear"></div>    
					</div>-->
					<div class="rate_div" >
						<div class="left"><strong> Rating &nbsp; : &nbsp; </strong></div>
						<?php for($i=1;$i<=5;$i++) { ?>
				
							<?php if($i <= $this->productRating ) {
								$image = "star_on.png";
							} else {?>
							<?php $image = "star_off.png"; ?>
							 <?php } ?>
				
						<span  class="renderRate <?php echo $classToCall?>" style="<?php echo $cursorStyle;?>;" id="renderRate_"<?php echo $i;?> rateVal="<?php echo $i;?>" ><img src="<?php echo ConfigUrl::images('business').$image;?>"  /></span>
				
							<?php } ?>
					</div>
					
					
				   <?php
				   
					 $productRating = $this->productRating;
				
				  //if ($productRating > 0) {
					  ?><!--<div class="rating_<?php echo $productRating; ?>" id="tmprate"></div>--> <?php //}  ?>
				
					<?php } ?>
				<div class="clear"></div>
				</div>
				<div class="clear">&nbsp;</div>
				
				<?php
    $tableArray = array('nBusId','nUserId','nCatid','dPostDate','nStatus','nFeatured','Title','Description','Image','Video','VideoURL','Zipcode','Address','Country','maxSearches');
      $fileExt    = array('txt','doc','pdf','xls');
    ?>
	
	<div class="full_width">
		<div class="detail_page_txt_bg">
		<div class="row">
        <div class="col-xs-12">
            <?php if($this->listData[0]->Address<>""){ ?>
            <div class="detail_page_txt_bg_inner">
				<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>Address</b></div>
				<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_R"><?php echo $this->listData[0]->Address; ?></div>
			<div class="clear"></div>
			</div>
            <?php } ?>
            
            <?php /*foreach($this->listData[0] as $product => $val )
                    {
                        if(!in_array($product,$tableArray))
                        {
                            if($val<>"")
                            {
                                $valFile = explode('.',$val);
                                if(in_array($valFile[sizeof($valFile)-1],$fileExt))
                                    echo '<div class="detail_page_txt_bg_inner"><td width="50%"><b>'.$product.'</b></td><td><a href="'.ConfigUrl::root().'uploads/doc/'.$val.'" target="_blank">Download</a></td></div>';
                                else
                                    echo '<div class="detail_page_txt_bg_inner"><td width="50%"><b>'.$product.'</b></td><td>'.$val.'</td></div>';
                            }
                        }
                    }*/
					foreach($this->listData[0] as $product => $val )
                    {
//                /echo $this->fieldtype[$product];
                        if(!in_array($product,$tableArray))
                        {//echopre($product);
                            if($val<>"")
                            {
                                if(isset($this->listingFields[$product]) && $this->listingFields[$product]!=''){
                                    $valFile = explode('.',$val);
                                    if(in_array($valFile[sizeof($valFile)-1],$fileExt))
                                        echo '<div class="detail_page_txt_bg_inner">
											<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>'.$this->listingFields[$product].'</b></div>
											<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R"><a href="'.ConfigUrl::root().'uploads/doc/'.$val.'" target="_blank">Download</a></div>
											<div class="clear"></div>
										</div>';
                                    else{ echo"<br>type:", $this->fieldtype[$product];
                                        if($this->fieldtype[$product]=='1'){
                                           $link_type    =   explode(':',$val);
                                           if($link_type[0]=='http' OR $link_type[0]=='https' ){
                                                $url_link   =$val;
                                            }
                                            else{
                                                $url_link   ='http://'.$val;
                                            }
                                            echo '<div class="detail_page_txt_bg_inner">
												<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>'.$this->listingFields[$product].'</b></div>
												<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R"><a href="'.$url_link.'" target="_blank">'.$url_link.'</a></div>
											<div class="clear"></div>
											</div>';
                                        }
                                        else{
                                            echo '<div class="detail_page_txt_bg_inner">
												<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>'.$this->listingFields[$product].'</b></div>
												<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R">'.$val.'</div>
											<div class="clear"></div>
											</div>';
                                        }
                                    }
                                }
                            }
                        }
                        else{
                            if($val<>"")
                            {
                              $tbl_array=array('Zipcode','Address','Country');
                              if(in_array($product,$tbl_array)){
                                //echo '<tr><td width="50%"><b>'.$product.'</b></td><td>'.$val.'</td></tr>'; 
                                 if($this->fieldtype[$product]=='1'){
                                    $link_type    =   explode(':',$val);
                                           if($link_type[0]=='http' OR $link_type[0]=='https' ){
                                                $url_link   =$val;
                                            }
                                            else{
                                                $url_link   ='http://'.$val;
                                            }
                                            echo '<div class="detail_page_txt_bg_inner">
												<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>'.$product.'</b></div>
												<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R"><a href="'.$url_link.'" target="_blank">'.$url_link.'</a></div>
											<div class="clear"></div>
											</div>';
                                }
                                else{
                                    if($product=='Country'){
                                        global $countries;
                                        echo '<div class="detail_page_txt_bg_inner">
											<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>'.$product.'</b></div>
											<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R">'.$countries[$val].'</div>
										<div class="clear"></div>
										</div>';
                                    }
                                    else{
                                         echo '<div class="detail_page_txt_bg_inner">
										 	<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>'.$product.'</b></div>
											<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R">'.$val.'</div>
										<div class="clear"></div>
										 </div>
										 ';
                                    }
                                   
                                }
                              }
                            }
                        }
                    }
             ?>
            
            <?php $paymentStatus = $this->listData[0]->nPaymentStatus == 'P' ? 'Paid' : 'Not Paid';?>
            <div class="detail_page_txt_bg_inner">
				<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>Payment Status</b></div>
				<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R"><?php echo $paymentStatus ?></div>
			<div class="clear"></div>
			</div>
            
            <?php $isFeatured = $this->listData[0]->nFeatured == '1' ? 'Yes' : 'No';?>
            <div class="detail_page_txt_bg_inner">
				<div class="col-xs-12 col-sm-6 col-md-5 detail_page_txt_bg_L"><b>Featured</b></div>
				<div class="col-xs-12 col-sm-6 col-md-7 detail_page_txt_bg_R"><?php echo $isFeatured; ?></div>
			<div class="clear"></div>
			</div>
        </div>
		<div class="clear"></div>
   		</div>
		<div class="clear"></div>
    </div>
		<div class="clear"></div>
    </div>
				
				
			</div>
		</div>
	</div>
</div>



<div class="product_details_div">
 	 

<div class="full_width">

<?php
if($this->listData[0]->nFeatured=='0')
{
?>


<div class="details_cntr_btns">

<ul>
<li><a href="<?php echo ConfigUrl::base(); ?>index/payment/">Make Featured</a></li>
<li></li>

</ul>
<div class="clear"></div>
</div>
<div class="full_width">
	<p>Pay <?php echo CURRENCY.FEATURED_AMOUNT ?> to make your listing featured.</p>
	<p><em>Featured listings appear on the first page of search results , always placed above basic listings. The higher up your listing are the quicker the customers can view it.</em></p>
</div>


<?php
}
?>




<div class="date_div" style="float:left;">
   
<div class="clear"></div>
</div>


<div class="clear"></div>
</div>

<div class="clear"></div>
</div>

<div class="clear"></div>
</div>


<div class="clear"></div>
</div>
<div class="clear">&nbsp;</div>
<?php
}
?>
<div class="row">
<?php
$map_flag = false;
if(trim($this->listData[0]->Zipcode) <> ''){
    $location = trim($this->listData[0]->Zipcode);
    $map_flag = true;
}
elseif(trim($this->listData[0]->Address) <> ''){
    $location = trim($this->listData[0]->Address);
    $map_flag = true;
}

if($this->isValidZip > 0){
    ?>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&key=<?php echo MAP_API_KEY; ?>"></script>
    <script type="text/javascript">
      var geocoder;
      var map;

      var disp_address = '<?php echo trim(preg_replace('/\s\s+/', ', ', $this->listData[0]->Address)).', '.$this->listData[0]->Zipcode; ?>';

      function initialize() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var mapOptions = {
          zoom: 12,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
        codeAddress();
      }

      function codeAddress() {
        var address = '<?php echo trim(preg_replace('/\s\s+/', ', ', $location)); ?>';
        geocoder.geocode( { 'address': address}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            map.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });

            var infoWindow = new google.maps.InfoWindow();
            var html='<b><u>Address</u></b><br />'+disp_address;
            google.maps.event.addListener(marker, 'click', function() {
                infoWindow.setContent(html);
                infoWindow.open(map, marker);
            });
          }
        });
      }
    </script>
	<div class="col-xs-12 col-sm-12 col-md-6">
	    <div id="map_canvas" style="width:100%; height:320px; margin:0;"></div>
	</div>
    <script type="text/javascript">
        initialize();
    </script>
    <?php
}
if(isset($showFlag)){
?>
<div class="col-xs-12 col-sm-12 col-md-6">
  
<?php  
if(trim($video_extn) == "mp4" || trim($video_extn) == "webm" || trim($video_extn) == "ogv"){ 
    if(trim($video) <> ""){
?>
<div>
    <video width="100%" height="320" controls>
<source src="<?php echo $video; ?>" type="video/mp4">
<!--<source src="movie.ogg" type="video/ogg">-->
</video> 
</div>
<div class="clear">&nbsp;
    </div>
<?php 
    }
}else{ ?>
<!--------VIDEO PLAYER------------>




<div class="js"  >

</div>

<div class="as3" style="float:left">
	<div id="alt"></div>
</div>



<!--------VIDEO PLAYER------------>
<?php } ?>

</div>
    <?php }?>
   <div class="clear"></div>
    
</div>


    

<!-- Details Comment Section Start -->
<?php if(PRODUCT_COMMENT_MODE=="Y") {?>
<div class="comment_section">
<h2>Comments</h2>
<ul>
<?php //print_r($this->productComment);
if(sizeof($this->productComment)>0)
{
foreach ($this->productComment as $comment)
{
?>

<li>

<div class="commet_list">
<p><?php echo $comment->vComment; ?></p>
<div class="commtz_by">
<h5><span>Posted By </span>: <?php echo $comment->vName; ?></h5>
<h6></h6>
</div>

<div class="clear"></div>
</div>

</li>
<?php }
}
else
{
    echo "Sorry No Records Found !!!";
}
?>

</ul>



<div class="clear"></div>
</div>

<!-- Details Comment Section End -->


<!--  start paging..................................................... -->
         <?php if($this->pageCount > 1){  ?>

		 <div class="pagination">
           <ul>
       		<li><a href="<?php echo ConfigUrl::base()?>index/viewlisting/<?php echo $this->alias;?>/1/" class="page_first" >First</a></li>
           	<li><a class="page_prev" href="<?php echo ConfigUrl::base()?>index/viewlisting/<?php echo $this->alias;?>/<?php if($this->page != 1) echo $this->page - 1; else echo $this->page; ?>/" >Previous</a></li>
            <li class="pageinfo"><div id="page-info">Page <strong><?php echo $this->page; ?></strong> / <?php echo $this->pageCount; ?></div></li>
         	<li><a class="page_next" href="<?php echo ConfigUrl::base()?>index/viewlisting/<?php echo $this->alias;?>/<?php if($this->pageCount != $this->page) echo  $this->page + 1; else echo $this->pageCount; ?>/" >Next</a></li>
            <li><a class="page_last" href="<?php echo ConfigUrl::base()?>index/viewlisting/<?php echo $this->alias;?>/<?php echo $this->pageCount; ?>/" >Last</a></li>
            </ul>
		<div class="clear"></div>
		</div>
        <?php
        }
       
       ?>

<div class="clear"></div>
</div>
<?php } ?>




<div class="clear"></div>
</div>

</div>
<div class="clear"></div>
</div>



<div class="clear"></div>
</div>


 <script>



<?php 
  if($this->tmp_rate_flag=='set')
  { ?>
  var customWidthForSelection= <?php echo $this->tmp_rate_count; ?>;
      customWidthForSelection = customWidthForSelection*23;
 <?php
  }
  else
  { ?>

              var customWidthForSelection=0;

 <?php
  }
 ?>


$(document).ready(function(){

//alert(customWidthForSelection);
			$('.exemple3').jRating({
				step:true,
				length : 5,
                                decimalLength : 0,
                                bigStarsPath: '<?php echo ConfigUrl::images();?>stars.png',
                                smallStarsPath:'<?php echo ConfigUrl::images();?>small.png',
                                phpPath: '<?php echo ConfigUrl::base(); ?>index/saverate/'
			});

  <?php
  if($this->tmp_rate_flag=='set')
  { ?>
 $('.exemple3').unbind().css('cursor','default').addClass('jDisabled');
 <?php
  }
 ?>


		});


function setRate(starNo){
        //alert(template_id);alert(page_id);exit;
        //$('#template_id').val(template_id);
        //$(".template_class").removeClass("selected_template");
       // $("#template_"+template_id).addClass("selected_template");
       // showAjaxLoader($("#html_content"));
        $.ajax({
            url:  "<?php echo ConfigUrl::base(); ?>index/renderRate/",
            data: {
                product_id: <?php echo $this->listData[0]->nBusId;?>,
                starNo: starNo
            },
            success: function(ret) {

               //$("#renderRate_"+starNo).text(ret);
               alert("Successfully Posted");
               window.location.reload();
               //$('.raterender')
               //$('.raterender').attr('disabled', true);
            }


        });

    }
    function disableLink(e) {
    // cancels the event
    e.preventDefault();

    return false;
}
    <?php
  if($_SESSION['business_hit_'.$this->listData[0]->nBusId]=='Y')
  { ?>
 //$('.renderRate').bind('click', disableLink);
 //$('.renderRate').unbind('click');
 //$('.renderRate').attr('disabled', true);
 //$('.renderRate').attr('style', 'cursor: default');
 <?php
  }
 ?>

</script>