<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     default_em0122
 * @copyright   Copyright (c) 2014 EMthemes (www.emthemes.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>

<?php	
	$setting = Mage::helper('themeframework/settings');
    $isMobile = $setting->checkMobilePhp();
 ?>

<?php if($setting->getGeneral_ShowPopup()!=0 && $isMobile==false) :?>			 
		<div class="popup-content" id="em-popup" style="display:none">	
			<div class="popup-content-block">
				<?php echo $this->getChildHtml('em_popup_content'); ?>
			</div>			
			<?php if($setting->getGeneral_ShowPopup()==1): ?>
				<?php $login = new Mage_Customer_Block_Form_Login(); ?>
	                <?php if (Mage::getSingleton('customer/session')->isLoggedIn()==0): ?>
	                <div class="em-account-popup">        
	                	<form action="<?php echo $login->getPostActionUrl() ?>" method="post" id="em-popup-loginform">
	                        <?php echo $this->getBlockHtml('formkey'); ?>
	                        <div class="block-content em-line-01">
								<p class="login-title h3 primary"><?php echo $this->__('Login') ?></p>
								<p class="login-desc normal"><?php echo $this->__('If you have an account with us, please log in.') ?></p>
								<ul class="form-list">
	                            <li><label for="mini-login"><?php echo $this->__('Email Address') ?><em><?php echo $this->__('*') ?></em></label>
	                            	<input type="text" name="login[username]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" id="mini-email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
	                            </li>
	                            <li><label for="mini-password"><?php echo $this->__('Password') ?><em><?php echo $this->__('*') ?></em></label><input type="password" name="login[password]" class="input-text required-entry validate-password" id="mini-pass" title="<?php echo $this->__('Password') ?>" /></li>  
								</ul>
								<p class="required"><?php echo $this->__('* Required Fields') ?></p>
	                            <div class="action-forgot">
	                                <div class="actions">
	                                    <button type="submit" class="button"><span><span><?php echo $this->__('Login') ?></span></span></button>
	                                </div>  
									<div class="login_forgotpassword">
	                                    <p><a href="<?php echo $login->getForgotPasswordUrl() ?>"><?php echo $this->__('Forgot Your Password?') ?></a></p>                                                
	                                    <p><a class="create-account-link-wishlist" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/create/'; ?>"><?php echo $this->__("Don't have an account") ?></a></p>
	                                </div>								
	                            </div>
	                        </div>
	                    </form>  

	                </div>
				 	<script type="text/javascript">
					    //<![CDATA[
					        var emPopupLoginForm = new VarienForm('em-popup-loginform', true);
					    //]]>
				    </script>
	                <?php endif;?>
				<?php elseif ($setting->getGeneral_ShowPopup()==2):  ?>						
					    <?php echo $this->getChildHtml('popup.newsletter');?>
			<?php endif; ?>			
		</div>	
    <script type="text/javascript">
    //<![CDATA[
    
        (function($) {
            function showPopUpLogin(){
                if ($('#em-popup').length > 0) {
                    $.fancybox.open('#em-popup',{
                        width : 'auto',
                        height: 'auto',
                        openEffect  : 'elastic',
                        closeEffect : 'elastic',
						<?php if($setting->getGeneral_ShowPopup()==2):?>
							padding : 0,
							wrapCSS : 'em-popup-newsletter',
                        <?php else:?>
							padding : 15,
                        <?php endif;?>                        
                    });
                }
                
            }
            $(window).bind('load', function() {
            	var now = new Date();
            	var time = now.getTime();
  				var expireTime = time + <?php echo Mage::getStoreConfig('web/cookie/cookie_lifetime')*1000; ?>;
  				 now.setTime(expireTime);
            	
            	if(!Mage.Cookies.get("empopup"))
            	{
            		document.cookie = 'empopup=true;expires='+now.toGMTString();
                	showPopUpLogin();
            	}
            });
        })(jQuery);
    //]]>
    </script>
<?php endif; ?>
