/*
* Author : Irving Dela Cruz
* Version : 2
* Definition : RollOverzzzzzz
* Type : Rollover utility
*
*/

(function( $ ){

  $.fn.kalrollover = function( options ) {  

    var settings = {
		itemid : 0,
		itemwidth :0,
		itemheight:0,
		itembgposx:0,
		itembgposy:0,
		bgimage:null,
		option:'pulldown',
		type: 'horizontal'
    };

    return this.each(function() {
	
      if ( options ) { 
        $.extend( settings, options );
      }
	  
	  //MAIN MENU
	  
	  $root = $(this);      	
	  
	  
		   $(this).find("ul > li:eq("+ settings.itemid +")").css({
			"width":settings.itemwidth + "px",
			"height":settings.itemheight + "px",
			"float" :"left"
		  });		  
		  
		  $(this).find("ul > li:eq("+ settings.itemid +") a").css({
	          "width":settings.itemwidth + "px",
			  "height":settings.itemheight + "px",
	         "display":"block"
		   });
			  
		  $(this).find("ul > li:eq("+ settings.itemid +")").css({
			
			"width":settings.itemwidth + "px",
			"height":settings.itemheight + "px",
			"background-image":"url("+ settings.bgimage +")",
			"background-position" : settings.itembgposx+"px " + settings.itembgposy +"px"
		  });
		  
		  $(this).find(" ul > li:eq("+ settings.itemid +")").mouseover(function(){			
		   $(this).css({
			 "background-position" : settings.itembgposx+"px " + -settings.itemheight +"px"
		   });		
		});
		
	  
		$(this).find(" ul > li:eq("+ settings.itemid +")").mouseout(function(){
		   $(this).css({
			   "background-position" : settings.itembgposx+"px " + "0px"
		   });
		});
		  
		  $(this).find("ul ul").css({
			    "display":"none",
		       "width":settings.itemwidth + "px"		   
		   });		
		   
		   
		   $(this).find(" ul > li:eq("+ settings.itemid +")").mouseover(function(){
			 $(this).find("ul").css({				 
			   "display" : "block",
			   "width":settings.itemwidth + "px"
			 });
			$(this).find(" ul > li:eq("+ settings.itemid +")").css({
				"background-image":"url("+ settings.bgimage +")",
				 "background-position" : settings.itembgposx+"px " + -settings.itemheight +"px"				 
			 });
		  });
		  
		 $(this).find(" ul > li:eq("+ settings.itemid +")").mouseout(function(){
			 $(this).find("ul").css({
			   "display" : "none"
			 });	
			$(this).find(" ul > li:eq("+ settings.itemid +")").css({
				 "background-image":"url("+ settings.bgimage +")",
				 "background-position" : settings.itembgposx+"px " + "0px"
			 });	
		  });
	  
    });
  };
})( jQuery );// JavaScript Document
