/**
 *
 * @access public
 * @return void
 **/
 var preverror ="";

function validateHomePage(){

	var obj = document.frmEditHomePage;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Title.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validateAboutUs(){

	var obj = document.frmEditaboutus;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Title.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.topdescription;
	if(objErr.value==""){
		inlineMsg("topdescription",'You must enter Top Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.bottomdescription;
	if(objErr.value==""){
		inlineMsg("bottomdescription",'You must enter Bottom Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}


		obj.submit();
}


function validateDestination(){

	var obj = document.frmAddDestination;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Title.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.destination_type;
	if(objErr.value==""){
		inlineMsg("destination_type",'You must Select Destination Type.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validatePartner(){

	var obj = document.frmAddPartner;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Title.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validateJet(){

	var obj = document.frmAddJet;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Title.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	obj.submit();
}


function validateBrochure(){

	var obj = document.frmAddBrochure;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Brochure.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}


function validateCharter(){

	var obj = document.frmAddCharter;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Charter.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.cat_id;
	if(objErr.value==""){
		inlineMsg("cat_id",'You must Select Category.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validateCategory(){

	var obj = document.frmAddCategory;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.category;
	if(objErr.value==""){
		inlineMsg("category",'You must enter Category.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validateService(){

	var obj = document.frmAddService;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Title.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}
	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validateNews(){

	var obj = document.frmAddNews;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter News.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.url;
	if(objErr.value==""){
		inlineMsg("url",'You must enter Url.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}


function validateMenu(){

	var obj = document.frmAddMenu;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.title;
	if(objErr.value==""){
		inlineMsg("title",'You must enter Menu.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.price;
	if(objErr.value==""){
		inlineMsg("price",'You must enter Price.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}

function validateManagement(){

	var obj = document.frmEditManagement;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.description;
	if(objErr.value==""){
		inlineMsg("description",'You must enter Description.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}


function validateNewsletter(){

	var obj = document.formNewsletter;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objError = obj.email;
	if(objError.value==""){
		inlineMsg("email",'You must enter Email.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var objErr = obj.email;
   if(reg.test(objErr.value) == false) {
      inlineMsg("email",'You must enter Valid Email.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}
		obj.submit();
}

function validateQuoteRequest(){

	var obj = document.formQuoteRequest;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.first_name;
	if(objErr.value==""){
		inlineMsg("first_name",'You must enter First Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.last_name;
	if(objErr.value==""){
		inlineMsg("last_name",'You must enter Last Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.telephone;
	if(objError.value==""){
		inlineMsg("telephone",'You must enter Telephone No.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

	var numericExpression = /^([0-9\-\/]{9,24})$/;
	var objErr = obj.telephone;
	if(numericExpression.test(objErr.value)==false){
		inlineMsg("telephone",'You must enter Valid Telephone No.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.email;
	if(objError.value==""){
		inlineMsg("email",'You must enter Email.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var objErr = obj.email;
   if(reg.test(objErr.value) == false) {
      inlineMsg("email",'You must enter Valid Email.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}
		obj.submit();
}

function validatePartnerInquiry(){

	var obj = document.formInquiryPartner;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.first_name;
	if(objErr.value==""){
		inlineMsg("first_name",'You must enter First Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.last_name;
	if(objErr.value==""){
		inlineMsg("last_name",'You must enter Last Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.telephone;
	if(objError.value==""){
		inlineMsg("telephone",'You must enter Telephone No.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

	var numericExpression = /^([0-9\-\/]{9,24})$/;
	var objErr = obj.telephone;
	if(numericExpression.test(objErr.value)==false){
		inlineMsg("telephone",'You must enter Valid Telephone No.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.email;
	if(objError.value==""){
		inlineMsg("email",'You must enter Email.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var objErr = obj.email;
   if(reg.test(objErr.value) == false) {
      inlineMsg("email",'You must enter Valid Email.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}
		obj.submit();
}

function validateCharterInquiry(){

	var obj = document.formInquiry;
	var frmLength = obj.length;
	var backcolor = "#13afc6";


	var objErr = obj.first_name;
	if(objErr.value==""){
		inlineMsg("first_name",'You must enter First Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.last_name;
	if(objErr.value==""){
		inlineMsg("last_name",'You must enter Last Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.telephone;
	if(objError.value==""){
		inlineMsg("telephone",'You must enter Telephone No.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

	var numericExpression = /^([0-9\-\/]{9,24})$/;
	var objErr = obj.telephone;
	if(numericExpression.test(objErr.value)==false){
		inlineMsg("telephone",'You must enter Valid Telephone No.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.email;
	if(objError.value==""){
		inlineMsg("email",'You must enter Email.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var objErr = obj.email;
   if(reg.test(objErr.value) == false) {
      inlineMsg("email",'You must enter Valid Email.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}
		obj.submit();
}

function validateJetInquiry(){

	var obj = document.formInquiryJet;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.first_name;
	if(objErr.value==""){
		inlineMsg("first_name",'You must enter First Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objErr = obj.last_name;
	if(objErr.value==""){
		inlineMsg("last_name",'You must enter Last Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.telephone;
	if(objError.value==""){
		inlineMsg("telephone",'You must enter Telephone No.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

	var numericExpression = /^([0-9\-\/]{9,24})$/;
	var objErr = obj.telephone;
	if(numericExpression.test(objErr.value)==false){
		inlineMsg("telephone",'You must enter Valid Telephone No.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.email;
	if(objError.value==""){
		inlineMsg("email",'You must enter Email.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var objErr = obj.email;
   if(reg.test(objErr.value) == false) {
      inlineMsg("email",'You must enter Valid Email.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}
		obj.submit();
}

function validateContact(){

	var obj = document.formContact;
	var frmLength = obj.length;
	var backcolor = "#13afc6";

	if(preverror!=""){
		preverror.style.background="white";
		preverror="";
	}

	var objErr = obj.name;
	if(objErr.value==""){
		inlineMsg("name",'You must enter Name.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.telephone;
	if(objError.value==""){
		inlineMsg("telephone",'You must enter Telephone No.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

	var numericExpression = /^([0-9\-\/]{9,24})$/;
	var objErr = obj.telephone;
	if(numericExpression.test(objErr.value)==false){
		inlineMsg("telephone",'You must enter Valid Telephone No.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

	var objError = obj.email;
	if(objError.value==""){
		inlineMsg("email",'You must enter Email.',5);
		objError.style.background=backcolor;
		preverror =objError;
		objError.focus();
		return false;
	}

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var objErr = obj.email;
   if(reg.test(objErr.value) == false) {
      inlineMsg("email",'You must enter Valid Email.',5);
		objErr.style.background=backcolor;
		preverror =objErr;
		objErr.focus();
		return false;
	}

		obj.submit();
}
// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80);
  arrow.src = "images/msg_arrow.gif";
}

function checkArray(form, arrayName) {
 //var retval = new Array();

  for(var i=0; i < form.elements.length; i++) {
  var el = form.elements[i];
  if(el.type == "checkbox" && el.checked) {
  		return el.value;
  	}
  }
  return "";
}


