// JavaScript Document
function onLoad()
{
	
}
function getRandom( min, max ) 
{
	if( min > max ) return( max );
	if( min == max ) return( min );
	return( min + parseInt( Math.random() * ( max-min + 1 ) ) );
}

function checkDocument(obj_id) 
{
	if (document.getElementById) return document.getElementById(obj_id);
	if (document.all) return document.all[obj_id];
	if (document.layers) return document.layers[obj_id];
	return ;
}



function showNaviActiveIndicator(id)
{
	var imageID = "naviActiveIndicator" + String(id);
	var imageElement = checkDocument(imageID);
	imageElement.style.visibility = "visible";
}

function hideNaviActiveIndicator(id)
{
	var imageID = "naviActiveIndicator" + String(id);
	var imageElement = checkDocument(imageID);
	imageElement.style.visibility = "hidden";
}

function checkContactInputs()
{
	var contactName = checkDocument("contactName");
	var contactEmail = checkDocument("contactEmail");
	var contactSubject = checkDocument("contactSubject");
	var contactMessage = checkDocument("contactMessage");
	var contactCaptcha = checkDocument("contactCaptcha");
	
	var contactNameLabel = checkDocument("contactNameLabel");
	var contactEmailLabel = checkDocument("contactEmailLabel");
	var contactSubjectLabel = checkDocument("contactSubjectLabel");
	var contactMessageLabel = checkDocument("contactMessageLabel");
	var contactCaptchaLabel = checkDocument("contactCaptchaLabel");
	
	var contactformErrorText = checkDocument("contactformErrorText");
	
	contactNameLabel.style.color = '#fff';
	contactEmailLabel.style.color = '#fff';
	contactSubjectLabel.style.color = '#fff';
	contactMessageLabel.style.color = '#fff';
	contactCaptchaLabel.style.color = '#fff';
	
	contactformErrorText.style.visibility  = "hidden";
	
	var isOK = true;
	
	if (contactName.value == "")
	{
		contactformErrorText.style.visibility  = "visible";
		contactNameLabel.style.color = '#ff0000';
		isOK = false;
	}
	
	if (!checkMail(contactEmail.value))
	{
		contactformErrorText.style.visibility  = "visible";
		contactEmailLabel.style.color = '#ff0000';
		isOK = false;
	}
	
	if (contactSubject.value == "")
	{
		contactformErrorText.style.visibility  = "visible";
		contactSubjectLabel.style.color = '#ff0000';
		isOK = false;
	}
	
	if (contactMessage.value == "")
	{
		contactformErrorText.style.visibility  = "visible";
		contactMessageLabel.style.color = '#ff0000';
		isOK = false;
	}
	
	if (contactCaptcha.value.length != 5)
	{
		contactformErrorText.style.visibility  = "visible";
		contactCaptchaLabel.style.color = '#ff0000';
		isOK = false;
	}
	
	
	
	return isOK;
}

function checkGuestInputs()
{
	var guestName = checkDocument("guestName");
	var guestSubject = checkDocument("guestSubject");
	var guestText = checkDocument("guestText");
	var guestCode = checkDocument("guestCode");
	var guestError = checkDocument("guestError");
	
	
	var isOK = true;
	
	if (guestName.value == "")
	{
		isOK = false;
	}
	
	if (guestSubject.value == "")
	{
		isOK = false;
	}
	
	if (guestText.value == "")
	{
		isOK = false;
	}
	
	if (guestCode.value.length != 5)
	{
		isOK = false;
	}
	
	if (isOK) 
	{
		guestError.style.visibility = 'hidden';
		return true;	
	}
	else
	{
		guestError.style.visibility = 'visible';
		return false;
	}
	
	
}

function checkMail(s)
{
 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\-\.\_]+)'+
                   '(\@)([a-zA-Z0-9\-\.]+)'+
                   '(\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
}

