// Note: function mmLoadMenus2() has two versions, one each for vinchaud.biz and e2webs-server-1 servers.

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function e2_insertMailTo(emailName, emailDomain, emailVisibleText) {
  var s;
  s = emailName + '@' + emailDomain;
  document.write("<a href='mailto:" + s + "'>" + emailVisibleText + "</a>");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
} 

function closeWindow() {
		newWindow.close()
} 
	
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
  return "Email address is incorrect (check @ and .'s)";
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
  return "The email username contains invalid characters.";
  }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
  return "The email domain name contains invalid characters.";
  }
}

// See if "user" is valid 
if (user.match(userPat)==null) {
  return "The email username is not valid.";
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
  return "The email destination IP address is invalid!";
  }
}
return "";
}

// Domain is symbolic name.  Check if it's valid.
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
  return "The email domain name is not valid.";
  }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
  return "The email address must end in a well-known domain or two letter country.";
}

// Make sure there's a host name preceding the domain.
if (len<2) {
  return "The email address is missing a hostname!";
}

// If we've gotten this far, everything's valid!
return "";
}

// Remember that there are two menu functions!
function mmLoadMenus2() {
  //var unsecurepath='http://dev.snowcard.co.uk/pages/';  //For vinchaud.biz server snowcard development site
  //var unsecurepath='http://www.vinchaud.biz/snowcardnew/pages/';  //For vinchaud.biz server snowcard development site
  var unsecurepath='http://www.snowcard.co.uk/pages/';  //for the vinchaud.biz server
  //var unsecurepath='http://e2webs-server-1/snowcardnew/pages/';  //for the e2webs-server-1 server
  if (window.mm_menu_1130210430_0) return;
    window.mm_menu_1130210430_0 = new Menu("root",330,22,"Verdana",12,"#000000","#ffffff","#ffcc00","#000000","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
  mm_menu_1130210430_0.addMenuItem("using&nbsp;snowcard&nbsp;with&nbsp;confidence&nbsp;&&nbsp;security","location='"+unsecurepath+"security.asp'");
  mm_menu_1130210430_0.addMenuItem("why&nbsp;use&nbsp;snowcard","location='"+unsecurepath+"s_about.asp'");
  mm_menu_1130210430_0.addMenuItem("contact&nbsp;us","location='"+unsecurepath+"s_contact.asp'");
   mm_menu_1130210430_0.fontWeight="bold";
   mm_menu_1130210430_0.hideOnMouseOut=true;
   mm_menu_1130210430_0.bgColor='#ffffff';
   mm_menu_1130210430_0.menuBorder=0;
   mm_menu_1130210430_0.menuLiteBgColor='#ffffff';
   mm_menu_1130210430_0.menuBorderBgColor='#ffffff';
  window.mm_menu_1130212026_1 = new Menu("root",160,22,"Verdana",12,"#000000","#ffffff","#ffcc00","#000000","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
  mm_menu_1130212026_1.addMenuItem("how&nbsp;to&nbsp;make&nbsp;a&nbsp;claim","location='"+unsecurepath+"policy_claims.asp'");
  mm_menu_1130212026_1.addMenuItem("request&nbsp;a&nbsp;claim&nbsp;form","location='"+unsecurepath+"policy_claims.asp#claimform'");

mm_menu_1130212026_1.addMenuItem("emergencies","location='"+unsecurepath+"policy_claims.asp#emergency'");

   mm_menu_1130212026_1.fontWeight="bold";
   mm_menu_1130212026_1.hideOnMouseOut=true;
   mm_menu_1130212026_1.bgColor='#ffffff';
   mm_menu_1130212026_1.menuBorder=0;
   mm_menu_1130212026_1.menuLiteBgColor='#ffffff';
   mm_menu_1130212026_1.menuBorderBgColor='#ffffff';
  window.mm_menu_1130212223_2 = new Menu("root",160,22,"Verdana",12,"#000000","#ffffff","#ffcc00","#000000","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
  mm_menu_1130212223_2.addMenuItem("choosing&nbsp;your&nbsp;policy","location='"+unsecurepath+"howtoapply.asp'");
  mm_menu_1130212223_2.addMenuItem("how&nbsp;to&nbsp;make&nbsp;a&nbsp;claim","location='"+unsecurepath+"policy_claims.asp'");
  
  mm_menu_1130212223_2.addMenuItem("faq's","location='"+unsecurepath+"faq.asp'");
	mm_menu_1130212223_2.addMenuItem("safety gear","location='"+unsecurepath+"s_safetygear.asp'");
  mm_menu_1130212223_2.addMenuItem("travel advice","location='"+unsecurepath+"traveladvice.asp'");
  mm_menu_1130212223_2.addMenuItem("know before you go","location='http://www.fco.gov.uk/travel'");
  mm_menu_1130212223_2.addMenuItem("loss prevention","location='"+unsecurepath+"traveladvice.asp#lossprevention'");
   mm_menu_1130212223_2.fontWeight="bold";
   mm_menu_1130212223_2.hideOnMouseOut=true;
   mm_menu_1130212223_2.bgColor='#ffffff';
   mm_menu_1130212223_2.menuBorder=0;
   mm_menu_1130212223_2.menuLiteBgColor='#ffffff';
   mm_menu_1130212223_2.menuBorderBgColor='#ffffff';
  window.mm_menu_1130212329_3 = new Menu("root",160,22,"Verdana",12,"#000000","#ffffff","#ffcc00","#000000","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
   mm_menu_1130212329_3.addMenuItem("policy&nbsp;options","location='"+unsecurepath+"policy_options.asp'");
  mm_menu_1130212329_3.addMenuItem("health&nbsp;declaration","location='"+unsecurepath+"policy_health.asp'");
  mm_menu_1130212329_3.addMenuItem("policy&nbsp;words","location='"+unsecurepath+"policy_words[1].asp'");
  mm_menu_1130212329_3.addMenuItem("terms&nbsp;of&nbsp;business","location='"+unsecurepath+"s_terms.asp'");
  mm_menu_1130212329_3.addMenuItem("privacy&nbsp;policy","location='"+unsecurepath+"s_privacy.asp'");
   mm_menu_1130212329_3.fontWeight="bold";
   mm_menu_1130212329_3.hideOnMouseOut=true;
   mm_menu_1130212329_3.bgColor='#ffffff';
   mm_menu_1130212329_3.menuBorder=0;
   mm_menu_1130212329_3.menuLiteBgColor='#ffffff';
   mm_menu_1130212329_3.menuBorderBgColor='#ffffff';

mm_menu_1130212329_3.writeMenus();
}

// same as mmLoadMenus2() but includes path offset "/pages/", specifically for index pages
function mmLoadMenus1() {
  if (window.mm_menu_1130210430_0) return;
        window.mm_menu_1130210430_0 = new Menu("root",160,22,"Verdana",12,"#006699","#ffffff","#99ccff","#99cc00","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
  mm_menu_1130210430_0.addMenuItem("why&nbsp;use&nbsp;snowcard","location='pages/s_about.asp'");
  mm_menu_1130210430_0.addMenuItem("contact&nbsp;us","location='pages/s_contact.asp'");
   mm_menu_1130210430_0.fontWeight="bold";
   mm_menu_1130210430_0.hideOnMouseOut=true;
   mm_menu_1130210430_0.bgColor='#FFFFFF';
   mm_menu_1130210430_0.menuBorder=0;
   mm_menu_1130210430_0.menuLiteBgColor='#FFFFFF';
   mm_menu_1130210430_0.menuBorderBgColor='#FFFFFF';
window.mm_menu_1130212026_1 = new Menu("root",160,22,"Verdana",12,"#006699","#ffffff","#99ccff","#99cc00","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
  mm_menu_1130212026_1.addMenuItem("how&nbsp;to&nbsp;make&nbsp;a&nbsp;claim","location='pages/policy_claims.asp'");
  mm_menu_1130212026_1.addMenuItem("request&nbsp;a&nbsp;claim&nbsp;form","location='pages/policy_claims.asp#claimform'");

mm_menu_1130212026_1.addMenuItem("emergencies","location='pages/policy_claims.asp#emergency'");

   mm_menu_1130212026_1.fontWeight="bold";
   mm_menu_1130212026_1.hideOnMouseOut=true;
   mm_menu_1130212026_1.bgColor='#ffffff';
   mm_menu_1130212026_1.menuBorder=0;
   mm_menu_1130212026_1.menuLiteBgColor='#ffffff';
   mm_menu_1130212026_1.menuBorderBgColor='#ffffff';
  window.mm_menu_1130212223_2 = new Menu("root",160,22,"Verdana",12,"#006699","#ffffff","#99ccff","#99cc00","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
  mm_menu_1130212223_2.addMenuItem("choosing&nbsp;your&nbsp;policy","location='pages/howtoapply.asp'");
  mm_menu_1130212223_2.addMenuItem("how&nbsp;to&nbsp;make&nbsp;a&nbsp;claim","location='pages/policy_claims.asp'");
  
  mm_menu_1130212223_2.addMenuItem("faq's","location='pages/faq.asp'");
		mm_menu_1130212223_2.addMenuItem("safety gear","location='pages/s_safetygear.asp'");
  mm_menu_1130212223_2.addMenuItem("travel advice","location='pages/traveladvice.asp'");
  mm_menu_1130212223_2.addMenuItem("know before you go","location='http://www.fco.gov.uk/travel'");
  mm_menu_1130212223_2.addMenuItem("loss prevention","location='pages/traveladvice.asp#lossprevention'");
   mm_menu_1130212223_2.fontWeight="bold";
   mm_menu_1130212223_2.hideOnMouseOut=true;
   mm_menu_1130212223_2.bgColor='#ffffff';
   mm_menu_1130212223_2.menuBorder=0;
   mm_menu_1130212223_2.menuLiteBgColor='#ffffff';
   mm_menu_1130212223_2.menuBorderBgColor='#ffffff';
  window.mm_menu_1130212329_3 = new Menu("root",160,22,"Verdana",12,"#006699","#ffffff","#99ccff","#99cc00","center","middle",3,1,250,-5,7,true,true,true,0,false,false);
    mm_menu_1130212329_3.addMenuItem("policy&nbsp;options","location='pages/policy_options.asp'");
  mm_menu_1130212329_3.addMenuItem("health&nbsp;declaration","location='pages/policy_health.asp'");
  mm_menu_1130212329_3.addMenuItem("policy&nbsp;words","location='pages/policy_words[1].asp'");
  mm_menu_1130212329_3.addMenuItem("terms&nbsp;of&nbsp;business","location='pages/s_terms.asp'");
  mm_menu_1130212329_3.addMenuItem("privacy&nbsp;policy","location='pages/s_privacy.asp'");
   mm_menu_1130212329_3.fontWeight="bold";
   mm_menu_1130212329_3.hideOnMouseOut=true;
   mm_menu_1130212329_3.bgColor='#ffffff';
   mm_menu_1130212329_3.menuBorder=0;
   mm_menu_1130212329_3.menuLiteBgColor='#ffffff';
   mm_menu_1130212329_3.menuBorderBgColor='#ffffff';

mm_menu_1130212329_3.writeMenus();
}
// from http://javascript.about.com/library/scripts/bldatemath.htm
function e2_dateAdd(startDate, numDays, numMonths, numYears)
{
  // Need a check here to correct for British Summer Time as I found out! rm28.10.03
  if (startDate.getHours() == 0) {
    startDate.setHours(1)
  }
  
	var returnDate = new Date(startDate.getTime());
	var yearsToAdd = parseInt(numYears);
	
	var month = returnDate.getMonth()	+ parseInt(numMonths);
	if (month > 11)
	{
		yearsToAdd = Math.floor((month+1)/12);
		month -= 12*yearsToAdd;
		yearsToAdd += parseInt(numYears);
	}
	returnDate.setMonth(month);
	returnDate.setFullYear(returnDate.getFullYear()	+ yearsToAdd);
	
	returnDate.setTime(returnDate.getTime()+864e5*parseInt(numDays));
	
	return returnDate;

}
