debugMode = false;
requesterName = "www.aussieconcretepumping.com.au support"; // 
var PathTo='index.php';
var min_pwd_length = 4;
var lng;

var errMsgs = new Array();
errMsgs[1] = "Error! Please fill in all the required fields: ";

var el_first;

var elTitles = new Array();
elTitles["login"] = "Username";
elTitles["pwd"] = "Password";
elTitles["pwdconf"] = "Password Confirmation";
elTitles["firstName"] = "First Name";
elTitles["lastName"] = "Last Name";
elTitles["city"] = "City/Town";
elTitles["suburb"] = "Suburb";
elTitles["strAddress1"] = "Street Address";
elTitles["phoneBusiness"] = "Business Phone Number";
elTitles["email"] = "Email Address";
elTitles["region"] = "Country (region)";
elTitles["state"] = "State";
elTitles["bus_region"] = "Business Country (region)";
elTitles["bus_state"] = "Business State";
var timeout2 = null;
//elTitles[""] = "";

//


/*
*/
var of = document.form1;
var scr=window.screen;
function init() {
	var of = document.form1;
}

function focusEmpty(of)
{
	var empty_el_arr = new Array();
	var ee_count = 0;
	var found = false;
//	var el_first = null;
	el_first = null;
//	alert(of.elements.length);
	for (var i = 0; i < of.elements.length; i++)
	{
		 el=of.elements[i];
		 elID=of.elements[i].id;
		 
		 if (elID.substr(elID.length-1,1) == "_")
			{
				/*
		 	if (elID.indexOf("hild") >-1) {
				//alert(elID);
				el_value(el);
			}*/
				var elValue = el_value(el);
				if (elValue == false || elValue == '') {
//		 		alert(elID+'"'+elValue+'"');
					//				if (empty(elValue) && elValue != 0) {

//						el.focus();
						found = true;
						if (el_first==null) el_first = el;
						empty_el_arr[ee_count] = el.name;
						ee_count = ee_count + 1;
						
//						return 0;
				} else {
					el.className = '';
				}
			}
	}
	
	if (found == true) {
//		var recipient_cell = document.getElementByID("err_reporter_cell");
//		if (recipient_cell != null) recipient_cell.style.visibility = '';

		var recipient = document.getElementById('err_reporter');

		if (recipient) {
			var list = '';

//			for (ee_el in empty_el_arr) {
		for (var i = 0; i < empty_el_arr.length; i++) {
				if (elTitles[empty_el_arr[i]])
				list = list + (elTitles[empty_el_arr[i]] || empty_el_arr[i]) + ', ';
				}
				
			if (list != '')	recipient.innerHTML = shellErrMsg(errMsgs[1]) + list.substr(0, list.length-2) + '<br><br>';
			}
//		var top_anchor = document.getElementByID["top_a"];
			/*
		*/
		var anchor_to = '#top_a';
		var new_loc = location.href;
		if (new_loc.indexOf(anchor_to)<=0) {
			new_loc = new_loc + anchor_to;
		}
		window.location.href = new_loc;
//		window.navigate('#top_a');
		if (el_first.style) el_first.className = "input_hl";
		
        if (timeout2) clearTimeout(timeout2);
		timeout2 = setTimeout("el_first.focus();", 400);
//		el_first.focus();
//		termedFocus();
		
//		recipient.innerHTML = errMsgs[0];
			
		return 0;
	}
	return 1;
}

function shellErrMsg(msg) {
		return '<span style="color:#777777">' + msg + '</span>';
}


/*
function termedFocus() {
        if (timeout) clearTimeout(timeout);
//        timeout = setTimeout(doFocus, 2000, obj);
		el_first.focus();
    }

function doFocus(obj) {
		obj.focus()
}
*/

/*
function focusEmpty(of)
{
	for (var i = 0; i < of.elements.length; i++)
	{
		 el=of.elements[i];
		 elID=of.elements[i].id;
		 if (elID.substr(elID.length-1,1) == "_")
			{
				if (el.value=='') {
						el.focus();
						found=true;
						return 0;
				}
			}
	}
	return 1;
}
*/

function onSubmit(obj)
{
	var of = obj.form;
//                if (of.Email.value==of.Email.defaultValue) {of.Email.value='';}
	if (focusEmpty(of)==1)
			{
					of.submit();
					return true;
			}
			return false;
}

function onSubmit_a(form)
{
	var of = document.forms[form];
	if (focusEmpty(of)==1) return  of.submit();
	return false;		
}


function onCancel() {
                window.location.href = PathTo;
}

function checkEmail(obj)
{
			var oEmail = obj.form.email;
			var email = oEmail.value;
//			var err_msg = "Incorrect email format! Please reenter";
			if (lng!='ru') {err_msg = "Incorrect email format! Please reenter";} else {err_msg = "E-mail èìååò íåâåðíûé ôîðìàò! Ïîâòîðèòå ïîæàëóéñòà ââîä";}
			if (oEmail.value)
			  {
				var parts = email.split("@");

				if ((parts.length!=2) || (!parts[0]) || (!parts[1]))
					{
					  alert(err_msg);
					  oEmail.focus();
					  return false;
					}
					else
					{
//					  alert("mailbox:"+parts[0]+"  domain:"+parts[1]+parts.length);
					  var domain_parts = parts[1].split(".");
					  if (domain_parts.length < 2) 
					    {
						  alert(err_msg);
						  oEmail.focus();
						  return false;
						}
					  return true;
//					  alert("domain-name:"+domain_parts[0]+"  zone:"+domain_parts[1]);
					}
			  }else{return true;}
}



function checkPwd(obj)
{
			var oPwd = obj.form.pwd;
			var oPwdconf = obj.form.pwdconf;
			var pwd = oPwd.value;
//			var login = obj.form.login;
			if ((pwd!=''))
			  {
				if (pwd.length < min_pwd_length)
					{
						  alert("Password length less than "+min_pwd_length+" characters! Please enter longer password");
						  oPwd.focus();
						  return false;
					}
					else
					{
						if (pwd!=oPwdconf.value)
						{
							  alert("Password and password confirmation aren`t equal! Please enter identical passwords");
							  oPwd.focus();
							  return false;
						}else{return true;}
					}
			  }else{return true;}

}




function doReset() {
	form1.reset();
	init();
}



var rusChars = new Array('à','á','â','ã','ä','å','¸','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ý','þ','ÿ','û','ú','ü',  'º', '³', '¿');
var transChars = new Array('a','b','v','g','d','e','yo','zh','z','i','y','k','l','m','n','o','p','r','s','t','u','f','kh','ts','ch','sh','shch','e','yu','ya','y','','','ye','i','yi');
//	
function convert(from) {
	if (empty(from)) return;
	from = from.toLowerCase();
	var to = "";
	var len = from.length;
	var character, isRus;
	for(i=0; i < len; i++) {
		character = from.charAt(i,1);
		isRus = false;
		j = array_search(character, rusChars);
		if (j>-1) isRus = true;
		/*
		for(j=0; j < rusChars.length; j++)
		  {
		  if(character == rusChars[j])
			{
			isRus = true;
			break;
			}
		  }
		  */
		to += (isRus) ? transChars[j] : character;
	}
	return to;
}

function str2tid(str) {
	if (str == '') return false;
	str = str.replace(/\s{1,}/gi, "_");
	str = convert(str);
	str = str.replace(/[^a-zA-Z0-9_]/gi, "");
//	alert(str);
	return str;
}


