//deleted doubles
function set_new_password()
{
	
	var current_pass = jQuery('#input_text_0').val();
	var new_pass = jQuery('#input_text_1').val();
	var vld_pass = jQuery('#input_text_2').val();
	var validator = true;
	
	if(current_pass==''){
		jQuery('#current_pswd').html();
		validator = false;
	}
	else
	{
		
		jQuery.post("/ajax.php",
		{action: 'get_current_user_pass', pass: current_pass},
		function(data)
		{ 	
			if(data==1){
				jQuery('#current_pswd').html('');
				if(new_pass=='')
				{
					jQuery('#passwordDescription').html(PASS_INSERT_PASSWORD);							
				}
				else
					if(jQuery('#check_paswd').val()>1)
					{						
						if(vld_pass!='' && new_pass==vld_pass)
						{
							 jQuery.post("/ajax.php",
							 {action: 'change_paswd_to_email', elem: new_pass},
							 function(data)
							 { 
							 	jQuery("#rem_n_pass").remove();
							 	jQuery("#rem_c_pass").remove();
							 	jQuery("#chng_pass_but").remove();
							 	jQuery("#rem_o_pass").remove();
							 	
							    jQuery("#chng_pswd").html(
							    	"<br /><strong>"+PASS_INSERT_PASSWORD_RESET+"</strong><br /><br />"+
									PASS_INSERT_PASSWORD_SENT+"."
								);
								
								 jQuery("#chng_pswd").fadeTo(2000,0.1,function(){
						                jQuery(this).html(
											"<br /><strong>"+PASS_INSERT_PASSWORD_RESET+"</strong><br /><br />"+
											PASS_INSERT_PASSWORD_SENT+"."				
										).fadeTo(1,1);
										document.location='/home';  
						            });
													 		
							 	
							 });					
						}						
					}
			}
		 	else
		 		jQuery('#current_pswd').html('Wrong password');
		});	
	}

}

function resetpswd()
{
	var name = jQuery('#rspswd_input_text_0').val();
	var elem = jQuery('#rspswd_input_text_1').val();
	jQuery.post("/ajax.php",
	{action: 'get_current_user_email', name: name, email: elem},
	function(data)
	{ 	
		if(data!=1) {			
		   jQuery(".input_text_1").html(RESET_PWD_WRONG_EMAIL); 
		   jQuery(".input_text_1").show(); 	
		   return false;	   
		} 		 	
		else { 		
			jQuery.post("/ajax.php",
			{action: 'reset_paswd_to_email', email: elem, name: name},
			function(data){
				jQuery("form").submit();				
			});
			/*
			var overlay = jQuery("#overlay");
		    var w = jQuery(window).width();
		    //var h = jQuery(window).height();
		    var h = 1000;
		    overlay.css('width', w);
		    overlay.css('height', h);
		    overlay.css('display','block');   
		    jQuery("#reset_pass").show();	
		    		  		    
		    jQuery("#reset_pass").fadeTo(200,0.1,function(){
                jQuery(this).html(
					"<br /><center><strong>Your password has been reset</strong><br /><br />"+
					"An email has been sent to your email addresses "+elem+".<br /><br />"+ 
					"This email describes how to get your new password.</center>"				
				).pause(10).fadeTo(900,1);
            });	 */
			//document.location='/login';  
		}
	});	
}

function check_user(type)
{	
	var allFlag = false;
	
	if(type=='register')
	{
		var us_val	=	jQuery('#reg_input_text_0').val();
	}
	else if(type=='resetpswd')
	{
		var us_val	=	jQuery('#rspswd_input_text_0').val();
	}
	else
	{
		var us_val	=	jQuery('#input_text_0').val();
	}
 	var count_val		=	us_val.length;	
 	var username_format = 	/^([a-zA-Z]|\d)$/;  	
 	var final_un		= 	''; 	
 	elements = us_val.split(''); 	
 	for(i=0; i<count_val;i++){ 		
 		if(username_format.exec(elements[i])){
 			final_un = final_un+''+elements[i]; 			 
		}
 	}
 	var final_un = final_un.toLowerCase();
 	var f_un     = final_un.length;
 	
 	if(type=='register')
	{
		jQuery('#reg_input_text_0').val(final_un); 
	}	
	else if(type=='resetpswd')
	{
		jQuery('#rspswd_input_text_0').val(final_un); 
	}
	else
	{
		jQuery('#input_text_0').val(final_un); 
	}
 		
 	
 	if(type=='submit_current_user'){
 		if(f_un>4){
 			get_current_user_name(final_un); 			
 		}
 		else if(f_un == 0){
 			jQuery("#login_result").fadeTo(200,0.1,function(){
                jQuery(this).html(CHECK_USER_NICKNAME).removeClass().addClass('error').fadeTo(900,1);
            });	 		
 		}
 		
 		else{
 			jQuery("#login_result").fadeTo(200,0.1,function(){
                jQuery(this).html(CHECK_USER_NICKNAME_TOO_SHORT).removeClass().addClass('error').fadeTo(900,1);
            });	 		
 		} 		
 	}
 	else if(type=='register')
 	{
		if(f_un>4 && document.getElementById("chkAgeVerification").checked)
	 	{
	 		get_user_name(final_un);
	 	}	 	
	 	else {
			jQuery("#reg_user").attr("disabled","disabled");
		}		
	}  
	else if(type=='resetpswd'){				
		if(f_un>4) {
	 		get_reset_user_name(final_un);	 				
		}
	 	else 
	 		jQuery("#reg_user").attr("disabled","disabled");
	}	

	
}

function check_search_user(type)
{	
 	var us_val			=	jQuery('#input_text_0').val();
 	var count_val		=	us_val.length;	
 	var username_format = 	/^([a-zA-Z]|\d|\"|\s)$/;  	
 	var final_un		= 	'';
 	elements = us_val.split(''); 	
 	for(i=0; i<count_val;i++){ 			
 		if(username_format.exec(elements[i])){
 			final_un = final_un+''+elements[i]; 			 
		}
 	}
 	//var final_un = final_un.toLowerCase();
 	var f_un     = final_un.length;
 	
 	jQuery('#input_text_0').val(final_un); 	
 	
 	if ( type == 'search_friend'){
		if(f_un > 4)
			return true;
		else
			return false;
	}	
}

function get_reset_user_name(elem_id)
{
 jQuery.post("/ajax.php",
 {action: 'get_current_user', id: elem_id},
 function(data)
 { 	
 	if(data!=1) {
 	   jQuery(".input_text_0").html(RESET_USERNAME_WRONG_NAME+' ...').addClass('error'); 		
 	   jQuery(".input_text_0").show();
 	   jQuery("#reg_user").attr("disabled","disabled");  
 	   /*
 	   jQuery(".input_text_0").fadeTo(200,0.1,function(){
           jQuery(this).html('Wrong nickname ...').addClass('error').fadeTo(900,1);
           return false;
       }); 	*/	
 	} 		 	
 	else { 		
 		jQuery(".input_text_0").removeClass('error');
 		jQuery(".input_text_0").hide();
 		jQuery("#reg_user").removeAttr("disabled");  
 	}
 });
}

function get_user_name(elem_id)
{	
 jQuery.post("/ajax.php",
 {action: 'get_user', id: elem_id},
 function(data)
 { 	 	
 	if(data==false) { 
 		jQuery('.input_text_0').show();
 		jQuery('#reg_input_text_0').addClass('err');
 		jQuery("#reg_user").attr("disabled","disabled");
 		if(jQuery('#us_valid').val()==1) jQuery("#us_valid").val('0');
 	}	 	
 	else {
 		jQuery("#reg_input_text_0").removeClass("err");
 		jQuery('.input_text_0').hide();
 		jQuery("#reg_user").removeAttr("disabled");  		
 		if(jQuery('#us_valid').val()==0) jQuery("#us_valid").val('1');		
 	}
 });
}

function get_current_user_name(elem_id)
{	
 jQuery.post("/ajax.php",
 {action: 'get_current_user', id: elem_id},
 function(data)
 { 	
 	if(data!=1) { 
 	   jQuery("#login_result").fadeTo(200,0.1,function(){
           jQuery(this).html(RESET_USERNAME_WRONG_NAME).removeClass().addClass('error').fadeTo(900,1);
           return false;
       }); 		
 	}
 		 	
 	else { 		
 		validate_paswd(elem_id);	
 	}
 });
}

function validate_paswd(elem_id)
{
	var pass = jQuery('#input_text_1').val();	
//	var data1 = "<table><tr><td></td></tr></table>"
	if(pass != ''){
		jQuery.post("/ajax.php",
		 {action: 'get_current_pass', name: elem_id, password: pass},
		 function(data)
		 { 			 
		
		 	if(data!=1) { 
		 	   jQuery("#login_result").fadeTo(200,0.1,function(){
		           jQuery(this).html(VALIDATE_PWD_WRONG_PASSWORD).removeClass().addClass('error').fadeTo(900,1);		          
		       }); 		
		 	}	 	
		 	else { 
				 
		 		 jQuery("#login_result").fadeTo(200,0.1,function() {
                   jQuery(this).html(VALIDATE_PWD_VALIDATING+'....').removeClass().addClass('success').fadeTo(900,1,
                           function() {			
						   				//	alert("Here...Logged");
						   					new_function();
						   				   // alert("Here...Logged in successfully");
										    //pupup_buddy_options(data);
											//	  document.location='/home&showHome=fromLogin';
                           });
                 });

		 	}
		 });
	}
	else{
		jQuery("#login_result").fadeTo(200,0.1,function(){
           jQuery(this).html(VALIDATE_PWD_ENTER_PASSWORD).removeClass().addClass('error').fadeTo(900,1); 
		   
        });          
	}	
}


function new_function()
{
		
		
	var id = "222";
		jQuery.post("/ajax.php",
		{action: 'change_usertype'},
		
		function(data){			
			if(data != 0)
			{
			//	alert(data);
				pupup_buddy_options1(data);
			}
			else
			{
				document.location='/home&showHome=fromLogin';
			}
			
	});

}
function fetched_usertype()
{
	//alert("herererererer");
//	jQuery("form").submit();	
    var value1 = document.getElementById('hidden_type').value;
//    var value2 = document.getElementById('change_type_d').value;
	
	//alert(value1);
	//alert(value2);
	var usertype = value1;

//	alert(value);
	jQuery.post("/ajax.php",
		{action: 'update_usertype', newusertype : value1},
		
		function(data)
		{
//			alert(data);
			if(data == 1)
			{
			//	location.reload;
				document.location='/home&showHome=fromLogin';
			}
		});
}

function validEmail()
{
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var emailToVal = jQuery("#reg_input_text_1").val();	
	
	if(emailToVal == '') {
		jQuery('.input_text_1').html(VALIDE_EMAL_FORGOT_EMAIL);
		jQuery('.input_text_1').show();
	 	jQuery('#reg_input_text_1').addClass('err');		
	} else if(!emailReg.test(emailToVal)) {
		jQuery('.input_text_1').html(VALID_EMAIL_VALID_EMAIL);
		jQuery('.input_text_1').show();
	 	jQuery('#reg_input_text_1').addClass('err');			
	} else {
		 jQuery.post("/ajax.php",
		 {action: 'validate_email', email: emailToVal},
		 function(data)
		 {	 	
		 	if(data!=1) { 
		 		if(data=='dublicate_email')
		 			jQuery('.input_text_1').html(VALID_EMAIL_ALREADY_USE);
		 		else
		 			jQuery('.input_text_1').html(VALID_EMAIL_VALID_EMAIL);
		 		jQuery('.input_text_1').show();
		 		jQuery('#reg_input_text_1').addClass('err');		 		
		 	}	 	
		 	else {
		 		jQuery("#reg_input_text_1").removeClass("err");
		 		jQuery('.input_text_1').hide();
		 		if(jQuery('#us_valid').val()==1){
		 			var usName = jQuery('#reg_input_text_0').val();
					var selGender = jQuery('#selGender').val();					
		 			send_email(emailToVal, usName, selGender);	
		 		}
		 	}
		});
	}
}

function validCoupon()
{

	var CouponToVal = jQuery("#reg_input_text_2").val();	
	
	if(CouponToVal != '') 
	{
		 jQuery.post("/ajax.php",
		 {action: 'validate_coupon', coupon_number: CouponToVal},

		 function(data)
		 {
				 
			//INVALID_COUPON = "dddddd";
		
		 	if(data!=1) { 
			
		 		jQuery('.input_text_3').html(INVALID_COUPON);
		 		jQuery('.input_text_3').show();
		 		jQuery('#reg_input_text_2').addClass('err');		 		
				
		 	}	 	
		 	else {
		 		jQuery("#reg_input_text_2").removeClass("err");
		 		jQuery('.input_text_3').hide();
		 		}
		});
		 
		 return false;
	}
}
var profile_type="";
jQuery(document).ready(function() {
	jQuery("input:radio").click(function(){Profile_type= jQuery(this).val()});
});
function send_email(email, usname, selGender)
{	
var CouponToVal = jQuery("#reg_input_text_2").val();





 jQuery.post("/ajax.php",
		{action: 'send_email', email: email, usname: usname, selGender : selGender , coupon : CouponToVal, Profile_type : Profile_type},
			function(data)
		 	{
		//alert(data);
			document.location='/reg_first_step';  		 		
		 	});
}

function passwordStrength(password)
{
	var pass = jQuery('#reg_input_text_1').val();
	var desc = new Array();
	desc[0] = "&nbsp;&nbsp;"+PASSWORD_STRENGTH_VERY_WEAK;
	desc[1] = "&nbsp;&nbsp;"+PASSWORD_STRENGTH_WEAK;
	desc[2] = "&nbsp;&nbsp;"+PASSWORD_STRENGTH_BETTER;
	desc[3] = "&nbsp;&nbsp;"+PASSWORD_STRENGTH_MEDIUM;
	desc[4] = "&nbsp;&nbsp;"+PASSWORD_STRENGTH_STRONG;
	desc[5] = "&nbsp;&nbsp;"+PASSWORD_STRENGTH_STRONGESET;

	var score   = 0;
	var lght = password.length;
	//if password bigger than 6 give 1 point
	if (lght > 5) score++;

	//if password has both lower and uppercase characters give 1 point	
	if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;

	//if password has at least one number give 1 point
	if (password.match(/\d+/) && lght>4) score++;

	//if password has at least one special caracther give 1 point
	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)  && lght>3)	score++;

	//if password bigger than 12 give another 1 point
	if (password.length > 8) score++;	

	 document.getElementById("passwordDescription").innerHTML = desc[score];
	 document.getElementById("passwordStrength").className = "strength" + score;
	 jQuery('#check_paswd').val(score);
	 
	 if(password==pass) { // && score>1
		jQuery("#reg_user").removeAttr("disabled"); 		
	 }
	 else {
		jQuery("#reg_user").attr("disabled","disabled");
	 }
}
function check_confirm_pass(password)
{
	var pass = jQuery('#reg_input_text_0').val();
	var desc = jQuery('#check_paswd').val();
	
	if(password==pass) // && desc>1
		jQuery("#reg_user").removeAttr("disabled"); 
	else		
		jQuery("#reg_user").attr("disabled","disabled"); 
}

function complete_user_profile(){
	var pas = jQuery('#step').val();
	if(pas='1'){
		jQuery('#step').val('2');
		jQuery('#first_part').hide();	
		jQuery('#second_part').show();
		jQuery('#user_pr_data1').remove();
		jQuery('#user_pr_data1').remove();
		jQuery('#user_profile').append('<input type="submit" value="'+SUBMIT+'" id="user_pr_data1" onclick="complete_user_profile();" style="margin-left:139px;" />');
	}
	/*jQuery("#user_profile").post_form("/user_profile", function(data){	
		//alert('result='+data);
	});*/
}

function check_postal_code(){
	var postalCode = jQuery('#input_text_6').val();
    var country = jQuery('#input_text_5 :selected').text();   
    var count_pc = postalCode.length;
    var format_default = /^([0-9]+)$/;
    var format = /^([0-9]+)$/;
    var format_a = /^([a-zA-Z]+)$/;
    var final_un = '';
	var elements = postalCode.split(''); 
    var score = 0;
    var valid = false;
    if(postalCode!='')
    switch (country) {
        case "NETHERLANDS":         	
        	
        	for(i=0; i<4;i++){ 		
		 		if(format.exec(elements[i]) && elements[0]>0){
		 			final_un = final_un+''+elements[i]; 
		 			score++;			 
				}
				jQuery('#input_text_6').val(final_un);				
		 	}
		 	
		 	for(i=4; i<6;i++){		 		
		 	 	if(count_pc>4)
		 	 	{	
		 	 		var elem = elements[i];			 	 		
		 	 		if(format_a.exec(elem)){
			 			valid = true;			 
					}					
			 		if(valid==true)
			 		{
				 		var elm = elem.toUpperCase();
				 		
				 		if(format_a.exec(elm)){
				 			final_un = final_un+''+elm;
				 			score++; 			 
						}
						jQuery('#input_text_6').val(final_un);
						if(final_un.length>5) ajax_get_pcode(final_un);	
						if(count_pc<6) break;
					}
					else break;
				}			
		 	}		 		 	 	
            break;
       case "GERMANY":
            for(i=0; i<5;i++){ 	
            	//alert(elements[i]+'###'+elements[0]);	
		 		if(format.exec(elements[i]) && elements[0]>0){
		 			final_un = final_un+''+elements[i]; 
		 			score++;			 
				}
				jQuery('#input_text_6').val(final_un);				
		 	}
            break;
        case "BELGIUM":
            for(i=0; i<4;i++){ 	
            	//alert(elements[i]+'###'+elements[0]);	
		 		if(format.exec(elements[i]) && elements[0]>0){
		 			final_un = final_un+''+elements[i]; 
		 			score++;			 
				}
				jQuery('#input_text_6').val(final_un);				
		 	}
            break;
        default:
            for(i=0; i<6;i++){ 	
            	//alert(elements[i]+'###'+elements[0]);	
		 		if(format_default.exec(elements[i]) && elements[0]>0){
		 			final_un = final_un+''+elements[i]; 
		 			score++;			 
				}
				jQuery('#input_text_6').val(final_un);				
		 	}
            break;
            
     }
}

function ajax_get_pcode(pcode)
{
	jQuery.post("/ajax.php",
	{action: 'get_pcode', pcode: pcode },
	function(data)
 	{	
 		if(data!=1) {	 		
	 		jQuery('.input_text_6').html(GET_PCODE_WRONG+'!');
	 		jQuery('.input_text_6').show();
	 		jQuery('#input_text_6').addClass('err');	
	 		jQuery('#pscd_valid').val(1);	 				
	 	}	 	
	 	else {
	 		jQuery('#pscd_valid').val(2);
	 		jQuery("#input_text_6").removeClass("err");
	 		jQuery('.input_text_6').hide();	 				 			
	 	}	
 	});
}

function change_avat(){
	jQuery('#avat').show(); 
	jQuery('#ths_avat').hide();
}

function limitChars(textid, limit, infodiv)
{
	var text = jQuery('#'+textid).val(); 
		
	text = jQuery.trim(text);
			
	var textlength = text.length;
	
	jQuery('#'+infodiv).show();
	
	if(textlength > limit)	
	{	
		jQuery('#' + infodiv).html(LIMIT_CHARACTERS_VALID+' '+limit+' '+LIMIT_CHARACTERS_CHARACTERS);		
		jQuery('#'+textid).val(text.substr(0,limit));		
		return false;	
	}	
	else	
	{	
		jQuery('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');		
		return true;	
	}
}

function saveTwitterSuccess(msg)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'saveTwitterSuccess', msg: msg },	
		function(data){				
			pupup_buddy_options(data);			
	});
	//window.setTimeout(function(){disablePopup()}, 3000);
}

function noCreditsFound(NoCredits) {
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'NoCredits', msg: NoCredits },	
		function(data){				
			pupup_buddy_options(data);			
	});
}

function add_twitter_msg(fromFlag)
{	
	if(fromFlag =='') {
		var msg = jQuery('#twit_comment').val();
		msg = jQuery.trim(msg);
	}
	else {
		var msg = jQuery('#twit_comment_1').val();
		msg = jQuery.trim(msg);
	}
	
	if(msg.length < 5)
	{
		if(fromFlag =='') {
			jQuery("#charlimitinfo").fadeTo(200,0.1,function(){
				jQuery(this).html(ADD_TWITTER_VALID).fadeTo(900,1);		          
			}); 		
		}
		else {
			jQuery("#charlimitinfo1").fadeTo(200,0.1,function(){
				jQuery(this).html(ADD_TWITTER_VALID).fadeTo(900,1);		          
			});
		}
	}
	else
	{	
		jQuery("#charlimitinfo").hide();
		jQuery.post("/ajax.php",
		{action: 'add_twitter_msg', msg: msg },	
		function(data)
	 	{	
			if(data == 'NoCredits') {
				noCreditsFound('NoCredits');
			}
			else {
				saveTwitterSuccess(ADD_TWITTER_SEND);
				data=data.split('###');
				jQuery('#content_twit_msg').prepend( 		
					'<div class="message-box-item"><div id="main_twitter_msg_'+data[0]+'" class="all_twitter_message" onmouseover="jQuery(\'#message_edit-'+data[0]+'\').show();" onmouseout="jQuery(\'#message_edit-'+data[0]+'\').hide();">'+
						'<div id="message_text">'+
							'<font size="1">'+data[1]+'</font><br />'+
							'<a href="javascript:void(0)" onclick="update_twitter_messages('+data[0]+');">'+
								'<img src="/images/edit.png" border="0" style="vertical-align:middle">'+
							'</a>'+
							'<a href="javascript:void(0)" onclick="delete_twitter_messages('+data[0]+');">'+
								' <img src="/images/delete.gif" border="0" style="vertical-align:middle">'+
							'</a>'+
							' <a href="javascript:void(0)" onclick="update_twitter_messages('+data[0]+');"  id="a_msg_twit-'+data[0]+'">'+msg+'</a>'+						
						'</div>'+
						'<!--<div id="message_edit-'+data[0]+'" style="display: none;">-->'+
							
						'<!--</div>-->'+
					'</div>'+
					'<div class="all_twitter_message_ws" id="all_twitter_message-'+data[0]+'"></div></div>');			
				
				jQuery("#twitter_messages").hide();
				jQuery("#twit_comment").val('');
			}
	 	}); 	 	
	}
}

function update_twitter_messages(msg)
{
	var mess= jQuery('#a_msg_twit-'+msg).html();
	
	jQuery('#all_twitter_message-'+msg).html('<div id="charlimitinfo_update-'+msg+'" style="position:relative;">&nbsp;</div><textarea style="position: relative;" class="twitter_reply" rows="4" name="twitter_reply" id="twit_comment_update-'+msg+'" onkeyup="limitChars(\'twit_comment_update-'+msg+'\', 160, \'charlimitinfo_update-'+msg+'\')">'+mess+'</textarea><br /><input style="position:relative;" type="button" value="Update" onclick="update_twitter_msg('+msg+');" />');
	//var overlay = jQuery("#overlay");
    //var w = jQuery(window).width();
    //var h = jQuery(window).height();
    //var h = 1000;
    //overlay.css('width', w);
    //overlay.css('height', h);
    //overlay.css('display','block');   
}

function update_twitter_msg(msg)
{
	var mess = jQuery('#twit_comment_update-'+msg).val();
	if(mess.length < 5)
	{
		jQuery('#charlimitinfo_update-'+msg).fadeTo(200,0.1,function(){
           	jQuery(this).html(ADD_TWITTER_VALID).fadeTo(900,1);		          
       	}); 		
	}
	else
	{
		jQuery.post("/ajax.php",
		{action: 'update_twitter_msg', msg: msg, mess: mess },	
		function(data)
	 	{	 		
	 		if(data==1)
	 		{	
	 			jQuery('#a_msg_twit-'+msg).html(mess);	 			
		        jQuery("#all_twitter_message-"+msg).html(''); 
		        //jQuery("#overlay").css('display','none');     			
	 		}	 			 		
	 	}); 	 
	}
}

function delete_twitter_messages(msg)
{
 	var answer = confirm(DELETE_TWITTER_MESSAGE+" ?")
    if (answer)
    {		
		jQuery.post("/ajax.php",
		{action: 'delete_twitter_msg', msg: msg },	
		function(data)
	 	{	
	 		if(data==1)
	 		{	
	 			jQuery('#main_twitter_msg_'+msg).remove();	 			
		        jQuery("#all_twitter_message-"+msg).remove(); 		            			
	 		} 			 		
	 	}); 
	}
}

/**********************************SETTING UP OUR POPUP***********************************/
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		jQuery("#backgroundPopup").css({
			"opacity": "0.7"
		});
		//jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact1").fadeIn("slow");
		popupStatus = 1;
		//window.setTimeout('disablePopup()', 5000);		
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		jQuery("#backgroundPopup").fadeOut("slow");
		jQuery("#popupContact1").fadeOut("slow");
		popupStatus = 0;
		jQuery('#overlay').fadeOut("slow");
	}
}

function disablePopup1(){

	//disables popup only if it is enabled
	if(popupStatus==1){
		jQuery("#backgroundPopup1").fadeOut("slow");
		jQuery("#popupContact1").fadeOut("slow");
		popupStatus = 0;
		
		jQuery("#overlay").css({			
			"top":0,
			"left":0
		});
		
		jQuery('#overlay').hide();	
	}
	
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#popupContact1").height();
	var popupWidth = jQuery("#popupContact1").width();
	
	
	var from_top = jQuery(window).scrollTop();	
	//centering
	jQuery("#popupContact1").css({
		"position": "absolute",
		"top": windowHeight/2+from_top-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	jQuery("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
function centerPopup1(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#popupContact1").height();
	var popupWidth = jQuery("#popupContact1").width();
	
	
	var from_top = jQuery(window).scrollTop();	
	//centering
	jQuery("#popupContact1").css({
		"position": "absolute",
		"top": windowHeight/2+from_top-popupHeight/2,
		"left": windowWidth/2-popupWidth/2,
		"z-index": 10000
	});
	//only need force for IE6
	
	jQuery("#backgroundPopup1").css({
		"height": windowHeight
	});
	
}

function shw_search_msg(type)
{	

	if(document.getElementById('advancedSearch').style.display == 'block') {
	
		var show = 0;
		
		if ( type == 'search_friend' )
		{
			var nickname = jQuery('#input_text_0').val();
			var gender   	= jQuery('#input_text_2').val();
			var lookingfor  = jQuery('#input_text_3').val();
				
			if( nickname == '' && jQuery('#nikname_val').val() == 0 && ( gender == '' || lookingfor == '' ) )
			{
				//jQuery('#contactArea1').html('When not using the free form the fields "gender" and "looking for" are manditory!');
				//jQuery('#nikname_val').val('1');
				//show = 1;
			}
			else if( nickname != '' && jQuery('#nnikname_val').val() == 0 && ( gender == '' || lookingfor == '' ) )
			{
				
				var count =0;
			
				jQuery("form select").each(function(i){			
					if(jQuery(this).val()!= '')
						count++
				 }); 
				 
				 var dif = 5 - count;
				 var chr = 'characters';
				if ( dif > 0 )						
				{				
					if( dif == 1) 
						chr = 'character';
						
					//jQuery('#contactArea1').html(SHW_SEARCH_MSG_VALID+' '+dif+' '+chr+'!');				
					//jQuery('#nnikname_val').val('1');
					//show = 1;
				}
			}
			
			validate_search_form();		
		}
		
		if ( show == 1 )
		{
			/* //centering with css
				centerPopup();
				//load popup
				loadPopup();
				
			//CLOSING POPUP
			//Click the x event!
			jQuery("#popupContactClose1").click(function(){
				disablePopup();
			});
			//Click out event!
			jQuery("#backgroundPopup").click(function(){
				disablePopup();
			});
			//Press Escape event!
			jQuery(document).keypress(function(e){
				if(e.keyCode==27 && popupStatus==1){
					disablePopup();
				}
			}); */
			centerPopup1();
			loadPopup();
	
			var windowHeight = document.documentElement.clientHeight;
			windowHeight = windowHeight * 1.2;
			var div_height = document.getElementById('wrapper').offsetHeight;
//			document.getElementById('overlay').style.height = div_height + "px";
		
			jQuery("#overlay").css({			
					"background":"#000000 none repeat scroll 0 0",			
					"left":"0",
					"opacity":"0.8",
					"position":"absolute",
					"top":"0",
					"width":"100%",
					"height":div_height,
					"z-index":"5000"
			});
			
			 jQuery("#overlay").show(); 	
			
			if(popupStatus==0){
				jQuery("#backgroundPopup1").css({
					"opacity": "0.7"
				});
				//jQuery("#backgroundPopup").fadeIn("slow");
				jQuery("#popupContact1").fadeIn("slow");
				popupStatus = 1;		
			}
			
			jQuery("#popupContactClose1").click(function(){disablePopup1();});
			jQuery("#backgroundPopup1").click(function(){disablePopup1();});
			jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup1();}});
		}	
	}
}
/***************************END of SETTING UP OUR POPUP*****************************/

function validate_search_form()
{
	var nickname 	= jQuery('#input_text_0').val();
	var gender   	= jQuery('#input_text_2').val();
	var lookingfor  = jQuery('#input_text_3').val();
	var username 	= check_search_user('search_friend');
	
	if(nickname!='') // && (gender == '' || lookingfor == '')
	{		
		/*
		var count =0;
		
		jQuery("form select").each(function(i){			
			if(jQuery(this).val()!= '')
		  		count++
		 }); 
		 
		 if ( count > 4 && jQuery("#frm_submit_btn").attr("disabled") == true && username == true)
			jQuery("#frm_submit_btn").removeAttr("disabled");
			
		 else		  
		 	jQuery("#frm_submit_btn").attr("disabled", "disabled"); 	
		*/
		var count = 0;
		jQuery("#frm_submit_btn").removeAttr("disabled");
	}
	else if ( gender != '' && lookingfor != '' )
	{
		var count =0;
		
		jQuery("form select").each(function(i){			
			if(jQuery(this).val()!= '')
		  		count++
		 }); 
		 
		 if ( count > 2 && gender != '' && lookingfor != '')
		 {//alert(count+'###'+gender+'###'+lookingfor)	
		 	if ( nickname != '' )	
		 	{	 	
		 		if( username == true )
		 			jQuery("#frm_submit_btn").removeAttr("disabled");
		 		else
		 			jQuery("#frm_submit_btn").attr("disabled", "disabled"); 
		 	}		
		 	else
		 		jQuery("#frm_submit_btn").removeAttr("disabled");		 		
		 }	
		 else		  
		 	jQuery("#frm_submit_btn").attr("disabled", "disabled"); 	
	}
	
}

function change_lang(lang)
{
	jQuery.post("/ajax.php",
	{action: 'change_lang', lang: lang },	
	function(data){
		location.reload();
	}); 
}

function change_nr_result_per_page()
{
	var res = jQuery('#resul_per_page').val();
	
	jQuery.post("/ajax.php",
	{action: 'change_nr_result_per_page', res: res },	
	function(data){
		
		if( data == 1)
			location.reload();
	});
}

function send_msg()
{
	var to = jQuery('#suggest3').val();
	
	if( to == '' )
	{
		show_mess_warning('empty_recipient_field');		
	}
	else
		/*jQuery.post("/ajax.php",
		{action: 'chech_user_to', to: to },	
		function(data){			
			if(data < 1)
				show_mess_warning('wrong_recipient');
			else
			{	*/
				//jQuery('#mess_to_id').val(data);
				if(validate_mess_title()) {
					if(validate_mess_text()) {
						
						str = '';
						availableitems = document.getElementById('suggest3');
						for (var i = 0; i < availableitems.length; i++) {
							newVal = availableitems.options[i].value;
							str += ','+newVal;
						}
						document.getElementById('messageTo').value = str;
						jQuery("form").submit();	
					}
				}
			/*}
		});*/	
}

function sendReply()
{
	if(validate_mess_text()) {
		return true;
	}
	else {
		return false;	
	}
}

function show_mess_warning(elem)
{
	if( elem == 'empty_recipient_field')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_INSERT_RECE+'!');
	
	if( elem == 'wrong_recipient')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_WRONG_USER+'!');
		
	if( elem == 'empty_msg_title_field')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_INSERT_MESS+'!');
			
	if( elem == 'empty_msg_text_field')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_INSERT_CONT+'!');
		
	if( elem == 'well_send_msg')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_SUCCESS+'!');
		
	if( elem == 'nbuddinvit')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_NO_BUDDY+'!');	
		
	if( elem == 'noAddesAsDates')
		jQuery('#contactArea1').html(SHOW_MESS_WARNING_DATES_INV+'!');	
		
	
	centerPopup1();
	loadPopup();

	var windowHeight = document.documentElement.clientHeight;
	windowHeight = windowHeight * 1.2;
	var div_height = document.getElementById('wrapper').offsetHeight;

	jQuery("#overlay").css({			
			"background":"#000000 none repeat scroll 0 0",			
			"left":"0",
			"opacity":"0.8",
			"position":"absolute",
			"top":"0",
			"width":"100%",
			"height":div_height,
			"z-index":"5000"
	});
	
	 jQuery("#overlay").show(); 	
	
	if(popupStatus==0){
		jQuery("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		//jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact1").fadeIn("slow");
		popupStatus = 1;		
	}
	
	jQuery("#popupContactClose1").click(function(){disablePopup1();});
	jQuery("#backgroundPopup1").click(function(){disablePopup1();});
	jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup1();}});
	
	
//	centerPopup();
//	loadPopup();
/*	jQuery("#popupContactClose1").click(function(){disablePopup();});
	jQuery("#backgroundPopup").click(function(){disablePopup();});
	jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup();}}); */
}

function validate_mess_title()
{
	var title = jQuery('#mess_title').val();
	if( title == '' )
	{
		show_mess_warning('empty_msg_title_field');	
		return false;	
	}
	else
		return true;
}

function validate_mess_text_for_send_message()
{
	var text = jQuery('#mess_text').val();
	if( text == '' )
	{
		show_mess_warning('empty_msg_text_field');	
		return false;	
	}
	else
		return true;
}

function validate_mess_text()
{
	//var text = jQuery('#mess_text').val();
	var text = tinyMCE.get('mess_text').getContent();
	if( text == '' )
	{
		show_mess_warning('empty_msg_text_field');	
		return false;	
	}
	else
		return true;
}

function del_my_mess(msg)
{
	var conf = confirm(ARE_YOU_SURE_WANT_TO_DELETE_MESSAGE);
	if(conf) {
		jQuery.post("/ajax.php",
		{action: 'del_my_mess', msg: msg },	
		function(data){			
			if(data > 0)				
				document.location='/messages/inbox';  
			
		});
	}	
}

function del_myh_mess(msg)
{
	
	jQuery.post("/ajax.php",
		{action: 'del_my_mess', msg: msg },	
		function(data){			
			if(data > 0)				
				document.location='/home';  
			
		});
}

function reply_myh_mess(msg_id)
{
	
	jQuery.post("/ajax.php",
		{action: 'reply_my_mess', msg_id: msg_id },	
		function(data){			
			document.location='/messages/reply';  
		});
}

function del_my_t_mess(msg)
{
	
	jQuery.post("/ajax.php",
		{action: 'del_my_t_mess', msg: msg },	
		function(data){			
			if(data > 0)				
				document.location='/messages/trash';  			
		});
}

function del_my_sent_mess(msg)
{
	jQuery.post("/ajax.php",
		{action: 'del_my_sent_mess', msg: msg },	
		function(data){			
			if(data > 0)				
				document.location='/messages/sent';  
			
		});
}

function check_all_mess()
{
	
	
	var chk = jQuery("#vld_chck_all").val();
	
	
	
   if(chk==1)
   {
	  	flag = 0;
	  	jQuery("#vld_chck_all").val('');
   }
   else
   {
   	  flag = 1;
   	  jQuery("#vld_chck_all").val('1');
   }
   
   if ( document.imbox_mess.myCB.length )
   {
      for (var x = 0; x < document.imbox_mess.myCB.length; x++)
      {
         if (flag == 1)
         {
            document.imbox_mess.myCB[x].checked = true;   
         }
         else
         {
            document.imbox_mess.myCB[x].checked = false;
         }
         
      }
   }
   else
   {
      if (flag == 1)
      {
         document.imbox_mess.myCB.checked = true;            
      }
      else
      {
         document.imbox_mess.myCB.checked = false;
      }
   }		 
}

function delete_all_imb_msg()
{	
	var conf = confirm(ARE_YOU_SURE_WANT_TO_DELETE_MESSAGE);
	if(conf) {
		var all_msg = '';
		
		jQuery(':checkbox:checked').each(function(i){			
				all_msg = all_msg+'-'+jQuery(this).attr('id');			
		});	
		
		jQuery.post("/ajax.php",
			{action: 'del_all_my_imbx_mess', msg: all_msg },	
			function(data){							
				document.location='/messages/inbox'; 			
		});
	}
}

function del_all_imb_msg()
{
	jQuery.post("/ajax.php",
		{action: 'deleteAllMessagess', msg: ARE_YOU_SURE_WANT_TO_DELETE_MESSAGE },	
		function(data){							
			pupup_buddy_options(data);
	});
	//var conf = confirm(ARE_YOU_SURE_WANT_TO_DELETE_MESSAGE);
}

function deleteAllInboxMessages() {
	
	var all_msg = '';
	jQuery(':checkbox').each(function(i){			
			all_msg = all_msg+'-'+jQuery(this).attr('id');			
	});	
	
	jQuery.post("/ajax.php",
		{action: 'del_all_my_imbx_mess', msg: all_msg },	
		function(data){							
			document.location='/messages/inbox'; 			
	});		
}

function delete_all_sent_msg()
{	
	var conf = confirm(ARE_YOU_SURE_WANT_TO_DELETE_MESSAGE);
	if(conf) {
		var all_msg = '';
		
		jQuery(':checkbox:checked').each(function(i){			
				all_msg = all_msg+'-'+jQuery(this).attr('id');			
		});	
		
		jQuery.post("/ajax.php",
			{action: 'del_all_my_sent_mess', msg: all_msg },	
			function(data){							
				document.location='/messages/sent'; 			
		});
	}
}

function del_all_sent_msg()
{	
	var all_msg = '';
	
	jQuery(':checkbox').each(function(i){			
			all_msg = all_msg+'-'+jQuery(this).attr('id');			
	});	
	
	jQuery.post("/ajax.php",
		{action: 'del_all_my_sent_mess', msg: all_msg },	
		function(data){							
			document.location='/messages/sent'; 			
	});
}


function delete_all_trash_msg()
{	
	var all_msg = '';
	
	jQuery(':checkbox:checked').each(function(i){			
			all_msg = all_msg+'-'+jQuery(this).attr('id');			
	});	
	
	jQuery.post("/ajax.php",
		{action: 'del_all_my_trash_mess', msg: all_msg },	
		function(data){							
			document.location='/messages/trash'; 			
	});
}

function del_all_trash_msg()
{	
	var all_msg = '';
	
	jQuery(':checkbox').each(function(i){			
			all_msg = all_msg+'-'+jQuery(this).attr('id');			
	});	
	
	jQuery.post("/ajax.php",
		{action: 'del_all_my_trash_mess', msg: all_msg },	
		function(data){							
			document.location='/messages/trash'; 			
	});
}

function xajax_find_friend(us_id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'community_options', us_id: us_id },	
		function(data){				
			pupup_buddy_options(data);			
	});
}
function xajax_find_friend_un_reg(us_id)
{   
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');
	jQuery.post("ajax.php",{action:'community_options_un',us_id:us_id },function(data){pupup_buddy_options1(data);});
	
}

function resend_invitation(us_id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'resend_invitation', us_id: us_id },	
		function(data){	
			pupup_buddy_options(data);
			jQuery('#contactArea1').html(SEND_FRIEND_REQUEST_SENT+' <strong>'+data+'</strong> '+SEND_FRIEND_REQUEST_APPROVAL+' !');
			//document.location='/pending_invitations';			
	});
}

function saveProfile(msg)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'save_profile_success', msg: msg },	
		function(data){				
			pupup_buddy_options(data);
	});
	window.setTimeout(function(){disablePopup()}, 2000);
}
function saveProfile1(msg)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'save_profile_success', msg: msg },	
		function(data){				
			pupup_buddy_options(data);
//			window.location.reload(true);
			window.location.href = "index.php?go=home";
	});
	
}
function saveProfile1(msg)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'save_profile_success', msg: msg },	
		function(data){				
			pupup_buddy_options(data);
	});
	window.setTimeout(location.reload, 2000);
}
function saveContact(msg)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'save_profile_success', msg: msg },	
		function(data){				
			pupup_buddy_options(data);			
	});
	//window.setTimeout(function(){disablePopup()}, 3000);
}

function successDeleteBuddy(msg)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'successDeleteBuddy', msg: msg },	
		function(data){				
			pupup_buddy_options(data);			
	});
	//window.setTimeout(function(){disablePopup()}, 3000);
}

function deleteBuddy(id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'deleteBuddy', id: id },	
		function(data){	
			pupup_buddy_options(data);			
	});
}

function deleteDate(id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'deleteDate', id: id },	
		function(data){	
			pupup_buddy_options(data);			
	});
}

function xajax_find_friend_unreg()
{							
	pupup_buddy_options(PLEASE_LOG_IN);	
}

function pupup_buddy_options(elem)
{
	jQuery('#contactArea1').html(elem);
	centerPopup1();
	
		var windowHeight = document.documentElement.clientHeight;
	windowHeight = windowHeight * 1.2;
var div_height = document.getElementById('wrapper').offsetHeight;

	jQuery("#overlay").css({			
			"background":"#000000 none repeat scroll 0 0",			
			"left":"0",
			"opacity":"0.8",
			"position":"absolute",
			"top":"0",
			"width":"100%",
			"height":div_height,
			"z-index":"5000"
	});
	
	 jQuery("#overlay").show(); 	
	
	if(popupStatus==0){
		jQuery("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		//jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact1").fadeIn("slow");
		popupStatus = 1;		
	}
	
	jQuery("#popupContactClose1").click(function(){disablePopup1();});
	jQuery("#backgroundPopup1").click(function(){disablePopup1();});
	jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup1();}});		
}

function pupup_buddy_options1(elem)
{
	jQuery('#contactArea1').html(elem);
	centerPopup1();
	
	var windowHeight = document.documentElement.clientHeight;
	windowHeight = windowHeight * 1.2;
	//var div_height = document.getElementById('wrapper').offsetHeight;
	var div_height = 800;

	jQuery("#overlay").css({			
			"background":"#000000 none repeat scroll 0 0",			
			"left":"0",
			"opacity":"0.8",
			"position":"absolute",
			"top":"0",
			"width":"100%",
			"height":div_height,
			"z-index":"5000"
	});
	
	 jQuery("#overlay").show(); 	
	
	if(popupStatus==0){
		jQuery("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		//jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact1").fadeIn("slow");
		popupStatus = 1;		
	}
	
	jQuery("#popupContactClose1").click(function(){disablePopup1();});
	jQuery("#backgroundPopup1").click(function(){disablePopup1();});
	jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup1();}});		
}
function pupup_buddy_options_large(elem)
{
	jQuery('#contactArea1').html(elem);
	centerPopup1();
	
	var windowHeight = document.documentElement.clientHeight;
	windowHeight = windowHeight * 1.2;
	//var div_height = document.getElementById('wrapper').offsetHeight;
	var div_height = 800;
	var div_width = 600;

	jQuery("#overlay").css({			
			"background":"#000000 none repeat scroll 0 0",			
			"left":"0",
			"opacity":"0.8",
			"position":"absolute",
			"top":"0",
			"width":'100%',
			"height":'100%',
			"z-index":"5000"
	});
	
	 jQuery("#overlay").show(); 	
	
	if(popupStatus==0){
		jQuery("#backgroundPopup1").css({
			"opacity": "0.7","width":div_width
		});
		jQuery("#popupContact1").css({
		"width":div_width, "top":"70.5px", "left":"190.5px"
		});
		
		//jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact1").fadeIn("slow");
		popupStatus = 1;		
	}
	
	jQuery("#popupContactClose1").click(function(){disablePopup1();});
	jQuery("#backgroundPopup1").click(function(){disablePopup1();});
	jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup1();}});		
}
function send_friend_request_to(us_id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'send_fr_req_to', us_id: us_id },	
		function(data){	
		jQuery('#contactArea1').html(' <strong>'+data+'</strong>');
		//jQuery('#contactArea1').html(SEND_FRIEND_REQUEST_SENT+' <strong>'+data+'</strong> '+SEND_FRIEND_REQUEST_APPROVAL+' !');
			//window.setTimeout('disablePopup()', 2000);	
	});
}
function sendinvitationmsg(us_id)
{	
	var additionalmsg = jQuery('#additionalmsg').val();		
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
		jQuery.post("/ajax.php",
		{action: 'sendfriendrequest', us_id: us_id,additionalmsg:additionalmsg },	
		function(data){	
		jQuery('#contactArea1').html(' <strong>'+data+'</strong>');
		jQuery('#contactArea1').html(SEND_FRIEND_REQUEST_SENT+' <strong>'+data+'</strong> '+SEND_FRIEND_REQUEST_APPROVAL+' !');
			//window.setTimeout('disablePopup()', 2000);	
	});
}
function accept_reject_buddy(b_uid, b_name, offset)
{
	pupup_buddy_options('');
	jQuery.post("/ajax.php",
		{action: 'accept_reject_buddy', b_uid: b_uid, b_name: b_name, offset: offset },	
		function(data){	
			jQuery('#contactArea1').html(data);
		}
	);
}

function accept_us_as_buddy(b_uid, b_name, offset)
{
	pupup_buddy_options(ACCEPT_US_BUDDY_SUCCESS+' '+b_name+' '+ACCEPT_US_BUDDY_TO_BUDDY+' !');
	jQuery.post("/ajax.php",
		{action: 'accept_us_as_buddy', b_uid: b_uid },	
		function(data){	
			document.location='/invitations?offset='+offset; 
	});
}

function reject_us_as_buddy(b_uid, b_name, offset)
{
	pupup_buddy_options('Rejected : '+b_name);
	jQuery.post("/ajax.php",
		{action: 'reject_us_as_buddy', b_uid: b_uid },	
		function(data){	
			document.location='/invitations?offset='+offset; 
	});
}


function accept_us_as_date(b_uid, b_name, offset)
{
	pupup_buddy_options('You succesfully add '+b_name+' to your datelist!');
	jQuery.post("/ajax.php",
		{action: 'accept_us_as_date', b_uid: b_uid },	
		function(data){	
			document.location='/dates_invitations?offset='+offset; 
	});
}

function decline_us_as_buddy(b_uid, b_name, offset)
{
	pupup_buddy_options(DECLINE_BUDDY_YOU_REJECT+' '+b_name+'\'s '+DECLINE_BUDDY_BUDDY_INVITATION+'!');	
	jQuery.post("/ajax.php",
		{action: 'decline_us_as_buddy', b_uid: b_uid },
		function(data){	
			document.location='/invitations?offset='+offset; 
	});
}

function decline_us_as_date(b_uid, b_name, offset)
{
	pupup_buddy_options(DECLINE_BUDDY_YOU_REJECT+' '+b_name+'\'s '+DECLINE_BUDDY_BUDDY_INVITATION+'!');	
	jQuery.post("/ajax.php",
		{action: 'decline_us_as_date', b_uid: b_uid },
		function(data){	
			document.location='/invitations?offset='+offset; 
	});
}


function send_mess_to(us_id)
{	
	jQuery.post("/ajax.php",
		{action: 'send_mess_to_us_buddy',us_id: us_id },
		function(data){	
			pupup_buddy_options(data);
	});
}


function addAsDates(us_id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'addAsDates', us_id: us_id },	
		function(data){				
			pupup_buddy_options(data);			
	});
}

function addAsDates_Request(us_id)
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'addAsDates_Request', us_id: us_id },	
		function(data){	
			jQuery('#contactArea1').html(ADD_AS_DATE_SUCCESS+' !');
			//window.setTimeout('disablePopup()', 2000);	
	});
}


function send_msg_to_buddy()
{
	var to = jQuery('#mess_to').val();
	var title = jQuery('#mess_title').val();
	var text = jQuery('#mess_text').val();
	
	if( to == '' )
	{
		show_mess_warning('empty_recipient_field');		
	}
	else
		jQuery.post("/ajax.php",
		{action: 'chech_user_to', to: to },	
		function(data){	
			if(data < 1)
				show_mess_warning('wrong_recipient');
			else
			{	
				jQuery('#mess_to_id').val(data);
				if(validate_mess_title())
					if(validate_mess_text_for_send_message())
						jQuery.post("/ajax.php",
						{action: 'send_msg_to_us_b', to: to, title: title, text: text},	
						function(data){	
							if (data)
								pupup_snd_msg_to_buddy(SEND_MSG_BUDDY_SUCCESS+'!')
						});
			}
		});	
}

function pupup_snd_msg_to_buddy(elem)
{
/*	jQuery('#contactArea1').html(elem);
	centerPopup();	
	loadPopup();	
	window.setTimeout(function(){disablePopup()}, 1000);	*/
	
	jQuery('#contactArea1').html(elem);
	centerPopup1();
	loadPopup();	
	
	var windowHeight = document.documentElement.clientHeight;
	windowHeight = windowHeight * 1.2;
var div_height = document.getElementById('wrapper').offsetHeight;

	
	jQuery("#overlay").css({			
			"background":"#000000 none repeat scroll 0 0",			
			"left":"0",
			"opacity":"0.8",
			"position":"absolute",
			"top":"0",
			"width":"100%",
			"height":div_height,
			"z-index":"5000"
	});
	
	 jQuery("#overlay").show(); 	
	
	if(popupStatus==0){
		jQuery("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		//jQuery("#backgroundPopup").fadeIn("slow");
		jQuery("#popupContact1").fadeIn("slow");
		popupStatus = 1;		
	}
	
	jQuery("#popupContactClose1").click(function(){disablePopup1();});
	jQuery("#backgroundPopup1").click(function(){disablePopup1();});
	jQuery(document).keypress(function(e){if(e.keyCode==27 && popupStatus==1){disablePopup1();}});
	
}

function submit_quick_src()
{
	var lf = jQuery('#officeItemList5').val();
	var age = jQuery('#officeItemList6').val();
	var country = jQuery('#officeItemList').val();
	
	
	jQuery.post("/ajax.php",
	{action: 'quick_search', lf: lf, age: age, country: country},	
	function(data){	
		if (data)
			document.location='/search_result'; 	
	});
}

function submit_unreg_src()
{
	var age_1 		= jQuery('#officeItemList').val();
	var age_2 		= jQuery('#officeItemList2').val();
	var country 	= jQuery('#officeItemList3').val();
	var gender_1 	= jQuery('#officeItemList5').val();
	var gender_2 	= jQuery('#officeItemList6').val();
	
	jQuery.post("/ajax.php",
	{action: 'unreg_search', age_1: age_1, age_2: age_2, country: country, gender_1: gender_1, gender_2: gender_2},	
	function(data){	
		if (data)
			document.location='/search_res'; 	
	});
}

function got_to_destination(dest)
{
	var us_val	=	jQuery('#destinput_text_0').val();
	
 	var count_val		=	us_val.length;	
 	var username_format = 	/^([a-zA-Z]|\d)$/;  	
 	var final_un		= 	''; 	
 	elements = us_val.split(''); 	
 	for(i=0; i<count_val;i++){ 		
 		if(username_format.exec(elements[i])){
 			final_un = final_un+''+elements[i]; 			 
		}
 	}
 	var final_un = final_un.toLowerCase();
 	var f_un     = final_un.length;
 	
  jQuery('#destinput_text_0').val(final_un); 
 	
 	
	if(f_un>4){
		destget_current_user_name(final_un); 			
	}
	else if(f_un == 0){
		jQuery("#destlogin_result").fadeTo(200,0.1,function(){
            jQuery(this).html(CHECK_USER_NICKNAME).removeClass().addClass('error').fadeTo(900,1);
        });	 		
	}
	
	else{
		jQuery("#destlogin_result").fadeTo(200,0.1,function(){
            jQuery(this).html(CHECK_USER_NICKNAME_TOO_SHORT).removeClass().addClass('error').fadeTo(900,1);
        });	 		
	} 		
}

function destget_current_user_name(elem_id)
{
 jQuery.post("/ajax.php",
 {action: 'get_current_user', id: elem_id},
 function(data)
 { 	
 	if(data!=1) { 
 	   jQuery("#destlogin_result").fadeTo(200,0.1,function(){
           jQuery(this).html(RESET_USERNAME_WRONG_NAME).removeClass().addClass('error').fadeTo(900,1);
           return false;
       }); 		
 	}
 		 	
 	else { 		
 		destvalidate_paswd(elem_id);	
 	}
 });
}

function destvalidate_paswd(elem_id)
{
	var pass = jQuery('#destinput_text_1').val();	
	if(pass != ''){
		jQuery.post("/ajax.php",
		 {action: 'get_current_pass', name: elem_id, password: pass},
		 function(data)
		 { 	
			 	if(data!=1) { 
			 	   jQuery("#destlogin_result").fadeTo(200,0.1,function(){
			           jQuery(this).html(VALIDATE_PWD_WRONG_PASSWORD).removeClass().addClass('error').fadeTo(900,1);		          
			       }); 		
			 	}	 	
			 	else { 		
			 		 jQuery("#destlogin_result").fadeTo(200,0.1,function() {
	           jQuery(this).html(VALIDATE_PWD_VALIDATING+'....').removeClass().addClass('success').fadeTo(900,1,
	             function() {
	             		
	             		var dest = jQuery("#dest_to").val();
	                document.location=dest;
	             });
	        });
			 	}
		 });
	}
	else{
		jQuery("#destlogin_result").fadeTo(200,0.1,function(){
           jQuery(this).html(VALIDATE_PWD_ENTER_PASSWORD).removeClass().addClass('error').fadeTo(900,1); 
        });          
	}	
}

function get_new_mess_twit(act, twt_ofs)
{		
	var tot = jQuery('#twt_tot').val();	
	
	jQuery.post("/ajax.php",
	 {action: 'get_us_act_twit', ofs: twt_ofs, tot: tot, act: act},
	 function(data)
	 {	 
		 	if(data!='') { 
		 	   jQuery(".twitter-box").fadeTo(200,0.1,function(){
		           jQuery(this).html(data).fadeTo(900,1);
		           return false;
		       }); 
		 	} 
	 });
}

function get_top_three_matches()
{
	jQuery.post("/ajax.php",
	 {action: 'get_top_three_matches'},
	 function(data)
	 {	 
		 	if(data!='') { 
		 	  jQuery("#get_top_three_matches").fadeTo(200,0.1,function(){
			    jQuery(this).html(data).fadeTo(900,1);
		      return false;
		    });
		 	}
	 });
}

function get_are_these_friends(male,female)
{
	jQuery.post("/ajax.php",
	 {action: 'get_are_these_friends'},
	 function(data)
	 {	 
		 	if(data!='') { 
		 	   jQuery("#get_are_these_friends").fadeTo(200,0.1,function(){
		           jQuery(this).html(data).fadeTo(900,1);
		           return false;
		       }); 
		 	} 
	 });
}

function advance_searc()
{
	if(document.getElementById('advancedSearch')) {
		document.getElementById('advancedSearch').style.display = 'block';
		shw_search_msg('search_friend');
	}
	else {
		document.location='/search&flag=advancedSearch';
	}
}

function add_new_photo_album()
{
	jQuery.post("/ajax.php",
		{action: 'add_new_photo_album' },
		function(data){
			pupup_buddy_options(data);
	});
}

function add_new_movie()
{
	jQuery.post("/ajax.php",
		{action: 'add_new_movie' },
		function(data){
			pupup_buddy_options(data);
	});
}
function attend_event(id)
{
	jQuery.post("/ajax.php",
		{action: 'attend_event',eventid: id },
		function(data){			
			pupup_buddy_options(data);
	});
}


function add_event(id){
		
		alert(id);
		jQuery.post("/ajax.php",
		{action: 'add_event' ,eventid: id},
		function(data){
			pupup_buddy_options(data);
	});
}

function add_news_comment(id)
{
	jQuery.post("/ajax.php?nid="+id,
		{action: 'add_news_comment' },
		function(data){
			pupup_buddy_options(data);
	});
}

function add_newscomment()
{	
	var alb_dsc = jQuery('#movie_desc').val();
	var newsid = jQuery('#newsid').val();
	
	
	if(alb_dsc == "")
	{
		alert("::"+ NEWSCOMMENT_ERROR +"::");		
		return false;
	}
	jQuery.post("/ajax.php",
		{action: 'add_newscomment',alb_dsc:alb_dsc,newsid:newsid},
		function(data){
			disablePopup();
			jQuery("#newscommentid").html(data)
	});	
}

function add_album()
{	
	var alb_tit = jQuery('#album_title').val();
	var alb_dsc = jQuery('#album_desc').val();
	
	jQuery.post("/ajax.php",
		{action: 'add_album', alb_tit:alb_tit, alb_dsc:alb_dsc  },
		function(data){
			disablePopup();
			jQuery("#all_phts_albms").html(data)
	});	
}



	

function add_movie()
{	
	var alb_tit = jQuery('#movie_title').val();
	var alb_dsc = jQuery('#movie_desc').val();
	
	var myRegExp = /youtube.com/;

	var matchPos1 = alb_tit.search(myRegExp);

	if(matchPos1 != -1)
	{}	
	else
	{
		alert("::"+ YOUTUBE_ERROR +"::");	
		return false;	
	}
	if(alb_tit == "")
	{
		alert("::"+ YOUTUBE_ERROR +"::");		
		return false;
	}
	jQuery.post("/ajax.php",
		{action: 'add_movie', alb_tit:alb_tit, alb_dsc:alb_dsc  },
		function(data){
			disablePopup();
			jQuery("#all_phts_albms").html(data)
	});	
}

function add_new_picture(alb)
{
	jQuery.post("/ajax.php",
		{action: 'add_new_picture', alb:alb },
		function(data){
			pupup_buddy_options(data);
	});
}

function get_all_album_admin_img(alb)
{
	jQuery.post("/ajax.php",
		{action: 'get_all_album_admin_img', alb:alb },
		function(data){
			jQuery("#all_album_admin_images").html(data)			
	});
}

function changeclass(id)
{
	document.getElementById(id).className = "selected";
	var MyFriends = document.getElementById('MyFriends');
	var MyDates = document.getElementById('MyDates');
	var MyGroups = document.getElementById('MyGroups');
	var MyMovie = document.getElementById('MyMovie');
	var MyPicture = document.getElementById('MyPicture');
	
	
	
	if(id == 'MyFriends')
	{
		document.getElementById('a2').className = "";
		document.getElementById('a3').className = "";
		MyFriends.style.display = 'block';
		MyDates.style.display = 'none';
		MyGroups.style.display = 'none';
	}
	if(id == 'MyDates')
	{
		document.getElementById('a1').className = "";
		document.getElementById('a3').className = "";
		MyFriends.style.display = 'none';
		MyDates.style.display = 'block';
		MyGroups.style.display = 'none';
	}
	if(id == 'MyGroups')
	{
		document.getElementById('a2').className = "";
		document.getElementById('a1').className = "";
		MyFriends.style.display = 'none';
		MyDates.style.display = 'none';
		MyGroups.style.display = 'block';
	}
	
	if(id == 'MyMovie')	
	{	document.getElementById('a11').className = "";
		MyPicture.style.display = 'none';	
		MyMovie.style.display = 'block';
	}
	if(id == 'MyPicture')
	{
		document.getElementById('a12').className = "";
		MyMovie.style.display = 'none';	
		MyPicture.style.display = 'block';
	}

}

function messageSettings()
{	
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'messageSettings', msg: '' },	
		function(data){				
			pupup_buddy_options(data);			
	});
}

function messageSettingsSave() {
	var radioObj = document.frmPreferences.messageSettings;
	var val = '';
	if(!radioObj)
		val = "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			val = radioObj.value;
		else
			val = "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			val = radioObj[i].value;
		}
	}
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'messageSettingsSave', messageSettings: val },	
		function(data){				
			pupup_buddy_options(data);			
	});
}

function thisIsNotOK() {
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'thisIsNotOK', msg: '' },	
		function(data){				
			pupup_buddy_options(data);			
	});
}

function thisIsNotOKSend() {
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'thisIsNotOKSend', msg: '' },	
		function(data){				
			pupup_buddy_options(data);			
	});
}

function EnableDisableButton(cb, id) {

    if (cb.checked == 1) {
      idList = idList + id + ";"
      document.getElementById('textbox1').value = idList;
    }

    if (cb.checked == 0) {
      var v;
      v = ";" + id + ";"
      idList = idList.replace(v, ";");
      document.getElementById('textbox1').value = idList;
    }

    if (idList == ";") {
      document.getElementById('reg_user').disabled = true;
    } else {
      document.getElementById('reg_user').disabled = false;
    }

  }

function deleteProfile() {
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'deleteProfile', id: 0 },	
		function(data){				
			pupup_buddy_options(data);			
	});	
}

function openPopopDeleteProfile2() {
	jQuery('#contactArea1').html('<img src="images/ajax_activity.gif">');	
	jQuery.post("/ajax.php",
		{action: 'deleteProfileReason', id: 0 },	
		function(data){				
			pupup_buddy_options(data);			
	});	
}

function openPopopDeleteProfile() {	
	
	var wind = window.open('/includes/delete_profile_form.php','DeleteProfile','width=500, height=500, left=400, top=100');
}
function checkreason()
{	
	if(document.getElementById('delprofilereason').value == '') {
			alert('::'+ HINT_PROFILE_DELRESON  +'::');
			document.getElementById('delprofilereason').focus();
			return false;
	}
	else
	{	
		document.frm.submit();
		//window.opener.document.frm.submit();
		//var wind = window.open('/includes/delete_profile_form.php','DeleteProfile','width=500, height=500, left=400, top=100');	
		//disablePopup1();
	}
}

function sendme() 
{ 
	disablePopup1();
    window.open("","myNewWin","width=450,height=400,toolbar=0"); 
    var a = window.setTimeout("document.form1.submit();",500); 
}

function openWindow(url, wname, width, height) {
window.open(url, wname, "height=" + height + ",width=" + width + "location = 0, status = 1, resizable = 0, scrollbars=1, toolbar = 0");
return true;
}


function swapSelectOptions(selectFrom,selectTo,swapAll) {
	if (typeof(selectFrom) == "string") {
		availableitems = document.getElementById(selectFrom);
	}
	if (typeof(selectTo) == "string") {
		selecteditems= document.getElementById(selectTo);
	}
	for (var i = 0; i < availableitems.length; i++) {
		if (availableitems.options[i].selected || swapAll) {  
			selecteditems.options[selecteditems.options.length] = new Option(availableitems.options[i].text);
			selecteditems.options[selecteditems.options.length-1].value = availableitems.options[i].value;
			//selecteditems.options[selecteditems.options.length-1].selected = true;			
			availableitems.options[i].selected = false;
		  	availableitems.options[i] = null;
			i--;
		}
	}
	selectAll('suggest3',true);
}

// For select all
function selectAll(selectBox,selectAll) {
		// have we been passed an ID
		if (typeof selectBox == "string") {
			selectBox = document.getElementById(selectBox);
		}
		// is the select box a multiple select box?
		if (selectBox.type == "select-multiple") {
			for (var i = 0; i < selectBox.options.length; i++) {
				selectBox.options[i].selected = selectAll;
			}
		}
	}
	
// For The Pagging Added By Raju
function navigatepage(form_name,pageno)
    {	
		var form = document.forms[form_name];
		form.currentpage.value=pageno;		
		form.submit(); 
}
function datting_alert()
{
//	pupup_buddy_option("HERERERERERER...");
	jQuery.post("/ajax.php",
		{action: 'registration_help', help_data: 'Datter' },	
		function(data){	
			//alert(data);
			pupup_buddy_options1(data);			
	});	
		
}
function profiling_alert()
{
	jQuery.post("/ajax.php",
		{action: 'registration_help', help_data: 'Profiler' },	
		function(data){				
			pupup_buddy_options1(data);			
	});			
}
function company_alert()
{
	jQuery.post("/ajax.php",
		{action: 'registration_help', help_data: 'company' },	
		function(data){				
			pupup_buddy_options_large(data);			
	});			
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}
/*function stripslashes (str) 
{
       return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {

            case '\\':
                return '';
            case '0':
                return '\0';
            case '':
                return '';
            default:
                return n1;
        }
    });
}*/
function delete_photo(photo_id, url)
{	
	var conf = confirm(ARE_YOU_SURE_WANT_TO_DELETE_PICTURE);
	if(conf) {
			jQuery.post("/ajax.php",
			{action: 'del_my_photo', photo_id: photo_id , url : url},	
			function(data){		
				document.location="/admin_gallery/album/"+data;  			
		});
	}
}