// jquery.colorize.js, 2/4/2009 4:29:25 PM
/**
* jQuery.colorize
* Copyright (c) 2008 Eric Karimov - ekarim57(at)gmail(dot)com | http://franca.exofire.net/jq/
* Dual licensed under MIT and GPL.
* Date: 10/27/2008
*
* @projectDescription Table colorize using jQuery.
* http://franca.exofire.net/jq/colorize
*
* @author Eric Karimov, contributor Aymeric Augustin
* @version 1.3.1
*
* @param {altColor, bgColor, hoverColor, hiliteColor,oneClick, columns, banColumns}
* altColor : alternate row background color
* bgColor : background color (The default background color is white).
* hoverColor : background color when you hover a mouse over a row
* hiliteColor : row highlight background color, 'none' could be used for no highlight
* oneClick : true/false(default) -	 if true, clicking a new row reverts the current highlighted row to the original background color
* columns : true/false(default)  - if true, highlights columns instead of rows
* banColumns : []	- columns not to be highlighted; supply an array of column indices, starting from 0
* @return {jQuery} Returns the same jQuery object, for chaining.
*
* @example $('#tbl1').colorize();
*
* @$('#tbl1').colorize({bgColor:'#EAF6CC', hoverColor:'green', hiliteColor:'red', columns:true, banColumns:[4,5,8]});
*
* @$('#tbl1').colorize({ columns : true, oneClick:true});
* All the parameters are optional.
*/

jQuery.fn.colorize = function(params) {
	options = {
		altColor: '#ECF6FC',
		bgColor: '#fff',
		hoverColor: '#BCD4EC',
		hiliteColor: 'yellow',
		oneClick: false,
		columns: false,
		banColumns: []
	};
	jQuery.extend(options, params);

	var colorHandler = {
		checkHover: function() {
			if (!this.onfire) {
				this.origColor = this.style.backgroundColor;
				this.style.backgroundColor= options.hoverColor;
			}
		},
		checkHoverOut: function() {
			if (!this.onfire) {
				this.style.backgroundColor=this.origColor;
			}
		},
		highlight: function() {
			if (options.hiliteColor != 'none') {
				this.style.backgroundColor= options.hiliteColor;
				this.onfire = true;
			}
		},
		stopHighlight: function() {
			this.onfire = false;
			this.style.backgroundColor = this.origColor;
		}
	}

	function getColCells(cells, idx) {
		var arr = [];
		for (var i = 0; i < cells.length; i++) {
			if (cells[i].cellIndex == idx)
				arr.push(cells[i]);
		}
		return arr;
	}

	function processCells(cells, idx, func) {
		var colCells = getColCells(cells, idx);
		jQuery.each(colCells, function(index, cell2) {
			func.call(cell2);
		});
	}

	function processAdapter(cells, cell, func) {
		processCells(cells, cell.cellIndex, func);
	}

	function toggleColumnClick(cells) {
		var func = (!this.onfire) ? colorHandler.highlight : colorHandler.stopHighlight;
		processAdapter(cells, this, func);
	}

	function toggleRowClick(cells) {
		row = jQuery(this).parent().get(0);
		if (!row.onfire)
			colorHandler.highlight.call(row);
		else
			colorHandler.stopHighlight.call(row);
	}

	function oneColumnClick(cells) {
		processAdapter(cells, this, colorHandler.highlight);
		if (cells.clicked > -1) {
			processCells(cells, cells.clicked, colorHandler.stopHighlight);
		}
		cells.clicked  = this.cellIndex;
	}

	function oneRowClick(cells) {
		row = jQuery(this).parent().get(0);
		colorHandler.highlight.call(row);
		if (cells.clicked) {
			colorHandler.stopHighlight.call(jQuery(cells.clicked).parent().get(0));
		}
		cells.clicked = this;
	}

	function checkBan() {
		return (jQuery.inArray(this.cellIndex, options.banColumns) != -1) ;
	}

	return this.each(function() {

		jQuery(this).find('tr:odd').css('background', options.bgColor);
		jQuery(this).find('tr:even').css('background', options.altColor);

		var cells = jQuery(this).find('td,th');
		cells.clicked = null;

		if (options.columns) {
			jQuery.each(cells, function(i, cell) {
				cell.onmouseover = function() {
					processAdapter(cells, this, colorHandler.checkHover);
				}
				cell.onmouseout = function() {
					processAdapter(cells, this, colorHandler.checkHoverOut);
				}
				cell.onclick = function() {
					if (checkBan.call(this))
						return;
					if (options.oneClick)
						oneColumnClick.call(this, cells);
					else
						toggleColumnClick.call(this, cells);
				}
			});
		}
		else {
			jQuery.each(cells, function(i, cell) {
				row = jQuery(cell).parent().get(0);
				row.onmouseover = colorHandler.checkHover ;
				row.onmouseout = colorHandler.checkHoverOut ;
				cell.onclick = function () {
						if (checkBan.call(this))
							return;
						if (options.oneClick)
							oneRowClick.call(this, cells);
						else
							toggleRowClick.call(this, cells);
				}
			});
 		}
 	});
 }




// jquery.badBrowser.js, 1/4/2010 2:09:41 PM
function badBrowser(){return($.browser.msie&&parseInt($.browser.version)<=6)}
function getBadBrowser(i){if(document.cookie.length>0){c_start=document.cookie.indexOf(i+"=");if(c_start!=-1){c_start=c_start+i.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end))}}
return ""}
function setBadBrowser(l,o,i){var I=new Date;I.setDate(I.getDate()+i);document.cookie=l+"="+escape(o)+((i==null)?"":";expires="+I.toGMTString())}
if(badBrowser()&&getBadBrowser('browserWarning')!='seen'){$(function(){$("<div id='browserWarning'>You are using an unsupported browser. Please switch to <a href='http://getfirefox.com'><strong>FireFox</strong></a>, <a href='http://www.opera.com/download/'><strong>Opera</strong></a>, <a href='http://www.apple.com/safari/'><strong>Safari</strong></a> or <a href='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx'>the latest <strong>Internet Explorer</strong> version</a>. Thanks!&nbsp;&nbsp;&nbsp;[<a href='#' id='warningClose'>close</a>] </div> ").css({backgroundColor:'#ffcc00','width':'100%','border-top':'solid 1px #000','border-bottom':'solid 1px #000','text-align':'center',padding:'5px 0px 5px 0px'}).prependTo("body");$('#warningClose').click(function(){setBadBrowser('browserWarning','seen');$('#browserWarning').slideUp('slow');return false})})}


// jquery.archiverollup.js, 5/18/2009 2:46:09 PM
jQuery.fn.archiverollup = function(){
	
	var $theTable = $(this),
		$postFirst,
		$rows,
		re = /\d{1,2}\/\d{1,2}\/(\d{2,4})/i,
		date = new Date(),
		currentYear = date.getFullYear(),
		oldestYear = $("td.articledate:last", $theTable).text().match(re)[1],
		rollupRow,
		bttnYear,
		i;
	
	for(i = oldestYear; i < currentYear; i++){
		/*
		// find the parent TR of TD.articledate
		// and hide them
		------------------------------------------*/
		$("td.articledate:contains('" + i + "')", $theTable).parent("tr").hide();
		// find the first .articledate position
		$posFirst = $("td.articledate:contains('" + i + "'):eq(0)", $theTable).parent("tr");
		// build the rollup row
		rollupRow = "<tr class=\"rollup\"><th colspan=\"2\"><button>" +  i  + "</button></th></tr>";
		// insert it before the first .articledate row		
		$posFirst.before( rollupRow );
	};
	
	// set the behavior of our roll up button
	// some CSS will be needed to make it pretty
	$("tr.rollup button").bind("click", function(e){
		// get the year based on teh button's text
		bttnYear = $(this).text();
		// toggle all hidden .articledate rows based on the year
		$rows = $("td.articledate:contains('" + bttnYear + "')", $theTable).parent("tr");
		$rows.toggle();
		// toggles the class on the button to show
		// this allows us to change the graphic applied
		$(this).toggleClass("close");
	});

};


// jquery.site.js, 7/2/2010 9:41:37 AM
jQuery.fn.callouts = function() {
  return this.each(function() {
    var I = $("p", this), i = I.prev("img").attr("width");
    I.css("width", i)
  })
};
$(function() {
  try {
    $("#right h4").each(function(I) {
      var i = this;
      if(!$(i).find("span").length) {
        $(i).wrapInner("<span/>")
      }
    })
  }catch(e) {
  }
	// external links
	$("a[rel=external]").attr({title: "Opens in new window", target: "_blank"})
		.click(function(){
			var href = $(this).attr("href");
			// only log external sites
			// prevents double logging of external documents such as PDF's
			// which occationally open in a new window
			if( href.search(/http/i) >= 0 ){
				try{
					pageTracker._trackPageview("/outgoing/" + href);
				}catch(e){}
			}
		});
	
	//track file downloads
	$("a[href$=exe],a[href$=pdf],a[href$=zip],a[href$=pps],a[href$=doc],a[href$=xls]")
		.click(function(){
			var href = $(this).attr("href");
			try{
				pageTracker._trackPageview("/download/" + href);
			}catch(e){}
		});

/* -------------------------------------------
	// FlowPlayer w/Overlay
	------------------------------------------- */
	try{
		
		// inserts the overlay and flvplayer containers
		// if not found
		if($("a[href$=flv]").length && !$("#overlay-video").length){
			$("<div id=\"overlay-video\"><div id=\"flvplayer\">&nbsp;</div></div>").appendTo("body");
		}
		
		//FlowPlayer Object
		var $flvPlayer = $f("flvplayer", "/global/flash/flowplayer.swf", {
							clip:{
								scaling: "fit"
							}
		});
		
		// overlay trigger
		$("a[href$=flv]").overlay({
			mask: {
				color: "#000000",
				loadSpeed: 200,
				opacity: 0.5
			},
			target: "#overlay-video",
			// when overlay is opened, load our player
			onLoad: function() {
				var trigger = this.getTrigger(),
					href = trigger.attr("href");
				$flvPlayer.load().play(href);
				try{
					pageTracker._trackPageview(href);
				}catch(e){}
			},
			// when we close the overlay
			// close the player
			onClose: function() {	
				$flvPlayer.unload();
			}	
		});
		
	}catch(e){}
  $("#query").val("Search...").blur(function() {
    var i = this;
    if($(i).val().length == 0 || $(i).val() == "Search...") {
      $(i).val("Search...")
    }
  }).focus(function() {
    var i = this;
    if($(i).val() == "Search...") {
      $(i).val("")
    }
  });
  $("#searchform").submit(function() {
    var i = $("#query");
    if(i.length == 0 || i.val() == "Search...") {
      var I = $(":hidden[name=cq]").val();
      window.location = "/texis/webinator/search?pr=Bemis&amp;cq=" + I;
      return false
    }
  });
  try {
    $(".expandme > a").removeAttr("onclick").attr({href:"#", title:"Click to expand"}).click(function() {
      $(this).parent().nextAll(".contentstub:eq(0)").slideToggle("normal");
      return false
    })
  }catch(e) {
  }
  try {
    var l = $("<img/>").attr({src:"/global/images/new-transparent.gif", width:"17", height:"5", alt:"New!"});
    $(".new").prepend(l.clone())
  }catch(e) {
  }
  try {
    $("div.callout").callouts()
  }catch(e) {
  }
  try {
    $("#listtools").remove();
    $("#list").attr("id", "navtree");
    $("#navtree").menuTree()
  }catch(e) {
  }
});


// jquery.news.js, 12/17/2009 10:02:14 AM
$(function(){try{$("#morenews").colorize({altColor:"#f2f2f2",hiliteColor:"none",hoverColor:"#cde"})}catch(e){};try{$("#morenews").archiverollup()}catch(e){};try{$("#printthis").attr("href","#").click(function(){window.print();return false})}catch(e){}});
