function hideFormText() {
	var _inputs = document.getElementsByTagName('input');
	var _txt = document.getElementsByTagName('textarea');
	var _value = [];
	
	if (_inputs) {
		for(var i=0; i<_inputs.length; i++) {
			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {
				
				_inputs[i].index = i;
				_value[i] = _inputs[i].value;
				
				_inputs[i].onfocus = function(){
					if (this.value == _value[this.index])
						this.value = '';
            if(_value[this.index] == 'Password') this.type = 'password';
				}
				_inputs[i].onblur = function(){
					if (this.value == ''){
						this.value = _value[this.index];
            this.type = 'text';
          }
				}
			}
		}
	}
	if (_txt) {
		for(var i=0; i<_txt.length; i++) {
			_txt[i].index = i;
			_value['txt'+i] = _txt[i].value;
			
			_txt[i].onfocus = function(){
				if (this.value == _value['txt'+this.index])
					this.value = '';
			}
			_txt[i].onblur = function(){
				if (this.value == '')
					this.value = _value['txt'+this.index];
			}
		}
	}
}

function validate_enquiry(){
  var errormsg = '';
  if($('#first_name').val() == '' || $('#first_name').val() == 'Name'){
    errormsg += '<li>Please enter your name.</li>';
  }
  if($('#email').val() == '' || $('#email').val() == 'Email Address'){
    errormsg += '<li>Please enter your email address.</li>';
  }else if(!isemail($('#email').val())){
    errormsg += '<li>Please enter a valid email address.</li>';
  }
  if($('#mobile_number').val() == '' || $('#mobile_number').val() == 'Phone Number'){
    errormsg += '<li>Please enter your phone number.</li>';
  }
  if(errormsg == ''){
    return true;
  }else{
    $('#message-box').html('<h2>Form Incomplete</h2><ul id="error">'+errormsg+'</ul>');
    $('#message-link').click();
    //$.fancybox.resize();
    return false;
  }
}

function isemail(val)
{
  var x=val
  var atpos=x.indexOf("@");
  var dotpos=x.lastIndexOf(".");
  if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length){
    return false;
  }
  return true;
}


$(function() {
  hideFormText();
  $('#message-link').fancybox({
    scrolling: 'no'
  });
  $('#image-box').easySlider({
    continuous:true
  });
});
