function check_register(fill_all,fill_email, check_tems, fill_password)
{
	f = document.register;
	if(f.day.value==-1)
	{
		alert(fill_all);
		f.day.focus();
		return false;
	}

	if(f.month.value==-1)
	{
		alert(fill_all);
		f.month.focus();
		return false;
	}

	if(f.year.value==-1)
	{
		alert(fill_all);
		f.year.focus();
		return false;
	}

	if(!ck_text(f.country, "", fill_all))
		return false;

	if(!ck_text(f.zipcode, "", fill_all))
		return false;

	if(!ck_text(f.username, "", fill_all))
		return false;
	if(!ck_text(f.password, "", fill_all))
		return false;
	if(!ck_text(f.repassword, "", fill_all))
		return false;
	
	
	if(f.password.value!=f.repassword.value)
	{
		alert(fill_password);
		f.repassword.focus();
		return false;
	}
	if(!validate_email(f.email, fill_email))
		return false;
	if(f.terms.checked==false)
	{
		alert(check_tems);
		return false;
	}

}

function check_login(fill_all)
{
	f = document.login_form;
	if(!ck_text(f.username, "", fill_all))
		return false;
	if(!ck_text(f.password, "", fill_all))
		return false;
	
}

function check_my_account(fill_all,fill_email)
{
	f = document.my_account;

	if(!validate_email(f.email, fill_email))
		return false;

}

//=====================================================================================


function check_profile(fill_all)
{
	f = document.register;
	if(f.day.value==-1)
	{
		alert(fill_all);
		f.day.focus();
		return false;
	}

	if(f.month.value==-1)
	{
		alert(fill_all);
		f.month.focus();
		return false;
	}

	if(f.year.value==-1)
	{
		alert(fill_all);
		f.year.focus();
		return false;
	}

	if(!ck_text(f.country, "", fill_all))
		return false;

	if(!ck_text(f.zipcode, "", fill_all))
		return false;

	
	
	

}

//=====================================================================================



function check_distance(){
	
	var formn = document.search;	
	
	if(formn.plz.value.length==5) {
		formn.km.disabled=false;
		//formn.km.value = '0';
		
	}else{
			formn.km.value="0";
			formn.km.disabled=true;
		
	}
}	

//=====================================================================================


function countryCheck(){
	

	var formn = document.forms['search'];

	if(formn.country[formn.country.selectedIndex].value==77)
	{
		formn.plz.disabled = false;

	}
	else
	{
		formn.plz.disabled = true;
		formn.plz.value = '';
	}
	

	check_distance();
	  
	 return true;
}

//=====================================================================================



function shoutbox_count()
{
	var d=document;
	
	

	var url = "./includes/server/shoutbox_count.php";

	var myAjax = new Ajax.Request( url,

										{ method: 'get',
										  onComplete: set_action_shoutbox_count
										}

									 );
}

//=====================================================================================


function set_action_shoutbox_count(originalRequest)
{
	
	Try.these(
		function () {
			var xml = originalRequest.responseXML;//we have the xml object	
			
			
			
			respNode = xml.getElementsByTagName("response")[0];		
			items = respNode.getElementsByTagName("item");

					
			name_action = items[0].getElementsByTagName("name")[0].firstChild.nodeValue;
			value_shoutbox = items[0].getElementsByTagName("value")[0].firstChild.nodeValue;	

			value_message = items[1].getElementsByTagName("value")[0].firstChild.nodeValue;	

			value_message_2 = items[2].getElementsByTagName("value")[0].firstChild.nodeValue;	

		


			var div_errors_page = $("display_invitations");
			
			if(value_shoutbox!="0")
			{
				value_shoutbox = "<font color='#ff0000'><b>"+value_shoutbox+"</b></font>";

				
				var chat_invitations = $("chat_invitations");
				chat_invitations.style.display = "block";

				var chat_invitations_text = $("chat_invitations_text");
				chat_invitations_text.innerHTML = "<font color='#ff0000'><b>"+value_message+"</b></font><br/><br/><a href='chat_all_inv.php'>"+value_message_2+"<br/><br/></a>";
			}

			div_errors_page.innerHTML = value_shoutbox;

			
					

		}

	);//end try

}

//===================================================

function image_change_div(img_name, img_src)
{
	var image_div = $("images_div");
	image_div.style.display = "block";

	var about_me_div = $("about_me_div");
	about_me_div.style.display = "none";

	var looking_for_div = $("looking_for_div");
	looking_for_div.style.display = "none";

	var questions_div = $("questions_div");
	questions_div.style.display = "none";
	
	
	image_change(img_name, img_src);
}


//===================================================

function about_me_ch_div()
{
	var image_div = $("images_div");
	image_div.style.display = "none";

	var about_me_div = $("about_me_div");
	about_me_div.style.display = "block";
	
	var looking_for_div = $("looking_for_div");
	looking_for_div.style.display = "none";

	var questions_div = $("questions_div");
	questions_div.style.display = "none";

	var about_me_ch_a = $("about_me_ch_a");
	about_me_ch_a.className = "sel_tab_a";
	var about_me_ch_s = $("about_me_ch_s");
	about_me_ch_s.className = "sel_tab_span";


	var looking_for_ch_a = $("looking_for_ch_a");
	looking_for_ch_a.className = "not_sel_tab_a";
	var looking_for_ch_s = $("looking_for_ch_s");
	looking_for_ch_s.className = "not_sel_tab_span";

	var questions_ch_a = $("questions_ch_a");
	questions_ch_a.className = "not_sel_tab_a";
	var questions_ch_s = $("questions_ch_s");
	questions_ch_s.className = "not_sel_tab_span";

	

}

//===================================================

function looking_for_ch_div()
{
	var image_div = $("images_div");
	image_div.style.display = "none";

	var about_me_div = $("about_me_div");
	about_me_div.style.display = "none";

	var looking_for_div = $("looking_for_div");
	looking_for_div.style.display = "block";

	var questions_div = $("questions_div");
	questions_div.style.display = "none";

	var about_me_ch_a = $("about_me_ch_a");
	about_me_ch_a.className = "not_sel_tab_a";
	var about_me_ch_s = $("about_me_ch_s");
	about_me_ch_s.className = "not_sel_tab_span";

	var looking_for_ch_a = $("looking_for_ch_a");
	looking_for_ch_a.className = "sel_tab_a";
	var looking_for_ch_s = $("looking_for_ch_s");
	looking_for_ch_s.className = "sel_tab_span";

	var questions_ch_a = $("questions_ch_a");
	questions_ch_a.className = "not_sel_tab_a";
	var questions_ch_s = $("questions_ch_s");
	questions_ch_s.className = "not_sel_tab_span";
	
}

//===================================================

function questions_ch_div()
{
	var image_div = $("images_div");
	image_div.style.display = "none";

	var about_me_div = $("about_me_div");
	about_me_div.style.display = "none";

	var looking_for_div = $("looking_for_div");
	looking_for_div.style.display = "none";
	
	var questions_div = $("questions_div");
	questions_div.style.display = "block";

	var about_me_ch_a = $("about_me_ch_a");
	about_me_ch_a.className = "not_sel_tab_a";
	var about_me_ch_s = $("about_me_ch_s");
	about_me_ch_s.className = "not_sel_tab_span";

	var looking_for_ch_a = $("looking_for_ch_a");
	looking_for_ch_a.className = "not_sel_tab_a";
	var looking_for_ch_s = $("looking_for_ch_s");
	looking_for_ch_s.className = "not_sel_tab_span";

	var questions_ch_a = $("questions_ch_a");
	questions_ch_a.className = "sel_tab_a";
	var questions_ch_s = $("questions_ch_s");
	questions_ch_s.className = "sel_tab_span";
	
	
}

//======================================
function change_current_page(new_page)
{
	f = document.search_form;
	f.current_page.value = new_page;
	f.submit();
}


//=====================================================================================



function msg_count()
{
	var d=document;
	
	

	var url = "./includes/server/msg_count.php";

	var myAjax = new Ajax.Request( url,

										{ method: 'get',
										  onComplete: set_action_msg_count
										}

									 );
}

//=====================================================================================


function set_action_msg_count(originalRequest)
{
	
	Try.these(
		function () {
			var xml = originalRequest.responseXML;//we have the xml object	
			
			
			
			respNode = xml.getElementsByTagName("response")[0];		
			items = respNode.getElementsByTagName("item");

					
			name_action = items[0].getElementsByTagName("name")[0].firstChild.nodeValue;
			value_shoutbox = items[0].getElementsByTagName("value")[0].firstChild.nodeValue;	

		


			var div_errors_page = $("display_msg_no");
			
			if(value_shoutbox!="0")
			{
				value_shoutbox = "<font color='#ff0000'><b>"+value_shoutbox+"</b></font>";
			}

			div_errors_page.innerHTML = value_shoutbox;

			
					

		}

	);//end try

}

//===================================================


function close_div(id)
{
	var div_id = $(id);

	div_id.style.display="none";
}

//=====================================================

function open_chat(inv_id)
{

	window_open("chat_invite_action.php?inv_id="+inv_id+"&valid=accepted", "chat", "yes", "no", 450, 600 );
	window.location = "chat_all_inv.php";

}
