<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<script language="javascript">
function openadminhelp()
{
	var url = '../help/adminhelp/index.html'
	window.open(url,"Help","scrollbars=yes");
}
function setVisible(obj)
{  
	obj = document.getElementById(obj);
	obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
	
}
function show(obj)
{  
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
	
}
function hide(obj)
{  
	//obj1 = document.getElementById(obj);
	//alert(obj);
	if(document.getElementById(obj))
	{
	document.getElementById(obj).style.display="none";
	}
	//obj1.style.display = 'none';
}


/*
function setVisible(obj)
{  
	obj = document.getElementById(obj);
	obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
	
}
function show(obj)
{  
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
	
}

function hide(obj)
{  
	obj = document.getElementById(obj);
	obj.style.display = 'none';
}
*/

</SCRIPT>

<?php
$dateflg=1;
$divar=array();
$divar=array("Settings","Members","MemberPayment","Users","Vendors","Transporters","Contents","Charecteristics","Mail","Dealers","Feedbacks","Reports","SalesReps","Marketing");	

   if(((isset($_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= "") || (isset($_SESSION["sess_adminlogin"]) and $_SESSION["sess_adminlogin"]!= "")) and $_SESSION['sess_useradmin']=="")
  {
  
  if(isset($_GET['displayDiv']) && $_GET['displayDiv']) {
		$_SESSION['divVar']=$_GET['displayDiv'];   // Get the value of displayDiv from Query String
		}
		
		$menus=getAdminMenus(0);
		  // Get the value of displayDiv from Query String


?>
<div align="left" class="links_container">
<?php
//print('<pre>'); print_r($menus);
//exit;
$m=0;
  for($i=0;$i<sizeof($menus);$i++)
  {
     if(($menus[$i]['menu_id']!=0)){
?>
	
<?php


if($menus[$i]['subpage']!="")
{
	$divVar = '';
        if(isset($_GET['rghtMenu']))
        {
            $divVar=$_SESSION['divVar']; 
        }
	$div=$menus[$i]['divname'];
	
	if($div==$divVar )
	{
		$styles[$i]="style='display:block'";
	}
	else
	{
		$styles[$i]="style='display:none'";
	}
	$str="";
	for($m=0;$m<sizeof($divar);$m++)
	{
		if($divar[$m]!=$div)
		{
			$str.= "hide('".$divar[$m]."');";
		}
    }
	if(isset($_GET["menu"]) && $_GET["menu"])
	{
	?>
		<script type="text/javascript">
			if(document.getElementById("<?php echo $_GET['menu'] ?>"))
			document.getElementById("<?php echo $_GET['menu'] ?>").style.display = "block";
		</script>
	<?php
	}
    ?>
<div><a href="javascript:void(0);" style="cursor:pointer" onClick="setVisible('<?php echo $div;?>');<?php echo $str;?>" >
<?php echo constant($menus[$i]['title']);// echo $menus[$i]['page_name'];?></a></div>
<div id="<?php echo $div;?>" <?php echo $styles[$i]; ?>>
<?php
$current_url = basename($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
$curr_page_name = getCurrPagename("$current_url");
for($k=0;$k < sizeof($menus[$i]['subpage']);$k++)
{
?>
	<div align="left"> 
		<a href="<?php echo $menus[$i]['subpage'][$k]['link'];?>">
		<?php
		if($curr_page_name == $menus[$i]['subpage'][$k]['page_name'])
		echo "<u>";
			echo constant($menus[$i]['subpage'][$k]['title']); // echo $menus[$i]['subpage'][$k]['page_name'];
		if($curr_page_name == $menus[$i]['subpage'][$k]['page_name'])
		echo "</u>";
		?>
		</a>
	</div>
<?php
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	<td width="167" align="left" valign="middle">&nbsp;</td>
	<td align="left" valign="middle"><?php echo $arrowImg1;?></td>
  </tr>
</table>
</div>
<?php
}  
else
{
?>	  
<div align="left">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="167" valign="middle">
				<a href="<?php echo $menus[$i]['link'];?>"><?php echo constant($menus[$i]['title']); //echo $menus[$i]['page_name'];?></a>
			</td>
		</tr>
	</table>
</div>
	<?php  
	  }
    }
   }
   ?>
   
 
  <!-- <li><a href="javascript:void(0)"  onClick="opensellerhelp();" title="Open User Help Window">Help</a></li> -->

</div>
<?php
}


/* From dagtabase */


else if(isset($_SESSION["sess_useradmin"]) and $_SESSION["sess_useradmin"]!= "")
  {
		if($_GET['displayDiv']) {
		$_SESSION['divVar']=$_GET['displayDiv'];   // Get the value of displayDiv from Query String
		}
		$username=$_SESSION["sess_useradmin"];
		$dept_id=getUserDepartment($username);
		$menus=getUserMenus($dept_id,0);
        $styleFeedback="style='display:none'";
		$styleReports="style='display:none'";
		$styleSalesrep="style='display:none'";
		$styleMarketing="style='display:none'";
		// Get the value of displayDiv from Query String

               
?>
<div id="links_container">
<div id="navMenu">
<ul>
<?php
$m=0;


for($i=0;$i<sizeof($menus);$i++)
{
	if(($menus[$i]['menu_id']!=0)){
?>
	
	<?php

        
	if($menus[$i]['subpage']!="")
	{
	  $divVar=$_SESSION['divVar']; 
	   
		 $div=$menus[$i]['divname'];
		 if($div==$divVar)
		 {
		  $styles[$i]="style='display:'";
		  }else
		  {
		  $styles[$i]="style='display:none'";
		  }
		  $str="";
	for($m=0;$m<sizeof($divar);$m++)
	{
	 if($divar[$m]!=$div)
	 {
	 $str.= "hide('".$divar[$m]."');";
     }
	}
	?>
	
<li class="submenulinks">
<div><a href="javascript:void(0)" style="cursor:pointer" onClick="setVisible('<?php echo $div;?>');<?php echo $str;?>" >
<?php echo constant($menus[$i]['title']); // echo $menus[$i]['page_name'];?></a></div>
 
<div id="<?php echo $div;?>" <?php echo $styles[$i]; ?>>
<ul rel="closed">
<?php
for($k=0;$k<sizeof($menus[$i]['subpage']);$k++)
{
?>
	<li>
		<a href="<?php echo $menus[$i]['subpage'][$k]['link'];?>"><?php echo constant($menus[$i]['subpage'][$k]['title']); //$menus[$i]['subpage'][$k]['page_name']; ?></a>
	</li>
<?php
}
?>
</ul>
</div>
</li>
	
	
	
<?php
      }  
	  else
	  {
	  ?>
	  
<li>
	<a href="<?php echo $menus[$i]['link'];?>"><?php echo constant($menus[$i]['title']); // echo $menus[$i]['page_name'];?></a>
	</li>
	<?php  
	  }
    }
   }?>
   
 
  <!-- <li><a href="javascript:void(0)"  onClick="opensellerhelp();" title="Open User Help Window">Help</a></li> -->
    </ul>
  </div>
</div>
   <?php
		
	}	else
		{
		?>
		<div id="navMenu">
		<ul >

		<li> <div align="left"><a href="login.php"><?php echo LOGIN;?></a></div>  </li>
  <!-- register.php-->
  <li><div align="left"><a href="vendor_plans.php"><?php echo REG_NOW;?></a></div>	  </li>
<li>  <div align="left"><a href="forgotpassword.php"><?php echo FORGOT_PWD;?></a></div>  </li>

		</ul>
		</div>
		</div>
		<?php
		}
		?>


