<?php
if (env('HTTPS')) {
    $lnk= $html->url('/index.php');
    $lnk = "http://".$_SERVER["HTTP_HOST"]. $lnk;
    header("Location:$lnk");
}
?><?php echo $javascript->link('jquery.js'); ?>
<?php echo $javascript->link('jquery.colorbox.js'); ?>
<script type="text/javascript">
    var cnt = <?php echo count($imgList); ?>;
    $(function(){
        for(var i = 1; i <= cnt; i++){
            $(".colorbox-"+i).colorbox({rel:'colorbox-'+i});
        }        
    });
    
    function loadFbCustPop(design_id){

        var mlink="<?php echo $cnfg["sitebasefolder"]; ?>/customimages/custominvitation/"+design_id;
        $.colorbox({width:"650px", height:"500px", iframe:true, href:mlink, overlayClose: false});

    }
</script>
<script type='text/javascript'>
    function gotopage(elem, url){
        //alert($(elem).attr('href'));
       // $(elem).attr('href', url);
      // alert(url);
        window.location.href = url;
    }
    $(window).load(function() {
      $(".pluginButton").css({"font-weight":"normal"});
});
</script>
<style>
    .pluginButton{
        font-size:5px !important;
    }
</style>
<?php
if (isset($facebookKey['facebook_app_id']) && !empty($facebookKey['facebook_app_id'])) {
    ?>
    <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 = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=363832800488923&version=v2.0";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script> 
<?php } ?>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>    
<?php if($session->check('Message.flash')) { ?><div class="home_error"><font color="#078402"><?php $session->flash(); ?></font></div><?php }
    
    foreach($right_sec as $val) {
        switch($val[$tblindex]['prod_type']) {
            case 'featured':
                $layoutTitle= ($Content_Heder)?strip_tags($Content_Heder):"";
                ?> 
<!--Featured products -->    
<div class="content_fulcol1">
<div class="wrapper row"> 
<div class="content_container">
<div class="row">
    <div class="twelve columns">
            <div class="content_header_txt">
                <h3><?php echo $layoutTitle; ?></h3>
                <a class="viewall_rounded" href="<?php echo $html->url('/products/allproducts'); ?>">View All <i class="fa fa-chevron-circle-right"></i>
</a>
            </div>
            <div class="content_header_viewall">
                
            </div>
                        <div class="to_be_altered">
                            <?php
                            $i = 0;
                            foreach ($featuredProducts as $ft) {
                                $i++;
                                ?>
                                <!-- Single product area starts here-->
                                <div class="four columns">
                                    <div class="home_product_box">
                        
                                        <div class="list_img">
                                            <?php
                                            $pure_product_name = cleanspecialchars($ft["Product"]["pname"]);
                                            $productnamealias = productnamealias($ft["Product"]["pname"]);
                                            $url = 'products/show/' . $pure_product_name . '/' . $ft["Product"]["id"];
                                            if (isset($ft["Productimages"]) && $ft["Productimages"] <> '') {
                                                $img = explode(".", $ft["Productimages"]);
                                                $ext = '.' . end(explode(".", $ft["Productimages"]));
                                                if (!empty($img[0]) == true) {
                                                    ?>
                                                    <a href='#' class="preview" onclick="gotopage(this, '<?php echo $url; ?>')">
                                                        <?php
                                                        if (file_exists(WWW_ROOT . IMAGES_URL . '/products/' . $img[0] . $ext)) {
                                                            echo $html->image('/img/products/' . $img[0] . "_disp" . $ext, array('border' => '0', 'class' => 'img_listing'));
                                                        } else {
                                                            echo $html->image('/img/noimages.gif', array('border' => '0', 'class' => 'img_listing'));
                                                        }
                                                        ?>
                                                    </a>
                                                <?php }
                                            } else {
                                                ?>
                                                <a href='#' onclick="return redirectPage('<?php echo $url; ?>');">
                                                <?php echo $html->image('/img/noimages.gif', array('border' => '0', 'class' => 'img_listing')); ?>
                                                </a>
                                            <?php } ?>
                                        </div>
                                        <div class="list_desc">
                                            <?php
//Setting the Prices & Discount for Wholesale/Retail Users
                                            $prod_price = 0;
                                            $discnt_type = '';
                                            $discnt_price = 0;
                                            if ($ft["Product"]["wholesale_price"] > 0 || $ft["Product"]["price"] > 0) {
                                                if (isset($ft["Product"]["discount"]) && $ft["Product"]["discount"] > 0) {
                                                    $discnt_type = $ft["Product"]["discount_type"];
                                                    $discnt_price = $ft["Product"]["discount"];
                                                }
                                            }
                                            if (isset($ft["Product"]["price"]))
                                                $retail_price = $ft["Product"]["price"];
                                            $utype = 'normal';
                                            display_price($utype, $retail_price, $discnt_type, $discnt_price, $curlogo);
                                            ?>
                                        </div>
                                        <div class="clear"></div>
                                        <div class="list_name">
                                            <?php
                                            $prodname = $pure_product_name;
                                            if (strlen($prodname) > 20) {
                                                $prodname = substr($prodname, 0, 20) . "...";
                                                ?>
                                                <a href="<?php echo $html->url('/products/show/' . $pure_product_name . '/' . $ft["Product"]["id"]); ?>" class="" title="<?php echo $ft["Product"]["pname"]; ?>"><?php echo (strlen($ft["Product"]["pname"]) > 20)?substr($ft["Product"]["pname"], 0, 20) . "...":$ft["Product"]["pname"]; ?></a>
                                                <?php
                                            } else {
                                                ?>
                                                <a href="<?php echo $html->url('/products/show/' . $pure_product_name . '/' . $ft["Product"]["id"]); ?>"><?php echo (strlen($ft["Product"]["pname"]) > 20)?substr($ft["Product"]["pname"], 0, 20) . "...":$ft["Product"]["pname"]; ?></a>
                                            <?php } ?>
                                        </div>
                                        <div class="list_link01">
                                           <!-- <a href="<?php echo $html->url('/products/show/' . $pure_product_name . '/' . $ft["Product"]["id"]); ?>" ><span>Product Details</span></a>-->
                                            <?php
                                            if (isset($facebookKey['facebook_app_id']) && !empty($facebookKey['facebook_app_id'])) {
                                                ?>
                                                <div class="fb-like" data-href="<?php echo $html->url('http://' . $_SERVER['HTTP_HOST'] . $cnfg["sitebasefolder"] . '/products/show/' . $pure_product_name . '/' . $ft["Product"]["id"]); ?>" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true" colorscheme='light'></div>
                                                <?php
                                            }
                                            ?> 
                <?php if (isset($twitterKey['tweet_status']) && $twitterKey['tweet_status'] == 'Y') { ?>
                                                <div class="tweetbutton"> 
                                                    <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo $pure_product_name; ?>" data-url="<?php echo FULL_BASE_URL . $html->url('/products/show/' . $pure_product_name . '/' . $ft["Product"]["id"]); ?>" data-counturl="<?php echo FULL_BASE_URL . $html->url('/products/show/' . $pure_product_name . '/' . $ft["Product"]["id"]); ?>" data-via="<?php echo $cnfg['site_name'] ?>">Tweet</a>
                                                     <!--<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php //echo $pure_product_name;  ?>" rel="canonical" data-counturl="<?php //echo FULL_BASE_URL.$html->url('/products/show/'.$pure_product_name.'/'.$ft["Product"]["id"]);  ?>" rel="me" >Tweet</a>-->
                                                </div>
                                        <?php } ?>
                                        </div>
                            
                            
                                    </div>
                                </div>
                <?php }
            ?>
                </div>
                </div>    
    <div class="clear"></div>
    </div>
  </div>
 </div>
</div>
 <!--Featured products ends here -->
<?php
   break;
case 'designed':
   $layoutTitle='design';
   ?>
<!--Designed products -->
<div class="content_fulcol2">
<div class="wrapper row"> 
<div class="content_container">
<div class="row">
        <div class="four columns">
            <div class="content_header">
            <div class="designed_hd_icon">
            </div>
            <div class="content_header_txt">
                <h3><?php echo  $Templates_Heder= ($Templates_Heder)?strip_tags(trim($Templates_Heder)):"Designed Products";?></h3>
                <div class="clearfix"></div>
                <a class="viewall_rounded" href="<?php echo $html->url('/products/alltemplates'); ?>">View all <i class="fa fa-chevron-circle-right"></i>
                </a>
            </div>
        </div>
    </div>
    <div class="eight columns">
     <div class="to_be_altered sidefix">
    <!--- If Starting -->   
    <?php if($imgList && $Templates_status=='Y'){ ?>
 
      <div class="content_box_1">
      <div class="row">
            <?php
                    $i = 0;  $cnt = 1; 
                    foreach($imgList as $key=>$userdes) { if($cnt<7){
                      //  print_r($imgList);
                        $tstamp = explode("_",$userdes['id']);
                        $i++;  ?>
        <!-- Single product area starts here-->
        <div class="six columns">
        <div class="home_product_box">

            <div class="list_img"><a href="<?php echo $html->url('/products/show_template/'.$userdes['pid'].'/'.$userdes['fid']); ?>">
                <?php
               
                          
                                 
               
                                       
                        if(file_exists(WWW_ROOT.IMAGES_URL.'/'.$userdes['Front'])) {
                                                echo $html->image('/img/'.$userdes['Front'],array('border' => '0', 'class' => 'img_listing'));
                                            }
                                            else {
                                                echo $html->image('/img/noimages.gif',array('border' => '0', 'class' => 'img_listing'));
                                            }
                                            ?>
               
                                           
                                   
                                    
         </a>   </div>

            <div class="list_name">
                                <?php 
                $prodname=$userdes['template_name'];
                if(strlen($prodname)>20) {
                    $prodname=substr($prodname, 0, 20)."..."; ?>
                <a href="<?php echo $html->url('/products/show_template/'.$userdes['pid'].'/'.$userdes['fid']); ?>" title="<?php echo $ft["Product"]["pname"]; ?>"><?php echo $prodname; ?></a>
                                    <?php
                                }
                                else { ?>
                <a href="<?php echo $html->url('/products/show_template/'.$userdes['pid'].'/'.$userdes['fid']); ?>"><?php echo $prodname; ?></a>
                    <?php } ?>
            </div>
 <div class="list_link01">
               <!-- <a href="<?php echo $html->url('/products/show/'.$pure_product_name.'/'.$ft["Product"]["id"]); ?>" ><span>Product Details</span></a>-->
                <?php
                if(isset($facebookKey['facebook_app_id']) && !empty($facebookKey['facebook_app_id'])) {
                    ?>
                <div class="fb-like" data-href="<?php echo $html->url('http://'.$_SERVER['HTTP_HOST'].$cnfg["sitebasefolder"].'/products/show_template/'.$userdes['pid'].'/'.$userdes['fid']);?>" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true" ></div>
                    <?php
                }
                 ?>
                 <?php if(isset($twitterKey['tweet_status']) && $twitterKey['tweet_status']=='Y') { ?>
                <div class="tweetbutton">
     <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo $prodname; ?>" data-url="<?php echo $html->url('http://'.$_SERVER['HTTP_HOST'].$cnfg["sitebasefolder"].'/products/show_template/'.$userdes['pid'].'/'.$userdes['fid']);?>" data-counturl="<?php echo $html->url('http://'.$_SERVER['HTTP_HOST'].$cnfg["sitebasefolder"].'/products/show_template/'.$userdes['pid'].'/'.$userdes['fid']);?>" data-via="<?php echo $cnfg['site_name']?>">Tweet</a>
                </div>
                     <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
                
                                    <?php } ?>
            </div>
       



            <div class="list_link01">
              
               
            </div>

        </div>
        </div>
                <?php
$cnt++;
if($cnt > 2)break;
                    } } ?>



        <div class="clear"></div>
    </div>
   <?php  } ?> 
 </div>
                        
                    </div>
    <div class="clear"></div>
  </div>
  </div>
 </div>
</div>
</div>
 <!--Designed products ends here -->
 
     
     
     
     
     
     
     
     
 <?php
   break;
case 'promotion':
   $layoutTitle='promotion';
   ?>
 
<?php /* Old Right portion
      foreach($left_sec as $val)
      {
          switch($val[$tblindex]['prod_type']){
              case 'testimonial':                        
                        
?>
<section class="parallax">
            <div class="wrapper row"> 
                <div class="row">
                    <?php if($testimonial_status <> 'N') {?>
                    <div class="four columns text-center">
                        <div class="testimonial_sec">
                            <div class="testimonial_sec_usericon">
                                <i class="fa fa-user"></i>
                            </div>
                        
                            <h3>Testimonials</h3>
                            <p><i class="fa fa-quote-left"></i>  <?php
    $testimonial = preg_replace('/<[^>]*>/', '', $testimonial); // strip formatting
    echo substr($testimonial,0,200)."......";
                    ?>
                <br>
                <span class="testi_name"></span></p>
                <?php
    if(strlen($testimonial) > 200) {
        ?>
            <div class="list_link2">
                <a href="<?php echo $html->url('/cmspages/testimonials/'); ?>" class="text_link_3">View More</a>
            </div>
        <?php
    }
    ?>
                        </div>
                    </div>
                        <?php } break;
              
             case 'specialoffer':
                        $layoutTitle='Special Offer';
      ?>
                    <div class="four columns text-center">
                            <?php if($special_offer <> 'N') {?>
    <div class="comm_side_module">
    <?php 
        if(trim($special_offer_banner) <> '') echo $html->image('/img/'.$special_offer_banner);
    else echo $html->image("/img/$style/img_shipping.jpg");
            ?>
    </div>
            <?php }?>
                    </div>

<?php  break;  case 'service': ?>                    
                    <div class="four columns text-center">
                          <?php  if($service_status <> 'N') {
                      $serviceDat   = str_replace("[sitebase_folder]", $cnfg['sitebasefolder'], $service);
                      echo $serviceDat;
                     } ?>
                    </div>
<?php break;  ?>
                </div>
            </div>
</section>
<?php  } //switchcase  ?>      
<?php  } //foreach   */  //Old Right portion ?>     
 


 

    <?php
   break;
case 'category':
   $layoutTitle='Categories';
   ?>
 
 <!-- category starts here -->
 <div class="content_fulcol1 home_cagegory_sec_outer">
<div class="wrapper row"> 
<div class="content_container">
<div class="row">
    <div class="twelve columns">
                    <div class="content_header_txt"><h3><?php echo $layoutTitle ?></h3>
                         <a class="viewall_rounded" href="<?php echo $html->url('/categories/allcategories'); ?>">View All <i class="fa fa-chevron-circle-right"></i>
</a>
                    </div>
        <div class="to_be_altered sidefix">
                    <?php
        if(count($homcat)>0){
        ?>
        
	<div class="twelve columns">
    <div class="content_box_2 home_cat_rt">
        <div class="home_cat_listing">
            <?php
            $i=0;
				foreach($homcat as $ct) {
                $i++; 
                ?>

                <div class="three columns">
                    <div class="home_cat_icon">
						<div class="home_cat_icon_inner">
                                <?php if(isset($ct["Category"]["cimage"])&& $ct["Category"]["cimage"] <> NULL) {//echo $ct["Category"]["cimage"];
                                    $pathInfo = pathinfo($ct["Category"]["cimage"]);  
                                    $pathCount = explode(".",$pathInfo['basename']);
                    if(count($pathCount) > 1){?>
                        <a href="<?php echo $html->url('/categories/show_cat/'.$ct["Category"]["cname"].'/'.$ct["Category"]["id"]); ?>"><?php echo $html->image('/img/categoryimages/'.$ct["Category"]["cimage"]);?></a>
                    <?php
                    }else{
                        ?>
                        <a href="<?php echo $html->url('/categories/show_cat/'.$ct["Category"]["cname"].'/'.$ct["Category"]["id"]); ?>"><?php echo $html->image('/img/noimagessmall.gif',array('border' => '0'));?></a>
                    <?php }
                     }else {?>
                        <a href="<?php echo $html->url('/categories/show_cat/'.$ct["Category"]["cname"].'/'.$ct["Category"]["id"]); ?>"><?php echo $html->image('/img/noimagessmall.gif',array('border' => '0'));?></a>
                                            <?php } ?>
	                    </div>
					</div>
					<div class="clear"></div>
                    <div class="home_cat_link">
                        <a href="<?php echo $html->url('/categories/show_cat/'.$ct["Category"]["cname"].'/'.$ct["Category"]["id"]); ?>"><?php echo $ct["Category"]["cname"];?></a>
                    </div>
                </div>


                <?php if($i % 4 == 0) { ?>
                    <?php }
            }
            ?>
            <?php while($i % 4 <> 0) {
                                $i++;?>
                <div></div>
                                <?php }  ?>
        </div>
		<div class="clear"></div>
    </div>
	</div>

        <?php
        }
        else{
            ?>
            <div class="list_name">No Category to Display!<br/></div>
        <?php
        }
        ?>
        
        
    <div class="content_box_shadow"></div>
            <?php
            break;
        }
        ?>
        </div>
                </div>    
    <div class="clear"></div>
    </div>
  </div>
 </div>
</div>
 <!-- category ends here -->
<?php  } ?>

 <!--Right part-> testimonials, features -->
 <section class="parallax">
      <div class="wrapper row"> 
              <div class="row">
                  
              <div class="five columns text-center">
                  <div class="testimonial_sec">
                            <div class="testimonial_sec_usericon">
                                  <i class="fa fa-comments-o"></i>
                              </div>
                        <div class="testimonial_contentsec">
                                <h3> <a href="<?php echo $html->url('/cmspages/testimonials/'); ?>">Testimonials</a></h3>
                                  <p><i class="fa fa-quote-left"></i>  <?php
             $testimonial = preg_replace('/<[^>]*>/', '', $testimonial); // strip formatting
             echo substr($testimonial, 0, 200) . "......";
              ?>
                                      <br>
                                      <span class="testi_name"></span>
                                        <div class="clearfix"></div>
                                      </p>
                                  <?php
                                  if (strlen($testimonial) > 200) {
                                      ?>
                                      
                                      <?php
                                  }
                                  ?>
                        </div>
                      
                  </div>
                  <div class="clearfix"></div>
              </div>
              <div class="three columns text-center">
                  <?php
                  $serviceDat = str_replace("[sitebase_folder]", $cnfg['sitebasefolder'], $service);
                  echo $serviceDat;
                  ?>
              </div>
                  
              <div class="four columns text-center">
                  <div class="comm_side_module">
                      <?php
                      if (trim($special_offer_banner) <> '')
                          echo $html->image('/img/' . $special_offer_banner);
                      else
                          echo $html->image("/img/$style/img_shipping.png");
                      ?>
                  </div>
              </div>                  

          </div>
      </div>
  </section>  
 <!-- Right part ends here -->
    

<?php
//Function to display price for Wholesale and Retail Users
function display_price($utype='',$prod_price='',$discnt_type='',$discnt_price='',$curlogo='') {
    if($utype=='wholesale'){
        //echo "<b>Wholesale Price : </b>";
		}
    else if($utype=='retail'){
        //echo "<b>Price : </b>";
		}
    else if($utype=='normal'){
       // echo "<b>Price : </b>";
}
    if(isset($discnt_type) && $discnt_type <> '') {
        if($discnt_type=='per') {
            if(isset($discnt_price) && $discnt_price <> '' && $discnt_price > 0) {
                $discounted_price=($prod_price-(($prod_price * $discnt_price)/100));
                echo "<strike>".$curlogo.number_format($prod_price,2)."</strike>"."<span>".$curlogo.number_format($discounted_price,2)."</span>";
            }
        }
        else if($discnt_type=='amnt') {
            if(isset($discnt_price) && $discnt_price <> '' && $discnt_price > 0) {
                $discounted_price=($prod_price-$discnt_price);
                echo "<strike>".$curlogo.number_format($prod_price,2)."</strike>"."<span>".$curlogo.number_format($discounted_price,2)."</span>";
            }
        }
    }
    else {
        echo "<span>".$curlogo.number_format($prod_price,2)."</span>";
    }
}

function cleanspecialchars($text) {

    $code_entities_match = array(' ','--','&quot;','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
    $code_entities_replace =
            array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
    $text = str_replace($code_entities_match, $code_entities_replace, $text);
    return $text;
}
function productnamealias($text) {

    $code_entities_match = array(' ','/','#','%','?','&','!');
    $code_entities_replace = array('-');
    $text = str_replace($code_entities_match, $code_entities_replace, $text);
    return $text;
}
?>
<script type="text/javascript">
    function redirectPage(url)
    {
        window.location.href=url;
        return false;
    }
</script>