/* javascript :: structure :: umna */

// searchField control
function clearDefault(clearThis) {
	if (clearThis.defaultValue==clearThis.value) clearThis.value = "";
}

// fontSize
fontMin = 9;
fontMax = 20;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=fontMax) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=fontMin) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

// jQuery
jQuery(document).ready(function(){
						   
						   
	jQuery.fn.wait = function(time, type) {
        time = time || 500;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                jQuery(self).dequeue();
            }, time);
        });
    };
						   
						   
	// main menu init: all off
	resetAll();
	
	function resetAll() {
		document.getElementById("discoverIMG").src = "img/mNav_discover_btn.gif";				   
		jQuery("#discoverMenu").stop([true],[true]);					   
		jQuery("#discoverMenu").hide();
		
		document.getElementById("connectIMG").src = "img/mNav_connect_btn.gif";					   
		jQuery("#connectMenu").stop([true],[true]);					   
		jQuery("#connectMenu").hide();
		
		document.getElementById("engageIMG").src = "img/mNav_engage_btn.gif";					   
		jQuery("#engageMenu").stop([true],[true]);				   
		jQuery("#engageMenu").hide();
		
		document.getElementById("joinIMG").src = "img/mNav_join_btn.gif";					   
		jQuery("#joinMenu").stop([true],[true]);				   
		jQuery("#joinMenu").hide();
	}
	
	transitionSpeed = 200;
	
	// mainNav: discoverBTN
	jQuery("#discoverBTN div").hoverIntent(
		function () {
			resetAll();
			jQuery("#discoverMenu").fadeIn(transitionSpeed);
			document.getElementById("discoverIMG").src = "img/mNav_discover_ro.gif";
		}, 
		function () {
			//resetAll();
		}
	);
	
	// mainNav: connectBTN
	jQuery("#connectBTN div").hoverIntent(
		function () {
			resetAll();
			jQuery("#connectMenu").fadeIn(transitionSpeed);
			document.getElementById("connectIMG").src = "img/mNav_connect_ro.gif";
		}, 
		function () {
			//resetAll();
		}
	);
	
	
	// mainNav: engageBTN
	jQuery("#engageBTN div").hoverIntent(
		function () {
			resetAll();
			jQuery("#engageMenu").fadeIn(transitionSpeed);
			document.getElementById("engageIMG").src = "img/mNav_engage_ro.gif";
		}, 
		function () {
			//resetAll();
		}
	);
	
	// mainNav: joinBTN
	jQuery("#joinBTN div").hoverIntent(
		function () {
			resetAll();
			jQuery("#joinMenu").fadeIn(transitionSpeed);
			document.getElementById("joinIMG").src = "img/mNav_join_ro.gif";
		}, 
		function () {
			//resetAll();
		}
	);
	
	
	// reset on mouseOut
	jQuery("#discoverMenu, #connectMenu, #engageMenu, #joinMenu,").hover(
		function () {
			//on
		}, 
		function () {
			resetAll();
		}
	);

});


