<?php 

if( !(isset($pathtoroot) && $pathtoroot) )
{
  $path=dirname(realpath(__FILE__));
  if(strlen($path))
  {
    /* determine the OS type for path parsing */
    $pos = strpos($path,":");
    if ($pos === false)
    {
      $gOS_TYPE="unix";
      $pathchar = "/";
    }
    else
    {
      $gOS_TYPE="win";
      $pathchar="\\";
    }
    $p = $path.$pathchar;
    /*Start looking for the root flag file */
    while(!strlen($pathtoroot) && strlen($p))
    {
      $sub = substr($p,strlen($pathchar)*-1);
      if($sub==$pathchar)
      {
        $filename = $p."root.flg";
      }
      else
        $filename = $p.$pathchar."root.flg";
      if(file_exists($filename))
      {
        $pathtoroot = $p;
      }
      else
      {
        $parent = realpath($p.$pathchar."..".$pathchar);
	if($parent!=$p)
	{
	  $p = $parent;
	}
	else
	  $p = "";
      }
    }
    if( !(isset($pathtoroot) && $pathtoroot) )
      $pathtoroot = ".".$pathchar;
  }
  else
  {
    $pathtoroot = ".".$pathchar;
  }
}

$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");

$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
    $admin = "admin";

$localURL=$rootURL."kernel/";
$adminURL=$rootURL.$admin;
$imagesURL = $adminURL."/images";
//admin only util
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
	//Set Section
	$section = "in-portal:main_import";
	
	//Set Environment Variable
	$envar = "env=" . BuildEnv();
	$var = '?env='.BuildEnv();
	
	$sec = $objSections->GetSection($section);
	$objCatToolBar = new clsToolBar();
   	
   	// Previous Button
	$MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
	$MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
	$link = $adminURL.'/import/step1.php'.$var;
	$objCatToolBar->Add('moveleft','la_ToolTip_PreviousStep', $link, $MouseOver, $MouseOut,'','tool_prev.gif');
	
	// Next Button
	$MouseOver = "if( ChoiseMade('import_form','choose') !== false ) swap('moveright','toolbar/tool_next_f2.gif');";
	$MouseOut = "if( ChoiseMade('import_form','choose') !== false ) swap('moveright', 'toolbar/tool_next.gif');";
	
	if($ro_perm)
	{
		$click_url = $adminURL."/import/step1.php".$var;
		$onClick = "if( ChoiseMade('import_form','choose') ) document.location= '$click_url'; ";
	}
	else
	{
		$click_url = $adminURL."/import/step3.php".$var;
		$onClick = "ImportRedirect('import_form', ChoiseMade('import_form','choose'), '$click_url');";
	}
	$objCatToolBar->Add("moveright",'la_ToolTip_NextStep','#',$MouseOver,$MouseOut,$onClick,"tool_next_f3.gif");
	
	// header
	$title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 2";
  	int_header($objCatToolBar,NULL,$title);

?>
<form name="import_form" id="import_form" method="post" action="<?php echo $click_url; ?>">
	<input type="hidden" name="import_id" id="import_id" value="">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">

	<?php int_subsection_title("Import Source"); ?>
 	<tr <?php echo int_table_color(); ?>> 
    	<td><span class="text">Select the program you are importing the data from:</span></td>
 	</tr>
 	<tr <?php echo int_table_color(); ?>>
  		<td>
		<?php
			foreach($import_scripts as $id => $iscript)
				echo '<input type="radio" name="choose" id="ch'.$id.'" value="'.$id.'" onclick="swap(\'moveright\', \'toolbar/tool_next.gif\')"'.(!$iscript['enabled'] ? ' disabled="true"' : '').'><span class="text"><label for="ch'.$id.'">'.$iscript['label'].'</label></span><br />'."\n";
		?>
   		</td>
   	</tr>
</table>
</form>
<?php
int_footer();
?>