

function updateProfile1() {
    var a = $("#lookingfor2").val();
    var b = $("#age_min").val();
    var c = $("#age_max").val();
    var d = "";
    var e = sitePath2 + "user_ajax.php?action=update_personalinfo";
    if (a == "0") {
        d += "<li>Please select looking for !</li>"
    }
    if (b > c) {
        d += "<li>Please select between age range !</li>"
    }
    if ($("#allow_zipcode").attr("checked")) {
        if ($("#zipcode").val() == "") {
            d += "<li>Please enter Zipcode !</li>"
        } else {
            e += "&zipcode=" + $("#zipcode").val()
        }
    } else {
        if ($("#country").val() == "0") d += "<li>" + lang.translate("enter_country") + "</li>";
        else e += "&country=" + $("#country").val();
        if ($("#state_list").val() == "0") d += "<li>" + lang.translate("enter_state") + "</li>";
        else e += "&state=" + $("#state_list").val();
        if ($("#city").val() == "") d += "<li>" + lang.translate("enter_city") + "</li>";
        else e += "&city=" + $("#city").val()
    }
    if (d != "") {
        $.facebox("<ul class='err_mge'>" + d + "</ul>")
    } else {
        e += "&looking_for=" + a + "&min_age=" + b + "&max_age=" + c + "&year=" + $("#year").val() + "&month=" + $("#month").val() + "&day=" + $("#day").val();
        
	$.ajax({
            url: e,
            success: function (a) {
                var b = "";
                if (a == "zipcode_not_found") b = "<ul class='err_mge'><li>Please enter valid zipcode or select from suggestion list !</li></ul>";
                else b = "<ul class='success_mge'><li>Information updated successfully !</li></ul>";
                $.facebox(b)
            }
        })
    }
}
function getZipCode(a) {
    if (a != "") {
        var b = sitePath2 + "user_ajax.php?action=get_zip&city_name=" + a;
        $.ajax({
            url: b,
            success: function (a) {
                $("#zipcode_input2").val(a)
            }
        })
    }
}
function show_selected_gallery() {
    var a = $("#gellery_select").val();
    alert(a)
}
function getCity() {
    var a = $("#zipcode_input").val();
    if (a.length == 5) {
        var b = $("#country").val().split("_");
        var c = b[0];
        $("#zipcode_input_mandatory_hidden").hide();
        var d = sitePath2 + "user_ajax.php?action=get_city&zipcode=" + a + "&country_code=" + c;
        var e = makeAjaxCall(d);
        if (e) {
            $("#city_div").html(e)
        }
    } else {
        $("#zipcode_input_mandatory_hidden").show()
    }
}
function openGalleryPopUp(a) {
    $.facebox(loadingmessage);
    if (a > 0) {
        var b = sitePath2 + "user_ajax.php?action=show_gallery&user_id=" + a;
        $.ajax({
            url: b,
            success: function (a) {
                $.facebox(a);
                //$("#facebox").css({
                    //position: "absolute"
                //})
            }
        })
    }
}
function show_thumb_new(a, b) {
    var c = imagespathuser + "/" + a + "/zoom_" + b;
    image = "<img src='" + c + "'>";
    var d = sitePath2 + "user_ajax.php?action=profile_appr_zoom_images&imagename=" + b + "&userid=" + a;
    var e = makeAjaxCall(d);
    var f = e.split("~");
    var g = f[0];
    var h = f[1];
    $("#full_pro_img").html(g);
    $("#commentDiv").html(h)
}
function delImg(a, b, c) {
    var d = sitePath2 + "user_ajax.php?action=del_img&image_name=" + a + "&user_id=" + b;
    $("#" + c).remove();
    $.ajax({
        url: d,
        context: document.body,
        success: function () {}
    })
}
function showCountryList() {
    var a = $("#country option:selected").val();
    $("#state_zipcode_div").html("");
    $("#city_div").html("");
    if (a.length > 0 && a != "0") {
        var b = sitePath2 + "user_ajax.php?action=get_state_zip&country_code=" + a;
        var c = makeAjaxCall(b);
        $("#state_zipcode_div").html(c)
    }
}
function validate_search_setting() {
    $.facebox(loadingmessage);
    var a = "";
    if ($("#Looking_for").val() == "0") {
        a += "<li>Looking for !</li>"
    }
    if ($("#age1").val() > $("#age2").val()) {
        a += "<li>Valid age range ! </li>"
    }
    if ($("#zipcode_input2").val() == "") {
        a += "<li>Zipcode/city ! </li>"
    } 
	/*else {
        var b = sitePath2 + "user_ajax.php?action=verify_zipcode&zip_val=" + $("#zipcode_input2").val() + "&location=search";
        var c = "false";
        $.ajax({
            url: b,
            success: function (a) {
                c = a
            },
            async: false
        });
        if (c != "false") {
            if (c != "") {
                $.facebox("<ul style='list-style:none;' class='err_mge'>Please enter <b>Valid zipcode</b> or select country, state and city from suggestion list !</ul>");
                return false
            }
        }
    }*/
    if (a != "") {
        var d = "To get correct search results, please fill the required field <br />";
        $.facebox("<ul style='list-style:none;' class='err_mge'>" + d + a + "</ul>");
        return false
    } else {
        var e = window.location.pathname;
        var f = e.substring(e.lastIndexOf("/") + 1);
        var g = f.split(".");
        var h = $("#Looking_for").val();
        var i = $("#age1").val();
        var j = $("#age2").val();
        var j = $("#age2").val();
        var k = $("#Horoscope").val();
        var l = $("#zipcode_input2").val();
        var m = "";
		$("#distance_chk").is(':checked') ? m = $("#distancesearch2").val() : m = 0;
		//var m = $("#distancesearch2").val();
		
        var n = $("#photos_only:checked").val();
        if (typeof n == "undefined") n = "0";
        var o = sitePath2 + "user_ajax.php?action=search_settings&page_name=" + g[0];
        o += "&looking_for=" + h + "&age1=" + i + "&age2=" + j;
        o += "&horoscope=" + k + "&zip_city=" + l + "&distance=" + m + "&photos_only=" + n;
        $.ajax({
            url: o,
            success: function (a) {                
                if($.trim(a)=="zipcode_not_found")
				{
					$.facebox("<ul style='list-style:none;' class='err_mge'>Please enter <b>Valid zipcode</b> or select country, state and city from suggestion list !</ul>");
					return false
				}
				$.facebox.close();
				if (f == "search.html")
				{
                    var b = a.split("~");
                    var c = b[0];
                    var d = b[1];
                    $("#total_records").html("<b>" + d + "</b>");
                    $("#arr_record").html(c);
                    if (b.length == 3) {
                        $("#pagination_div").html(b[2])
                    } else $("#pagination_div").html("")
                }
				else
				{
                    location.href = sitePath2 + "search.html"
                }
            }
        })
    }
}
function validateMatchForm() {
    var age_min = $("#age_min").val();
    var age_max = $("#age_max").val();
    var Looking_for = $("#Looking_for").val();
    var Marital_status = $("#Marital_status").val();
    var Relationship = $("#Relationship").val();
    var body_type = $("#body_type").val();
    var smoke = $("#smoke").val();
    var Profession = $("#Profession").val();
    var Appearance = $("#Appearance").val();
    var have_kids = $("#have_kids").val();
    var drink = $("#drink").val();
    var Education=$("#Education").val();
    var errorMsg='';

	if(age_min>=age_max){
	  errorMsg+='<li>Age min could not be greater then the age max</li>';
	}
	
	if(Looking_for=="0"){
	  errorMsg+='<li>Please select looking for.</li>';
	}
	
	if(Relationship=='0'){
	  errorMsg+='<li>Please select Relationship.</li>';
	}
/*	if(Marital_status=='0'){
	  errorMsg+='<li>Please select Marital Status.</li>';
	}
	
	if(have_kids=='0'){
	  errorMsg+='<li>Please select Have Kids.</li>';
	}
	
	if(Appearance=='0'){
	  errorMsg+='<li>Please select Appearance.</li>';
	}*/
	
	if(errorMsg!=""){
		$.facebox("<ul class='err_mge'>"+errorMsg+"</ul>");
                return false;
	}else{
            var path = sitePath2 + "/user_ajax.php?action=match_settings&between_age1=" + age_min + "&between_age2=" + age_max+"&looking_for=" + Looking_for+ "&marital_status=" + Marital_status + "&relationship=" + Relationship;
                path += "&education=" + Education + "&profession=" + Profession + "&smoke=" + smoke + "&drink=" + drink + "&children=" + have_kids;
                path += "&body_type=" + body_type + "&appearance="+Appearance;
            $.ajax({
              url: path,
              cache: false,
              success: function(msg){
				  if(msg==1){
					   $.facebox("<ul class='success_mge'>My matches has been updated</ul>");
				   }
              }
            });
        }
}

function shotlisted(a, b) {
    $.facebox(loadingmessage);
    var c = sitePath2 + "user_login.php";
    var d = "section=shortlisted&userid=" + a + "&type=" + b;
    $.ajax({
        type: "POST",
        url: c,
        data: d,
        success: function (a) {
            a = jQuery.trim(a);
            a = a.split("#");
            if (a[0] == "error") {
                $("#showresult").html(a[1])
            } else {
                $("#showresult").html(a[0]);
                $("#removeshort").replaceWith(a[1])
            }
        }
    })
}
function allowtrace(a, b) {
    $.facebox(loadingmessage);
    var c = sitePath2 + "user_login.php";
    var d = "section=allowtrace&userid=" + a + "&type=" + b;
    $.ajax({
        type: "POST",
        url: c,
        data: d,
        success: function (a) {
            a = jQuery.trim(a);
            a = a.split("#");
            if (a[0] == "error") {
                $("#showresult").html(a[1])
            } else {
                $("#showresult").html(a[0]);
                $("#allowtrace").replaceWith(a[1])
            }
        }
    })
}
function addhotlist(a, b) {
    $("#showvalue").html(loadingmessage);
    var c = sitePath2 + "user_login.php";
    var d = "section=addtohotlist&userid=" + a + "&type=" + b;
    $.ajax({
        type: "POST",
        url: c,
        data: d,
        success: function (c) {
            c = jQuery.trim(c);
            c = c.split("#");
            if (b == "addhot" || b == "removehot") {
                if (c[0] == "error") {
                    $("#showresult").html(c[1])
                } else {
                    if ($("#pagenamevalue").val() == undefined) {
                        $("#parentid_" + a).remove()
                    }
                    $("#showresult").html(c[1]);
                    if ($("#pagenamevalue").val() == undefined) {
                        if (c[3] == 0) {
                            $(".action_td").remove();
                            $(".gray_btn").remove();
                            $("#loadingimage").html("<img src=" + imagePath + 'cartoon.png">')
                        }
                    }
                    $("#hotlist_" + a + "").replaceWith(c[2]);
                    $("#hot_list_count").html(c[3]);
                    $("#total_hotlisted").html(c[3])
                }
            } else {
                if (c[0] == "error") {
                    $("#showresult").html(c[1])
                } else {
                    $("#showresult").html(c[1]);
                    $("#hotlist_" + a + "").replaceWith(c[1]);
                    $("#hotlist_toggle").html(c[2])
                }
            }
        }
    })
}
function confirmhotlist(a, b, c) {
    var d;
    if (c == "removehot") {
        d = lang.translate("deletedhotlist")
    } else {
        d = lang.translate("adddhotlist")
    }
    var e = $("#profile_image_" + a).attr("src");
    $.facebox('<div id="showvalue"><div style="width:300px;"><div class="say_hello" style="font:13px/22px Verdana,Geneva,sans-serif;text-align:center;">' + b + '</div><div style="padding:3px 0px;"><hr></div><div style="text-align:center; margin:5px 0px;"><img src=' + e + ' style="border:1px solid #615E5E;padding:4px;" /></div><div class="clear" style="margin-top:2px;"></div><div class="xdispimes" style="width:auto; background-color:#FFCCFF;font: 13px/30px Verdana,Geneva,sans-serif; text-align:left;">' + d + " " + b + ' ?</div><div style="margin-top: 10px; float: left;" class="gray_btn"><a onclick="hidefacebox()" href="javascript: void(0);"><span id="check_text">No</span></a></div><div style="margin-top: 10px; float: left;" class="gray_btn"><a onclick="addhotlist(' + a + ",'" + c + '\');" href="javascript: void(0);"><span id="check_text">Yes</span></a></div></div></div>');
    return false
}
function flirtmessagepopup(a) {
    $.facebox("<div id='showresult'><div style='text-align:left;'><img src='" + imagePath + "ajax-wait.gif'/></div><div class='clear'></div><div style='font:13px/22px Verdana,Geneva,sans-serif;color:#615E5E;'>Please wait while processing your request....</div></div>");
    var b = sitePath2 + "user_login.php";
    var c = "section=flirtpopup&userid=" + a;
    $.ajax({
        type: "POST",
        url: b,
        data: c,
        success: function (a) {
            a = jQuery.trim(a);
            if (a) {
                $("#showresult").html(a)
            }
        }
    })
}
function sentmail(a, b) {
    if (b == "main") {
        $.facebox("<div id='showresult'><div style='text-align:left;'><img src='" + imagePath + "ajax-wait.gif'/></div><div class='clear'></div><div style='font:13px/22px Verdana,Geneva,sans-serif;color:#615E5E;'>Please wait while processing your request....</div></div>")
    } else {
        $("#showvalue").html("<div id='showresult'><div style='text-align:left;'><img src='" + imagePath + "ajax-wait.gif'/></div><div class='clear'></div><div style='font:13px/22px Verdana,Geneva,sans-serif;color:#615E5E;'>Please wait while processing your request....</div></div>")
    }
    var c = sitePath2 + "user_login.php";
    var d = "section=sentmail&userid=" + a;
    $.ajax({
        type: "POST",
        url: c,
        data: d,
        success: function (a) {
            a = jQuery.trim(a);
            if (a) {
                $("#showresult").html(a)
            }
        }
    })
}
function clickhertomeetme(a, b, c) {
    var d = $("#profile_image_" + a).attr("src");
    $.facebox('<div id="showvalue"><div style="width:230px;"><div class="say_hello" style="font:13px/22px Verdana,Geneva,sans-serif;text-align:center;"><h3><b>' + b + '</b></h3></div><div style="padding:2px;width:231px;"><hr></div><div style="text-align:center;"><img src="' + d + '" style="border:1px solid #615E5E;padding:6px;" /></div><div class="clear" style="margin-top:2px;"></div><div class="xdispimes" style="width: auto; background-color: rgb(255, 204, 255); font: 14px/30px Verdana,Geneva,sans-serif; text-align: center;">' + lang.translate("doulike") + '</div> <div class="gray_btn"><a href="javascript: void(0);" onclick="hidefacebox();"><span id="check_text">No</span></a></div> <div class="gray_btn"><a href="javascript: void(0);" onclick="sentmail(' + a + ');"><span id="check_text">Yes</span></a></div></div></div>')
}
function loadingimage() {
    $.facebox('<div id="showresult"><img  style="margin-left:10px;margin-right:10px;" src=' + imagePath + "loadingajax.png></img></div>")
}
function updateuserinformations(a, b) {
    loadingimage();
    var c = sitePath2 + "user_login.php";
    var d = "section=" + a + "&" + $("#" + b).serialize();
    $.ajax({
        type: "POST",
        url: c,
        data: d,
        success: function (a) {
            a = jQuery.trim(a);
            if (a) {
                $("#showresult").html(a)
            }
        }
    })
}
function deleteprofilehotlistedyou(a, b, c) {
    var d = sitePath2 + "user_login.php";
    var e = "section=" + c + "&deletedid=" + a + "&pageno=" + b;
    $.ajax({
        type: "POST",
        url: d,
        data: e,
        success: function (a) {
            a = jQuery.trim(a);
            a = a.split("~");
            if (a[0] == "succ") {
                $("#arr_record").html(a[1]);
                $("#hotlisted_you_count").html(a[3]);
                $("#total_records").html(a[3])
            }
            if (a[0] == "error") {
                $("#arr_record").html(a[1]);
                $("#hotlisted_you_count").html(a[3]);
                $("#total_records").html(a[3]);
                $("#action_td").remove();
                $("#gray_btn1").remove()
            }
        }
    })
}
function deleteprofile(a, b, c) {
    var d = sitePath2 + "user_login.php";
    var e = "section=" + c + "&deletedid=" + a + "&pageno=" + b;
    $.ajax({
        type: "POST",
        url: d,
        data: e,
        success: function (a) {
            a = jQuery.trim(a);
            a = a.split("~");
            if (a[0] == "succ") {
                $("#arr_record").html(a[1]);
                $("#hot_list_count").html(a[2]);
                $("#total_hotlisted").html(a[2])
            }
            if (a[0] == "error") {
                $("#arr_record").html(a[1]);
                $("#hot_list_count").html(a[2]);
                $("#total_hotlisted").html(a[2]);
                $("#action_td").remove();
                $("#gray_btn1").remove()
            }
        }
    })
}
function replyflirtmessage(a, b, c) {
    var d = $("input[name*='" + c + "']:checked").val();
    if (d == undefined || d == "") {
        $("#error_message").html("<ul class='err_mge'><li>" + lang.translate("flirtmessageerror") + "</li></ul>");
        return false
    } else {
        var e = sitePath2 + "user_login.php";
        var f = "section=flirtreply&loginuserid=" + a + "&userid=" + b + "&messageid=" + d;
        $.ajax({
            type: "POST",
            url: e,
            data: f,
            success: function (a) {
                $("#show_message").html(a)
            }
        });
        return false
    }
}
function hidefacebox() {
    jQuery(document).trigger("close.facebox")
}
function showhidevalue(a) {
    for (var b = 1; b <= 4; b++) {
        if (document.getElementById("flirtmess_" + b).style.display == "block") {
            document.getElementById("flirtmess_" + b).style.display = "none";
            document.getElementById("sign_" + b).innerHTML = "<span style='font-size:20px;'>+<span>"
        } else {
            if (document.getElementById("flirtmess_" + b) != null && a == b) {
                document.getElementById("flirtmess_" + b).style.display = "block";
                document.getElementById("sign_" + b).innerHTML = "<span style='font-size:20px;'>-<span>"
            } else {
                document.getElementById("flirtmess_" + b).style.display = "none";
                document.getElementById("sign_" + b).innerHTML = "<span style='font-size:20px;'>+<span>"
            }
        }
    }
}

function updateUserpassword(a, b) {
    $.facebox('<div id="popupimage"><img style="height:19px;width:89px;" src=' + imagePath + "loadingajax.png></img></div>");
    var c = sitePath2 + "user_login.php";
    var d = "section=updatepassword&password=" + a + "&userid=" + b;
    $.ajax({
        type: "POST",
        url: c,
        data: d,
        success: function (a) {
            $("#popupimage").html(a);
            $("#oldpassword").val("");
            $("#newpassword").val("");
            $("#confirmpassword").val("");
            return false
        }
    });
    return false
}
function fieldRequest(a, b, c) {
    var d = "";
    var e = sitePath2 + "user_login.php";
    var f = "section=fieldrequest&" + b + "=" + a + "&userid=" + c;
    $.ajax({
        type: "post",
        url: e,
        data: f,
        success: function (a) {
            d = a
        },
        async: false
    });
    if (d != "") return d
}

function deleteUserdetails(a, b, c) {
    $("#loadingimage").html('<img style="height:19px;width:89px;" src=' + imagePath + "loadingajax.png></img>");
    var d = $("#page_no").val();
    var e = sitePath2 + "user_login.php";
    var f = "section=" + c + "&deleteid=" + b + "&pageno=" + d;
    $.ajax({
        type: "GET",
        url: e,
        data: f,
        success: function (a) {
            a = jQuery.trim(a);
            a = a.split("~");
            if (a[0] == "succ") {
                $("#arr_record").html(a[1]);
                $("#total_records").text(a[2]);
                $("#pagination_div").html(a[3]);
                $("#loadingimage").html("")
            } else if (a[0] == "error") {
                $("#arr_record_all").html(a[1]);
                $("#total_records").text(a[2]);
                $("#loadingimage").html("<span style='text-align:left;'>" + a[1] + "</span>");
                $("#loadingimage").css("display", "block");
                $(".border").css("height", "470px")
            }
            return false
        }
    })
}
function showmessage(a, b, c, d) {
    var e = sitePath2 + "user_login.php";
    var f = "section=a&messageid=" + a + "&messagetype=" + b + "&loginuserid=" + c + "&guestuserid=" + d;
    $.ajax({
        type: "POST",
        url: e,
        data: f,
        success: function (a) {
            a = jQuery.trim(a);
            $.facebox(a)
        }
    })
}
function messageReply(a, b, c, d) {
    $("#erroruser").html("<img src=" + imagePath + "loadingajax.png></img>");
    if (d == "") {
        $("#messageuser").html("");
        $("#erroruser").show(500).html('<ul class="err_mge"><li>Please enter message!</li></ul>');
        return false
    } else {
        var e = sitePath2 + "user_login.php";
        var f = "section=userReply&loginuserid=" + c + "&userid=" + b + "&message=" + d + "&subject=" + a;
        $.ajax({
            type: "POST",
            url: e,
            data: f,
            success: function (a) {
                a = jQuery.trim(a);
                var b = a.split("#");
                $("#messageuser").html(b[0]);
                $("#erroruser").show(500).html(b[1]);
                $("#message").val("")
            }
        });
        return false
    }
}
function showPopupbox(a, b, c, d) {
    var e = sitePath2 + "user_login.php";
    var f = "section=" + c + "&loginuserid=" + a + "&userid=" + b + "&messageid=" + d;
    $.ajax({
        type: "POST",
        url: e,
        data: f,
        success: function (a) {
            a = jQuery.trim(a);
            $.facebox(a)
        }
    })
}
function showHide(a, b) {
    $("#message_" + a).show();
    for (i = 1; i <= b; i++) {
        if (a == i) {
            $("#message_" + a).show();
            $("#sign_" + a).html("[-]")
        } else {
            $("#sign_" + i).html("[+]");
            $("#message_" + i).hide()
        }
    }
}
function checkZip() {
    if ($("#zipcode_input").val() == "") {
        $("#zipcode_input").addClass("mandatory_textbox needed");
        $("#zipcode_input_mandatory_hidden").show()
    } else {
        $("#state_zipcode_list_div").hide();
        $("#city").hide();
        $("#zipcode_input").removeClass("mandatory_textbox needed");
        $("#city_mandatory_hidden").removeClass("mandatory");
        $("#zipcode_input_mandatory_hidden").hide();
        if ($("#zipcode_input").val().length > 4) {
            var a = sitePath2 + "user_ajax.php?action=verify_zipcode&zip_val=" + $("#zipcode_input").val();
            $.ajax({
                url: a,
                success: function (a) {
                    var b = $.trim(a);
                    if (b) {
                        $("#zipcode_input").addClass("mandatory_textbox needed");
                        $("#zipcode_input_mandatory_hidden").show()
                    } else {
                        $("#city_mandatory_hidden").removeClass("mandatory");
                        $("#zipcode_input_mandatory_hidden").hide()
                    }
                }
            })
        }
    }
}
function getCityList() {
    var a = $("#state_list :selected").text();
	var b = $("#country :selected").val();
	
    if (a != "-- Select --") {
        $("#state_list").removeClass("needed mandatory_dropdown2");
        var b = sitePath2 + "user_ajax.php?action=city_list&state_name=" + a + "&country_code="+b;
        data = makeAjaxCall(b);
        $("#city_div").html(data);
        $(".red_line").width($(".red_line").width() + 25)
    } else {
        $(".red_line").width($(".red_line").width() - 25);
        $("#state_list").addClass("needed mandatory_dropdown2");
        $("#city_div").html("")
    }
}
function findStateZipCode(a) {
    if (a == "zipcode") {
        $("#state_zipcode_list_div").hide();
        $("#zipcode_state_div").show();
        $("#city_div").hide();
        $("#zipcode_input").val("");
        $("#zipcode_input").addClass("needed");
        $("#state_list").removeClass("needed")
    } else if (a == "state") {
        $("#zipcode_state_div").hide();
        $("#city_div").show();
        $("#zipcode_input").val("");
        $("#state_zipcode_list_div").show();
        $("#zipcode_input").removeClass("needed");
        $("#zipcode_input_mandatory_hidden").removeClass("needed");
        $("#state_list").addClass("needed")
    }
}
function checkMandatory(a, b) {
    if (b == "radio") {
        var c = a + "_mandatory_hidden";
        if ($("#" + c).hasClass("needed")) {
            $(".red_line").width($(".red_line").width() + 25)
        }
        $("#" + c).hide();
        $("#" + c).removeClass("mandatory needed")
    } else if (b == "checkbox") {
        var d = $("input[name*=" + a + "]:checked");
        if (d.length > 0) {
            var c = a + "_mandatory_hidden";
            if ($("#" + c).hasClass("needed")) {
                $(".red_line").width($(".red_line").width() + 25)
            }
            $("#" + c).hide();
            $("#" + c).removeClass("mandatory needed")
        } else {
            var c = a + "_mandatory_hidden";
            if (!$("#" + c).hasClass("needed")) {
                $(".red_line").width($(".red_line").width() - 25)
            }
            $("#" + c).show();
            $("#" + c).addClass("mandatory needed")
        }
    } else if (b == "select") {
        var c = a + "_mandatory_hidden";
        var e = $("#" + a + " option:selected").val();
        var f = a.replace(/_/gi, " ");
        if (e == 0) {
            $("#" + c).show();
            $("#" + c).addClass("mandatory")
        } else {
            $("#" + c).hide();
            $("#" + c).removeClass("mandatory")
        }
    } else if (b == "textbox" || b == "textarea") {
        var g = $("#" + a).val();
        if (g != "") {
            $("#" + a).removeClass("mandatory_textbox needed");
            $("#" + a + "_mandatory_hidden").hide();
            $(".red_line").width($(".red_line").width() + 25)
        } else {
            $("#" + a).addClass("mandatory_textbox needed");
            $("#" + a + "_mandatory_hidden").show();
            $(".red_line").width($(".red_line").width() - 25)
        }
    }
}
function checkMandatoryDropDown(a, b) {
    var c = $("#" + a + " :selected").val();
    if (c == "0") {
        if (!$("#" + a).hasClass("mandatory_dropdown2")) {
            $(".red_line").width($(".red_line").width() - 25)
        }
        $("#" + a).addClass("mandatory_dropdown2");
        $("#" + a).addClass("needed")
    } else {
        if ($("#" + a).hasClass("needed")) {
            $(".red_line").width($(".red_line").width() + 25)
        }
        $("#" + a).removeClass("mandatory_dropdown2");
        $("#" + a).removeClass("needed")
    }
}
function validateForm() {
    var a = $("#first_name").val();
    var b = /\d/g;
    if (b.test(a)) {
        $.facebox("<ul class='err_mge'><li>Please enter valid First name !</li></ul>");
        return false
    }
    if (typeof $("#zipcode_state_div").css("display") != "undefined" && $("#zipcode_state_div").css("display") != "none") {
        if ($("#zipcode_input").val() == "") {
            $("#zipcode_input").addClass("mandatory_textbox needed");
            $("#zipcode_input_mandatory_hidden").addClass("mandatory_textbox needed");
            $("#zipcode_input_mandatory_hidden").show()
        } else {
            $("#zipcode_input").removeClass("mandatory_textbox needed");
            $("#zipcode_input_mandatory_hidden").removeClass("mandatory_textbox needed");
            $("#zipcode_input_mandatory_hidden").hide()
        }
        $("#state_list").removeClass("needed")
    } else if (typeof $("#state_zipcode_list_div").css("display") != "undefined" && $("#state_zipcode_list_div").css("display") != "none") {
        if ($("#state_list").val() == "0") {
            $("#state_list").addClass("needed")
        } else {
            $("#state_list").removeClass("needed")
        }
        $("#zipcode_input_mandatory_hidden").removeClass("needed")
    }
    var c = $(".needed");
    var d = "";
    var e = "";
    if (c.length > 0) {
        c.each(function (a) {
            d = $(this).get(0).tagName;
            e = $(this).attr("id");
            if (d == "INPUT") {
                if (a == "0") {
                    $("#" + e).focus()
                }
                $("#" + e + "_mandatory_hidden").show()
            } else if (d == "SELECT") {
                if (a == "0") {
                    $("#" + e).focus()
                }
                $("#" + e).addClass("mandatory_dropdown2")
            } else if (d == "A") {
                $("#" + e).show();
                if (a == "0") {
                    $("#" + e).focus()
                }
            } else if (d == "TEXTAREA") {
                $("#" + e).addClass("mandatory_textbox needed");
                $("#" + e + "_mandatory_hidden").show();
                if (a == "0") {
                    $("#" + e).focus()
                }
            }
        })
    } else {
        var a = $("#first_name").val();
        var f = $("#Marital_status").val();
        var g = $("#Relationship").val();
        var h = $("#country").val();
        var i = "";
        var j = "";
        var k = "";
        var l = $("#zipcode_state_div").css("display");
        if (typeof l != "undefined" && l != "none") {
            i = $("#zipcode_input").val();
            j = $("#state_2").val();
            k = $("#city_2").val()
        } else {
            j = $("#state_list option:selected").text();
            k = $("#city option:selected").text()
        }
        var m = "";
        $('#Language option:selected').each(function () {
            m += $(this).val() + ","
        });
		
        var n = "";
        $('#Interests option:selected').each(function () {
            n += $(this).val() + ","
        });
        //var o = $('input[name*="Education"]:checked').val();
        var o = $('#Education').val();
        var p = $("#Profession").val();
        var q = $("#Do_you_smoke").val();
        var r = $("#How_often_do_you_drink").val();
        var s = $("#Do_you_have_children").val();
        var t = $("#Which_of_these_best_describes_your_body_type").val();
        var u = $("#What_is_your_eye_color").val();
        var v = $("#What_is_your_hair_color").val();
        var w = $("#Appearance").val();
        var x = $("#descYourself").val();
        var y = $("#descYourMatch").val();
        var z = $("#Height").val();
        var A = $("#Religion").val();
        var B = $("#Income").val();
        var C = sitePath2 + "user_ajax.php?action=signup2&first_name=" + a;
        C += "&marital_status=" + f + "&relationship=" + g + "&country=" + h + "&zip_code=" + i;
        C += "&state=" + j + "&city=" + k + "&language=" + m + "&interests=" + n;
        C += "&education=" + o + "&profession=" + p + "&smoke=" + q + "&drink=" + r + "&children=" + s;
        C += "&body_type=" + t + "&eye_color=" + u + "&hair_color=" + v + "&appearance=" + w + "&yourself=" + x + "&your_match=" + y + "&height=" + z;
        C += "&income=" + B + "&religion=" + A;
        data = makeAjaxCall(C);
        data = data.split("~");
        $.facebox(data[1]);
        if (data[0] == 1) {
            var D = "<li style='list-style-type: none;text-align:center;line-height:4em'><img src=" + imagePath + "loading.gif /></li>";
            $.facebox(data[1] + D);
            setTimeout("window.location.href='signup3.html'", 2e3)
        }
    }
}
function checkUncheckAll(a) {
    var b = $("#" + a + "_hidden").val();
    var c = a + "_mandatory_hidden";
    if (b == "unchecked") {
        var d = "<a onclick=checkUncheckAll('" + a + "') href='javascript:void(0)'>Uncheck All</a><input type='hidden' value='checked' id='" + a + "_hidden'>";
        $("input[id=" + a + "]").attr("checked", true);
        $("#" + a + "_hidden").val("checked");
        $("#" + a + "_div").html(d);
        $(".red_line").width($(".red_line").width() + 25);
        $("#" + c).removeClass("mandatory needed");
        $("#" + c).hide()
    } else {
        var d = "<a onclick=checkUncheckAll('" + a + "') href='javascript:void(0)'>Check All</a><input type='hidden' value='unchecked' id='" + a + "_hidden'>";
        $("input[id=" + a + "]").attr("checked", false);
        $("#" + a + "_hidden").val("unchecked");
        $("#" + a + "_div").html(d);
        $(".red_line").width($(".red_line").width() - 25);
        $("#" + c).addClass("mandatory needed");
        $("#" + c).show()
    }
}
function callCaptcha() {
    var a = sitePath2 + "captcha.php";
    $.ajax({
        type: "POST",
        url: a,
        data: "section=captch_code",
        success: function (a) {
            a = jQuery.trim(a);
            var b = a.split("|");
            $("#imagecode").val(b[0]);
            $("#imageId").attr("src", sitePath2 + "captcha_images/" + b[1])
        }
    })
}
function check() {
    if ($("#check_btn").text() == "Check all") {
        $("input[id=delid]").attr("checked", true);
        $("#check_btn").text("Uncheck all")
    } else {
        $("input[id=delid]").attr("checked", false);
        $("#check_btn").text("Check all")
    }
}

function sendAjaxcall(a, b) {
    $.ajax({
        type: "POST",
        url: a,
        data: b,
        success: function (a) {
            a = jQuery.trim(a);
            var b = a.split("#");
            if (b[1] == "error") {
                $.facebox("<ul class='err_mge'><li>" + b[0] + "</li></ul>");
                return false
            }
            if (b[1] == "succ") {
                $.facebox("<ul class='err_mge'>Please wait while we redirect you to home page....</ul>");
                setTimeout("window.location.href='" + sitePath2 + b[0] + ".html'", 2e3)
            }
        }
    })
}

function makeAjaxCall(a) {
    var b = "false";
    $.ajax({
        url: a,
        success: function (a) {
            b = a
        },
        async: false
    });
    if (b != "false") return b;
}

function include(a) {
    var b = document.createElement("script");
    b.src = a;
    b.type = "text/javascript";
    b.defer = true;
    b.async = false;
    document.getElementsByTagName("head").item(0).appendChild(b)
}
var sitePath2 = "http://" + top.location.host + "/";
var imagePath = "http://" + top.location.host + "/webroot/images/";
var jsPath = "http://" + top.location.host + "/webroot/js/";
var imagespathuser = "http://" + top.location.host + "/webroot/uploades/approved_images";
var phraseBook = null;
var loadingmessage = "<div id='showresult'><div style='text-align:left;'><img src='" + imagePath + "ajax-wait.gif'/></div><div class='clear'></div><div style='font:13px/22px Verdana,Geneva,sans-serif;color:#615E5E;'>Please wait while processing your request....</div></div>";
include(jsPath + "lang.js");
window.onload = function () {
    window.lang = function () {
        return {
            translate: function (a) {
                return phraseBook[a]
            }
        }
    }()
};

$(document).ready(function () {
    $("#country").change(function () {
        var a = $(this).val();
        $("#state_zipcode_div").html(" ");
        $("#city_div").html("");
        if (a.length > 0 && a != "0") {
            var b = sitePath2 + "user_ajax.php?action=get_state_zip&country_code=" + a;
            var c = makeAjaxCall(b);
            $("#state_zipcode_div").html(c)
        }
    })
})

function block_user(friendid,add){
	var sitePath2 = "http://"+top.location.host+"/";
	var jsonObjects = {section:"blockuserprofile",user_id:friendid,profilestatus:add};
	$.ajax({
			  url:sitePath2+"ajaxcall.php",
			  type: "POST",
			  data: {request: JSON.stringify(jsonObjects) },
			  dataType: "json",
			  beforeSend: function(x) {
				if (x && x.overrideMimeType) {
				  x.overrideMimeType("application/j-son;charset=UTF-8");
				}
			  },
			  success: function(msg){
				if(msg.response.code=='200'){
					$.facebox(msg.response.messages);
				}
			  }
		});
}

function submit_block_user(friendid,action){
    var value_radio = $("input[name*='block_value']:checked").val();
	if(value_radio==undefined){
		$("#error_msge").html("<ul  class='err_mge'><li>please select option !</li></ul>");
	}else{
		var sitePath2 = "http://"+top.location.host+"/";
		var jsonObjects = {section:"blockuserfromid",user_id:friendid,optionvalue:value_radio};
		$.ajax({
				  url:sitePath2+"ajaxcall.php",
				  type: "POST",
				  data: {request: JSON.stringify(jsonObjects) },
				  dataType: "json",
				  beforeSend: function(x) {
					if (x && x.overrideMimeType) {
					  x.overrideMimeType("application/j-son;charset=UTF-8");
					}
				  },
				  success: function(msg){
					if(msg.response.code=='200'){
						$("#error_msge").html(msg.response.message);
				        setTimeout("window.location.href='home.html'",500);
					}
				  }
			});
	}
}

function removefavriote(friendid){
	$("#remove_"+friendid).html("<div style='text-align:center'><img src='webroot/images/ajax-loader.gif'/></div>");
	var sitePath2 = "http://"+top.location.host+"/";
	var jsonObjects = {section:"favriotefriend",user_id:friendid};
	$.ajax({
			  url:sitePath2+"ajaxcall.php",
			  type: "POST",
			  data: {request: JSON.stringify(jsonObjects) },
			  dataType: "json",
			  beforeSend: function(x) {
				if (x && x.overrideMimeType) {
				  x.overrideMimeType("application/j-son;charset=UTF-8");
				}
			  },
			  success: function(msg){
				if(msg.response.code=='200'){
					$("#remove_"+friendid).remove();
		            setTimeout("window.location.href='favriotefriends.html'",500);
			}
		 }
	});
}


function unfriendresult(friendid){
	$("#friendrequest_"+friendid).html("<div><img src='webroot/images/ajax-loader.gif'/></div>");
	var sitePath2 = "http://"+top.location.host+"/";
	var jsonObjects = {section:"unfriendlist",user_id:friendid};
	$.ajax({
			  url:sitePath2+"ajaxcall.php",
			  type: "POST",
			  data: {request: JSON.stringify(jsonObjects) },
			  dataType: "json",
			  beforeSend: function(x) {
				if (x && x.overrideMimeType) {
				  x.overrideMimeType("application/j-son;charset=UTF-8");
				}
			  },
			  success: function(msg){
				if(msg.response.code=='200'){
					$("#friendrequest_"+friendid).remove();
		            setTimeout("window.location.href='hotlisted.html'",500);
				}
			  }
	});
}


function blockUser(blockeduserid) {
	var sitePath2 = "http://"+top.location.host+"/";
	var jsonObjects = {section:"blockusers",blockedid:blockeduserid};
	$.ajax({
			  url:sitePath2+"ajaxcall.php",
			  type: "POST",
			  data: {request: JSON.stringify(jsonObjects) },
			  dataType: "json",
			  beforeSend: function(x) {
				if (x && x.overrideMimeType) {
				  x.overrideMimeType("application/j-son;charset=UTF-8");
				}
			  },
			  success: function(msg){
				if(msg.response.code=='200'){
					$("#friendrequest_"+blockeduserid).remove();
		            setTimeout("window.location.href='blockuser.html'",500);
				}
		  }
	});
}

