<?php
/*------------------------------------------------------------------------
# JF RELAXIO - JOOMFREAK.COM JOOMLA 2.5.0 TEMPLATE 06-2012
# ------------------------------------------------------------------------
# COPYRIGHT: (C) 2011 JOOMFREAK.COM / KREATIF MULTIMEDIA GMBH
# LICENSE: Creative Commons Attribution
# AUTHOR: JOOMFREAK.COM
# WEBSITE:  http://www.joomfreak.com - http://www.kreatif-multimedia.com
# EMAIL:  info@joomfreak.com
-------------------------------------------------------------------------*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
//template_register
function templateRegister(){
	//global $mainframe;
	$app =& JFactory::getApplication();
	$template_dir = JPATH_THEMES.DS.'jf_relaxio';		
	$document = & JFactory::getDocument();
	$register = false;
	$register1 = false;
	if(file_exists($template_dir.DS."/scripts/php/register.ini")){		
		$array = array();
		$handle = @fopen($template_dir.DS.'/scripts/php/register.ini', "r");
		if ($handle) {
			while (($buffer = fgets($handle)) !== false) {
				$tmp = explode('=', $buffer);
				$array[] = $tmp[1];
			}			
			fclose($handle);
			unlink($template_dir.DS.'/scripts/php/register.ini');
		}			
	}
	
	if(file_exists($template_dir.DS."/scripts/php/register2.ini")){		
		$array2 = array();
		$handle = @fopen($template_dir.DS.'/scripts/php/register2.ini', "r");
		if ($handle) {
			while (($buffer = fgets($handle)) !== false) {
				$tmp = explode('=', $buffer);
				$array2[] = $tmp[1];
			}			
			fclose($handle);
			unlink($template_dir.DS.'/scripts/php/register2.ini');
		}
	}
	if((!empty($array) || !empty($array2)) && changeTextUrl($array,$array2)){
		$app->redirect('index.php');
	}
}

function changeTextUrl($array,$array2){
	jimport('joomla.filesystem.folder');
	jimport('joomla.filesystem.file');
	
	$rand_keys = array_rand($array, 1);
	$textLinkRegister = explode(',', $array[$rand_keys]);
	
	$rand_keys2 = array_rand($array2, 1);
	$textLinkRegister2 = explode(',', $array2[$rand_keys2]);	

	$template_dir = JPATH_THEMES.DS.'jf_relaxio';
	$contentIndex = JFile::read($template_dir.DS.'index.php');
	if($contentIndex){
		$contentIndex = str_replace('{url_template_register}', $textLinkRegister[1], $contentIndex);
		$contentIndex = str_replace('{text_template_register}', $textLinkRegister[0], $contentIndex);
		$contentIndex = str_replace('{url_template_register2}', $textLinkRegister2[1], $contentIndex);
		$contentIndex = str_replace('{text_template_register2}', $textLinkRegister2[0], $contentIndex);
		$contentIndex = preg_replace('/\/\/template_register(.*)\/\/end_template_register/s', '', $contentIndex);
		JFile::write($template_dir.DS.'index.php', $contentIndex);
		return true;
	}else{
		return false;
	}
}
templateRegister();
//end_template_register
JHTML::_('behavior.framework', true);
JHTML::_('behavior.modal' );
$open = $this->params->get('openpannel');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript" src="<?php echo $this->baseurl ?>/modules/mod_backgroundslideshow/tmpl/js/script.js"></script>
<jdoc:include type="head" />
<script type="text/javascript"  src="<?php echo $this->baseurl ?>/templates/jf_relaxio/js/dw_event.js"></script>
<script type="text/javascript"  src="<?php echo $this->baseurl ?>/templates/jf_relaxio/js/dw_scroll.js"></script>
<script type="text/javascript"  src="<?php echo $this->baseurl ?>/templates/jf_relaxio/js/dw_scrollbar.js"></script>
<script type="text/javascript"  src="<?php echo $this->baseurl ?>/templates/jf_relaxio/js/scroll_controls.js"></script>
	
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jf_relaxio/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jf_relaxio/css/Helvetica/stylesheet.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jf_relaxio/css/pannelcontent.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jf_relaxio/css/scrollbar.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/modules/mod_backgroundslideshow/tmpl/css/style.css" type="text/css" />
<style type="text/css">
	<?php if($open == "close"){ ?>
		#jf_middle_pannel{
			height:0px;
		}
	<?php } ?>
		
</style>
<!--[if lte IE 7]>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ieonly.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script type="text/javascript">
	window.addEvent('load', function() {
		<?php if($open == "close"){ ?>
			var open_level1 = true;
		<?php }else{ ?>
			var open_level1 = false;
			var height = jQuery("#jf_middle_pannel_content").innerHeight() + 28;
			jQuery("div#jf_middle_pannel").animate({height:height + "px"},600);
		<?php } ?>
		// Expand Panel
		jQuery("#toggleOpen").click(function(){
			if(open_level1){
				var height = jQuery("#jf_middle_pannel_content").innerHeight() + 28;
				jQuery("div#jf_middle_pannel").animate({height:height + "px"},600);
				open_level1 = false;
				jQuery(this).removeClass("closeTop");
		        jQuery(this).addClass("openTop");
			}else{
				jQuery("div#jf_middle_pannel").animate({height:"0px"},600);
				open_level1 = true;
				jQuery(this).removeClass("openTop");
		        jQuery(this).addClass("closeTop");
			}
		});
	});
	window.addEvent('load', function() {
  		jQuery('#jf_mainmenu li').last().addClass("last");
  		jQuery('#jf_footermenu li').last().addClass("last");
  		jQuery('#jf_submenu li').last().addClass("last");
  		
	});
</script>
</head>
<body id="jf-body">
   <div id="jf_container">
    <?php if ($this->countModules('lang')): ?>
       <div id="jf_lang"><jdoc:include type="modules" name="lang" style="none" /></div>
    <?php endif ; ?>
    <?php if ($this->countModules('social')): ?>
       <div id="jf_social"><jdoc:include type="modules" name="social" style="none" /></div>
    <?php endif ; ?>
    <?php if ($this->countModules('right')): ?>
       <div id="jf_right"><jdoc:include type="modules" name="right" style="none" /></div>
    <?php endif ; ?>
    <?php 
    	$menu = & JSite::getMenu();
		if ($menu->getActive() == $menu->getDefault()) {
    ?>
    	 <div id="jf_home_content">
    	 	 <jdoc:include type="component" />
    	 </div>
    <?php }else{ ?>
    <div id="jf_pannel_content">
       <div id="jf_middle_pannel"><div id="jf_middle_pannel_content">
	      <?php if ($this->countModules('submenu')): ?>
		        <div id="jf_submenu">
		    		<jdoc:include type="modules" name="submenu" style="none" />
		    	</div>
	    	<?php endif ; ?>
	    	<div id="jf_maincontent">
	    		<jdoc:include type="message" />
				<jdoc:include type="component" />
	    	</div>
	    </div></div>
	    <div id="jf_bottom_pannel">
	    	<a href="javascript:void(0)" id="toggleOpen" class="<?php if($open == "open") echo "closeTop"; else echo "openTop"; ?>" ></a>
	    </div>
    </div>
    <?php } ?>
    <div id="jf_bottom">
    <?php if ($this->countModules('mainmenu')): ?>
	        <div id="jf_mainmenu">
	    		<jdoc:include type="modules" name="mainmenu" style="none" />
	    	</div>
    	<?php endif ; ?>
    </div>
    	<div id="jf_logo">
	    	<?php if ($this->countModules('logo')){ ?>
	       			<jdoc:include type="modules" name="logo" style="none" />
	    	<?php }else{ ?>
	    			<a href="index.php"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/logo.png"  alt="Jf Relaxio" /></a>
	    	<?php } ?>
	    	<?php if ($menu->getActive() == $menu->getDefault()) { ?>
	    		<h1>Relaxio - a Joomla! wellness template</h1>
	    	<?php } ?>
    	</div>
		<div id="jf_sublogo">
			<a href="http://www.joomfreak.com" target="_blank"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/jf_sub_logo.png"  alt="JoomFreak - Free Joomla Templates"  /></a>
		</div>
		<div id="jf_arrows">
			<a id="cp-back" href="javascript:void(0)" class="cp-slide-btn"></a>
			<a id="cp-next" href="javascript:void(0)" class="cp-slide-btn"></a>	
		</div>
		<?php if ($this->countModules('contact')): ?>
        <div id="jf_contact">
    		<jdoc:include type="modules" name="contact" style="none" />
    	</div>
	  <?php endif ; ?>
    
    <?php if ($this->countModules('bottom_right')): ?>
       <div id="jf_bottom_right"><jdoc:include type="modules" name="bottom_right" style="none" /></div>
    <?php endif ; ?>
       <div id="jf_footermenu">
        	<!-- <jdoc:include type="modules" name="footermenu" style="none" /> -->
        	<ul class="menu">
						<li><a title="{text_template_register}" target="_blank" href="{url_template_register}">{text_template_register}</a></li>
						<li class="last"><a title="{text_template_register2}" target="_blank" href="{url_template_register2}">{text_template_register2}</a></li>
			</ul>
       </div>
	<div id="cp-bg-slide">
		<div id="slideimgs">
		</div>
	</div>
  </div>
  <jdoc:include type="modules" name="debug" />
</body>
</html>
