/*

	Scripts by wictor.olseryd@orbitsville.com

*/

// new code for firstpage items
window.addEvent('load', function() {
	
		arFpItems = $$('.fpItem');
		if($type(arFpItems) == "array") {
			for(i = 0, c = arFpItems.length; i < c; i++) {
				fpOverlay = arFpItems[i].getElementById("fpOverlay" + arFpItems[i].id.substring(2, 3));
				if($chk(fpOverlay)) {
					arFpItems[i].store("effect", new Fx.Morph(fpOverlay, {duration: 300, transition: Fx.Transitions.Sine.easeOut}));
					arFpItems[i].addEvent('mouseenter', function() {
						myEffect = this.retrieve("effect");
						myEffect.cancel();
						myEffect.set({ "opacity": 0.7});
					});
					arFpItems[i].addEvent('mouseleave', function() {
						myEffect = this.retrieve("effect");
						myEffect.cancel();
						myEffect.start({ "opacity": 0 });
					});
				}
			}
		}
		
		// move the overlay divs in place
		arFpOverlayItems = $$('.fpItemOverlay');
		if($type(arFpOverlayItems) == "array") {
			for(i = 0, c = arFpOverlayItems.length; i < c; i++) {
				arFpOverlayItems[i].setStyle("margin-top", "-" + arFpOverlayItems[i].scrollHeight + "px");
			}
		} else {
			fpOverlayItem = arFpOverlayItems;
			fpOverlayItem.setStyle("margin-top", "-" + fpOverlayItem.scrollHeight + "px");
		}
});

function showcontact(num) {
	$('cont_'+num).setStyle('visibility', 'visible');
}

function closecontact(num) {
	$('cont_'+num).setStyle('visibility', 'hidden');
}

function checkFieldBlur(obj,text) {
	if (obj.value == '') {
		obj.value = text;
	}
}

function checkFieldFocus(obj,text) {
	if (obj.value == text) {
		obj.value = '';
	}
}

function sendForm(name) {

	if(name == 'contactFooter') {
		frm = document.forms[name]
		if(frm.elements['cus_text'].value != 'Your question' && frm.elements['cus_email'].value != 'Your email') {
			frm.submit();
		}
		else {
			alert('Please include your email address and your question.');
		}
	}
	else {
		document.forms[name].submit();
	}
	
}

function showContactForm() {
	$('thankyou').setStyle('display', 'none');
	$('input').setStyle('display', 'block');	
}
