function MatchInfoPopup()
{
	window.open(matchInfoPopup,null,'height=400,width=500,channelmode=0,directories=0,fullscreen=0,location=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0');
}

function P2pPopup()
{
	window.open(p2pPopup,null,'height=200,width=400,channelmode=0,directories=0,fullscreen=0,location=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0');	
}
function ChemistryRedirect(chemDomain)
{
	
	
	var varFName, varHandle, varEmailAddress;
	var varPassword, varEmailAddress, varGender, varThemGender;
	var varDay, varMonth, varYear;
	var varPostal;
	

	
	varFName = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:registrationFirstName'].value;
	document.matchMainForm.elements['txtFName'].value = varFName;
	
	varHandle = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:registrationHandle'].value;
	document.matchMainForm.elements['txtHandle'].value = varHandle;
	
	varEmailAddress = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:emailAddress'].value;
	document.matchMainForm.elements['txtEmailAddress'].value = varEmailAddress;
	
	varPassword = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:registrationPassword'].value;
	
	document.matchMainForm.elements['txtPassword'].value = varPassword;
	document.matchMainForm.elements['txtPassword1'].value = varPassword;
	

	var gender = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:gender'];
	for (i=0;i<gender.length;i++)
    {
		if (gender[i].checked)
		{
			varGender = gender[i].value;
		}
    }
    if(varGender == "genderMale")
    {
    document.matchMainForm.elements['ddGender'].value = "1";
    } else {
    document.matchMainForm.elements['ddGender'].value = "2";
    }
    
	var themGender = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:themGender'];
	for (i=0;i<themGender.length;i++)
    {
		if (themGender[i].checked)
		{
			varThemGender = themGender[i].value;
		}
    }
    if(varThemGender == "themGenderMale")
    {
    document.matchMainForm.elements['ddGenderPref'].value = "1";
    } else {
    document.matchMainForm.elements['ddGenderPref'].value = "2";
    }
    
   
    var monthSelectBox = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:birthdateMonth'];
    var daySelectBox = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:birthdateDay'];
    var yearSelectBox = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:birthdateYear'];
    
    varMonth = monthSelectBox.options[monthSelectBox.selectedIndex].value
    document.matchMainForm.elements['ddMonth'].value = varMonth;
    varDay = daySelectBox.options[daySelectBox.selectedIndex].value
    document.matchMainForm.elements['ddDay'].value = varDay;
    varYear = yearSelectBox.options[yearSelectBox.selectedIndex].value
    if(varYear == 1919)
    {
       varYear = 1920;
    }
    document.matchMainForm.elements['ddYear'].value = varYear;
    
    
    var varPostal = document.matchMainForm.elements['ControlLandingPage:ControlRegistrationLandingPage:postalCode'].value;
    document.matchMainForm.elements['txtPostal'].value = varPostal;
    
    document.matchMainForm.elements['chkAgreement'].value = "on";
    
    document.matchMainForm.action = "http://" + chemDomain + "/registration/deeplinkregistration.aspx";
    
	document.matchMainForm.submit();
	
    /*
    var countryBox = document.matchMainForm.elements['CountryCode'];
    var countryCode = countryBox.options[countryBox.selectedIndex].value
    */
    
}

$jq.namespace('MatchCore.UI.Registration');

MatchCore.UI.Registration.LocationSelection = function() {
    var _container;
    var _regionPane;
    var _zipPane;
    var _countryddl;

    var wireupControls = function() {
        MatchCore.Page.onInitComplete(function() {


            $jq('.ajaxGeoContainer').behavior('MatchCore.AjaxGeo', function(ajaxGeo) {
                ajaxGeo.CountryFilledEvent(function() {
                    countryChangedHandler();
                })
            });
        });


        _zipPane = $jq(".postalPane", _container);
        _countryddl = $jq(".countryList", _container);
        _regionPane = $jq(".regionPane", _container);

        _countryddl.change(countryChangedHandler);
    };

    var countryChangedHandler = function() {
        var selected = $jq("option:selected", _countryddl);
        if ($jq(selected).val() == 1 || $jq(selected).val() == 2 || $jq(selected).val() == 224 || $jq(selected).val() == null) {
            HideStateShowZip();
        }
        else {
            HideZipShowState();
        }
    };

    var HideStateShowZip = function() {
        $jq(_regionPane).hide();
        $jq(_zipPane).show();
    };

    var HideZipShowState = function() {
        $jq(_regionPane).show();
        $jq(_zipPane).hide();
    };

    var self = {
        init: function(opts) {

            if (opts != null && opts.container) {
                _container = opts.container;

                wireupControls();
            }
        }
    };
    return self;

};