var bShowactive = true;
var iFadespeed	= 10;

function MakeVisible(objectId)
{
	temp_obj = getObj(objectId);
	
	if(temp_obj)
	{
		temp_obj.style.visibility = 'visible';
	}
}

function MakeHidden(objectId)
{
	temp_obj = getObj(objectId);
	
	if(temp_obj)
	{
		temp_obj.style.visibility = 'hidden';
	}
}

function getObj(objectId)
{
	return document.getElementById(objectId);
}

function isObj(obj)
{
	if(obj) return true;
	return false;
}

function fadeObj(objectId, iFrom, iTo)
{
	fadeObject = document.getElementById(objectId);
	
	if(fadeObject)
	{
		new Effect.Opacity(objectId, { from: iFrom, to: iTo, duration: 0.2 });
	}
}

function fadeOver(objectId)
{
	fadeObject = document.getElementById(objectId);
	
	if(fadeObject)
	{
		//Effect.Fade(objectId, { duration: 3.0 });
		new Effect.Opacity(objectId, { from: 1.0, to: 0.0, duration: 0.2 });
		
		//$(objectId).fade({ duration: 1.0, from: 0, to: 1 });
	}
}

function fadeOut(objectId)
{
	fadeObject = document.getElementById(objectId);
	
	if(fadeObject)
	{
		new Effect.Opacity(objectId, { from: 0.0, to: 1.0, duration: 0.5 });
		//$(objectId).fade({ duration: 1.0, from: 1, to: 0 });
	}
}

function fadeObjectIn(objectId, activeId)
{
	bShowactive = false;
	
	fadeObject = document.getElementById(objectId);
	activeObject = document.getElementById(activeId);
	
	// Hide the active object
	if(activeObject)
	{
		fadeTransparencyDown(activeObject, 0, iFadespeed);
	}
	
	if(fadeObject)
	{
		fadeTransparencyUp(fadeObject, 100, iFadespeed);
	}
}

function fadeObjectOut(objectId, activeId)
{
	fadeObject = document.getElementById(objectId);
	activeObject = document.getElementById(activeId);
	
	if(fadeObject)
	{
		fadeTransparencyDown(fadeObject, 0, iFadespeed);
	}
	
	if(activeObject)
	{
		setTimeout("showActive('"+activeId+"')", 1500);
	}
	
	bShowactive = true;
}

function showActive(activeId)
{
	activeObject = document.getElementById(activeId);
	
	if(bShowactive == true)
	{
		// Show the active photo
		if(activeObject)
		{
			fadeTransparencyUp(activeObject, 100, iFadespeed);
		}
	}
}

function loadImage(sObjectId, sImagePath)
{
	imgObj = document.getElementById(sObjectId);
	
	if(imgObj)
	{
		imgObj.src = sImagePath;
	}
}

function checkInput(obj, value)
{
	if(obj)
	{
		setMessage("");
		
		if(obj.value == value)
		{
			obj.value = "";
		}
		else if(obj.value == "")
		{
			obj.value = value;
		}
	}
}

function isEmpty(obj)
{
	if(obj.value == "") return true;
	return false;
}

function isEmail(obj)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (filter.test(obj.value)) return true;
	return false;
}

function isPostcode(obj)
{
	var filter = /^[1-9]{1}[0-9]{3}[a-zA-Z]{2}$/;
	
	if (filter.test(obj.value)) return true;
	return false;
}

function isSameAsTitle(obj)
{
	if(obj.value == obj.title) return true;
	return false;
}

function focusObject(obj)
{
	obj.focus();
}

function setMessageById(value, messageId)
{
	objMessage = document.getElementById(messageId);
	
	if(objMessage)
	{
		objMessage.innerHTML = value;
	}
}

function setMessage(value, objectId)
{
	objMessage = document.getElementById(objectId);
		
	if(objMessage )
	{
		objMessage.innerHTML = value;
	}
}

function sendContactRequest()
{
	objBericht	= document.getElementById('t_bericht');
	objNaam 	= document.getElementById('t_naam');
	objEmail 	= document.getElementById('t_email');
	
	if(objBericht && objNaam && objEmail)
	{
		if(isEmpty(objBericht) || isSameAsTitle(objBericht))
		{
			focusObject(objBericht);
			setMessage("U bent vergeten het <strong>bericht</strong> in te vullen!","message");
			return;
		}
		
		if(isEmpty(objNaam) || isSameAsTitle(objNaam))
		{
			focusObject(objNaam);
			setMessage("U bent vergeten uw <strong>naam</strong> in te vullen!","message");
			return;
		}
		
		if(isEmpty(objEmail) || isSameAsTitle(objEmail))
		{
			focusObject(objEmail);
			setMessage("U bent vergeten uw <strong>e-mailadres</strong> in te vullen!","message");
			return;
		}
		
		if(!isEmail(objEmail))
		{
			focusObject(objEmail);
			setMessage("Het opgegeven <strong>e-mailadres</strong> is onjuist!","message");
			return;
		}
		
		document.contactForm.submit();
	}
}