

var bubbleovercolor = "#6699FF";
var bubblebasecolor = "#A9A9A9";
var bubblebasedarkcolor = "#0033CC";
function bubblechange(bubble,color){
  var bubbleel = document.getElementById(bubble);
  var el1 = bubbleel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el1.style.background = color;
  el2.style.background = color;
  el3.style.background = color;
  el4.style.background = color;
  el5.style.background = color;
  el6.style.background = color;
  el7.style.background = color;
  el8.style.background = color;
  el9.style.background = color;
}

var downarrowovercolor= "#FF0000";
var downarrowbasecolor = "#A9A9A9";
var downarrowbasedarkcolor = "#0033CC";
function downarrowchange(downarrow,color){
  var downarrowel = document.getElementById(downarrow);
  var el1 = downarrowel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el1.style.background = color;
  el2.style.background = color;
  el3.style.background = color;
  el4.style.background = color;
  el5.style.background = color;
  el6.style.background = color;
  el7.style.background = color;
  el8.style.background = color;
  el9.style.background = color;
}

var uparrowovercolor= "#008000";
var uparrowbasecolor = "#A9A9A9";
var uparrowbasedarkcolor = "#0033CC";
function uparrowchange(uparrow,color){
  var uparrowel = document.getElementById(uparrow);
  var el1 = uparrowel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el1.style.background = color;
  el2.style.background = color;
  el3.style.background = color;
  el4.style.background = color;
  el5.style.background = color;
  el6.style.background = color;
  el7.style.background = color;
  el8.style.background = color;
  el9.style.background = color;
}

var starovercolor = "#00FF00";
var starbasecolor = "#A9A9A9";
var starbasedarkcolor = "#DAA520";
var staralreadyvotedcolor = "#8B5A00";
function starload(id,rating){
  for(var i=1;i<=5;i++){
    if(i<=rating){
      starchange('star'+i+'_'+id,starbasedarkcolor);
    } else {
      starchange('star'+i+'_'+id,starbasecolor);
    }
  }
}
function stardonekeepon(el,id,rating,tot){
  document.getElementById("starsnumber"+id).innerHTML = tot+" votes";
  var starname = '';
  for(var i=1;i<=rating;i++){
    starname = 'star'+i+'_'+id;
    starchange(starname,starbasecolor); //staralreadyvotedcolor
  }
}
function stardone(el,id,rating,tot){
  var starel = document.getElementById(el);
  starel.innerHTML = "<div id=\"stars"+id+"\" class=\"stars\"><div id=\"star1_"+id+"\" class=\"star\"><em class=\"s1\"></em><em  class=\"s2\"></em><em class=\"s3\"></em><em class=\"s4\"></em><em class=\"s5\"></em><em class=\"s6\"></em><em class=\"s7\"></em><em class=\"s8\"></em><em class=\"s9\"></em></div><div  id=\"star2_"+id+"\" class=\"star\"><em class=\"s1\"></em><em class=\"s2\"></em><em  class=\"s3\"></em><em class=\"s4\"></em><em class=\"s5\"></em><em  class=\"s6\"></em><em class=\"s7\"></em><em class=\"s8\"></em><em class=\"s9\"></em></div><div id=\"star3_"+id+"\" class=\"star\"><em class=\"s1\"></em><em  class=\"s2\"></em><em class=\"s3\"></em><em class=\"s4\"></em><em class=\"s5\"></em><em class=\"s6\"></em><em class=\"s7\"></em><em class=\"s8\"></em><em  class=\"s9\"></em></div><div id=\"star4_"+id+"\" class=\"star\"><em class=\"s1\"></em><em class=\"s2\"></em><em class=\"s3\"></em><em class=\"s4\"></em><em class=\"s5\"></em><em class=\"s6\"></em><em class=\"s7\"></em><em class=\"s8\"></em><em class=\"s9\"></em></div><div id=\"star5_"+id+"\" class=\"star\"><em class=\"s1\"></em><em class=\"s2\"></em><em class=\"s3\"></em><em class=\"s4\"></em><em class=\"s5\"></em><em class=\"s6\"></em><em class=\"s7\"></em><em class=\"s8\"></em><em class=\"s9\"></em></div></div><center><div class=\"starsnumber\" id=\"starsnumber"+id+"\">&nbsp;&nbsp;"+tot+" votes</div></center>";
  var starname = '';
  for(var i=1;i<=rating;i++){
    starname = 'star'+i+'_'+id;
    starchange(starname,staralreadyvotedcolor); //staralreadyvotedcolor
  }
}
function starchange(star,color){
  var starel = document.getElementById(star);
  var el1 = starel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el7.style.borderLeft = "3px solid " + color;
  el7.style.borderRight = "3px solid " + color;
  el8.style.borderLeft = "2px solid " + color;
  el8.style.borderRight = "2px solid " + color;
  el9.style.borderLeft = "2px solid " + color;
  el9.style.borderRight = "2px solid " + color;
  el1.style.background = color;
  el2.style.background = color;
  el3.style.background = color;
  el4.style.background = color;
  el5.style.background = color;
  el6.style.background = color;
  }
function arrowdonekeepon(el,id,rating){
  document.getElementById("downarrowrating"+id).innerHTML = rating;
}
function arrowdone(el,id,rating){
  var starel = document.getElementById(el);
  starel.innerHTML = "<span class=\"downarrowwrap\" id=\"downarrowwrap"+id+"\"><div id=\"downarrow1_"+id+"\" class=\"downarrow\"><em class=\"daF1\"></em><em class=\"daF2\"></em><em class=\"daF3\"></em><em class=\"daF4\"></em><em class=\"daF5\"></em><em class=\"daF6\"></em><em class=\"daF7\"></em><em class=\"daF8\"></em><em class=\"daF9\"></em><span id=\"downarrowrating"+id+"\">"+rating+"</span></div></span>";
}
function setNewPopLink(cur){
  document.getElementById("Popular").childNodes[0].href = "/" + cur + "/";
  document.getElementById("New").childNodes[0].href = "/" + cur + "/new/";
}
function setMainLinks(){
  val = "";
  if(document.getElementById("New").className == "activemenuplain"){
    val = "new/";
  }
  document.getElementById("home").childNodes[0].href = document.getElementById("home").childNodes[0].href + val;
  document.getElementById("news").childNodes[0].href = document.getElementById("news").childNodes[0].href + val;
  document.getElementById("opinion").childNodes[0].href = document.getElementById("opinion").childNodes[0].href + val;
  document.getElementById("scoop").childNodes[0].href = document.getElementById("scoop").childNodes[0].href + val;
  document.getElementById("tabloid").childNodes[0].href = document.getElementById("tabloid").childNodes[0].href + val;
  document.getElementById("review").childNodes[0].href = document.getElementById("review").childNodes[0].href + val;
}
function setMenuClean(){
  if(document.getElementById("home")) document.getElementById("home").className = "lihome";
  if(document.getElementById("news")) document.getElementById("news").className = "linews";
  if(document.getElementById("opinion")) document.getElementById("opinion").className = "liopinion";
  if(document.getElementById("scoop")) document.getElementById("scoop").className = "liscoop";
  if(document.getElementById("tabloid")) document.getElementById("tabloid").className = "litabloid";
  if(document.getElementById("review")) document.getElementById("review").className = "lireview";
}
function toggleNewPop(offon){
  /*if(offon=="on"){
    document.getElementById("Popular").style.visibility = "visible";
    document.getElementById("New").style.visibility = "visible";
  } else {
    document.getElementById("Popular").style.visibility = "hidden";
    document.getElementById("New").style.visibility = "hidden";
  }*/
}
function setMenuActive(){
/*
  //var menupop = document.getElementById("Popular");
  //var menunew = document.getElementById("New");
  //menupop.className = "menuplain";
  //menunew.className = "menuplain";
  document.getElementById("home").className = "lihome";
  document.getElementById("news").className = "linews";
  document.getElementById("opinion").className = "liopinion";
  document.getElementById("scoop").className = "liscoop";
  document.getElementById("tabloid").className = "litabloid";
  document.getElementById("review").className = "lireview";
  var url = String(document.location).split('/');
  if(url[3] == "new"){
    //menupop.className = "menuplain";
    //menunew.className = "activemenuplain";
    setMainLinks();
  } else {
    //menupop.className = "activemenuplain";
    //menunew.className = "menuplain";
    setMainLinks();
  }
  if(url[3] != "" && url[3] != "all" && url[3] != "new" && url[3] != "pop"){
    document.getElementById(url[3]).className = "activelink";
    if(url[4] == "new"){
      //menupop.className = "menuplain";
      //menunew.className = "activemenuplain";
      setMainLinks();
    } else {
      //menupop.className = "activemenuplain";
      //menunew.className = "menuplain";
      setMainLinks();
    }
    //setNewPopLink(url[3]);
  } else {
    document.getElementById("home").className = "activelink";
  }
*/
}
/* global */
function parseUri(sourceUri){
    var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
    var uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);
    var uri = {};
    for(var i = 0; i < 10; i++){
        uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
    }
    if(uri.directoryPath.length > 0){
        uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
    }
    
    return uri;
}
function GetArticleType(name){
  result = -1;
  if(document.getElementById("exampleTypeText").innerHTML == "news"){ result = 1; }
  else if(document.getElementById("exampleTypeText").innerHTML == "scoop"){ result = 2; }
  else if(document.getElementById("exampleTypeText").innerHTML == "tabloid"){ result = 3; }
  else if(document.getElementById("exampleTypeText").innerHTML == "review"){ result = 4; }
  else if(document.getElementById("exampleTypeText").innerHTML == "opinion"){ result = 5; }
  return(result);
}
function FindArticleType(str){
  result = '';
  if(str.match('news') != null){ result = 'news'; }
  else if(str.match('tabloid') != null){ result = 'tabloid'; }
  else if(str.match('scoop') != null){ result = 'scoop'; }
  else if(str.match('opinion') != null){ result = 'opinion'; }
  else if(str.match('review') != null){ result = 'review'; }
  return(result); 
}
function FindColorByType(str){
  result = ''; 
  if(str == 'news'){ result = 'D3D3D3'; }
  else if(str == 'tabloid'){ result = '90EE90'; }
  else if(str == 'scoop'){ result = 'F08080'; }
  else if(str == 'opinion'){ result = 'FAFAD2'; }
  else if(str == 'review'){ result = '87CEFA'; }
  return(result); 
}
function DisableEnableForm(xForm,xHow){
  objElems = xForm.elements;
  for(i=0;i<objElems.length;i++){
    objElems[i].disabled = xHow;
  }
}
function convertText_TBtoDB(t){
    var result = t.replace(/\r?\n|\r/g,'<br>');
    return(result);
  }
function stripCRLF(t){
  var result = t.replace(/\r?\n|\r/g,'');
  return(result);
}
function stripBR(t){
  var result = t.replace('<br>','');
  return(result);
}
/* end global */
/* add picture */

/* end add picture */
/* comments */
function PostCommentDB(textareaRef,pid,table,reviewID,ad,cache){
  $.get("/clearcachefile.php", { pn: cache } );
  
  DisableEnableForm(document.formSubmitComment,true);
  var oktogo = true;
    
  document.getElementById('lblValidateComment').style.visibility = "hidden";
  if(document.getElementById('taInput').value == ""){
    document.getElementById('lblValidateComment').innerHTML = "* enter a comment";
    document.getElementById('lblValidateComment').style.visibility = "visible";
    oktogo = false;
  }
  
  if(ad==1){
    var indexpid = document.getElementById("user").selectedIndex;
    var newpid = document.getElementById("user")[indexpid].value;
    if(newpid!=-1){pid=newpid;}
  }

  if(oktogo == true){
    var validatedCom = validateCom(textareaRef.value);
    if(validatedCom != "-1"){
      var textForDB = convertText_TBtoDB(validatedCom);
      var tbComment = textForDB;
      document.getElementById("commentNotify").innerHTML = "Processing...";
      $("#commentNotify").fadeIn("fast", function(){
        $.get("lib/calculations.php", { action: "postcomment", id: pid, tbComment: tbComment, reviewID: reviewID, table: table}, function(data){
          results = data.split("|");
          document.getElementById("commentNotify").innerHTML = "";
          $("#commentNotify").fadeIn("commentNotify");
            if(results[0] == 'good'){
              document.getElementById('nocoms').innerHTML = '';
              document.getElementById('lblResults').innerHTML = 'Comment Posted';
              location.replace(window.location.href);
            }
	    });
     });               
    } 
  } else {
    DisableEnableForm(document.formSubmitComment,false);  
  }
}
function editcomtext(id,table,revid,page){
  turnOffHeaderEditLink('com-head-right-edit-'+id);
  StartEditComment(id,table,revid,page);
}
function turnOffHeaderEditLink(id){
  document.getElementById(id).innerHTML = "";
}
function turnOnHeaderEditLink(id,revid,page){
  document.getElementById('com-head-right-edit-'+id).innerHTML = "<a href=\"javascript:editcomtext('"+id+"','"+revid+"','"+page+"');\">edit</a>";
}
function StartEditComment(id,table,reviewid,page){
  $("#com-text-inside-"+id).fadeOut("slow", function(){
    var origHTMLText = document.getElementById('com-text-inside-'+id).innerHTML;
    var numberOfCRLF = getNumberOfCRLFfromHTML(origHTMLText);
    var holdcurtext = convertText_HTMLtoTB(origHTMLText);
    var charCount = holdcurtext.length;
    var rows = (charCount/60 + 1) + numberOfCRLF + "";
    document.getElementById('com-text-inside-'+id).innerHTML = "<form id=\"formCommentEdit"+id+"\" name=\"formCommentEdit"+id+"\" action=\"javascript:saveEdit('"+id+"','"+table+"','"+reviewid+"','"+page+"');\" method=\"POST\"><table><tr><td><textarea id=\"edit"+id+"\" rows=\""+rows+"\" cols=\"65\">"+holdcurtext+"</textarea><span style=\"display:none;\" id=\"editOrig"+id+"\">"+origHTMLText+"</span></td></tr><tr><td><input id=\"btnSubmit\" type=\"submit\" class=\"sitebutton\" value=\"Submit\" onmouseover=\"javascript:button_goLite('formCommentEdit"+id+"','btnSubmit')\" onmouseout=\"javascript:button_goDim('formCommentEdit"+id+"','btnSubmit')\">&nbsp;&nbsp;<input id=\"btnCancel\" value=\"Cancel\" class=\"cancelbutton\" onmouseover=\"javascript:button_goLite('formCommentEdit"+id+"','btnCancel')\" onmouseout=\"javascript:button_goDim('formCommentEdit"+id+"','btnCancel')\" onclick=\"javascript:cancelEdit('"+id+"','"+table+"','"+page+"');\">&nbsp;<img id=\"process"+id+"\" src=\"img/blank.gif\"><label id=\"lblValidateComment"+id+"\" class=\"validateerror\"></label><span class=\"\" id=\"commentNotify"+id+"\"></span></td></tr></table></form>";
    $("#com-text-inside-"+id).fadeIn("#com-text-inside-"+id);
  });
}
function cancelEdit(id,table,page){
  SaveEditComment(id,document.getElementById('editOrig'+id).innerHTML,table,page);
}
function SaveEditComment(id,textForHTML,table,page){
 $("#com-text-inside-"+id).fadeOut("slow", function(){
    document.getElementById('com-text-inside-'+id).innerHTML = textForHTML;
    turnOnHeaderEditLink(id,table,page);
    $("#com-text-inside-"+id).fadeIn("#com-text-inside-"+id);
  });
}
function saveEdit(id,table,reviewID,page){
  $.get("/clearcachefile.php", { pn: page } );
  var oktogo = true;

  document.getElementById('lblValidateComment'+id).style.visibility = "hidden";
  if(document.getElementById('edit'+id).value == ""){
    document.getElementById('lblValidateComment'+id).innerHTML = "* enter a comment";
    document.getElementById('lblValidateComment'+id).style.visibility = "visible";
    oktogo = false;
  }

  if(oktogo == true){
    var validatedCom = validateCom(document.getElementById('edit'+id).value);
    if(validatedCom != "-1"){
      var textForDB = convertText_TBtoDB(validatedCom);
      var tbComment = textForDB;
      document.getElementById("commentNotify"+id).innerHTML = "Processing...";
      $("#commentNotify"+id).fadeIn("fast", function(){
        $.get("lib/calculations.php", { action: "editcomment", id: 0, tbComment: tbComment, comID: id, table: table}, function(data){
          results = data.split("|");
          document.getElementById("commentNotify"+id).innerHTML = "";
          $("#commentNotify"+id).fadeIn("commentNotify"+id);
            var comm = results[3];
            var newID = results[4];
            var table = results[5];
            SaveEditComment(newID,comm,table,page);
	    });
     });               
    } 
  } else {
    //DisableEnableForm(document.formCommentEdit+id,false);  
  }
}
/* end comments */
/* registration */
function saveRegistrationPage(pid,popup) {
    var pop = "false";
    if(popup==true){ pop = "true";}
    DisableEnableForm(document.registrationForm,true);   
    var tbUsername = document.getElementById('tbUsernameP').value
    var tbPassword1 = document.getElementById('tbPassword1P').value;
    var tbPassword2 = tbPassword1;
    var tbEmail = document.getElementById('tbEmailP').value;
    document.getElementById("registrationNotify").innerHTML = "Processing...";
    $("#registrationNotify").fadeIn("fast", function(){
      $.get("lib/calculations.php", { action: "registerpage", id: pid, tbUsername: tbUsername, tbPassword1: tbPassword1, tbPassword2: tbPassword2, tbEmail: tbEmail, popup: pop}, function(data){
        results = data.split("|");
        document.getElementById("registrationNotify").innerHTML = "";
        $("#registrationNotify").fadeIn("registrationNotify");
          document.getElementById('lblResultsP').innerHTML = '';
          document.getElementById('VDtbUsernameP').innerHTML = '';
          document.getElementById('VDtbEmailP').innerHTML = '';
          document.getElementById('VDtbPasswordP').innerHTML = '';
          if(results[1] == 'bad'){
              if(results[2] != 'ok'){document.getElementById('VDtbUsernameP').innerHTML = results[2];}
              if(results[3] != 'ok'){document.getElementById('VDtbPasswordP').innerHTML = results[3];}
              if(results[4] != 'ok'){document.getElementById('VDtbEmailP').innerHTML = results[4];}
          } else if(results[1] == 'good'){
             document.getElementById("registrationNotify").innerHTML = "Success";
             if(results[5] == 'true'){
				var popupbtn = document.getElementById('btnPopup');
				var mainbtn = document.getElementById('btn');
				popupbtn.type = 'hidden';
				mainbtn.type = 'submit';
				document.getElementById("usernamelink").innerHTML = results[6];
              } else {
                window.location.href=window.location.href;
              }
             //location.replace("/");
          } else if(results[1] == 'error'){
              document.getElementById('lblResultsP').innerHTML = results[2];
          }
	    });
     });
     DisableEnableForm(document.registrationForm,false); 
}
/* end registration */
/* login */
function LoginAttemptPage(pid,popup) {
    var pop = "false";
    if(popup==true){ pop = "true";}
    DisableEnableForm(document.loginForm,true); 
    document.getElementById('lblResultsL').innerHTML = 'processing...';
    document.getElementById('VDtbUsernameL').innerHTML = "";
    document.getElementById('VDtbPasswordL').innerHTML = "";
    document.getElementById('lblResultsL').innerHTML = "";
    var tbUsername = document.getElementById('tbUsernameL').value;
    var tbPassword = document.getElementById('tbPasswordL').value;
    document.getElementById("loginNotify").innerHTML = "Processing...";
    $("#loginNotify").fadeIn("fast", function(){
      $.get("lib/calculations.php", { action: "loginpage", id: pid, tbUsername: tbUsername, tbPassword: tbPassword, popup: pop}, function(data){
        results = data.split("|");
        document.getElementById("loginNotify").innerHTML = "";
        $("#loginNotify").fadeIn("loginNotify");
          if(results[1] == 'bad'){
            if(results[2] != 'ok'){document.getElementById('VDtbUsernameL').innerHTML = results[2];}
            if(results[3] != 'ok'){document.getElementById('VDtbPasswordL').innerHTML = results[3];}
          } else if(results[1] == 'good'){
            if(results[2] == 'yes'){
              //location.replace("/");
              document.getElementById("loginNotify").innerHTML = "Success";
              if(results[4] == 'true'){
				var popupbtn = document.getElementById('btnPopup');
				var mainbtn = document.getElementById('btn');
				popupbtn.type = 'hidden';
				mainbtn.type = 'submit';
				document.getElementById("usernamelink").innerHTML = results[5];
              } else {
                window.location.href=window.location.href;
              }
            } else if(results[2] == 'no'){
              document.getElementById('lblResultsL').innerHTML = 'Login Failed';
            }
          } else if(results[1] == 'error'){
            document.getElementById('lblResultsL').innerHTML = results[1];
          }
          DisableEnableForm(document.loginForm,false); 
	    });
     });
}
function LoginAttemptTOP(pid, cache) {
    $.get("/clearcachefile.php", { pn: cache } );
    DisableEnableForm(document.login_corner,true); 
    var tbUsername = document.getElementById('tbUsernameTOP').value;
    var tbPassword = document.getElementById('tbPasswordTOP').value;
    document.getElementById('VDtbUsername').innerHTML = "";
    document.getElementById('VDtbPassword').innerHTML = "";
    document.getElementById('lblResultsTOP').innerHTML = "";
    document.getElementById("loginTopNotify").innerHTML = "Processing...";
    $("#loginTopNotify").fadeIn("fast", function(){
      $.get("lib/calculations.php", { action: "login_top", id: pid, tbUsername: tbUsername, tbPassword: tbPassword}, function(data){
        results = data.split("|");
        document.getElementById("loginTopNotify").innerHTML = "";
        $("#loginTopNotify").fadeIn("loginTopNotify");
          if(results[1] == 'bad'){
            if(results[2] != 'ok'){document.getElementById('VDtbUsername').innerHTML = results[2].substring(0,1);document.getElementById('lblResultsTOP').innerHTML = "login failed";}
            if(results[3] != 'ok'){document.getElementById('VDtbPassword').innerHTML = results[3].substring(0,1);document.getElementById('lblResultsTOP').innerHTML = "login failed";}
          } else if(results[1] == 'good'){
            if(results[2] == 'yes'){
              location.replace(window.location.href);
            } else if(results[2] == 'no'){
              document.getElementById('lblResultsTOP').innerHTML = 'Login Failed';
            }
          } else if(results[1] == 'error'){
            document.getElementById('lblResultsTOP').innerHTML = results[1];
          }
	    });
     });   
     DisableEnableForm(document.login_corner,false); 
}
function changePassword(pid){
  DisableEnableForm(document.changePassForm,true); 
  document.getElementById('VDtbOldPass').innerHTML = '';
  document.getElementById('VDtbNewPass').innerHTML = '';
  document.getElementById('lblResultsP').innerHTML = 'processing...';
  dateNow = new Date();
  var tbOldPass = document.getElementById('tbOldPass').value;
  var tbNewPass = document.getElementById('tbNewPass').value;
  $("#lblResultsP").fadeIn("fast", function(){
    $.get("lib/calculations.php", { action: "changepass", id: pid, tbOldPass: tbOldPass, tbNewPass: tbNewPass, date: dateNow}, function(data){
      results = data.split("|");
      document.getElementById("lblResultsP").innerHTML = "";
      $("#loginNotify").fadeIn("lblResultsP");
      if(results[1]=='good'){
        document.getElementById('lblResultsP').innerHTML = 'Password changed.';
      } else if(results[1]=='wrongpass'){
        document.getElementById('VDtbOldPass').innerHTML = results[2];
      } else if(results[1]=='bad'){
        if(results[2] != 'ok'){document.getElementById('VDtbOldPass').innerHTML = results[2];}
        if(results[3] != 'ok'){document.getElementById('VDtbNewPass').innerHTML = results[3];}
      }
      DisableEnableForm(document.changePassForm,false); 
    });
  });    
  DisableEnableForm(document.changePassForm,false);    
}
function getNewPassword(){
 DisableEnableForm(document.newPassForm,true); 
  document.getElementById('VDtbUser').innerHTML = '';
  document.getElementById('VDtbEmail').innerHTML = '';
  dateNow = new Date();
  var tbUser = document.getElementById('tbUser').value;
  var tbEmail = document.getElementById('tbEmail').value;
  document.getElementById('lblResultsP').innerHTML = 'processing...';
  dateNow = new Date();
  $("#lblResultsP").fadeIn("fast", function(){
    $.get("lib/calculations.php", { action: "getnewpass", id: -1, tbUser: tbUser, tbEmail: tbEmail, date: dateNow}, function(data){
      results = data.split("|");
      document.getElementById("lblResultsP").innerHTML = "";
      $("#lblResultsP").fadeIn("lblResultsP");
      if(results[1]=='good'){
            document.getElementById('lblResultsP').innerHTML = 'A new password has been sent.  Please check your email.';
          } else if(results[1]=='bad'){
            if(results[2] != 'ok'){document.getElementById('VDtbUser').innerHTML = results[2];}
            if(results[3] != 'ok'){document.getElementById('VDtbEmail').innerHTML = results[3];}
          } else if(results[1]=='eunomatch' || results[1]=='mailfail'){
            document.getElementById('lblResultsP').innerHTML = results[2];
          } else {
            document.getElementById('lblResultsP').innerHTML = 'There was an error processing your request.';
          }
      DisableEnableForm(document.newPassForm,false); 
    });
  });    
  DisableEnableForm(document.newPassForm,false); 
}
/* end login */
/* openid */
function RemoveOpenID(url,numloc,userid){
  $("#openidremove"+numloc).fadeIn("fast", function(){
   document.getElementById("openidremove"+numloc).innerHTML = 'removing...';
    $.get("lib/calculations.php", { action: "openidremove", url: url, id: userid}, function(data){
      showresults = document.getElementById("openidrall"+numloc).innerHTML;
      innershowresults = "";
      results = data.split("|");
      if(results[0] == 'error'){
        innershowresults = '<font color=red>'+results[1]+'</font>';
      } else {
        showresults = '<font color=red>deleted</font>';
      }
	  document.getElementById("openidrall"+numloc).innerHTML = showresults;
	  if(innershowresults!=''){
  	    document.getElementById("openidremove"+numloc).innerHTML = innershowresults;
  	  }
    });
  });
}
function CompleteOpenIDRegistration(openidurl,email){
  DisableEnableForm(document.openIDRegForm,true);
  password = document.getElementById("tbPasswordL").value;
  name = document.getElementById("username").value;
  document.getElementById("openIDRegNotify").innerHTML = "Processing...";
  $("#openIDRegNotify").fadeIn("fast", function(){
    $.get("lib/calculations.php", { action: "openidregister", url: openidurl, email: email, name: name, password: password, id: -1}, function(data){
      results = data.split("|");
      document.getElementById("openIDRegNotify").innerHTML = "";
      $("#openIDRegNotify").fadeIn("openIDRegNotify");
      if(results[0] == 'error'){
        if(results[1]=='password required'){
         name = document.getElementById("username").value;
         document.getElementById("tbPasswordL").style.visibility = "visible";
         document.getElementById("passwordtext").style.visibility = "visible";
         document.getElementById("passwordtext").innerHTML = "The user name "+name+" is already registered in our system.  If you're trying to sign up as a new user, please try to find a different, availible name.  If you are trying to attatch this OpenID to "+name+", enter the password to this account.  Once finished, resubmit.";
        } else {
          document.getElementById("openIDRegNotify").innerHTML = results[1];
        }
      } else if(results[0] == 'success'){
        location.replace("/");
      } else {
	  }
	  DisableEnableForm(document.openIDRegForm,false);
    });
  });
}
function OpenIDAttemptPage(pid,popup,attempt) {
    var pop = "false";
    if(popup==true){ pop = "true";}
    DisableEnableForm(document.openidForm,true); 
    var openid_url = document.getElementById('openid_url').value;
    document.getElementById("openIDNotify").innerHTML = "Processing...";
    //$("#openIDNotify").fadeIn("fast", function(){
      $.get("lib/calculations.php", { action: "openidauthenticate", url: openid_url, popup: pop, id: -1}, function(data){
         results = data.split("|");
         //document.getElementById("openIDNotify").innerHTML = "";
         //$("#openIDNotify").fadeIn("openIDNotify");
           if(results[0] == 'error'){
            document.getElementById("openIDNotify").innerHTML = results[1];
           } else if(results[0] == 'success'){
             location.replace(results[1]);
           } else if(results[0] == 'login'){
             location.replace("/");
           } else {
            attempt = attempt + 1;
            if(attempt==3){
			  document.getElementById("openIDNotify").innerHTML = 'OpenID Not Found.';
			} else {
              OpenIDAttemptPage(pid,popup,attempt); //retry
            }
		   }
			DisableEnableForm(document.openidForm,false);
	    });
     //});
}
/* end openid */
/* contribute */
var glob_description_lim = 450;
var glob_headline_lim = 80;
var glob_content_lim = 10000;

function ContributeSubmit(e){
  myEditor.saveHTML(); 
  ok = false;
  ClearValidators();
  //DisableEnableForm(document.contributeForm,true);
  var link = "0";
  var index = document.getElementById("subtype").selectedIndex;
  if(document.getElementById("subtype")[index].value == "link"){
      link = "1";
    }
  ok = ValidateContribution(link);
  if(ok==false){
    if (e && e.preventDefault){
      e.preventDefault(); // DOM style
    }
  }
  //DisableEnableForm(document.contributeForm,false);
  contribute_Content()
  return(ok);
}
function ContributeFinish(){
  DisableEnableForm(document.contributeForm,true);
  var link = "0";
  if(document.getElementById("subtype").value == "link"){
    link = "1";
  }
    var subcat = document.getElementById("subtype").value;
    var intsubcat = GetArticleType(subcat);
    //var headline = convertText_TBtoDB(document.getElementById("tbHeadline").value);
    var headline = convertText_TBtoDB(document.getElementById("exampleHeadline").innerHTML);
    //var description = convertText_TBtoDB(document.getElementById("taDescription").value);
    var description = convertText_TBtoDB(stripCRLF(document.getElementById("exampleDescription").innerHTML));
    //var content = convertText_TBtoDB(document.getElementById("taContent").value); 
    //var content = convertText_TBtoDB(document.getElementById("exampleContent").innerHTML);
    var content = document.getElementById("exampleContent").innerHTML;
    var url = document.getElementById("tbUrl").value;
    //var captcha = document.getElementById("tbCaptcha").value;
    var recaptcha_response_field = document.getElementById("recaptcha_response_field").value;
    var recaptcha_challenge_field = document.getElementById("recaptcha_challenge_field").value;
    var imagelink = document.getElementById("contentContainer").childNodes[0].src;
    if( imagelink.indexOf('ph.gif') > 0){ imagelink = ''; }
    imgpos = imagelink.indexOf('img/');
    imagelink = imagelink.substr(imgpos,imagelink.length);
    $("#VDtbSubmit").fadeIn("fast", function(){
    document.getElementById("VDtbSubmit").innerHTML = "Submitting...";
    //alert("from span: " + document.getElementById("exampleDescription").innerHTML);
    //alert("des b: " + document.getElementById("taDescription").value);
    //alert("des a: " + description);
    $.post("lib/postart.php", { link: link, subcat: intsubcat, headline: headline, description: description, content: content, url: url, imagelink: imagelink, recaptcha_response_field: recaptcha_response_field, recaptcha_challenge_field: recaptcha_challenge_field }, function(data){
        results = data.split("|");
        $("#VDtbSubmit").fadeIn("slow");
        if(results[1]=="good"){
          document.getElementById("VDtbSubmit").innerHTML = "Submission OK";
          //location.replace('/new/');
          location.replace(results[2]);
        } else if(results[1]=="duplicate"){
          document.getElementById("VDtbSubmit").innerHTML = results[2];
        } else {
          document.getElementById("VDtbSubmit").innerHTML = "Submission Failed";
          if(results[2]=="badcaptcha"){
            document.getElementById("VDtbSubmit").innerHTML = "Please enter the correct text value";
          } else {
            document.getElementById("VDtbSubmit").innerHTML = document.getElementById("VDtbSubmit").innerHTML + " " + results[2];//"Undefined error.";   
          } 
        }
    });
  });
  DisableEnableForm(document.contributeForm,false);
}
function ClearValidators(){
  document.getElementById("VDtbUrl").innerHTML = "&nbsp;"; 
  document.getElementById("VDtbDescription").innerHTML = "&nbsp;";
  document.getElementById("VDtbContent").innerHTML = "&nbsp;";
  document.getElementById("VDtbHeadline").innerHTML = "&nbsp;";
}
function ValidateContribution(type){
  result = true;
  if(type=="1"){
    if(document.getElementById("hiddenURLOK").value == "1"){
      document.getElementById("VDtbUrl").innerHTML = "URL OK!"; 
    } else if(document.getElementById("hiddenURLOK").value == "0"){
      //result = false;
      url = document.getElementById("tbUrl").value;
      var data = $.ajax({
        url: "lib/calculations.php",
        data: "action=checkurl&url="+url+"&id=0",
        async: false
      }).responseText;
      results = data.split("|");
      if(results[1]=="good"){
        result = true;
        document.getElementById("hiddenURLOK").value = "1";
        document.getElementById("VDtbUrl").innerHTML = "URL OK!";
        document.getElementById("podcontentWrapID").firstChild.href = document.getElementById("tbUrl").value;
      } else {
        document.getElementById("VDtbUrl").innerHTML = "URL not found.";
        result = false;
      }
    } 
  } else {
    if(!document.getElementById("taContent").value.length > 0){
      document.getElementById("VDtbContent").innerHTML = "*Please enter your content"; result = false;
    }
    if(document.getElementById("taContent").value.length > 10000){
      document.getElementById("VDtbContent").innerHTML = "*Please shorten your content"; result = false;
    }
  }
  if(!document.getElementById("tbHeadline").value.length > 0){
    document.getElementById("VDtbHeadline").innerHTML = "*Please enter a headline"; result = false;
  }
  if(document.getElementById("tbHeadline").value.length > 80){
    document.getElementById("VDtbHeadline").innerHTML = "*Please shorten your headline"; result = false;
  }
  if(document.getElementById("taDescription").value.length > 450){
    document.getElementById("VDtbDescription").innerHTML = "*Please shorten your description"; result = false;
  }
  return(result);
}
function characterCount(target,tot,label){
  var cur = document.getElementById(target).value.length;
  if(cur>tot){
    document.getElementById(label).style.color = "red"
  } else {
    document.getElementById(label).style.color = "black"
  }
  document.getElementById(label).innerHTML = "" + cur + "/" + tot;
}
function characterCountRichTextBox(target,tot,label){
  myEditor.saveHTML(); 
  var cur = document.getElementById(target).value.length;
  if(cur>tot){
    document.getElementById(label).style.color = "red"
  } else {
    document.getElementById(label).style.color = "black"
  }
  document.getElementById(label).innerHTML = "" + cur + "/" + tot;
}
function contribute_SubType(){
  var index = document.getElementById("subtype").selectedIndex;
  if(document.getElementById("subtype")[index].value == "link"){
    document.getElementById("trurl").style.display = "";
    //document.getElementById("trcontent").style.display = "none";
  } else {
    document.getElementById("trurl").style.display = "none";
    //document.getElementById("trcontent").style.display = "";
  }
}
function contribute_SubCategory(){
  var index = document.getElementById("subcategory").selectedIndex;
  if(document.getElementById("subcategory")[index].value == "news"){
    document.getElementById("exampleType").className = "lhs_news";
    document.getElementById("exampleTypeText").innerHTML = "news";
  } else if(document.getElementById("subcategory")[index].value == "scoop"){
    document.getElementById("exampleType").className = "lhs_scoop";
    document.getElementById("exampleTypeText").innerHTML = "scoop";
  } else if(document.getElementById("subcategory")[index].value == "tabloid"){
    document.getElementById("exampleType").className = "lhs_tabloid";
    document.getElementById("exampleTypeText").innerHTML = "tabloid";
  } else if(document.getElementById("subcategory")[index].value == "opinion"){
    document.getElementById("exampleType").className = "lhs_opinion";
    document.getElementById("exampleTypeText").innerHTML = "opinion";
  } else if(document.getElementById("subcategory")[index].value == "review"){
    document.getElementById("exampleType").className = "lhs_review";
    document.getElementById("exampleTypeText").innerHTML = "review";
  }
}
/**************************
function clearSubTypes(){
  document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilink";
  document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liom";
}
function clearContributes(){
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linews";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinion";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoop";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloid";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireview";
}
function fillContributeBoxes(){
  clearSubTypes();
  clearContributes();
  var index = document.getElementById("subcategory").selectedIndex;
  if(document.getElementById("subcategory")[index].value == "news"){
    document.getElementById("exampleType").className = "lhs_news";
    document.getElementById("exampleTypeText").innerHTML = "news";
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linewsactive";
  } else if(document.getElementById("subcategory")[index].value == "scoop"){
    document.getElementById("exampleType").className = "lhs_scoop";
    document.getElementById("exampleTypeText").innerHTML = "scoop";
      document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoopactive";
  } else if(document.getElementById("subcategory")[index].value == "tabloid"){
    document.getElementById("exampleType").className = "lhs_tabloid";
    document.getElementById("exampleTypeText").innerHTML = "tabloid";
      document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloidactive";
  } else if(document.getElementById("subcategory")[index].value == "opinion"){
    document.getElementById("exampleType").className = "lhs_opinion";
    document.getElementById("exampleTypeText").innerHTML = "opinion";
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinionactive";
  } else if(document.getElementById("subcategory")[index].value == "review"){
    document.getElementById("exampleType").className = "lhs_review";
    document.getElementById("exampleTypeText").innerHTML = "review";
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireviewactive";
  }
  index = document.getElementById("subtype").selectedIndex;
  if(document.getElementById("subtype")[index].value == "link"){
    document.getElementById("trurl").style.display = "";
    document.getElementById("trurl2").style.display = "";
    document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilinkactive";
  } else {
    document.getElementById("trurl").style.display = "none";
    document.getElementById("trurl2").style.display = "none";
    document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liomactive";
  }
}
function contributeSet(t){
  clearContributes();
  if(t=='news'){
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linewsactive";
    document.getElementById("exampleType").className = "lhs_news";
    document.getElementById("exampleTypeText").innerHTML = "news";
    document.getElementById('subcategory').value = "news";
  } else if(t=='opinion'){
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinionactive";
    document.getElementById("exampleType").className = "lhs_opinion";
    document.getElementById("exampleTypeText").innerHTML = "opinion";
    document.getElementById('subcategory').value = "opinion";
  } else if(t=='scoop'){
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoopactive";
    document.getElementById("exampleType").className = "lhs_scoop";
    document.getElementById("exampleTypeText").innerHTML = "scoop";
    document.getElementById('subcategory').value = "scoop";
  } else if(t=='tabloid'){
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloidactive";
    document.getElementById("exampleType").className = "lhs_tabloid";
    document.getElementById("exampleTypeText").innerHTML = "tabloid";
    document.getElementById('subcategory').value = "tabloid";
  } else if(t=='review'){
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireviewactive";
    document.getElementById("exampleType").className = "lhs_review";
    document.getElementById("exampleTypeText").innerHTML = "review";
    document.getElementById('subcategory').value = "review";
  }
}
function contributeSubType(t){
  clearSubTypes();
  if(t=='link'){
    document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilinkactive";
    //document.getElementById('c_link').className = "lilinkactive";
    document.getElementById('subtype').value = "link";
    document.getElementById("trurl").style.display = "";
    document.getElementById("trurl2").style.display = "";
  } else if(t=='om'){
    document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liomactive";  
    //document.getElementById('c_om').className = "liomactive";
    document.getElementById('subtype').value = "originalmaterial";
    document.getElementById("trurl").style.display = "none";
    document.getElementById("trurl2").style.display = "none";
  } 
}
function clearSubTypes(){
  document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilink";
  document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liom";
}
function clearContributes(){
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linews";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinion";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoop";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloid";
  document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireview";
}
function fillContributeBoxes(){
  clearSubTypes();
  clearContributes();
  var index = document.getElementById("subcategory").selectedIndex;
  if(document.getElementById("subcategory")[index].value == "news"){
    document.getElementById("exampleType").className = "lhs_news";
    document.getElementById("exampleTypeText").innerHTML = "news";
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linewsactive";
  } else if(document.getElementById("subcategory")[index].value == "scoop"){
    document.getElementById("exampleType").className = "lhs_scoop";
    document.getElementById("exampleTypeText").innerHTML = "scoop";
      document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoopactive";
  } else if(document.getElementById("subcategory")[index].value == "tabloid"){
    document.getElementById("exampleType").className = "lhs_tabloid";
    document.getElementById("exampleTypeText").innerHTML = "tabloid";
      document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloidactive";
  } else if(document.getElementById("subcategory")[index].value == "opinion"){
    document.getElementById("exampleType").className = "lhs_opinion";
    document.getElementById("exampleTypeText").innerHTML = "opinion";
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinionactive";
  } else if(document.getElementById("subcategory")[index].value == "review"){
    document.getElementById("exampleType").className = "lhs_review";
    document.getElementById("exampleTypeText").innerHTML = "review";
    document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireviewactive";
  }
  index = document.getElementById("subtype").selectedIndex;
  if(document.getElementById("subtype")[index].value == "link"){
    document.getElementById("trurl").style.display = "";
    document.getElementById("trurl2").style.display = "";
    document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilinkactive";
  } else {
    document.getElementById("trurl").style.display = "none";
    document.getElementById("trurl2").style.display = "none";
    document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liomactive";
  }
}
*******************************/
function contributeSet(t){
  clearContributes();
  if(t=='news'){
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linewsactive";
    document.getElementById('c_news').className = "linewsactive";
    document.getElementById("exampleType").className = "lhs_news";
    document.getElementById("exampleTypeText").innerHTML = "news";
    document.getElementById('subcategory').value = "news";
  } else if(t=='opinion'){
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinionactive";
    document.getElementById('c_opinion').className = "liopinionactive";
    document.getElementById("exampleType").className = "lhs_opinion";
    document.getElementById("exampleTypeText").innerHTML = "opinion";
    document.getElementById('subcategory').value = "opinion";
  } else if(t=='scoop'){
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoopactive";
    document.getElementById('c_scoop').className = "liscoopactive";
    document.getElementById("exampleType").className = "lhs_scoop";
    document.getElementById("exampleTypeText").innerHTML = "scoop";
    document.getElementById('subcategory').value = "scoop";
  } else if(t=='tabloid'){
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloidactive";
    document.getElementById('c_tabloid').className = "litabloidactive";
    document.getElementById("exampleType").className = "lhs_tabloid";
    document.getElementById("exampleTypeText").innerHTML = "tabloid";
    document.getElementById('subcategory').value = "tabloid";
  } else if(t=='review'){
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireviewactive";
    document.getElementById('c_review').className = "lireviewactive";
    document.getElementById("exampleType").className = "lhs_review";
    document.getElementById("exampleTypeText").innerHTML = "review";
    document.getElementById('subcategory').value = "review";
  }
}
function contributeSubType(t){
  clearSubTypes();
  if(t=='link'){
    //document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilinkactive";
    document.getElementById('c_link').className = "lilinkactive";
    document.getElementById('subtype').value = "link";
    document.getElementById("trurl").style.display = "";
    document.getElementById("trurl2").style.display = "";
  } else if(t=='om'){
    //document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liomactive";  
    document.getElementById('c_om').className = "liomactive";
    document.getElementById('subtype').value = "originalmaterial";
    document.getElementById("trurl").style.display = "none";
    document.getElementById("trurl2").style.display = "none";
  } 
}
function clearSubTypes(){
  //document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilink";
  //document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liom";
  document.getElementById('c_link').className = "lilink";
  document.getElementById('c_om').className = "liom";
}
function clearContributes(){
  //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linews";
  //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinion";
  //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoop";
  //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloid";
  //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireview";
  document.getElementById('c_news').className = "linews";
  document.getElementById('c_opinion').className = "liopinion";
  document.getElementById('c_scoop').className = "liscoop";
  document.getElementById('c_tabloid').className = "litabloid";
  document.getElementById('c_review').className = "lireview";
}
function fillContributeBoxes(){
  clearSubTypes();
  clearContributes();
  var index = document.getElementById("subcategory").selectedIndex;
  if(document.getElementById("subcategory")[index].value == "news"){
    document.getElementById("exampleType").className = "lhs_news";
    document.getElementById("exampleTypeText").innerHTML = "news";
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.className = "linewsactive";
    document.getElementById('c_news').className = "linewsactive";
  } else if(document.getElementById("subcategory")[index].value == "scoop"){
    document.getElementById("exampleType").className = "lhs_scoop";
    document.getElementById("exampleTypeText").innerHTML = "scoop";
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "liscoopactive";
    document.getElementById('c_scoop').className = "liscoopactive";
  } else if(document.getElementById("subcategory")[index].value == "tabloid"){
    document.getElementById("exampleType").className = "lhs_tabloid";
    document.getElementById("exampleTypeText").innerHTML = "tabloid";
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "litabloidactive";
    document.getElementById('c_tabloid').className = "litabloidactive";
  } else if(document.getElementById("subcategory")[index].value == "opinion"){
    document.getElementById("exampleType").className = "lhs_opinion";
    document.getElementById("exampleTypeText").innerHTML = "opinion";
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liopinionactive";
    document.getElementById('c_opinion').className = "liopinionactive";
  } else if(document.getElementById("subcategory")[index].value == "review"){
    document.getElementById("exampleType").className = "lhs_review";
    document.getElementById("exampleTypeText").innerHTML = "review";
    //document.getElementById("menusub").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.className = "lireviewactive";
    document.getElementById('c_review').className = "lireviewactive";
  }
  index = document.getElementById("subtype").selectedIndex;
  if(document.getElementById("subtype")[index].value == "link"){
    document.getElementById("trurl").style.display = "";
    document.getElementById("trurl2").style.display = "";
    //document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.className = "lilinkactive";
    document.getElementById('c_link').className = "lilinkactive";
  } else {
    document.getElementById("trurl").style.display = "none";
    document.getElementById("trurl2").style.display = "none";
    //document.getElementById("menuom").firstChild.nextSibling.firstChild.nextSibling.nextSibling.nextSibling.className = "liomactive";
    document.getElementById('c_om').className = "liomactive";
  }
}
function fillContributePreview(){
  contribute_Headline();
  contribute_Description();
  contribute_Content();
  contribute_SubType();
  contribute_SubCategory();
  contribute_URL();
}
function contribute_Headline(){
  characterCount("tbHeadline",glob_headline_lim,"spanHeadlineCount");
  document.getElementById("exampleHeadline").innerHTML = document.getElementById("tbHeadline").value;
}
function contribute_Description(){
  characterCount("taDescription",glob_description_lim,"spanDescriptionCount");
  document.getElementById("exampleDescription").innerHTML = document.getElementById("taDescription").value;
}
function contribute_Content(){
  myEditor.saveHTML(); 
  characterCountRichTextBox("taContent",glob_content_lim,"spanContentCount");
  document.getElementById("exampleContent").innerHTML = document.getElementById("taContent").value;//convertText_TBtoDB(document.getElementById("taContent").value);
  document.getElementById("hiddenContentToPass").value = document.getElementById("exampleContent").innerHTML;
}
function contribute_URL(){
  result = false;
  url = document.getElementById("tbUrl").value;
  $("#VDtbUrl").fadeIn("fast", function(){
    document.getElementById("VDtbUrl").innerHTML = "Checking URL...";
    $.get("lib/calculations.php", { action: "checkurl", id: "0", url: url }, function(data){
        results = data.split("|");
        $("#VDtbUrl").fadeIn("slow");
        if(results[1]=="good"){
          result = true;
          document.getElementById("hiddenURLOK").value = "1";
          document.getElementById("VDtbUrl").innerHTML = "URL OK!";
          document.getElementById("podcontentWrapID").firstChild.href = document.getElementById("tbUrl").value;
        } else {
          document.getElementById("VDtbUrl").innerHTML = "URL not found.";
        }
    });
  });
  return(result);
}
/* end contribute*/
/* image finder */
function fillimagebox(){
 $("#pictureresults").fadeOut("fast",function(){
     se("camals");
  });
}
function se(query) {
  var searcher = new GimageSearch();
  searcher.setRestriction(GSearch.RESTRICT_SAFESEARCH, GSearch.SAFESEARCH_STRICT);
  searcher.setRestriction(GimageSearch.RESTRICT_IMAGESIZE, GimageSearch.IMAGESIZE_MEDIUM);
  searcher.setNoHtmlGeneration();
  var options = new GsearcherOptions();
  options.setImageResultsTbHeight(200);

  var sc = new GSearchControl();
  sc.setResultSetSize(GSearch.LARGE_RESULTSET);
  sc.addSearcher(searcher,options);
  sc.setNoResultsString(GSearchControl.NO_RESULTS_DEFAULT_STRING);
  sc.setSearchCompleteCallback(this,OnSearchComplete);
  sc.draw(document.getElementById("pictureresults1"));
  sc.execute(query);
}
OnSearchComplete = function(sc, searcher) {
  if ( searcher.results && searcher.results.length > 0) {
    $("#pictureresults").fadeIn("fast",function(){
      document.getElementById("pictureresults").innerHTML = "";
      FillPictures(searcher);
    });
  }
}
function FindPictures(){
  document.getElementById("pictureresults").innerHTML = "<center>Loading...</center>";
  $("#pictureresults").fadeIn("fast",function(){
     se(document.getElementById("tbPictureSearchTerms").value);
  });
}
function FillPictures(searcher){
 var fullImagesArray = new Array();
  var imagesArray = new Array();
  i=0;
  done=false;
  while(!done){
    imagesArray[i]=searcher.results[i].tbUrl;
    fullImagesArray[i]=searcher.results[i].unescapedUrl;
    i++;
    if(i==10 || i==searcher.results.length){
      done=true;
    }
  }
 var container = document.getElementById("imagefindercontainer");
 var x=container.childNodes;
 for (i=0;i<x.length;i++)
 {
   x[i].style.cssText = "background: url('"+imagesArray[i]+"')"; //fix for ie
   y = x[i].childNodes;
   z = y[0].childNodes;
   z[0].src = fullImagesArray[i];
 }
}
function SS(){
  scope = "http://www.google.com/calendar/feeds";
  var token = google.accounts.user.login(scope);
}
function pictureChoosen(){
  url = document.getElementById("finalImageURL").value;
  document.getElementById("showresults").innerHTML = "Saving...";
  $("#showresults").fadeOut("fast", function(){
    $.get("lib/calculations.php", { action: "addpicture", id: "-1", url: url }, function(data){
      $("#showresults").fadeIn("slow");
      results = data.split("|");
      if(results[1]=="OK"){
        document.getElementById("showresults").innerHTML = "Picture saved!";
        document.getElementById("contentContainer").childNodes[0].src = results[2];
        $("#article_pic").fadeOut("fast", function(){
           $("#article_pic").fadeIn("slow");
         });
      } else {
        document.getElementById("showresults").innerHTML = "Could not save this picture.";
      }
    });
  });
}
function ContributeFinishPic(){
  url = document.getElementById("image").value;
  if(url.length > 0){
    $.get("lib/calculations.php", { action: "addpicture", id: "-1", url: url }, function(data){
      results = data.split("|");
      if(results[1]=="OK"){
        document.getElementById("contentContainer").childNodes[0].src = results[2];
      } 
      ContributeFinish();
    });
  } else {
    ContributeFinish();
  }
}
function testIII(){
  content = document.getElementById("contentContainer");
  content.childNodes[0].src = results[2];
}
function ShowImage(){
  clearMainImageDisplay();
  var image = document.getElementById("finalImageIndex").value;
  if(image>0){
   $("#i"+image).fadeIn("fast");
    var container = document.getElementById("imagefindercontainer");
    var x=container.childNodes;
    y = x[image-1].childNodes;
    z = y[0].childNodes;
    z[0].style.visibility='visible';
  }
}
function clearMainImageDisplay(){
  var container = document.getElementById("imagefindercontainer");
  var x=container.childNodes;
  for(i=0;i<8;i++){
    y = x[i].childNodes;
    z = y[0].childNodes;
    z[0].style.visibility='hidden';
  }
}
function removeImage(){
  document.getElementById("contentContainer").childNodes[0].src = "img/ph.gif";
}
function SaveImage(image){
  var container = document.getElementById("imagefindercontainer");
  var x=container.childNodes;
  y = x[image-1].childNodes;
  z = y[0].childNodes;
  document.getElementById("finalImageURL").value = z[0].src;
  document.getElementById("finalImageIndex").value = image;
  ShowImage();
}
/* end image finder */
/* blogs */
function getBlogLinks(){
 document.getElementById("blogLinks").innerHTML = "";
 $("#blogLinks").fadeOut("fast", function(){
   $.get("lib/calculations.php", { action: "getbloglinks", id: "-1"}, function(data){
      $("#blogLinks").fadeIn("slow");
      results = data.split("|");
      document.getElementById("loadingblogLinks").className = "bloglinks";
      document.getElementById("loadingblogLinks").innerHTML = "m<sup>y</sup>o<sup>u</sup>vies</a> blogs";
      document.getElementById("bloglinkstable").innerHTML = makeBlogLinksTable(results);
	 });
  });	 
}
function makeBlogLinksTable(results){
 /*
 table = '<table cellspacing="0" cellpadding="0">';
 num = 1;
 for(i=0;i<results.length-1;i=i+2){
   name = results[i];
   time = results[i+1];
   if(time==""){
     time = "no entries yet"; 
   } else {
     time = "updated " + time; 
   }
   if(name.length>16){
     name = name.substring(0,15)+'...';
   }
   table = table + '<tr><td align=left valign=bottom><span class="graphlinks"><a href="/blog/'+name+'/">'+name+'</a> - '+time+'</span></td></tr>';
   num++;
 }
 table = table + '</table>';
 return(table);
 */
 table = '';
 num = 1;
 for(i=0;i<results.length-1;i=i+2){
   name = results[i];
   time = results[i+1];
   if(time==""){
     time = "no entries yet"; 
   } else {
     time = "updated " + time; 
   }
   if(name.length>16){
     name = name.substring(0,15)+'...';
   }
   table = table + '<span class="graphtableitem"><a href="/blog/'+name+'/">'+name+'</a> - '+time+'</span><br>';
   num++;
 }
 return(table);
}
/* end blogs */
/* graphs */
function getSubmissionBreakdown(span,time,filenameaddition,url){
 var uri = parseUri(url);
 var section = FindArticleType(uri.path);
 var color = FindColorByType(section);
 document.getElementById("loading"+span).innerHTML = "Loading Submission Breakdown...";
 document.getElementById("linksgraphSubmissionBreakdown30").className = "graphlinks";
 document.getElementById("linksgraphSubmissionBreakdown365").className = "graphlinks";
 document.getElementById("linksgraphSubmissionBreakdown365000").className = "graphlinks";
 var links = document.getElementById("links"+span).innerHTML;
 document.getElementById("links"+span).innerHTML = "";
 $("#"+span).fadeOut("fast", function(){
   $.get("lib/calculations.php", { action: "getsubmissionbreakdown", id: "-1", time: time, filenameaddition: filenameaddition, section: section, color: color }, function(data){
      results = data.split("|");
      $("#"+span).fadeIn("slow");
      document.getElementById("links"+span).innerHTML = links;
      document.getElementById("linksgraphSubmissionBreakdown"+results[1]).className = "graphlinksactive";
      document.getElementById("loading"+span).innerHTML = "";
      document.getElementById(span).innerHTML = results[0];
	 });
  });	 
}
function getGraphTopUsers(span,time,filenameaddition,url){
 var uri = parseUri(url);
 var section = FindArticleType(uri.path);
 var color = FindColorByType(section);
 document.getElementById("loading"+span).innerHTML = "Loading Top Users...";
 document.getElementById("linksgraphTopUsers30").className = "graphlinks";
 document.getElementById("linksgraphTopUsers365").className = "graphlinks";
 document.getElementById("linksgraphTopUsers365000").className = "graphlinks";
 var links = document.getElementById("links"+span).innerHTML;
 document.getElementById("links"+span).innerHTML = "";
 $("#"+span).fadeOut("fast", function(){
   $.get("lib/calculations.php", { action: "getgraphtopusers", id: "-1", time: time, filenameaddition: filenameaddition, section: section, color: color }, function(data){
      results = data.split("|");
      $("#"+span).fadeIn("slow");
      document.getElementById("links"+span).innerHTML = links;
      document.getElementById("linksgraphTopUsers"+results[2]).className = "graphlinksactive";
      document.getElementById("loading"+span).innerHTML = "";
      document.getElementById("loadinggraphTopUsers").innerHTML = results[0];
      document.getElementById("usertable").innerHTML = makeUserTable(results);
      //document.getElementById(span).innerHTML = results[1];
	 });
  });	 
}
function makeUserTable(results){
 /*
 table = '<table cellspacing="0" cellpadding="0" width=100%>';
 num = 1;
 for(i=3;i<results.length;i=i+3){
   name = results[i+1];
   if(name.length>16){
     name = name.substring(0,15)+'...';
   }
   table = table + '<tr><td align=left valign=bottom><span class="graphlinks">'+num+'.&nbsp;<a href="/user/'+results[i]+'/">'+name+'</a>&nbsp;('+results[i+2]+')</span></td></tr>';
   num++;
 }
 table = table + '</table>';
 return(table);
 */
 table = '';
 num = 1;
 for(i=3;i<results.length;i=i+3){
   name = results[i+1];
   if(name.length>16){
     name = name.substring(0,15)+'...';
   }
   table = table + '<span class="graphtableitem">'+num+'.&nbsp;<a href="/user/'+results[i]+'/">'+name+'</a>&nbsp;('+results[i+2]+')</span><br>';
   num++;
 }
 return(table);
}
function getGraphPopularArticles(span,time,filenameaddition,url){
 var uri = parseUri(url);
 var section = FindArticleType(uri.path);
 var color = FindColorByType(section);
 document.getElementById("loading"+span).innerHTML = "Loading Popular Articles...";
 document.getElementById("linksgraphPopularArticles1").className = "graphlinks";
 document.getElementById("linksgraphPopularArticles7").className = "graphlinks";
 document.getElementById("linksgraphPopularArticles30").className = "graphlinks";
 var links = document.getElementById("links"+span).innerHTML;
 document.getElementById("links"+span).innerHTML = "";
 $("#"+span).fadeOut("fast", function(){
   $.get("lib/calculations.php", { action: "getgraphpopulararticles", id: "-1", time: time, filenameaddition: filenameaddition, section: section, color: color }, function(data){
      results = data.split("|");
      $("#"+span).fadeIn("slow");
      document.getElementById("links"+span).innerHTML = links;
      document.getElementById("linksgraphPopularArticles"+results[2]).className = "graphlinksactive";
      document.getElementById("loading"+span).innerHTML = "";
      document.getElementById("loadinggraphPopularArticles").innerHTML = results[0];
      document.getElementById("populararticlestable").innerHTML = makePopularArticlesTable(results);
	 });
  });	 
}
function makePopularArticlesTable(results){
  /*
  table = '<table cellspacing="0" cellpadding="0">';
  if(results.length>4){
    num = 1;
    for(i=3;i<results.length;i=i+4){
      name = results[i+1];
      table = table + '<tr><td align=left valign=bottom><span class="graphlinks'+results[i+3]+'">'+num+'.&nbsp;<a href="/article/'+results[i]+'/">'+name+'</a>&nbsp;('+results[i+2]+')</span></td></tr>';
      num++;
    }
  } else {
    table = table + '<tr><td align=left valign=bottom><span class="graphlinks">No Comments</span></td></tr>';
  }
  table = table + '</table>';
 return(table);
 */
 table = '';
 num = 1;
 if(results.length>4){
    num = 1;
    for(i=3;i<results.length;i=i+4){
      name = results[i+1];
      table = table + '<span class="graphlinks'+results[i+3]+'">'+num+'.&nbsp;<a href="/article/'+results[i]+'/">'+name+'</a>&nbsp;('+results[i+2]+')</span><br>';
      num++;
    }
  } else {
    table = table + '<span class="graphlinks">No Comments</span><br>';
  }
 return(table);
}
/* end graphs */
function geturldot(){
  result = window.location.href.replace('http://','').replace(/\//g,'.'); 
  if(result.substr(result.length-1,1) == '.'){
    result = result.substr(0,result.length-1);
  }
  return(result);
}
/* ranking */
function processingRank(user,el,id,rating,ia,frompop,page){
 $.get("/clearcachefile.php", { pn: page } );
 if(ia==1){
   $.get("lib/calculations.php", { action: "usersranked", id: -1, article: id}, function(data){
      k = 0;
      var elSel = document.getElementById("admin_userratingname");
      //elSel.setAttribute("onChange","processingRank(this.options[this.selectedIndex].value,document.xform.admin_userrating_el.value,document.xform.admin_userrating_id.value,document.xform.admin_userrating_rating.value,0,1);");
      elSel.onchange = function() { processingRank(this.options[this.selectedIndex].value,document.xform.admin_userrating_el.value,document.xform.admin_userrating_id.value,document.xform.admin_userrating_rating.value,0,1); }
      results = data.split("|");
      for(i=0;i<results.length-1;i=i+2){
        var elOptNew = document.createElement('option');
        elOptNew.text = results[i];
        elOptNew.value = results[i+1];
	 try{
          elSel.add(elOptNew, null); // standards compliant
        }
        catch(ex){
          elSel.add(elOptNew); // IE only
        }
      }
      document.getElementById("admin_userrating_user").value = user;
	  document.getElementById("admin_userrating_el").value = el;
      document.getElementById("admin_userrating_id").value = id;
      document.getElementById("admin_userrating_rating").value = rating;
      popup_show('popup', 'popup_drag', 'popup_exit', 'mouse',-10, -10,user,el,id,rating);
	 });
  } else {
 $("#"+el).fadeOut("slow", function(){
    $.get("lib/calculations.php", { action: "rating", id: user, article: id, rating: rating }, function(data){
      results = data.split("|");
      var totalvotes = results[4];
      var newrating = results[3];
      $("#"+el).fadeIn("slow");
      if(frompop!=1){
        stardone(el,id,newrating,totalvotes);
      } else {
        exitadpop();
        stardonekeepon(el,id,newrating,totalvotes);
  	  }
	 });
  });
 }
}
function exitadpop()
{
  removeseladpop(document.getElementById("admin_userratingname"));
  document.getElementById("admin_userrating_user").value = "";
  document.getElementById("admin_userrating_el").value = "";
  document.getElementById("admin_userrating_id").value = "";
  document.getElementById("admin_userrating_rating").value = "";
  document.getElementById("popup").style.display = 'none';
}
function removeseladpop(elSel){
  for (i = elSel.length - 1; i>=0; i--) {
    elSel.remove(i);
  } 
}
function processingDownArrow(user,el,id,ia,frompop){
 if(ia==1){
   $.get("lib/calculations.php", { action: "downarrowranked", id: -1, article: id}, function(data){
      k = 0;
      var elSel = document.getElementById("admin_userratingname");
      //elSel.setAttribute("onChange","processingDownArrow(this.options[this.selectedIndex].value,document.xform.admin_userrating_el.value,document.xform.admin_userrating_id.value,0,1);");
      elSel.onchange = function() { processingDownArrow(this.options[this.selectedIndex].value,document.xform.admin_userrating_el.value,document.xform.admin_userrating_id.value,0,1); }
      results = data.split("|");
      for(i=0;i<results.length-1;i=i+2){
        var elOptNew = document.createElement('option');
        elOptNew.text = results[i];
        elOptNew.value = results[i+1];
        try{
          elSel.add(elOptNew, null); // standards compliant
        }
        catch(ex){
          elSel.add(elOptNew); // IE only
        }
      }
      document.getElementById("admin_userrating_user").value = user;
	  document.getElementById("admin_userrating_el").value = el;
      document.getElementById("admin_userrating_id").value = id;
      popup_show('popup', 'popup_drag', 'popup_exit', 'mouse',-10, -10,user,el,id,-1);
	 });
  } else {
 $("#"+el).fadeOut("slow", function(){
    $.get("lib/calculations.php", { action: "downarrow", id: user, article: id }, function(data){
      results = data.split("|");
      var newrating = results[4];
      $("#"+el).fadeIn("slow");
      if(frompop!=1){
        arrowdone(el,id,newrating);
      } else {
        exitadpop();
        arrowdonekeepon(el,id,newrating);
  	  }
      
	 });
  });
  }
}
/* end ranking */
var boxold = "";
function boxchange(id,totalvotes,currentrating){
  boxold = document.getElementById("lhs_"+id).innerHTML;
  document.getElementById("lhs_"+id).innerHTML = "<span>rating: "+currentrating+"</span>"+totalvotes+" total votes"; 
}
function boxrevert(id,type,time){
  document.getElementById("lhs_"+id).innerHTML = "<span>"+type+"</span>"+time; 
}
function button_goLite(FRM,BTN)
{
   window.document.forms[FRM].elements[BTN].style.backgroundColor = "#003366";
   window.document.forms[FRM].elements[BTN].style.borderStyle = "groove";
}
function button_goDim(FRM,BTN)
{
   window.document.forms[FRM].elements[BTN].style.backgroundColor = "#6699FF";
   window.document.forms[FRM].elements[BTN].style.borderStyle = "solid";
}
function button_goLiteNoForm(BTN)
{
   document.getElementById(BTN).style.backgroundColor = "#003366";
   document.getElementById(BTN).style.borderStyle = "groove";
}
function button_goDimNoForm(BTN)
{
   document.getElementById(BTN).style.backgroundColor = "#6699FF";
   document.getElementById(BTN).style.borderStyle = "solid";
}
function stripIllegalChars(t){
    var tex = t + "";
    for(i=0; i<tex.length; i++){
      if(tex.indexOf("<") > -1){
        tex = tex.replace("<","");
      }
      if(tex.indexOf("") > -1){
        tex = tex.replace("","'");
      }
      if(tex.indexOf("’") > -1){
        tex = tex.replace("’","'");
      }
      if(tex.indexOf("”") > -1){
        tex = tex.replace("”","'");
      }
      if(tex.indexOf("“") > -1){
        tex = tex.replace("“","'");
      }
    }
    return(tex);
  }
  function validateCom(t){
    var newT = stripIllegalChars(t);
    return(newT);
  }
  function validateComLess(t){
    var tex = t + "";
    for(i=0; i<tex.length; i++){
      if(tex.indexOf("") > -1){
        tex = tex.replace("","'");
      }
      if(tex.indexOf("’") > -1){
        tex = tex.replace("’","'");
      }
      if(tex.indexOf("”") > -1){
        tex = tex.replace("”","'");
      }
      if(tex.indexOf("“") > -1){
        tex = tex.replace("“","'");
      }
    }
    return(tex);
  }
  function getNumberOfCRLFfromHTML(t){
    var result = 0;
    var temp = t;
    for(i=0; i<temp.length; i++){
      if(temp.indexOf("<br>") > -1){
        temp=temp.replace("<br>","");
        result += 1;
      }
      if(temp.indexOf("<BR>") > -1){
        temp=temp.replace("<BR>","");
        result += 1;
      }
    }
    return(result);
  }
  function convertText_HTMLtoTB(t){
    var result = t;
    for(i=0; i<result.length; i++){
      if(result.indexOf("<br>") > -1){
        result=result.replace("<br>","%0D%0A");
      }
      if(result.indexOf("<BR>") > -1){
        result=result.replace("<BR>","%0D%0A");
      }
    }
    result = unescape(result);
    return(result);
  }
  function SpellCheck(ta){
    var textarea1 = document.getElementById(ta);
	var speller = new spellChecker(textarea1);
	speller.openChecker();
  }
  
/* BEGIN Article Search Code */
function searchPageButtonPress(){
   var x = document.getElementById("ddlSortorder").value;
   var a = searchpagecheckboxsearch();
   location.replace("/articlesearch/1/"+x+"/"+a+"/");
}
function searchpagecheckboxsearch(){
  var a = '';
  if(document.getElementById("cbNews").checked == true){
    a = a + '1';
  }
  if(document.getElementById("cbScoops").checked == true){
    a = a + '2';
  }
  if(document.getElementById("cbTheories").checked == true){
    a = a + '3';
  }
  if(document.getElementById("cbReviews").checked == true){
    a = a + '4';
  }
  if(document.getElementById("cbOpinions").checked == true){
    a = a + '5';
  }
  return(a);
}
function searchDropDownChange(x,a){
   location.replace("/articlesearch/1/"+x+"/"+a+"/");
}
function checkboxChange(x){
  var a = '';
  if(document.getElementById("cbNews").checked == true){
    a = a + '1';
  } 
  if(document.getElementById("cbScoops").checked == true){
    a = a + '2';
  } 
  if(document.getElementById("cbTheories").checked == true){
    a = a + '3';
  } 
  if(document.getElementById("cbReviews").checked == true){
    a = a + '4';
  } 
  if(document.getElementById("cbOpinions").checked == true){
    a = a + '5';
  } 
  location.replace("/articlesearch/1/"+x+"/"+a+"/");
}
/* END Article Search Code */
function disableElement(x){
document.getElementById(x).disabled = true;
}
function enableElement(x){
document.getElementById(x).disabled = false;
}
function disableButton(x){
  document.getElementById(x).className = 'buttondis';
  document.getElementById(x).disabled = true;
}
function enableButton(x){
  document.getElementById(x).className = '';
  document.getElementById(x).disabled = false;
}
function ftInToIn(ft,inch){
    var result = (ft*12)+inch;
    return(result);
}
function InToFt(inch){
    var resFt = ((inch-(inch%12))/12);
    return(resFt);
}
function InToIn(inch){
    var resIn = inch%12;
    return(resIn);
}

function GetAMPM(t){
    var result = 'AM';
    if(t>'11:59:59')
        result = 'PM';

    return(result);
}
function convertToDisplayTime(t){
    var timesections = t.split(":");
    if(timesections[0]>12)
      timesections[0] = timesections[0]-12;

    var result = timesections[0] + ":" + timesections[1];
    return(result);
}
function Processing(dir){
    if(dir == 'stop'){
        document.getElementById('img_head').src = "img/blank.gif";
    } else if (dir == 'go'){
        document.getElementById('img_head').src = "img/motion.gif";
    }
}
function Processing2(dir,el){
    if(dir == 'stop'){
        document.getElementById(el).src = "img/blank.gif";
    } else if (dir == 'go'){
        document.getElementById(el).src = "img/motion.gif";
    }
}
function Processing(dir,el){
    if(dir == 'stop'){
        document.getElementById('process').src = "img/blank.gif";
        if(document.getElementById(el)){
          document.getElementById(el).style.backgroundImage="url(img/sectionhead.gif)";
        }
    } else if (dir == 'go'){
        document.getElementById('process').src = "img/motion.gif";
        if(document.getElementById(el)){
          document.getElementById(el).style.backgroundImage="url(img/sectionhead_motion.gif)";
        }
    }
}
function Processing3(dir,el,pic){
    document.getElementById(el).src = pic;
}
function Processing4(dir,el,val){
 	if(dir == 'stop'){
        document.getElementById(el).innerHTML = val;
    } else if (dir == 'go'){
        document.getElementById(el).innerHTML = val;
    }
}
function watch_user(mainuser,watchuser){ 
  $("#spanwatch").fadeOut("fast", function(){
    $.get("lib/calculations.php", { action: "watchuser", id: "-1", mainuser: mainuser, watchuser: watchuser }, function(data){
     results = data.split("|");
     $("#spanwatch").fadeIn("slow");
     if(results[1] == 'good'){
       document.getElementById("spanwatch").innerHTML = "<a href='javascript:unwatch_user("+results[2]+","+results[3]+");'>Remove this user from your watch list</a>";
      }
    });
  });
}
function unwatch_user(mainuser,watchuser){
  $("#spanwatch").fadeOut("fast", function(){
    $.get("lib/calculations.php", { action: "unwatchuser", id: "-1", mainuser: mainuser, watchuser: watchuser }, function(data){
     results = data.split("|");
     $("#spanwatch").fadeIn("slow");
     if(results[1] == 'good'){
       document.getElementById("spanwatch").innerHTML = "<a href='javascript:watch_user("+results[2]+","+results[3]+");'>Watch this user</a>";
     }
    });
  });
}
/* popup window */
var popup_dragging = false;
var popup_target;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;
function popup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";
  popup_mouseposX = ie ? window.event.clientX : e.clientX;
  popup_mouseposY = ie ? window.event.clientY : e.clientY;
}
function popup_mousedown_window(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";
  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;
  popup_dragging = true;
  popup_target   = this['target'];
  popup_mouseX   = ie ? window.event.clientX : e.clientX;
  popup_mouseY   = ie ? window.event.clientY : e.clientY;
  if (ie)
       popup_oldfunction = document.onselectstart;
  else popup_oldfunction = document.onmousedown;
  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}
function popup_mousemove(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  var mouseX  = ie ? window.event.clientX : e.clientX;
  var mouseY  = ie ? window.event.clientY : e.clientY;
  if (!popup_dragging) return;
  element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-popup_mouseY)+'px';
  popup_mouseX = ie ? window.event.clientX : e.clientX;
  popup_mouseY = ie ? window.event.clientY : e.clientY;
}
function popup_mouseup(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  if (!popup_dragging) return;
  popup_dragging = false;
  if (ie)
       document.onselectstart = popup_oldfunction;
  else document.onmousedown   = popup_oldfunction;
}
function popup_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById("popup");
  popup_mouseup("popup");
  element.style.display = 'none';
}
function popup_show(id, drag_id, exit_id, position, x, y, position_id)
{
  var element      = document.getElementById(id);
  var drag_element = document.getElementById(drag_id);
  var exit_element = document.getElementById(exit_id);
  var width        = window.innerWidth  ? window.innerWidth  : document.documentElement.clientWidth;
  var height       = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
  element.style.position = "absolute";
  element.style.display  = "block";
  if (position == "element" || position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);
    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop;
      }
    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;
    element.style.left = x+'px';
    element.style.top  = y+'px';
  }
  if (position == "mouse")
  {
    element.style.left = (document.documentElement.scrollLeft+popup_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +popup_mouseposY+y)+'px';
  }
  if (position == "screen-top-left")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }
  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(height-element.clientHeight)/2+y)+'px';
  }
  if (position == "screen-bottom-right")
  {
    element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth )  +x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(height-element.clientHeight)  +y)+'px';
  }
  drag_element['target']   = id;
  drag_element.onmousedown = popup_mousedown_window;
  exit_element.onclick     = exitadpop;
}
if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent   ('onmousedown', popup_mousedown);
else document.addEventListener('mousedown', popup_mousedown, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent   ('onmousemove', popup_mousemove);
else document.addEventListener('mousemove', popup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent   ('onmouseup', popup_mouseup);
else document.addEventListener('mouseup', popup_mouseup, false);

/* end popup window */
/**/
function show120x600(){
  clearAdExamples();
  $("#advertisesidespan").fadeOut("fast", function(){
    document.getElementById("advertisesidespan").innerHTML = '<img src="img/120x600.gif">';
    $("#advertisesidespan").fadeIn("fast");
  });
}
function show468x60(){
  clearAdExamples();
  $("#advertisetopspan").fadeOut("fast", function(){
    document.getElementById("advertisetopspan").innerHTML = '<img src="img/468x60.gif">';
    $("#advertisetopspan").fadeIn("fast");
  });
}
function show120x240(){ 
  clearAdExamples();
  $("#advertisesidespan").fadeOut("fast", function(){
    document.getElementById("advertisesidespan").innerHTML = '<img src="img/120x240.gif"><br><img src="img/120x240.gif"><br><img src="img/120x240.gif"><br>';
    $("#advertisesidespan").fadeIn("fast");
  });
}
function show125x125top(){
  clearAdExamples();
  $("#advertisetopspan").fadeOut("fast", function(){
    document.getElementById("advertisetopspan").innerHTML = '<table width=100%><tr><td><img src="img/125x125.gif"></td><td><img src="img/125x125.gif"></td><td><img src="img/125x125.gif"></td></tr>';
    $("#advertisetopspan").fadeIn("fast");
  });
}
function show125x125side(){
  clearAdExamples();
  $("#advertisesidespan").fadeOut("fast", function(){
    document.getElementById("advertisesidespan").innerHTML = '<img src="img/125x125.gif"><br><img src="img/125x125.gif"><br><img src="img/125x125.gif"><br><img src="img/125x125.gif">';
    $("#advertisesidespan").fadeIn("fast");
  });
}

function show728x90(){
  clearAdExamples();
  $("#advertisetopspan").fadeOut("fast", function(){
    document.getElementById("advertisetopspan").innerHTML = '<img src="img/728x90.gif">';
    $("#advertisetopspan").fadeIn("fast");
  });
}

function clearAdExamples(){
  document.getElementById("advertisesidespan").innerHTML = "";
  document.getElementById("advertisetopspan").innerHTML = "";
}
/* infobox */
function showInfoBox(box,text,opentext,closetext){
  var browser=navigator.appName;
  var b_version=navigator.appVersion;
  document.getElementById("infobox-description").innerHTML = document.getElementById("hiddeninfobox").innerHTML;
  if(browser=="Microsoft Internet Explorer"){
    expandBoxBasic(box,text,opentext,closetext);
  } else {
    expandBox(box,text,opentext,closetext);
  }
}
function hideInfoBox(box,text,opentext,closetext){
  var browser=navigator.appName;
  var b_version=navigator.appVersion;
  if(browser=="Microsoft Internet Explorer"){
    colapseBoxBasic(box,"infobox-description",text,opentext,closetext);
  } else {
    colapseBox(box,"infobox-description",text,opentext,closetext);
  }
}
function expandBoxLook(box){
  document.getElementById(box).style.padding = "2px 5px 5px 5px";
  document.getElementById(box).style.width = "610px";
  document.getElementById(box).style.background = "#FFFFBF";
  document.getElementById(box).style.border = "3px solid #A9A938";
}
function expandBoxBasic(box,text,opentext,closetext){
  $("#"+box).fadeOut("fast");
  document.getElementById("infobox-topleft1").style.fontSize = "18px";
  expandBoxLook(box);
  document.getElementById("helpwrap").style.padding = "10px 0px 10px 0px";
  $("#infobox-description").fadeIn("fast");
  $("#infobox-topright1").fadeIn("fast"); 
  document.getElementById("infobox-topleft1").innerHTML = text;
  document.getElementById("infobox-topright1").innerHTML = '<span id=inputboxtime></span><span id=inputboxopenclose><a href="javascript:hideInfoBox(\''+box+'\', \''+text+'\', \''+opentext+'\', \''+closetext+'\')">'+closetext+'</a></span>';
  $("#"+box).fadeIn("fast");
}
function expandBox(box,text,opentext,closetext){
  $("#infobox-topleft1").animate({
    fontSize: "18px"
   }, 100, function(){
      expandBoxLook(box);
      $("#"+box).animate({ 
      padding:"2px 5px 5px 5px"
    }, 500);
      $("#helpwrap").animate({ 
        padding:"10px 0px 10px 0px"
      }, 500);
  });
  $("#"+box).animate({ 
    width: "610px"
  }, 500, function(){
     $("#infobox-description").fadeIn("fast");
  }); 
  document.getElementById("infobox-topleft1").innerHTML = text;
  document.getElementById("infobox-topright1").innerHTML = '<span id=inputboxtime></span><span id=inputboxopenclose><a href="javascript:hideInfoBox(\''+box+'\', \''+text+'\', \''+opentext+'\', \''+closetext+'\')">'+closetext+'</a></span>';
  $("#infobox-topright1").fadeIn("fast"); 
}
function colapseBoxLook(box){
  document.getElementById(box).style.padding = "0px 0px 0px 0px";
  document.getElementById(box).style.width = "120px";
  document.getElementById(box).style.background = "#FFF";
  document.getElementById(box).style.border = "";
}
function colapseBoxBasic(box,inner,text,opentext,closetext){
  $("#"+box).fadeOut("fast");
  document.getElementById("infobox-topleft1").style.fontSize = "10px";
  colapseBoxLook(box);
  document.getElementById("helpwrap").style.padding = "0px 0px 10px 0px";
  $("#infobox-description").fadeOut("fast");
  $("#infobox-topright1").fadeOut("fast"); 
  document.getElementById("infobox-topright1").innerHTML = '';
  document.getElementById("infobox-topleft1").innerHTML = '<a href="javascript:showInfoBox(\''+box+'\', \''+text+'\', \''+opentext+'\', \''+closetext+'\');">'+opentext+'</a>';
  $("#"+box).fadeIn("fast");
}
function colapseBox(box,inner,text,opentext,closetext){
  $("#infobox-topright1").fadeOut("fast", function(){
    colapseBoxLook(box);
    document.getElementById("infobox-topright1").innerHTML = '';
  });
  $("#"+inner).fadeOut("fast", function(){
    $("#infobox-topleft1").fadeOut("fast", function(){
      document.getElementById("infobox-topleft1").innerHTML = '';
    });
    $("#"+box).animate({ 
      width: "120px"
    }, 500, function(){
      $("#helpwrap").animate({ 
          padding:"0px 0px 10px 0px"
        }, 500);
      $("#infobox-topleft1").animate({
        fontSize: "10px"
       }, 100, function() {
        $("#"+box).animate({ 
        padding:"0px 0px 0px 0px"
      }, 500);
        document.getElementById("infobox-topleft1").innerHTML = '<a href="javascript:showInfoBox(\''+box+'\', \''+text+'\', \''+opentext+'\', \''+closetext+'\');">'+opentext+'</a>';
        $("#infobox-topleft1").fadeIn("fast");
      });
    });
  });
}
var alertTimerId = 0;
function infobox_timer(time,box,text,opentext,closetext){
  if(time==0){
    hideInfoBox(box,text,opentext,closetext);
  } else {
    document.getElementById("inputboxtime").innerHTML = time;
    time=time-1;
    alertTimerId=setTimeout('infobox_timer('+time+',\''+box+'\',\''+text+'\',\''+opentext+'\',\''+closetext+'\')',1000);
  }
}
function infobox_timer_cancel(){
  clearTimeout(alertTimerId);
  $("#timertext").fadeOut("slow");
}
function updateAdsense(u){
  if(document.getElementById("agreeterms").checked == false){
    document.getElementById("adsenseNotify").innerHTML = "  please agree to the terms before submitting.";
  } else {
    DisableEnableForm(document.adsenseForm,true);   
    var adid = document.getElementById('adsenseCode').value
    document.getElementById("adsenseNotify").innerHTML = "Processing...";
    $("#adsenseNotify").fadeIn("fast", function(){
      $.get("lib/calculations.php", { action: "adsense", id: u, adid: adid }, function(data){
        results = data.split("|");
        document.getElementById("adsenseNotify").innerHTML = "";
        $("#adsenseNotify").fadeIn("registrationNotify");
        document.getElementById('adsenseNotify').innerHTML = '';
        document.getElementById('adsenseNotify').innerHTML = results[1];
        //window.location.href=window.location.href;
      });
    });
    DisableEnableForm(document.adsenseForm,false); 
  }
}
function mdEncode(str){
  return(str.replace(/'/g, "%27;"));
}
function mdDecode(str){
  return(str.replace(/%27;/g, "'"));
}
function mdTrim(str){
  return(str.replace(/^\s+|\s+$/g, ''));
}
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3(2x 14==\'2r\'){14={};14.2t=c(){}}g={w:c(1J){w(\'2 w: \'+1J)},1S:c(s){7 h=5.1t(s);3(h.o>0){8 h[0]}8 6},1c:c(s,1m,1n,1u){3(1u){h=1u.1t(s)}l{h=5.1t(s)}3(h.o===0){8[]}7 W=[];G(7 i=0;i<h.o;i++){3(1m==\'V\'){12=\'\';3(h[i].d(\'V\')){12=h[i].d(\'V\')}l{3(h[i].d(\'1Y\')){12=h[i].d(\'1Y\')}}7 1M=2u 2v(\'(^| )\'+1n+\'($| )\');3(1M.2w(12)){W.1h(h[i])}}l{3(h[i].d(1m)==1n){W.1h(h[i])}}}8 W},1b:c(L,1N){7 m=L.M(\'?\');3(!m[1]){8 6}7 C=m[1];7 1o=m[1].M(\'&\');G(7 i=0;i<1o.o;i++){X=1o[i].M(\'=\');3(X[0]==1N){8 X[1]?X[1]:6}}8 6},J:c(L,U,10){3(U===\'11\'){t=5.S(\'11\');t.U=\'1Q/2y\';t.1z=L}l{t=5.S(\'2z\');t.U=\'1Q/1C\';t.2A=\'2B\';t.p=L}3(10){t.10=10}7 I=g.1S(\'I\');3(I){I.13(t);8}g.w(\'I 2C 1j 1K\')}};R={1B:c(4){7 m=6;7 C=6;4=4.b(/{a}/,2.a);3(2.r[2.u].v){7 v=2.r[2.u].v;m=v.M(\'?\');C=m[1]?m[1]:6;3(2.1q){v+=(C?\'&\':\'?\')+\'j=\'+2.j+(2.a?\'&a=\'+2.a:\'\')}4=4.b(/{1T}/,"F.p=\'"+v+"\';8 6;");4=4.b(/{1U}/,\'\')}l{4=4.b(/{1T}/,\'8 6;\');4=4.b(/{1U}/,\'1X\')}3(2.r[2.u].q){7 q=2.r[2.u].q;m=q.M(\'?\');C=m[1]?m[1]:6;3(2.1q&&(!2.1p||2.r[q].q)){q+=(C?\'&\':\'?\')+\'j=\'+2.j+(2.a?\'&a=\'+2.a:\'\')}4=4.b(/{1V}/,"F.p=\'"+q+"\';8 6;");4=4.b(/{1W}/,\'\')}l{4=4.b(/{1V}/,\'8 6;\');4=4.b(/{1W}/,\'1X\')}4=4.b(/{15}/,2.15);4=4.b(/{16}/,2.16);4=4.b(/{17}/,2.17);4=4.b(/{19}/,2.19);4=4.b(/{2F}/,2.1L);4=4.b(/{E}/,2.E);4=4.b(/{n}/,g.1c(\'f\',\'k\',2.u,5.N(2.j))[0].Z);7 f=5.S(\'f\');f.1s=\'R\';f.Z=4;5.n.13(f);3(!2.Y&&!2.1a){5.N(\'2H\').H.2J=\'2K\'}3(2.1y){g.J(2.1y,\'H\')}3(2.1x){g.J(2.1x,\'11\')}},1e:c(){e=5.N(\'R\');e.22.1O(e)}};2={18:\'24://25.27/1z/29/\',j:6,a:6,15:\'2a\',16:\'x\',17:\'&2d;\',19:\'&2e;\',1a:6,1i:1r,1Z:6,1q:1r,u:6,r:{},E:0,1p:6,1f:6,1B:c(){2.j=2.j?2.j:g.1b(F.p,\'j\');2.a=2.a?2.a:g.1b(F.p,\'a\');3(!2.j){8}3(!2.a){2.a=\'2f\'}7 B=6;7 P=g.1c(\'f\',\'V\',\'1w\');G(i=0;i<P.o;i++){3(P[i].d(\'1s\')==2.j){B=P[i]}}3(!B){g.w(\'2g 2h 2i "1w" 2j 2l "\'+2.j+\'" 1j 2m 2n\')}2.Y=B.d(\'k\')?B.d(\'k\'):6;7 K=B.2o;7 9=[];G(i=0;i<K.o;i++){3(!K[i].s||K[i].s.Q()!=\'f\'){1I}9.1h(K[i])}G(i=0;i<9.o;i++){2.r[9[i].d(\'k\')]={}}G(i=0;i<9.o;i++){3(!9[i].s||9[i].s.Q()!=\'f\'){1I}3(!9[i].d(\'k\')){g.w(\'2s "k" 1j 1K\');8}3(2.1D(9[i].d(\'k\'))&&9[i].Z!==\'\'){2.1L=i+1;2.u=9[i].d(\'k\')}2.E++;3(i>=1&&i<9.o){2.r[9[i].d(\'k\')].v=9[i-1].d(\'k\')}3(i<9.o-1){2.r[9[i].d(\'k\')].q=9[i+1].d(\'k\')}}3(9[i-1].Z===\'\'){2.E=2.E-1;2.1p=1r}3(!2.u){g.w(\'2D 2E 2G 2I 1w 21\')}g.J(2.18+\'1P/\'+2.a.Q()+\'/23.26.28\',\'11\');g.J(2.18+\'1P/\'+2.a.Q()+\'/H.1C\',\'H\');3(2.1i){2.1R()}},1D:c(p){8(F.p.2k(p)!=-1)},1d:c(){7 z;3(A.O&&A.1F){z=A.O+A.1F}l 3(5.n.T>5.n.1g){z=5.n.T}l 3(5.y&&5.y.T>5.y.1g){z=5.y.T}l{z=5.n.1g}7 2p,D;3(1H.O){D=1H.O}l 3(5.y&&5.y.1l){D=5.y.1l}l 3(5.n){D=5.n.1l}8(z<D)?D:z},1R:c(){7 f=5.S(\'f\');f.1s=\'1v\';f.H.1E=2.1d()+\'1G\';3(2.1Z){f.2L=c(){2.1k()}}5.n.13(f);2.1f=A.2b(2.1A,2c)},1A:c(){5.N(\'1v\').H.1E=2.1d()+\'1G\'},1k:c(){A.2q(2.1f);5.n.1O(5.N(\'1v\'))},1e:c(){3(2.1a){R.1e();3(2.1i){2.1k()}8 20}3(2.Y){A.F.p=2.Y}8 20}};',62,172,'||Amberjack|if|tplHtml|document|false|var|return|_children|skinId|replace|function|getAttribute||div|AmberjackBase|els||tourId|title|else|urlSplit|body|length|href|nextUrl|pages|tagName|scriptOrStyle|pageId|prevUrl|alert||documentElement|yInner|window|tourDef|urlQuery|windowHeight|pageCount|location|for|style|head|postFetch|children|url|split|getElementById|innerHeight|tourDefElements|toLowerCase|AmberjackControl|createElement|scrollHeight|type|class|_els|paramSplit|closeUrl|innerHTML|onerror|script|classNames|appendChild|console|textOf|textClose|textPrev|BASE_URL|textNext|onCloseClickStay|getUrlParam|getElementsByTagNameAndAttr|getWindowInnerHeight|close|interval|offsetHeight|push|doCoverBody|is|uncoverBody|clientHeight|attrName|attrValue|paramsSplit|hasExitPage|urlPassTourParams|true|id|getElementsByTagName|domNode|ajBodyCover|ajTourDef|ADD_SCRIPT|ADD_STYLE|src|refreshCover|open|css|urlMatch|height|scrollMaxY|px|self|continue|str|missing|pageCurrent|reg|paramName|removeChild|skin|text|coverBody|getByTagName|prevClick|prevClass|nextClick|nextClass|disabled|className|bodyCoverCloseOnClick|null|found|parentNode|control|http|amberjack|tpl|org|js|stable|of|setInterval|2000|laquo|raquo|model_t|DIV|with|CLASS|and|indexOf|ID|not|defined|childNodes|windowWidth|clearInterval|undefined|attribute|log|new|RegExp|test|typeof|javascript|link|rel|stylesheet|tag|no|matching|currPage|page|ajClose|in|display|none|onclick'.split('|'),0,{}))

function fb_connectuser(){
  $.get("lib/fblogin.php", { }, function(data){
    if(data != "fail"){
      if(document.getElementById("logincornercontainer") && document.getElementById("logincornercontainer").innerHTML != data){
        document.getElementById("logincornercontainer").innerHTML = data;
      }
    }
  });
}

function fb_disconnectuser(){
  $.get("lib/fblogout.php", { }, function(data){
    if(document.getElementById("logincornercontainer")){
      document.getElementById("logincornercontainer").innerHTML = data;
    }
  });
}

