﻿/**
 * Rollover script using j-query.
 * 
 * Thomas Nicolosi
 * 1-to-1 Products
 * tom@1to1products.com
 *
 * Rev. 1.0.0 
 * 2009-07-03
 *
 * Requires transparent *.png file and *-hover.png file. 
 * The *-hover.png file must include an alpha layer. Color the alpha channel as desired and set
 * the opacity as appropriate (30% seems to work well).  
 * Since IE 6 does not support alpha channel in png files the opacity and color of the hover image must be set
 * using the filter style attribute in the style sheet. In order to implement this the browser is detected and then the appropriate class is added or removed.
 *
 */
function rollOn(selected){
	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	var theImage = $(selected).children("img");
    if (badBrowser) {
			theImage.addClass("ie-hover");
		} else {						
				var imgPath = $(selected).children("img").attr("src");
				var theEnd = imgPath.indexOf(".");
				imgPath = imgPath.slice(0,theEnd) + "-hover.png";
				theImage.attr({src: imgPath}).end();
				}
	}
function rollOff(selected){
	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	var theImage = $(selected).children("img");
    if (badBrowser) {
			theImage.removeClass("ie-hover");
		} else { 
				var imgPath = $(selected).children("img").attr("src");
				var theEnd = imgPath.indexOf("-");
				imgPath = imgPath.slice(0,theEnd) + ".png";
				theImage.attr({src: imgPath});
				}
	}
$(document).ready(function(){
	$(".banner-img-container").children("a.main-banner-overlay").hover(function(){
							rollOn("a.main-banner-overlay");
							}, 
							function(){
									rollOff("a.main-banner-overlay");
									});
	$(".banner-img-container").children("a:not(.link-button):not(.main-banner-overlay)").hover(function(){
							rollOn(this);
							}, 
							function(){
									rollOff(this);
									});
	});
