//************ Start Default Commands ************
var graphic = "";   
var isNS4 = 0; var isIE4 = 0; var isNS6 = 0; var isNew = 0;
var docObj, styleObj, currObj, cstyleObj;

var bVer = (parseInt(navigator.appVersion));
var bName = navigator.appName;
var brow = ((navigator.appName) + (parseInt(navigator.appVersion)));

if (bName == "Netscape" && bVer >= 3) version = "js";
else if (bName == "Microsoft Internet Explorer" && bVer >= 4) version = "js";
else if (bName == "Netscape" && bVer == 2) version = "no";
else if (bName == "Microsoft Internet Explorer" && bVer >= 2) version = "no";

if (parseInt(navigator.appVersion >= 5)){isNew = 1}
else if (brow == "Netscape4") {isNS4 = 1;}
else if (brow == "Netscape5") {isNS6 = 1;}
else if (brow == "Microsoft Internet Explorer4") {isIE4 = 1;}
				
if (isNS4||isNS6||isIE4||isNew) {
  if(isNS4){ docObj = "document."; }
  else if(isNS6){ docObj = "document.getElementById('"; }
  else { docObj = "document.all."; }

  if(isNS4){ styleObj = ""; }
  else if(isNS6){ styleObj = "').style"; }
  else { styleObj = ".style"; }
  
  if(isNS4){ cstyleObj = ""; }
  else if(isNS6){ cstyleObj = "').currentStyle"; }
  else { cstyleObj = ".currentStyle"; }
}

function getQuery(val){
  var querystring = location.search.substring(1,location.search.length);
  var o = "";
  var tSec = querystring.indexOf(val+"=");
  var tStr = querystring.substring( (tSec+(val.length+1)),querystring.length);
  
  if(tSec != -1){
    if(tStr.indexOf('&') != -1){
      o = tStr.substring(0,tStr.indexOf('&'));
    } else {
      o = tStr;
    }
  }
  return o;
}

function replaceSubstring(s,f,w){
  rtn = "";
  flg = 0;
  
  for(i = 0; i < s.length; i++){
    if(s.substr(i,f.length) == f){
      rtn += w;
      i += (f.length - 1);
    } else {
      rtn += s.charAt(i);
    }
  }
  
  return (rtn);
}

function urlencode(str) {
  str = escape(str);
  str = str.replace('+', '%2B');
  str = str.replace('%20', '+');
  str = str.replace('*', '%2A');
  str = str.replace('/', '%2F');
  str = str.replace('@', '%40');
  return str;
}

function testAlphaPassword(f,d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  var ele = doc.elements[f];
  var str = false;

  if(ele.value == ""){
    alert("Please enter a password");
  } else {
    if(/[^a-zA-z0-9]/i.test(ele.value)){
      alert("Sorry, your password may only contain letters and numbers");
    } else {
      str = true;
    }
  }

  return str;
}

function openPopup(URL,id,width,height){
  window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=yes");
}

function openPopupLocked(URL,id,width,height){
  window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=no");
}

function goPage(u){
  location.href = u;
}

function updatePage(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];

  doc.submit();
}

function displayChange(l,v) {
  if (isNS4||isNS6||isIE4||isNew) { eval(docObj + l + styleObj + '.display = "' + v + '"') }
}

function clearText(f,t,d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  var ele = doc.elements[f].value;

  if(ele == t){
    doc.elements[f].value = "";
  }
}

function addText(f,t,d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  var ele = doc.elements[f].value;

  if(ele == ""){
    doc.elements[f].value = t;
  }
}
//************ End Default Commands ************

function updateTab(rid,str){
  if(document.getElementById(rid)){
    var ele = document.getElementById(rid);

    if(ele.className == ""){
      ele.className = str;
    } else {
      ele.className = "";
    }
  }
}

function updateSubTabs(rid,n,str){
  for(i=0; i < (n*1); i++){
    if(document.getElementById("profile_data_" + (i+1) + "_tab")){
      var ele = document.getElementById("profile_data_" + (i+1) + "_tab");
      if((i+1) == rid){
        ele.className = str;
      } else {
        ele.className = "";
      }
    }
  }
}

function validateCancel(d){
  var doc = document.forms[d];

  if(doc.elements['data_reason'].value.length > 0){
    doc.elements['action'].value = "sendcancelmessage";
    return true;
  } else {
    alert("Please enter a reason for cancelling your account with facefitter.com");
    return false;
  }
}

function validateStatus(d){
  var doc = document.forms[d];
  doc.elements['action'].value = "upd4t35t4tus";
  return true;
}

//-->