// Common JS Library, requires jQuery

// execute scripts
$(document).ready( function(){
	
// auto mouseover script
	AutoMouseOver.init();
   
// faq toggle   
	$("dl#faqs")
	.find("dd").addClass("hide").hide().end()
	.find("dt").addClass("toggleOff").wrapInner("<div class=\"toga\">")
	.toggle(
			function(){ $(this).swapClass("toggleOff", "toggleOn").next("dd").slideDown("normal"); },
			function(){ $(this).swapClass("toggleOff", "toggleOn").next("dd").slideUp("normal"); }
	);
	// Payment options Fisheye
	
	if($('ul.fisheye').get(0) && $.browser.version!="6.0"){
		$('ul.fisheye').jqDock({ 
			align:        'middle',
			size:         20,
			distance:     90,
			coefficient : 1.5,
			labels:       false,
			duration : 200   
		});
	}
});


// Auto mouseover preloader, detects onmouseover img src, and preloads the mouseover img
AutoMouseOver ={
	init: function(){
		this.preload();    
		$("img").hover(
			function () { $(this).attr( 'src', this.over);},
			function () { $(this).attr( 'src', this.old);}
		);
	},
	preload: function(){
		$(window).bind('load', function() {
			$('img').each( function( key, elm ) { 
				try{
					if((this.attributes.onmouseover!=null) && (this.attributes.onmouseover.nodeValue.match(".jpg'$|.png'$|.gif'$"))){
						this.over = this.attributes.onmouseover.nodeValue.replace(/'/g, "");
						this.old = this.src;
						$('<img>').attr( 'src',this.over);
					}
				}catch(err){

				}					
			});
		});
	}
};
$.fn.swapClass = function(c1,c2) {
    return this.each(function() {
        if ($(this).hasClass(c1)) {
            $(this).removeClass(c1);
            $(this).addClass(c2);
        } else if ($(this).hasClass(c2)) {
            $(this).removeClass(c2);
            $(this).addClass(c1);
        }                    
    });
};

