
function initOverLabels () {
  if (!document.getElementById) return;

  var labels, id, field;

  // Set focus and blur handlers to hide and show
  // LABELs with 'overlabel' class names.
  labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {

    if (labels[i].className == 'overlabel') {

      // Skip labels that do not have a named association
      // with another field.
      id = labels[i].htmlFor || labels[i].getAttribute('for');
      if (!id || !(field = document.getElementById(id))) {
        continue;
      }

      // Change the applied class to hover the label
      // over the form field.
      labels[i].className = 'overlabel-apply';

      // Hide any fields having an initial value.
      if (field.value !== '') {
        hideLabel(field.getAttribute('id'), true);
      }

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };

      // Handle clicks to LABEL elements (for Safari).
      labels[i].onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };

    }
  }
};

function hideLabel (field_id, hide) {
  var field_for;
  var labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
    field_for = labels[i].htmlFor || labels[i].getAttribute('for');
    if (field_for == field_id) {
      labels[i].style.textIndent = (hide) ? '-9999px' : '0px';
      return true;
    }
  }
}




window.onload = function () {

  setTimeout(initOverLabels, 50);
	document.documentElement.className = "jsOn";
};

function toggle(id) {
	el = document.getElementById(id);
	if (el) {
		if (el.style.display == 'block') el.style.display = 'none'
		else el.style.display = 'block';
	}
}

$(document).ready(function(){
	$("body").addClass("jsok");

	$("a[href$='jpg'], a[href$='png'], a[href$='gif'], a[href$='bmp'], .nyromodal").nyroModal({ zIndexStart: 1001});
	$("a[href$='JPG'], a[href$='PNG'], a[href$='GIF'], a[href$='BMP'], a.thickbox").nyroModal({ zIndexStart: 1001});
  	
  $('#col1, #col2, #col3').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});
	$('#col1, #col2, #col3').click(function(){
		var href = $(this).children('.block').children('h1').children('a').attr('href');
		location.href = href;
		return false;
	});

	//labelify
	$("#login,#password").labelify({
		text: "label",
		labelledClass: "labelhi"
	});

	// news cycler
	$('#banner ul').cycle({
		fx: "fade",
		timeout: 3000,
		speed: 500,
		pause: 1
	});

	// pull down menu
	jQuery.browser.version = jQuery.browser.msie && parseInt(jQuery.browser.version) >= 6 && window["XMLHttpRequest"] ? "7.0" : jQuery.browser.version;
	if ($.browser.msie && $.browser.version <= 6) { $('#nav').addClass('ie');}
	$("#nav li.sub").hoverIntent({
	     sensitivity:3, // number = sensitivity threshold (must be 1 or higher)
	   	 interval: 100, // number = milliseconds for onMouseOver polling interval
	     over: function(){$(this).addClass('jHover').children('ul').show();},
	   	 timeout: 100, // number = milliseconds delay before onMouseOut
	     out: function(){$(this).children('ul').hide();$(this).removeClass('jHover');}
	});
      
      
      	
	
	$("a[rel='external']").attr({target: "_blank"});
	$('.quest').click(function(){
		$(this).next().slideToggle();
	});
 	$('.quest').hover(function() {$(this).addClass('hover');}, function() {$(this).removeClass('hover'); });  


	// print button
  $('.print').click(function(){window.print();return false;});

  
  $("#profi1").jHelperTip({trigger: "hover",source: "container", dC:"#tip1", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#profi2").jHelperTip({trigger: "hover",source: "container", dC:"#tip2", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#profi3").jHelperTip({trigger: "hover",source: "container", dC:"#tip3", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#profi4").jHelperTip({trigger: "hover",source: "container", dC:"#tip4", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#profi5").jHelperTip({trigger: "hover",source: "container", dC:"#tip5", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#oasis1").jHelperTip({trigger: "hover",source: "container", dC:"#tip1", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#oasis2").jHelperTip({trigger: "hover",source: "container", dC:"#tip2", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#oasis3").jHelperTip({trigger: "hover",source: "container", dC:"#tip3", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#oasis4").jHelperTip({trigger: "hover",source: "container", dC:"#tip4", opacity: 0.9, topOff: 10, leftOff: 10 });
  $("#oasis5").jHelperTip({trigger: "hover",source: "container", dC:"#tip5", opacity: 0.9, topOff: 10, leftOff: 10 });   

});
