﻿ function ShowMessage(context)
    {   
        //#FF007Ectl00_ContentPlaceHolder1_btnSend
        document.getElementById("SendDiv").style.filter="alpha(opacity=30)";
        document.getElementById("SendDiv").style.MozOpacity="0.3";
        document.getElementById("SendDiv").style.backgroundColor="#F6F6F6";
        
        //document.getElementById("ctl00_ContentPlaceHolder1_btnSend").style.backgroundColor="#FF007E";
        
        var currentState =document.getElementById("SendDiv").style.display;
        if(currentState=="block")
        {
            document.getElementById("SendDiv").style.display="none";
        }
        
        document.getElementById("ctl00_ContentPlaceHolder3_ControlOfMessage1_lblEmail").textContent="";
        document.getElementById("ctl00_ContentPlaceHolder3_ControlOfMessage1_lblEmail").innerText="";
        document.getElementById("SendDiv").style.display="block";

         OpenNow();
       
    }
    var Nw =15;
    var Nh =10;
    var ChangeW=10;
    var ChangeH=10;
    var OverW=475;
    var OverH=100;
    
    function OpenNow()
    {
        Nw=Nw+ChangeW;Nh=Nh+ChangeH;
        if(OverW>Nw||OverH>Nh)
         {        
            if(OverW>Nw)
             {
	            document.getElementById("SendDiv").style.width=Nw+"px";
	            document.getElementById("SendDiv").style.left=(document.documentElement.clientWidth-Nw)/2+"px";
	         }
            if(OverH>Nh) 
            {
                document.getElementById("SendDiv").style.height=Nh+"px";
                //document.getElementById("SendDiv").style.top=(document.documentElement.clientHeight-Nh)/2+"px"
                document.getElementById("SendDiv").style.top=800+"px"
            }
            window.setTimeout("OpenNow()",10);
         }
	    else
	    {
	        document.getElementById("SendDiv").style.filter="alpha(opacity=100)";
	        document.getElementById("SendDiv").style.MozOpacity="1";
	        document.getElementById("TextMessage").style.display="block";
	       
	        Nw=20;
	        Nh=10;
	        ChangeH=20;
	        ChangeW=20;
	    }
	}
	
	function Close()
	{
	    document.getElementById("SendDiv").style.display="none";
	}
	
	
	
	function CheckMsg(controlName)
	{
	
	    var context = document.getElementById(controlName).value;
	    var name = document.getElementById('ctl00_ContentPlaceHolder3_ControlOfMessage1_EmailToFirend1_txtName').value;
        
        if(name=="")
        {
            document.getElementById('ctl00_ContentPlaceHolder3_ControlOfMessage1_EmailToFirend1_txtName').focus();
            return false;
        }
        
        var matchArray = context.match(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/);
         if (matchArray==null)
         {
            document.getElementById(controlName).value="";
            return false;
         }
         else
         {
            return true;
         }
	}
	

	
	
function TxtFocus(control,context)
{
    if(control.value==context)
    {
        control.value ="";
    }
}
function TxtBlur(control,context)
{
    if(control.value=="")
    {
        control.value=context;
    }
}

function SendLink(pid,url,result,friendNameControlName)
{  
    if(!result)
    {
        return;
    }
     var friendname = document.getElementById(friendNameControlName);
     if(confirm("Thank you!The link has been send to you friend"))
     {
         var email = document.getElementById("ctl00_ContentPlaceHolder3_ControlOfMessage1_EmailToFirend1_txtEmail").value;
         var friend = friendname.value;
          $.get(url,{"id":pid,"mailto":email,"friend":friend},function(data)
          {   
             $("#EmailTo").hide(500);
          }
        )
     }
 }
 
 
 	function CheckTellFriend(controlYou,controlSendTo,controlMessage)
	{

	    var You = document.getElementById(controlYou).value;
	    var Sendto = document.getElementById(controlSendTo).value;
	    var Message = document.getElementById(controlMessage).value;
        
        if(You=="")
        {
            document.getElementById(controlYou).focus();
            return false;
        }
        
        var matchArray = Sendto.match(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/);
         if (matchArray==null)
         {
            document.getElementById(controlSendTo).value="";
            document.getElementById(controlSendTo).focus();
            return false;
         }
         else
         {
            return true;
         }
	}
	
 
 function TellFriend(url,result)
{  
    if(!result)
    {
        return;
    }
     if(confirm("Are you sure want to send ?"))
     {
          $.post(url,{},function(data)
          {   
             $("#EmailTo1").hide(500);
          }
        )
     }
 }