/*
 * Droppy 0.1.2
 * (c) 2008 Jason Frame (jason@onehackoranother.com)
 */
 
$.fn.droppy = function(options) {
    
  options = $.extend({speed: 250}, options || {});
  
  this.each(function() {
    
    var root = this, zIndex = 1000;
    
    function getSubnav(ele) {
      if (ele.nodeName.toLowerCase() == 'li') {
        var subnav = $('> ul', ele);
        return subnav.length ? subnav[0] : null;
      } else {
        return ele;
      }
    }
    
    function getActuator(ele) {
      if (ele.nodeName.toLowerCase() == 'ul') {
        return $(ele).parents('li')[0];
      } else {
        return ele;
      }
    }
    
    function hide() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', false);
      setTimeout(function() {
        if (!$.data(subnav, 'cancelHide')) {
          $(subnav).slideUp(options.speed);
        }
      }, 50);
    }
  
    function show() {			
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', true);
      $(subnav).css({zIndex: zIndex++}).slideDown(options.speed);
      if (this.nodeName.toLowerCase() == 'ul') {
        var li = getActuator(this);
        $(li).addClass('hover');
        $('> a', li).addClass('hover');
      }
    }
		
    $('ul, li', this).hover(show, hide);
    $('li', this).hover(
      function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); },
      function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); }
    );
    
  });
	
	//  Animate main logo
	
	$('#posim_logo').mouseover(function(){
		$("#posim_logo").animate({opacity:.75}, 100, function() {
			$("#posim_logo").animate({opacity:1}, 600)
			});																
	});
	
	//  Preload images
	
	jQuery.preloadImages = function(){
		for(var i = 0; i<arguments.length; i++){
			jQuery("<img>").attr("src", arguments[i]);
		}
	}
	
	// preloaded images array
  
	$.preloadImages("template/products_btn_over.png", "template/services_btn_over.png", "template/support_btn_over.png",
									"template/demo_btn_over.png", "template/chat_btn_over.png", "template/training_btn_over.png",
									"template/users_btn_over.png", "template/store_btn_over.png");
	
	//
	
	$(".noclick").click(function(){
		return false;														 
	});
	
	$(".noclick").mouseover(function(){
		$(this).css({'cursor' : 'default'});												 
	});
	
	//////////////  navigation hover
	
	// products
	
	$("#products").hover(
		function () {
        $("#products img").attr({src : 'template/products_btn_over.png'});
      }, 
      function () {
        $("#products img").attr({src : 'template/products_btn.png'});
      }
	);
	
	$("#products").hover(
		function () {
        $("#products img").attr({src : 'template/products_btn_over.png'});
      }, 
      function () {
        $("#products img").attr({src : 'template/products_btn.png'});
      }
	);
	
	//services
	
	$("#services").hover(
		function () {
        $("#services img").attr({src : 'template/services_btn_over.png'});
      }, 
      function () {
        $("#services img").attr({src : 'template/services_btn.png'});
      }
	);
	
	//support
	
	$("#support").hover(
		function () {
        $("#support img").attr({src : 'template/support_btn_over.png'});
      }, 
      function () {
        $("#support img").attr({src : 'template/support_btn.png'});
      }
	);
	
	//training
	
	$("#training").hover(
		function () {
        $("#training img").attr({src : 'template/training_btn_over.png'});
      }, 
      function () {
        $("#training img").attr({src : 'template/training_btn.png'});
      }
	);
	
	//users
	
	$("#users").hover(
		function () {
        $("#users img").attr({src : 'template/users_btn_over.png'});
      }, 
      function () {
        $("#users img").attr({src : 'template/users_btn.png'});
      }
	);
	
	//store
	
	$("#store").hover(
		function () {
        $("#store img").attr({src : 'template/store_btn_over.png'});
      }, 
      function () {
        $("#store img").attr({src : 'template/store_btn.png'});
      }
	);
	
	//chat
	
	$("#chat").hover(
		function () {
        $("#chat img").attr({src : 'template/chat_btn_over.png'});
      }, 
      function () {
        $("#chat img").attr({src : 'template/chat_btn.png'});
      }
	);
	
	//demo
	
	$("#demo").hover(
		function () {
        $("#demo img").attr({src : 'template/demo_btn_over.png'});
      }, 
      function () {
        $("#demo img").attr({src : 'template/demo_btn.png'});
      }
	);

	
		
}; //


//navigation image swap functions

function imageOver(image_source, image){
	$(image).attr({src : image_source});
	
}
	
function imageOut(image_source, image){
	$(image).attr({src : image_source});
}
