<?php $themefoldername = $this->config->get('config_template'); ?>
<?php $themepath = 'catalog/view/theme/'.$themefoldername; ?>
<?php $langcode = $this->language->get('code'); if (empty($langcode)) { $langcode = (!empty($_COOKIE['language'])) ? $_COOKIE['language'] : 'en'; } ?>
<?php $idata = json_decode(file_get_contents('image/cache/icustomfooter.json'),true);?>
<?php if ($idata['Settings']['Show'] == 'true'): ?>
 
<link rel="stylesheet" type="text/css" href="<?=$themepath?>/stylesheet/icustomfooter.css" />
<style>
.iWidgets .iWidget { height:350px; }
#footer { <?=$idata['Settings']['HideOriginalFooter']?> }
#powered { <?=$idata['Settings']['HidePoweredBy']?> }
.iCustomFooter { width:<?=$idata['Settings']['FooterWidth']?>px; }
.iCustomFooter .iWidgets .iWidget h2 { <?=(!empty($idata['Settings']['ColumnColor'])) ? 'color:'.$idata['Settings']['ColumnColor'] : '' ?> }
.iCustomFooter .iWidgets .iWidget h2 { border-bottom-style:<?=$idata['Settings']['ColumnLineStyle']?>; ?> }
</style>
<div class="clearfix"></div>
<div id="iCustomFooter" class="iCustomFooter <?=$idata['Settings']['BackgroundPattern']?> <?=$idata['Settings']['FontFamily']?> <?=$idata['Settings']['ColumnContentOverflow']?> <?=$idata[$langcode]['Widgets']['Contacts']['IconSet']?>">
	<ul class="iWidgets">

    	<?php if ($idata[$langcode]['Widgets']['AboutUs']['Show'] == 'true'): ?>
    	<li class="iAboutUs iWidget grid_3">
        	<div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['AboutUs']['Title']?></h2>
                <div class="text"><?=html_entity_decode($idata[$langcode]['Widgets']['AboutUs']['Text'])?></div>
            </div>
        </li>
        <?php endif; ?>

    	<?php if ($idata[$langcode]['Widgets']['Contacts']['Show'] == 'true'): ?>
        <li class="iContactUs iWidget grid_3">
        	<div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['Contacts']['Title']?></h2>
                <div class="text"><?=html_entity_decode($idata[$langcode]['Widgets']['Contacts']['Text'])?></div>
                <ul class="iContactsListing">
        
                    <?php if (!empty($idata[$langcode]['Widgets']['Contacts']['Address1']) || !empty($idata[$langcode]['Widgets']['Contacts']['Address2'])): ?>
                    <li class="iAddress">
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Address1']?></div>
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Address2']?></div>
                    </li>
                    <?php endif; ?>
                    <?php if (!empty($idata[$langcode]['Widgets']['Contacts']['Phone1']) || !empty($idata[$langcode]['Widgets']['Contacts']['Phone2'])): ?>
                    <li class="iPhone">
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Phone1']?></div>
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Phone2']?></div>
                    </li>
                    <?php endif; ?>
                    <?php if (!empty($idata[$langcode]['Widgets']['Contacts']['Fax1']) || !empty($idata[$langcode]['Widgets']['Contacts']['Fax2'])): ?>
                    <li class="iFax">
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Fax1']?></div>
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Fax2']?></div>
                    </li>
                    <?php endif; ?>   
                    <?php if (!empty($idata[$langcode]['Widgets']['Contacts']['Email1']) || !empty($idata[$langcode]['Widgets']['Contacts']['Email2'])): ?>
                    <li class="iEmail">
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Email1']?></div>
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Email2']?></div>
                    </li>
                    <?php endif; ?>              
                    <?php if (!empty($idata[$langcode]['Widgets']['Contacts']['Skype1']) || !empty($idata[$langcode]['Widgets']['Contacts']['Skype2'])): ?>
                    <li class="iSkype">
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Skype1']?></div>
                        <div class="contactItem"><?=$idata[$langcode]['Widgets']['Contacts']['Skype2']?></div>
                    </li>
                    <?php endif; ?>              
                </ul>
            </div>
        </li>
        <?php endif; ?>

        <?php if ($idata[$langcode]['Widgets']['GoogleMaps']['Show'] == 'true'): ?>
        <li class="iGoogleMaps iWidget grid_3">
        	<div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['GoogleMaps']['Title']?></h2>
                <div class="text"><?=html_entity_decode($idata[$langcode]['Widgets']['GoogleMaps']['Code'])?></div>
            </div>
        </li>
        <?php endif; ?>
        
    	<?php if ($idata[$langcode]['Widgets']['ContactForm']['Show'] == 'true'): ?>
    	<li class="iContactForm iWidget grid_3" id="messageSent">
        	<div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['ContactForm']['Title']?></h2>
                <div class="iContactFields">
                    <?php if (isset($_POST['iContactForm'])) {
                            @mail($idata[$langcode]['Widgets']['ContactForm']['Email'], 'Message from your site', $_POST['iContactForm']['Message'], 'From: '.$_POST['iContactForm']['Name'].' <'.$_POST['iContactForm']['Email'] .'>' );
                            echo '<div class="flashmessage">Your message was sent, thanks!</div>';
                        } else {
                    ?>
						<div class="redflashmessage"></div>
						<form action="#messageSent" method="post" onsubmit="return iContactFormValidation(this)">
						<label for="contactName">Your name:</label><input type="text" id="contactName" name="iContactForm[Name]" />
						<hr />
						<label for="contactEmail">Your email:</label><input type="text" id="contactEmail" name="iContactForm[Email]" />
						<hr />
						<label for="contactMessage">Message:</label><textarea id="contactMessage" name="iContactForm[Message]"></textarea>
						<input type="submit" value="Send message" />
						</form>
						<script>
							var emailfilter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
							var iContactFormValidation = function(form) {
								if ($(form).find('#contactName').val() == '') {
									$('.redflashmessage').html('<b>Name</b> is a required field').slideDown();
									return false;		
								}
								if ($(form).find('#contactEmail').val() == '') {
									$('.redflashmessage').html('<b>Email</b> is a required field').slideDown();
									return false;		
								}
								if (!emailfilter.test($(form).find('#contactEmail').val())) {
									$('.redflashmessage').html('<b>Email</b> is not valid').slideDown();
									return false;		
								}
								if ($(form).find('#contactMessage').val() == '') {
									$('.redflashmessage').html('<b>Message</b> is a required field').slideDown();
									return false;		
								}
								return true;
							}
						</script>
					<?php } ?>
                </div>
            </div>
        </li>
        <?php endif; ?>

        <?php if ($idata[$langcode]['Widgets']['Twitter']['Show'] == 'true'): ?>
        <li class="iTwitter iWidget grid_3">
        	<div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['Twitter']['Title']?></h2>
                <?php $tweets = json_decode(file_get_contents('http://search.twitter.com/search.json?q='.str_replace(' ','+',$idata[$langcode]['Widgets']['Twitter']['Keyword']).'&rpp=5&include_entities=true&result_type=mixed'), true);  ?>
                
                <ul class="iTweets">
                <?php $i = 0; ?>
                <?php foreach($tweets['results'] as $key => $result): ?>
                <?php $tweeturl = 'http://twitter.com/#!/'.$result['from_user'].'/status/'.$result['id'] ?>
                <?php $i++; if (!empty($idata[$langcode]['Widgets']['Twitter']['NumberOfTweets'])) if ($i > (int)$idata[$langcode]['Widgets']['Twitter']['NumberOfTweets']) continue;  ?>
                    <li class="iTweet">
                        <span class="tweetText"><a href="<?=$tweeturl?>" target="_blank"><?=$result['text']?></a></span>
                        <span class="tweetDate"><?=date('n/j/Y',strtotime($result['created_at']))?></span>
                    </li>
                <?php endforeach;?>
                </ul>
            </div>
        </li>
        <?php endif; ?>
        
        <?php if ($idata[$langcode]['Widgets']['Facebook']['Show'] == 'true'): ?>
        <li class="iFacebook iWidget grid_3">
            <div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['Facebook']['Title']?></h2>
                <iframe src="//www.facebook.com/plugins/likebox.php?href=<?=htmlentities($idata[$langcode]['Widgets']['Facebook']['URL'])?>&amp;width=210&amp;height=<?=$idata[$langcode]['Widgets']['Facebook']['Height']?>&amp;colorscheme=light&amp;show_faces=true&amp;border_color=%23ddd&amp;stream=false&amp;header=false&amp;appId=159650554163037" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:210px; height:<?=$idata[$langcode]['Widgets']['Facebook']['Height']?>px;" allowTransparency="true"></iframe>
            </div>
            
        </li>
        <?php endif; ?>
            
        <?php if ($idata[$langcode]['Widgets']['YouTube']['Show'] == 'true'): ?>
        <li class="iYouTube iWidget grid_3">
            <div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['YouTube']['Title']?></h2>
                <?php $videoHeight = (!empty($idata[$langcode]['Widgets']['YouTube']['Height'])) ? (int)$idata[$langcode]['Widgets']['YouTube']['Height'] : 200; ?>
                <?php $videoWidth = (!empty($idata[$langcode]['Widgets']['YouTube']['Width'])) ? (int)$idata[$langcode]['Widgets']['YouTube']['Width'] : 210; ?>
                <iframe width="<?=$videoWidth?>" height="<?=$videoHeight?>" src="http://www.youtube.com/embed/<?=$idata[$langcode]['Widgets']['YouTube']['URL']?>" frameborder="0" allowfullscreen></iframe>
        	</div>
        </li>
        <?php endif; ?>
        
        <?php if ($idata[$langcode]['Widgets']['Custom']['Show'] == 'true'): ?>
        <li class="iCustom iWidget grid_3">
        	<div class="iWidgetWrapper">
                <h2><?=$idata[$langcode]['Widgets']['Custom']['Title']?></h2>
                <div class="text"><?=html_entity_decode($idata[$langcode]['Widgets']['Custom']['Text'])?></div>
            </div>
        </li>
        <?php endif; ?>
         <li class="clearfix"></li>
    </ul>
    <?php if ($idata[$langcode]['Widgets']['SocialButtons']['Show'] == 'true'): ?>
    <ul class="iButtons">
        <?php if ($idata[$langcode]['Widgets']['SocialButtons']['PinterestPin']['Show'] == 'true'): ?>
    	<li class="iPinterest iButton">
			<a href="http://pinterest.com/pin/create/button/" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
            <script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
        </li>
        <?php endif; ?>
        <?php if ($idata[$langcode]['Widgets']['SocialButtons']['GooglePlus']['Show'] == 'true'): ?>
    	<li class="iGooglePlus iButton">
            <g:plusone size="medium" annotation="none"></g:plusone>
            <script type="text/javascript">
              (function() {
                var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                po.src = 'https://apis.google.com/js/plusone.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
              })();
            </script>
        </li>
        <?php endif; ?>
    	<?php if ($idata[$langcode]['Widgets']['SocialButtons']['FacebookLike']['Show'] == 'true'): ?>
    	<li class="iFacebook iButton">
            <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/all.js#xfbml=1&appId=159650554163037";
              fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));</script>
            <fb:like send="false" layout="button_count" width="200" show_faces="false"></fb:like>
        </li>
        <?php endif; ?>
        <li class="clearfix"></li>
    </ul>
   
    <?php endif; ?>
</div>
<?php endif; ?>
