/*There is a rare and random error in IE if identify is clicked too quickly, it has something to do with the xmlhttp request around line 306 in main.js, but it's not a fatal error and everything works perfectly if the error does appear.  Hide all JS errors on the live server (there should be no errors and users shouldn't see them anyway...comment this out when developing*/
/*
function handleError()
{
return true;
}
window.onerror = handleError;

*/
/*---------------------
|    Image Rollover
----------------------*/
function move_in(img_name,img_src) 
{ 
	document[img_name].src=img_src;
}

function move_out(img_name,img_src) 
{
	document[img_name].src=img_src;
}

var nameok = false;
var emailok = false;
var messageok = false;
function openPage(){
	window.open('http://olarchitect.com/','OpenLayers Architect') 
}
window.addEvent('domready', function() {
/*TODO - BREAK UP SCRIPTS*/
	/*EVENTS TO DO ON LOAD*/
	//$('formSubmit').setStyle('opacity', '.2');
	
	if($$('.formMsgC')){
		$$('.formMsgC').setStyle('opacity', '0');
	}
	
	if($('contactEmailMeText')){
	$('contactEmailMeText').innerHTML = "<a h"+"ref=\"m"+"ailt"+"o:"+"%65%72%69%6b%40%76%61%73%69%72%2e%6e%65%74\">&#101;&#109;&#97;&#105;&#108;&#32;&#109;&#101;<\/a>";
	$('backgroundSendMeAnEmailText').innerHTML = '<a h'+'ref="m'+'ailt'+'o:'+'%65%72%69%6b%40%76%61%73%69%72%2e%6e%65%74">&#83;&#101;&#110;&#100;&#32;&#109;&#101;&#32;&#97;&#110;&#32;&#101;&#109;&#97;&#105;&#108;<\/a>';
	}
	
	$$('.menuBg').addEvent('mouseenter', function(event) {
		$$('.menuBg').fade(0.2);
		this.fade(1.0);
	});
	$$('.menuBg').addEvent('mouseleave', function(event) {
		$$('.menuBg').fade(1.0);
		//$$('#topMenu .active').setStyle('background-image','url(images/links/linkoverSmall.png)');
	});
	
	if($('aboutLinks')){
		$$('.aboutMenuBg').addEvent('mouseenter', function(event) {
			$$('.aboutMenuBg').fade(0.2);
			this.fade(1.0);
		});
		$$('.aboutMenuBg').addEvent('mouseleave', function(event) {
			$$('.aboutMenuBg').fade(1.0);
			//$$('#topMenu .active').setStyle('background-image','url(images/links/linkoverSmall.png)');
		});
	}
	
	/*Logo Image Fade*/
	$('logoImageFade0').setStyle('opacity','1');
	$('logoImageFade1').setStyle('opacity','0');
	$('logoImage').addEvent('mouseenter', function(event){
		$('logoImageFade1').fade(1.0);
		/*$$('.menuBg').fade(0.2);*/
	});
	$('logoImage').addEvent('mouseleave', function(event){
		$('logoImageFade1').fade(0.0);
		/*$$('.menuBg').fade(1.0);*/
	});
	
	/*Latest Work Image Fade*/
	if($('rrdImageFade0')){
		$('rrdImageFade0').setStyle('opacity','1');
		$('rrdImageFade1').setStyle('opacity','0');
		$('rrdImage').addEvent('mouseenter', function(event){
			$('rrdImageFade1').fade(1.0);
		});
		$('rrdImage').addEvent('mouseleave', function(event){
			$('rrdImageFade1').fade(0.0);
		});
	
	/*Latest Work Button Image Fade*/
		$('aboutButtonFade0').setStyle('opacity','1');
		$('aboutButtonFade1').setStyle('opacity','0');
		$('aboutButtonContainer').addEvent('mouseenter', function(event){
			$('aboutButtonFade1').setStyle('opacity','1');
		});
		$('aboutButtonContainer').addEvent('mouseleave', function(event){
			$('aboutButtonFade1').setStyle('opacity','0');
		});
		
		
	}
});

function nameFail(){
	nameok = false;
	$('formName').setStyle('background-color','#9cb9d5');
	$('formName').setStyle('color','#2f3234');
	$('formNameErrorText').set('html', 'Name is too short');
	$('formNameMessageContainer').fade(1);
	//$('formSubmit').fade(0.2);
	//$('formMessageContainer').tween('background-color','#9cb9d5');
}

function emailFail(){
	emailok = false;
	$('formEmail').setStyle('background-color','#9cb9d5');
	$('formEmail').setStyle('color','#2f3234');
	$('formEmailErrorText').set('html', 'Valid email required');
	$('formEmailMessageContainer').fade(1);
	//$('formSubmit').fade(0.2);
	//$('formMessageContainer').tween('background-color','#9cb9d5');
}

function messageFail(){
	messageok = false;
	$('formMessage').setStyle('background-color','#9cb9d5');
	$('formMessage').setStyle('color','#2f3234');
	$('formMessageErrorText').set('html', 'Enter a longer message');
	$('formMessageMessageContainer').fade(1);
	//$('formSubmit').fade(0.2);
	//$('formMessageContainer').tween('background-color','#9cb9d5');
}	

function submitMessage(){
	if(messageok == true && emailok == true && nameok == true){
		alert("Message Sent!");
		$('form_id').submit();
	}
}