<?

	/*==================================================================*\
	######################################################################
	#                                                                    #
	# Copyright 2005 Arca Solutions, Inc. All Rights Reserved.           #
	#                                                                    #
	# This file may not be redistributed in whole or part.               #
	# eDirectory is licensed on a per-domain basis.                      #
	#                                                                    #
	# ---------------- eDirectory IS NOT FREE SOFTWARE ----------------- #
	#                                                                    #
	# http://www.edirectory.com | http://www.edirectory.com/license.html #
	######################################################################
	\*==================================================================*/

	# ----------------------------------------------------------------------------------------------------
	# * FILE: /frontend/socialnetwork/add_account.php
	# ----------------------------------------------------------------------------------------------------

    if (!$hideAddLabel) { ?>

    <h2><?=LANG_CREATE_MEMBER_PROFILE?></h2>
    
    <? }

    include(INCLUDES_DIR."/code/newsletter.php");

	$formloginaction = ((SSL_ENABLED == "on" && FORCE_MEMBERS_SSL == "on") ? SECURE_URL : NON_SECURE_URL)."/".MEMBERS_ALIAS."/login.php?destiny=".EDIRECTORY_FOLDER."/".SOCIALNETWORK_FEATURE_NAME."/";

	unset($openIDEnabled, $facebookEnabled, $googleEnabled);
	
	setting_get("foreignaccount_openid", $foreignaccount_openid);
	if ($foreignaccount_openid == "on") {
		$openIDEnabled = true;
	}
	
	setting_get("foreignaccount_google", $foreignaccount_google);
	if ($foreignaccount_google == "on") {
		$googleEnabled = true;
	}
	
	if (FACEBOOK_APP_ENABLED == "on") {
		$facebookEnabled = true;
	}
	    
	if ((string_strlen(trim($message_account)) > 0) || (string_strlen(trim($message_contact)) > 0) ) { ?>
		<p class="errorMessage">
            <? if (string_strlen(trim($message_contact)) > 0) { ?>
				<?=$message_contact?>
			<? } ?>
            <? if ((string_strlen(trim($message_contact)) > 0) && (string_strlen(trim($message_account)) > 0)) { ?>
				<br />
			<? } ?>
			<? if (string_strlen(trim($message_account)) > 0) { ?>
				<?=$message_account?>
			<? } ?>
		</p>
	<? } ?>
        
    <script language="javascript" type="text/javascript" src="<?=DEFAULT_URL?>/scripts/checkusername.js"></script>
		
    <? if (FACEBOOK_APP_ENABLED == "on" || $openIDEnabled == "on" || $googleEnabled == "on") { ?>
    <div class="left create-profile content-custom title textcenter">

        <h3 class="left signup"><?=system_showText(LANG_LABEL_PROFILE_SIGNUP);?></h3>      
        <h3 class="left or"><?=system_showText(LANG_LABEL_PROFILE_OR);?></h3>
        <h3 class="left signin"><?=system_showText(LANG_LABEL_PROFILE_FOREIGNACC);?></h3>

    </div>
    
    <? } ?>

    <div class="clear">&nbsp;</div>

    <div class="content-custom create-profile cont_100">

        <div class="<?=(FACEBOOK_APP_ENABLED == "on" || $openIDEnabled == "on" || $googleEnabled == "on" ? "cont_50" : "cont_100")?>">

            <form class="" name="add_account" action="<?=system_getFormAction($_SERVER["PHP_SELF"])?>" method="post">
                <div>
                    <div class="inputimg"><i class="inpname"></i><input type="text" name="first_name" placeholder="<?=system_showText(LANG_LABEL_FIRST_NAME);?>" value="<?=$first_name?>" /></div>
                    <div class="inputimg"><i class="inpname"></i><input type="text" name="last_name"  placeholder="<?=system_showText(LANG_LABEL_LAST_NAME);?>" value="<?=$last_name?>" /></div>
                </div>

                <div>
                    <div class="inputimg large"><i class="inpemail"></i><input type="text" name="username" placeholder="<?=system_showText(LANG_LABEL_USERNAME)?>" id="username" value="<?=$username?>" maxlength="<?=USERNAME_MAX_LEN?>" onblur="checkUsername(this.value, '<?=DEFAULT_URL;?>', 'members', 0); populateField(this.value,'email');"/></div>
                    <input type="hidden" name="email" id="email" value="<?=$email?>" />
                    <label id="checkUsername"></label>
                </div>

                <div>
                    <div class="inputimg"><i class="inppassword"></i><input type="password"  placeholder="<?=system_showText(LANG_LABEL_CREATE_PASSWORD)?>" name="password" maxlength="<?=PASSWORD_MAX_LEN?>" /></div>
                    <div class="inputimg"><i class="inppassword"></i><input type="password"  placeholder="<?=system_showText(LANG_LABEL_RETYPE_PASSWORD);?>" name="retype_password" /></div>
                </div>
                
                <? if ($showNewsletter) { ?>
                <div>
                    <input type="checkbox" class="checkbox" name="newsletter" value="y" <?=($newsletter || (!$newsletter && $_SERVER["REQUEST_METHOD"] != "POST")) ? "checked" : ""?> />
                    <label><?=$signupLabel?></label>
                </div>
                 <br class="clear" />
                <? } ?>

                <div>
                    <input type="checkbox" class="checkbox" name="agree_tou" value="1" <?=($agree_tou) ? "checked" : ""?> />
                    <label><a rel="nofollow" href="<?=DEFAULT_URL?>/popup/popup.php?pop_type=terms" class="fancy_window_iframe"><?=system_showText(LANG_IGREETERMS)?></a></label>
                </div>

                <br class="clear" />

                <p class="standardButton buttoncenter">
                    <button type="submit" value="Submit"><?=system_showText(LANG_BUTTON_SUBMIT)?></button>
                </p>
            </form>

        </div>

        <? if (FACEBOOK_APP_ENABLED == "on" || $openIDEnabled == "on" || $googleEnabled == "on") { ?>

            <div class="divider"></div>

            <div class="cont_40">

                <? if (FACEBOOK_APP_ENABLED == "on" || $googleEnabled == "on") { ?>
                    <div>
                        <p>
                            <? if (FACEBOOK_APP_ENABLED == "on") {
                                $summaryForm = true;
                                $urlRedirect = "?destiny=".urlencode(DEFAULT_URL."/".SOCIALNETWORK_FEATURE_NAME."/");
                                include(INCLUDES_DIR."/forms/form_facebooklogin.php");
                            } ?>

                            <? if ($googleEnabled == "on") {
                                $summaryForm = true;
                                $urlRedirect = "&destiny=".urlencode(DEFAULT_URL."/".SOCIALNETWORK_FEATURE_NAME."/");
                                include(INCLUDES_DIR."/forms/form_googlelogin.php");
                            } ?>
                        </p>
                    </div>
                <? } ?>

                <? if ($openIDEnabled) { ?>
                    <div>
                        <? if (FACEBOOK_APP_ENABLED == "on" || $googleEnabled == "on") { ?>
                            <p><?=system_showText(LANG_LABEL_PROFILE_OPENID);?></p>
                        <? } ?>

                        
                         <form class="form" name="formOpenID" method="post" action="<?=$formloginaction;?>">

                            <input type="hidden" name="userform" value="openid" />
							<p class="standardButton btn-openid">
                                <? 
                                $summaryForm = true;
                                include(INCLUDES_DIR."/forms/form_openidlogin.php");
                                ?>
							</p>
                        </form>
                        
                    </div>
                <? } ?>

            </div>

        <? } ?>

    </div>