/*
* Author : Irving Dela Cruz
* Version : 3
* 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);
	  
	  
	  if(settings.type == "vertical"){
		  		  
	      $root.find("ul > li:eq("+ settings.itemid +")").css({
			"width":settings.itemwidth + "px",
			"height":settings.itemheight + "px",
			"float" :"left"
		  });
		  
			  
		  $root.find("ul > li:eq("+ settings.itemid +") a").css({
			  "background-color":"#FFFFFF",
			"width":settings.itemwidth + "px",
			"height":settings.itemheight + "px",
			"float" :"left",
			"background-image":"url("+ settings.bgimage +")",
			"background-position":"0 " + settings.itemid * -settings.itemheight + "px"
		  });
		  
		  
		  $root.find(" ul > li:eq("+ settings.itemid +") a").mouseover(function(){
		   $(this).css({
			 "background-position": -settings.itemwidth + "px " + settings.itemid * -settings.itemheight + "px"
		   });		
		});
	  
		$root.find(" ul > li:eq("+ settings.itemid +") a").mouseout(function(){
		   $(this).css({
			   "background-position":"0 " + settings.itemid * -settings.itemheight + "px"
		   });
		});
		  
	  }
	  else
	  {
		   $root.find("ul > li:eq("+ settings.itemid +")").css({
			"width":settings.itemwidth + "px",
			"height":settings.itemheight + "px",
			"float" :"left",
			"background-image":"url("+ settings.bgimage +")",
			"background-position" : settings.itembgposx+"px " + settings.itembgposy +"px"
		  });		  
			  
		  $root.find("ul > li:eq("+ settings.itemid +") a").css({
			"width":settings.itemwidth + "px",
			"height":settings.itemheight + "px",
			"float":"left"
			
		  });
		  
		  $root.find(" ul > li:eq("+ settings.itemid +") a").mouseover(function(){
		   $(this).css({
			// "background-position" : settings.itembgposx+"px " + -settings.itemheight +"px"
		   });		
		});
	  
		$root.find(" ul > li:eq("+ settings.itemid +") a").mouseout(function(){
		   $(this).css({
			   //"background-position" : settings.itembgposx+"px " + "0px"
		   });
		});
	  }
	 
	 
	  
	  //DROP DOWN MENU
	  
	  if(settings.type == "vertical")
	  {
	  
	  }
	  else
	  {
		  
		  
		  $root.find("ul ul").css({
		   "width":settings.itemwidth + "px"
		   });		  
		   
		   if(settings.option == "pullup"){
			   
			   multiplier = $root.find("ul ul:eq("+settings.itemid+") li").length -1;
			   total = (multiplier * settings.itemheight) * -1;
			   $root.find("ul ul:eq("+settings.itemid+")").css({
				   "top":-130
			   });
		   }  
		   
		   
		   
		   $root.find(" ul > li:eq("+ settings.itemid +")").mouseover(function(){
			 $(this).find("ul").css({
			   "display" : "block",
			   "width":settings.itemwidth + "px"
			 });
			 $root.find(" ul > li:eq("+ settings.itemid +")").css({
				 "background-image":"url("+ settings.bgimage +")",
				 "background-position" : settings.itembgposx+"px " + -settings.itemheight +"px"
			 });
		  });
		  
		  $root.find(" ul > li:eq("+ settings.itemid +")").mouseout(function(){
			 $(this).find("ul").css({
			   "display" : "none"
			 });	
			 $root.find(" ul > li:eq("+ settings.itemid +")").css({
				 "background-image":"url("+ settings.bgimage +")",
				 "background-position" : settings.itembgposx+"px " + "0px"
			 });	
		  });
		  
		  
		  
		  
	  }
	  
    });
  };
})( jQuery );// JavaScript Document
