function sumTotal()
{

numMember = new Number(document.register_conference.memberfee.value);
numNonMember = new Number(document.register_conference.nonmemberfee.value);
numPartner = new Number(document.register_conference.partnerfee.value);

memberTotal = numMember * 300;
nonMemberTotal = numNonMember * 350;
partnerTotal = numPartner * 180;

total = memberTotal + nonMemberTotal + partnerTotal;


return "$"+total+".00";

}

function iVal(val)
{
  var sTmp = "";
  var sAllow = "1234567890";
  
  for(i=0; i<val.length; i++) 
  {
  	if(sAllow.indexOf(val.charAt(i))>=0) 
  	sTmp+=val.charAt(i);
  }
  return sTmp;
}


function regPmtClick(element)
{

if ((element.value == "AMEX") || (element.value == "MASTERCARD") || (element.value == "DINERSCARD") || (element.value == "VISA"))
{
	document.register_conference.Cardname.disabled=false;
	document.register_conference.Cardnumber.disabled=false;
	document.register_conference.Cardmonth.disabled=false;
	document.register_conference.Cardyear.disabled=false;
	document.register_conference.Cardname.focus();
}

return true;
}

function onRegisterFormSubmit(frm) 
{

   if ((frm.surname.value == "") || (frm.surname.value == 0))
   {
      alert("Please enter your surname. ");
      frm.surname.focus();
      return false;
   }

    if ((frm.firstname.value == "") || (frm.firstname.value == 0))
   {
      alert("Please enter your firstname. ");
      frm.firstname.focus();
      return false;
   }
   
   if ((frm.organisation.value == "") || (frm.organisation.value == 0))
   {
      alert("Please enter name of your oganisation. ");
      frm.organisation.focus();
      return false;
   }
   if ((frm.title.value == "") || (frm.title.value == 0))
   {
      alert("Please enter your job title. ");
      frm.title.focus();
      return false;
   }
   if ((frm.telephone.value == "") || (frm.telephone.value == 0))
   {
      alert("Please enter your telephone contact. ");
      frm.telephone.focus();
      return false;
   }
   
    check = check_email(frm.email.value);
   
   if (!check)
   {
       frm.email.focus();
       return false;
   }
   
   check = check_confemail(frm.confemail.value);
   
   if (!check)
   {
       frm.confemail.focus();
       return false;
   }
   
   if (frm.email.value != frm.confemail.value)
   {
       alert("Entered Email address and confirmation Email do not match");
       frm.email.focus();
       return false;
   }
   
    check = check_country(frm) 
    if (!check)
   {
       frm.country.focus();
       return false;
   }      
   
    check = check_payment(frm) 
    if (!check)
   {
       frm.payment.focus();
       return false;
   }     

   
   if ((element.value == "AMEX") || (element.value == "MASTERCARD") || (element.value == "DINERSCARD") || (element.value == "VISA"))
   {
   	// if paying by card make sure details are entered

   	if ((frm.cardname.value == "") || (frm.cardname.value == 0))
   	{
      		alert("Please enter the card name. ");
      		frm.cardname.focus();
      		return false;
   	}

   	if ((frm.cardnumber.value == "") || (frm.cardnumber.value == 0))
   	{
      		alert("Please enter the card number. ");
      		frm.cardnumber.focus();
      		return false;
   	}

   	
  }

   return true;   
}

function check_email(str)
{
   
   if (str == "")
   {
      alert("Please enter your e-mail address. ");
      return false;
   }
   
   if (str == 0)
   {
      alert("Please enter your e-mail address. ");
      return false;
   } 
   
   name = str;
   name = name.toLowerCase().substring(0, name.indexOf('@'));
   if ((name == "root") || (name == "domain-admin") || (name == "postmaster") || (name == "webmaster") || (name == "administrator") || (name == "admin") || (name == "adm") || (name == "dns") || (name == "mail") || (name == "news") || (name == "uucp") || (name == "ftp") || (name == "gopher") || (name == "nobody") || (name == "daemon") || (name == "noaccess") || (name == "listen") || (name == "lp") || (name == "hostmaster") || (name == "abuse") || (name == "security")) {
      alert("The entered email address cannot be used for subscription purposes.  Please enter a personal address");
      return false;
   }

   if (!isEmail(str))
   {
      alert("Please enter a valid e-mail address. ");
      return false;
   } 
   
   return true;
 }

function check_confemail(str)
{
   
   
   if (str == "")
   {
      alert("Please confirm your e-mail address. ");
      return false;
   }
   
   if (str == 0)
   {
      alert("Please confirm your e-mail address. ");
      return false;
   } 
   
   name = str;
   name = name.toLowerCase().substring(0, name.indexOf('@'));
   if ((name == "root") || (name == "domain-admin") || (name == "postmaster") || (name == "webmaster") || (name == "administrator") || (name == "admin") || (name == "adm") || (name == "dns") || (name == "mail") || (name == "news") || (name == "uucp") || (name == "ftp") || (name == "gopher") || (name == "nobody") || (name == "daemon") || (name == "noaccess") || (name == "listen") || (name == "lp") || (name == "hostmaster") || (name == "abuse") || (name == "security")) {
      alert("The entered confirmation email address  cannot be used as for subscription purposes.  Please enter a personal address");
      return false;
   }

   if (!isEmail(str))
   {
      alert("Please enter a valid confirmation e-mail address. ");
      return false;
   } 
   
   return true;
   
}
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function check_country(frm) 
{

   if (frm.country.options[frm.country.selectedIndex].value == "NULL")
   {
       alert("Please select your country of residence.");
       return false;
   }
   return true;
}

function check_payment(frm) 
{

   if (frm.payment.options[frm.payment.selectedIndex].value == "NULL")
   {
       alert("Please enter a method of payment.");
       return false;
   }
   return true;
}

function onRTSFormSubmit(frm) 
{


   if ((frm.name.value == "") || (frm.name.value == 0))
   {
      alert("Please enter your name. ");
      frm.name.focus();
      return false;
   }
   
    check = check_email(frm.email.value);
   
   if (!check)
   {
       frm.email.focus();
       return false;
   }
   
   check = check_confemail(frm.confemail.value);
   
   if (!check)
   {
       frm.confemail.focus();
       return false;
   }
   
   if (frm.email.value != frm.confemail.value)
   {
       alert("Entered Email address and confirmation Email do not match");
       frm.email.focus();
       return false;
   }
   
   if ((frm.feetype.value == "") || (frm.details.value == 0))
   {
      alert("Please select type of registration fees. ");
      frm.details.focus();
      return false;
   }      
   return true;
}

function onContactFormSubmit(frm) 
{


   if ((frm.name.value == "") || (frm.name.value == 0))
   {
      alert("Please enter your name. ");
      frm.name.focus();
      return false;
   }
   
    check = check_email(frm.email.value);
   
   if (!check)
   {
       frm.email.focus();
       return false;
   }
   
   check = check_confemail(frm.confemail.value);
   
   if (!check)
   {
       frm.confemail.focus();
       return false;
   }
   
   if (frm.email.value != frm.confemail.value)
   {
       alert("Entered Email address and confirmation Email do not match");
       frm.email.focus();
       return false;
   }
   
   if ((frm.comments.value == "") || (frm.comments.value == 0))
   {
      alert("Please enter a message. ");
      frm.message.focus();
      return false;
   }   
   return true;
}

function onFeedbackFormSubmit(frm) 
{


   check = check_email(frm.email.value);
   
   if (!check)
   {
       frm.email.focus();
       return false;
   }
   
   if (frm.email.value != frm.confemail.value)
   {
       alert("Entered Email address and confirmation Email do not match");
       frm.email.focus();
       return false;
   }
         
   return true;
}

function onSubscribeFormSubmit(frm) 
{


   check = check_email(frm.email.value);
   
   if (!check)
   {
       frm.email.focus();
       return false;
   }
   
   check = check_for_countrynews(frm)
    if (!check)
   {
       frm.countrynews[0].focus();
       return false;
   }

  
   check = check_for_activities(frm)
    if (!check)
   {
       frm.activities[0].focus();
       return false;
   }

   check = check_country(frm) 
    if (!check)
   {
       frm.country.focus();
       return false;
   }

   check = check_confemail(frm.confemail.value);
   
   if (!check)
   {
       frm.confemail.focus();
       return false;
   }
   
   if (frm.email.value != frm.confemail.value)
   {
       alert("Entered Email address and confirmation Email do not match");
       frm.email.focus();
       return false;
   }
   
   return true;
}

function check_email(str)
{
   
   if (str == "")
   {
      alert("Please enter your e-mail address. ");
      return false;
   }
   
   if (str == 0)
   {
      alert("Please enter your e-mail address. ");
      return false;
   } 
   
   name = str;
   name = name.toLowerCase().substring(0, name.indexOf('@'));
   if ((name == "root") || (name == "domain-admin") || (name == "postmaster") || (name == "webmaster") || (name == "administrator") || (name == "admin") || (name == "adm") || (name == "dns") || (name == "mail") || (name == "news") || (name == "uucp") || (name == "ftp") || (name == "gopher") || (name == "nobody") || (name == "daemon") || (name == "noaccess") || (name == "listen") || (name == "lp") || (name == "hostmaster") || (name == "abuse") || (name == "security")) {
      alert("The entered email address cannot be used as for subscription purposes.  Please enter a personal address");
      return false;
   }

   if (!isEmail(str))
   {
      alert("Please enter a valid e-mail address. ");
      return false;
   } 
   
   return true;
   
}

function check_confemail(str)
{
   
   
   if (str == "")
   {
      alert("Please confirm your e-mail address. ");
      return false;
   }
   
   if (str == 0)
   {
      alert("Please confirm your e-mail address. ");
      return false;
   } 
   
   name = str;
   name = name.toLowerCase().substring(0, name.indexOf('@'));
   if ((name == "root") || (name == "domain-admin") || (name == "postmaster") || (name == "webmaster") || (name == "administrator") || (name == "admin") || (name == "adm") || (name == "dns") || (name == "mail") || (name == "news") || (name == "uucp") || (name == "ftp") || (name == "gopher") || (name == "nobody") || (name == "daemon") || (name == "noaccess") || (name == "listen") || (name == "lp") || (name == "hostmaster") || (name == "abuse") || (name == "security")) {
      alert("The entered confirmation email address  cannot be used as for subscription purposes.  Please enter a personal address");
      return false;
   }

   if (!isEmail(str))
   {
      alert("Please enter a valid confirmation e-mail address. ");
      return false;
   } 
   
   return true;
   
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function check_for_countrynews(frm) {
   if (frm.countrynews.length > 0) {
      for (var i = 0; i < frm.countrynews.length; i++) {
         if (frm.countrynews[i].checked) {
            return true;
         }
      }
   } else {
      // there is only one checkbox
      if (frm.countrynews.checked) {
         return true;
      }
   }

   alert("Please select one or more countries to receive news from");
   return false;
}

function check_for_activities(frm) {
   if (frm.activities.length > 0) {
      for (var i = 0; i < frm.activities.length; i++) {
         if (frm.activities[i].checked) {
            return true;
         }
      }
   } else {
      // there is only one checkbox
      if (frm.activities.checked) {
         return true;
      }
   }

   alert("Please select one or more activities.");
   return false;
}

function check_country(frm) 
{

   if (frm.country.options[frm.country.selectedIndex].value == "NULL")
   {
       alert("Please select your country of residence.");
       return false;
   }
   return true;
}

function check_hotel(frm) 
{

   if (frm.hotel.options[frm.hotel.selectedIndex].value == "NULL")
   {
       alert("Please select your choice of accommodation.");
       return false;
   }
   return true;
}
function onReservationFormSubmit(frm) 
{


   if ((frm.name.value == "") || (frm.name.value == 0))
   {
      alert("Please enter your name. ");
      frm.name.focus();
      return false;
   }
   

   check = isDate(frm.checkin.value);
    if (!check)
   {
       frm.checkin.focus();
       return false;
   }

   check = isDate(frm.checkout.value);
    if (!check)
   {
       frm.checkout.focus();
       return false;
   }
   
   check = check_hotel(frm) 
    if (!check)
   {
       frm.hotel.focus();
       return false;
   }
      
   check = check_email(frm.email.value);
   
   if (!check)
   {
       frm.email.focus();
       return false;
   }
   
   check = check_confemail(frm.confemail.value);
   
   if (!check)
   {
       frm.confemail.focus();
       return false;
   }
   
   if (frm.email.value != frm.confemail.value)
   {
       alert("Entered Email address and confirmation Email do not match");
       frm.email.focus();
       return false;
   }
   

   return true;
}


/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
     // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	// Declaring valid date character, minimum year and maximum year

	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;

	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
