function move2next_3(fielda, fieldb) {
  if (fielda.value.length == 3)
		fieldb.focus();
}

function checkForm()
    {
        var temp;
        var re;
// added by Cristine for sub id
var urlString = new String();
urlString = location.search;
var key = new String();
var value = new String();

newString = urlString.substr(1, urlString.length);

parameters = newString.split("&");
//document.cchForm.subid.value = parameters[0];
//document.cchForm.rcid.value = parameters[1];

for ( i=0; i < parameters.length; i++ ) {
  pair = parameters[i].split("=");
  key = pair[0];
  value = pair[1];

  if (pair[0] == 'subid') {
      document.cchForm.subid.value = pair[1];
  }
  if (pair[0] == 'refid') {
      document.cchForm.rcid.value  = pair[1];
  }

  }


        if (document.cchForm.first_name.value == "") {
            alert("First Name field is empty!");
      		document.cchForm.first_name.focus();
           return false;
        } else if (checkrepeat(document.cchForm.first_name.value, 2)) {
            alert("First Name field conatins repetitive characters.");
      		document.cchForm.first_name.focus();
            return false;
        } else if (document.cchForm.first_name.value.search(/\d+/)!= -1) {
            alert("First Name may not contain any numbers.");
      		document.cchForm.first_name.focus();
            return false;
        }

        if (document.cchForm.home_phone1.value == ""
            || document.cchForm.home_phone2.value == ""
            || document.cchForm.home_phone3.value == "")
        {
            alert("Home Phone field is empty!");
      		document.cchForm.home_phone1.focus();
            return false;
        } else {
            temp = document.cchForm.home_phone1.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("Home Phone format error!");
      		document.cchForm.home_phone1.focus();
                return false;
            }
            temp = document.cchForm.home_phone2.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("Home Phone format error!");
      		document.cchForm.home_phone2.focus();
                return false;
            }
            temp = document.cchForm.home_phone3.value;
            if (temp.search(/^[0-9]{4}$/) == -1) {
                alert("Home Phone format error!");
      		document.cchForm.home_phone3.focus();
                return false;
            }
            document.cchForm.home_phone.value = document.cchForm.home_phone1.value + document.cchForm.home_phone2.value + document.cchForm.home_phone3.value;
            if (checkrepeat(document.cchForm.home_phone.value, 5)) {
            	alert("Home Phone conatins repetitive characters.");
      		document.cchForm.home_phone1.focus();
            	return false;
            }
        }





        if (document.cchForm.last_name.value == "") {
            alert("Last Name field is empty!");
            return false;
        } else if (checkrepeat(document.cchForm.last_name.value, 2)) {
            alert("Last Name field conatins repetitive characters.");
            return false;
        }  else if (document.cchForm.last_name.value.search(/\d+/)!= -1) {
            alert("Last Name may not contain any numbers.");
            return false;
        }


        if (document.cchForm.work_phone1.value == ""
            || document.cchForm.work_phone2.value == ""
            || document.cchForm.work_phone3.value == "")
        {

        } else {
            temp = document.cchForm.work_phone1.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("work Phone format error!");
                return false;
            }
            temp = document.cchForm.work_phone2.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("work Phone format error!");
                return false;
            }
            temp = document.cchForm.work_phone3.value;
            if (temp.search(/^[0-9]{4}$/) == -1) {
                alert("work Phone format error!");
                return false;
            }
            document.cchForm.work_phone.value = document.cchForm.work_phone1.value + document.cchForm.work_phone2.value + document.cchForm.work_phone3.value;
            if (checkrepeat(document.cchForm.work_phone.value, 5)) {
            	alert("work Phone conatins repetitive characters.");
            	return false;
            }
        }


        if (document.cchForm.email_address.value == "") {
            alert("Email field is empty!");
            return false;
        } else {
        	document.cchForm.email_address.value = trim(document.cchForm.email_address.value);
            temp = document.cchForm.email_address.value;
            if (temp.search(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/i) == -1) {
                alert("Email format error!");
                return false;
            }
        }


		if (document.cchForm.field_1.value == "") {
            alert("Please enter your total debt!");
            return false;
        }

        if (document.cchForm.state.value == "") {
            alert("Please select your state!");
            return false;
        }

        if (document.cchForm.include_in_market.checked) {
            document.cchForm.include_in_market.value = 'Y';
        }

        return true;
    }
function trim(str) {
  return str.replace(/^\s+|\s+$/g,"");
}
function checkrepeat(str, n) {
	for (var i = 0; i < str.length; i++) {
	  var j = 0;
	  for (j; j < n; j++) {
	    if(!(str.charAt(i)==str.charAt(i+j+1)))
	      break;
	  }
	  if (j == n) return true;
	}
	return false;
}
function poptastic(type, url) {
if (type == 'disclaimer'){
  newwindow=window.open(url,'disclaimer','height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
}  else {
  newwindow=window.open(url,'customer','height=375,width=475,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no');
}
  if (window.focus) {newwindow.focus()}
}

// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005, 24th August 2008
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
function pw() {return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth}; function mouseX(evt) {return evt.clientX ? evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) : evt.pageX;} function mouseY(evt) {return evt.clientY ? evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop) : evt.pageY} function popUp(evt,oi) {if (document.getElementById) {var wp = pw(); dm = document.getElementById(oi); ds = dm.style; st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else {tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; lv += 'px';tv += 'px';  ds.left = lv; ds.top = tv; ds.visibility = "visible";}}}
