function Neighborrow() {
  var thing_type = 'books';
  function scroll(args)
  {
    if ( args && args.obj && args.id ) {
      var el;
      if ( el = $jq('#' + args.obj + '_' + args.id) ) {
	//el.ScrollTo();
      }
    }
  }
  this.setPrivacy = function(args)
  {
    if (!args && ( args.type && args.id && args.value ) ) {
      return undef;
    }
    $.post('thing/privacy.php', args, function(data){  });
  }
  function create(args) {
    if ( args && !args.obj ) {
      alert('must specify an object to create');
      return false;
    }
    
    var params = $jq('#create_' + args.obj).formToArray();
    params.push({name: 'ajax', value: 1});
    var hoodID = '';
    $jq.map(params, function(p) { if ( p.name == 'neighborrowhoodID' ) { hoodID = p.value } });
    if ( !hoodID ) {
      alert("Couldn't get neighborrowhood id");
      return false;
    }
    
    var url = args.obj + '/create.php';
    $jq.post(url, params,
	     function(data) {
	       if ( !data ) {
		 alert('Error saving ');
		 return false;
	       } else {
		 $jq('#create_' + args.obj).clearForm();
		 var listargs = { neighborrowhoodID: hoodID, obj: args.obj, id: data };
		 if ( args.obj == 'idea' ) {
		   listargs['postit_date'] = 0;
		 }
		 list(listargs);
	       }
	     }
	     );
  }
  this.create = create;
  function del(args) {
    if ( !( args && args.obj && args.id)) {
      alert('must specify an object and id to delete');
      return false;
    }
    var url = args.obj + '/edit.php';
    args.del = 1;
    $jq.post(url, args,
	     function(data) {
		
		//   if ( !data ) {
		// alert('Error deleting')
		//   } else {
		 $jq('#create_' + args.obj).clearForm();
		 var listargs = { neighborrowhoodID: args.neighborrowhoodID, obj: args.obj, id: data };
		 if ( args.obj == 'idea' ) {
		   listargs['postit_date'] = 0;
		 }
		 list(listargs);
	       } //}
	     );
  };
  this.del = del;

  function message(args)
  {
    var inner = $jq('#messagenote');
    display('messagenote');
    inner.html('<span style="font-weight: bold; font-size: 16px; padding: 3px">Message Sent</span><br /><br />');
    var ajax_params =
        {
    url: 'sendmessage.php',
    type: 'POST',
    data: args,
    complete: function(xhr, str) {inner.html(xhr.responseText); scroll(args);pausecomp(1000); display('bio'); },
    dataType: 'html'
        };
    $jq.ajax(ajax_params);
    return false;
  }
  this.message = message;
  function list(args) {
    if ( !args.obj ) {
      alert('must specify an object to list');
      return false;
    }
    
    if ( !args ) {
      alert('args required for list()');
      return false;
    }
    var outer = $jq('#' + args.obj.toUpperCase() + 'S');
    var inner = $jq('#' + args.obj + '_list');
    
    if ( !( outer && inner ) ) {
      alert(args.obj + " elements don't exist");
      return false;
    }
    var url = args.obj + '/list.php';
    inner.html('<span style="font-weight: bold; font-size: 16px; padding: 3px">Searching...</span><br /><br />');
    args.ajax = 1;
    var ajax_params = 
      {
	url: url,
	type: 'POST',
	data: args,
	error: function(xhr, msg, err) { inner.html("Error getting list"); },
	complete: function(xhr, str) { outer.html(xhr.responseText); scroll(args); },
	dataType: 'html'
      };
    
    if ( args.obj == 'thing' ) {
      ajax_params.success = function(data) {
	$('#create_thing input#type').val(args.type);
      }
      if ( !ajax_params.data.type ) {
	ajax_params.data.type = thing_type;
      }
      if ( !ajax_params.data.type ) {
	alert("Can't determine type of thing");
	return false;
      }
    }
    
    $jq.ajax(ajax_params);
    return false;
  }
  this.list = list;
  
}
neighborrow = new Neighborrow();
function clearDisplay()
{
    var divv = document.getElementById('message');
    var divn = document.getElementById('messagenote');
    var divb = document.getElementById('bio');
    divv.style.display = "none";
    divn.style.display = "none";
    divb.style.display = "none";
}
function hide(nameid)
{
    var div = document.getElementById(nameid);
    if (div.style.display == "")
    {
        div.style.display = "none";
    }
}
function display(nameid)
{
    var divv = document.getElementById(nameid);
    if (divv.style.display == "none")
    {
        clearDisplay();
        divv.style.display = "";
    }
    else
    {
        divv.style.display = "none";
    }
}
function pausecomp(millis)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
}
/**
 * @author Hcc Web Solutions
 */
function updateTabTotal(spanId, val){
    $(spanId).innerHTML = "&nbsp;(" + val + ")";
    $(spanId).style.fontSize = "13px";
    if (val > 0) {
        $(spanId).style.color = "red";
    }
    else {
        $(spanId).style.color = "#0d4054";
    }
}
function updateInboxTotal(val){
    updateTabTotal('inboxTotal', val);
}
function updateInboxTotalMessage(val){
    url = "ajax/inbox.php?act=updateTotal";
    new Ajax.Request(url, {
        method: 'get',
        onComplete: function(res){
            $('totalMessage').innerHTML = res.responseText;
            updateTabTotal('inboxTotal', res.responseText);
            if (res.responseText == "0") {
                $('lnkInbox').style.color = "white";
            }
        }
    });
}
function updateBorrowedItemsTotal(val){
    updateTabTotal('borrowedItemsTotal', val);
}
function updateNeighborrowhoodMembershipTotal(val){
    updateTabTotal('neighborrowhoodMembershipTotal', val);
}
function updateRequestsTotal(val){
    updateTabTotal('requestsTotal', val);
}
function updateExpectingItemsTotal(val){
    updateTabTotal('expectingItemsTotal', val);
}
function updateReturnedItemsTotal(val){
    updateTabTotal('returnedItemsTotal', val);
}
function setDeliverTime(input, id){
    new Ajax.Request("ajax/deliverTime.php?requestID=" + id + "&time=" + input.value, {
        method: 'get'
    });
}
function countdown(spanId, seconds){
    if (seconds < 0) 
        seconds = 0;
    second = seconds % 60;
    minutes = parseInt(seconds / 60);
    minute = minutes % 60;
    hours = parseInt(minutes / 60);
    $(spanId).innerHTML = hours + " hour(s) : " + minute + " min.(s) : " + second + " sec.(s)";
    if (seconds > 0) 
        setTimeout(function(){
            countdown(spanId, seconds - 1);
        }, 1 * 1000);
}
function checkform(){
    var obj = document.frm_askus;
    //alert(obj.message.value.length);                
    if (obj.txt_email_address.value == "") {
        alert("Please enter your email address.")
        obj.txt_email_address.focus();
        return false;
    }
    else 
        if (obj.message.value.length < 5) {
            alert("Please enter your message not less than 5 characters.")
            obj.message.focus();
            return false;
        }
        else {
            return true;
        }
}
function loadInbox(start){
    var url = 'ajax/IN_DEV_inbox.php';
    if (start) 
        url += "?start=" + start;
    
    var pars = '';
    
    var myAjax = new Ajax.Updater({
        success: 'divMessagebox'
    }, url, {
        method: 'get',
        parameters: pars,
        onComplete: function(res){
            var response = new String(res.responseText);
            response.extractScripts().map(function(script){
                return eval(script.replace("<!--", "").replace("// -->", ""));  
            });}});}
function loadOutbox(start){
    var url = 'ajax/outbox.php';   
    if (start) 
        url += "?start=" + start;    
    var pars = '';    
    var myAjax = new Ajax.Updater({
        success: 'divMessagebox'
    }, url, {    
        method: 'get',        
        parameters: pars,        
        onComplete: function(res){        
            var response = new String(res.responseText);            
            response.extractScripts().map(function(script){            
                return eval(script.replace("<!--", "").replace("// -->", ""));                
            });}});}
function viewItem(type, typeid, id){
    Modalbox.show('Item Information', "quickviewitem.php?type=" + type + "&" + typeid + "=" + id, {
        width: 720,
        height: 340
    });
}
function loadBorrowedItems(start){
    var url = 'ajax/IN_DEV_borrowedItems.php';
    if (start) 
        url += "?start=" + start;
    var pars = '';    
    var myAjax = new Ajax.Updater({
        success: 'divBorrowedItems'
    }, url, {    
        method: 'get',        
        parameters: pars,        
        onComplete: function(res){        
            var response = new String(res.responseText);            
            response.extractScripts().map(function(script){            
                return eval(script.replace("<!--", "").replace("// -->", ""));                
            });            
        }        
    });    
}
function sendAMessage(toid, fromid, subject, message){
    var url = "sendmessage.php";
    var pars = "toid=" + toid + "&fromid=" + fromid + "&subject=" + subject + "&message=" + message;
    
    new Ajax.Request(url, {
        method: 'post',
        postBody: pars,
        onComplete: function(res){
            $('inboxMessages').innerHTML = res.responseText;
            Modalbox.close()
        }
    });
    
}
function deleteMessage(messageID, start){
    var url = 'ajax/inbox.php?act=delete&messageID=' + messageID;
    
    if (start) 
        url += "&start=" + start;
    
    var pars = '';
    
    var myAjax = new Ajax.Updater({
        success: 'divMessagebox'
    }, url, {
    
        method: 'get',
        
        parameters: pars,
        
        onComplete: function(){
            updateTotalMessage();
        }
        
    });
    
}
function changeReadStatus(a){
    img = a.getElementsByTagName("img")[0];
    
    img.src = img.src.replace(/unread.png/, 'read.png');
    
}
function updateTotalMessage(){
    url = "ajax/inbox.php?act=updateTotal";
    
    new Ajax.Request(url, {
        method: 'get',
        onComplete: function(res){
            $('totalMessage').innerHTML = res.responseText;
        }
    });
    
}
function inviteToHood(hoodID){
    Modalbox.show('Invite Friends', "/idea/invite.php?hasnext=&neighborrowhoodID=" + hoodID, {
        width: 790,
        height: 520
    });
    
}
function createHood(){
    Modalbox.show('Create a neighBORROW-hood', 'createHood.php', {
        width: 670,
        height: 480
    });
    
}
function nocreate(){
    Modalbox.show('Create a neighBORROW-hood', '/ajax/messages/nocreateMessage.php', {
        width: 670,
        height: 120
    });
    
}
function showPvtOrPub(type){
    if (type == 'private') {
        //pvt nbh
        document.getElementById("create_user_private").style.display = "inline";
        
        //hide pub nbh
        document.getElementById("create_user_public").style.display = "none";
        
        //hide all error messages
        document.getElementById("errorMessage").innerHTML = "";
        document.getElementById("create_user_header").style.display = "none";
        
        //initialize the js variables.
        init();
    }
    else 
        if (type == 'public') {
            //pub nbh
            document.getElementById("create_user_public").style.display = "inline";
            
            //hide pvt nbh
            document.getElementById("create_user_private").style.display = "none";
            
            //hide all error messages
            document.getElementById("errorMessage").innerHTML = "";
            document.getElementById("create_user_header").style.display = "none";
        }
        else {
            document.getElementById("create_user_header").style.display = "block";
            document.getElementById("create_user_public").style.display = "none";
            document.getElementById("create_user_private").style.display = "none";
        }
}
function prepareInputsForHints(){
    var inputs = document.getElementsByTagName("input");
    
    for (var i = 0; i < inputs.length; i++) {
    
        // test to see if the hint span exists first
        
        if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
        
            // the span exists!  on focus, show the hint
            
            inputs[i].onfocus = function(){
            
                this.parentNode.getElementsByTagName("span")[0].style.visibility = "visible";
                
            }
            
            // when the cursor moves away from the field, hide the hint
            
            inputs[i].onblur = function(){
            
                this.parentNode.getElementsByTagName("span")[0].style.visibility = "hidden";
                
            }
            
        }
        
    }
    
    // repeat the same tests as above for selects
    
    var selects = document.getElementsByTagName("select");
    
    for (var k = 0; k < selects.length; k++) {
    
        if (selects[k].parentNode.getElementsByTagName("span")[0]) {
        
            selects[k].onfocus = function(){
            
                this.parentNode.getElementsByTagName("span")[0].style.visibility = "visible";
                
            }
            
            selects[k].onblur = function(){
            
                this.parentNode.getElementsByTagName("span")[0].style.visibility = "hidden";
                
            }
            
        }
        
    }
    
}

//current number of rows in the table
var currentRows = 9;
function create_public_user(){
    /** Do Not allow an under-rated user (rating < 6) to create a public group
     *
     * piyush.hari@gmail.com
     * February 13, 2007
     */
    if ('11.5' < 6) 
    
        alert("You do not have sufficient rating to create a public group. Bump up your rating to 6 to create a public group.");
    
    else {
    
        Modalbox.show('Create a Public neighBORROWhood', 'createPublicHoodtest.html', {
            width: 570,
            height: 250
        });
        
    }
    
}

/** This function will show/hide the password input field for pvt neighborrowhood
 * if the "Password Protected" checkbox is checked/unchecked
 *
 * piyush.hari@gmail.com
 * February 13,2007
 */
var passwordRow;
function show_hide_pvt_password(){
    //Show the Password field by doing an innerhtml to table
    
    var oTbody = document.getElementById("table_pvt_tbody");
    
    if (document.frm_create_user_private.password.checked == true) {
    
        currentRows++;
        
        //innerHTML is only read ONLY in a table element. So, use table DOM instead
        
        var oRow = document.createElement("TR");
        
        var oCell1 = document.createElement("TD");
        
        //oCell1.width = 155;
        
        oCell1.innerHTML = "Set a Password ";
        
        var oCell2 = document.createElement("TD");
        
        //oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_password_private' type='password' id='txt_password_private'/><span class=\"hint\">You can set a password to restrict membership to this neighBORROW-hood. Share the password via email or POST A HINT that will be known only by those whom you wish to join.<span class=\"hint-pointer\">&nbsp;</span></span>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        var exchangeRow = null;
        
        if (oTbody.rows.length >= 9) 
            exchangeRow = oTbody.rows[oTbody.rows.length - 4];
        
        oTbody.insertBefore(oRow, exchangeRow);
        
        //oTbody.appendChild(oRow);
        
        passwordRow = currentRows;
        
        
        
        //Show display hint checkbox if password protected is checked
        
        currentRows++;
        
        if (oTbody.rows.length >= 9) 
            exchangeRow = oTbody.rows[oTbody.rows.length - 4];
        
        var oRow_displayHint = document.createElement("TR");
        
        var oCell0_displayHint = document.createElement("TD");
        
        var oCell1_displayHint = document.createElement("TD");
        
        oCell1_displayHint.innerHTML = "<input type='checkbox' name='displayhint' value='1' onclick='show_hide_pvt_hint()'><font size='2'>&nbsp;Display password hint";
        
        oRow_displayHint.appendChild(oCell0_displayHint);
        
        oRow_displayHint.appendChild(oCell1_displayHint);
        
        //oTbody.appendChild(oRow_displayHint);
        
        oTbody.insertBefore(oRow_displayHint, exchangeRow);
        
        
        
        prepareInputsForHints();
        
    }
    
    else {
    
        passwordRow = oTbody.rows.length - 2;
        
        if (oTbody.rows.length > 10) 
            passwordRow = oTbody.rows.length - 5;
        
        
        
        if (passwordRow == 9) { // delete hint
            oTbody.deleteRow(passwordRow);
            
            passwordRow--;
            
        }
        
        
        
        //Delete the password field row.
        
        oTbody.deleteRow(passwordRow);
        
        passwordRow--;
        
        //Delete display hint checkbox if password protected is unchecked
        
        oTbody.deleteRow(passwordRow);
        
        passwordRow--;
        
    }
    
    
    
}
/** This function will show/hide the hint input field for pvt neighborrowhood
 * if the "Password Protected" checkbox is checked/unchecked
 *
 * piyush.hari@gmail.com
 * February 13,2007
 */
var hintRow = 0;
function show_hide_pvt_hint(){
    //Show the Password field by doing an innerhtml to table
    
    var oTbody = document.getElementById("table_pvt_tbody");
    
    if (document.frm_create_user_private.displayhint.checked == true) {
    
        currentRows++;
        
        //innerHTML is only read ONLY in a table element. So, use table DOM instead
        
        var oRow = document.createElement("TR");
        
        var oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Enter Hint";
        
        var oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_hint_private' type='text' id='txt_hint_private'/>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        var exchangeRow = null;
        
        if (oTbody.rows.length > 9) 
            exchangeRow = oTbody.rows[oTbody.rows.length - 4];
        
        oTbody.insertBefore(oRow, exchangeRow);
        
        //oTbody.appendChild(oRow);
        
        hintRow = currentRows;
        
        //		alert(hintRow);
    
    }
    
    else {
    
        //Delete the hint field row
        
        try {
        
            hintRow = oTbody.rows.length - 2;
            
            if (oTbody.rows.length > 10) 
                hintRow = oTbody.rows.length - 5;
            
            oTbody.deleteRow(hintRow);
            
            currentRows--;
            
            hintRow = null;
            
        } 
        
        catch (ex) {
        };
        
            }
    
}

var exchangeAvRow;
var exchangeBlockShown = true;
var exchangeAvRow = 9;
function toggleExchangeAv(showOrHide){
    //Show the Password field by doing an innerhtml to table
    
    var oTbody = document.getElementById("table_pvt_tbody");
    
    if (document.frm_create_user_private.group1[0].checked == true) {
    
        currentRows++;
        
        //innerHTML is only read ONLY in a table element. So, use table DOM instead
        
        var oRow = document.createElement("TR");
        
        var oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Exchange Venue 1";
        
        var oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_exchange_venue1' id='txt_exchange_venue1' rows='3'/><span class=\"hint\">Please list up to 3 suggested exchange venues or click the options for AUTOMATED EXCHANGE VENUE.<span class=\"hint-pointer\">&nbsp;</span></span>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        exchangeAvRow = currentRows;
        
        
        
        currentRows++;
        
        oRow = document.createElement("TR");
        
        oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "&nbsp;";
        
        oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<td><input type=\"checkbox\" name=\"autoVenue\" id=\"autoVenue\" onclick=\"toggleOtherVenue(this);\"/>&nbsp;Automated Exchange Venue<span class=\"hint\">Please click this option if there is only one exchange venue, and items cab be \"left\" at this venue automatically upon confirmation. Use this if you have a front desk, a drop spot, or some other place that your members will \"know automatically.\" <a href=\"mailto:info@neighborrow.com\">Contact us</a> with any questions.<span class=\"hint-pointer\">&nbsp;</span></span></td>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        
        
        
        
        currentRows++;
        
        //innerHTML is only read ONLY in a table element. So, use table DOM /instead
        
        oRow = document.createElement("TR");
        
        oRow.id = "exchangeVenue2";
        
        oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Exchange Venue 2 &nbsp;";
        
        oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_exchange_venue2' id='txt_exchange_venue2' rows='3'/>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        exchangeAvRow = currentRows;
        
        
        
        currentRows++;
        
        //innerHTML is only read ONLY in a table element. So, use table DOM /instead
        
        oRow = document.createElement("TR");
        
        oRow.id = "exchangeVenue3";
        
        oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Exchange Venue 3";
        
        oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_exchange_venue3' id='txt_exchange_venue3' rows='3'/>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        exchangeAvRow = currentRows;
        
        
        
        exchangeBlockShown = true;
        
        
        
        prepareInputsForHints();
        
    }
    
    else 
    
        if (document.frm_create_user_private.group1[1].checked == true) {
        
            //Delete the exchange venue
            
            //if(oTbody.rows.length>7)
            
            {
            
                oTbody.deleteRow(oTbody.rows.length - 1);
                
                oTbody.deleteRow(oTbody.rows.length - 1);
                
                oTbody.deleteRow(oTbody.rows.length - 1);
                
                oTbody.deleteRow(oTbody.rows.length - 1);
                
            }
            
        }
    
    
    
}

function toggleExchangeAv1(){
    //Show the Password field by doing an innerhtml to table
    
    var oTbody = document.getElementById("table_public_tbody");
    
    if (document.frm_create_user_public.group1[0].checked == true) {
    
        //innerHTML is only read ONLY in a table element. So, use
        
        //table DOM instead
        
        var oRow = document.createElement("TR");
        
        var oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Exchange Venue 1";
        
        var oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_exchange_venue1' id='txt_exchange_venue1' rows='3'/><span class=\"hint\">Please list up to 3 suggested exchange venues or click the options for AUTOMATED EXCHANGE VENUE.<span class=\"hint-pointer\">&nbsp;</span></span>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        
        
        oRow = document.createElement("TR");
        
        oCell1 = document.createElement("TD");
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "&nbsp;";
        
        oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<td><input type=\"checkbox\" name=\"autoVenue\" id=\"autoVenue\" onclick=\"toggleOtherVenue(this);\"/>&nbsp;Automated Exchange Venue<span class=\"hint\">Please click this option if there is only one exchange venue, and items cab be \"left\" at this venue automatically upon confirmation. Use this if you have a front desk, a drop spot, or some other place that your members will \"know automatically.\" <a href=\"mailto:info@neighborrow.com\">Contact us</a> with any questions.<span class=\"hint-pointer\">&nbsp;</span></span></td>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        
        
        //innerHTML is only read ONLY in a table element. So, use table DOM /instead
        
        oRow = document.createElement("TR");
        
        oCell1 = document.createElement("TD");
        
        oCell.id = "exchangeVenue2";
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Exchange Venue 2 &nbsp;";
        
        oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_exchange_venue2' id='txt_exchange_venue2' rows='3'/>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        
        
        //innerHTML is only read ONLY in a table element. So, use table DOM /instead
        
        oRow = document.createElement("TR");
        
        oCell1 = document.createElement("TD");
        
        oCell.id = "exchangeVenue3";
        
        oCell1.width = 155;
        
        oCell1.innerHTML = "Exchange Venue 3";
        
        oCell2 = document.createElement("TD");
        
        oCell2.width = 196;
        
        oCell2.innerHTML = "<input name='txt_exchange_venue3' id='txt_exchange_venue3' rows='3'/>";
        
        oRow.appendChild(oCell1);
        
        oRow.appendChild(oCell2);
        
        oTbody.appendChild(oRow);
        
        
        
        prepareInputsForHints();
        
    }
    
    else 
    
        if (document.frm_create_user_public.group1[1].checked == true) {
        
            //Delete the exchange venue
            
            if (oTbody.rows.length > 7) {
            
                oTbody.deleteRow(7);
                
                oTbody.deleteRow(6);
                
                oTbody.deleteRow(5);
                
            }
            
        }
    
}

function init(){
    exchangeAvRow = 0;
    
    exchangeBlockShown = true;
    
    exchangeAvRow = 9;
    
    hintRow = 0;
    
    passwordRow = 0;
    
    currentRows = 9;
    
}

var zipChecked = false;
var oldZip = "";
function privateZipOnBlur(){
    if (oldZip != $('txt_zip_private').value) 
        zipChecked = false;
    
}
function enabledSubmitButton(){
    if ($('create_private_button')) 
        $('create_private_button').removeAttribute("disabled");
    
    $('checkZipResult').style.display = "none";
    
    $('table_pvt').style.visibility = "visible";
    
    $('table_pvt').style.position = "relative";
    
}
function checkPrivateZipCode(){
    var oldZip = zip = $('txt_zip_private').value;
    
    //$('create_private_button').disabled = true;
    
    if (zipChecked) 
        return true;
    
    if (zip == "") 
        return true;
    
    else {
    
        //$('create_private_button').disabled = false;
        
        var url = "ajax/checkzip.php?zip=" + zip;
        
        new Ajax.Request(url, {
            method: 'get',
            onComplete: function(res){
            
                if (res.responseText == "") {
                
                    $('frm_create_user_private').submit();
                    
                    //Modalbox.hide();
                
                }
                
                else {
                
                    $('checkZipResult').innerHTML = res.responseText;
                    
                    $('checkZipResult').style.display = "block";
                    
                    $('errorMessage').innerHTML = '';
                    
                    $('table_pvt').style.visibility = "hidden";
                    
                    $('table_pvt').style.position = "absolute";
                    
                    
                    
                    //$('create_private_button').value = "Continue to Create neighBORROWhood";
                    
                    zipChecked = true;
                    $('create_private_button').onclick = function(){
                        $('frm_create_user_private').submit();
                    }
                    
                }
                
            }
        });
        
    }
    
    return false;
    
}

var zipPublicChecked = false;
function checkPublicZipCode(){
    var oldZip = zip = $('txt_zip_public').value;
    
    if (zipPublicChecked) 
        return true;
    
    if (zip == "") 
        return true;
    
    else {
    
        var url = "ajax/checkzip.php?zip=" + zip;
        
        new Ajax.Request(url, {
            method: 'get',
            onComplete: function(res){
            
                if (res.responseText == "") {
                
                    $('frm_create_user_public').submit();
                    
                }
                
                else {
                
                    $('checkZipResult').innerHTML = res.responseText;
                    
                    $('checkZipResult').style.display = "block";
                    
                    $('errorMessage').innerHTML = '';
                    
                    $('table_public').style.visibility = "hidden";
                    
                    $('table_public').style.position = "absolute";
                    
                    zipPublicChecked = true;
                    
                }
                
            }
        });
        
    }
    
    return false;
    
}
function clearErrorMessage(){
    $('checkZipResult').style.display = "none";
    $('checkZipResult').innerHTML = "";
}
function checkEduDomain(){
    clearErrorMessage();
    
    var isCampusChecked = $('is_campus').checked;
    
    if (!isCampusChecked) {
        checkPublicZipCode();
        return;
    }
    
    var url = "ajax/checkEduDomain.php";
    
    new Ajax.Request(url, {
        method: 'get',
        onComplete: function(res){
        
            if (res.responseText == "") {
            
                checkPublicZipCode();
                
            }
            else {
            
                $('errorMessage').innerHTML = 'To create PUBLIC neighBORROW-hood you should have email in edu domain.';
                
            }
            
        }
    });
}

function toggleOtherVenue(check){
    if (check.checked) {
    
        $("exchangeVenue2").style.display = "none";
        
        $("exchangeVenue3").style.display = "none";
        
    }
    
    else {
    
        $("exchangeVenue2").style.display = "";
        
        $("exchangeVenue3").style.display = "";
        
    }
    
}

function showCreateHoodSuccessMessage(hoodID){
    Modalbox.show("Create a neighBORROW-hood", "/ajax/messages/message.php?createdHoodID=" + hoodID, {
        width: 600,
        height: 200
    });
    
}

function generateLink(){
    hood = $('neighborrowhoodID');
    link = $('link_invitation');
    if (hood && link) {
        xmlhttp = init();
        hoodID = hood.value;
        page = "/idea/invite.php?generateID=" + hoodID;
        link.innerHTML = "<font color='red'>Please Wait</font>";
        sendRequest2(page, link, xmlhttp);
    }
}
function sendRequest2(page, obj, xmlhttp){
    xmlhttp.open("GET", page);
    xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            password = xmlhttp.responseText;
            link = "http://www.neighborrow.com/idea/invite.php?m=" + password;
            link = "<font style='font-size: 20px; color: green;'>" + link + "</font>";
            obj.innerHTML = link;
        }
    }
    
    xmlhttp.send(null);
}
function init(){
    var xmlhttp = false;
    
    //Check if we are using IE
    try {
        //If the javascript version is greater than 5
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (E) {
            xmlhttp = false;
        }
    }
    
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}
function validate(){
    xmlhttp = init();
    obj = $('emails');
    result = $('result');
    tickets = $('tickets');
    hood = $('hoodID');
    hoodID = hood.value;
    if (obj && result && hood) {
        email = obj.value;
        emails = email.split(",");
        result.innerHTML = "<font color='red'>Please Wait</font><img src='imgs/ajax-loader.gif'/>";
        sendRequest(hoodID, result, tickets, emails, xmlhttp);
    }
}
var currValue = 0;
function sendRequest(hoodID, obj, obj2, emails, xmlhttp){
    var page = "/idea/invite.php?email=";
    var email = trim(emails[parseInt(currValue)]);
    if ((email != '') && (email.match(/^[a-zA-Z0-9]+[a-zA-Z0-9.\-_]*@[a-zA-Z0-9\-._]*[.]+[a-zA-Z0-9]{2,4}$/))) {
    
        page += email + "&hoodID=" + hoodID;
        
        currValue++;
        if (currValue < emails.length) {
            sendRequest(hoodID, obj, obj2, emails, xmlhttp);
        }
        else {
            obj.innerHTML = '';
            ta = $('emails');
            ta.value = '';
        }
        xmlhttp = init();
        xmlhttp.open("GET", page);
        xmlhttp.onreadystatechange = function(){
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                response = xmlhttp.responseText;
                values = response.split("!");
                obj.innerHTML = values[0];
                obj2.innerHTML = values[1] + " tickets left";
                currValue++;
                if ((currValue < emails.length) && (values[1] > 0)) {
                    xmlhttp = init();
                    sendRequest(hoodID, obj, obj2, emails, xmlhttp);
                }
            }
        }
        xmlhttp.send(null);
    }
    else {
        currValue++;
        if (currValue < emails.length) {
            xmlhttp = init();
            sendRequest(hoodID, obj, obj2, emails, xmlhttp);
        }
        else {
            obj.innerHTML = '';
            ta = $('emails');
            ta.value = '';
        }
    }
}
function trim(s){
    return (s != null) ? rtrim(ltrim(s)) : '';
}
function ltrim(s){
    return s.replace(/^\s+/, '');
}
function rtrim(s){
    return s.replace(/\s+$/, '');
}

var divs = new Array('inboxDiv', 'borrowedItemsDiv', 'neighborrowhoodMembershipDiv', 'requestsDiv', 'expectingItemsDiv', 'returnedItemsDiv');
function hideAll(first){
    for (i = 0; i < divs.length; i++) {
    
        document.getElementById(divs[i]).style.opacity = 0.01;
        document.getElementById(divs[i]).style.filter = "alpha(opacity=1)";
        document.getElementById(divs[i]).style.display = "none";
    }
    
    var tds = document.getElementById("tabtable").getElementsByTagName("td");
    
    for (i = 0; i < tds.length; i++) {
    
        tds[i].className = "";
        
    }
    
    if (first) 
        tds[0].className = "selection";
    
}
function showHide(id, a){
    hideAll(a == null);
    
    if (a != null) {
    
        var el = a.parentNode;
        
        while (el && el.tagName.toLowerCase() != "td") 
            el = el.parentNode;
        
        el.className = "selection";
        
    }
    
    document.getElementById(divs[id]).style.display = 'block';
    
    Effect.Fade(divs[id], {
        duration: 2.0,
        from: 0,
        to: 1
    });
    
    
}