var currentEl="1";
var views= 7;

/*
function initialise(){
var el;
if (ebook=="btl") views=7;
if (ebook=="rtb") views=8;
if (ebook=="ftb") views=8;
if (ebook=="rem") views=8;
for(i=0;i<=views;i++) {
	document.getElementById("div_view" + i).style.display="none";
	}
document.getElementById("div_view1").style.display="block";
}
*/

function sidemenu(item){
var el;
	document.getElementById("div_view" + currentEl).style.display="none";
	document.getElementById("div_view" + item).style.display="block";
document.getElementById("smenu_view" + currentEl).style.color="white";	  document.getElementById("smenu_view" + item).style.color="darkred";
	currentEl=item;
return;
}


function ApplyFormSubmit(){
var name="";
var email="";
var phone="";
var contactType="";
var missingItems="";
var missingNo=0;
var other="";
var rtype="";

missingItems = "Sorry you have not completed some fields we need to respond.\r Please complete the fields indicated and try again.\r\r";
missingNo = missingItems.length;
name = document.getElementById("ApplyForm").elements["txtNm"].value;
addr = document.getElementById("ApplyForm").elements["txtAd1"].value;
pcode = document.getElementById("ApplyForm").elements["txtPCd"].value;
email= document.getElementById("ApplyForm").elements["txtEMl"].value;
phone= document.getElementById("ApplyForm").elements["txtPh"].value;
contactType = document.getElementById("ApplyForm").elements["contactPrefs"].value;
rtype=document.getElementById("ApplyForm").elements["infoType"].value;
other=document.getElementById("ApplyForm").elements["txtOther"].value;

if ( name.length==0)
		{ missingItems+="Name\r"; }
if ( addr.length==0)
		{ missingItems+="Address\r"; }
if ( pcode.length==0)
		{ missingItems+="Post Code\r"; }

if (contactType=="0")
		{ missingItems+="Preferred Contact Method\r"; }
if (rtype=="0")
		{ missingItems+="Information requested\r"; }
if (contactType=="2" && email.length==0)
	{ missingItems+="Email Address\r"; }
if (contactType=="1" && phone.length==0)
		{ missingItems+="Phone Number\r"; }
if (contactType=="2" && email.length > 0)
	{ if (email.indexOf("@") <= 0 || email.indexOf(".") <= 0)
		{ missingItems+="Email Address not valid\r"; }
	}
if (contactType=="1" && phone.length > 0)
	{ phone=phone.replace(/[ ()]/gi, "");
	  if(isNaN(phone))		
		{ missingItems+="Phone Number not numeric\r"; }
	}
if(other.length > 255)
	document.getElementById("ApplyForm").elements["txtOther"].innerHTML=other.substr(0,255);
if(missingNo < missingItems.length)
	{ alert(missingItems);
	 return false; }
else
	{ document.forms("ApplyForm").submit();
	  return true; }
}
