var alertmessage="";
var checkstr ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-/:?*,.'@~#%$£€!µ°±(){}[ ]\n\r\f";
var badchars="";


function InsertContent(d) {
   document.getElementById(d).style.display = "";
} 

function RemoveContent(d) {
   document.getElementById(d).style.display = 'none';
}

function articles() {
	document.getElementById('intro').style.display = '';	
	document.getElementById('npi').style.display = 'none';
	document.getElementById('lcm').style.display = 'none';
	document.getElementById('models').style.display = 'none';
	document.getElementById('value').style.display = 'none';
	document.getElementById('parts').style.display = 'none';
	document.getElementById('serviceequity').style.display = 'none';
	document.getElementById('armor').style.display = 'none';
	document.getElementById('seven').style.display = 'none';
	document.getElementById('servicepicture').style.display = 'none';
	document.getElementById('toggleline').style.display = 'none';
}	

function casestudies() {
	document.getElementById('intro').style.display = '';	
	document.getElementById('streamlining').style.display = 'none';
	document.getElementById('buildingtrades').style.display = 'none';
	document.getElementById('electroplater').style.display = 'none';
	document.getElementById('processredesign').style.display = 'none';
	document.getElementById('businessmodelling').style.display = 'none';
	document.getElementById('bpr').style.display = 'none';
	document.getElementById('fundamental').style.display = 'none';
	document.getElementById('decisionsupport').style.display = 'none';
	document.getElementById('supportreorg').style.display = 'none';
	document.getElementById('forecasting').style.display = 'none';
	document.getElementById('msop').style.display = 'none';
	document.getElementById('toggleline').style.display = 'none';
}	

function faqs() {
	document.getElementById('intro').style.display = '';	
	document.getElementById('f01').style.display = 'none';
	document.getElementById('f02').style.display = 'none';
	document.getElementById('f03').style.display = 'none';
	document.getElementById('f04').style.display = 'none';
	document.getElementById('f05').style.display = 'none';
	document.getElementById('f06').style.display = 'none';
	document.getElementById('f07').style.display = 'none';
	document.getElementById('f08').style.display = 'none';
	document.getElementById('f09').style.display = 'none';
	document.getElementById('f10').style.display = 'none';
	document.getElementById('f11').style.display = 'none';
	document.getElementById('f12').style.display = 'none';
	document.getElementById('f13').style.display = 'none';
	document.getElementById('f14').style.display = 'none';
	document.getElementById('f15').style.display = 'none';
	document.getElementById('f16').style.display = 'none';
	document.getElementById('f17').style.display = 'none';
	document.getElementById('f18').style.display = 'none';
	document.getElementById('f19').style.display = 'none';
	document.getElementById('toggleline').style.display = 'none';
}	

function faqs1()	{
	faqs();
	toggle('toggleline');
	toggle('intro');
	}
	
function programs() {
	document.getElementById('elst').style.display = 'none';
	document.getElementById('el').style.display = 'none';
	document.getElementById('sp').style.display = 'none';
	document.getElementById('mgmt').style.display = 'none';
	document.getElementById('supv').style.display = 'none';
	document.getElementById('sales').style.display = 'none';
	document.getElementById('agr').style.display = 'none';
	document.getElementById('ctr').style.display = 'none';
	document.getElementById('varred').style.display = 'none';
}	

function hideall() {
	document.getElementById('intro').style.display = '';
	document.getElementById('resourcetable').style.display = '';
	document.getElementById('finance').style.display = 'none';
	document.getElementById('operations').style.display = 'none';
	document.getElementById('healthinsce').style.display = 'none';
	document.getElementById('infotech').style.display = 'none';
	document.getElementById('execcoach').style.display = 'none';
	document.getElementById('salescoach').style.display = 'none';
	document.getElementById('fundssource').style.display = 'none';
	document.getElementById('mfgops').style.display = 'none';
	document.getElementById('busowner').style.display = 'none';
	document.getElementById('toggleline').style.display = 'none';	
}	

function displaybusmgmt()	{
	void(location.href='#topmosttop');
	RemoveContent('initialscreen');
	RemoveContent('openscreen');
	InsertContent('busmgmt');
	InsertContent('busmgmt1');
	RemoveContent('showbusmgmt');
	RemoveContent('npi');
	RemoveContent('npi1');
	InsertContent('shownpi');
	InsertContent('showtechnicalsupport');
	RemoveContent('technicalsupport');
	RemoveContent('technicalsupport1');
	}
	
function displaynpi()	{
	void(location.href='#topmosttop');
	RemoveContent('initialscreen');
	RemoveContent('openscreen');
	RemoveContent('busmgmt');
	RemoveContent('busmgmt1');
	InsertContent('npi');
	InsertContent('showbusmgmt');
	InsertContent('npi1');
	RemoveContent('shownpi');
	InsertContent('showtechnicalsupport');
	RemoveContent('technicalsupport');
	RemoveContent('technicalsupport1');
	}

function displaytechnicalsupport()	{
	void(location.href='#topmosttop');
	RemoveContent('initialscreen');
	RemoveContent('openscreen');
	RemoveContent('busmgmt');
	RemoveContent('busmgmt1');
	RemoveContent('npi');
	InsertContent('showbusmgmt');
	RemoveContent('npi1');
	InsertContent('shownpi');
	RemoveContent('showtechnicalsupport');
	InsertContent('technicalsupport');
	InsertContent('technicalsupport1');
	}



function resizer() {
var winwidth="0", maxwidth="960", minwidth="760", usablewidth="0", firsttablewidth="0", secondtablewidth="0";

	winwidth = document.all?document.body.clientWidth:window.innerWidth
	usablewidth = Math.min(maxwidth,winwidth);
	usablewidth = Math.max(usablewidth,minwidth);
	firsttablewidth=usablewidth-"460";
	secondtablewidth=usablewidth-"210";

	document.getElementById("datatable").setAttribute("width",usablewidth)
	document.getElementById("secondtable").setAttribute("width",secondtablewidth)
}


function ShowFirstPart()	{
	void(location.href='#topmosttop');
	InsertContent('FirstPart');	
	RemoveContent('Results');
	RemoveContent('Secondpart');
	RemoveContent('thistop');
}

function ShowResults()	{
	void(location.href='#topmosttop');
	InsertContent('Results');
	InsertContent('GetScore');
	InsertContent('GoToSecond');
	RemoveContent('FirstPart');	
	RemoveContent('Secondpart');
	RemoveContent('thistop');
}
 
function ShowSecondPart()	{
	void(location.href='#topmosttop');
	InsertContent('SecondPart');
	RemoveContent('FirstPart');	
	RemoveContent('Results');
	RemoveContent('thistop');
}

function toggle(obj) {
   var el = document.getElementById(obj);
   if ( el.style.display != 'none' ) {
      el.style.display = 'none';
   }
   else {
      el.style.display = '';
   }
}

<!-- // This script computes scores by question as well as the total. //-->
var q1total=0, q2total=0, q3total=0, q4total=0, q5total=0, q6total=0, q7total=0, q8total=0, q9total=0, totalscore=0;
var q11=q12=q13=q14=q15=q21=q22=q23=q24=q25=q26=q31=q32=q33=q34=q35=q36=0;
var q41=q42=q51=q52=q61=q62=q71=q72=q81=q82=q91=0;
var q111=q112=q113=q114=q115=q116=q117=q118=0;
var q121=q122=q123=q124=0;
var q10=q10total=q10display="x";
var alertmessage="";
var totalscore=0;
var qdisplay=0;
function q1sum () {
   q1total=0;
   if (document.queries.q11[0].checked==true) {q1total=q1total+2;}
   if (document.queries.q12[0].checked==true) {q1total=q1total+3;}
   if (document.queries.q13[0].checked==true) {q1total=q1total+3;}
   if (document.queries.q14[0].checked==true) {q1total=q1total+2;}
   if (document.queries.q15[0].checked==true) {q1total=q1total+5;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
      qdisplay=totalscore;
   document.queries.q1display.value = q1total;
   document.queries.qdisplay.value = totalscore;
}
function q2sum () {
   q2total=0;
   if (document.queries.q21[0].checked==true) {q2total=q2total+2;}
   if (document.queries.q22[0].checked==true) {q2total=q2total+2;}
   if (document.queries.q23[0].checked==true) {q2total=q2total+3;}
   if (document.queries.q24[0].checked==true) {q2total=q2total+3;}
   if (document.queries.q25[0].checked==true) {q2total=q2total+2;}
   if (document.queries.q26[0].checked==true) {q2total=q2total+4;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q2display.value = q2total;
   document.queries.qdisplay.value = totalscore;
}
function q3sum () {
   q3total=0;
   if (document.queries.q31[0].checked==true) {q3total=q3total+3;}
   if (document.queries.q32[0].checked==true) {q3total=q3total+4;}
   if (document.queries.q33[0].checked==true) {q3total=q3total+4;}
   if (document.queries.q34[0].checked==true) {q3total=q3total+2;}
   if (document.queries.q35[0].checked==true) {q3total=q3total+4;}
   if (document.queries.q36[0].checked==true) {q3total=q3total+4;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q3display.value = q3total;
   document.queries.qdisplay.value = totalscore;
}
function q4sum () {
   q4total=0;
   if (document.queries.q41[0].checked==true) {q4total=q4total+4;}
   if (document.queries.q42[0].checked==true) {q4total=q4total+4;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q4display.value = q4total;
   document.queries.qdisplay.value = totalscore;
}
function q5sum () {
   q5total=0;
   if (document.queries.q51[0].checked==true) {q5total=q5total+3;}
   if (document.queries.q52[0].checked==true) {q5total=q5total+3;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q5display.value = q5total;
   document.queries.qdisplay.value = totalscore;
}
function q6sum () {
   q6total=0;
   if (document.queries.q61[0].checked==true) {q6total=q6total+4;}
   if (document.queries.q62[0].checked==true) {q6total=q6total+4;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q6display.value = q6total;
   document.queries.qdisplay.value = totalscore;
}
function q7sum () {
   q7total=0;
   if (document.queries.q71[0].checked==true) {q7total=q7total+4;}
   if (document.queries.q72[0].checked==true) {q7total=q7total+4;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q7display.value = q7total;
   document.queries.qdisplay.value = totalscore;
}
function q8sum () {
   q8total=0;
   if (document.queries.q81[0].checked==true) {q8total=q8total+4;}
   if (document.queries.q82[0].checked==true) {q8total=q8total+4;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q8display.value = q8total;
   document.queries.qdisplay.value = totalscore;
}
function q9sum () {
   q9total=0;
   if (document.queries.q91[0].checked==true) {q9total=q9total+10;}
      totalscore=q1total+q2total+q3total+q4total+q5total+q6total+q7total+q8total+q9total;
   document.queries.q9display.value = q9total;
   document.queries.qdisplay.value = totalscore;
}

function q10sum () {
   q10display="Yes";
   if (document.queries.q101[0].checked==true) {document.queries.q10display.value = "Yes";}
   if (document.queries.q101[1].checked==true) {document.queries.q10display.value =  "No";}
}

<!--//	end of score computing script	//-->
<!-- // This script displays and hides the second half of the questionnaire until needed //-->


/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
This credit MUST stay intact for use
*/

function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

function enforcechar(what,limit){
if (what.value.length>=limit)
{return false;}
}


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 timestamp() {
    document.queries.dateandtime.value = new Date();
}

function ValidateAll()
{
	timestamp();
	alertmessage=""
	CheckName(document.queries.yourname);
	CheckEmail(document.queries.email.value);
	ValidatePhone(document.queries.busphone);
	CheckTextArea(document.queries.messagearea);
	if (alertmessage=="") {
		document.queries.submit();
	}
	if(!alertmessage=="") {
		alert(alertmessage);
	}	
}


<!-- Beginning of JavaScript for checking required fields and for checking that certain fields contain only digits. -->

<!-- Copyright 1999 William Bontrager

function CheckName(target)
{
	// developed by www.willmaster.com
	
	s_name = target.value ;
	s_name = IsItPresent(s_name,target.name);
	if(! s_name) return false;
	var i = s_name.indexOf('  ',0);
	while(i> -1)
	{
		s_name = s_name.substring(0,(i + 1)) + 
			s_name.substring((i + 2),s_name.length);
		i = s_name.indexOf('  ',0);
	}
	s_name = s_name.toLowerCase();
	var s = new String(s_name.substring(0,1));
	s = s.toUpperCase();
	s_name = s + s_name.substring(1,s_name.length);
	i = s_name.indexOf(' ',0);
	if(i == (s_name.length - 1)) i = -1;
	var ts = new String("");
	var j = 0;
	while(i> -1)
	{
		i++;
		j = i + 1;
		s = s_name.substring(i,j);
		s = s.toUpperCase();
		ts = '';
		if(i> 0) ts = s_name.substring(0,i);
		s_name = ts + s + s_name.substring(j,s_name.length);
		i = s_name.indexOf(' ',j);
		if(i == (s_name.length - 1)) i = -1;
	}
	// document.queries.name.value = s_name;
	target.value = s_name;
	return true;
}

function IsItPresent(s,explanation)
{
	// developed by www.willmaster.com
	s = StripSpacesFromEnds(s);
	if(s.length) return s;
	alertmessage=alertmessage+'\n'+'Please verify ' + explanation;
//	alert('Please enter ' + explanation + '.');
	return '';
}

function StripSpacesFromEnds(s)
{
	// developed by www.willmaster.com
	while((s.indexOf(' ',0) == 0) && (s.length> 1))
	{
		s = s.substring(1,s.length);
	}
	while((s.lastIndexOf(' ') == (s.length - 1)) && (s.length> 1))
	{
		s = s.substring(0,(s.length - 1));
	}
	if((s.indexOf(' ',0) == 0) && (s.length == 1)) s = '';
	return s;
}

function CheckURL(s_url)
{
	// developed by www.willmaster.com
	s_url = IsItPresent(s_url,s_url.name);
	if(! s_url) return false;
	var i = s_url.indexOf(' ',0);
	while(i> -1)
	{
		s_url = s_url.substring(0,i) + 
			s_url.substring((i + 1),s_url.length);
		i = s_url.indexOf(' ',0);
	}
	document.queries.x_added_url.value = s_url;
	if((s_url.indexOf('http://',0) != 0) ||
	   (s_url.length <11) ||
	   (s_url.indexOf('.',0) <8) ||
	   (s_url.lastIndexOf('.')> (s_url.length - 3)) ||
	   (s_url.lastIndexOf('.') <(s_url.length - 4)))
	{
		alertmessage=alertmessage+'\n'+"Invalid Web address";
//		alert('The URL ' + s_url + ' is not valid.');
		return false;
	}
	return true;
}

function CheckEmail(s_email)
{
	// developed by www.willmaster.com
	s_email = IsItPresent(s_email,'your email address');
	if(! s_email) return false;
	var i = s_email.indexOf(' ',0);
	while(i> -1)
	{
		s_email = s_email.substring(0,i) + 
			s_email.substring((i + 1),s_email.length);
		i = s_email.indexOf(' ',0);
	}
	document.queries.email.value = s_email;
	if((s_email.length <6) ||
	   (s_email.indexOf('@',0) <1) ||
	   (s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||
	   (s_email.lastIndexOf('@') > (s_email.length - 5)) ||
// Because domain name extensions now have varying lengths, 
// the code to check for maximum of 3 characters after the final dot is disabled.
//	   (s_email.lastIndexOf('.') > (s_email.length - 3)) ||
	   (s_email.lastIndexOf('.') < (s_email.length - 4)) ||
	   (s_email.indexOf('..',0)> -1) ||
	   (s_email.indexOf('@.',0)> -1) ||
	   (s_email.indexOf('.@',0)> -1) ||
	   (s_email.indexOf(',',0)> -1))
	{
		alertmessage=alertmessage+'\n'+'The email address is not valid';
//		alert('The email address "' + s_email + '" is not valid.');
		return false;
	}
	return true;
}


/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function ValidatePhone(target){
	var Phone=target ;
	
	if ((Phone.value==null)||(Phone.value=="")){
		alertmessage=alertmessage+'\n'+'Please enter your '+target.name+' number';
//		alert("Please Enter your Phone Number");
//		Phone.focus();
		return false;
	}
	if (checkInternationalPhone(Phone.value)==false){
		alertmessage=alertmessage+'\n'+'Please verify '+target.name;
//		alert("Please Enter a Valid Phone Number")
//		Phone.value="";
//		Phone.focus();
		return false;
	}
	return true
 }

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++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length == minDigitsInIPhoneNumber);
}


//var alertmessage="";
//var checkstr ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-/*,.'@~#%$£€!µ°±(){}[ ]\n\r\f";

//*************************************************
//This routine validates all required fields before submitting the email form
//function ValidateAll() {
//	alertmessage=""
//	CheckName(document.queries.yourname);
//	CheckName(document.queries.company);
//	CheckEmail(document.queries.email.value);
//	ValidatePhone(document.queries.busphone);
//	CheckTextArea(document.queries.messagearea);
//	stamp();
//	if (alertmessage=="") {
//		document.queries.submit();
//	}
//	if(!alertmessage=="") {
//		alert(alertmessage);
//	}	
//
//}

//*************************************************
//This routine validates fields before submitting the email form
function ValidateVoid() {
	alertmessage=""
	CheckName(document.queries.yourname); 
	CheckEmail(document.queries.email.value);
	ValidatePhone(document.queries.busphone);
	if (alertmessage=="") {
		document.queries.submit();
	}
	if(!alertmessage=="") {
		alert(alertmessage);
	}	
}

//*************************************************
//This routine validates fields before submitting the email form
function Validatepdfrequest() {
	alertmessage=""
	timestamp();
	CheckName(document.queries.yourname); 
	CheckEmail(document.queries.email.value);
	if (alertmessage=="") {
		document.queries.submit();
	}
	if(!alertmessage=="") {
		alert(alertmessage);
	}	
}



//*************************************************
function RemoveContent(d) {
   document.getElementById(d).style.display = "none";
}

//*************************************************
function InsertContent(d) {
   document.getElementById(d).style.display = "";
} 

//*************************************************
function zp(n){
return n<10?("0"+n):n;
}

//*************************************************
function insertDate(t,format){
var now=new Date();
var DD=zp(now.getDate());
var MM=zp(now.getMonth()+1);
var MM=zp(now.getMonth()+1);
var YYYY=now.getFullYear();
var YY=zp(now.getFullYear()%100);
format=format.replace(/DD/,DD);
format=format.replace(/MM/,MM);
format=format.replace(/YYYY/,YYYY);
format=format.replace(/YY/,YY);
t.value=format;
}


//*************************************************
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}


//*************************************************
function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

//*************************************************
function enforcechar(what,limit){
if (what.value.length>=limit)
{return false;}
}

//*************************************************
function stamp() {
    document.queries.dateandtime.value = new Date();
}

//*************************************************
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;
}


<!-- Beginning of JavaScript for checking required fields and for checking that certain fields contain only digits. -->

<!-- Copyright 1999 William Bontrager

//*************************************************
function CheckName(target)
{
	// developed by www.willmaster.com
	
	s_name = target.value ;
	s_name = IsItPresent(s_name,target.name);
	if(! s_name) return false;
	var i = s_name.indexOf('  ',0);
	while(i> -1)
	{
		s_name = s_name.substring(0,(i + 1)) + 
			s_name.substring((i + 2),s_name.length);
		i = s_name.indexOf('  ',0);
	}
	s_name = s_name.toLowerCase();
	var s = new String(s_name.substring(0,1));
	s = s.toUpperCase();
	s_name = s + s_name.substring(1,s_name.length);
	i = s_name.indexOf(' ',0);
	if(i == (s_name.length - 1)) i = -1;
	var ts = new String("");
	var j = 0;
	while(i> -1)
	{
		i++;
		j = i + 1;
		s = s_name.substring(i,j);
		s = s.toUpperCase();
		ts = '';
		if(i> 0) ts = s_name.substring(0,i);
		s_name = ts + s + s_name.substring(j,s_name.length);
		i = s_name.indexOf(' ',j);
		if(i == (s_name.length - 1)) i = -1;
	}
	target.value = s_name;
	return true;
}

//*************************************************
function CheckTextArea(target)
{
	// developed by www.willmaster.com
	
	s_name = target.value ;
	s_name = IsItPresent(s_name,target.name);
	if(! s_name) return false;
	var i = s_name.indexOf('  ',0);
	while(i> -1)
	{
		s_name = s_name.substring(0,(i + 1)) + 
			s_name.substring((i + 2),s_name.length);
		i = s_name.indexOf('  ',0);
	}
//	s_name = s_name.toLowerCase();
	var s = new String(s_name.substring(0,1));
//	s = s.toUpperCase();
	s_name = s + s_name.substring(1,s_name.length);
	i = s_name.indexOf(' ',0);
	if(i == (s_name.length - 1)) i = -1;
	var ts = new String("");
	var j = 0;
	while(i> -1)
	{
		i++;
		j = i + 1;
		s = s_name.substring(i,j);
//		s = s.toUpperCase();
		ts = '';
		if(i> 0) ts = s_name.substring(0,i);
		s_name = ts + s + s_name.substring(j,s_name.length);
		i = s_name.indexOf(' ',j);
		if(i == (s_name.length - 1)) i = -1;
	}
	target.value = s_name;
//	ValidateTextArea(target);
	return;
}


//*************************************************
function ValidateTextArea(field) {
//	var valid = "abcdefghijklmnopqrstuvwxyz0123456789";
var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-/:?&*,.'@~#%$£€!µ°±(){}<>[ ]\n\r\f";
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
	temp = "" + field.value.substring(i, i+1);
	if (valid.indexOf(temp) == "-1") ok = "no";
		}
	if (ok == "no") {
//		alert(ok);
		alertmessage=temp+" is an unacceptable character\n\nInvalid entry!  Only characters and numbers are accepted!\n";
//		alertmessage=alertmessage+temp+" is an unacceptable character\n\nInvalid entry!  Only characters and numbers are accepted!\n";
	}
	
}	

//*************************************************
function IsItPresent(s,explanation)
{
	// developed by www.willmaster.com
	s = StripSpacesFromEnds(s);
	if(s.length) return s;
	alertmessage=alertmessage+'\n'+'Please verify ' + explanation;
//	alert('Please enter ' + explanation + '.');
	return '';
}

//*************************************************
function StripSpacesFromEnds(s)
{
	// developed by www.willmaster.com
	while((s.indexOf(' ',0) == 0) && (s.length> 1))
	{
		s = s.substring(1,s.length);
	}
	while((s.lastIndexOf(' ') == (s.length - 1)) && (s.length> 1))
	{
		s = s.substring(0,(s.length - 1));
	}
	if((s.indexOf(' ',0) == 0) && (s.length == 1)) s = '';
	return s;
}

//*************************************************
function CheckURL(s_url)
{
	// developed by www.willmaster.com
	s_url = IsItPresent(s_url,s_url.name);
	if(! s_url) return false;
	var i = s_url.indexOf(' ',0);
	while(i> -1)
	{
		s_url = s_url.substring(0,i) + 
			s_url.substring((i + 1),s_url.length);
		i = s_url.indexOf(' ',0);
	}
	document.queries.weburl.value = s_url;
	if((s_url.indexOf('http://',0) != 0) ||
	   (s_url.length <11) ||
	   (s_url.indexOf('.',0) <8) ||
	   (s_url.lastIndexOf('.')> (s_url.length - 3)) ||
	   (s_url.lastIndexOf('.') <(s_url.length - 4)))
	{
		alertmessage=alertmessage+'\n'+"Invalid Web address";
//		alert('The URL ' + s_url + ' is not valid.');
		return false;
	}
	return true;
}

//*************************************************
function CheckEmail(s_email)
{
	// developed by www.willmaster.com
	s_email = IsItPresent(s_email,'your email address');
	if(! s_email) return false;
	var i = s_email.indexOf(' ',0);
	while(i> -1)
	{
		s_email = s_email.substring(0,i) + 
			s_email.substring((i + 1),s_email.length);
		i = s_email.indexOf(' ',0);
	}
	document.queries.email.value = s_email;
	if((s_email.length <6) ||
	   (s_email.indexOf('@',0) <1) ||
	   (s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||
	   (s_email.lastIndexOf('@') > (s_email.length - 5)) ||
// Because domain name extensions now have varying lengths, 
// the code to check for maximum of 3 characters after the final dot is disabled.
//	   (s_email.lastIndexOf('.') > (s_email.length - 3)) ||
	   (s_email.lastIndexOf('.') < (s_email.length - 4)) ||
	   (s_email.indexOf('..',0)> -1) ||
	   (s_email.indexOf('@.',0)> -1) ||
	   (s_email.indexOf('.@',0)> -1) ||
	   (s_email.indexOf(',',0)> -1))
	{
		alertmessage=alertmessage+'\n'+'The email address is not valid';
//		alert('The email address "' + s_email + '" is not valid.');
		return false;
	}
	return true;
}


/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

//*************************************************
function ValidatePhone(target){
	var Phone=target ;
	
	if ((Phone.value==null)||(Phone.value=="")){
		alertmessage=alertmessage+'\n'+'Please enter your '+target.name+' number';
//		alert("Please Enter your Phone Number");
//		Phone.focus();
		return false;
	}
	if (checkInternationalPhone(Phone.value)==false){
		alertmessage=alertmessage+'\n'+'Please verify '+target.name;
//		alert("Please Enter a Valid Phone Number")
//		Phone.value="";
//		Phone.focus();
		return false;
	}
	return true
 }

//*************************************************
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++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//*************************************************
function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length == minDigitsInIPhoneNumber);
}


//*************************************************
function submitform(){
	document.queries.submit();
}

