//Receive Socket Msg from UserAccount.asp
function ReceiveAndShowMsg(msg)
{
	try
	{
	    var RemindMsgTitle="";
	    var RemindMsgMainContent="";
	    var ViewProfileButtonHtml="";
	
	    var RemindMsgSender="";
	    var RemindMsgSenderUsername="";
	    var RemindMsgAlertType="";
	    
        var x1=0;
        var x1string=",Sender=";
        var x2=0;
        var x2string=",SenderUsername=";


        x1=msg.indexOf(x1string,x2);
        x2=msg.indexOf(x2string,x1);
        if(x1>=0&&x2>=0)
        {
            RemindMsgSender=msg.substring(x1+x1string.length,x2);
        }
        
        x1string=",SenderUsername=";
        x1=msg.indexOf(x1string,x2);
        x2string=",Receiver=";
        x2=msg.indexOf(x2string,x1);
        if(x1>=0&&x2>=0)
        {
            RemindMsgSenderUsername=msg.substring(x1+x1string.length,x2);
        }
        
        x1string=",AlertType=";
        x1=msg.indexOf(x1string,x2);
        x2string=":end";
        x2=msg.indexOf(x2string,x1);
        if(x1>=0&&x2>=0)
        {
            RemindMsgAlertType=msg.substring(x1+x1string.length,x2);
        }
        
        
        if(RemindMsgAlertType=="ViewProfile")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" is viewing your profile";
	        RemindMsgMainContent="This message just remind you that <b>"+RemindMsgSenderUsername+"</b> is viewing your profile now. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="Email")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" sent you an Email";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> sent you an Email just now. You can <a href='inbox.asp?RemindMsg=1"+RemindMsgLoginGUIDQueryString+"'>click here</a> to check the email. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="Wink")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" sent you a Wink";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> sent you a Wink just now. You can <a href='inbox.asp?RemindMsg=1"+RemindMsgLoginGUIDQueryString+"'>click here</a> to check the wink. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="Favorite")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" is interested in you!";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> is interested in you. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="ReplyWink")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" replied your wink";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> replied your wink just now. You can <a href='inbox.asp?RemindMsg=1"+RemindMsgLoginGUIDQueryString+"'>click here</a> to check the wink. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="Rate")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" rated your profile";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> rated your profile just now. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="askphoto")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" would like to see your photo!";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> asked you to post a photo just now. Would you like to show your photo? <a href='myphoto.asp?RemindMsg=1"+RemindMsgLoginGUIDQueryString+"'>Click here</a> to upload your photo now! "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="askdescribe")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" would like to know more about you!";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> would like to know more about you. Would you like to write more details about yourself and your match? <a href='my_profile.asp?RemindMsg=1"+RemindMsgLoginGUIDQueryString+"'>Click here</a> to describe yourself and your match now! "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="ReadEmail")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" is reading your email";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> is reading your email. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
        else if(RemindMsgAlertType=="ReadWink")
        {
	        RemindMsgTitle=RemindMsgSenderUsername+" is reading your wink";
	        RemindMsgMainContent="This message remind you that <b>"+RemindMsgSenderUsername+"</b> is reading your wink. "+RemindMsgSenderUsername+" is online! It's a good chance to chat with "+RemindMsgSenderUsername+" now!";
        }
	    
	    ViewProfileButtonHtml="<div style='margin-top:15px; text-align:center;'><a href='user_details.asp?profile_id="+RemindMsgSender+RemindMsgLoginGUIDQueryString+"'><img border='0' src='image/RemindMsg_viewprofile.gif' /></a>&nbsp;&nbsp;&nbsp;<a href='javascript:ClosePopup()'><img border='0' src='image/RemindMsg_close.gif' /></a></div>";
	    RemindMsgMainContent=RemindMsgMainContent+ViewProfileButtonHtml;
	    var ShowRemindMsg="<table border='0' cellspacing='0' cellpadding='0' width='96%'><tr><td class='BigText' colspan='2' align='center' height='35'>"+RemindMsgTitle+"</td></tr><tr><td width='180'><table border='0' cellspacing='0' cellpadding='0' width='170'><tr><td><div id='SenderMainPhoto' style='display:block;position:relative;background-color:#FFFFFF;margin:0px;padding:5px;border:1px solid #E4E3E3;z-index:0;overflow:hidden;width:auto;text-align:center;'><img src='image/loader_small.gif' border='0'> Loading photo now....</div></td></tr></table></td><td>"+RemindMsgMainContent+"</td></tr></table>";
		var PlaySoundMsg="<div id='PlaySoundDiv'><embed src='voice/WebNewMsg.wav' autostart='true' loop='false' width='0' height='0' /></div>";
		//ShowRemindMsg+=PlaySoundMsg;
		DoPopup("alert",ShowRemindMsg);
		window.parent.EndSendMsgtoClient();
		
		//=====================================
		//Loading RemindMsgSender's photo(Begin)
        //make the ajax call  
        var req = new Request
        ({  
            method: 'post',  
            url: "../XML_Get_Photo.asp?profile_id="+RemindMsgSender+"&Version="+Math.random(),  
            data: { },  
            headers: { 'If-Modified-Since':'0' },  
            onRequest: function() 
            {},  
            onSuccess: function(txt)
            {
    		    UpdateDivContent($("SenderMainPhoto"),txt);
            },
            onFailure: function()
            {
    		    UpdateDivContent($("SenderMainPhoto"),"Sorry, Photo Load Failed");
            }
        });
                 
        req.send();
		//Loading RemindMsgSender's photo(End)
		//=====================================
	}
	catch(e)
	{
	    alert(e.description);
	}
}

//Send msg to UserAccount.asp
function SendMsgtoServer(Receiver,msg)
{
	try
	{
		window.parent.SendMsgtoServer(Receiver,msg);
	}
	catch(e)
	{
	}
}