function showPolicies()
{
NBLegalWin = window.open("/Legal.html","NBLegalWin","width=390,height=410,resizable=no,scrollbars=yes,status=no,location=no,menubar=no");
NBLegalWin.opener = self;
NBLegalWin.focus();
} 

function showNewsletterPageflip()
{
NBLegalWin = window.open("/_pageflips/newsletter.html","NBPageflipWin","width=1015,height=350,resizable=no,scrollbars=no,status=no,location=no,menubar=no");
NBLegalWin.opener = self;
NBLegalWin.focus();
} 

function hideSearchResultLayer()
{
 showHideLayer('windowSearchResultLayer',0);
 showHideLayer('contentSearchResultLayer',0);
}	

function showSaleDescription()
{
	document.getElementById("PurchaseDesc").style.display = 'none';	
	document.getElementById("SaleDesc").style.display = 'block';	
}

function showPurchaseDescription()
{
	document.getElementById("SaleDesc").style.display = 'none';	
	document.getElementById("PurchaseDesc").style.display = 'block';	
}

function hideDescription()
{
	document.getElementById("SaleDesc").style.display = 'none';	
	document.getElementById("PurchaseDesc").style.display = 'none';	
}


function changeOffice(objSel)
{location.href="OceanstyleLocations.asp?office=" + objSel.value;}

var strActivePerson;
function changePerson(objSel)
{
 if (strActivePerson != ""){showHideLayer('Details_'+strActivePerson,0);}
 strActivePerson = objSel.value;
 showHideLayer('Details_'+strActivePerson,1);
}

function showDescription(desc)
{
	/* document.getElementById("PurchaseDesc").style.display = 'none';	*/
	document.getElementById(desc).style.display = 'block';	
}

function ChangeGridOrder(objSel)
{
// var strURL = eval(structure + "GridFrame').src");
 var strURL = location.href;
 if (strURL.indexOf("OrderBy=") > -1){strURL = strURL.slice(0,strURL.indexOf("OrderBy="));}
 strURL += (strURL.indexOf("?") > -1 ? (strURL.lastIndexOf("?")+1==strURL.length || strURL.lastIndexOf("&")+1==strURL.length ? "" : "&") : "?");
 strURL += objSel.value;
 if (strURL.indexOf("asp") == -1)
 {
  var splitURL = strURL.split("?");
  strURL = splitURL[0] + "default.asp?" + splitURL[1]
 }
// eval(structure + "GridFrame').src='" + strURL + "'");
// alert(strURL);
 location.href=strURL
}

function SelectYacht(objSel,strSector)
{location.href="/"+strSector+"/YachtSpecs.asp?" + objSel.value;}

function SelectModel(objSel,strSector)
{if(objSel.value != ""){location.href="/"+strSector+"/Search.asp?ModelType=" + objSel.value;}}

function ViewSearch(objRad)
{
 showHideLayer('Container_SaleAndPurchase',0)
 showHideLayer('Container_Charter',0)
 showHideLayer('Container_'+objRad.value,1)
}

function emailFriend()
{
 showHideLayer('EmailToFriend',1)
}
function closeEmail()
{
 document.getElementById('ajaxresponse').innerHTML = "&nbsp;";
 showHideLayer('EmailToFriend',0)
}

/*
 ChangeContactDept(objSel)
 on change of department:
  1) change the deptemail form field
  2) show/hide location form as necessary
*/
function ChangeContactDept(objSel)
{
 eval(structure + "deptemail').value = '" + objSel.options[objSel.selectedIndex].getAttribute("rel") + "'");
 if(objSel.id == "department")
 {showHideLayer('tr_offices',(objSel.options[objSel.selectedIndex].getAttribute("rel") == "sales" ? 1 : 0));}
}

function checkReset(strDept)
{
 showHideLayer('tr_offices',(strDept == "sales" ? 1 : 0));
}

function changeButton(objBut,intState)
{
 objBut.style.background='url("/_images/forms/' + objBut.getAttribute("rel") + "_" + objBut.type + (intState==1 ? "_on" : "_off") + '.gif")';
}

var blnSLtoggle = false;
function fn_toggleShortlist(objBox,strSection)
{
 if(!blnSLtoggle)
 {
  blnSLtoggle = true;
  document.getElementById('SLaddLabel').innerHTML = "Updating shortlist...";
   if(xmlHttp == null) {setupAjax();}
//   window.open("/cgi-bin/SendFriendEmail.asp?YourName=" + escape(objform.YourName.value) + "&YourEmail=" + escape(objform.YourEmail.value) + "&FriendsName=" + escape(objform.FriendsName.value) + "&FriendsEmail=" + escape(objform.FriendsEmail.value) + "&LinkText=" + escape(document.title) + "&URL=" + encodeURIComponent(location.href.replace(" ","")));
//   return;
   xmlHttp.open("GET","/cgi-bin/SlAddRemoveYacht.asp?thisID=" + escape(objBox.value) + "&strSection=" + escape(strSection) + "&blnAdd=" + escape(objBox.checked),true);
   xmlHttp.send(null);
   xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4)
    {
     strxml=xmlHttp.responseText;
     document.getElementById('SLaddLabel').innerHTML = strxml;
	 blnSLtoggle = false;
	 xmlHttp = null;
    }
   }
 }
}

var blnEmailFriend = false;
function verify_emailtofriend(objform)
{
 if(!blnEmailFriend)
 {
  if(fn_isEmpty(objform.YourName)||fn_isEmpty(objform.YourEmail)||fn_isEmpty(objform.FriendsName)||fn_isEmpty(objform.FriendsEmail))
  {
   alert("All fields must be filled to send this page");
  }
  else
  {
   blnEmailFriend = true;
   document.getElementById('ajaxresponse').innerHTML = "Sending email...";
   if(xmlHttp == null) {setupAjax();}
//   window.open("/cgi-bin/SendFriendEmail.asp?YourName=" + escape(objform.YourName.value) + "&YourEmail=" + escape(objform.YourEmail.value) + "&FriendsName=" + escape(objform.FriendsName.value) + "&FriendsEmail=" + escape(objform.FriendsEmail.value) + "&LinkText=" + escape(document.title) + "&URL=" + encodeURIComponent(location.href.replace(" ","")));
//   return;
   xmlHttp.open("GET","/cgi-bin/SendFriendEmail.asp?YourName=" + escape(objform.YourName.value) + "&YourEmail=" + escape(objform.YourEmail.value) + "&FriendsName=" + escape(objform.FriendsName.value) + "&FriendsEmail=" + escape(objform.FriendsEmail.value) + "&LinkText=" + escape(document.title) + "&URL=" + encodeURIComponent(location.href.replace(" ","")),true);
   xmlHttp.send(null);
   xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4)
    {
     strxml=xmlHttp.responseText;
     document.getElementById('ajaxresponse').innerHTML = strxml;
     objform.FriendsName.value = "";
     objform.FriendsEmail.value = "";
	 blnEmailFriend = false;
	 xmlHttp = null;
    }
   }
  }
 }
 return false;
}

function verify_SLBrokerMail(objform)
{
 if(fn_isEmpty(objform.SelectOffice)||fn_isEmpty(objform.Message))
 {
  alert("Please fill in all fields");
 }
 else
 {
  showHideLayer('SubmitMask',1);
  showHideLayer('SubmitConfirm',1);
//  document.getElementById('SubmitConfirm').innerHTML = "<p>Sending email, please wait ...</p>";
 }
 return false;
}

function verify_SLFriendMail(objform)
{
 if(fn_isEmpty(objform.SLName)||fn_isEmpty(objform.SLEmail)||fn_isEmpty(objform.Message))
 {
  alert("Please fill in all fields");
 }
 else
 {
  showHideLayer('SubmitMask',1);
  showHideLayer('SubmitConfirm',1);
//  document.getElementById('SubmitConfirm').innerHTML = "<p>Sending email, please wait ...</p>";
 }
 return false;
}

function verify_ContactForm(objform)
{
 if(fn_isEmpty(objform.name)||fn_isEmpty(objform.email)||fn_isEmpty(objform.emailconfirm)||fn_isEmpty(objform.department)||(eval(structure + "tr_offices').style.display")=="block"&&fn_isEmpty(objform.sel_office))||((objform.deptemail.value=="recruitment" ? true : false)&&fn_isEmpty(objform.CurrentPosition)))
 {
  alert("Please fill in all required fields marked with *");
 }
 else
  if(objform.email.value != objform.emailconfirm.value)
  {alert("Your email addresses do not match - please enter your correct email address into both fields.")}
  else
  {
   showHideLayer('SubmitMask',1);
   showHideLayer('SubmitConfirm',1);
   document.getElementById('SubmitConfirm').innerHTML = "<p>Sending email, please wait ...</p>";
   if(objform.department.value == "HR"){return true;}
   else
   {
    if(xmlHttp == null) {setupAjax();}
//    window.open("/cgi-bin/SendFriendEmail.asp?YourName=" + escape(objform.YourName.value) + "&YourEmail=" + escape(objform.YourEmail.value) + "&FriendsName=" + escape(objform.FriendsName.value) + "&FriendsEmail=" + escape(objform.FriendsEmail.value) + "&LinkText=" + escape(document.title) + "&URL=" + escape(location.href));
    xmlHttp.open("GET","/cgi-bin/SendContactEmail.asp?name=" + escape(objform.name.value) + "&email=" + escape(objform.email.value) + "&tel=" + escape(objform.tel.value) + "&deptemail=" + escape(objform.deptemail.value) + "&department=" + escape(objform.department.value) + "&message=" + escape(objform.message.value) + "&optin=" + (escape(objform.optin.checked)=="true" ? "Yes" : "No"),true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
     if(xmlHttp.readyState==4)
     {
      strxml=xmlHttp.responseText;
// 	  alert(strxml);
      document.getElementById('SubmitConfirm').innerHTML = strxml;
 	  xmlHttp = null;
     }
    }
   }
 }
 return false;
}

function closeContact()
{
 document.getElementById('SubmitConfirm').innerHTML = "";
 showHideLayer('SubmitMask',0);
 showHideLayer('SubmitConfirm',0);
 try{document.getElementById('frmEnquiries').reset();}
 catch(err){}
}

// ===================================================
//  Variables and functions for setting up AJAX
//   - only call if required
// ===================================================
var strxml;
var xmlHttp = null;
var answers;

function setupAjax()
{
 try
 {xmlHttp=new XMLHttpRequest();} // Firefox, Opera 8.0+, Safari    
 catch (e)
 {
  // Internet Explorer
  try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  catch (e)
  {
   try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
   catch (e)
   {
    alert("Your browser does not support this function");
	return false;
   }
  }
 }
}

function PrintPage()
{
 try
 {window.print();}
 catch (e)
 {alert("Sorry, your browser does not support this feature,\nplease use your print menu")}
}

