﻿// JScript File

function shareDialog(data,isMulti)
{
    $("div[role='dialog']").detach();
    var sHTML ="";
    var sEmbedCode ="";    
    sEmbedCode += '<div id="shareEmbedTab" style="height:320px; border:0px;"><ul><li><a href="#embedMySpace">for myspace</a></li><li><a href="#embedFacebook">for facebook - fan page</a></li><li><a href="#embedHTML">for HTML</a></li></ul>';
    sEmbedCode += '<div id="embedMySpace" style="height:280px;"><div class="ShareTitle">embed this canvas</div>embed code<br/><textarea rows="2" cols="1500" readonly="readonly" id="txtCanvasEmbedCodeMS" class="inputTextBox" onclick="this.focus();this.select();" style="height: 170px; width: 580px;"></textarea><br/>copy and paste this HTML Code into your MySapce<br/></div>';
    sEmbedCode += '<div id="embedFacebook" style="height:280px;"><div class="ShareTitle">embed this canvas</div>embed code<br/><textarea rows="2" cols="1500" readonly="readonly" id="txtCanvasEmbedCodeFB" class="inputTextBox" onclick="this.focus();this.select();" style="height: 170px; width: 580px;"></textarea><br/>copy and paste this HTML Code into your Facebook<br/></div>';
    sEmbedCode += '<div id="embedHTML" style="height:280px;"><div class="ShareTitle">embed this canvas</div>embed code<br/><textarea rows="2" cols="1500" readonly="readonly" id="txtCanvasEmbedCode" class="inputTextBox" onclick="this.focus();this.select();" style="height: 170px; width: 580px;"></textarea><br/>copy and paste this HTML into your blog or web page<br/></div></div>';

    
    sHTML += '<div id="mDialog"><input value="' + data + '"  id="hdnIDs" type="hidden"/><div id="shrErrorMsg" class="shrErrorMsg" style="display:none"></div><div id="shrSuccessMsg" class="shrSuccessMsg" style="display:none"></div>';
    sHTML += '<div id="shareTab"><ul><li><a href="#share">share</a></li><li><a href="#email">email</a></li><li><a href="#url">url</a></li><li><a href="#embed">embed code</a></li></ul>';
    sHTML += '<div id="share"><div id="divShareIcon" style="height: 100%; overflow: auto"></div><div id="divSSNetwork" style="display:none;height: 100%;overflow: hidden"></div></div>';
    sHTML += '<div id="email"><div id="divEmailthis" style="height: 100%; overflow: auto"></div><div id="divImportEmail" style="display:none;height: 100%;overflow: hidden"></div><div id="divImportContacts" style="display:none;height: 100%;overflow:auto;"></div></div>';
    sHTML += '<div id="url"><div class="ShareTitle">url to this canvas</div>canvas url<br/><textarea rows="2" cols="1300" readonly="readonly" id="txtCanvasLinkURL" class="inputTextBox" onclick="this.focus();this.select();" style="height: 100px; width: 550px;"></textarea><br/>copy and paste this url in an email or IM<br/></div>';
    sHTML += '<div id="embed">&nbsp;<br>' + sEmbedCode + '</div>';
    sHTML += '</div></div>';
    var $dialog = $(sHTML)
		.dialog({
			width: 660,
			height: 470,
			modal: true,
			title:"SHARE THIS CANVAS"
		});
		
	if (isMulti)
    {	
        $("#shareTab").tabs({disabled: [0,2,3] },{ selected: 1 });
    }
    else
    {
        $("#shareTab").tabs();
    }
    
    $("#shareEmbedTab").tabs();
    
    $("#shareTab").bind('tabsselect', function(event, ui) 
    {
        if (ui.index ==1){$("#txtIFFromName").focus();}
        else if(ui.index==2){$("#txtCanvasLinkURL").focus();}
        else if(ui.index==3){$("#txtCanvasEmbedCodeMS").focus();}
    });
    
    $.ajax({
        type: "POST",
        url: "CanvasShareThisData.aspx",
        data: "ZXVC="+encodeURIComponent(data),
        dataType: 'json',
        "cache":false,
        error:function(response){$("#shareTab").hide();$("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();},
        success: function(response)
        {
              if(response["status"]["code"]=="1")
              {
                if(isMulti!=true)
                {
                    $("#txtCanvasLinkURL").val(response["link"]["url"]);
                    $("#txtCanvasEmbedCode").val(response["embed"]["url"]);
                    $("#txtCanvasEmbedCodeMS").val(response["embedForMS"]["url"]);
                    $("#txtCanvasEmbedCodeFB").val(response["embedForFB"]["url"]);
                    pShare(response["share"], response["sharehtml"]["url"]);
                }
                pEmail(response["email"], response["uinfo"]);
              }
              else if(response["status"]["code"]=="0")
              {
                $("#shareTab").hide();
                $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
              }
            
        }
        });
   
}


function pEmail(sData, uInfo)
{

    var sHTML="";
    sHTML += '<div class="ShareTitle">email to this canvas</div><div class="formGap">';
    sHTML += '<div class="shrCatalogName"><b><u>Catalog</u></b></div><div class="shrCanTitle"><b><u>Canvas Title</u></b></div><br/>';
    $(sData).each(function(index,eItem)
    { 
        sHTML += '<div class="shrCatalogName">' + eItem["catalog"] + '</div><div class="shrCanTitle">' + eItem["title"] + '</div><br/>';
    });
    sHTML += '</div><br/>';
    sHTML += '<div class="formGap">from name<br/>';
    sHTML += '<input maxlength="50" size="500" id="txtIFFromName" value="'+ uInfo["name"] +'" class="inputTextBox" style="width: 550px;" type="text"><span class="Required">&nbsp;*</span></div>';
    sHTML += '<div class="formGap">from email address<br/>';
    sHTML += '<input maxlength="50" size="500" id="txtIFFromEmail" value="'+ uInfo["emailid"] +'"  class="inputTextBox" style="width: 550px;" type="text"><span class="Required">&nbsp;*</span></div>';
    sHTML += '<div class="formGap">to email address<br/>';
    sHTML += '<textarea rows="2" cols="1500" id="txtIFToEmail" class="inputTextBox" style="height: 120px; width: 550px;"></textarea><span class="Required">&nbsp;*</span><br>'
    sHTML += 'use commas(,) to separate emails</div>';
    sHTML += '<div class="formGap"><input value="send to friends" id="btnIFEmail" title="send to friends" class="buttonStyle" type="button">&nbsp;&nbsp;';
    sHTML += '<input value="Reset" id="btnIFEmailReset" title="reset" class="buttonStyle" type="reset">&nbsp;&nbsp;';
    sHTML += '<input value="Import Email Address" id="btnIFImportEmail" title="Import Email Address" class="buttonStyle" type="button">&nbsp;&nbsp;</div>';
    $("#divEmailthis").html(sHTML).show();
    $("#btnIFEmailReset").bind("click",uInfo,function(e)
    {
        $("#txtIFFromName").val(uInfo["name"]);
        $("#txtIFFromEmail").val(uInfo["emailid"]);
        $("#txtIFToEmail").val("");
        $("#txtIFFromName").focus();
    });
    
    $("#txtIFFromName").bind("keydown",function(e){defaultButton(e,"#btnIFEmail");});
    $("#txtIFFromEmail").bind("keydown",function(e){defaultButton(e,"#btnIFEmail");});
    $("#txtIFToEmail").bind("keydown",function(e){defaultButton(e,"#btnIFEmail");});
        
    $("#btnIFImportEmail").bind("click",function(e){pImportEmail()});
    
    $("#btnIFEmail").bind("click", function(e)
    {
        $("div[id$='shrSuccessMsg']").empty().hide();
        $("div[id$='shrErrorMsg']").empty().hide();        
        if( ($.trim($("#txtIFFromName").val())=="") || ($.trim($("#txtIFFromEmail").val())=="") || ($.trim($("#txtIFToEmail").val())=="") )
        {
            $("div[id$='shrErrorMsg']").html("fields marked as (*) are required").show();
            if (($.trim($("#txtIFFromName").val())=="")){$("#txtIFFromName").focus();}
            else if (($.trim($("#txtIFFromEmail").val())=="")){$("#txtIFFromEmail").focus();}
            else if (($.trim($("#txtIFToEmail").val())=="")){$("#txtIFToEmail").focus();}
            return;
        }
        else if (!valid_email($.trim($("#txtIFFromEmail").val())))
        {
            $("div[id$='shrErrorMsg']").html("invalid from email address").show();
            $("#txtIFFromEmail").focus();
            return;
        }

        $("#btnIFEmail").attr("disabled", "disabled");
        $("#btnIFEmail").val("processing");

        
        $.ajax({
            type: "POST",
            url: "SaveShareThisData.aspx",
            data: "typ=email&FromName="+ encodeURIComponent($("#txtIFFromName").val()) +"&FromEmail="+ encodeURIComponent($("#txtIFFromEmail").val()) +"&ToEmail=" + encodeURIComponent($("#txtIFToEmail").val()) +"&ZXVC="+encodeURIComponent($("#hdnIDs").val()),
            dataType: 'json',
            "cache":false,
            error:function(response){$("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();$("#btnIFEmail").removeAttr("disabled");$("#btnIFEmail").val("Invite Friends");},
            success: function(response)
            {
                  if(response["status"]["code"]=="1")
                  {
                     $("div[id$='shrSuccessMsg']").html(response["status"]["msg"]).show();
                  }
                  else if(response["status"]["code"]=="0")
                  {
                    $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
                  } 
                  $("#btnIFEmail").removeAttr("disabled");
                  $("#btnIFEmail").val("send to friends");
            }
        });
    });
}

function pImportEmail(isAddressBook)
{
    var sHTML="";
    $("div[id$='shrSuccessMsg']").empty().hide();
    $("div[id$='shrErrorMsg']").empty().hide();
    
    if (isAddressBook != true)
     $("#divEmailthis").hide();
    
    $("#divImportEmail").empty();
    
    sHTML += '<div class="ShareTitle"><img src="_shared/images/email_web.gif">&nbsp;web email&nbsp;&nbsp;(hotmail, gmail, yahoo, etc.);</div>';
    sHTML += '<div class="formGap">email address<br>';
    sHTML += '<input maxlength="200" id="txtIEEmail" class="inputTextBox" style="width: 300px;" type="text">&nbsp;@&nbsp;';
    sHTML += '<select id="optIEEmail" style="width: 140px;"><option selected="selected" value="gmail.com">gmail.com</option><option value="hotmail.com">hotmail.com</option><option value="yahoo.com">yahoo.com</option><option value="msn.com">msn.com</option><option value="aol.com">aol.com</option><option value="yahoo.co.in">yahoo.co.in</option><option value="rediffmail.com">rediffmail.com</option><option value="mail.com">mail.com</option><option value="email.com">email.com</option><option value="fastmail.fm">fastmail.fm</option><option value="live.com">live.com</option><option value="bellsouth.net">bellsouth.net</option><option value="windowslive.com">windowslive.com</option><option value="mac.com">mac.com</option><option value="lycos.com">lycos.com</option><option value="earthling.net">earthling.net</option><option value="myspace.com">myspace.com</option><option value="plaxo.com">plaxo.com</option><option value="orkut.com">orkut.com</option></select></div>';
    sHTML += '<div class="formGap">password<br>';
    sHTML += '<input maxlength="200" id="txtIEPassword"  class="inputTextBox" style="width: 300px;" type="password"></div>';
    sHTML += '<div class="formGap"><input value="Find Friends" id="btnIEFindFriends" title="Find Friends" class="buttonStyle" type="button"><br>';
    sHTML += 'we won\'t store your email  login information</div>';
    sHTML += '<br><br><div class="ShareTitle"><img src="_shared/images/email_application.gif">&nbsp; email application &nbsp;&nbsp;(outlook, outlook express, etc.)</div>';
    sHTML += '<div class="formGap">upload a contacts file below and ZingZag! Community will securely import your contacts.</div>';
    sHTML += '<div class="formGap">format type<br>';
    sHTML += '<select id="optIECSVType"><option value="o2000">Outlook CSV</option><option value="oe6">Outlook Express CSV</option><option value="tb">Mozilla Thunderbird (CSV)</option><option value="tbldif">Mozilla Thunderbird (LDIF)</option><option value="vcf">Mac OS Address Book (or any vCard)</option></select></div>';
    sHTML += '<div class="formGap">contact file<br>';
    sHTML += '<input id="filIECSVFile" name="filIECSVFile" style="width: 350px;"  type="file"></div>';
    sHTML += '<div class="formGap"><input value="Find Friends" id="btnIECSVFiles" title="Find Friends" class="buttonStyle" type="button">&nbsp;&nbsp;';
    sHTML += '<input value="Reset" id="btnIEReset" title="reset" class="buttonStyle" type="reset">&nbsp;&nbsp;';
    if (isAddressBook != true)
        sHTML += '<input value="back" id="btnIEBack" title="back" class="buttonStyle" type="button">&nbsp;&nbsp;';
    sHTML +='</div>';
    $("#divImportEmail").html(sHTML).show();
    $("#txtIEEmail").focus();
    if (isAddressBook != true)
        $("#btnIEBack").bind("click",function(e){$("#divEmailthis").show();$("#divImportEmail").hide();$("#txtIFFromName").focus();});
    $("#btnIEReset").bind("click",function(e)
    {
        $("#txtIEEmail").val("");
        $("#optIEEmail").attr("selectedIndex","0");
        $("#txtIEPassword").val("");
        $("#optIECSVType").attr("selectedIndex","0");
        $("#filIECSVFile").val("");
        $("#txtIEEmail").focus();
    });
    
    $("#txtIEEmail").bind("keydown",function(e){defaultButton(e,"#btnIEFindFriends");});
    $("#optIEEmail").bind("keydown",function(e){defaultButton(e,"#btnIEFindFriends");});
    $("#txtIEPassword").bind("keydown",function(e){defaultButton(e,"#btnIEFindFriends");});
    
    $("#optIECSVType").bind("keydown",function(e){defaultButton(e,"#btnIECSVFiles");});
    $("#filIECSVFile").bind("keydown",function(e){defaultButton(e,"#btnIECSVFiles");});
    
    $("#btnIEFindFriends").bind("click", function(e)
    {
        $("div[id$='shrSuccessMsg']").empty().hide();
        $("div[id$='shrErrorMsg']").empty().hide();        
        if( ($.trim($("#txtIEEmail").val())=="") || ($.trim($("#txtIEPassword").val())=="") )
        {
            $("div[id$='shrErrorMsg']").html("email address & password are required").show();
            if (($.trim($("#txtIEEmail").val())=="")){$("#txtIEEmail").focus();}
            else if (($.trim($("#txtIEPassword").val())=="")){$("#txtIEPassword").focus();}
            return;
        }

        $("#btnIEFindFriends").attr("disabled", "disabled");
        $("#btnIEFindFriends").val("processing");

        $.ajax({
            type: "POST",
            url: "ImportContacts.aspx",
            data: "uid="+ encodeURIComponent($("#txtIEEmail").val()) +"&pwd="+ encodeURIComponent($("#txtIEPassword").val()) +"&ser=" + encodeURIComponent($("#optIEEmail option:selected").val()),
            dataType: 'json',
            "cache":false,
            error:function(response){$("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();$("#btnIEFindFriends").removeAttr("disabled");$("#btnIEFindFriends").val("find friends");},
            success: function(response)
            {
                  if(response["status"]["code"]=="1")
                  {
                     pImportContacts(response["contacts"],isAddressBook);
                  }
                  else if(response["status"]["code"]=="0")
                  {
                    $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
                  } 
                  $("#btnIEFindFriends").removeAttr("disabled");
                  $("#btnIEFindFriends").val("find friends");
            }
        });
    });
    
    
    $("#btnIECSVFiles").bind("click", function(e)
    {
        $("div[id$='shrSuccessMsg']").empty().hide();
        $("div[id$='shrErrorMsg']").empty().hide();        
        if($("#filIECSVFile").val()=="")
        {
            $("div[id$='shrErrorMsg']").html("contact file is required").show();
            if (($.trim($("#filIECSVFile").val())=="")){$("#filIECSVFile").focus();}
            return;
        }

        $("#btnIECSVFiles").attr("disabled", "disabled");
        $("#btnIECSVFiles").val("processing");

		$.ajaxFileUpload({
				url:'ImportContactsFromFile.aspx?typ='+ $("#optIECSVType option:selected").val(),
				secureuri:false,
				fileElementId:'filIECSVFile',
				dataType: 'text',
				error:function (data, status, e)
				{
				    var response;
					response=$.parseJSON($(data).text());
				    $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
				    $("#btnIECSVFiles").removeAttr("disabled");
				    $("#btnIECSVFiles").val("find friends");
				},
				success: function (data, status)
				{
                      var response;
					  response=$.parseJSON($(data).text());
			          if(response["status"]["code"]=="1")
                      {
                         pImportContacts(response["contacts"],isAddressBook);
                      }
                      else if(response["status"]["code"]=="0")
                      {
                        $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
                      } 
                      $("#btnIECSVFiles").removeAttr("disabled");
                      $("#btnIECSVFiles").val("find friends");
				}
			});
    });
    return false;
}

function pImportContacts(sData,isAddressBook )
{
    var sHTML="";
    var sbtnCaption="";
    var iCount=sData.length;
    $("div[id$='shrSuccessMsg']").empty().hide();
    $("div[id$='shrErrorMsg']").empty().hide();
    
    $("#divEmailthis").hide();
    $("#divImportEmail").hide()
    $("#divImportContacts").empty();
    if (isAddressBook !=true)
        sbtnCaption ="invite friends"
    else
        sbtnCaption ="import contacts"
    
    sHTML += '<div class="importcontacts" style="font-size:12px;">';
    sHTML += '<div style="padding:5px 0px 5px 0px"><input value="' + sbtnCaption + '" id="btnICInviteFriends" title="' + sbtnCaption + '" class="buttonStyle" type="button">&nbsp;&nbsp;';
    sHTML += '<input value="back" id="btnICBack" title="back" class="buttonStyle" type="button">&nbsp;&nbsp;<span class="ictotal">Total contacts : ' + iCount +'</span></div>';
    sHTML +='<div id="divICHeader" class="icheadertop" ><span style="display:inline-block;width:50px;"><input id="chkICHeader" type="checkbox"/></span><span style="display:inline-block;width:240px"><b>name</b></span><span style="display:inline-block;width:280px"><b>email address</b></span></div>';
    sHTML +='<div id="divICData">';
    $(sData).each(function(index,conItem)
    { 
        sHTML +='<div id="divIC' + index + '" class="icitem" ><span style="display:inline-block;width:50px;"><input id="chkIC' + index +  '" type="checkbox"/></span><span id="divICName' + index +'" style="display:inline-block;width:240px">' + conItem["name"] +'</span><span id="divICEmail' + index +'"style="display:inline-block;width:280px">' + conItem["email"] +'</span></div>';

    });
    sHTML +='</div>';
    sHTML +='<div id="divICHeader1" class="icheaderbottom"><span style="display:inline-block;width:50px;"><input id="chkICHeader1" type="checkbox"/></span><span style="display:inline-block;width:240px"><b>name</b></span><span style="display:inline-block;width:280px"><b>email address</b></span></div>';
    sHTML += '<div style="padding:5px 0px 5px 0px"><input value="' + sbtnCaption + '" id="btnICInviteFriends1" title="' + sbtnCaption + '" class="buttonStyle" type="button">&nbsp;&nbsp;';
    sHTML += '<input value="back" id="btnICBack1" title="back" class="buttonStyle" type="button">&nbsp;&nbsp;Total contacts : ' + iCount +'</div>';
    sHTML += '</div>';
    $("#divImportContacts").html(sHTML).show();
    $("#chkICHeader").focus();
    var sICDetails="";
    var iIndex=0;
    var sName="";
    $("input[id^='chkICHeader']").bind("click",function(){ $("#divImportContacts input[type='checkbox']").attr('checked', $(this).is(':checked'));});
    if (isAddressBook !=true)
        $("input[id^='btnICBack']").bind("click",function(e){$("#divEmailthis").show();$("#divImportContacts").hide();$("#txtIFFromName").focus();});
    else
        $("input[id^='btnICBack']").bind("click",function(e){$("#divImportEmail").show();$("#divImportContacts").hide();$("#txtIEEmail").focus();});
    if (isAddressBook !=true)
    {
        $("input[id^='btnICInviteFriends']").bind("click",function(e)
        {
            $("#divICData input:checked").each(function()
            {
            iIndex= $(this).attr("id").replace("chkIC","");
            sICDetails += $("#divICName"+iIndex).text() + "<" + $("#divICEmail"+iIndex).text() + ">,";
            });

            $("#txtIFToEmail").val(sICDetails);
            $("#divEmailthis").show();
            $("#divImportContacts").hide();
        });
    }
    else
    {
        $("input[id^='btnICInviteFriends']").bind("click",function(e)
        {
            sICDetails=""
            $("#divICData input:checked").each(function()
            {
                iIndex= $(this).attr("id").replace("chkIC","");
                sICDetails += $("#divICName"+iIndex).text() + "<" + $("#divICEmail"+iIndex).text() + ">,";
            });

            $("input[id^='btnICInviteFriends']").attr("disabled", "disabled");
            $("input[id^='btnICInviteFriends']").val("processing");
        
            $.ajax({
            type: "POST",
            url: "ImportContactsToAddressBook.aspx",
            data: "contacts=" + encodeURIComponent(sICDetails),
            dataType: 'json',
            "cache":false,
            error:function(response){$("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();$("input[id^='btnICInviteFriends']").removeAttr("disabled");$("input[id^='btnICInviteFriends']").val(sbtnCaption);},
            success: function(response)
            {
                  if(response["status"]["code"]=="1")
                  {
                     $("div[id$='shrSuccessMsg']").html(response["status"]["msg"]).show();
                     loadAddressBook("ALL",false);
                  }
                  else if(response["status"]["code"]=="0")
                  {
                    $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
                  } 
                  $("input[id^='btnICInviteFriends']").removeAttr("disabled");
                  $("input[id^='btnICInviteFriends']").val(sbtnCaption);
            }
            });

        });
    }
}
function pShare(sData, sShareHTML)//share
{
    var sShrHTML='<div class="ShareTitle">share this canvas</div><div style="margin:0px 0px 0px 10px;">';
    var iCount=0;
    $(sData).each(function(index,shrItem)
    { 
       if ($.trim(shrItem["url"])=="")
       {
        sShrHTML += '<a class="sharethisIcon"  id="shrIcon' + shrItem["text"].replace(" ", "") + '"  title="' + shrItem["text"]+'"><img src="_shared/images/sharethis/' + shrItem["img"] + '" alt="' + shrItem["text"] + '">&nbsp;' + shrItem["text"] + '</a>';
       }
       else
       {
        sShrHTML += '<a class="sharethisIcon" href="' + shrItem["url"] +  '" id="shrIcon' + shrItem["text"].replace(" ", "") + '" target="_blank" title="' + shrItem["text"]+'"><img src="_shared/images/sharethis/' + shrItem["img"] + '" alt="' + shrItem["text"] + '">&nbsp;' + shrItem["text"] + '</a>';
       }
       iCount++;
       if (iCount==4)
       {
        sShrHTML +='<br/>';
        iCount=0;
       }
    });
    sShrHTML +='</div>';
    $("#divShareIcon").html(sShrHTML).show();
    
    //$("a#shrIconMySpace").bind("click",function(e){postShare('myspace',sShareHTML)});
    $("a#shrIconFriendSter").bind("click",function(e){postShare('friendster', sShareHTML)});
    $("a#shrIconhi5").bind("click",function(e){postShare('hi5',sShareHTML)});
    
}

function postShare(pType, sShareHTML)//share myspace,hi5,friendster
{
    var sHTML="";
    $("div[id$='shrSuccessMsg']").empty().hide();
    $("div[id$='shrErrorMsg']").empty().hide();
    $("#divShareIcon").hide()
    $("#divSSNetwork").empty();
    sHTML += '<div class="ShareTitle">share this canvas to&nbsp;' + pType;
    sHTML += '<input value="' + pType + '"  id="hdnShareType" type="hidden"></div>';
    sHTML += '<div class="formGap">email address<br>';
    sHTML += '<input maxlength="200" id="txtSSEmail" class="inputTextBox" style="width: 500px;" type="text"><span class="Required">&nbsp;*</span></div>';
    sHTML += '<div class="formGap">password<br>';
    sHTML += '<input maxlength="200" id="txtSSPassword" class="inputTextBox" style="width: 500px;" type="password"><span class="Required">&nbsp;*</span><br>';
    sHTML += 'we won\'t store your email  login information</div>';
    sHTML += '<div class="formGap">section<br>';
    sHTML += '<select id="optSSSection">';
    
    if (pType=='myspace')
    {
        sHTML += '<option value="blog">Blog</option>';
	    sHTML += '<option value="bulletin">Bulletin</option>';
	    sHTML += '<option value="aboutme">About Me</option>';
	    sHTML += '<option value="liketomeet">Like to Meet</option>';
		sHTML += '<option value="interests">Interests</option>';
		sHTML += '<option value="music">Music</option>';
		sHTML += '<option value="movies">Movies</option>';
		sHTML += '<option value="tv">Tv</option>';
		sHTML += '<option value="heroes">Heroes</option>';
		sHTML += '<option value="books">Books</option>';
    }
    else if (pType=='hi5')
    {
	    sHTML += '<option value="aboutme">About Me</option>';
		sHTML += '<option value="iliketomeet">Want to Meet</option>';
		sHTML += '<option value="Interests">Interests</option>';
		sHTML += '<option value="allTimeFavoriteArtists">All Time Favourite Artists</option>';
		sHTML += '<option value="favoriteSongs">Favourite Songs</option>';
		sHTML += '<option value="favoriteAlbums">Favourite Albums</option>';
		sHTML += '<option value="favoriteMusicVideos">Favourite Music Videos</option>';
		sHTML += '<option value="currentFavoriteArtists">Current Favourite Artists</option>';
		sHTML += '<option value="favoriteVideoGames">Favourite Video Games</option>';
		sHTML += '<option value="tv">Tv</option>';
		sHTML += '<option value="movies">Movies</option>';
		sHTML += '<option value="quote">Quote</option>';
	}
	else if (pType=='friendster')
	{
        sHTML += '<option value="aboutme">About Me</option>';
		sHTML += '<option value="wanttomeet">Want to Meet</option>';
    }
    sHTML += '</select></div>';
    sHTML += '<div class="formGap">subject<br>';
    sHTML += '<input maxlength="500" id="txtSSSubject" class="inputTextBox" style="width: 500px;" type="text"></div>';
    sHTML += '<div class="formGap"><div id="divSSCanvasDetails" class="inputTextBox" style="width: 500px; height: 125px;">' + sShareHTML + '</div></div>';
    sHTML += '<div class="formGap"><input value="share" id="btnSSShare" title="share" class="buttonStyle" type="button">&nbsp;&nbsp;';
    sHTML += '<input value="Reset" id="btnSSReset" title="reset" class="buttonStyle" type="reset">&nbsp;&nbsp;';
    sHTML += '<input value="back" id="btnSSBack" title="back" class="buttonStyle" type="button">&nbsp;&nbsp;</div>';
    $("#divSSNetwork").html(sHTML).show();
    $("#txtSSEmail").focus();
    
    $("#txtSSEmail").bind("keydown",function(e){defaultButton(e,"#btnSSShare");});
    $("#txtSSPassword").bind("keydown",function(e){defaultButton(e,"#btnSSShare");});
    $("#txtSSSubject").bind("keydown",function(e){defaultButton(e,"#btnSSShare");});
    $("#optSSSection").bind("keydown",function(e){defaultButton(e,"#btnSSShare");});
    
    $("#btnSSBack").bind("click",function(e){$("#divShareIcon").show();$("#divSSNetwork").hide();});
    $("#btnSSReset").bind("click",function(e)
    {
        $("#txtSSEmail").val("");
        $("#txtSSPassword").val("");
        $("#optSSSection").attr("selectedIndex","0");
        $("#txtSSSubject").val("");
        $("#txtSSEmail").focus();
    });
    
    $("#btnSSShare").bind("click", function(e)
    {
        $("div[id$='shrSuccessMsg']").empty().hide();
        $("div[id$='shrErrorMsg']").empty().hide();        
        if( ($.trim($("#txtSSEmail").val())=="") ||    ($.trim($("#txtSSPassword").val())=="") )
        {
            $("div[id$='shrErrorMsg']").html("fields marked as (*) are required").show();
            if (($.trim($("#txtSSEmail").val())=="")){$("#txtSSEmail").focus();}
            else if (($.trim($("#txtSSPassword").val())=="")){$("#txtSSPassword").focus();}
            return;
        }
        else if (!valid_email($.trim($("#txtSSEmail").val())))
        {
            $("div[id$='shrErrorMsg']").html("invalid email address").show();
            $("#txtSSEmail").focus();
            return;
        }

        $("#btnSSShare").attr("disabled", "disabled");
        $("#btnSSShare").val("processing");

        $.ajax({
            type: "POST",
            url: "SaveShareThisData.aspx",
            data: "typ=" + encodeURIComponent($("#hdnShareType").val()) +"&email="+ encodeURIComponent($("#txtSSEmail").val()) +"&pwd="+ encodeURIComponent($("#txtSSPassword").val()) +"&section="+ encodeURIComponent($("#optSSSection option:selected").val()) +"&subject=" + encodeURIComponent($("#txtSSSubject").val()) +"&ZXVC="+encodeURIComponent($("#hdnIDs").val()),
            dataType: 'json',
            "cache":false,
            error:function(response){$("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();$("#btnSSShare").removeAttr("disabled");$("#btnSSShare").val("share");},
            success: function(response)
            {
                  if(response["status"]["code"]=="1")
                  {
                     $("div[id$='shrSuccessMsg']").html(response["status"]["msg"]).show();
                  }
                  else if(response["status"]["code"]=="0")
                  {
                    $("div[id$='shrErrorMsg']").html(response["status"]["msg"]).show();
                  } 
                  $("#btnSSShare").removeAttr("disabled");
                  $("#btnSSShare").val("share");
            }
        });
    });
}


