/*


Dynamic Application of Functions to DOM
*/
var _debugMode = false;
document.observe('dom:loaded', init);
Event.observe(window, 'load', initAfterImages);
Event.observe(window, 'resize', adjustBodyHeight);


function init () {
  if (bodyTooShort()) adjustBodyHeight();
  [$('content-top'), $('content-bottom'), $('bfly1'), $('bfly2'), $('cocoDesign')].compact().invoke('pngHack');

  if($('productList')) {	
	var a = $('productList');
    cleanPayPal(a);
  }

}

function initAfterImages () {

}

function bodyTooShort() {
  if ($(document.body).getHeight() < document.viewport.getHeight()) return true;
  else return false;
}

function adjustBodyHeight() {
  if (bodyTooShort()) {
    document.body.setStyle({height: document.viewport.getHeight() + 'px'});
  }
}

function cleanPayPal(contentDiv) {
	if(contentDiv) {
		$$('#productList input').each(function(node,i) {
			if(node.type == "image") {
				node.replace('<input type="submit" name="submit" value="Add To Cart" class="product_submit" />');
			}
		});

		//var str = contentDiv.innerHTML
		//str = str.replace(/<(\/|)(table)(.|\n)+?>/gi, "");
		//contentDiv.update(str)

		//str = str.replace(/<(table|td|tr|tbody)(.|\n)+?>/gi, "");
		//contentDiv.update(str);
	}
}
