// JavaScript Document

// ADDS IMAGES INTO THE SEARCH RESULTS WHEN AN IMAGE IS NOT AVAILABLE
function default_sr_img(img_td, default_img, alt, link_start)
{
	td = document.getElementById(img_td);
	if (td != null)
	{
		if (td.innerHTML.indexOf("src=",0) == -1)
		{
			td.innerHTML = link_start + "<img src=\"/acatalog/" + default_img + "\" alt=\"" + alt + "\" title=\"" + alt + "\" width=\"50\" height=\"50\" class=\"thumbnailimage\" /></a>";
		}
	}
}

if(typeof(jQuery) == "function")
{
	// code in here to be used with jQuery
	/*
<td width="10">&nbsp;</td>
<td valign="top" width="287">
<div id="tm">
<div id="tmi">
<strong>Testimonials:</strong>
<marquee behavior="scroll" direction="up" height="55" width="250" scrollamount="1" scrolldelay="200">
</marquee>
</div>
</div>
</td>	
	*/
	$(document).ready(function()
	{
		var testimonials = $('.extendedinfotext');
		if (testimonials.length)
		{
			var mtext = $(testimonials).html();
			//alert(mtext);
			
			$('#title').parent().parent().append("\
<td width=\"10\">&nbsp;</td>\
<td valign=\"top\" width=\"287\">\
<div id=\"tm\">\
<div id=\"tmi\">\
<strong>Testimonials:</strong>\
<marquee behavior=\"scroll\" direction=\"up\" height=\"55\" width=\"250\" scrollamount=\"1\" scrolldelay=\"200\">"+mtext+"</marquee>\
</div>\
</div>\
</td>");
			
			$('.extendedinfotext').parent().hide();
			
			$('marquee').marquee().mouseover(function () {
				$(this).trigger('stop');
			}).mouseout(function () {
				$(this).trigger('start');
			}).mousemove(function (event) {
				if ($(this).data('drag') == true) {
					this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
				}
			}).mousedown(function (event) {
				$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
			}).mouseup(function () {
				$(this).data('drag', false);
			});
		}
	});
}


// these bits don't appear to work even though they should!
/*
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(function() {
	document.write("onload");
	var couponcodes = document.getElementsByName('COUPONCODE');
	for (var cc = 0; cc < couponcodes.length; cc++) {
		couponcodes[cc].onBlur = this.value.toUpperCase();
	}
})
*/
// end of bits that don't seem to work!

