Event.observe(window, 'load', function() { 
	
	var height = $$('.col-main')[0].getHeight();	
	if ($$('.col-left')[0])
		height = ($$('.col-left')[0].getHeight() > height) ? $$('.col-left')[0].getHeight() : height;	
	if ($$('.col-right')[0])
		height = ($$('.col-right')[0].getHeight() > height) ? $$('.col-right')[0].getHeight() : height;
		
	$$('.col-main')[0].style.minHeight = height - 30 +'px';	
	if ($$('.col-left')[0])
		$$('.col-left')[0].style.minHeight = height - 30 +'px';
	if ($$('.col-right')[0])
		$$('.col-right')[0].style.minHeight = height - 30 +'px';
	
	$$('input.example-text').each(function(input) {
		var defaultValue = input.getAttribute('title');
		var defaultClass = 'default';
		/* Set default value when page loads */
		if (input.value == "" || input.value == defaultValue) {
		  input.value = defaultValue;
		  input.addClassName(defaultClass);
		}
		
		/* When input gets focus, set value to "" if value is default value */
		input.observe("focus", function(event) {
		  if (input.value == defaultValue) {
			input.value = "";
			input.removeClassName(defaultClass);
		  }
		});
		
		/* When input loses focus, set value to default value if value = "" */
		input.observe("blur", function(event) {
		  if (input.value == "") {
			input.value = defaultValue;
			input.addClassName(defaultClass);
		  }
		});
	});
	
	try {
		Event.observe($$('.header .block-cart')[0], 'mouseover', function(event) {
			$$('.header .block-cart .sub-items')[0].style.display = 'block';
		});
	} catch(err){}
	
	try {
		Event.observe($$('.header .block-cart')[0], 'mouseout', function(event) {
			$$('.header .block-cart .sub-items')[0].style.display = 'none';
		});
	} catch(err){}
	
	try {
		Event.observe($$('.header .form-language')[0], 'mouseover', function(event) {
			$$('.header .form-language .notactive-block')[0].style.display = 'block';
		});
	} catch(err){}
	
	try {
		Event.observe($$('.header .form-language')[0], 'mouseout', function(event) {
			$$('.header .form-language .notactive-block')[0].style.display = 'none';
		});
	} catch(err){}
	
	try {
		Event.observe($$('.info-link')[0], 'mouseover', function(event) {
			$$('.info-link .info-block')[0].style.display = 'inline';
		});
	} catch(err){}
	
	try {
		Event.observe($$('.info-link')[0], 'mouseout', function(event) {
			$$('.info-link .info-block')[0].style.display = 'none';
		});
	} catch(err){}
	
	try {
		$$('.prod-info-link').each(function (el) {
			Event.observe(el, 'mouseover', function(event) {
				el.next().style.display = 'inline';
			});
		});
	} catch(err){}
	
	try {
		$$('.prod-info-link').each(function (el) {
			Event.observe(el, 'mouseout', function(event) {
				el.next().style.display = 'none';
			});
		});
	} catch(err){}
	
	var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
	
	/*if ((version >= 5.5) && (version < 7)) {
		document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
		// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
		
		var cBGImg = poElement.currentStyle.backgroundImage;
		var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
		alert(cImage);
		poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "', sizingMethod='scale')";
		poElement.style.backgroundImage = "none";
		});
	}*/
	
	
	$$('.layered-more').each(function(el) {
		Event.observe(el, 'click', function(event) {
			if (el.up().up().previous().style.display == 'none') {
				new Effect.SlideDown(el.up().up().previous(), {duration:1});
				el.down().hide().next().show();
			} else {
				new Effect.SlideUp(el.up().up().previous(), {duration:1});
				el.down().show().next().hide();
			}
		});
	});
	
	if ($$('a.scroll_me')) {
		$$('a.scroll_me').invoke('observe','click', function(event) {
			Event.stop(event);
			var elementLink = this.readAttribute('href');
			var scrollHere = elementLink.substr(1, elementLink.length);
			Effect.ScrollTo(scrollHere);
			return false;
		});
	}

	ProductToolTip();
	
});

function ProductToolTip() {
	if ($$('.product-stock-information span')[0]) {
		var txt = $$('.product-stock-information span')[0].innerHTML;
		$$('.product-stock-information span')[0].update('').addClassName('prod-info-block');
		$$('.product-stock-information span')[0].appendChild(new Element('span').addClassName('info-top'));
		$$('.product-stock-information span')[0].appendChild(new Element('span').addClassName('info-middle')).update(txt);
		$$('.product-stock-information span')[0].appendChild(new Element('span').addClassName('info-bottom'));		
	}
	if ($$('.product-delivery-information span')[0]) {
		var txt = $$('.product-delivery-information span')[0].innerHTML;
		$$('.product-delivery-information span')[0].update('').addClassName('prod-info-block');
		$$('.product-delivery-information span')[0].appendChild(new Element('span').addClassName('info-top'));
		$$('.product-delivery-information span')[0].appendChild(new Element('span').addClassName('info-middle')).update(txt);
		$$('.product-delivery-information span')[0].appendChild(new Element('span').addClassName('info-bottom'));		
	}
}
