<?php
/*------------------------------------------------------------------------
# mod_vtem_fancymenu - VTEM Fancy Menu Module
# ------------------------------------------------------------------------
# author Nguyen Van Tuyen
# copyright Copyright (C) 2010 VTEM.NET. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.vtem.net
# Technical Support: Forum - http://vtem.net/en/forum.html
-------------------------------------------------------------------------*/
// no direct access
defined('_JEXEC') or die('Restricted access');
$menuID = $params->get('menuid', 'vt_menu');
$background = $params->get('background', '#222');
$textcolor = $params->get('textcolor', '#999');
$sub_background = $params->get('sub_background', '#eee');
$sub_textcolor = $params->get('sub_textcolor', '#555');
$main_width = $params->get('main_width', '80');
$sub_width = $params->get('sub_width', '180');
$hovertextcolor = $params->get('hovertextcolor', '#f90');
$jquery = $params->get('jquery', 1);
$css = $params->get('css');
$position = $params->get('position', 'left');
$docktag = $params->get('docktag', 'body');
if($jquery){echo '<script type="text/javascript" src="'.JURI::root().'modules/mod_vtem_fancymenu/assets/jquery-1.4.2.min.js"></script>';}
?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
      var docked = 0;          
      jQuery("#<?php echo $menuID;?> li ul").height(jQuery(window).height());           
      jQuery("#<?php echo $menuID;?> .dock").click(function(){
                jQuery(this).parent().parent().addClass("docked").removeClass("vt_menu_sub");              
                docked += 1;
                var dockH = (jQuery(window).height()) / docked
                var dockT = 0;                              
                jQuery("#<?php echo $menuID;?> li ul.docked").each(function(){
                    jQuery(this).height(dockH).css("top", dockT + "px");
                    dockT += dockH;
                });
                jQuery(this).parent().find(".undock").show();
                jQuery(this).hide();               
                if (docked > 0)
                    jQuery("<?php echo $docktag;?>").css("margin-<?php echo $position;?>","<?php echo $main_width+$sub_width+20;?>px");
                else
                    jQuery("<?php echo $docktag;?>").css("margin-<?php echo $position;?>", "<?php echo $main_width;?>px");
            });           
       jQuery("#<?php echo $menuID;?> .undock").click(function(){
                jQuery(this).parent().parent().addClass("vt_menu_sub").removeClass("docked")
                    .animate({<?php echo $position;?>:"-<?php echo $sub_width;?>px"}, 200).height(jQuery(window).height()).css("top", "0px");
                docked = docked - 1;
                var dockH = (jQuery(window).height()) / docked
                var dockT = 0;                            
                jQuery("#<?php echo $menuID;?> li ul.docked").each(function(){
                    jQuery(this).height(dockH).css("top", dockT + "px");
                    dockT += dockH;
                });
                jQuery(this).parent().find(".dock").show();
                jQuery(this).hide();     
                if (docked > 0)
                    jQuery("<?php echo $docktag;?>").css("margin-<?php echo $position;?>", "<?php echo $main_width+$sub_width+20;?>px");
                else
                    jQuery("<?php echo $docktag;?>").css("margin-<?php echo $position;?>", "<?php echo $main_width;?>px");
            });
      jQuery("#<?php echo $menuID;?> li").hover(function(){
                jQuery(this).find("ul.vt_menu_sub").animate({<?php echo $position;?>:"<?php echo $main_width;?>px"}, 200);
            }, function(){
                jQuery(this).find("ul.vt_menu_sub").animate({<?php echo $position;?>:"-<?php echo $sub_width;?>px"}, 200);
           });
		   ///////////////////////////////////////////////////////////////
		   jQuery('#<?php echo $menuID;?> li ul li.parent ul').hide();
		   jQuery('#<?php echo $menuID;?> li ul li.parent ul:first').show().parent().addClass('vtemfancyhover');
		   jQuery('#<?php echo $menuID;?> li ul li.parent a').click(function(){
                         var checkElement = jQuery(this).next();
                         if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                         return false;
                         }
                         if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                         jQuery('#<?php echo $menuID;?> li ul li.parent ul:visible').not(jQuery(this).parents()).not(jQuery(this).siblings()).slideUp().parent().removeClass('vtemfancyhover');
                         checkElement.slideDown().parent().addClass('vtemfancyhover');
                         return false;
                         }
          });	 
}); 
</script>
<style type="text/css">
ul.vt_fancymenu li a,ul.vt_fancymenu li a:link,ul.vt_fancymenu li a:visited{color:<?php echo $textcolor;?>;display:block;width:100%;height:100%;text-align:center; font-weight:bold; text-decoration:none;}
ul.vt_fancymenu li a:hover,ul.vt_fancymenu li ul li a:hover,ul.vt_fancymenu li a:focus,ul.vt_fancymenu li.active a,ul.vt_fancymenu li li.vtemfancyhover a span,ul.vt_fancymenu li ul li.vtemfancyhover ul li.vtemfancyhover a span,ul.vt_fancymenu li ul li.vtemfancyhover ul li.vtemfancyhover ul li.vtemfancyhover a span{color:<?php echo $hovertextcolor;?> !important; background-color:transparent !important; outline:none;}
ul.vt_fancymenu li li a,ul.vt_fancymenu li li a:link,ul.vt_fancymenu li li a:visited, ul.vt_fancymenu li li.vtemfancyhover ul li a span, ul.vt_fancymenu li  ul li.vtemfancyhover ul li.vtemfancyhover ul li a span,ul.vt_fancymenu li  ul li.vtemfancyhover ul li.vtemfancyhover ul li.vtemfancyhover ul li a span{color: <?php echo $textcolor;?> !important;text-align:left; font-weight:normal;padding:0; height:30px; line-height:30px;}
ul.vt_fancymenu li li.parent{background:url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/arrow.gif) 98% 10px no-repeat;}
ul.vt_fancymenu li li.vtemfancyhover{background:url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/arrow1.gif) 98% 10px no-repeat !important;}
/*/////////////////////////////////////////////////////////////*/
ul.vt_fancymenu{margin:0px !important; padding:0 1px 0 0 !important; list-style:none !important; position:fixed; top:0px; height:100%; z-index:0; background:<?php echo $background;?> url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/line1.png) top right repeat-y; <?php echo $position;?>:0px;}
.vt_fancymenu li.level0{background-color:<?php echo $background;?>; }
ul.vt_fancymenu > li {width:<?php echo $main_width;?>px; min-height:60px; margin:0; background-image:url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/line.png); background-position:left bottom; background-repeat:repeat-x; padding:8px 0;}
ul.vt_fancymenu ul li {padding:0; margin:0;border-bottom:dotted 1px #888;}
ul.vt_fancymenu li:hover ul {display:block;}
ul.vt_fancymenu li ul {position:absolute; top:0px; <?php echo $position;?>:-<?php echo $sub_width;?>px;  z-index:-1;width:<?php echo $sub_width;?>px; display:none; background:<?php echo $background;?> url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/sub_bg.png); padding:10px !important; margin:0 !important; list-style:none !important;}
ul.vt_fancymenu li ul.docked { display:block;z-index:-2;}
.vt_fancymenu li ul li a.dock,.vt_fancymenu li ul li a.undock{text-align:right; color:#fff !important; font-weight:bold; padding:0px;background:url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/arrow2.png) 0 center no-repeat !important;}
.vt_fancymenu li ul li a.dock:hover,.vt_fancymenu li ul li a.undock:hover{color:#000 !important;}
.vt_fancymenu li ul li a.undock{display:none;}
.vt_fancymenu li ul.docked li a.undock{display:block !important;}
.vt_fancymenu li ul li.header{background:<?php echo $hovertextcolor;?> url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/main_bg.png) repeat-x !important; border-bottom:none;-moz-border-radius:3px; padding:0 5px !important;}
.vt_fancymenu li ul li{position:relative; display:block;}
.vt_fancymenu li ul li ul{height:auto !important; position:static; width:95%; margin:0 !important; padding:0 5px !important; background-image:url(<?php echo JURI::root();?>modules/mod_vtem_fancymenu/assets/images/sub_bg1.png);}
.vt_fancymenu li ul li ul li.header{display:none !important;}
.vt_fancymenu li ul li ul li{border-top:dotted 1px #888;border-bottom:none;}
<?php echo $css;?>
</style>
