$(document).ready(function () {
  
  $('.link_friend').click(function () {
    $("#friendWindow").html(makeFriendForm());
    $('#friendWindow').modal();
	});
 
  var url=document.URL; 
}); 
  
  
  function sendFriend(){
      $("#friend_msg").html('');

          $.ajax({
		          type: "POST",
		          data: {
                      action: 'sendToFriend',
                      url: url,
                      captcha: $("#friend_captcha").val(),
                      my_name: $("#my_name").val(),
                      my_email: $("#my_email").val(),
                      friend_name: $("#friendWindow #friend_name").val(),
                      friend_email: $("#friendWindow #friend_email").val()
                 }, 
              url: 'data.php',
		          dataType: 'json',
		          timeout: 6000,
		          global: 'false',
		          success: function(json) {
                 if (json.Result==true){
                     alert(json.Text);
                     $.modal.close();
                     $("#friendWindow #friend_name").attr("value","");
                     $("#friendWindow #friend_email").attr("value","");
                 }else{
                  $("#friend_msg").html(json.Text);
                 
                 }
             }    
          });  
 
  }
  
  
  function makeFriendForm(){

     var text='';
    
       text+='<b class="b1f default"></b><b class="b2f default"></b><b class="b3f default"></b><b class="b4f default"></b>';
            text+='<div class="ldefault  pb5">';
                text+='<div class="default pl5 pt3 pb5 bb_news bold">';
                  text+=tr_send_friend;
                text+='</div>';
                
                  text+='<div class="abstand pt2"></div>';
                  text+='<div class="invisib mt5 mb5 c_red bold" id="friend_msg"></div>';
    
                  text+='<div class="abstand pt3"></div>';
              
                  text+='<div class="inline w300 wauto" >';
                  text+='<b>'+tr_your_name+'</b><br />';
                    text+='<input type="text" value="" id="my_name" class="w260 intxt" name="user" maxlength="40" />';   
                  text+='</div>';
    
                  text+='<div class="inline w300 wauto" >';
                    text+='<b>'+tr_your_email+'</b><br />';
                    text+='<input type="text" value="" id="my_email" class="w260  intxt " name="user" maxlength="40" />';   
                  text+='</div>';
                  text+='<div class="abstand pt10"></div>';
               
                  text+='<div class="inline  wauto w300" >';
                    text+='<b>'+tr_friend_name+'</b><br />';
                    text+='<input type="text" value="" id="friend_name" class="w260   intxt" name="user" maxlength="40" />';   
                  text+='</div>';
    
                  text+='<div class="inline wauto w300" >';
                    text+='<b>'+tr_friend_email+'</b><br />';
                    text+='<input type="text" id="friend_email" value="" class="w260 intxt" name="user" maxlength="40" />';   
                  text+='</div>';
   
                
                   text+='<div class="abstand pt3 pb3"></div>';

                   text+='<div class="no_dist inline w350 ml10 mr5 mt2 right">';
                      text+='<b>'+tr_captcha_text+':</b> <br />'; 
                   text+='</div>';    

                    text+='<div class="no_dist inline w180 ml10 mr5">';
                         text+='<input type="text" value="" name="friend_captcha" id="friend_captcha" class="w80  intxt" />';
                    text+='</div>';    

                    text+='<div class="abstand"></div>';
  
                    text+='<div class="no_dist inline w100 ml10 mr5">';
                        text+='<img class="ml10" src="'+captcha+'" />';
                    text+='</div>';         
               
            
                text+='<div class="abstand pt5"></div>';
            
                text+='<div class="inline w270 inline mr10">';
                     text+='<input type="button" onClick="sendFriend();" class="w150 inbtn fright" value="'+tr_send+'" />';
                text+='</div>';
               
                 text+='<div class="inline w270 left inline">';
                     text+='<input type="button" onClick="$.modal.close();"; class="w150 inbtn" value="'+tr_close+'" />';
                text+='</div>';
               
                text+='<div class="abstand pt5"></div>';
            
           text+='</div>';
     text+='<b class="b4f ldefault"></b><b class="b3f ldefault"></b><b class="b2f ldefault"></b><b class="b1f ldefault"></b>';
 
 return text;
}

