onerror=exfoerr
var text1=""
function exfoerr(msg,url,line)
{
text1="Error: " + msg + "\n"
text1+="URL: " + url + "\n"
text1+="Line Number: " + line + "\n\n"
return true
}


$(document).ready(function() {
    //print
    var generatstyle = $('link[href="style/style.css"]');
    $("a#print").click(function() {
      $(generatstyle).attr({href : "style/print.css"});
         setTimeout(function(){window.print()}, 100);
         $("#print_dialog").show();

         $("div#print_dialog a.back").click(function() {
           $("#print_dialog").hide();
           $(generatstyle).attr({href : "style/style.css"});
            return false;
         })

         $("div#print_dialog a.cancel").click(function() {
           $("#print_dialog").hide();
           return false;
         })

      return false;

    });
    //send to friend
    $("#send_to_friend"). click(function() {
        $(this).colorbox({
        		width:"370px",
        		inline:true,
        		href:"#cboxcontent_",
        		opacity:0.6,
        		close: "",
        		transition:"none",
            open:true
        });
        $("#submittofriend").click(function() {
            var form = $(this).parents("form#sendtofriendform");
            $.getJSON("json.php", {
              type: "sendtofriend", 
              url: form.find("input[name='url']").val(), 
              recipient: form.find("input[name='recipient']").val(),
              sender: form.find("input[name='sender']").val(),
              text: form.find("textarea[name='text']").val(),
              title: $("head title").html(),
              content: $("body .content").html()
            }, function(j) {
                if(j.ok) {
                    $.fn.colorbox.close();
                } else {
                    if(typeof(j.errors.recipient) != 'undefined') {
                        form.find("input[name='recipient']").parent().parent().addClass("error");
                    } else {
                        form.find("input[name='recipient']").parent().parent().removeClass("error");
                    }
                    if(typeof(j.errors.sender) != 'undefined') {
                        form.find("input[name='sender']").parent().parent().addClass("error");
                    } else {
                        form.find("input[name='sender']").parent().parent().removeClass("error");
                    }
                }
            });
            return false;
        });
  	});

    
    
});