window.addEvent('domready', function(){
	$$('img[rel=^hover]').each(function(img) {
		var matches = img.getProperty('rel').match(/hover\[(.+)\]/);
		if (matches[1]) {
			img.store('imgEnter',matches[1]);
			img.store('imgLeave',img.getProperty('src'));

			img.addEvent('mouseenter', function() {
				img.setProperty('src',img.retrieve('imgEnter'));
			});
			img.addEvent('mouseleave',function() {
				img.setProperty('src',img.retrieve('imgLeave'));
			});
		}
	});
	var siteAccordion = new Fx.Accordion($$('.peffect_title'), $$('.peffect_text'), {
		display:-1,
		alwaysHide: true
	});

	if(Browser.Engine.trident && Browser.Engine.name=='trident' && Browser.Engine.version<=4){
		iexplorer6PngFix();
	};
	
	$$('.ABbox_444').each(function(el){
		el.setStyle('margin-bottom',0);
		var bottomEl = new Element('div',{ 'class':'bottom444', 'html':'&nbsp;' });
		bottomEl.inject(el, 'after');
	});
	$$('.ABbox_333').each(function(el){
		el.setStyle('margin-bottom',0);
		var bottomEl = new Element('div',{ 'class':'bottom333', 'html':'&nbsp;' });
		bottomEl.inject(el, 'after');
	});
	$$('.ABbox_296').each(function(el){
		el.setStyle('margin-bottom',0);
		var bottomEl = new Element('div',{ 'class':'bottom296', 'html':'&nbsp;' });
		bottomEl.inject(el, 'after');
	});
});
iexplorer6PngFix = function() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {

			var imgID = (img.id) ? "id='" + img.id + "' " : ""

			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:block;"
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<div " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='image');\"></div>";
			img.outerHTML = strNewHTML;
			//$('headout').appendText(document.images[i].width+'x'+document.images[i].height+';');
			i = i-1
		}
	}
};
var topMenu = new UvumiDropdown('dd-menu',{
	duration:150,
	delay:300,
	transition:Fx.Transitions.linear,
	clickToOpen:false
});


google.load('search', '1', {language : siteLang});
google.setOnLoadCallback(function() {
	var options = {
		'google.search.Search.RESTRICT_EXTENDED_ARGS' :	{
			'lr': 'lang_' + siteLang,
			'as_sitesearch' : 'www.baufuchs.com/*'
		}
	};
	var customSearchControl = new google.search.CustomSearchControl(
    '003045779162044184349:nsqqkka42oe', options);

	customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
	customSearchControl.setSearchStartingCallback(this,function() {
		$('content').setStyle('display', 'none');
	});
	
 
	var drawOptions = new google.search.DrawOptions();
	drawOptions.setSearchFormRoot('search_form');
	// Draw the search results in the results div
	customSearchControl.draw('search_result', drawOptions);

	$$('div.gsc-clear-button').addEvent('click',function() {
		$('content').setStyle('display', '');
	});
	

});

