<div id="selImportedEmails">
<div class="clsCommonTopAnalystRoundedCorner">
  <!--rounded corners-->
  <h2 class="clsInboxReadHeading">{$LANG.common_import_contacts}</h2>
   <div class="clsShadedBg">
  <div class="lbtopanalyst">
    <div class="rbtopanalyst">
      <div class="bbtopanalyst">
        <div class="blctopanalyst">
          <div class="brctopanalyst">
            <div class="tbtopanalyst">
              <div class="tlctopanalyst">
                <div class="trctopanalyst">
				<div class="clsInboxReadTbl">
	<ul class="clsImportContactLink">
		 <li class="highlight"><a href="{$myobj->getGmailUrl()}">{$LANG.label_get_gmail_contacts}</a></li>
        {if $myobj->yahooCheck}
            <li><a href="{$myobj->getYahooUrl()}">{$LANG.label_get_yahoo_contacts}</a></li>
		{/if}
        {if $myobj->msnCheck}
            <li><a href="{$myobj->getLiveUrl()}" >{$LANG.label_get_msn_contacts}</a></li>
        {/if}
     	{if $facebook_user && isMember()}
			<li><a onclick="return popupFacebookInvite();" href="javascript:void(0);" class="registerlinktext">{$LANG.common_facebook_contacts}</a></li>
		{/if}
	</ul>
{if $myobj->isShowPageBlock('form_imported_emails')}
	{include file='../general/box.tpl' opt='form_top'}
	{literal}
		<script type="text/javascript">
			function inviteSelectedContacts(){
				var frm = document.email_form;
				var e = new Array();
				var l = new Array();
				var selectedEmail = false;
				for(var i=0, n = frm.elements.length, o=null; i<n ; i++){
					 o=frm.elements[i];
					 if(o.type == 'checkbox'){
						if(o.checked){
							e.push(o.value)
							l.push(o.id);
							selectedEmail = true;
						}
					 }
				}
				if (!selectedEmail){
					alert_manual(LANG_select_and_import_emails);
					return false;
				}

				var opin = window.opener;
				var doError = false;
				if (opin != null){
					var selImporter = opin.document.getElementById('selImportedEmails');
					var txtArea = opin.document.getElementById('to_emails');
					var email_id = email_id_label = anchor_id = str = sel_name = '';
					var delContactIcon = 'Delete';
					if (selImporter != null){
						//selImporter.innerHTML = '';
						for(var i=0, n=e.length; i<n; i++){
							id = l[i];
							id = id.replace('chk', 'spn');
							email_id = email_id_label = e[i];
							sel_name = '&lt;'+email_id+'&gt;'+$(id).innerHTML+'&nbsp';
							email_id_label = email_id_label.replace('\.', 'DOT');
							email_id_label = email_id_label.replace('@', 'AT');
							anchor_id = 'cont_anchor_'+email_id_label;
							var o = opin.document.getElementById(anchor_id);
							if(o == null){
								str = '<span id="'+ anchor_id +'"><a href="#" onclick="Element.remove(\''+ anchor_id +'\');return false">'+ delContactIcon +'</a><input type="hidden" name="email_set[]" value="'+ email_id +'" /><input type="hidden" name="email_set_names[]" value="'+ $(id).innerHTML +'" />' + sel_name + '<br/></span>';
								selImporter.innerHTML += str;
							}
						}
						//txtArea.focus();
					}else{
						//doError = true;
					}
				}else{
					//doError = true;
				}
				if(doError){
					alert('We are Sorry, An Error Occured in this process!');
					window.close();
				}
			}

			function twcChkAllContact(chk){
				var k = document.email_form.elements;
				var e = null;
				var chkString = (chk > 0)?'checked':'';
				for(var i=0, n=k.length; i<n; i++){
					e = k[i];
					if(e.type == 'checkbox'){
						e.checked = chkString;
					}
				}
			}

		</script>
	{/literal}
	{if $myobj->emails}
		<div>
			<h2>Imported Contacts</h2>
			<form id="email_form" name="email_form">
				{assign var = "id" value= 0}
				{include file='../general/box.tpl' opt='data_top'}
				{foreach name='emails' from=$myobj->emails key=key item=item}
	                <input type="checkbox" id="chk_{$smarty.foreach.emails.index}" value="{$key}" />
	                &nbsp;<label for="chk_{$smarty.foreach.emails.index}">
	                        <span id="spn_{$smarty.foreach.emails.index}">
	                            {$item}
	                        </span>
	                      </label><br />
	            {/foreach}
				{include file='../general/box.tpl' opt='data_bottom'}
			<div class="clsImportButtons">
				Select <a href="javascript:twcChkAllContact(1)">{$LANG.common_all}</a>
				&nbsp;
				<a href="javascript:twcChkAllContact(0)">{$LANG.common_none}</a>
				<input class="clsSubmitButton" type="button" value="Import Contacts" onclick="inviteSelectedContacts();" /></div>
			</form>
		</div>
	{/if}
    <div class="clsImportButtons">
		<div class="clsImportButtonClose"><p class="clsImportClose"><a href="javascript:window.close()" title="{$LANG.close}">{$LANG.close}</a></p></div>
	</div>
	{include file='../general/box.tpl' opt='form_bottom'}
{/if}
</div>
  </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  </div>
  <!--end of rounded corners-->
</div>
</div>
{if $facebook_user && isMember()}
{literal}
	<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
	<script language="javascript">
				var a = '{/literal}{$ask}{literal}';

		FB_RequireFeatures(["XFBML"], function()
			{
			  FB.Facebook.init("{/literal}{$CFG.facebook.api_key}{literal}", "{/literal}{$CFG.site.url}{literal}facebook/xd_receiver.htm");
			  //8e1eac6825a150fe4831b9b55163e0ab
			});
		if( a=='')
			{
					function popupRequestForm(){
						FB.IFrameUtil.CanvasUtilServer.run(true);
						var _de=document.createElement("div");
						_de.setAttribute("iframeHeight","630px");
						_de.setAttribute("iframeWidth","560px");
						var _df=new FB.UI.PopupDialog("{/literal}{$LANG.facebook_invite_app} {$CFG.site.name}{literal}",_de,false,false);
						_df.setContentWidth(560);
						_df.setContentHeight(630);
						_df.set_placement(FB.UI.PopupPlacement.center);

						_de.setAttribute("fbml","<fb:fbml>"+"<fb:request-form style=\"width:560px; height:630px;\" action=\""+document.location.href+"\"\tmethod=\"POST\" invite=\"true\" type=\"{/literal}{$CFG.site.name}{literal}\" "+"content=\"{/literal}{$LANG.facebook_invite_message}{$CFG.site.name}{literal}<fb:req-choice url='{/literal}{$CFG.site.url}{literal}' label='Confirm' />\">"+"<fb:multi-friend-selector\tshowborder=\"false\" actiontext=\"{/literal}{$LANG.facebook_invite_title}{$CFG.site.name}{literal}\" rows=\"10\" bypass=\"cancel\"\tshowborder=\"false\" exclude_ids=\"{/literal}{$facebook_friends}{literal}\" />"+"</fb:request-form>"+"</fb:fbml>");
						_df.show();
						FB_RequireFeatures(["XFBML"],function(){
						var _e0=new FB.XFBML.ServerFbml(_de);
						FB.XFBML.Host.addElement(_e0);
						});
						}
			}

		 if( a == 'forum')
			{
					function popupRequestForm2(){
						FB.IFrameUtil.CanvasUtilServer.run(true);
						var _de2=document.createElement("div");
						_de2.setAttribute("iframeHeight","630px");
						_de2.setAttribute("iframeWidth","560px");
						var _df2=new FB.UI.PopupDialog("{/literal}{$LANG.facebook_show_forums} {$CFG.site.name}{literal}",_de2,false,false);
						_df2.setContentWidth(560);
						_df2.setContentHeight(630);
						_df2.set_placement(FB.UI.PopupPlacement.center);
						_de2.setAttribute("fbml","<fb:fbml>"+"<fb:request-form style=\"width:560px; height:630px;\" action=\""+document.location.href+"\"\tmethod=\"POST\" invite=\"true\" type=\"{/literal}{$CFG.site.name}{literal}\" "+"content=\"{/literal}{$LANG.facebook_invite_forum_message}{$CFG.site.name}{literal}<fb:req-choice url='{/literal}{$forum_details}{literal}' label='Confirm' />\">"+"<fb:multi-friend-selector\tshowborder=\"false\" actiontext=\"{/literal}{$LANG.facebook_forum_title}{$CFG.site.name}{literal}\" rows=\"10\" bypass=\"cancel\"\tshowborder=\"false\" />"+"</fb:request-form>"+"</fb:fbml>");
						_df2.show();
						FB_RequireFeatures(["XFBML"],function(){
						var _e02=new FB.XFBML.ServerFbml(_de2);
						FB.XFBML.Host.addElement(_e02);
						});
						}
			}
		 if( a == 'question')
			{

					function popupRequestForm1(){
						FB.IFrameUtil.CanvasUtilServer.run(true);
						var _de1=document.createElement("div");
						_de1.setAttribute("iframeHeight","630px");
						_de1.setAttribute("iframeWidth","560px");
						var _df1=new FB.UI.PopupDialog("{/literal}{$LANG.facebook_show_question} {$CFG.site.name}{literal}",_de1,false,false);
						_df1.setContentWidth(560);
						_df1.setContentHeight(630);
						_df1.set_placement(FB.UI.PopupPlacement.center);
						_de1.setAttribute("fbml","<fb:fbml>"+"<fb:request-form style=\"width:560px; height:630px;\" action=\""+document.location.href+"\"\tmethod=\"POST\" invite=\"true\" type=\"{/literal}{$CFG.site.name}{literal}\" "+"content=\"{/literal}{$LANG.facebook_invite_question_message}{$CFG.site.name}{literal}<fb:req-choice url='{/literal}{$question_details}{literal}' label='Confirm' />\">"+"<fb:multi-friend-selector\tshowborder=\"false\" actiontext=\"{/literal}{$LANG.facebook_question_title}{$CFG.site.name}{literal}\" rows=\"10\" bypass=\"cancel\"\tshowborder=\"false\" />"+"</fb:request-form>"+"</fb:fbml>");
						_df1.show();
						FB_RequireFeatures(["XFBML"],function(){
						var _e01=new FB.XFBML.ServerFbml(_de1);
						FB.XFBML.Host.addElement(_e01);
						});
						}
			}

		function popupFacebookInvite(){
		FB.Facebook.get_sessionState().waitUntilReady(Delegate.create(null,function(_e1){
		FB.Facebook.apiClient.connect_getUnconnectedFriendsCount(function(o,e){
		if(o>1){
		FB.Connect.inviteConnectUsers();
		}
		else{
		if( a=='')
 		   popupRequestForm();
	         if( a == 'forum')
		   popupRequestForm2();
		 if( a == 'question')
		   popupRequestForm1();
		}
		});
		}));
		return false;
		}
	</script>
    <script type="text/javascript">window.onload =  function() { facebook_onload(true); };</script>
{/literal}
{/if}