if (typeof(loaded) == "undefined") {

  var loaded = true; 

  function isEmpty (elm) {
     return (elm.value.replace(/^ */,"") == "")
  }



	// Extend the string functionality
	//
	String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
	}
	String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
	}
	String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
	}


  function TrimText(obj) { 
     obj.value = obj.value.trim();
  } 
  
  
  
  
  var privacyNameOffset = 0
  
  function SetPrivacyOption(rb,lbl,enable,txt) {
     rb.disabled  = !enable;
     if (!enable)
        rb.checked = false;
     lbl.disabled = !enable;
     lbl.innerHTML = txt;
  }

  function InitPrivacyName(objFirstName) {
     form = document.forms[0];
     offset=0;
     i=0;
     while (i < form.elements.length && offset == 0) {
        if (form.elements[i].id == objFirstName)
           offset = i; 
        i++;
     }
     privacyNameOffset = offset 
     lbl1 = document.forms[0].elements[privacyNameOffset+4].nextSibling;
     lbl2 = document.forms[0].elements[privacyNameOffset+5].nextSibling;
     lbl3 = document.forms[0].elements[privacyNameOffset+7].nextSibling;
     lbl4 = document.forms[0].elements[privacyNameOffset+8].nextSibling;
     lbl5 = document.forms[0].elements[privacyNameOffset+6].nextSibling;
     
     lbl1.defaulttext = lbl1.innerHTML;
     lbl2.defaulttext = lbl2.innerHTML;
     lbl3.defaulttext = lbl3.innerHTML;
     lbl4.defaulttext = lbl4.innerHTML;
     lbl5.defaulttext = lbl5.innerHTML;
  }


  function UpdatePrivacyName() {
     txt1 = document.forms[0].elements[privacyNameOffset+0];
     txt2 = document.forms[0].elements[privacyNameOffset+1];
     txt3 = document.forms[0].elements[privacyNameOffset+2];
     txt4 = document.forms[0].elements[privacyNameOffset+3];

     rb1 = document.forms[0].elements[privacyNameOffset+4];
     rb2 = document.forms[0].elements[privacyNameOffset+5];
     rb3 = document.forms[0].elements[privacyNameOffset+7];
     rb4 = document.forms[0].elements[privacyNameOffset+8];
     rb5 = document.forms[0].elements[privacyNameOffset+6];

     lbl1 = rb1.nextSibling;
     lbl2 = rb2.nextSibling;
     lbl3 = rb3.nextSibling;
     lbl4 = rb4.nextSibling;
     lbl5 = rb5.nextSibling;


     if (!isEmpty(txt1))
        SetPrivacyOption(rb3,lbl3,true,txt1.value)
     else
        SetPrivacyOption(rb3,lbl3,false,lbl3.defaulttext)
     
     if (!isEmpty(txt1) && !isEmpty(txt3)) {
        if (!isEmpty(txt2)) {
          SetPrivacyOption(rb1,lbl1,true,txt1.value+' '+txt2.value+' '+txt3.value)
          SetPrivacyOption(rb2,lbl2,true,txt1.value+' '+txt2.value+' '+txt3.value.substr(0,1)+'.')
          SetPrivacyOption(rb5,lbl5,true,txt3.value+' '+txt2.value+' '+txt1.value)
        }
        else
        {
          SetPrivacyOption(rb1,lbl1,true,txt1.value+' '+txt3.value)
        SetPrivacyOption(rb2,lbl2,true,txt1.value+' '+txt3.value.substr(0,1)+'.')
        SetPrivacyOption(rb5,lbl5,true,txt3.value+' '+txt1.value)
        }
     }
     else {
        SetPrivacyOption(rb1,lbl1,false,lbl1.defaulttext)
        SetPrivacyOption(rb2,lbl2,false,lbl2.defaulttext)
        SetPrivacyOption(rb5,lbl5,false,lbl5.defaulttext)
     }
     
     
     
     if (!isEmpty(txt4))
        SetPrivacyOption(rb4,lbl4,true,txt4.value)
     else
        SetPrivacyOption(rb4,lbl4,false,lbl4.defaulttext)
  }

}


function cancelOnKeyPress()
{
	// process only the Enter key
    if (event.keyCode == 13)
    {
        // cancel the default submit
        event.returnValue	=	false;
        event.cancel		=	true;

    }
}


function agreeTermsAndConditions(chkbox,btnRegister) {
	var obj = document.getElementById(btnRegister);
	if(!chkbox.checked) {
	 obj.disabled  = true;
	} 
	else {
	 obj.disabled  = false;
	}
	
}


