function jobDel(_url){
	if(confirm("Are you sure you want to delete this job Ad??")){
		window.location = _url;
	}
}

function WBM_jobAds_pg(value, typeOfJobs, object){

	document.getElementById(typeOfJobs+object).value = value;
	document.search_from.submit();

}

function initPage() {
/*	if (window.attachEvent && !window.opera){ ieHover();}
	main_height();
	box_height();
	gal_list();
	initPost();
	initCheck();
	init_starRating();
	init_rasFavourite();
	WBM_provider_formCheck();
	displayPopup('calendar-area', 'edit-exercise-popup', 'edit');
	displayPopup('user-tools-area', 'join-group-popup', 'btn');
	displayPopup('my-photos-area', 'photo-edit-popup', 'edit');
	displayPopup('photos', 'add-friend-popup', 'add');
	displayPopup('exercise-area', 'exercise-popup', 'edit-info');
	displayPopup('relaxation-area', 'relaxation-popup', 'edit-info');
	initTabs();
	WBM_communityProvider();*/
}
if (window.addEventListener){
	window.addEventListener("load", initPage, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", initPage);
}
function initPost(){
	var _post = document.getElementById("news");
	if (_post)
	{
		var nodes = _post.getElementsByTagName("div");
		for (var i=0; i<nodes.length; i++)
		{
			if ((nodes[i].className.indexOf("news-bar") != -1) && (nodes[i].className.indexOf("top") == -1) && (nodes[i].className.indexOf("bottom") == -1))
			{
				
				//on mouse over
				nodes[i].onmouseover = function()
				{
					this.className += " active";
					
					buttons = this.getElementsByTagName("a");
					for (j=0; j<buttons.length; j++)
					{
						if ((buttons[j].className.indexOf("btn") != -1))
						{
							buttons[j].className += " active";
						}
			
					}
				}


				//on mouse out
				nodes[i].onmouseout = function()
				{
					this.className = this.className.replace(" active", "");

					buttons = this.getElementsByTagName("a");
					for (j=0; j<buttons.length; j++)
					{
						if ((buttons[j].className.indexOf("btn") != -1))
						{
							buttons[j].className = buttons[j].className.replace(" active", "");
						}
					}
				}

				//on click (view profile)
				nodes[i].onclick = function()
				{					
					buttons = this.getElementsByTagName("a");
					for (j=0; j<buttons.length; j++)
					{
						if ((buttons[j].className.indexOf("btn") != -1))
						{
							_section_link = buttons[j].href;
						}
					}

					window.location = _section_link;
				}



			}
		}
	}
}




function gal_list(){
	var nav_t = document.getElementById("gallery-list");
	var gal_list_count;
	var gal_list_auto_close;

	if(nav_t)
	{
		nav_t = nav_t.getElementsByTagName("li");
		gal_list_count = nav_t.length;

		for (var i=0; i<nav_t.length; i++)
		{

			nav_t[i].onclick = function (i)
			{
				if(gal_list_auto_close)
				{
					clearInterval(gal_list_auto_close);
				}

				if(this.className.indexOf("active") !=-1)
				{
					this.className = this.className.replace("active", "");
				}
				else
				{
					for (var j=0; j<nav_t.length; j++){ nav_t[j].className = nav_t[j].className.replace("active", "");}
					
					this.className += ' active ';

					gal_list_auto_close = setTimeout(function() { for (var k=1; k<=gal_list_count; k++){ document.getElementById('expert_popup_'+k).className = '';} }, expert_popup_autoclose);
				}
				
				return false;
			}
		}



	}
}

function initCheck(){
	var _hold = document.getElementsByTagName('ul');
	var _list = [];
	var _k = 0;
	for(var i = 0; i < _hold.length; i++){
		if(_hold[i].className.indexOf('personal-goals') != -1){
			
			var t_btn = _hold[i].getElementsByTagName('a');
			var t_checkbox = _hold[i].getElementsByTagName('input');
			var _btn;
			var _checkbox = [];
			
			for(var j = 0; j < t_btn.length; j++){
				if(t_btn[j].className.indexOf('select-all') != -1){ _btn = t_btn[j];}
			}
			for(var j = 0; j < t_checkbox.length; j++){
				if(t_checkbox[j].type == "checkbox"){
					_checkbox.push(t_checkbox[j]);
				}
			}
			if(_btn){
				_list[_k] = _btn;
				_list[_k]._ind = _k;
				_list[_k]._checkbox = _checkbox;
				_k++;
			}
		}
	}
	for(var i = 0; i < _list.length; i++){
		if(_list[i]){
			_list[i].onclick = function(){
				if(this.className.indexOf('checked') != -1){
					for(var j = 0; j < _list[this._ind]._checkbox.length; j++){
						_list[this._ind]._checkbox[j].checked = false;
					}
					this.className = this.className.replace('checked','');
				}
				else{
					for(var j = 0; j < _list[this._ind]._checkbox.length; j++){
						_list[this._ind]._checkbox[j].checked = true;
					}
					this.className += ' checked ';
				}
				return false;
			}
		}
	}
}
function main_height()
{
	var col = document.getElementsByTagName("div");
	for (var i = 0; i < col.length; i++)
	{
		if(col[i].className.indexOf('information') != -1)
		{
			var _h = col[i].offsetHeight;
			var hold = col[i].getElementsByTagName("div");
			for( var j = 0 ; j < hold.length ; j++)
				if( hold[j].className.indexOf('box-holder') !=-1)
				{
					hold[j].style.minHeight = _h - 50 +'px';
					if (window.attachEvent && !window.opera){ hold[j].style.height = _h - 50 + 'px'; }
				}
				
		}
	}
}
function box_height()
{
	var col1 = document.getElementsByTagName("div");
	for (var i = 0; i < col1.length; i++)
	{
		if(col1[i].className.indexOf('info-row') != -1)
		{
			var _h1 = 0;
			var hold1 = col1[i].getElementsByTagName("div");
			for( var j = 0 ; j < hold1.length ; j++) {
				if( hold1[j].className.indexOf('info-box-bar') !=-1) {
					if(hold1[j].offsetHeight > _h1) { _h1 = hold1[j].offsetHeight;}
				}
			}
			for( var j = 0 ; j < hold1.length ; j++) {
				if( hold1[j].className.indexOf('info-box-bar') !=-1) {
					hold1[j].style.minHeight = _h1 - 46 + 'px';
					if (window.attachEvent && !window.opera){ hold1[j].style.height = _h1 - 46 + 'px'; }
				}
			}
		}
	}
}
function initTabs()
{
	var sets = document.getElementsByTagName("ul");
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabset") != -1 || sets[i].className.indexOf("tabset-list") !=-1)
		{
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));
					if (c) if (links[j].className.indexOf("active") != -1) c.style.display = "block";
					else c.style.display = "none";
					links[j].onclick = function ()
					{
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							//reset all tabs before change
							for (var i = 0; i < this.tabs.length; i++)
							{
								document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1)).style.display = "none";
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.display = "block";
							return false;
						}
					}
				}
			}
		}
	}
}
function displayPopup(hold_id, popup_id, btn_class) {
	var _hold = document.getElementById(hold_id);
	var _popup = document.getElementById(popup_id);
	if(_hold && _popup){
		var _btn = _hold.getElementsByTagName('a');
		for(var i=0; i < _btn.length; i++) {
			if(_btn[i].className.indexOf(btn_class) != -1) {
				_btn[i].onclick = function() {
					var t_popup_text = this.parentNode.getElementsByTagName('div');
					var popup_text = null;
					for(var j = 0; j < t_popup_text.length; j++) {
						if(t_popup_text[j].className.indexOf('popup-text') != -1) { popup_text = t_popup_text[j].innerHTML;}
					}
					if(popup_text) {
						var _top = getAbsoluteTop(this);
						var _left = getAbsoluteLeft(this);
						_popup.innerHTML = popup_text;
						if (window.attachEvent && !window.opera && (typeof(hideSelectBoxes) == 'function')){ showSelectBoxes(document.body);}
						_popup.style.display = 'block';
						if(typeof(initRollovers) == 'function'){ initRollovers();}
						_popup.style.top = _top - _popup.offsetHeight + 'px';
						_popup.style.left = _left + 'px';
						if (window.attachEvent && !window.opera && (typeof(hideSelectBoxes) == 'function')){ hideSelectBoxes(_popup);}
						var btn_close = _popup.getElementsByTagName('a');
						for(var j = 0; j < btn_close.length; j++) {
							if(btn_close[j].className.indexOf('close') != -1){
								btn_close[j].onclick = function(){
									if (window.attachEvent && !window.opera && (typeof(hideSelectBoxes) == 'function')){ showSelectBoxes(_popup);}
									_popup.style.display = 'none';
									_popup.innerHTML = '';
									return false;
								}
							}
						}
						return false;
					}
				}
			}
		}
	}
}
function getAbsoluteTop(obj) {
	var posTop = 0;
	while (obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
	return posTop;
}
function getAbsoluteLeft(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {posLeft += obj.offsetLeft; obj = obj.offsetParent;}
	return posLeft;
}
function ieHover()
{
	var nav = document.getElementById("navigation");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].onmouseover = function() 
			{
				this.className += " hover";
				var t_box = this.getElementsByTagName('div')[0];
				if (window.attachEvent && !window.opera && t_box && (typeof(hideSelectBoxes) == 'function')){ hideSelectBoxes(t_box);}
			}
			nodes[i].onmouseout = function()
			{
				var t_box = this.getElementsByTagName('div')[0];
				if (window.attachEvent && !window.opera && t_box && (typeof(showSelectBoxes) == 'function')){ showSelectBoxes(t_box);}
				this.className = this.className.replace(" hover", "");
			}
		}
	}
	var nav = document.getElementById("gallery-list");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].onmouseover = function() 
			{
				this.className += " hover";
			}
			nodes[i].onmouseout = function()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
	var nav = document.getElementById("calendar-area");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("td");
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].onmouseover = function() 
			{
				this.className += " hover";
			}
			nodes[i].onmouseout = function()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

function init_rasFavourite()
{
	var ras = $('rasbox-favourite');
	if(ras)
	{
		var id_ras = ras.name;

		new Ajax.Request('includes/ajax/ras_favourite.php', {
			method: 'get',
			parameters: {id: id_ras},
		  
			onSuccess: function(transport){
				var response = transport.responseText;
				$('rasbox-favourite').innerHTML = response;
			},
			onComplete: function(){ control_rasFavourite(); }
		  });
	}
}

function control_rasFavourite()
{
	var ras = $('rasbox-favourite');
	var ras_box = $('rasbox-favourite-box');
	
	if(ras)
	{
		var id_ras = ras.name;
		ras_box.onclick = function()
		{
			new Ajax.Request('includes/ajax/ras_favourite.php', {
				method: 'get',
				parameters: {id: id_ras, action: 'switch'},
			  
				onSuccess: function(){ init_rasFavourite(); },
				onFailure: function(){ init_rasFavourite(); }
			  });

		}
	}	
}

function init_starRating()
{

	var rating = $('rasbox-rating');
	var initResponse;

	if(rating)
	{
		var id_ras = rating.title;

		new Ajax.Request('includes/ajax/ras_rate_it.php', {
			method: 'get',
			parameters: {id: id_ras, rate: 0},
		  
			onSuccess: function(transport){
				initResponse = transport.responseText;
				$('rasbox-rating').innerHTML = initResponse;
			},
			onComplete: function(){ control_starRating(); }
		  });
	}
}


function control_starRating()
{

	var rating = $('rasbox-rating');
	var stars = $('ras-rate-container');
	var current_rating = 0;
	var nodes, i, j;
	var id_ras = rating.title;

	//Getting the current rating
	nodes = stars.getElementsByTagName("a");
	for (i=0; i<nodes.length; i++)
	{
		if(nodes[i].className.indexOf('ras-star-active') != -1)
		{
			star_number = nodes[i].id.replace("ras-rate-", "") * 1;
			if(star_number > current_rating)
			{
				current_rating = star_number;
			}
		}
	}
	// -- end -- 

	for (i=0; i<nodes.length; i++)
	{
		nodes[i].onmouseover = function() 
		{
			this_rate = this.id.replace("ras-rate-", "") * 1;

			for(j=1; j<=5; j++)
			{
				$('ras-rate-'+j).className = $('ras-rate-'+j).className.replace(" ras-star-active", "");
			}
			for(j=1; j<=this_rate; j++)
			{
				$('ras-rate-'+j).className += " ras-star-active";
			}
		}

		nodes[i].onmouseout = function()
		{
			for(j=1; j<=5; j++)
			{
				$('ras-rate-'+j).className =$('ras-rate-'+j).className.replace(" ras-star-active", "");
			}
			for(j=1; j<=current_rating; j++)
			{
				$('ras-rate-'+j).className += " ras-star-active";
			}
		}

		nodes[i].onclick = function()
		{
			this_rate = this.id.replace("ras-rate-", "") * 1;
			if(this_rate >= 1 && this_rate <= 5)
			{
				new Ajax.Request('includes/ajax/ras_rate_it.php', {
					method: 'get',
					parameters: {id: id_ras, rate: this_rate},
					  
					onSuccess: function(){ init_starRating(); },
					onFailure: function(){ init_starRating(); }
				  });
			}
		}


	}
	
}


function WBM_gotoURL(_url)
{
	if(_url != '')
	{
		window.location = _url;
	}
}

function WBM_Facebook_click()
{
	var _url = location.href;
	var _title = document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(_url)+'&t='+encodeURIComponent(_title),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
function WBM_Delicious_click()
{
	var _url = location.href;
	var _title = document.title;
	window.open('http://del.icio.us/post?url='+encodeURIComponent(_url)+'&title='+encodeURIComponent(_title),'delicious_sharer','toolbar=0,status=0,width=850,height=600');
	return false;
}

function WBM_Digg_click()
{
	var _url = location.href;
	var _title = document.title;
	window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(_url),'digg_sharer','scrollbars=1,toolbar=0,status=0,width=950,height=700');
	return false;
}



function WBM_checkIncorrectPassword_form()
{
	var _username = document.getElementById('pbox_frm_username');
	var _password = document.getElementById('pbox_frm_password');

	var _has_errors = false;

	if(_username.value == '')
	{
		_username.style.borderColor = '#FF8C00';
		_has_errors = true;
		_username.focus();
		return false;
	}
	else
	{
		_username.style.borderColor = '#C3C3C3';
	}

	if(_password.value == '')
	{
		_password.style.borderColor = '#FF8C00';
		_has_errors = true;
		_password.focus();
		return false;
	}
	else
	{
		_password.style.borderColor = '#C3C3C3';
	}

	if(_has_errors == true)
	{
		return false;
	}
	else
	{
		document.pbox_form.submit();
	}

}

function WBM_checkForgotPassword_form()
{
	var _username = document.getElementById('pbox_frm_username');

	var _has_errors = false;

	if(_username.value == '')
	{
		_username.style.borderColor = '#FF8C00';
		_has_errors = true;
		_username.focus();
		return false;
	}
	else
	{
		_username.style.borderColor = '#C3C3C3';
	}

	if(_has_errors == true)
	{
		return false;
	}
	else
	{
		document.pbox_form.submit();
	}

}


function WBM_checkCreatePassword_form()
{
	var _password = document.getElementById('pbox_frm_password');
	var _confirm = document.getElementById('pbox_frm_confirm');

	var _has_errors = false;

	if(_password.value == '')
	{
		_password.style.borderColor = '#FF8C00';
		_has_errors = true;
		_password.focus();
		return false;
	}
	else
	{
		_password.style.borderColor = '#C3C3C3';
	}

	if(_confirm.value == '')
	{
		_confirm.style.borderColor = '#FF8C00';
		_has_errors = true;
		_confirm.focus();
		return false;
	}
	else
	{
		_confirm.style.borderColor = '#C3C3C3';
	}

	if(_password.value != '' && _confirm.value != '' && _confirm.value != _password.value)
	{
		_password.style.borderColor = 'red';
		_confirm.style.borderColor = 'red';
		_has_errors = true;
		_password.focus();
		return false;
	}

	if(_has_errors == true)
	{
		return false;
	}
	else
	{
		document.pbox_form.submit();
	}

}

function WBM_gotoItem(_id, _direction, _view, _category) {

	new Ajax.Request('includes/ajax/ras_homepage.php', {
		method: 'get',
		parameters: {item_id: _id, direction: _direction, viewDIV: _view, category: _category},
			  
		onSuccess: function(transport){
			var response = transport.responseText;
			$(_view).innerHTML = response;
		},
		onFailure: function() { WBM_reportError(); },
		onComplete: function() { main_height(); }
	});	

}

function WBM_reportError(request) {
	alert("Error");
}

function WBM_documentPrint()
{
	window.print(); 
}

function WBM_communityProvider()
{
	var serviceType = $('service-type');
	var serviceSubType = $('service-sub-type');
	var serviceSubTypeContainer = $('service-sub-type-container');

	if(serviceType && serviceSubType)
	{
		if(serviceType.value != '')
		{
			new Ajax.Request('includes/ajax/provider_subtype.php', {
				method: 'get',
				parameters: {pos: serviceType.value},
			  
				onSuccess: function(transport){
					var response = transport.responseText;
					serviceSubTypeContainer.innerHTML = response;
				}
			});		
		}

		serviceType.onchange = function()
		{
			new Ajax.Request('includes/ajax/provider_subtype.php', {
				method: 'get',
				parameters: {pos: this.value},
			  
				onSuccess: function(transport){
					var response = transport.responseText;
					serviceSubTypeContainer.innerHTML = response;
				}
			});
		}

	}
}

var WBM_providerFocus = true;
var WBM_providerError = false;

function WBM_provider_inputValidation(_element)
{
	if(_element.value == '' || _element.value*1 == 0)	
	{
		_element.style.border = '1px solid #FF0000';

		WBM_providerError = true;

		if(WBM_providerFocus == true)
		{
			_element.focus();
			WBM_providerFocus = false;
		}
	}
	else
	{
		_element.style.borderColor = '#C3C3C3';
		return false;
	}
}

function WBM_provider_inputConfirmValidation(_element, _element_confirm)
{
	if(_element.value != _element_confirm.value)	
	{
		_element.style.borderColor = '#FF0000';
		_element_confirm.style.borderColor = '#FF0000';

		WBM_providerError = true;

		if(WBM_providerFocus == true)
		{
			_element.focus();
			WBM_providerFocus = false;
		}
	}
	else
	{
		_element.style.borderColor = '#C3C3C3';
		_element_confirm.style.borderColor = '#C3C3C3';
		return false;
	}
}


function WBM_provider_formCheck()
{
	var checkIt = $('community-provider-form') ? true : false;

	if(checkIt)
	{
		var _businessType = $('business-type');
		var _businessName = $('business-name');
		var _abnAcn = $('abn-acn');
		var _firstName = $('first-name');
		var _lastName = $('last-name');
		var _businessAddress = $('business-address');
		var _suburb = $('suburb');
		var _state = $('state');
		var _postcode = $('postcode');
		var _contactNumber = $('contact-number');
		var _email = $('email');
		var _confirmEmail = $('confirm-email');
		var _password = $('password');
		var _confirmPassword = $('confirm-password');
		var _serviceType = $('service-type');
		var _serviceSubType = $('service-sub-type');
		var _typeOfBusiness = $('type-of-business');

		var _degreesQualifications01 = $('degrees-qualifications-01');
		var _defreesQualificationsYear01 = $('year-completed-01');
		var _degreesQualifications02 = $('degrees-qualifications-02');
		var _defreesQualificationsYear02 = $('year-completed-02');
		var _degreesQualifications03 = $('degrees-qualifications-03');
		var _defreesQualificationsYear03 = $('year-completed-03');

		var _employmentHistory01 = $('employment-history-01');
		var _employmentYear01 = $('employment-year-01');
		var _employmentHistory02 = $('employment-history-02');
		var _employmentYear02 = $('employment-year-02');
		var _employmentHistory03 = $('employment-history-03');
		var _employmentYear03 = $('employment-year-03');


		$('button-apply').onclick = function()
		{
			WBM_providerFocus = true;
			WBM_providerError = false;

			WBM_provider_inputValidation(_businessType);
			WBM_provider_inputValidation(_businessName);
			WBM_provider_inputValidation(_abnAcn);
			WBM_provider_inputValidation(_firstName);
			WBM_provider_inputValidation(_lastName);
			WBM_provider_inputValidation(_businessAddress);
			WBM_provider_inputValidation(_suburb);
			WBM_provider_inputValidation(_state);
			WBM_provider_inputValidation(_postcode);
			WBM_provider_inputValidation(_contactNumber);
			WBM_provider_inputValidation(_email);
			WBM_provider_inputValidation(_confirmEmail);
			WBM_provider_inputValidation(_password);
			WBM_provider_inputValidation(_confirmPassword);
			WBM_provider_inputValidation(_serviceType);
			WBM_provider_inputValidation(_typeOfBusiness);

			WBM_provider_inputValidation(_degreesQualifications01);
			WBM_provider_inputValidation(_defreesQualificationsYear01);
			WBM_provider_inputValidation(_employmentHistory01);
			WBM_provider_inputValidation(_employmentYear01);

			WBM_provider_inputConfirmValidation(_email, _confirmEmail);
			WBM_provider_inputConfirmValidation(_password, _confirmPassword);

			return (WBM_providerError == true ? false : true); 
		}

		$('button-upload').onclick = function()
		{
			WBM_providerError = false;

			var _uploadTermsLabel = $('upload-terms');
			var _uploadTermsCheck = $('upload-pictures-check');
			var _uploadMainPicture = $('upload-picture-1');
			var _uploadMainPictureLabel = $('upload-picture-1-label');

			//main photo
			if(_uploadMainPicture.value == '')
			{
				_uploadMainPictureLabel.style.color = '#FF0000';
				_uploadMainPicture.focus();
				WBM_providerError = true;

				return false;				
			}			
			else
			{
				_uploadMainPictureLabel.style.color =  '#000000';
			}				
			
			//terms checkbox			
			if(_uploadTermsCheck.checked == false)
			{
				_uploadTermsLabel.style.color =  '#FF0000';
				_uploadTermsCheck.focus();
				WBM_providerError = true;

				return false;
			}
			else
			{
				_uploadTermsLabel.style.color =  '#A1A1A1';
			}

			return (WBM_providerError == true ? false : true);
		}

	}
}

function WBM_load_graph_data (_chart_id,_data_file,_view){
	new Ajax.Request('includes/ajax/'+_data_file, {
		method: 'post',
		parameters: {view: _view},
		onSuccess: function(transport){
			var response = transport.responseText;
			var t = findSWF(_chart_id); 
			t.load(response);
			//$(_view).innerHTML = response;
		},
		onFailure: function() { WBM_reportError(); }
	});
}

function findSWF(movieName) {
  if (navigator.appName.indexOf("Microsoft")!= -1) {
    return window["ie_" + movieName];
  } else {
    return document[movieName];
  }
}

function WBM_addGoal(){
		var val_url = 'includes/ajax/goals_action.php';

		var val_goal = $('#enter-goal').val();
		var val_day = $('#goalday').val();
		var val_month = $('#goalmonth').val();
		var val_year = $('#goalyear').val();
		var val_range = $('#curRange').val();
		
		new Ajax.Request(val_url ,{
			method: 'get',
			parameters: {entergoal: val_goal,day: val_day,month: val_month,year: val_year,range: val_range,action: "add"},
			onSuccess: function(newGoalList){
				$('#goalList').html(newGoalList.responseText);      
			}
		});
		return false;
}

function WBM_completeGoal(goal_id){
		//alert(window.location.href);
		var val_url = 'includes/ajax/goals_action.php';
		var val_range = $('#curRange').val();

		new Ajax.Request(val_url ,{
			method: 'get',
			parameters: {goal_id: goal_id,range: val_range,action: "complete"},
			onSuccess: function(newGoalList){
				$('#goalList').html(newGoalList.responseText);      
			}
		});
		return false;
}

function WBM_delGoal(goal_id,status){
		//alert(window.location.href);
		var val_url = 'includes/ajax/goals_action.php';
		var val_range = $('#curRange').val();

		new Ajax.Request(val_url ,{
			method: 'get',
			parameters: {goal_id: goal_id,range: val_range,action: "delete",status: status},
			onSuccess: function(newGoalList){
				$('#goalList').html(newGoalList.responseText);      
			}
		});
}

function WBM_changeView(status,range){
		//alert(window.location.href);
		var val_url = 'includes/ajax/goals_action.php';

		new Ajax.Request(val_url ,{
			method: 'get',
			parameters: {status: status,range: range,action: "view"},
			onSuccess: function(newGoalList){
				$('#goalList').html(newGoalList.responseText);      
			}
		});
}

document.write("<script type=\"text/javascript\" src=\"includes/other/search.js\"></script>");