﻿

document.write('<style type="text/css">body{display:none}</style>');

$(document).ready (function() {
  $('body').css('display','block');
  $('#submenunav li').hide();
  $('#logingutter').hide();
  $('label.required').append(" <span class=\"red\">*</span>");
  $('.modal-opener').click(function(e) {
      e.preventDefault();
 
   });
   
  
  /// creates a hoverover window for any img with a class of "hover-over" **********
  
  var offsetX = 10;
  var offsetY = 10;
  
  $('.hover-over').hover(function (e) {
      var src = $(this).attr('src');
      var ext = src.substring(src.length - 4, src.length);
      src = src.substring(10, src.length -4) + "-large";
      src = src + ext;
      // alert(src);
      $('<img id="largeImg" src="/graphics/' + src + '" alt="zoom view" />')
      .css('top', e.pageY + offsetY)
      .css('left', e.pageX + offsetX)
      .appendTo('body');
    }, function() {
      $('#largeImg').remove();
    });
  
  $('.hover-over').mousemove(function(e) {
    $('#largeImg').css('top', e.pageY + offsetY).css('left', e.pageX + offsetX);
  });
  
  /// colors the first word of every H1 tag green **********************************
  $('h1').each(function() {
    var me = $(this)
       , t = me.text().split(' ');
    me.html( '<span class="green">'+t.shift()+'</span> '+t.join(' ') );
  });
  
  /// captures click event for the login form at the top of the page ***************
  
  $('#logingutter .loginsubmit').click(function(e) {
    e.preventDefault();   
    doLogin();
  });
  
  $('#loginPage .loginpage').click(function(e) {
    e.preventDefault();   
    doLoginPage();
  });
  
  $('#wasaLogin .wasalogin').click(function(e) {
    e.preventDefault();
    doWasaLogin();
  });
  
  /// end logins ********************************************************************

  
  $('#logintab a').click(function(e) {
    e.preventDefault();
    
    if($('#logingutter').is(":hidden"))
    {
      $('#logingutter').slideDown(500);
    }
    else
    {
      $('#logingutter').slideUp(500);
    }
    
  });
  
  
  /// code that controls subnav fade and styling ***********************************  
  
  $('#nav li a:not(:last)').click (function(e) {    
    e.preventDefault();
    $('#submenunav li').hide();
    var path = $(this).attr("href");
    var section = path.substring(1, path.length - 1);
    $('#submenunav #' + section + ' li').fadeIn(500);    
    $('#nav li').removeClass('active');
    $('#nav li a').removeClass('active');
    $(this).toggleClass('active');
    $(this).parent('li').toggleClass('active');
  });
  
    
  $('#submenunav li a[href=/test/]').click (function(e) {
    e.preventDefault();
    alert("Still working on that page...come back later.");
  });

  var path = location.pathname;
  var pathArr = new Array();
  pathArr = path.split('/');
  var section;
  
  if(pathArr.length >= 3)
  {
    section = pathArr[1];
  } else {
    section = "home";
  }
  
  
  if(path == "/catalog-search.aspx")
  {
    section="catalog";
  }
  
  
  switch(section)
  {
    case "news":
      section = "resources";
      break;  
    case "courses":
      section = "catalog";
      break;
    case "contact":
      section = "about";
      break;
     
  }
  
  
  
  $('#nav a[href=/'+ section + '/]').parent('li').toggleClass('active');
  
  $('#submenunav #' + section + ' li').show();
  var thispage = location.pathname;
  $('#submenunav li a[href=' + thispage + ']').addClass('selected');

 
//    alert(thispage);
    

//  
//  $('#nav dd a[href=/test/]').addClass('red');
//  //alert(section);

});






  
  
  
  

  