<!--

//	AJAX function for elements
function doAjax (url,id) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (x) {
    x.onreadystatechange = function() {
	    if (x.readyState == 4 && x.status == 200) {
	      el = document.getElementById(id);
	      el.innerHTML = x.responseText;
	    }
	  }
    x.open("GET", url, true);
    x.send(null);
  }
  return true;
}

function doParentAjax (url,id) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (x) {
    x.onreadystatechange = function() {
	    if (x.readyState == 4 && x.status == 200) {
	      el = parent.document.getElementById(id);
	      el.innerHTML = x.responseText;
	    }
	  }
    x.open("GET", url, true);
    x.send(null);
  }
  return true;
}

//	AJAX function for text fields (value attribute)
function doAjax_value (url,id) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (x) {
    x.onreadystatechange = function() {
	    if (x.readyState == 4 && x.status == 200) {
	      el = document.getElementById(id);
	      el.value = x.responseText;
	    }
	  }
    x.open("GET", url, true);
    x.send(null);
  }
  return true;
}

// AJAX function
function ajaxCountrySelect (url,id) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (x) {
    x.onreadystatechange = function() {
	    if (x.readyState == 4 && x.status == 200) {
	      el = document.getElementById(id);
	      //el.value = x.responseText;
	      //alert(x.responseText);
	      if (x.responseText == 'Canada') {
	      	document.getElementById('country_canada').style.border='1px solid #666666';
	      	document.getElementById('country_usa').style.border='';
	      	doAjax('/register.php?setRegisterCountry=CAN','country_sel_canada');
	      }
	    }
	  }
    x.open("GET", url, true);
    x.send(null);
  }
  return true;
}



document.getElementsByClassName = function(clsName){
    var retVal = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++){
        if(elements[i].className.indexOf(" ") >= 0){
            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++){
                if(classes[j] == clsName)
                    retVal.push(elements[i]);
            }
        }
        else if(elements[i].className == clsName)
            retVal.push(elements[i]);
    }
    return retVal;
}




//	CALLED FROM MODAL OVERLAY "change region" LINK
//	GLOBALLY. IF THE PAGE IS BROWSING JOBS OR THE LIKE
//	THE PAGE NEEDS TO BE RELOADED CURRENTLY AS THEY
//	ARE NOT AJAX. THIS COULD/SHOULD BE MODIFIED IN
//	FUTURE RELEASES WITH A SIMPLE CALL TO doAjax().
function setRegion (id) {
  var curl = window.location.href;
  doAjax('/change_region_modal.php?setUserRegionTitle='+id,'user_region_name');
  if (curl.indexOf('browsejobs') > 0) {
  	setTimeout('window.location=window.location.href;',1000);
  }
  return true;
}




//
//		USER PROFILE - UPDATE CONTACT INFORMATION
//
function saveContactInfo () {
  var address = document.getElementById('mycurrent_address').value;
  var city = document.getElementById('mycurrent_city').value;
  var province = document.getElementById('mycurrent_province').value;
  var cell_number = document.getElementById('mycurrent_cn1').value+'-'+document.getElementById('mycurrent_cn2').value+'-'+document.getElementById('mycurrent_cn3').value;
  if (location.href.match('settings/0/1/')!=null) {
  	
  //if (!ereg("settings/0/1/",location.href)) {
    document.getElementById('myprofile_address').innerHTML=address;
    document.getElementById('myprofile_city').innerHTML=city;
    document.getElementById('mycurrent_province').innerHTML=province;
    document.getElementById('myprofile_cellnum').innerHTML=cell_number;
  }


  document.getElementById('update_message').style.display='block';
  doAjax('/safe_redir.php?saveContactInfo=1&a='+address+'&c='+city+'&p='+province+'&cn='+cell_number,'update_message');
  MOOdalBox.close();
  return true;
}



//
//		USER PROFILE - GENERAL SETTINGS (change email address)
//
function updateUserEmailAddress (email) {
  //document.getElementById('usr_email_address').innerHTML='<input type=text id="new_email_value" value="'+email+'" style="width:250px;"> <input type="button" value="Save" onclick="setEmailAddress();">';
  //document.getElementById('new_status_msg').focus();
  //Modalbox.show('/settings.updateUserEmailAddress.inc', {title: 'Update Contact Information', height: 400, width: 650});
  MOOdalBox.open('/settings.updateUserEmailAddress.inc','Update Contact Information','650 400');
  return true;
}
function setEmailAddress () {
  var eml = document.getElementById('new_email_value').value;
  
  if (eml.length == 0) {
    document.getElementById('email_status').style.display='block';
    document.getElementById('email_status').innerHTML='A blank e-mail address... har har.. original... try again. No really..';
    return false;
  }
  if (!validateEmail(eml)) {
    document.getElementById('email_status').style.display='block';
    document.getElementById('email_status').innerHTML='Try a valid email address...we promise not to send you SPAM..';
    return false;
  }
  
  
  //document.getElementById('usr_email_address').innerHTML='<span onclick="updateUserEmailAddress(\''+eml+'\');">'+eml+'</span>';
  //doAjax('/safe_redir.php?setEmailAddress='+eml,'generalSettings_debug');
  document.getElementById('myemail_subtxt').style.display='none';
  doAjax('/safe_redir.php?setEmailAddress='+eml,'parentemail_status');
  document.getElementById('parentemail_status').style.display='block';
  MOOdalBox.close();
  return true;
}

function deleteIdleTimeAccount () {
  MOOdalBox.open('/settings.deleteIdleTimeAccount.inc','Delete My Account','480 235');
  return true;
}


function popChangePassword () {
	MOOdalBox.open('/settings.changePassword.inc','Change My Password','480 235');
	return true;
}
function verifyOldPassword (pwd) {
	doAjax('/safe_redir.php?verifyOldPassword='+pwd,'error_op');
	return true;
}
function verifyPasswordMatch (pwd1,pwd2) {
  if (pwd1 == pwd2) {
    document.getElementById('error_pr').innerHTML='<img src="/images/check2.png" />';
  } else {
    document.getElementById('error_pr').innerHTML='<img src="/images/forbidden24.png" />';
    //document.getElementById('error_pr').innerHTML='P1:'+pwd1+' - P2:'+pwd2;
  }
  return true;
}
function modalChangePassword () {
  document.getElementById('password_errors').style.display='none';

  if (document.getElementById('password_old').value.length == 0) {
    document.getElementById('password_errors').style.display='block';
    document.getElementById('password_errors').innerHTML='<b>old password</b> must have a value!';
    return false;
  }
  if (document.getElementById('password_new').value.length == 0) {
    document.getElementById('password_errors').style.display='block';
    document.getElementById('password_errors').innerHTML='<b>new password</b> must have a value!';
    return false;
  }
  if (document.getElementById('password_repeat').value.length == 0) {
    document.getElementById('password_errors').style.display='block';
    document.getElementById('password_errors').innerHTML='password <b>repeat</b> must have a value!';
    return false;
  }

  doAjax('/safe_redir.php?changePasswordSys=1&op='+document.getElementById('password_old').value+'&p1='+document.getElementById('password_new').value+'&p2='+document.getElementById('password_repeat').value,'password_status');
  document.getElementById('mypassword_subtxt').style.display='none';
  document.getElementById('password_status').style.display='block';
  MOOdalBox.close();
  return true;
}

function findPasswordStrength (pwd) {

  var minimum = 4;
  var fair = 6;
  var strength_label = Array( 'Your password is too short', 'Weak password. Keep going...', 'Fair password, could be stronger though.', 'Medium strength password.', 'Nice strong password!', 'Wow! Make sure you can remember it!' );

  if (!pwd) {
  	var pwd = document.getElementById('password_new').value.toString();
  }
  if (!pwd) {
  	return false;
  }

  var strength = 0;
  if (pwd.length >= minimum) {
    strength = 1;
    if (pwd.length >= fair) {
      strength++;
    }
    if(/\d+/.test(pwd)){
      strength++;
    }
    if(/\W+/.test(pwd)){
      strength++;
    }
    if(/[a-z]+/.test(pwd) && /[A-Z]+/.test(pwd)){
      strength++;
    }
  }
  document.getElementById('password_strength').innerHTML = strength_label[strength];
  if (strength >= 2) {
    document.getElementById('error_np').innerHTML='<img src="/images/check2.png" />';
  } else {
    document.getElementById('error_np').innerHTML='';
  }
}






function setAsJobThumbnail (id) {
  document.getElementById('jobthumbnail').innerHTML='<img src="/images/indicator_blue_large.gif">';
  doAjax('/post_an_item.beta.php?makeProfilePicJobThumbnail='+id,'jobthumbnail');
  //Modalbox.hide();
  MOOdalBox.close();
  return true;
}


//
//	VIEW JOB FUNCTIONS
//
//
function editJobTitle (id) {
	//doAjax('/safe_redir.php?editJobTitle='+id,'job_title_cont');
	Modalbox.show('/view.job.editTitle.inc?id='+id, {title: 'Edit Job Title', height: 235, width: 480});
	//document.getElementById('job_title_cont').innerHTML='<input type="text" style="width:450px;background-color:#e5f2fa;border:1px solid #8f8fcf;font-size:16px;">';
	return true;
}
function saveNewJobTitle (id) {
  document.getElementById('title_status').style.display='none';
  var raw_title = document.getElementById('edit_job_title').value;
  var min_length = 5;

  if (raw_title.length == 0) {
    document.getElementById('title_status').style.display='block';
    document.getElementById('title_status').innerHTML='Your new job title cannot be left blank. Enter a title and try again!';
    return false;
  }
  if (raw_title.length < min_length) {
    document.getElementById('title_status').style.display='block';
    document.getElementById('title_status').innerHTML='Your new job title must be greater than '+min_length+' characters. Please try again!';
    return false;
  }


  var new_title = urlencode(escape(raw_title));
  //alert(new_title);
  doAjax('/safe_redir.php?saveNewJobTitle='+id+'&jt='+new_title,'job_title_cont');
  Modalbox.hide();
  new Effect.Highlight('job_title_cont', { startcolor: '#ffff99', endcolor: '#ffffff' });
  return true;
}


function bidInformation (id,jobid) {
	//document.getElementById('bid_thinger').style.display='block';
	//doAjax('/view_job.php?viewBidInformation='+id+'&job_id='+jobid,'bid_thinger_information');
	//Modalbox.show('/view_job.view_bid_modal.inc?id='+id+'&job_id='+jobid, {title: 'View Bid', height: 450, width: 600});
	MOOdalBox.open('/view_job.view_bid_modal.inc?id='+id+'&job_id='+jobid,'View Bid','600 450');
	return true;
}
function updateBidStatus (id,jobid) {
  var radio_accept = document.getElementById('radio_accept');
  var radio_reject = document.getElementById('radio_reject');
  var bid_message = urlencode(escape(document.getElementById('statusMessage').value));
  
  if (radio_accept.checked == true && radio_reject.checked == false) {

    //	ACCEPTED
    var bid_status = 'accepted';
  } else if (radio_accept.checked == false && radio_reject.checked == true) {

    //	REJECTED
    var bid_status = 'rejected';
  } else {
    //alert('There was an error processing your');
  }
  
  doAjax('/safe_redir.php?updateJobBidStatus=1&id='+id+'&jobid='+jobid+'&m='+bid_message+'&s='+bid_status,'job_bid_table');
  MOOdalBox.close();
  return true;
}

function respondToQuestion (qid,jid) {
  Modalbox.show('/view_job.questionResponder.inc?id='+qid+'&job_id='+jid, {title: 'Repond to question', height: 450, width: 600});
  return true;
}
function sendQuestionResponse (qid,jid,response) {
  var myResponse = urlencode(escape(response));
  doAjax('/safe_redir.php?sendQuestionResponse=1&qid='+qid+'&jid='+jid+'&r='+myResponse,'questionsContainer');
  Modalbox.hide();
  return true;
}




//
//		PROMOTE YOUR JOB
//		Called when the user has posted a job and purchased credits at the same time.. 
//		Used to promote the job if the user wants.
//
function sendJobPromotionEmail (jobid) {
  var email_list = document.getElementById('promoteEmail').value;
  if (email_list.length == 0) {
    alert('You need to enter some emails to continue! (ERROR CHECKING)');
    return false;
  }

  //print_r(x);

  var x = explode(",",email_list);
  var error = '';
  for (var i in x) {
    if (validateEmail(trim(x[i]))) {
      var email = trim(x[i]);
      document.getElementById('email_send_status').style.display='block';
      document.getElementById('email_send_status').innerHTML='Sending promotional email...';
      doAjax('/safe_redir.php?sendJobPromotionEmail=1&jobid='+jobid+'&e='+email,'email_send_status');
    }
  }

  var html_out = '<ul id="promoteColumn">';
	html_out+='  <li style="background-color:#D9ECF2;width:550px;"><strong>Your job has been promoted!</strong></li>';
  html_out+='  <li style="font-size:11px;">';
  html_out+='    We have sent a promotional email to your friends! If you forgot a friend, you can add another friend to your promotion list and re-send another promotion!';
  html_out+='    <div id="email_send_status" style="display:none;margin-top:5px;margin-left:5px;margin-bottom:10px;"></div>';
  html_out+='  </li>';
  html_out+='  <li>';
  html_out+='    <form action="" id="promoteJobForm" name="promoteJobForm">';
  html_out+='      <textarea id="promoteEmail" name="promoteEmails"></textarea>';
  html_out+='    </form>';
  html_out+='  </li>';
  html_out+='  <li>';
  html_out+='    <div class="buttonwrapper" style="float:left;margin:0 0 10px 495px;">';
  html_out+='      <!-- <a class="ovalbutton" onclick="return buyCrFrmChk();" href="javascript://"><span>Next Step</span></a> -->';
  html_out+='      <a class="boldbuttons" onclick="return sendJobPromotionEmail(\''+jobid+'\');" href="javascript://"><span>Send</span></a>';
  html_out+='    </div><!-- closing buttonWrapper -->';
  html_out+='  </li>';
  html_out+='</ul>';

  document.getElementById('promoteColumn').innerHTML=html_out;
  return true;
}




//
//	VIEW JOB FUNCTIONS (RECOMMENDATIONS)
//
//
function selectRecType (type,user_id) {
	var html_out = '';
  document.getElementById('recommendation_type_div').style.display='block';
/*
  new Effect.Fade(
    'recommendation_type_div', {
      duration:0.2,
      afterFinish: function (obj) {
				doAjax('/safe_redir.php?selectRecType='+type+'&user_id='+user_id,'recommendation_type_div');
        new Effect.Appear('recommendation_type_div', {delay:0.2,duration:0.2})
      }
    }
  )
*/

  doAjax('/safe_redir.php?selectRecType='+type+'&user_id='+user_id,'recommendation_type_div');
	return true;
}

function saveRecommendationOff(user_id) {

  //	RECOMMENDATION TYPE
  var rec_type_c = document.getElementById('rec_type_c').checked;
  var rec_type_s = document.getElementById('rec_type_s').checked;
  var rec_type_b = document.getElementById('rec_type_b').checked;

  //	CHECKBOXES
  var recOpt_G = document.getElementById('recOpt_G').checked;
  var recOpt_P = document.getElementById('recOpt_P').checked;
  var recOpt_E = document.getElementById('recOpt_E').checked;
  var recOpt_GV = document.getElementById('recOpt_GV').checked;
  var recOpt_OT = document.getElementById('recOpt_OT').checked;
  var recOpt_HI = document.getElementById('recOpt_HI').checked;
  var recOpt_CR = document.getElementById('recOpt_CR').checked;
  var message = document.getElementById('recommendation_msg').value;
  var message = urlencode(escape(message));
  var name = document.getElementById('rec_name').value;
  var email = document.getElementById('rec_email').value;
  
  
  
  if (rec_type_c == true && rec_type_s == false && rec_type_b == false) {
    var recommendation_type = 'C';
  }
  if (rec_type_c == false && rec_type_s == true && rec_type_b == false) {
    var recommendation_type = 'S';
  }
  if (rec_type_c == false && rec_type_s == false && rec_type_b == true) {
    var recommendation_type = 'B';
  }

  if (recOpt_G == true) {
    var option_G = 'Y';
  } else {
    var option_G = 'N';
  }
  if (recOpt_P == true) {
    var option_P = 'Y';
  } else {
    var option_P = 'N';
  }
  if (recOpt_E == true) {
    var option_E = 'Y';
  } else {
    var option_E = 'N';
  }
  if (recOpt_GV == true) {
    var option_GV = 'Y';
  } else {
    var option_GV = 'N';
  }
  if (recOpt_OT == true) {
    var option_OT = 'Y';
  } else {
    var option_OT = 'N';
  }
  if (recOpt_HI == true) {
    var option_HI = 'Y';
  } else {
    var option_HI = 'N';
  }
  if (recOpt_CR == true) {
    var option_CR = 'Y';
  } else {
    var option_CR = 'N';
  }

  
 doAjax('/safe_redir.php?saveRecommendation='+user_id+'&rec_type='+recommendation_type+'&m='+message+'&o_G='+option_G+'&o_P='+option_P+'&o_E='+option_E+'&o_GV='+option_GV+'&o_OT='+option_OT+'&o_HI='+option_HI+'&o_CR='+option_CR+'&rn='+name+'&re='+email,'recommendation_div_vj');
  doAjax('/safe_redir.php?viewJob_updateRecommendations='+user_id,'viewJobUserRecommendations');
  
  MOOdalBox.close();
  //new Effect.Highlight('recommendation_div_vj', { startcolor: '#ffff99', endcolor: '#ffffff' });
  return true;
}
function saveRecommendationOn(user_id){

  //	RECOMMENDATION TYPE
  var rec_type_c = document.getElementById('rec_type_c').checked;
  var rec_type_s = document.getElementById('rec_type_s').checked;
  var rec_type_b = document.getElementById('rec_type_b').checked;

  //	CHECKBOXES
  var recOpt_G = document.getElementById('recOpt_G').checked;
  var recOpt_P = document.getElementById('recOpt_P').checked;
  var recOpt_E = document.getElementById('recOpt_E').checked;
  var recOpt_GV = document.getElementById('recOpt_GV').checked;
  var recOpt_OT = document.getElementById('recOpt_OT').checked;
  var recOpt_HI = document.getElementById('recOpt_HI').checked;
  var recOpt_CR = document.getElementById('recOpt_CR').checked;
  var message = document.getElementById('recommendation_msg').value;
  var message = urlencode(escape(message)); 
  
  
  if (rec_type_c == true && rec_type_s == false && rec_type_b == false) {
    var recommendation_type = 'C';
  }
  if (rec_type_c == false && rec_type_s == true && rec_type_b == false) {
    var recommendation_type = 'S';
  }
  if (rec_type_c == false && rec_type_s == false && rec_type_b == true) {
    var recommendation_type = 'B';
  }

  if (recOpt_G == true) {
    var option_G = 'Y';
  } else {
    var option_G = 'N';
  }
  if (recOpt_P == true) {
    var option_P = 'Y';
  } else {
    var option_P = 'N';
  }
  if (recOpt_E == true) {
    var option_E = 'Y';
  } else {
    var option_E = 'N';
  }
  if (recOpt_GV == true) {
    var option_GV = 'Y';
  } else {
    var option_GV = 'N';
  }
  if (recOpt_OT == true) {
    var option_OT = 'Y';
  } else {
    var option_OT = 'N';
  }
  if (recOpt_HI == true) {
    var option_HI = 'Y';
  } else {
    var option_HI = 'N';
  }
  if (recOpt_CR == true) {
    var option_CR = 'Y';
  } else {
    var option_CR = 'N';
  }

  
 doAjax('/safe_redir.php?saveRecommendation='+user_id+'&rec_type='+recommendation_type+'&m='+message+'&o_G='+option_G+'&o_P='+option_P+'&o_E='+option_E+'&o_GV='+option_GV+'&o_OT='+option_OT+'&o_HI='+option_HI+'&o_CR='+option_CR,'recommendation_div_vj');
  doAjax('/safe_redir.php?viewJob_updateRecommendations='+user_id,'viewJobUserRecommendations');
  
  MOOdalBox.close();
  //new Effect.Highlight('recommendation_div_vj', { startcolor: '#ffff99', endcolor: '#ffffff' });
  return true;
}

//DELETE RECOMMENDATIONS
function deleteRecommendation(rec_id){
	document.getElementById('recAction_'+rec_id).height='30';
	doAjax('/safe_redir.php?delete-recommendation='+rec_id,'recAction_'+rec_id);
}
//DONT DELETE RECOMMENDATION
function noDeleteRecommendation(rec_id){
	document.getElementById('recAction_'+rec_id).height='30';
	doAjax('/safe_redir.php?no-delete-recommendation='+rec_id,'recAction_'+rec_id);	
}
//YES DELETE RECOMMENDATION
function yesDeleteRecommendation(rec_id){
	document.getElementById('rec_'+rec_id).style.display='none';
	doAjax('/safe_redir.php?yes-delete-recommendation='+rec_id,'recAction_'+rec_id);	
}


//	INTEGER VALIDATION
function isInteger (s) {
  var i;
  if (isEmpty(s))
  if (isInteger.arguments.length == 1) return 0;
  else return (isInteger.arguments[1] == true);

  for (i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if (!isDigit(c)) return false;
  }
  return true;
}
function isEmpty(s) {
  return ((s == null) || (s.length == 0))
}
function isDigit (c) {
  return ((c >= "0") && (c <= "9"))
}


/**
*		PROFILE SETTINGS - PROFILE PICTURE FUNCTIONS	
*
**/
function myImgAction (id,e) {

	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	} else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	// posx and posy contain the mouse position relative to the document
	// Do something with this information
  document.getElementById('myImageOverlay').style.top=posy;
  document.getElementById('myImageOverlay').style.left=posx;
  document.getElementById('myImageOverlay').style.display='block';
  
  doAjax('/safe_redir.php?populateImageOverlayMenu='+id,'myImageOverlay');
  return true;
}
function makePictureActive (id) {
  doAjax('/safe_redir.php?makePictureActive='+id,'usrProfilePic');
  document.getElementById('myImageOverlay').style.display='none';
  return true;
}
function removeProfilePicture (id) {
  doAjax('/safe_redir.php?removeProfilePicture='+id,'my_profile_pictures');
  document.getElementById('myImageOverlay').style.display='none';
  return true;
}
/**
*		END PROFILE SETTINGS - PROFILE PICTURE FUNCTIONS	
*
**/



/**
*		USER PROFILE - STATUS CHANGING FUNCTIONS
*
**/
function catchStatusEnter (evt) {
  var keyCode = null;
  if (evt.which) {
    keyCode = evt.which;
  } else if (evt.keyCode) {
    keyCode = evt.keyCode;
  }

  if (keyCode == 13) {
    var sm = document.getElementById('new_status_msg').value;
    setStatusMsg(sm);
    return false;
  }
  return true;
}
function setStatusMsg (new_status) {

  var status_db = urlencode(escape(new_status));
  var status_disp = new_status;

  document.getElementById('personal_status').innerHTML='<span onclick="updateStatus(\''+status_db+'\');" class="secondarymid">'+status_disp+'</span><span id="lastUpdatedOn" style="font:10px arial,sans serif;"></span>';
  doAjax('/view_profile_fix.php?setStatusMsg='+status_db,'');
  //doAjax('/view_profile_fix.php?lastUpdatedOn=1','lastUpdatedOn');
  document.getElementById('lastUpdatedOn').innerHTML=' &nbsp;just a few moments ago.';
  return true;
}
function updateStatus (status) {
  var status = urldecode(unescape(htmlentities(stripslashes(status))));
  document.getElementById('personal_status').innerHTML='<input type=text id="new_status_msg" value="'+status+'" onkeypress="return catchStatusEnter(event);" onblur="setStatusMsg(this.value);" style="width: 250px; background-color: #e5f2fa; border: 1px solid #8f8fcf; font-size: 16px;">';
  document.getElementById('personal_status').innerHTML+='&nbsp;<input type="button" value="Update" onclick="setStatusMsg(document.getElementById(\'new_status_msg\').value);" />';
  document.getElementById('new_status_msg').focus();
  document.getElementById('new_status_msg').select();
  return true;
}
/**
*		END USER PROFILE - STATUS CHANGING FUNCTIONS
*
**/



/**
*			SAVE SMS NUMBER - REGISTRATION
*
**/
function saveSmsNumber () {
  var ac = document.getElementById('sms_areaCode').value;
  var a = document.getElementById('sms_num1').value;
  var b = document.getElementById('sms_num2').value;
  var n = ac+'-'+a+'-'+b;

  doAjax('/safe_redir.php?saveSmsNumber_registration='+n,'sms_status');
  return false;
}
  
  


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '' + num + '.' + cents);
}


/**
*		UPDATE PASSWORD STRENGTH
*
**/
function updatePasswordStrength (pw) {

  var minimum = 4;
  var fair = 6;
  var strength_label = Array( 'Your password is too short', 'Weak password. Keep going...', 'Fair password, could be stronger though.', 'Medium strength password.', 'Nice strong password!', 'Wow! Make sure you can remember it!' );
  var strength_color = Array( 'FF0000', 'FF9900', 'FFCC33', '99CC99', '00CC33', '006600' );
  var strength_width = Array( '10', '20', '30', '50', '75', '100' );

  if (!pw) {
  	var pw = document.getElementById('password1').value.toString();
  }
  if (!pw) {
  	return false;
  }

  var strength = 0;
  if (pw.length >= minimum) {
    strength = 1;
    if (pw.length >= fair) {
      strength++;
    }
    if(/\d+/.test(pw)){
      strength++;
    }
    if(/\W+/.test(pw)){
      strength++;
    }
    if(/[a-z]+/.test(pw) && /[A-Z]+/.test(pw)){
      strength++;
    }
  }
  //document.getElementById('strength').innerHTML = strength_label[ strength ] + ' ' + strength;
  document.getElementById('strength').innerHTML = strength_label[strength];
  //document.getElementById('strengthbar').style.backgroundColor = strength_color[ strength ];
  //document.getElementById('strengthbar').style.backgroundColor = '#'+strength_color[ strength ];
  //document.getElementById('strengthbar').style.width = strength_width[ strength ]+'%';
}

function showLoginForm () {
	html_out ='<form action=\"/login\" method=\"post\" name=\"loginForm\" id=\"loginForm\">';
	html_out+='<ul id=\"loginC1\">';
	html_out+='<li><label class=\"loginLabel\">email</label></li>';
	html_out+='<li><input type=\"text\" id=\"username\" name=\"username\" class=\"formField\"></li>';
	html_out+='<li style=\"margin-top:3px;\"><input style=\"margin:0px 3px 0px 0px;\" name=\"login_remember_me\" id=\"login_remember_me\" type=\"checkbox\" value=\"Y\">&nbsp;<label for=\"login_remember_me\">remember me</label></li>';
	html_out+='</ul>';
	html_out+='<ul id=\"loginC2\">';
	html_out+='<li><label class=\"loginLabel\">password</label></li>';	
	html_out+='<li><input type=\"password\" id=\"password\" name=\"password\" class=\"formField\"></li>';
	html_out+='<li style=\"margin-top:3px;\"><span style=\"font:12px arial,sans serif;\"><a href=\"javascript://\" onclick=\"forgotPassword();\">forgot password?</a></span></li>';
	html_out+='</ul>';
	html_out+='<ul>';
	html_out+='<li style=\"margin:18px 0px 0px 0px;\"><input type=\"image\" src=\"/images/loginBtn.gif\" name=\"user_login\" class=\"formBtn\" value=\"user_login\"></li>';
	html_out+='</ul>';
	html_out+='</form><!-- closing the loginForm -->';
  document.getElementById('userBarContent').innerHTML=html_out;
/*
  new Effect.Fade(
    'userBarContent', {
      duration:0.2,
      afterFinish: function (obj) {
        document.getElementById('userBarContent').innerHTML=html_out;
        new Effect.Appear('userBarContent', {delay:0.5,duration:0.2});
      }
    }
  )
*/
  return true;
}

//	FORGOT PASSWORD
function forgotPassword () {
	var username_text = document.getElementById('username').value;
	var html_out = '<table style="margin-top:10px;width:100%;" border="0" cellpadding="0" cellspacing="0">';
	html_out += '  <tr>';
	html_out += '    <td colspan="2"><span id="email_status">Enter your email address below</span></td>';
	html_out += '  </tr>';
	html_out += '  <tr style="height:2px;"><td colspan="2"></td></tr>';
	html_out += '  <tr>';
	html_out += '    <td style="width:80px;">';
	html_out += '      <input type="text" name="fp_email_address" value="'+username_text+'" id="fp_email_address" style="width:220px;background:#e5f2fa;border:1px solid #8f8fcf;font-size:16px;"> &nbsp;<input type="button" onclick="forgotPasswordSend();" name="forgot_password_userbar" value="Send password">';
	html_out += '    </td>';
	html_out += '  </tr>';
	html_out += '</table>';

  document.getElementById('userBarContent').innerHTML=html_out;
/*
  new Effect.Fade(
    'userBarContent', {
      duration:0.2,
      afterFinish: function (obj) {
        document.getElementById('userBarContent').innerHTML=html_out;
        new Effect.Appear('userBarContent', {delay:0.5,duration:0.2});
      }
    }
  )
*/
	return true;
}

function forgotPasswordSend () {
  var fp_user_email = trim(document.getElementById('fp_email_address').value);
  if (fp_user_email.length == 0) {
    document.getElementById('email_status').innerHTML='A blank email address...very original. Try again please';
    $('email_status').highlight('#ffff99');
    return false;
  }
  if (!validateEmail(fp_user_email)) {
    document.getElementById('email_status').innerHTML='The email you entered appears to be invalid. Try again';
    $('email_status').highlight('#ffff99');
    return false;
  }

  doAjax('/safe_redir.php?userBar_forgotPassword='+fp_user_email,'userBarContent');
/*
  new Effect.Fade(
    'userBarContent', {
      duration:0.2,
      afterFinish: function (obj) {
        doAjax('/safe_redir.php?userBar_forgotPassword='+fp_user_email,'userBarContent');
        new Effect.Appear('userBarContent', {delay:0.2,duration:0.2});
      }
    }
  )
*/
  return true;
}


//	FORGOT PASSWORD WINDOW
function forgotPasswordWindow () {
	var username_text = document.getElementById('username').value;
	var html_out = '<table style="margin-top:10px;width:100%;" border="0" cellpadding="0" cellspacing="0">';
	html_out += '  <tr>';
	html_out += '    <td colspan="2"><span id="email_status">Enter your email address below</span></td>';
	html_out += '  </tr>';
	html_out += '  <tr style="height:2px;"><td colspan="2"></td></tr>';
	html_out += '  <tr>';
	html_out += '    <td style="width:80px;">';
	html_out += '      <input type="text" name="fp_email_address" value="'+username_text+'" id="fp_email_address" style="width:220px;background:#e5f2fa;border:1px solid #8f8fcf;font-size:16px;"> &nbsp;<input type="button" onclick="forgotPasswordSendWindow();" name="forgot_password_userbar" value="Send password">';
	html_out += '    </td>';
	html_out += '  </tr>';
	html_out += '</table>';

  document.getElementById('login_form').innerHTML=html_out;
/*
  new Effect.Fade(
    'login_form', {
      duration:0.2,
      afterFinish: function (obj) {
        document.getElementById('login_form').innerHTML=html_out;
        new Effect.Appear('login_form', {delay:0.5,duration:0.2});
      }
    }
  )
*/
	return true;
}

function forgotPasswordSendWindow () {
  var fp_user_email = trim(document.getElementById('fp_email_address').value);
  if (fp_user_email.length == 0) {
    document.getElementById('email_status').innerHTML='A blank email address...very original. Try again please';
    $('email_status').highlight('#ffff99');
    return false;
  }
  if (!validateEmail(fp_user_email)) {
    document.getElementById('email_status').innerHTML='The email you entered appears to be invalid. Try again';
    $('email_status').highlight('#ffff99');
    return false;
  }

  doAjax('/safe_redir.php?userBar_forgotPasswordWindow='+fp_user_email,'login_form');
/*
  new Effect.Fade(
    'login_form', {
      duration:0.2,
      afterFinish: function (obj) {
        doAjax('/safe_redir.php?userBar_forgotPasswordWindow='+fp_user_email,'login_form');
        new Effect.Appear('login_form', {delay:0.2,duration:0.2});
      }
    }
  )
*/
  return true;
}

function showLoginFormWindow () {	
	html_out ='<form method="POST" action="/login" name="loginForm">';
	html_out+='<span style="font:16px arial,sans serif;font-weight:bold"><?php echo $page_heading_title_sec; ?></span><br />';
	html_out+='<?php echo $page_login_text; ?><br />';
	html_out+='<br />';
	html_out+='<div class="row">';
	html_out+='<div class="a">Email:</div>';
	html_out+='<div class="b"><input name="username" type="text" style="width:200px;" /></div>';
	html_out+='</div>';
	html_out+='<div class="row">';
	html_out+='<div class="a">Password:</div>';
	html_out+='<div class="b"><input name="password" type="password" style="width:200px;" /></div>';
	html_out+='</div>';
	html_out+='<div style="width:200px;">&nbsp;</div>';
	html_out+='<div class="b"><a href="javascript://" onclick="forgotPasswordWindow();">forgot your password?</a></div>';
	html_out+='<br />';
	html_out+='<div class="row">';
	html_out+='<input type="image" name="user_login" src="/images/loginBtn.gif">';
	html_out+='</div>';
	html_out+='</form>';

  document.getElementById('login_form').innerHTML=html_out;
/*
  new Effect.Fade(
    'login_form', {
      duration:0.2,
      afterFinish: function (obj) {
        document.getElementById('login_form').innerHTML=html_out;
        new Effect.Appear('login_form', {delay:0.5,duration:0.2});
      }
    }
  )
*/
  return true;
}




/**
 **		FACEBOOK CONNECT
 **
 **/
function processLogin_ub (ev) {
  var x = md5('ZmJsb2dpbi1pZGxldGltZQ==');
  doAjax('/safe_redir.php?ifbl='+x,'fb_login_ub');
  FB.XFBML.Host.parseDomTree();
  //this.location.href='http://edmonton.idletime.ca/#fb-login-ok-proceed';
  //document.location.href='http://edmonton.idletime.ca/?xfm='+x;
  document.location.href='http://edmonton.idletime.ca/?redir_fb_login=1';
  //this.location.href='http://edmonton.idletime.ca/?redir_fb_login=1';
  return true;
}
function processLogin_lp (ev) {
  var x = md5('ZmJsb2dpbi1pZGxldGltZQ==');
  doAjax('/safe_redir.php?ifbl='+x,'facebook_login_bttn');
  FB.XFBML.Host.parseDomTree();
  //this.location.href='http://edmonton.idletime.ca/#fb-login-ok-proceed';
  //document.location.href='http://edmonton.idletime.ca/?xfm='+x;
  document.location.href='http://edmonton.idletime.ca/?redir_fb_login=1';
  //this.location.href='http://edmonton.idletime.ca/?redir_fb_login=1';
  return true;
}
function update_fblogin_containers () {
  //print_r(isset(document.getElementById('
  var x = this.location.href;
  if (strpos(x,'/login') > 0) {
    //alert('Found STR position');
    //document.getElementById('facebook_login_bttn').innerHTML='You are already logged in using Facebook Connect ...';
  }
  //alert(strpos(x,'login'));
  //alert(this.location.href);
  return true;
}









function validateEmail (src) {
  var emailReg = "^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$";
  var regex = new RegExp(emailReg);
  return regex.test(src);
}





function checkPostalCode (v) {
  var x = trim(v).substr(0,3);

  doAjax_value('/register.php?checkPostalCode_city='+x,'reg_city');
  doAjax_value('/register.php?checkPostalCode_prov='+x,'reg_province');
  ajaxCountrySelect('/register.php?setCountryAjax='+x,'test');
  return true;
}

function selectCountry (c) {
  if (c == 'CAN') {
    document.getElementById('country_canada').style.border='1px solid #666666';
    document.getElementById('country_usa').style.border='';
    var cDiv = 'country_sel_canada';
  } else if (c == 'USA') {
    document.getElementById('country_usa').style.border='1px solid #666666';
    document.getElementById('country_canada').style.border='';
    var cDiv = 'country_sel_usa';
  }

  doAjax('/register.php?setRegisterCountry='+c,cDiv);
  return true;
}


// Count remaining characters of textarea
function CountLeft(field, max) {

	// if the length of the string in the input field is greater than the max value, trim it
	if (field.value.length > max) {
		field.value = field.value.substring(0, max);
	} else {
		// calculate and display the remaining characters 
    document.getElementById('title_remaining').innerHTML = max - field.value.length;
  }
}





function displayCreditsInfo (e) {
  if (document.all) {
    mousePosX = event.clientX; + document.body.scrollLeft;
	  mousePosY = event.clientY; + document.body.scrollTop;
  } else {
	  mousePosX = e.pageX;
    mousePosY = e.pageY;
  }

  document.getElementById('credit_popup').style.left=mousePosX;
  document.getElementById('credit_popup').style.display='block';
  return true;
}
function hideCreditsInfo () {
  document.getElementById('credit_popup').style.display='none';
  return true;
}

function updateProfileField (f,v) {
	doAjax('/inc/html_heading.inc?updateProfileField='+f+'&v='+v,'profile_update_status');
	return true;
}


//	BUY CREDITS - VIEWING PROFILE
function goPurchaseCredits (usercredits) {
  if (usercredits.length > 0) {
    var ncval = usercredits;
  } else {
    var nvcal = 0;
  }

  var credits = getCheckedValue(document.forms['creditfrm'].elements['credits']);
  doAjax('/safe_redir.php?purchaseCredits=1&nc='+credits+'&ncval='+ncval,'credit_main');
  return true;
}
function calcCreditCost (value) {
  var x = formatCurrency(value * 1);
  document.getElementById('usercreditcost').innerHTML=x;
  return true;
}
function creditCalcUpdate (id) {
  if (id == '-1') {
    document.getElementById('cost_display').style.display='none';
  } else {
    doAjax('/safe_redir.php?creditCalcUpdate='+id,'cost_display');
    document.getElementById('cost_display').style.display='block';
  }
  return true;
}

// -- END BUY CREDITS - VIEWING PROFILE






function changeBidStatus (bid_id,status_type) {
  var x = confirm('Are you sure?');
  if (x == true) {
    doAjax('/inc/html_heading.inc?change_bid_status=Y&new_status='+status_type+'&bid_id='+bid_id,'bid_status');
    return true;
  }
  return false;
}

function qualifications_addNew (type) {
document.getElementById('add_new_form_school').style.display='block';
document.getElementById('add_new_form_job').style.display='block';


  if (type == 'job') {
    //new Effect.Appear('add_new_form_job', { duration: 0.4 });
	document.getElementById('add_new_form_job').style.display='block';
    doAjax('/safe_redir.php?add_new='+type,'add_new_form_job');
  } else {
    //new Effect.Appear('add_new_form_school', { duration: 0.4 });
	document.getElementById('add_new_form_school').style.display='block';
    doAjax('/safe_redir.php?add_new='+type,'add_new_form_school');
  }

  return true;
}
function checkAddJobFrm () {
  document.getElementById('add_job_errors').innerHTML='';
  document.getElementById('add_job_errors').style.display='none';
  
  //alert(time_period_checkbox.checked);
  var employer = document.getElementById('addJob_employer').value;
  if (employer.length == 0) {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You must enter a value for <b>Employer</b>';
    return false;
  }

  var position = document.getElementById('addJob_position').value;
  if (position.length == 0) {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You must enter a value for <b>Position</b>';
    return false;
  }

  var description = document.getElementById('addJob_description').value;
  if (description.length == 0) {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You must enter a value for <b>Description</b>';
    return false;
  }

  var city = document.getElementById('addJob_cityTown').value;
  if (city.length == 0) {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You must enter a <b>City/Province</b>!';
    return false;
  }


  //check select dropdowns
  var tsStart_mth = document.getElementById('addJob_tsStart_mth').value;
  var tsStart_year = document.getElementById('addJob_tsStart_year').value;
  var tsEnd_mth = document.getElementById('addJob_tsEnd_mth').value;
  var tsEnd_year = document.getElementById('addJob_tsEnd_year').value;
  var time_period_checkbox = document.getElementById('time_period_checkbox');

  if (tsStart_mth == '-1' && tsStart_year == '-1') {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You need to enter your starting month/year in <b>Time Period</b>!';
    return false;
  }

  if ( (tsStart_mth != '-1' && tsStart_year != '-1') && (tsEnd_mth == '-1' && tsEnd_year == '-1') ) {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You must enter an ending time period!';
    return false;
  }


  if (tsStart_mth == '-1' && tsStart_year == '-1' && tsEnd_mth == '-1' && tsEnd_year == '-1') {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='You must enter a valid <b>Time Period</b>!';
    return false;
  }


  
/*  
  if (time_period_checkbox.checked == true) {
    document.getElementById('add_job_errors').style.display='block';
    document.getElementById('add_job_errors').innerHTML='<img src="/images/forbidden.png"> <span style="font:16px arial,sans serif;font-weight:bold;">Error!</span>';
    return false;
  }
*/

  return true;
}
function checkJobFrm () {
  //var x=document.getElementsByName("time_period_checkbox");
  //alert(x.length);
  //return false;
  return true;
/*
  var x = document.getElementsByTagName('select');
  for (y=0;y<=x.length;y++) {
  	if (x[y].name.match('qualifications_jobHistory')) {
  	  alert('Found one: '+x[y].name);
  	  return false;
  	}
  }
*/
}

function updateFields (type,cw) {
  if (type=='-1') {
    document.getElementById('addEducation_highschool').style.display='none';
    document.getElementById('addEducation_university').style.display='none';
  }
  if (type=='highschool') {
	  document.getElementById('addEducation_university').style.display='none';
	  document.getElementById('addEducation_highschool').style.display='block';
	  //new Effect.Appear('addEducation_highschool', { duration: 0.3 });
  } else if (type=='university') {
    document.getElementById('addEducation_highschool').style.display='none';
    document.getElementById('addEducation_university').style.display='block';
	//new Effect.Appear('addEducation_university', { duration: 0.3 });
  }
  return true;
}


function checkAddEducationFrm () {

  document.getElementById('add_education_errors').innerHTML='';
  document.getElementById('add_education_errors').style.display='none';


  var degree_level = document.getElementById('degree_level').value;
  if (degree_level == '-1') {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='You must select a <b>Degree/Level</b>!';
    return false;
  }

  if (degree_level == 'highschool') {
    var school_program_name = document.getElementById('school_name').value;
	  if (school_program_name.length == 0) {
	    document.getElementById('add_education_errors').style.display='block';
	    document.getElementById('add_education_errors').innerHTML='You must enter a <b>School Name</b> value!';
	    return false;
	  }
	}

  if (degree_level == 'university') {
    var school_institution_name = document.getElementById('school_institution_name').value;
    if (school_institution_name.length == 0) {
      document.getElementById('add_education_errors').style.display='block';
      document.getElementById('add_education_errors').innerHTML='You must enter an <b>Institution</b> name!';
      return false;
    }

    var school_program_name = document.getElementById('school_program_name').value;
    if (school_program_name.length == 0) {
      document.getElementById('add_education_errors').style.display='block';
      document.getElementById('add_education_errors').innerHTML='You must enter a <b>Program Name</b> value!';
      return false;
    }

    var school_concentration_name = document.getElementById('school_concentration_name').value;
    if (school_concentration_name.length == 0) {
      document.getElementById('add_education_errors').style.display='block';
      document.getElementById('add_education_errors').innerHTML='You must enter a <b>Concentration</b> value!';
      return false;
    }
  }


	var city_town = document.getElementById('city_town').value;
	if (city_town.length == 0) {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='You must enter a <b>City/Town</b> value!';
    return false;
  }

	var province = document.getElementById('province').value;
	if (province == '-1') {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='You must enter a valid <b>Province</b> value!';
    return false;
  }

	var education_country = document.getElementById('education_country').value;
	if (education_country == '-1') {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='You must enter a valid <b>Country</b> value!';
    return false;
  }

	var startDate_month = document.getElementById('startDate_month').value;
	var startDate_year = document.getElementById('startDate_year').value;
	var endDate_month = document.getElementById('endDate_month').value;
	var endDate_year = document.getElementById('endDate_year').value;




	if (startDate_year == '-1') {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='You must enter a <b>Start Date</b> year. The month is optional :)';
    return false;
  }

	if (endDate_year == '-1') {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='You must enter a <b>End Date</b> year. The month is optional :)';
    return false;
  }

  if (startDate_year > endDate_year) {
    document.getElementById('add_education_errors').style.display='block';
    document.getElementById('add_education_errors').innerHTML='Going back to the future, are you? Check your <b>End Date</b>, it must be greater than your <b>Start Date</b>...';
    return false;
  }


	//var related_information = document.getElementById('related_information').value;
	return true;
}




function qualifications_tpChk (v,id) {

	if (v == true) {
	  if (id == 'time_period_checkbox') {
	    document.getElementById('time_period_end').innerHTML='present.';
	  } else {
	    document.getElementById('time_period_end_'+id).innerHTML='present.';
	  }
	} else {
	  if (id == 'time_period_checkbox') {
	    doAjax('/edit_profile.php?qualifications_tpChk_printDates=1&add_new=1','time_period_end');
	  } else {
	    doAjax('/edit_profile.php?qualifications_tpChk_printDates=1&jobId='+id,'time_period_end_'+id);
	  }
	}
	return true;
}




/**
 **		AVAILABILITY
 **/
function openDay (d) {
	//new Effect.Appear('edit_'+d, { duration: 0.6 });
	document.getElementById('edit_'+d).innerHTML='<img src=/images/photo_loading.gif alt=loading>';
	doAjax('/safe_redir.php?availabilityOpenDay='+d,'edit_'+d);
	return true;
}
function deleteTime (day,str) {
	alert(day+' - '+str);
	return true;
}
function availabilityAddTime (day) {
	var fh = document.getElementById('avail_fh_'+day).value;
	var fm = document.getElementById('avail_fm_'+day).value;
	var fa = document.getElementById('avail_fa_'+day).value;

	var th = document.getElementById('avail_th_'+day).value;
	var tm = document.getElementById('avail_tm_'+day).value;
	var ta = document.getElementById('avail_ta_'+day).value;
	doAjax('/safe_redir.php?availabilityAddTime='+day+'&fh='+fh+'&fm='+fm+'&fa='+fa+'&th='+th+'&tm='+tm+'&ta='+ta,'edit_'+day);
	return true;
}


/**
*			CREDIT CARD RELATED FUNCTIONS
*
**/

// basic credit card validation
// LUHN Formula for validation of credit card numbers.
// this is only to prevent card attacks, and can be broken!
function mod10 (cardNumber) {
  var ar = new Array(cardNumber.length);
  var i=0,sum=0;

  for (i=0;i<cardNumber.length; ++i) {
    ar[i] = parseInt(cardNumber.charAt(i));
  }
	for (i=ar.length -2; i >= 0; i-=2) {  // you have to start from the right, and work back.
    ar[i] *= 2;                         // every second digit starting with the right most (check digit)
    if( ar[i] > 9 ) ar[i]-=9;					  // will be doubled, and summed with the skipped digits.
  }										 								  // if the double digit is > 9, ADD those individual digits together
  for (i=0; i < ar.length; ++i) {
    sum += ar[i];
  }
	return (((sum%10)==0)?true:false);	 	// if the sum is divisible by 10 mod10 succeeds
}

function validateCard (cardNumber,cardType,cardMonth,cardYear) {
	if (cardNumber.length == 0) {                 //most of these checks are self explanitory
		
		//	error 61 - please enter a valid card number
		doAjax('/safe_redir.php?cardError=61','cardErrors');
		return false;				
	}
  for (var i = 0; i < cardNumber.length; ++i) {    // make sure the number is all digits.. (by design)
    var c = cardNumber.charAt(i);
		if (c < '0' || c > '9') {

			//	error 62 - please enter a valid card number. use only digits. do not use spaces or hyphens!
			doAjax('/safe_redir.php?cardError=62','cardErrors');
			return false;
		}
	}
  var length = cardNumber.length;               //perform card specific length and prefix tests

  switch (cardType) {
    case 'a':
      if (length != 15) {

				//	error 63 - please enter a valid american express card number
				doAjax('/safe_redir.php?cardError=63','cardErrors');
				return;
			}
			var prefix = parseInt(cardNumber.substring(0,2));

			if (prefix != 34 && prefix != 37) {

				//	error 63 - please enter a valid american express card number
				doAjax('/safe_redir.php?cardError=63','cardErrors');
				return;
			}
			break;

		case 'd':
      if (length != 16) {

				//	error 64 - please enter a valid discover card number
				doAjax('/safe_redir.php?cardError=64','cardErrors');
        return;
      }
      var prefix = parseInt(cardNumber.substring(0,4));

      if (prefix != 6011) {

				//	error 64 - please enter a valid discover card number
				doAjax('/safe_redir.php?cardError=64','cardErrors');
        return;
      }
      break;

    case 'm':
      if (length != 16) {

				//	error 65 - please enter a valid mastercard number
				doAjax('/safe_redir.php?cardError=65','cardErrors');
        return;
      }
      var prefix = parseInt(cardNumber.substring(0,2));

      if (prefix < 51 || prefix > 55) {

				//	error 65 - please enter a valid mastercard number
				doAjax('/safe_redir.php?cardError=65','cardErrors');
        return;
      }
      break;

    case 'v':
      if(length != 16 && length != 13) {

				//	error 66 - please enter a valid visa card number
				doAjax('/safe_redir.php?cardError=66','cardErrors');
        return;
      }
      var prefix = parseInt(cardNumber.substring(0,1));

      if (prefix != 4) {

				//	error 66 - please enter a valid visa card number
				doAjax('/safe_redir.php?cardError=66','cardErrors');
        return;
      }
      break;
  }

  if (!mod10(cardNumber)) {                       // run the check digit algorithm

    //	error 67 - sorry! this is not a valid credit card number
    doAjax('/safe_redir.php?cardError=67','cardErrors');
    return false;
  }
  if (isset(cardMonth) && !isset(cardYear)) {
  	//alert('Month set - Broken!');
  	doAjax('/safe_redir.php?cardError=69','cardErrors');
  	return false;
  }
  if (!isset(cardMonth) && isset(cardYear)) {
  	//alert('Year set - Broken!');
  	doAjax('/safe_redir.php?cardError=70','cardErrors');
  	return false;
  }

  if (expired(cardMonth,cardYear)) {              // check if entered date is already expired.

    //	error 68 - sorry! the expiration date you have entered would make this card invalid
    doAjax('/safe_redir.php?cardError=68','cardErrors');
    return false;
  }

  // at this point card has not been proven to be invalid
  return true;
}

function expired (month, year) {
  var now = new Date();                         // this function is designed to be Y2K compliant.
  var expiresIn = new Date(year,month,0,0,0);   // create an expired on date object with valid thru expiration date
  expiresIn.setMonth(expiresIn.getMonth()+1);   // adjust the month, to first day, hour, minute & second of expired month
  if( now.getTime() < expiresIn.getTime() ) return false;
  return true;                                  // then we get the miliseconds, and do a long integer comparison
}





//	FB CONNECT FUNCTIONS
function update_user_box () {
  //alert('Test');
  document.getElementById('fb_connect_off').style.display='none';
  document.getElementById('fb_connect_on').style.display='block';
  //document.getElementById('fb_connect').innerHTML='Hello facebook connect person!';

  FB.XFBML.Host.parseDomTree();
  return true;
}


-->