﻿function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
        
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;



}


$(function () {

    var PortalSignIn = function () {
        $(".error").text("");
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: "../Services/Registration.asmx/PortalLogIn",
            dataType: "json",
            data: JSON.stringify(objPortal),
            success: function (data) {
                data = data.d;
                if (data.ContainsMetadata) {
                    alert(data.Metadata);
                }
                else {
                    if (data.IsPortalMember) {
                        window.location.href = referralUrls.RedirectUrl;
                    }
                    else {
                        $(".error").text("Your Facebook Connect login is not associated with this portal.");
                    }
                }
            }
        });
    };

    FB.init({ appId: window.fbID, status: true, cookie: true, xfbml: true });

    FB.Event.subscribe('auth.sessionChange', function (response) {
        if (response.session) {
            //PortalSignIn();

        }
    });

    window.memberCheck = function () {

        PortalSignIn();

    }


});
