
$.fn.recommend=function(e){var link=$(this).attr("link");var tytul=$(this).attr("tytul");$(this).html('<div name="send_rec" id="send_rec" style="display: none; position: fixed; left: 200px; top: 100px; width:0px; height: 0px; background-color:#f5f5ef; border: 1px solid #000; z-index: 50;">'+'<div id="top_bar" class="WindowTitle" style="cursor: move; float: left; width: 100%;">'+'<div style="font-size: 14px; font-family: arial; float: left; font-weight: bold; color: #000; margin: 3px 0px 0px 3px;">'+'Poleć znajomemu'+'</div>'+'<div id="close" class="close" style="cursor: pointer; float: right; margin: 3px 3px 0px 0px;">'+'<img src="css/images/window_close.png">'+'</div>'+'</div>'+'<div id="message" style="float: left; width: 100%; height: 20px;">'+'</div>'+'<form name="send_rec_form" id="send_rec_form" method="post">'+'<div id="wrapper" style="width: 100%; height: 100%; padding: 10px 10px 10px 10px;">'+'<div id="rec_link" style="float: left; width: 100%;">'+'<div style="float: left; width: 100%; font-weight: bold; margin-top: 20px;">'+'Polecany artykuł:'+'</div> '+'<div style="margin-bottom: 10px; font-weight: bold; font-size: 12px;" id="span_rec_link">'+tytul+'</div>'+'</div>'+'<div style="float: left; width: 100%; margin-bottom: 5px;">'+'<div style="float: left; width: 40%; font-weight: bold;">'+'Od: '+'</div>'+'<div id="from" style="float: left; width: 60%;">'+'<input id="from_input" type="text" value="">'+'</div>'+'</div>'+'<div style="float: left; width: 100%; margin-bottom: 25px;">'+'<div style="float: left; width: 40%; font-weight: bold;">'+'Adres nadawcy: '+'</div>'+'<div id="from_mail" style="float: left; width: 40%; height: 22px;">'+'<input id="from_mail_input" name="from_mail_input" type="text">'+'</div>'+'</div>'+'<div style="float: left; width: 100%; margin-bottom: 5px;">'+'<div style="float: left; width: 40%; font-weight: bold;">'+'Do: '+'</div>'+'<div style="float: left; width: 60%;">'+'<input id="to_input" type="text" value="">'+'</div>'+'</div>'+'<div style="float: left; width: 100%; margin-bottom: 25px;">'+'<div style="float: left; width: 40%; font-weight: bold;">'+'Adres odbiorcy: '+'</div>'+'<div id="to_mail" style="float: left; width: 60%; height: 22px;">'+'<input id="to_mail_input" name="to_mail_input" type="text" value="">'+'</div>'+'</div>'+'<div style="float: left; width: 100%; margin-bottom: 25px;">'+'<div style="float: left; width: 40%; font-weight: bold;">'+'Komentarz: '+'</div>'+'<div id="comment_text" style="float: left; width: 60%;">'+'<textarea id="comment_textarea" style="height: 100px;"></textarea>'+'</div>'+'</div>'+'<div id="send_button" style="float: left; width: 100%; padding: 0px 0px 0px 200px;">'+'<input type="submit" value="Wyślij">'+'</div>'+'<input id="link_input" type="hidden" value="http://www.serwiskariery.pl'+link+'">'+'</div>'+'</form>'+'</div>');return this.each(function(){$("#recommend").click(function(e){var width=400;var height=450;var left=e.pageX;var top=e.pageY;var showX;var showY;var tempX=left+width;var tempY=top+height;if(tempX>=$(window).width()){showX=left-width-$(window).scrollLeft();}else{showX=left-$(window).scrollLeft();}
if(tempY>=$(window).height()){showY=top-height/2-$(window).scrollTop();}else{showY=top-$(window).scrollTop();}
$("#send_rec").css("top",showY).css("left",showX);$("#send_rec").children("div#sent_container").hide();$("#send_rec").children("div#select_container").show();$("#send_rec").animate({width:"400",height:"450px",opacity:"0.9"},500)});$('#close').click(function(){$("#send_rec").animate({width:"0px",height:"0px",opacity:"0.3"},500,function(){$("#send_rec").hide(function(){$("#message").html('');});});});$("#send_rec_form").validate({rules:{from_mail_input:{required:true,email:true},to_mail_input:{required:true,email:true}},messages:{from_mail_input:{required:"Podaj adres nadawcy",email:"Podaj poprawny e-mail"},to_mail_input:{required:"Podaj adres odbiorcy",email:"Podaj poprawny e-mail"}},submitHandler:function(form){var data=getFormData();$("#message").html('<center><img src="graph/Layout/icons/LayoutPreloader.gif" title="Ładuję" alt="Ładuję" style="border-style: none; margin-top: 10px;" /></center>');$.post("modules/rec/rec.php",data,function(response){$("#message").html(response);$("#from_input").val('');$("#from_mail_input").val('');$("#to_input").val('');$("#to_mail_input").val('');$("#comment_textarea").val('');});return false;}});});function getFormData()
{var from=$("#from_input").val();var from_mail=$("#from_mail_input").val();var to=$("#to_input").val();var to_mail=$("#to_mail_input").val();var comment=$("#comment_textarea").val();var link_input=$("#link_input").val();var rec_action=1;var obj={from_name:from,from_adres:from_mail,to_name:to,to_adres:to_mail,com:comment,link:link_input,rekomendacja:rec_action}
return obj;};};