﻿// JScript File

$(document).ready(function()
    {
    $("#msg").hide();
    
    $(".msgOn").hover(
    function(){
        //var cssa=$("#TextBox1").top();
     
        var id=$(this).attr("id");
        
        if(id=="profileid_textbox")
        {
        var offset=$("#profileid_textbox").offset();
        setMsg(offset.top-60,offset.left + 147,"Enter Profile Id");
        }
         if(id=="email_textbox")
        {
        var offset=$("#email_textbox").offset();
        setMsg(offset.top-60,offset.left + 147,"Enter Email");
        }
         if(id=="confirmEmail_textbox")
        {
          var offset=$("#confirmEmail_textbox").offset();
        setMsg(offset.top-60,offset.left + 147,"Enter confirm Email");
        }
         if(id=="password_textbox")
        {
         var offset=$("#password_textbox").offset();
        setMsg(offset.top-60,offset.left + 147,"Enter password");
        }
        if(id=="confirmpassword_textbox")
        {
         var offset=$("#confirmpassword_textbox").offset();
        setMsg(offset.top-60,offset.left + 147,"Enter confirm password");
        }
        if(id=="malefemale_radio")
        {
         var offset=$("#malefemale_radio").offset();
        setMsg(offset.top-60,offset.left + 147,"Select M/F");
        }
       
        
        if(id=="region_ddl")
        {
         var offset=$("#region_ddl").offset();
        setMsg(offset.top-55,offset.left + 179,"Select region");
        }
        if(id=="country_ddl")
        {
         var offset=$("#country_ddl").offset();
        setMsg(offset.top-47,offset.left + 160,"Select country");
        }
        
    },
    function(){
        $("#msg").hide();
    });

});
function setMsg(top,left,msg)
{

            $("#msg").css("top",top);
            $("#msg").css("left",left);
            $("#d1").html( msg);
            $("#msg").show();
}

//-----------------------Section (Registration1)-----------------------------------

function enableSubmit()/* if user have checked the terms and condition */
{
 
    var chk = document.getElementById("afirm_checkbox").checked;
    
  
    if(chk)
    {
       
       // alert(document.getElementById("afirm_checkbox").name);
         return true;
    }
    else
    {
        alert("Please confirm if you heve read and agree to Privacy Policy and Terms And Condition !");
        return false;
    }
     
}

//------------- checks if any value is selected in a dropdownlist ----------------------

function checkSelect()
{  
    
    var checkSelect=document.getElementsByTagName("select");/* returns array */
    var count=checkSelect.length;
    
      while(count>0)
      {
           
            
            if(document.getElementById(checkSelect[count-1].id).value == "")
            {
                var controlName=document.getElementById(checkSelect[count-1].id).name;
                controlName=controlName.replace("_ddl","");
                alert("Plese select " + controlName);
                return false;
            }
            
           count=count-1;
      }
       
}

//------------------------To check Brother/sister marry-----------------------------

 function effectSecound(fcombo,scombo)
        {
            var firstValue = document.getElementById(fcombo).value ;
            //alert(firstValue);
             if(firstValue=='0')
             {
                document.getElementById(scombo).disabled=true;
                document.getElementById(scombo).value="0";
             }
             else
             {
                document.getElementById(scombo).disabled=false;
             }
        }
//--------------------------------------------------------------------------------

$(window).load(
		function()
		{document.getElementById("interaction_tbl").innerHTML='<tr>'+
                                 '<td>'+
                                      '<table id="t1" align="right" border="0" cellpadding="0" cellspacing="0" width="130">'+
                                          '<tr>'+
                                              '<td align="left" valign="top" width="7">'+
                                                  '<img height="29" src="images/crv.gif" width="7" /></td>'+
                       '<td align="left"valign="middle" style="background: url(images/cap_bg.gif) repeat-x"><a href="#" class="login_txt03">Express&gt;&gt;</a></td>'+
                                         ' </tr></table></td>'+
                                  '<td bgcolor="#ffffff" rowspan="5" style="width: 179px">'+
                                      '<table align="left" border="0" cellpadding="0" cellspacing="0" width="215">'+
                                         ' <tr> <td align="left" valign="top" width="10"><img src="images/left_top_curv.png" width="15" height="20" /></td>'+
                                              '<td align="left" style="background: url(images/top_bg.gif) repeat-x" valign="top">&nbsp;</td>'+
                                              '<td align="right" valign="top" width="10"><img src="images/right_top_curv.png" width="15" height="20" /></td>'+
                                         ' </tr>        <tr>'+
                                              '<td align="left" style="background:url(images/left_bckgrnd.png) repeat-y" valign="top">&nbsp;'+
                                                 ' </td>'+
                                             ' <td align="left" style="background:url(images/bckgrnd.png) repeat-x" valign="top">'+
                                                '  <table border="0" cellpadding="0" cellspacing="0" width="100%">'+
                                                    '  <tr>'+
                                                         ' <td id="exp_td">'+
                                                              '  <div class="prnsl_sbhd_txt" id="exp">Express Interest-'+
                                                              '  <br />'+
                                                               '  <br />'+
                                                               ' <img id="exp_btn" src="images/btn_express.png" onclick="getContact(1)" />'+
                                                              '  </div>'+
                                                               ' <div class="prnsl_sbhd_txt" id="con">Contact-<br/> <br /><img id="cnt_btn" src="images/btn_contact.png" '+								'onclick="getContact(2)" />'+
                                                               ' </div>'+
                                                               ' <div class="prnsl_sbhd_txt" id="wri">Write To him/her-<br/> <br /><img id="exp_btn" 	'+							'src="images/btn_wrte_mssg.png" onclick="getContact(3)" />'+
                                                             '   </div>'+
                                                    ' <div class="prnsl_sbhd_txt" id="cht">Chat with him/her-<br /> <br /><img id="exp_btn" src="images/btn_chat.png"'+								'onclick="popUp('+"'http://www.123lifepartner.com/phpmychat/'"+')" />'+
                                                               ' </div>'+
                                                          '</td>'+
                                                     ' </tr>'+
                                                     ' <tr>'+
                                                        '  <td align="center" style="padding-bottom:7px" id="loading_img" ><div><br />'+
                                                      '  <img id="loading_img_gif"  src="images/ajax-loader.gif" /><br /><br /></div></td>'+
                                                   ' </tr>'+
                                                     ' <tr>'+
                                                         ' <td>&nbsp;'+
                                                              '</td>'+
                                                      '</tr>'+
                                                 ' </table>'+
                                              '</td>'+
                                             ' <td align="left" style="background:url(images/right_bckgrnd.png) repeat-y" valign="top">&nbsp;'+
                                                  '</td>'+
                                         ' </tr>'+
                                         ' <tr>'+
                                             ' <td align="left" valign="top"><img src="images/left_bottom_curv.png" width="15" height="20" /></td>'+
                                             ' <td align="left" style="background:url(images/bottom_bckgrnd.png) repeat-x" valign="top">&nbsp;'+
                                              '  </td>'+
                                            '  <td align="left" valign="top"><img src="images/rightt_bottom_curv.png" width="15" height="20" /></td>'+
                                         ' </tr>'+
                                     ' </table>'+
                                  '</td>'+
                              '</tr>'+
                              '<tr>'+
                                  '<td>'+
                                     ' <table id="t2" align="right" border="0" cellpadding="0" cellspacing="0" width="130">'+
                                         ' <tr>'+
                                             ' <td align="left" valign="top" width="7">'+
                                                 ' <img height="29" src="images/crv.gif" width="7" /></td>'+
                                           '   <td align="left" style="background: url(images/cap_bg.gif) repeat-x" valign="middle">'+
                                                '  <a  href="#" class=" login_txt03">Contact &gt;&gt;</a></td>'+
                                         ' </tr>'+
                                     ' </table>'+
                                  '</td>'+
                             ' </tr>'+
                             ' <tr>'+
                                 ' <td>'+
                                     ' <table id="t3" align="right" border="0" cellpadding="0" cellspacing="0" width="130">'+
                                          '<tr>'+
                                             ' <td align="left" valign="top" width="7">'+
                                                  '<img height="29" src="images/crv.gif" width="7" /></td>'+
                                              '<td align="left" style="background: url(images/cap_bg.gif) repeat-x" valign="middle">'+
                                                  '<a class="login_txt03" href="#">Write to him/her &gt;&gt;</a></td>'+
                                         ' </tr>'+
                                     ' </table>'+
                                 ' </td>'+
                             ' </tr>'+
                             ' <tr>'+
                                 ' <td>'+
                                     ' <table id="t4" align="right" border="0" cellpadding="0" cellspacing="0" width="130">'+
                                         ' <tr>'+
                                             ' <td align="left" valign="top" width="7">'+
                                                '  <img height="29" src="images/crv.gif" width="7" /></td>'+
                                            '  <td align="left" style="background: url(images/cap_bg.gif) repeat-x" valign="middle">'+
                                                  '<a class="login_txt03" href="#">Make a chat &gt;&gt;</a></td>'+
                                         ' </tr>'+
                                     ' </table>'+
                                 ' </td>'+
                             ' </tr>'+
                             ' <tr>'+
                                 ' <td height="2">'+
                                  '</td>'+
                              '</tr>';
    
			$("#pop_contact").hide();
			$("#pop_email").hide();
			//$("#exp").hide();
			$("#loading_img").hide();
			$("#con").hide();
			$("#wri").hide();
			$("#cht").hide();
			$("#t1").click(function()
			{
			    $("#pop_contact").hide();
				$("#exp").show();
				$("#con").hide();
				$("#wri").hide();
				$("#cht").hide();
				$("#loading_img").hide();
			});
			$("#t2").click(function()
			{
				$("#exp").hide();
				$("#con").show();
				$("#wri").hide();
				$("#cht").hide();
				$("#loading_img").hide();
			    $("#pop_contact").hide();
			});
			$("#t3").click(function()
			{
				$("#exp").hide();
				$("#con").hide();
				$("#wri").show();
				$("#cht").hide();
				$("#loading_img").hide();
			    $("#pop_contact").hide();
			});
			$("#t4").click(function(){
				$("#exp").hide();
				$("#con").hide();
				$("#wri").hide();
				$("#cht").show();
				$("#loading_img").hide();
				$("#pop_contact").hide();
			});
		}
		
	);
	function showloading()
	{           $("#exp").hide();
				$("#con").hide();
				$("#wri").hide();
				$("#cht").hide();
	    $("#loading_img").show();
	}
//	AjaxPro.onLoading = function(b) {
//    c++;
//    window.status = c;
//    var l = document.getElementById("loading_img");
//    l.style.visibility = b ? "visible" : "hidden";
//}
	function getContact(request)
	{
	   //alert("response.value");
	   $("#pop_contact").hide();
	   ajaxHelper.partnerInteraction(request,getContact_callBack) ;
	}
	function getContact_callBack(response)
	{
	    if(response.value=="login.aspx")
	    {
	    window.location=response.value;
	    }
	    else
	    {
	    document.getElementById("pop_contact").innerHTML="";
	    document.getElementById("pop_contact").innerHTML=response.value;
	    
	    var offset=$("#exp_td").offset();
	   $("#pop_contact").css("top",offset.top);
       $("#pop_contact").css("left",offset.left);
	   
	   $("#pop_contact").show();
	   }
	    //alert(response.value);
	}
    function sendMail()
    {   
         var mailBody=document.getElementById("txt_2").value;
         var mailTo=document.getElementById("mailTD").innerHTML; 
         ajaxHelper.sendMailtoPartner(mailTo,mailBody,sendMail_callBack); 
    }
    function sendMail_callBack(response)
    {
          if(response.value==1)
          {
             document.getElementById("pop_contact").innerHTML="";
	         document.getElementById("pop_contact").innerHTML="<b>Mail Sent"; 
          }
          else
          {
            document.getElementById("pop_contact").innerHTML="";
	         document.getElementById("pop_contact").innerHTML="<b>Unable to sent mail"; 
          }
    }
    $(document).ready(function() 
    {
        
    });
    function popUp(URL) 
    {
        day = new Date();
        id = day.getTime();
        eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=550');");
    }
    
    
    
    
    function sendMailTo(mailTo)
    {   
         var mailBody=document.getElementById("txt_2").value;
        
         ajaxHelper.sendMailtoPartner_withId(mailTo,mailBody,sendMailTo_callBack); 
    }
    
    
     function sendMailTo_callBack(response)
    {
        $('#reply_tbl').hide();
    }
    
    
    
    
     function openCompose (user_to)
	{
	
    document.getElementById("reply_tbl").innerHTML=
'<table width="75%" height="75%" border="0" align="left" cellpadding="0" cellspacing="0">'+
 ' <tr>'+
   ' <td width="10" align="left" valign="top"><img src="images/tp_lft_crv1.gif" width="10" height="20" /></td>'+
    '<td align="left" valign="top" style="background:url(images/tp_bg1.gif) repeat-x;">&nbsp;</td>'+
    '<td width="10" align="right" valign="top"><img src="images/tp_rght_crv1.gif" width="10" height="20" /></td>'+
  '</tr>'+
  '<tr>'+
   ' <td align="left" valign="top" style="background:url(images/lft_bg1.gif) repeat-y;">&nbsp;</td>'+
   ' <td align="left" valign="top" style="background-color:#FFFFFF;"><table width="100%" height="100%">'+
 "<tr><td id='mailTD' >"+
"</td></tr>"+
"<tr><td><textarea id='txt_2' style='width:100%;height:100%;' ></textarea></td></tr>"+
"<tr><td align='right'><img id='close_btn'  src='images/btn_cancel.gif' onclick='closePop()' /><img id='email_btn'  src='images/btn_send.gif' onclick='sendMailTo("+ user_to +")' />"+
"</td></tr>"+
"</table>&nbsp;</td>"+
   ' <td align="right" valign="top" style="background:url(images/rghtt_bg1.gif) repeat-y;">&nbsp;</td>'+
  '</tr>'+
 ' <tr>'+
  '  <td align="left" valign="top"><img src="images/btm_lftt_crv1.gif" width="10" height="20" /></td>'+
   ' <td align="left" valign="top" style="background:url(images/btm_bg1.gif) repeat-x;">&nbsp;</td>'+
  '  <td align="right" valign="top"><img src="images/btm_rght_crv1.gif" width="10" height="20" /></td>'+
 ' </tr>'+
'</table>';

    var offset=$('#msg_dataList').offset();
    var IpopTop = (document.body.offsetHeight - document.getElementById("reply_tbl").offsetHeight)/2;
      var IpopLeft = (document.body.offsetWidth - document.getElementById("reply_tbl").offsetWidth)/2;
      
      var left=IpopLeft + document.body.scrollLeft;
      var top=IpopTop + document.body.scrollTop;
alert(document.body.offsetHeight);
    $('#reply_tbl').css("top", top);
    
    $('#reply_tbl').css("left",offset.left);
    $('#reply_tbl').width($('#msg_dataList').width());
    //alert(offset.width);
    $('#reply_tbl').show();
}
function closePop()
{
    $('#reply_tbl').hide();
}
function successStoryProfileIdCheck()
{
    var pid= document.getElementById("userProfile_txt").value;
    ajaxHelper.checkProfileId(pid,successStoryProfileIdCheck_callback);
}
function successStoryProfileIdCheck_callback(response)
{
    var res=response.value;
    if (res="Sorry! profile id exists.")
    {
    document.getElementById("lbl_you_id_exist").value="";
    }
    else
    {
    document.getElementById("lbl_you_id_exist").value="Profile Id dose not exist ";
    }
}