function sub_register(){
var u=document.getElementById("username");
var p=document.getElementById("password");
var pr=document.getElementById("re_password");
var em=document.getElementById("email");
var emr=document.getElementById("re_email");
var s=document.getElementById("sex");
var d=document.getElementById("day");
var m=document.getElementById("month");
var y=document.getElementById("year");
var l=document.getElementById("location");


var cm = '';
//////////////check login lenght
var user=u.value;

if(user.length<3 || user.length>10){
	alert(user.length);
cm+="• please enter the characters between 3 and 10 \n";
}

//////////////check password
if(p.value==''){
cm+="• please insert password /n";
}else{
if(p.value!=pr.value){
cm+="• password not match. please try again. \n";
}
}
//////////////check email
if(em.value==''){
cm+="• please insert email \n";
}else{
if(em.value!=emr.value){
cm+="• email not match. please try again. \n";
}else{

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(!filter.test(em.value)){
	cm+="• email format. \n";
	}

}
}



if(cm==''){
document.form1.submit();
}else{
var al = " \n"+cm;
alert(cm);
}

}




function saveprofile(type){


if(type=='general'){

	 var phone = $("#edit_phone").val();  
	 var address = $("#edit_address").val();     
	var firstname = $("#edit_firstname").val();   
	 var country = $("#edit_country  :selected").val();  
	 var lastname = $("#edit_lastname").val();  
	 var state = $("#edit_state  :selected").val();  
	 var sex = $('input[name=edit_sex]:checked').val();  
	 var ethnicity = $("#edit_ethnicity  :selected").val();  
	 var city = $("#edit_city").val();  
	 var potal = $("#edit_potal").val();  

$.post("page/edit_profile_save.php", { type: type, edit_phone:phone, edit_address:address, edit_firstname:firstname, edit_country:country, edit_lastname:lastname, edit_state:state, edit_sex:sex, edit_ethnicity:ethnicity, edit_city:city, edit_potal:potal },
  function(data){
    //alert("Data Loaded: " + data);
  });

}




if(type=='bio'){

	 var height = $("#edit_bio_height  :selected").val();  
	 var weight = $("#edit_bio_weight  :selected").val();  
	 var build = $("#edit_bio_build  :selected").val();  
	 var mannerism = $("#edit_bio_mannerism  :selected").val();  
	 var facialhair = $("#edit_bio_facialhair  :selected").val();  
	 var bodyhair = $("#edit_bio_bodyhair  :selected").val();  
	 var complexion = $("#edit_bio_complexion  :selected").val();  
	 var piercings = $("#edit_bio_piercings  :selected").val();  
	 var tattoos = $('input[name=edit_bio_tattoos]:checked').val();
	 var shoesize = $("#edit_bio_shoesize  :selected").val();  
	 var cut = $("#edit_bio_cut  :selected").val();  
	 var status = $("#edit_bio_status  :selected").val();  
	 var hetero_marriage = $("#edit_bio_hetero_marriage  :selected").val();  

$.post("page/edit_profile_save.php", { type: type, edit_bio_height:height, edit_bio_weight:weight, edit_bio_build:build, edit_bio_mannerism:mannerism, edit_bio_facialhair:facialhair, edit_bio_bodyhair:bodyhair, edit_bio_complexion:complexion, edit_bio_piercings:piercings, edit_bio_tattoos:tattoos, edit_bio_shoesize:shoesize, edit_bio_cut:cut, edit_bio_status:status, edit_bio_hetero_marriage:hetero_marriage },
  function(data){
    //alert("Data Loaded: " + data);
  });

}



if(type=='about'){

var myoccupation = $("#edit_ab_myoccupation :selected").val();
var smokehabit = $('input[name=edit_ab_smokehabit]:checked').val();
var drug = $('input[name=edit_ab_drug]:checked').val();
var role = $("#edit_ab_role :selected").val();
var praticesafesex = $("#edit_ab_praticesafesex :selected").val();
var ownplace = $('input[name=edit_ab_ownplace]:checked').val();
var religion = $("#edit_ab_religion :selected").val();
var drinkhabit = $('input[name=edit_ab_drinkhabit]:checked').val();
var orientation = $("#edit_ab_orientation :selected").val();
var hiv = $('input[name=edit_ab_hiv]:checked').val();
var howoutareyou = $("#edit_ab_howoutareyou :selected").val();
var spoken = $("#edit_ab_spoken :selected").val();
var txt_aboutme = $("#edit_txt_aboutme").val();

$.post("page/edit_profile_save.php", { type: type, myoccupation: myoccupation, smokehabit: smokehabit, drug: drug, role: role, praticesafesex: praticesafesex, ownplace: ownplace, religion: religion, drinkhabit: drinkhabit, orientation: orientation, hiv: hiv, howoutareyou: howoutareyou, spoken: spoken, txt_aboutme:txt_aboutme},
  function(data){
    //alert("Data Loaded: " + data);
  });



}


if(type=='avatar'){

var imp = $("#imp").val();

$.post("page/edit_profile_save.php", { type: type, imp:imp },
  function(data){
    //alert("Data Loaded: " + data);
  });

}


if(type=='interest'){

var single_man=$('#single_man').attr('checked'); 
var single_women=$('#single_women').attr('checked'); 
var gay_male_couple=$('#gay_male_couple').attr('checked'); 
var gay_female_couple=$('#gay_female_couple').attr('checked'); 
var bi_couple=$('#bi_couple').attr('checked'); 
var group=$('#group').attr('checked'); 
var txt_interest = $("#edit_txt_interest").val();

if(single_man==true){ var sl1='1';}else{ var sl1='0';}
if(single_women==true){ var sl2='1';}else{ var sl2='0';}
if(gay_male_couple==true){ var sl3='1';}else{ var sl3='0';}
if(gay_female_couple==true){ var sl4='1';}else{ var sl4='0';}
if(bi_couple==true){ var sl5='1';}else{ var sl5='0';}
if(group==true){ var sl6='1';}else{ var sl6='0';}

$.post("page/edit_profile_save.php", { type: type, 'look[]': [sl1,sl2,sl3,sl4,sl5,sl6] , 'look_name[]':['single_man','single_women','gay_male_couple','gay_female_couple','bi_couple','group'], txt_interest:txt_interest},
  function(data){
    //alert("Data Loaded: " + data);
  });

}


//End Function

}


// Accept   friend

function accept_req(id){
$.post("page/request_update.php", { type: 'accept', id:id},
  function(data){
			$("#dv"+id).fadeOut("slow");
	});
}


function cancel_req(id){
$.post("page/request_update.php", { type: 'cancel', id:id},
	function(data){
			$("#dv"+id).fadeOut("slow");
	});
}


function remove_req(id){
$.post("page/request_update.php", { type: 'remove', id:id},
	function(data){
			$("#dv"+id).fadeOut("slow");
	});
}


function remove_message(id){
$.post("page/message_update.php", { type: 'remove', id:id},
	function(data){
			$("#dv"+id).fadeOut("slow");
	});
}

function send_message(id){
var txtbox = 'txts'+id;
var texts = $('text#s'+txtbox).val();
var text = $('textarea#'+txtbox).val();

$.post("page/message_update.php", { type: 'send', id:id, title:texts , txt:text},
	function(data){
			tb_remove();
	});

}


function remove_fav(id){
$.post("page/favorites_update.php", { type: 'remove', id:id},
	function(data){
			$("#dv"+id).fadeOut("slow");
	});
}


function create_album(){

var album_name = $("#album_name").val();
var album_description = $("#album_description").val();
var album_vault = $("#album_vault").val();
var album_password = $("#album_password").val();
var album_private = $("#album_private").val();

if(album_vault==''){album_password='';album_vault='0';}else{album_vault='1';}
if(album_private==''){album_private='0';}else{album_private='1';}

//alert(album_name+' / '+album_description+' / '+album_vault+' / '+album_password+' / '+album_private);

$.post("page/photo_update.php", { type: 'newalbum', album_name:album_name, album_description:album_description, album_vault:album_vault, album_password:album_password, album_private:album_private},
	function(data){
			$("#sub_select").fadeOut(1000);
			$("#main_select").html('<table border="0"><tr><td align="middle">&nbsp; <img src="images/loading.gif" border="0"></td><td align="middle"> Loading ....Please wait!</td></tr></table>');
			$("#main_select").html(data);
	});
}