$(document).ready(function() {

  ////////////////////////////////////////////////////
  //                                                //
  //              Edit This Section                 //
  //                                                //
  ////////////////////////////////////////////////////

  // Enter the src or href that identifies the image or anchor.
  // One entry per line.
  // Place all entries in quotes.
  // Each line (except the last) should end with a comma (outside of the quotes).
  //
  // Example:
  //
  //    var alt_value = new Array(
  //      "http://www.ucsc-extension.edu",
  //      "/ucsc/specialrequest/publicSpecialRequest.do?method=load",
  //      "/ucsc/portal/student/studentNews.do?method=load",

  //    );
  //
  //
  var alt_value = new Array(
    "http://www.ucsc-extension.edu",
	"http://www.ucsc-extension.edu/view/certificates",
	"/ucsc/portal/logon.do?method=load",
	"http://www.ucsc-extension.edu/view/aos",
	"http://www.ucsc-extension.edu/view/onsite/home",
	"http://www.ucsc-extension.edu/view/online",
	"http://www.ucsc-extension.edu/view/aboutus",
	"http://www.ucsc-extension.edu/content/contact-us",
	"/ucsc/portal/student/studentHome.do?method=load",
	"/ucsc/portal/student/studentProfile.do?method=edit",
	"/ucsc/portal/student/studentAcademicHistory.do?method=load",
	"/ucsc/portal/student/studentAccountInfo.do?method=load",
	"/ucsc/portal/student/studentStudentServices.do?method=load",
	"/ucsc/specialrequest/publicSpecialRequest.do?method=load",
	"/ucsc/portal/student/studentNews.do?method=load",
	"/ucsc/portal/pdfs/Studenthelp.pdf",
	"/ucsc/specialrequest/publicSpecialRequest.do?method=addSpecialRequestWithCode&code=SR0051",
	"/ucsc/public/student/studentRequestInformation.do?method=load",
	"/ucsc/generalInfo/enrollment/books.jsp",
	"/ucsc/coursebasket/publicCourseBasket.do?method=load",
	"/ucsc/images/nav/buttons/portal/save_drk.gif",
	"/ucsc/images/nav/buttons/forms/remove_off.gif",
	"/ucsc/portal/student/studentTimetable.do?method=load",
	"/ucsc/eli/eli.jsp",
	"/ucsc/images/nav/buttons/news/back_news_off.gif",
	"/ucsc/images/nav/buttons/news/news_previous_off.gif",
	"/ucsc/images/nav/buttons/news/news_next_off.gif",
	"/ucsc/portal/student/studentNews.do?method=previousNews",
	"/ucsc/portal/student/studentNews.do?method=nextNews",
	"/ucsc/images/pagetitles/req_info.gif",
	"http://www.amazon.com/exec/obidos/redirect-home/ucscextensionboo",
	"/ucsc/images/nav/buttons/search/print_version_off.gif",
	"/ucsc/images/nav/buttons/coursebasket/add2_cart_off.gif",
	"/ucsc/images/nav/buttons/coursebasket/checkout_off.gif",
	"/ucsc/images/pagetitles/instructor_log_in.gif",
	"/ucsc/images/nav/buttons/forms/email_password_off.gif",
	"/ucsc/images/nav/buttons/forms/cancel_off.gif"
  );

  // Enter the tags to be used with the above list.
  // Each line here pairs with the same line in the list above.
  // One entry per line.
  // Place all entries in quotes.
  // Each line (except the last) should end with a comma (outside of the quotes).
  //
  // Example:
  //
  //    var alt_tag = new Array(
  //      "Home Page",
  //      "Special Request",
  //      "Student News"
  //    );
  //
  //
  var alt_tag = new Array(
    "Home Page",
	"Certificates",
	"Login",
	"Areas of Study",
	"Onsite Home Page",
	"Online Home",
	"About Us",
	"Contact Us",
	"Student Home",
	"Student Profile",
	"Academic History",
	"Account Information",
	"Student Services",
	"Special Request",
	"News",
	"Help",
	"Certificate and Award Applications",
	"Request More Information",
	"Textbooks",
	"My Cart",
	"Save",
	"Remove",
	"Timetable",
	"International Students",
	"Back to Headlines",
	"Previous News Article",
	"Next News Article",
	"Previous News Article",
	"Next News Article",
	"Request More Information",
	"Amazon.com",
	"Print Version",
	"Add to Cart",
	"Checkout",
	"Instructor Login",
	"Email Password",
	"Cancel"
  );
  
  ////////////////////////////////////////////////////
  //                                                //
  // !! DO NOT EDIT ANYTHING BELOW THIS SECTION !!  //
  //                                                //
  ////////////////////////////////////////////////////
  
  // variables
  var no = "<b>Not Done =></b> ";
  var yes = "<b>Done! =></b> ";
  var done = no;
  var g;
  
  //
  //
  // Reporting Empty Alt Tags
  //
  //
  
  //$("body").append("<p>Note: This is not a complete list of images and anchors on this page. It is only those images and anchors which are determined to need tags dynamically generated.</p>");
  
  // for anchors
  //$("body").append("<p><b><u>Anchor Paths With Missing Alt Tags</u></b><br>Note: Only anchors around images are displyed here since the text anchors are automatically being generated already.</p>");
  $("a").each(function() {
  
    // find all anchors with no alt tag
    if (!($(this).attr("alt"))) {
	
	  // check to see if it surrounds (1) text or an (2) image
	  if ($(this).text()) {
	  
	    // automatically generate an ALT tag using the text
	    var value = $(this).text();
	    $(this).attr("alt", value);
		
	  } else {
	  
	    if ($(this).attr("href")) {
	    
		  done = no;
		
		  // check to see if there is an entry for this tag
	      for (var i = 0; i < alt_value.length; i++) {
            if( $(this).attr("href") == alt_value[i] ) {
	          done = yes;
              g = i;
	        }
	      }
		
		  // display output to the screen
	      if (done == yes) {
	        //$("body").append(
	        //  done + "<b>" + alt_tag[g] + ": </b>" + $(this).attr("href") + "<br>" 
	        //);
	      } else {
	        //$("body").append(
	        //  done + $(this).attr("href") + "<br>" 
	        //);
	      }
		  
		}
		
	  }
	}
  });
  
  // for images
  //$("body").append("<p><b><u>Image Paths With Missing Alt Tags</u></b></p>");
  $("img").each(function() {
  
    // find all anchors with no alt tag
    if (!($(this).attr("alt")) &&
	    !($(this).attr("src") == "/ucsc/images/1x1.gif") &&
		!($(this).attr("src") == "/ucsc//images/1x1.gif") &&
		!($(this).attr("src") == "/ucsc/images/bullet.gif") &&
		!($(this).attr("src") == "/ucsc/images/nav/btmnav/btmnav_line.gif") &&
		!($(this).attr("src") == "/ucsc/images/arrows_blue.gif") &&
		!($(this).attr("src") == "/ucsc/images/nav/student/sp_menu_space.gif") &&
		!($(this).attr("src") == "/ucsc/images/H_new_bullet.gif")) {
	
	  done = no;
	  
	  // check to see if there is an entry for this tag
	  for (var i = 0; i < alt_value.length; i++) {
        if( $(this).attr("src") == alt_value[i] ) {
	      done = yes;
		  g = i;
	    }
	  }
	  
	  // display output to the screen
	  if (done == yes) {
	    //$("body").append(
	    //  done + "<b>" + alt_tag[g] + ": </b>" + $(this).attr("src") + "<br>" 
	    //);
	  } else {
	    //$("body").append(
	    //  done + $(this).attr("src") + "<br>" 
	    //);
	  }
	  
	}
	
  });

  //
  //
  // Modify Tags
  //
  //

  // for achors
  $("a").each(function() {
  
    // cycle through the values array
    for (var i = 0; i < alt_value.length; i++) {
	
	  // if the href matches a value, then apply the tag
      if( $(this).attr("href") == alt_value[i] ) {
	    $(this).attr("alt", alt_tag[i]);
	  }
	  
	}
	
  });
  
  // for images
  $("img").each(function() {
  
    // cycle through the values array
    for (var i = 0; i < alt_value.length; i++) {
	
	  // if the src matches a value, then apply the tag
      if( $(this).attr("src") == alt_value[i] ) {
	    $(this).attr("alt", alt_tag[i]);
	  }
	  
	}
	
  });
  
});

