﻿$(document).ready(function() {
    $(".tout").hover(
			    function() { $(this).find(".more a").css("background-position", "0 -20px"); },
			    function() { $(this).find(".more a").css("background-position", "0 0"); }
			    ).css("cursor", "pointer").click(function() { window.location = $(this).find(".more a").attr("href"); });
    $("tr:odd").addClass("stripe");
    $("ul.stripe li:even").addClass("stripe");
    $("a[href*='.pdf']").addClass("pdf");
    $("#maintopic .secYear").css("display", "none").first().css("display", "block");
    $("#maintopic a.secYearLink").click(function() {
        var $this = $(this);
        var years = $this.attr("href");
        $("#maintopic .secYear").css("display", "none");
        $(years).css("display", "block");
    });
    //search box text
    $(".searchbox").focus(function() { $this = $(this); if ($this.val() == "Search") { $this.val(""); } }).blur(function() { $this = $(this); if ($this.val() == "") { $this.val("Search"); } });
    //popoutform
    var reqForm = $("#form1");
    $("#requestinfo").toggle(
        function() { reqForm.css("display", "block"); $(this).parent().addClass("hover"); },
        function() { reqForm.css("display", "none"); $(this).parent().removeClass("hover"); }
        );
    $(".closer").click(function() { $(this).parent().css("display", "none").parent().removeClass("hover"); return false; });
    if ($("#actionBtns .val").text() != "" || $(".EditingFormInfoLabel").text() != "") { reqForm.css("display", "block"); reqForm.parent().addClass("hover"); }
    $("#curURLinput input").val(window.location);
    //end popoutform
	$('a:not(.noexternal)').each(function(){ if(isExternal($(this).attr('href'))) { $(this).addClass("external").attr("target","_blank"); } });
});

function isExternal(strHref) {
	var bExternalLink = false;
	if (strHref.indexOf("http://") != -1) {
		if(getDomain(strHref).toString().indexOf("multnomah.edu") == -1) { bExternalLink = true; } //dhref != getDomain(window.location.href) && 
	}
	return bExternalLink;
}
function getDomain(pageurl) {
   var urldomain = pageurl.match(/:\/\/(.[^/]+)/)[1]; return urldomain;
}
/// <summary>
/// Get parameters from the URL
/// Author  : Bruno Leonardo Michels
/// Date    : 2010 Apr 21 - 06:12pm GMT+0
/// Version : 0.1
/// Category: jQuery plugin
/// License : Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html)
/// http://plugins.jquery.com/project/QueryStringdotnet
/// </sumary>
/// <example>
/// <code>
///     var q0 = $.QueryString["search"]; // ?search=123&cat=1 (123)
///     var q1 = $.QueryString["foo"]; // ?search=123&cat=1 (undefined)
/// </code>
/// </example>
jQuery.extend({'QueryString':window.location.search.length<=1?new Array():function(a){var b=new Array();for(var i=0;i<a.length;++i){var p=a[i].split('=');b[p[0]]=decodeURIComponent(p[1]);}return b;}(window.location.search.substr(1).split('&'))});
