function checkrequired(which) { // include a hidden field in form with name CompulsoryFields
var pass=true;
var regEmailPattern = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

if ( regEmailPattern.test( which.EmailAddress.value )) {
}
else {
alert("Please enter a valid email address");
return false; 
}
}

// returns the element value from modules array
function getHmElement(eName,b,eMod) {

elementName= eName + b + eMod;
  for (var a=0;a<mdModule.length;a++) {
   if (elementName == mdModule[a][0]) {
   var eValue = mdModule[a][1];
   return eValue;
   break;
   }
  }
 return null;
}

// write the pagedate out in long format
function formatDate(numdate){  
  var numlist = numdate.split('%2F');
  d=Number(numlist[0]);
  m=Number(numlist[1])-1;
  y=numlist[2];
  var strmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
    strdate = d+" "+strmonth[m]+" "+y;
    return strdate;	
   }

function inStr(beginning, word1, word2) {
check1 = new String(word2);
returnInStr = word1.indexOf(word2, (beginning - 1)) + 1;
return returnInStr; 
}

function mid(inputMid, pos, l) {
pos = pos - 1;
if ((pos < inputMid.length) && ((pos + l) <=
    inputMid.length)) {
  returnMid = inputMid.substring(pos, pos + l); }
else { returnMid = "";  }
return returnMid;
}

function replaceSubstring (inputString, badString,
                          goodString, caseSensitive) {
  fixedReplace = "";
  UI = inputString;
  UB = badString;
  if ((caseSensitive != 1) && (caseSensitive != true)) {
  UI = inputString.toUpperCase();
     UB = badString.toUpperCase();
     }
  badEnd = -1;
  badLoc = UI.indexOf(UB);
  if (badLoc != -1) {
     for (x=1; (badLoc != -1); x++) {
        fixedReplace = fixedReplace + 
                       inputString.substring((badEnd +
                       1), badLoc) + goodString
        badEnd = badLoc + UB.length - 1;
        badLoc = UI.indexOf(UB, (badLoc + 1)); }
     fixedReplace = fixedReplace + 
                    inputString.substring((badEnd + 1),
                    inputString.length); }
     else { fixedReplace = inputString;    }
return fixedReplace;
}


// similar to the StrLeft function 
function getFront(mainStr, searchStr ){
	foundOffset = mainStr.indexOf(searchStr)
	if ( foundOffset == -1 ) {
		return null;
	}
	return mainStr.substring(0, foundOffset );
}

// similar to the StrRight function 
function getEnd(mainStr, searchStr ){
	foundOffset = mainStr.indexOf(searchStr)
	if ( foundOffset == -1 ) {
		return null;
	}
	return mainStr.substring( foundOffset + searchStr.length, mainStr.length);
}

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_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_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_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];}
}
// similar to the StrLeft function 
function getFront(mainStr, searchStr ){
	foundOffset = mainStr.indexOf(searchStr)
	if ( foundOffset == -1 ) {
		return null;
	}
	return mainStr.substring(0, foundOffset );
}

// similar to the StrRight function 
function getEnd(mainStr, searchStr ){
	foundOffset = mainStr.indexOf(searchStr)
	if ( foundOffset == -1 ) {
		return null;
	}
	return mainStr.substring( foundOffset + searchStr.length, mainStr.length);
}