﻿var olay;

window.addEvent('domready', function(){
	
	
	//scroll to loginbox
	if($$('ul.message')[0]){
		document.location = '#securelog';
	}
	
	

	if($('imageMenuBasic')){
		new imageMenu('#imageMenuBasic',{
			openWidth:316, 
			border:1
		});
	}
	
	
	var popupTips = $$('div.popupTip');
	popupTips.each(function(el,i){
		el.setStyle('display', 'block');
		el.fade('hide');
		el.addEvent('mouseover', function(){
			popupTips[i].fade('in');
		});
		el.addEvent('mouseout', function(){
			popupTips[i].fade('out');
		});
	});
	$$('li.popupTipTrigger a').each(function(el,i){
		el.addEvent('mouseover', function(){
			popupTips[i].fade('in');
		});
		el.addEvent('mouseout', function(){
			popupTips[i].fade('out');
		});

	});
	
	
	olay = new overlay();
	
	$$('.mbForm').each(function(el){
		el.set('href', el.get('href')+'?modal=true');
	});
	
	//multiBox: forms
	new multiBox('mbForm', {
		overlay: olay,
		showControls: false,
		openFromLink: false,
		movieWidth: 660,
		movieHeight: 500
	});
	
	//multiBox: images
	new multiBox('mb', {
		overlay: olay
	});
	
	//landing popup
	if($$('.company_popup_wrapper')[0]){
		
		//check cookie
		var landingCookie = Cookie.read('landing');
		
		//console.log(landingCookie);
		//console.log(parseUrl(document.location).query.indexOf('landing=false'));
		
		if(!landingCookie && parseUrl(document.location).query.indexOf('landing=false') == -1){
			$(document.body).addClass('landing');
			olay.reset();
			olay.show();
			$$('.company_popup_wrapper')[0].setStyle('height', window.getScrollSize().y);
			$$('li.popupTipTrigger a').each(function(el,i){
				el.href += '?landing=false';
			});
		}else{
			Cookie.write('landing', false);
		}
	}
	

	//external links
	$$('a[rel=external]').set('target', '_blank');
	
	$$('.print').setStyle('display', 'block');
	
	
	//form
	var appSelect = $('Template_BuyConcrete_ApplicationChoice');
	if(appSelect){
		var app = $('application').getParent('li');
			app.setStyle('visibility', 'hidden');
		appSelect.addEvent('change', function(e){
			if(this.value == 'Other'){
				app.setStyle('visibility', 'visible');
			}else{
				app.setStyle('visibility', 'hidden');
			}
		});
		appSelect.fireEvent('change');
	}


//Drop down

	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}




	
});