//Start



 function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}



//End



//Start first function

var acePopupWindow=null;



function acePopup(mypage,myname,w,h,pos,infocus){

if(pos=='random'){

LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;

TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}

if(pos=='center'){

LeftPosition=(screen.width)?(screen.width-w)/2:100;

TopPosition=(screen.height)?(screen.height-h)/2:100;}

else if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';

acePopupWindow=window.open('',myname,settings);

if(infocus=='front'){acePopupWindow.focus();acePopupWindow.location='/bmi.html';}

}

// end of first funtion



// Start go functio

function gotofunction()

{

//var node=document.getElementById('pagenode').value;

window.location.href='http://ready4achange.com/contact';

}

//end of go function



//Rajiv



 function trim(str, chars) {

	return ltrim(rtrim(str, chars), chars);

                    }



function ltrim(str, chars) {

	chars = chars || "\\s";

	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");

}



function rtrim(str, chars) {

	chars = chars || "\\s";

	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");

}



//End of Rajiv



//Start



var win= null;

function NewWindow(mypage,myname,w,h,scroll){

var winl = (screen.width-w)/2;

var wint = (screen.height-h)/2;

var settings ='height='+h+',';

settings +='width='+w+',';

settings +='top='+wint+',';

settings +='left='+winl+',';

settings +='scrollbars='+scroll+',';

settings +='resizable=yes';

win=window.open(mypage,myname,settings);

if(parseInt(navigator.appVersion) >= 4){win.window.focus();}

}



function MM_openBrWindow(theURL,winName,features) {

window.open(theURL,winName,features);

}



//End





//Start 



var randNum = 0;

function randNoDups(maxNum)

{

	tmpRand = randNum;

	while (tmpRand == randNum) {

		tmpRand = Math.round(Math.random()*maxNum);

	}

	randNum = tmpRand;

	return tmpRand;

}





  function validate(evt) {

  var theEvent = evt || window.event;

  var key = theEvent.keyCode || theEvent.which;

  key = String.fromCharCode( key );

  var regex = /[0-9]|\./;

  if( !regex.test(key) ) {

    theEvent.returnValue = false;

    theEvent.preventDefault();

  }

}



function ismaxlength(obj){

var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""

if (obj.getAttribute && obj.value.length>mlength)

obj.value=obj.value.substring(0,mlength)

}



function textonly(e){

var code;

if (!e) var e = window.event;

if (e.keyCode) code = e.keyCode;

else if (e.which) code = e.which;

var character = String.fromCharCode(code);

    var AllowRegex  = /^[\ba-zA-Z\s-\.]$/;

    if (AllowRegex.test(character)) return true;

    return false;

}



//End



//Start



function loadVCode() {



	var vCode, strVCode, vCodeLen;

	document.applynow.txt1.value= randNoDups(99999);

	vCode = document.applynow.txt1.value;

	

	vCodeLen = document.applynow.txt1.value.length;

	//alert(vCodeLen);

	strVCode = "";

	for(i=1;i<=vCodeLen;i++) {

		strVCode = strVCode + "<img src='http://ready4achange.com/images/num/" + vCode.substring(i-1,i) + ".gif'>"

	}

	document.getElementById("vCode").innerHTML = strVCode;

	//alert(vCode);

	document.applynow.verifycode.value = ""; 

}



function limitText(limitField, limitCount, limitNum) {

	if (limitField.value.length > limitNum) {

		limitField.value = limitField.value.substring(0, limitNum);

	} else {

		limitCount.value = limitNum - limitField.value.length;

	}

}



//End





//Start



var xmlHttp;

	function chkvalid()

{

		var frm = document.applynow;

		var ph= trim(frm.phone.value,' ');

	

		var msg;

		msg = "";

		var i;

		

		i = 0 ;



		//alert(ph);



		if(cutChars(frm.FullName.value," ") == "")

		{

			i = i + 1;

			msg = "\"FullName\" : Please Enter Full Name \n";

			alert(msg);

			frm.FullName.focus();

			return false;

		}

		else

		{

			if(frm.FullName.value.length > 50)

			{

				i = i + 1;

				msg = msg + "\"FullName\" : Should Not Exceed 50 Characters Length. \n";

				alert(msg);

				frm.FullName.focus();

				return false;

			}

			

			if(!isCharsInBag(frm.FullName.value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "))

			{

				i = i + 1;

				msg = msg + "\"FullName\" : Contains Invalid Characters,Only Alphabets Are Allowed. \n";

				alert(msg);

				frm.FullName.focus();

				return false;

			}





		}

		

		/////////////////////////----------  Phone Validation-------------------------//////////////////////

		/*

if (ph == "")

  {

    alert("Please enter your Phone Number.");

   frm.phone.focus();

    return (false);

  }

 if (ph.length < 10)

  {

    alert("Please enter  minimum 10 characters in the phone field.");

    frm.phone.focus();

    return (false);

  }



 if (ph.length > 11)

  {

    alert("Maximum 11 characters should be in phone number.");

   frm.phone.focus();

    return (false);

  }





   if(!isCharsInBag( frm.phone.value ,"1234567890-() "))

	{

	    alert("Invalid characters in phone number");

	   frm.phone.focus();

        return (false);

	}		

*/



var phoneRegEx = /^\(?[1-9]\d{2}\)?([-., ])?[1-9]\d{2}([-., ])?\d{4}$/;

var str = frm.phone.value;



		if(!str.match(phoneRegEx)){

		

			alert('Please enter a valid phone No. in 111-111-1111 format.');

			frm.phone.value="";

			frm.phone.focus();

			return false;

		}



/////////////////////////----------  Phone Validation-------------------------//////////////////////



//----------------Validate Email------------------------------

var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

var str = frm.email.value;



		if(!str.match(emailRegEx)){

		

			alert('Please enter a valid email address.');

			frm.email.value="";

			frm.email.focus();

			return false;

		}



//---------------End validate Email---------------------------



//-------------------------Validate Sex--------------------



 if (!frm.sex[0].checked && !frm.sex[1].checked){

			alert("Please Select Sex");

			return false;

	}	

	

 if (frm.weight.value==""){

			alert("Please enter weight");

			return false;

	}	

		

	

 if (frm.height.value==""){

			alert("Please Select height");

			return false;

	}	

	

if (frm.area_interest.value==""){

      alert("Please select one of the \"Area of interest\" options.");

    frm.area_interest.focus();

    return (false);

  }	

	

	



	

	

//-------------------------End valid sex------------------









		if(cutChars(frm.email.value," ") == "")

		{

			i = i + 2;

			msg = msg+ "\"Email Id\" : Please Enter Email \n";

			alert(msg);

			frm.email.focus();

			return false;

		}

		else

		{

			if(!validateEmail(frm.email.value))

			{

				

				frm.email.focus();

				return false;

			}

		}

		

		

		

cutChars(frm.comments.value," ")
		

	if(frm.verifycode.value=='')

	{

	   alert("Please enter the shown Verification Code");

	   frm.verifycode.focus();

	   return false;

	}

		if(frm.verifycode.value!=frm.txt1.value)

	{

		alert("Invalid Verification Code");

		frm.verifycode.value="";

		frm.verifycode.focus();

		return false;

		

	}

		/* if(cutChars(frm.capatcha.value," ") == "")

		{

			i = i + 4;

			msg = "\"Capatcha\" : Please Enter Capatcha \n";

			alert(msg);

			frm.capatcha.focus();

			return false;

		}

		*/

		if(cutChars(frm.textfield2.value," ") == "")

		{

			i = i + 3;

			msg = i + ") \"Phone\" : Please Enter Phone Number \n";

			alert(msg);

			frm.phone.focus();

			return false;

		}



		else

		{

		

			if(frm.textfield2.value.length > 50)

			{

				i = i + 3;

				msg = msg + i + ") \"Phone Number\" : Should Not Exceed 50 Characters Length. \n";

				alert(msg);

				frm.phone.focus();

				return false;

			}



			

			if(!isCharsInBag(frm.textfield2.value,"1234567890-+()"))

			{

				i = 3;

				msg = msg + i + ") \"Phone Number\" : Contains Invalid Characters. \n";

				alert(msg);

				frm.phone.focus();

				return false;

			}

		}	



		/*if(cutChars(frm.drpdiscipline.selectedIndex," ") == "")

		{

			i = i + 4;

			msg = i + ") \"Discipline\" : Please Select Discipline. \n";

			alert(msg);

			frm.drpdiscipline.focus();

			return false;

		} */

		

return true;

}

	function cutChars(s, c)

		{

			var s1, x;

			x = s1 = "";

			l = s.length;

			for(i = 0; i < l; i++)

				if((x = s.charAt(i)) != c)

					s1+=x;

			return s1;

		}

		function isCharsInBag (s, bag)

		{  

			var i;

			for (i = 0; i < s.length; i++)

			{   

		       

				var c = s.charAt(i);

				if (bag.indexOf(c) == -1) return false;

			}

			return true;

		}

		function validateEmail(emailid)

		{

			if (emailid.charAt(0) == ' ')

			{

			alert("Email cannot have spaces");

			return false;

			}

			emailid = cutChars(emailid, " ");

			if(cutChars(emailid, ' ') == '')

			{

				return true;

			}

			at = emailid.indexOf("@");

			if(at <= -1) //one @ shd be there, not as the 1st char tho'

			{

				alert("Invlaid Emailid - no @");

				return false;

			}

			at1 = emailid.indexOf("@", at + 1);

			if(at1 != -1) //only one @ shd be there

			{

				alert("Invlaid Emailid - only one @");

				return false;

			}

			dot = emailid.indexOf(".", at + 1);

			if(dot - at < 2) //. shd be present, with atleast 1 char after @

			{

				alert("Invlaid Emailid - @.");

				return false;

			}

			if(emailid.indexOf(".@") != -1) //. shd not be just b4 @

			{

				alert("Invlaid Emailid - .@");

				return false;

			}

			if(emailid.indexOf("..") != -1)

			{

				alert("Invlaid Emailid - ..");

				return false;

			}

			if(emailid.charAt(emailid.length - 1) == "." || emailid.charAt(emailid.length - 2) == ".")

			{

				alert("Invlaid Emailid - last two chars");

				return false;

			}

			return true;

		}



//End



//Start



var tooltipObj = new DHTMLgoodies_formTooltip();

tooltipObj.setTooltipPosition('right');

tooltipObj.setPageBgColor('#EEEEEE');

tooltipObj.setTooltipCornerSize(15);

tooltipObj.initFormFieldTooltip();



// End JavaScript Document