//drop menu and navigation
$(document).ready(function () {
        function addMega1() {
            $(this).addClass("hovering");
        }
        function removeMega1() {
            $(this).removeClass("hovering");
        }
        var megaConfig1 = {
            interval: 250,
            sensitivity: 4,
            over: addMega1,
            timeout: 250,
            out: removeMega1
        };
		$("li.mega-products").hoverIntent(megaConfig1);
	});
	
$(document).ready(function () {
        function addMega2() {
            $(this).addClass("hovering");
        }
        function removeMega2() {
            $(this).removeClass("hovering");
        }
        var megaConfig2 = {
            interval: 250,
            sensitivity: 4,
            over: addMega2,
            timeout: 250,
            out: removeMega2
		};
		$("li.mega-solutions").hoverIntent(megaConfig2);
	});
	
$(document).ready(function () {
        function addMega3() {
            $(this).addClass("hovering");
        }
        function removeMega3() {
            $(this).removeClass("hovering");
        }
        var megaConfig3 = {
            interval: 250,
            sensitivity: 4,
            over: addMega3,
            timeout: 250,
            out: removeMega3
		};
		$("li.mega-services").hoverIntent(megaConfig3);
	});
		
$(document).ready(function () {
        function addMega4() {
            $(this).addClass("hovering");
        }
        function removeMega4() {
            $(this).removeClass("hovering");
        }
		var megaConfig4 = {
            interval: 250,
            sensitivity: 4,
            over: addMega4,
            timeout: 250,
            out: removeMega4
		};
		$("li.mega-support").hoverIntent(megaConfig4);
	});
	
$(document).ready(function () {
        function addMega5() {
            $(this).addClass("hovering");
        }
        function removeMega5() {
            $(this).removeClass("hovering");
        }
		var megaConfig5 = {
			interval: 250,
			sensitivity: 4,
			over: addMega5,
			timeout: 250,
			out: removeMega5
		};
		$("li.mega-clearance").hoverIntent(megaConfig5);
	});

$(document).ready(function () {
        function addMega6() {
            $(this).addClass("hovering");
        }
        function removeMega6() {
            $(this).removeClass("hovering");
        }
		var megaConfig6 = {
			interval: 250,
			sensitivity: 4,
			over: addMega6,
			timeout: 250,
			out: removeMega6
		};
		$("li.mega-question").hoverIntent(megaConfig6);
	});

// related products jcarousellite
$(function () {
    $(".relatedproducts").jCarouselLite({
        btnNext: ".nexttwo",
        btnPrev: ".prevtwo"
    });
});

// breadcrumbing
$(document).ready(function ()
{
	jQuery("#breadCrumb").jBreadCrumb({easing: 'swing'});
});

$(document).ready(function ()
{
	jQuery("#breadCrumb2").jBreadCrumb({easing: 'swing'});
});

// product page thumbnail colorbox
$(document).ready(function () {
	$("a[rel='prod']").colorbox({});
	$(".colorbox").colorbox({width: "850px", height: "575px", iframe: true});
	$("a.single").colorbox({});
	$("#inline-tour").colorbox({width: "550px", inline: true, href: "#kickoutthejams"});
	// learn more
	$("#learn1").colorbox({width: "475px", inline: true, href: "#learnmore1"});
	$("#learn2").colorbox({width: "475px", inline: true, href: "#learnmore2"});
	$("#learn3").colorbox({width: "475px", inline: true, href: "#learnmore3"});
	$("#learn4").colorbox({width: "475px", inline: true, href: "#learnmore4"});
	$("#learn5").colorbox({width: "475px", inline: true, href: "#learnmore5"});
	// form url listing
	$("a[href='http://www.transcriptiongear.com/fpp/catalog/catalog_request.htm']").colorbox({width: "790px", height: "575px", iframe: true});
	// youtube direct
	$(".youtube").colorbox({iframe: true, width: "650px", height: "550px"});
});

// cart buttons
$(document).ready(function () {
	$('.button-addtocart').hover(
		function () { // Change the input image's source when we "roll on"
			$(this).attr({ src: '/img/button_add-to-cart_b.gif'});
		},
		function () { // Change the input image's source back to the default on "roll off"
			$(this).attr({ src: '/img/button_add-to-cart_a.gif'});
		});
	$('.button-addonetocart').hover(
		function () {
			$(this).attr({ src: '/img/button_add-one-to-cart_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_add-one-to-cart_a.gif'});
		});
	$('.button-buyonenow').hover(
		function () {
			$(this).attr({ src: '/img/button_buy-one-now_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_buy-one-now_a.gif'});
		});
	$('.button-next').hover(
		function () {
			$(this).attr({ src: '/img/button_next_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_next_a.gif'});
		});
	$('.button-prev').hover(
		function () {
			$(this).attr({ src: '/img/button_previous_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_previous_a.gif'});
		});
	$('.button-continueshopping').hover(
		function () {
			$(this).attr({ src: '/img/button_continueshopping_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_continueshopping_a.gif'});
		});
	$('.button-checkout').hover(
		function () {
			$(this).attr({ src: '/img/button_checkout_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_checkout_a.gif'});
		});
	$('.button-continuecheckout').hover(
		function () {
			$(this).attr({ src: '/img/button_continuecheckout_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_continuecheckout_a.gif'});
		});
	$('.button-save').hover(
		function () {
			$(this).attr({ src: '/img/button_save_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_save_a.gif'});
		});
	$('.button-login').hover(
		function () {
			$(this).attr({ src: '/img/button_login_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_login_a.gif'});
		});

	$('.button-remove').hover(
		function () {
			$(this).attr({ src: '/img/button_remove_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_remove_a.gif'});
		});
	$('.button-update').hover(
		function () {
			$(this).attr({ src: '/img/button_update_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_update_a.gif'});
		});
	$('.button-learnmore').hover(
		function () {
			$(this).attr({ src: '/img/button_learnmore_b.gif'});
		},
		function () {
			$(this).attr({ src: '/img/button_learnmore_a.gif'});
		});
});

// outgoing links
$(document).ready(function () {
        $( '.outgoing' ).each(
            function() {
                this.target = '_blank';
            });
    });

//iframe validation help
$(document).ready(function () {
	// create xhtml strict friendly iframe
	$('a.iframe').each(
	function (i) {
		$(this).replaceWith("<iframe src='" + this.getAttribute("href") + "' width='750' height='660' frameborder='0' scrolling='auto'></iframe>");
	});
});

jQuery.dbPopWin = function (url, options) {
	options = jQuery.extend(
		{
			/* default options */
			dbPopWinWidth: 400,
			dbPopWinHeight: 400,
			dbPopWinTarget: 'dbPopWin',
			dbPopWinScrollbars: 'yes',
			dbPopWinResizable: 'no',
			dbPopWinMenuBar: 'no',
			dbPopWinAddressBar: 'yes'
		},
		options
	);

	/* center the window by default. */
	if (!options.dbPopWinY)
	{
		options.dbPopWinY = screen.height / 2 - options.dbPopWinHeight / 1;
	}
	if (!options.dbPopWinX)
	{
		options.dbPopWinX = screen.width / 2 - options.dbPopWinWidth / 2;
	}

	open(
		url,
		options['dbPopWinTarget'],
		'width= '      + options.dbPopWinWidth +
		',height='     + options.dbPopWinHeight + 
		',top='        + options.dbPopWinY + 
		',left='       + options.dbPopWinX + 
		',scrollbars=' + options.dbPopWinScrollbars +
		',resizable='  + options.dbPopWinResizable +
		',menubar='    + options.dbPopWinMenuBar +
		',location='   + options.dbPopWinAddressBar
	);
	return false;
};

$(document).ready(function () {
	$('a[rel="dbPopWin"]').click(
		function ()
		{
			return $.dbPopWin($(this).attr('href'), { dbPopWinWidth: 630, dbPopWinHeight: 500 });
		});
	});

/*
addPrintLink function by Roger Johansson, www.456bereastreet.com
*/
var addPrintLink = {
	init:function(sTargetEl,sLinkText) {
		if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
		if (!document.getElementById(sTargetEl)) {return;} // Check that the target element actually exists
		if (!window.print) {return;} // Check that the browser supports window.print
		var oTarget = document.getElementById(sTargetEl);
		var oLink = document.createElement('a');
		oLink.id = 'print-link'; // Give the link an id to allow styling
		oLink.href = '#'; // Make the link focusable for keyboard users
		oLink.appendChild(document.createTextNode(sLinkText));
		oLink.onclick = function() {window.print(); return false;} // Return false prevents the browser from following the link and jumping to the top of the page after printing
		oTarget.appendChild(oLink);
	},
/*
addEvent function included here for portability. Replace with your own addEvent function if you use one.
*/
/* addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */
	addEvent:function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
addPrintLink.addEvent(window, 'load', function(){addPrintLink.init('article','Print this page');});
