function addToFriends() {var notify = document.getElementById("notify"); var msg = ""; notify.style.display = "block"; notify.innerHTML = "Processing request..."; var callback = {success: function(o) {if (o.status == 200) {var response = o.responseText; if (response.indexOf("not_logged_in") != -1) {msg = "You are not logged in yet. Please log in first.";} else if (response.indexOf("add_yourself") != -1) {msg = "You can't add yourself as a friend.";} else if (response.indexOf("already_exists") != -1) {msg = "This user already added to your friends list.";} else if (response.indexOf("add_later") != -1) {msg = "User will be notified about your request to add him(her).";} else if (response.indexOf("add_now") != -1) {msg = "Friend has been added.";} else {msg = "Sorry, we've experienced some problems on server. Please try again later.";} notify.innerHTML = msg;} else {notify.innerHTML = "LOADING FAILED: There was a problem with the request.";}}, failure: function(o) {notify.innerHTML = "LOADING FAILED: There was a problem with the request.";}}; httpRequest = YAHOO.util.Connect.asyncRequest('GET', baseUrl + "?" + params, callback);}

/**
 * function for tab selecting and checking for changes
 *
 * @param string name  tab name
 * @param bool   check true - for check, false for not checking for changes
 * @param bool   nHide true - not hide message div (that displays errors or 'succesfully modified')
 */
function selectTab(name, check, nHide) {if (check) {if (isChanged) {var answer = confirm('You made some changes on following tabs:\n\'Name\', \'Basic Info\', \'Interests & Personality\' or \'Background & Lifestyle\'.\nDo you want to save changes?'); if (answer) {document.nameBscinfIapBal.elements['t'].value = name; document.nameBscinfIapBal.submit();} else {isChanged = false; window.location.href = baseUrl + name;}} else {window.location.href = baseUrl + name;}} else {for (i = 0; i < tabs.length; i++) {document.getElementById("tab_" + tabs[i]).style.display = 'none'; document.getElementById("tab_" + tabs[i] + "_top").className = 'iTopTab';} document.getElementById("tab_" + name).style.display = 'inline'; document.getElementById("tab_" + name + "_top").className = 'aTopTab'; document.nameBscinfIapBal.elements['t'].value = name; if (!nHide) {document.getElementById('message').style.display = 'none';}}}

//
// SCHOOL FUNCTIONS
//
function setSchlIdName(id, name) {document.usrSchlAdd.elements['id'].value = id; document.getElementById("schlName").innerHTML = name;}

function onSchlSearch() {var status = true; var msg = ""; var countryEl = document.schlSearch.elements['search[country_id]']; var name = document.schlSearch.elements['search[name]'].value; var country = countryEl.options[countryEl.selectedIndex].value; if (country == null || country == "") {msg += "Please select a country."; status = false;} if (status) {return true;} else {alert(msg); return false;}}

function onUsrSchlAdd() {var status = true; var msg = ""; var id = document.usrSchlAdd.elements['id'].value; var stat0 = document.usrSchlAdd.elements['schlAdd[stud_status]'][0].checked; var stat1 = document.usrSchlAdd.elements['schlAdd[stud_status]'][1].checked; var maj = document.usrSchlAdd.elements['schlAdd[major]'].value; var min = document.usrSchlAdd.elements['schlAdd[minor]'].value; if (id == null || id == "") {msg += "Please select a school you want to add.\n"; status = false;} if (!stat0 && !stat1) {msg += "Please select a student status.\n"; status = false;} if (maj == null || maj == "") {msg += "Please enter a major/concentration.\n"; status = false;} if (min == null || min == "") {msg += "Please enter a minor."; status = false;} if (status) {return true;} else {alert(msg); return false;}}

function onSchlAdd() {var status = true; var msg = ""; var name = document.schlAdd.elements['schl[name]'].value; var city = document.schlAdd.elements['schl[city]'].value; var stat0 = document.schlAdd.elements['schl[stud_status]'][0].checked; var stat1 = document.schlAdd.elements['schl[stud_status]'][1].checked; var maj = document.schlAdd.elements['schl[major]'].value; var min = document.schlAdd.elements['schl[minor]'].value; if (name == null || name == "") {msg += "Please enter a school name.\n"; status = false;} if (city == null || city == "") {msg += "Please enter a city name.\n"; status = false;} if (!stat0 && !stat1) {msg += "Please select a student status.\n"; status = false;} if (maj == null || maj == "") {msg += "Please enter a major/concentration.\n"; status = false;}
if (min == null || min == "") {msg += "Please enter a minor.\n"; status = false;} if (status) {return true;} else {alert(msg); return false;}}

//
// COMPANY FUNCTIONS
//
function setCmpnIdName(id, name) {document.usrCmpnAdd.elements['id'].value = id; document.getElementById("cmpnName").innerHTML = name;}

function onUsrCmpnAdd() {var status = true; var msg = ""; var id = document.usrCmpnAdd.elements['id'].value; var dEmployed = document.usrCmpnAdd.elements['cmpnAdd[dates_employed]'].value; var position = document.usrCmpnAdd.elements['cmpnAdd[position]'].value; if (id == null || id == "") {msg += "Please select a company to add.\n"; status = false;} if (dEmployed == null || dEmployed == "") {msg += "Please enter date employed.\n"; status = false;} if (position == null || position == "") {msg += "Please enter a title/position."; status = false;} if (status) {return true;} else {alert(msg); return false;}}

function onCmpnAdd(isModify) {var status = true; var msg = ""; if (!isModify) {var stateEl = document.cmpnAdd.elements['cmpn[state_id]']; var countryEl = document.cmpnAdd.elements['cmpn[country_id]']; var state = stateEl.options[stateEl.selectedIndex].value; var country = countryEl.options[countryEl.selectedIndex].value;} var name = document.cmpnAdd.elements['cmpn[name]'].value; var city = document.cmpnAdd.elements['cmpn[city]'].value; var dEmployed = document.cmpnAdd.elements['cmpn[dates_employed]'].value; var position = document.cmpnAdd.elements['cmpn[position]'].value; if (name == null || name == "") {msg += "Please enter a company name.\n"; status = false;} if (city == null || city == "") {msg += "Please enter a city name.\n"; status = false;} if (!isModify) {if (country == null || country == "") {msg += "Please select a country.\n"; status = false;} if (state == null || state == "") {msg += "Please select a state.\n"; status = false;}} if (dEmployed == null || dEmployed == "") {msg += "Please enter date employed.\n"; status = false;} if (position == null || position == "") {msg += "Please enter a title/position."; status = false;} if (status) {return true;} else {alert(msg); return false;}}

function onCmpnSearch() {var status = true; var msg = ""; var countryEl = document.cmpnSearch.elements['search[country_id]']; var name = document.cmpnSearch.elements['search[name]'].value; var city = document.cmpnSearch.elements['search[city]'].value; var country = countryEl.options[countryEl.selectedIndex].value; if (name == null || name == "" || name.length < 2) {msg += "Please enter a company name (at least two letters).\n"; status = false;} if (city == null || city == "" || city.length < 1) {msg += "Please enter a city name (at least one letters).\n"; status = false;} if (country == null || country == "") {msg += "Please select a country."; status = false;} if (status) {return true;} else {alert(msg); return false;}}

//
// BOOKMARK FUNCTIONS
//
function onBkmrkAdd() {var status = true; var msg = ""; var caption = document.bkmrkAdd.elements['bkmrk[caption]'].value; var link = document.bkmrkAdd.elements['bkmrk[link]'].value; if (caption == null || caption == "") {msg += "Please enter caption.\n"; status = false;} if (link == null || link == "") {msg += "Please enter link."; status = false;} if (status) {return true;} else {alert(msg); return false;}}