//  profile_editprofile.php- Basic tab   javascript************************//

function textCounter(field, countfield, maxlimit) 
{
  if (field.value.length >= maxlimit)
  {
    alert("Please limit your message to "+maxlimit+" chars");
    return false;
  }
  if (field.value.length > maxlimit) { // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
  }
  else {   // otherwise, update 'characters left' counter
    countfield.value = maxlimit - field.value.length; 
  }
  return true;
}
function enforceLength(field,maxlen)
{
	if (field.value.length > maxlen + 1)
	alert('your input has been truncated!');
	if (field.value.length > maxlen)
	field.value = field.value.substring(0, maxlen);
}

function submit_post(theFrm,maxlen)
{
 if (theFrm.msg.value=="")
  { alert ("Please enter you comments first ");
   theFrm.msg.focus() ; return false;
  } 
  var iChars = ";\"";
  for (var i = 0; i < theFrm.msg.value.length; i++) {
  	if (iChars.indexOf(theFrm.msg.value.charAt(i)) != -1) {
  	alert ("Your Comment has special characters. \nThese are not allowed.\n Please remove them and try again.");
    theFrm.msg.focus(); return false;
  	}
  } 
 if (theFrm.msg.value.length < 2)
  {   alert ("Please enter your comments not less than 2 Char");
     theFrm.msg.focus(); return false;
  }
 if (theFrm.msg.length > maxlen)
  {  alert("Please limit your message to "+maxlen+" chars");
  	theFrm.msg.focus() ; return false;
  }
 theFrm.confirmed.value="true";
}

function profileCheck_Bas(theForm)
{
if (theForm.firstName.value=="") {
	alert("Please enter your first name");
	theForm.firstName.focus();
	return false;
}
if (theForm.lastName.value=="") {
	alert("Please enter your last name.");
	theForm.lastName.focus();
	return false;
}
if (theForm.gender.value=="") {
	alert("Please choose right gender option.");
	theForm.gender.focus();
	return false;
}
if (theForm.country.value=="") {
	alert("Please enter your country name.");
	theForm.lastName.focus();
	return false;
}

 if ((theForm.dd[theForm.dd.selectedIndex].value < 1) || (theForm.dd[theForm.dd.selectedIndex].value > 31)){
    alert("Invalid \"Birth Date\" (Day).\n");
    theForm.dd.focus();
    return (false);
  }

  if ((theForm.yyyy[theForm.yyyy.selectedIndex].value < 1899) || (theForm.yyyy[theForm.yyyy.selectedIndex].value > 2001)){
    alert("Invalid \"Birth Date\" (Year).\n");
    theForm.yyyy.focus();
    return (false);
  }

  if ((theForm.dd[theForm.dd.selectedIndex].value > 30) && ((theForm.mmm.selectedIndex == 4) || (theForm.mmm.selectedIndex == 6) || (theForm.mmm.selectedIndex == 9) || (theForm.mmm.selectedIndex == 11))){
    alert("Invalid \"Birth Date\".\n");
    theForm.dd.focus();
    return (false);
  }

  if ((theForm.mmm.selectedIndex == 2) && (theForm.dd[theForm.dd.selectedIndex].value > 28)){
    if ((theForm.yyyy[theForm.yyyy.selectedIndex].value % 4) == 0){
      if (theForm.dd[theForm.dd.selectedIndex].value > 29){
        alert("Invalid \"Birth Date\".\n");
        theForm.dd.focus();
        return (false);
      }
    }else{
      alert("Invalid \"Birth Date\".\n");
      theForm.dd.focus();
      return (false);
    }
  }
  
theForm.confirmed.value="true";
return true;
}

//  profile_editprofile.php-SOCIAL tab   javascript************************//

function profileCheck_Soc(theForm)
{
  // Validation script for field 'MaritalStatus' (MaritalStatus)
  // Validation script for field 'Hangout' (Favourite Hangout)
  if (theForm.Hangout.value == "")
  {
    alert("Please complete the \"Favourite Hangout\" field.");
    theForm.Hangout.focus();
    return false;
  }
  if (theForm.Hangout.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Favourite Hangout\" field.");
    theForm.Hangout.focus();
    return false;
  }
  if (theForm.Hangout.value.length > 200)
  {
    alert("Please enter at most 200 characters in the \"Favourite Hangout\" field.");
    theForm.Hangout.focus();
    return false;
  }
  // Validation script for field 'Drinking' (Drinking)
  // Validation script for field 'PrefLanguage' (Preferred Language)
  // Validation script for field 'TagLine' (Favourite Phrase)
  

  // Validation script for field 'Description' (Message)
  if (theForm.Description.value == "")
  {
    alert("Please complete the \"Message\" field.");
    theForm.Description.focus();
    return false;
  }

  if (theForm.Description.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Message\" field.");
    theForm.Description.focus();
    return false;
  }

  if (theForm.Description.value.length > 255)
  {
    alert("Please enter at most 255 characters in the \"Message\" field.");
    theForm.Description.focus();
    return false;
  }
 
theForm.confirmed.value="true";
return true;
}
//  profile_editprofile.php-personality tab   javascript************************//
function profileCheck_per(theForm)
{
  // Validation script for field 'MaritalStatus' (MaritalStatus)
  // Validation script for field 'Hangout' (Favourite Hangout)
  if (theForm.notice.value == "")
  {
    alert("Please complete the \"notice about me\" field.");
    theForm.notice.focus();
    return false;
  }
  if (theForm.notice.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"notice about me\" field.");
    theForm.notice.focus();
    return false;
  }
  if (theForm.notice.value.length > 180)
  {
    alert("Please enter at most 180 characters in the \"notice about me\" field.");
    theForm.notice.focus();
    return false;
  }

theForm.confirmed.value="true";
return true;
}
