// JavaScript Document

addLoadEvent(addQuoteButton);

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}






// Get Elements by Class function borrowed from Jonathan Snook - http://www.snook.ca/archives/javascript/your_favourite_1/ 
function getElementsByClassName(needle) {
	var my_array = document.getElementsByTagName("*");
	var retvalue = new Array();
	var h;
	var j;
	for (h=0,j=0;h<my_array.length;h++) {
		var c = " " + my_array[h].className + " ";
		if (c.indexOf(" " + needle + " ") != -1) retvalue[j++] = my_array[h];
	}
	return retvalue;
}



// Finds <a> elements within the class name "create_quote_button"
// Adds image content with link into the title attribute of the <a> elements within the class name "create_quote_button"
function addQuoteButton() {
	if (!document.getElementsByTagName) {
	return false;
	}
	
	if (!getElementsByClassName("create_quote_button")) {
	return false;
	}
	
	var needButton = getElementsByClassName("create_quote_button");
	
	for (var k=0; k < needButton.length; k++) {
		var myLinks = needButton[k].getElementsByTagName("a");
		
		for (var m=0; m < myLinks.length; m++) {
			
			var ogTitle = myLinks[m].getAttribute("title");
			
            if (ogTitle) {
			
				var makeContent = (ogTitle);
			
			myLinks[m].setAttribute("title", makeContent);
		
			}
			
			else {
				var buttonOnly = "<a href=\'buybamboonow_flooring.html\'><img src=\'https://www.calibamboo.com/mm5/images/bambooquote.gif\' alt=\'Request Quote\'  ><\/a>";
			
			
			myLinks[m].setAttribute("title", buttonOnly);
			}
			
			// Since IE has issues with onmouseleave, make sure your linked text or image has an alt and a title tag so that the garbage above won't be stuffed in there.
		}
	}
}









