Commit 3948fd6f authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

initial commit

parent f9a26a9f
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
......@@ -7,17 +7,15 @@ GNU GENERAL PUBLIC LICENSE
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
......@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
......@@ -72,7 +60,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
......@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
......@@ -631,44 +629,33 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
\ No newline at end of file
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
\ No newline at end of file
/*
FILE NAME : axii_and_scales.js
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
function draw_axii(){
//x-axis
$("#cnv1").drawLine({
layer: true,
name: "axis_x",
strokeStyle: "rgba(50,50,50,0.5)",
strokeWidth: 0.5,
x1: x0, y1: $("#cnv1").height()/2,
x2: $("#cnv1").width()-x0, y2: $("#cnv1").height()/2
});
$("#cnv1").drawLine({
layer: true,
name: "axis_x_arrow",
strokeStyle: "rgba(50,50,50,0.5)",
fillStyle: "rgba(50,50,50,0.5)",
strokeWidth: 0.5,
x1: $("#cnv1").width()-x0, y1: $("#cnv1").height()/2,
x2: $("#cnv1").width()-x0-x0, y2: $("#cnv1").height()/2+2,
x3: $("#cnv1").width()-x0-x0, y3: $("#cnv1").height()/2-2,
});
$("#cnv1").drawText({
layer: true,
name: "axis_x_label",
fillStyle: "rgba(0,0,0,0.5)",
x: $("#cnv1").width()-x0, y: $("#cnv1").height()/2+y0,
font: "8px Arial, sans-serif",
align:"left",
text: "z"
});
//y-axis
$("#cnv1").drawLine({
layer: true,
name: "axis_y",
strokeStyle: "rgba(50,50,50,0.5)",
strokeWidth: 0.5,
x1: xO, y1: $("#cnv1").height()-3*y0+5,
x2: xO, y2: y0
});
$("#cnv1").drawLine({
layer: true,
name: "axis_y_arrow",
strokeStyle: "rgba(50,50,50,0.5)",
fillStyle: "rgba(50,50,50,0.5)",
strokeWidth: 0.5,
x1: xO, y1: y0,
x2: xO+2, y2: y0+y0,
x3: xO-2, y3: y0+y0,
});
$("#cnv1").drawText({
layer: true,
name: "axis_y_label",
fillStyle: "rgba(0,0,0,0.5)",
x: xO-x0, y: y0,
font: "8px Arial, sans-serif",
align:"left",
text: "y"
});
}
//draw mm scale
function draw_reference_scale(){
var sx0=xO;
var sy0=$("#cnv1").height()-y0-5;
//lines
$("#cnv1").drawLine({
layer: true,
strokeStyle: "rgba(0,0,0,1)",
strokeWidth: 0.5,
x1: sx0, y1: sy0-5,
x2: sx0, y2: sy0+5,
x3: sx0, y3: sy0,
x4: sx0+canvas_reference_scale, y4: sy0,
x5: sx0+canvas_reference_scale, y5: sy0-5,
x6: sx0+canvas_reference_scale, y6: sy0+5,
cornerRadius: 0,
});
//1m label
$("#cnv1").drawText({
layer: true,
fillStyle: "rgba(0,0,0,1)",
x: sx0+canvas_reference_scale-30, y: sy0-10,
font: "8pt Verdana, sans-serif",
align:"left",
text: (canvas_reference_scale/canvas_scale)+"mm"
});
}
function draw_scale(){
canvas_length = $("#cnv1").width() - 3*x0;
//mm scale
canvas_scale_steps = canvas_length/canvas_reference_scale;
for (var i=1;i<canvas_scale_steps;i++){
$("#cnv1").drawLine({
layer: true,
strokeStyle: "rgba(0,0,0,0.5)",
strokeWidth: 0.5,
x1: xO+(canvas_reference_scale*i), y1: $("#cnv1").height()/2-3,
x2: xO+(canvas_reference_scale*i), y2: $("#cnv1").height()/2+3
});
if (i%5==0) {
if ((xO+(canvas_reference_scale*i)+12)<($("#cnv1").width() - xO))
$("#cnv1").drawText({
layer: true,
fillStyle: "rgba(0,0,0,0.5)",
x: xO+(canvas_reference_scale*i)+3, y: $("#cnv1").height()/2-14,
font: "8pt Verdana, sans-serif",
align:"left",
text: i*(canvas_reference_scale/canvas_scale)+"mm"
});
}
}
canvas_height = $("#cnv1").height()/2 - 3*y0/2;
canvas_scale_steps = canvas_height/canvas_reference_scale;
for (var i=1;i<canvas_scale_steps;i++){
$("#cnv1").drawLine({
layer: true,
strokeStyle: "rgba(0,0,0,0.5)",
strokeWidth: 0.5,
x1: xO-3, y1: $("#cnv1").height()/2-(canvas_reference_scale*i),
x2: xO+3, y2: $("#cnv1").height()/2-(canvas_reference_scale*i)
});
$("#cnv1").drawLine({
layer: true,
strokeStyle: "rgba(0,0,0,0.5)",
strokeWidth: 0.5,
x1: xO-3, y1: $("#cnv1").height()/2+(canvas_reference_scale*i),
x2: xO+3, y2: $("#cnv1").height()/2+(canvas_reference_scale*i)
});
}
}
\ No newline at end of file
button {
/* font-family:"Times New Roman", Times, serif;*/
border: 0px solid black;
font-size: 16px;
/*line-height: 24px;*/
padding: 3px 10px 0px 10px;
margin: 3px 3px 3px 3px;
/*border radius*/
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
/*shadow*/
-moz-box-shadow: 1px 1px 1px black;
-webkit-box-shadow: 1px 1px 1px black;
box-shadow: 1px 1px 1px black;
/*text-shadow: 1px 1px 1px gray;*/
color: rgba(260,260,260,1);
text-align:center;
/*remove text selection*/
/* -webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;*/
}
button::-moz-focus-inner {
border: 0;
}
button:active, button:disabled {
text-shadow: 0px 0px 0px gray;
color: rgba(150,100,100,1);
/*shadow*/
-moz-box-shadow: 1px 1px 1px gray;
-webkit-box-shadow: 1px 1px 1px gray;
box-shadow: 1px 1px 1px gray;
/*margin: 3px 1px 3px 5px;*/
/* margin-left: 2px;
margin-top: 2px;*/
}
button:hover{
/* -moz-box-shadow: 0px 0px 10px black;
-webkit-box-shadow: 0px 0px 10px black;
box-shadow: 0px 0px 10px black; */
}
/*background gradients*/
button {
background: -webkit-gradient(linear, left top, left bottom, from(rgba(200,100,100,0.7)), to(rgba(200,100,100,0.7))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(200,100,100,0.7), rgba(200,100,100,0.7)); /* for firefox 3.6+ */
}
button:hover {
background: -webkit-gradient(linear, left top, left bottom, from(rgba(256,170,170,1)), to(rgba(230,130,130,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(256,170,170,1), rgba(230,130,130,1)); /* for firefox 3.6+ */
}
button:active, button:disabled {
background: -webkit-gradient(linear, left top, left bottom, from(rgba(230,130,130,1)), to(rgba(256,170,170,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(230,130,130,1), rgba(256,170,170,1)); /* for firefox 3.6+ */
}
input {
border: 0px solid black;
/*line-height: 22px;*/
width: 110px;
height: 15px;
-moz-line-height: 18px;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
padding: 2px 5px 2px 5px;
}
\ No newline at end of file
/*
FILE NAME : files.js
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
function save_design(){
console.log("save_design(): "+$("#file_to_save").val());
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Document>\n";
$(".elements").each(function(i){
//console.log($(this).find("#distance").val()+" ")
xml += "\t<element>\n";
xml += "\t\t<distance>"+e[i].d+"</distance>\n";
xml += "\t\t<thickness>"+e[i].t+"</thickness>\n";
xml += "\t\t<material>"+e[i].m+"</material>\n";
xml += "\t\t<name>"+e[i].name+"</name>\n";
xml += "\t\t<front>\n";
xml += "\t\t\t<height>"+e[i].front.h+"</height>\n";
xml += "\t\t\t<rcurve>"+e[i].front.c+"</rcurve>\n";
xml += "\t\t\t<k>"+e[i].front.k+"</k>\n";
xml += "\t\t\t<a1>"+e[i].front.a[0]+"</a1>\n";
xml += "\t\t\t<a2>"+e[i].front.a[1]+"</a2>\n";
xml += "\t\t\t<a3>"+e[i].front.a[2]+"</a3>\n";
xml += "\t\t\t<a4>"+e[i].front.a[3]+"</a4>\n";
xml += "\t\t</front>\n";
xml += "\t\t<back>\n";
xml += "\t\t\t<height>"+e[i].back.h+"</height>\n";
xml += "\t\t\t<rcurve>"+e[i].back.c+"</rcurve>\n";
xml += "\t\t\t<k>"+e[i].back.k+"</k>\n";
xml += "\t\t\t<a1>"+e[i].back.a[0]+"</a1>\n";
xml += "\t\t\t<a2>"+e[i].back.a[1]+"</a2>\n";
xml += "\t\t\t<a3>"+e[i].back.a[2]+"</a3>\n";
xml += "\t\t\t<a4>"+e[i].back.a[3]+"</a4>\n";
xml += "\t\t</back>\n";
xml += "\t</element>\n";
});
xml += "</Document>"
postSettings($("#file_to_save").val(), "save", xml);
}
function postSettings(file, cmd, xml) {
$.ajax({
url: "files.php?file="+file+"&cmd="+cmd,
type: "POST",
dataType: "xml",
data: xml,
async:false,
complete: function(response){parse_save_response(response.responseText);},
contentType: "text/xml; charset=\"utf-8\""
});
}
function parse_save_response(text) {
//$("#test").html(text);
//reload list
get_designs_list("load_designs_list");
jquery_list("load_designs_list","Load",load_design);
}
function getDesign(file) {
$.ajax({
url: "files.php?file="+file+"&cmd=read",
type: "GET",
async: false,
complete: function(response){
restore_design(response.responseXML);
},
contentType: "text/xml; charset=\"utf-8\""
});
}
function restore_design(text){
console.log("restore_design()");
//erase old
$(".elements").each(function(){
console.log("removing "+$(this).attr("value"));
array_remove_element($(this).attr("value"));
// $("#element_"+i).remove();
// $("#cnv1").removeLayer("element_"+i).drawLayers();
});
selected_elements = Array();
//draw new
var data = $(text).find("Document");
data.find("element").each(function(){
array_add_element(
$(this).find("distance").text(),
$(this).find("thickness").text(),
$(this).find("material").text(),
$(this).find("name").text(),
$(this).find("front").find("height").text(),
$(this).find("front").find("rcurve").text(),
$(this).find("front").find("k").text(),
$(this).find("front").find("a1").text(),
$(this).find("front").find("a2").text(),
$(this).find("front").find("a3").text(),
$(this).find("front").find("a4").text(),
$(this).find("back").find("height").text(),
$(this).find("back").find("rcurve").text(),
$(this).find("back").find("k").text(),
$(this).find("back").find("a1").text(),
$(this).find("back").find("a2").text(),
$(this).find("back").find("a3").text(),
$(this).find("back").find("a4").text()
);
});
}
\ No newline at end of file
<?php
/*
FILE NAME : files.php
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
if (isset($_GET['file'])) $file = $_GET['file'];
else die("-1");
if (isset($_GET['cmd'])) $cmd = $_GET['cmd'];
else die("-2");
$default_path = "local";
if ($cmd=="save") {
file_put_contents("$default_path/$file",file_get_contents("php://input"));
}elseif ($cmd=="read") {
$content = file_get_contents("$default_path/$file");
header("Content-Type: text/xml\n");
header("Content-Length: ".strlen($content)."\n");
header("Pragma: no-cache\n");
echo $content;
}
?>
\ No newline at end of file
<?php
/*
FILE NAME : get_designs_list.php
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
//$res_xml = file_get_contents("sensors/sensors.xml");
$path = "local";
$res_xml = "<?xml version='1.0'?>\n";
$res_xml .= "<Document>\n";
$files = scandir($path);
foreach($files as $file){
if (is_file("$path/$file")) {
$res_xml .= "\t<file>$file</file>\n";
}
}
$res_xml .= "</Document>";
header("Content-Type: text/xml");
header("Content-Length: ".strlen($res_xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $res_xml);
flush();
?>
#cnv1{
position: absolute;
left:5px;
top:5px;
width: 1000px;
height: 500px;
box-shadow: 0px 0px 5px rgba(100,100,100,0.7);
border-radius:3px;
}
#elements_table_header{
position: absolute;
left:5px;
top:510px;
}
#elements_table{
position: absolute;
left:5px;
top:544px;
}
#controls_div{
position: absolute;
left: 1010px;
top:5px;
}
table {
border: 1px solid rgba(200,200,200,1);
border-collapse:collapse;
}
#elements_table_header, #controls_table, #ray_draw_table{
background: rgba(200,200,200,0.6);
}
td{
padding: 2px 5px 2px 5px;
text-align: center;
border: 0px solid red;
}
#controls_table tr td input{
padding: 10px;
}
input{
width: 100px;
text-align:right;
}
#file_to_save{
width: 200px;
}
#load_designs_list{
position:absolute;
left:1010px;
top:44px;
}
#number{
margin: 0px;
padding:2px 3px 2px 3px;
font-size:0.7em
}
#ray_draw_div{
position: absolute;
left:1010px;
top:74px;
}
.remove_button{
font-size: 16px;
margin: 0px;
padding: 1px 6px 1px 6px;
border-radius: 10px;
}
.plus_button{
font-size: 16px;
padding: 2px 6px 0px 6px;
border-radius: 10px;
}
.elements{
margin: 0px;
}
#elements_table{
padding: 0px 0px 0px 0px;
background: rgba(200,200,200,0.6);
}
<html>
<!--
FILE NAME : index.html
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
-->
<head>
<title>Lens Design Tool</title>
<script src="jquery-2.1.0.min.js" type="text/javascript"></script>
<script src="jcanvas.min.js" type="text/javascript"></script>
<script src="lens_design.js" type="text/javascript"></script>
<script src="axii_and_scales.js" type="text/javascript"></script>
<script src="list.js" type="text/javascript"></script>
<script src="jquery_list.js" type="text/javascript"></script>
<script src="files.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="button.css" />
<link rel="stylesheet" type="text/css" href="index.css" />
<link rel="stylesheet" type="text/css" href="list.css" />
</head>
<body>
<div id=load_designs_list class=list></div>
<div id="cnv1_div">
<canvas id="cnv1" width="1000" height="500"></canvas>
</div>
<div id="controls_div">
<table id="controls_table">
<tr>
<td><button onclick="save_design()">Save</button></td>
<td><input type="text" id="file_to_save" value="tmp_design.xml" /></td>
</tr>
<td></td>
<td></td>
</table>
</div>
<div id="elements_table_header_div">
<table id="elements_table_header">
<tr id="header">
<td><div style="width:16px;">#</div></td>
<td width=100 >Distance, <span style="font-size:0.8em">mm</span></td>
<td width=100 >Thickness, <span style="font-size:0.8em">mm</span></td>
<td width=100 >Material</td>
<td width=100 >Comment</td>
<td width=24></td>
<td>Aperture<span style="font-size:0.8em"> (Dia)</span>, <span style="font-size:0.8em">mm</span></td>
<td width=100 >R<span style="font-size:0.8em">(curve)</span>, <span style="font-size:0.8em">mm</span></td>
<td width=100 >&kappa;</td>
<td width=100 >&alpha;<span style="font-size:0.6em">1</span></td>
<td width=100 >&alpha;<span style="font-size:0.6em">2</span></td>
<td width=100 >&alpha;<span style="font-size:0.6em">3</span></td>
<td width=95 >&alpha;<span style="font-size:0.6em">4</span></td>
<td><button class='plus_button' onclick="element_add_button()"><b>+</b></button></td>
</tr>
</table>
</div>
<div id="elements_table">
</div>
<div id="ray_draw_div">
<table id="ray_draw_table">
<tr>
<td>Image height/2, <span style="font-size:0.6em">mm</span></td>
<td><input type="text" id="rays_imhh" value="3" /></td>
</tr>
<tr>
<td>N</td>
<td><input type="text" id="rays_n" value="3" /></td>
</tr>
<tr>
<td>color</td>
<td><input type="text" id="rays_color" value="rgb(20,150,20)" /></td>
</tr>
<tr>
<td><button onclick="rays_draw()">Draw rays</button></td>
</tr>
</table>
</div>
</body>
</html>
\ No newline at end of file
/*
jCanvas v14.01.22
Copyright 2014 Caleb Evans
Released under the MIT license
*/
(function(f,ta,ua,Ta,ea,ja,na,w,z,g,r){function J(d){var c;if(O.future.inheritance)for(c in d)d.hasOwnProperty(c)&&(this[c]=d[c]);else Z(this,d)}function O(d){var c;if(d)Z($,d);else for(c in $)$.hasOwnProperty(c)&&delete $[c];na&&na.warn&&!va.jCanvas&&(va.jCanvas=w,na.warn("The jCanvas() method has been deprecated and will be removed in a future release."));return this}function wa(){}function ka(d){return"string"===aa(d)}function K(d){return d&&d.getContext?d.getContext("2d"):g}function la(d){d=Z({},
d);d.masks=d.masks.slice(0);return d}function fa(d,c){var a;d.save();a=la(c.transforms);c.savedTransforms.push(a)}function xa(d,c,a,b){a[b]&&(ca(a[b])?c[b]=a[b].call(d,a):c[b]=a[b])}function T(d,c,a){xa(d,c,a,"fillStyle");xa(d,c,a,"strokeStyle");c.lineWidth=a.strokeWidth;a.rounded?c.lineCap=c.lineJoin="round":(c.lineCap=a.strokeCap,c.lineJoin=a.strokeJoin,c.miterLimit=a.miterLimit);c.shadowOffsetX=a.shadowX;c.shadowOffsetY=a.shadowY;c.shadowBlur=a.shadowBlur;c.shadowColor=a.shadowColor;c.globalAlpha=
a.opacity;c.globalCompositeOperation=a.compositing;a.imageSmoothing&&(c.webkitImageSmoothingEnabled=c.mozImageSmoothingEnabled=a.imageSmoothing)}function ya(d,c,a){a.mask&&(a.autosave&&fa(d,c),d.clip(),c.transforms.masks.push(a._args))}function X(d,c,a){a.closed&&c.closePath();a.shadowStroke&&0!==a.strokeWidth?(c.stroke(),c.fill(),c.shadowColor="transparent",c.shadowBlur=0,c.stroke()):(c.fill(),"transparent"!==a.fillStyle&&(c.shadowColor="transparent"),0!==a.strokeWidth&&c.stroke());a.closed||c.closePath();
a._transformed&&c.restore();a.mask&&(d=D(d),ya(c,d,a))}function za(d,c,a){c._toRad=c.inDegrees?H/180:1;d.translate(c.x,c.y);d.rotate(c.rotate*c._toRad);d.translate(-c.x,-c.y);a&&(a.rotate+=c.rotate*c._toRad)}function Aa(d,c,a){1!==c.scale&&(c.scaleX=c.scaleY=c.scale);d.translate(c.x,c.y);d.scale(c.scaleX,c.scaleY);d.translate(-c.x,-c.y);a&&(a.scaleX*=c.scaleX,a.scaleY*=c.scaleY)}function Ba(d,c,a){c.translate&&(c.translateX=c.translateY=c.translate);d.translate(c.translateX,c.translateY);a&&(a.translateX+=
c.translateX,a.translateY+=c.translateY)}function S(d,c,a,b,e){a._toRad=a.inDegrees?H/180:1;a._transformed=w;c.save();a.fromCenter||a._centered||b===r||(e===r&&(e=b),a.x+=b/2,a.y+=e/2,a._centered=w);a.rotate&&za(c,a,g);1===a.scale&&1===a.scaleX&&1===a.scaleY||Aa(c,a,g);(a.translate||a.translateX||a.translateY)&&Ba(c,a,g)}function D(d){var c=ba.dataCache,a;c._canvas===d&&c._data?a=c._data:(a=f.data(d,"jCanvas"),a||(a={canvas:d,layers:[],layer:{names:{},groups:{}},eventHooks:{},intersecting:[],lastIntersected:g,
cursor:f(d).css("cursor"),drag:{layer:g,dragging:z},event:{type:g,x:g,y:g},events:{},transforms:la(oa),savedTransforms:[],animating:z,animated:g,pixelRatio:1,scaled:z},f.data(d,"jCanvas",a)),c._canvas=d,c._data=a);return a}function Ca(d,c,a){for(var b in O.events)O.events.hasOwnProperty(b)&&(a[b]||a.cursors&&a.cursors[b])&&Da(d,c,a,b)}function Da(d,c,a,b){window.ontouchstart!==r&&Y.touchEvents[b]&&(b=Y.touchEvents[b]);O.events[b](d,c);a._event=w}function Ea(d,c,a){var b,e,h;if(a.draggable||a.cursors){b=
["mousedown","mousemove","mouseup"];for(h=0;h<b.length;h+=1)e=b[h],Da(d,c,a,e);c.events.mouseoutdrag||(d.bind("mouseout.jCanvas",function(){var a=c.drag.layer;a&&(c.drag={},Q(d,c,a,"dragcancel"),d.drawLayers())}),c.events.mouseoutdrag=w);a._event=w}}function pa(d,c,a,b){d=c.layer.names;b?b.name!==r&&ka(a.name)&&a.name!==b.name&&delete d[a.name]:b=a;ka(b.name)&&(d[b.name]=a)}function qa(d,c,a,b){d=c.layer.groups;var e,h,k,f;if(!b)b=a;else if(b.groups!==r&&a.groups!==g)for(h=0;h<a.groups.length;h+=
1)if(e=a.groups[h],c=d[e]){for(f=0;f<c.length;f+=1)if(c[f]===a){k=f;c.splice(f,1);break}0===c.length&&delete d[e]}if(b.groups!==r&&b.groups!==g)for(h=0;h<b.groups.length;h+=1)e=b.groups[h],c=d[e],c||(c=d[e]=[],c.name=e),k===r&&(k=c.length),c.splice(k,0,a)}function ra(d,c,a,b,e){b[a]&&c._running&&!c._running[a]&&(c._running[a]=w,b[a].call(d[0],c,e),c._running[a]=z)}function Q(d,c,a,b,e){if(!a.disableEvents){if("mouseout"!==b){var h;a.cursors&&(h=a.cursors[b]);-1!==f.inArray(h,V.cursors)&&(h=V.prefix+
h);h&&d.css({cursor:h})}ra(d,a,b,a,e);ra(d,a,b,c.eventHooks,e);ra(d,a,b,O.eventHooks,e)}}function P(d,c,a,b){var e=c._layer?a:c;c._args=a;c.canvas=d;if(c.draggable||c.dragGroups)c.layer=w,c.draggable=w;c._method=b?b:c.method?f.fn[c.method]:c.type?f.fn[Y.drawings[c.type]]:function(){};c.layer&&!c._layer&&(a=f(d),d=D(d),b=d.layers,e.name===g||ka(e.name)&&d.layer.names[e.name]===r)&&(e=new J(c),e.layer=w,e._layer=w,e._running={},e.data=e.data!==g?Z({},e.data):{},e.groups=e.groups!==g?e.groups.slice(0):
[],pa(a,d,e),qa(a,d,e),Ca(a,d,e),Ea(a,d,e),c._event=e._event,e._method===f.fn.drawText&&a.measureText(e),e.index===g&&(e.index=b.length),b.splice(e.index,0,e),c._args=e,Q(a,d,e,"add"));return e}function Fa(d,c){var a,b;for(b=0;b<V.props.length;b+=1)a=V.props[b],d[a]!==r&&(d["_"+a]=d[a],V.propsObj[a]=w,c&&delete d[a])}function Ua(d,c,a){var b,e,h,k;for(b in a)if(a.hasOwnProperty(b)&&(e=a[b],ca(e)&&(a[b]=e.call(d,c,b)),"object"===aa(e))){for(h in e)e.hasOwnProperty(h)&&(k=e[h],c[b]!==r&&(c[b+"."+h]=
c[b][h],a[b+"."+h]=k));delete a[b]}return a}function Ga(d){var c,a,b=[],e=1;d.match(/^([a-z]+|#[0-9a-f]+)$/gi)&&("transparent"===d&&(d="rgba(0,0,0,0)"),a=ta.head,c=a.style.color,a.style.color=d,d=f.css(a,"color"),a.style.color=c);d.match(/^rgb/gi)&&(b=d.match(/(\d+(\.\d+)?)/gi),d.match(/%/gi)&&(e=2.55),b[0]*=e,b[1]*=e,b[2]*=e,b[3]=b[3]!==r?ja(b[3]):1);return b}function Va(d){var c=3,a;"array"!==aa(d.start)&&(d.start=Ga(d.start),d.end=Ga(d.end));d.now=[];if(1!==d.start[3]||1!==d.end[3])c=4;for(a=0;a<
c;a+=1)d.now[a]=d.start[a]+(d.end[a]-d.start[a])*d.pos,3>a&&(d.now[a]=Wa(d.now[a]));1!==d.start[3]||1!==d.end[3]?d.now="rgba("+d.now.join(",")+")":(d.now.slice(0,3),d.now="rgb("+d.now.join(",")+")");d.elem.nodeName?d.elem.style[d.prop]=d.now:d.elem[d.prop]=d.now}function Xa(d){O.events[d]=function(c,a){var b,e;e=a.event;b="mouseover"===d||"mouseout"===d?"mousemove":d;a.events[b]||(c.bind(b+".jCanvas",function(a){e.x=a.offsetX;e.y=a.offsetY;e.type=b;e.event=a;c.drawLayers({resetFire:w});a.preventDefault()}),
a.events[b]=w)}}function U(d,c,a){var b,e,h,k;if(a=a._args)d=D(d),b=d.event,b.x!==g&&b.y!==g&&(h=b.x*d.pixelRatio,k=b.y*d.pixelRatio,e=c.isPointInPath(h,k)||c.isPointInStroke&&c.isPointInStroke(h,k)),c=d.transforms,a.eventX=a.mouseX=b.x,a.eventY=a.mouseY=b.y,a.event=b.event,b=d.transforms.rotate,h=a.eventX,k=a.eventY,0!==b?(a._eventX=h*N(-b)-k*R(-b),a._eventY=k*N(-b)+h*R(-b)):(a._eventX=h,a._eventY=k),a._eventX/=c.scaleX,a._eventY/=c.scaleY,e&&d.intersecting.push(a),a.intersects=e}function Ha(d){for(;0>
d;)d+=2*H;return d}function Ia(d,c,a,b){var e,h,k,f,B,t,g;a===b?g=t=0:(t=a.x,g=a.y);b.inDegrees||360!==b.end||(b.end=2*H);b.start*=a._toRad;b.end*=a._toRad;b.start-=H/2;b.end-=H/2;B=H/180*1;b.ccw&&(B*=-1);e=b.x+b.radius*N(b.start+B);h=b.y+b.radius*R(b.start+B);k=b.x+b.radius*N(b.start);f=b.y+b.radius*R(b.start);ga(d,c,a,b,e,h,k,f);c.arc(b.x+t,b.y+g,b.radius,b.start,b.end,b.ccw);e=b.x+b.radius*N(b.end+B);B=b.y+b.radius*R(b.end+B);h=b.x+b.radius*N(b.end);k=b.y+b.radius*R(b.end);ha(d,c,a,b,h,k,e,B)}
function Ja(d,c,a,b,e,h,k,f){var B,t;b.arrowRadius&&!a.closed&&(t=Ya(f-h,k-e),t-=H,d=a.strokeWidth*N(t),B=a.strokeWidth*R(t),a=k+b.arrowRadius*N(t+b.arrowAngle/2),e=f+b.arrowRadius*R(t+b.arrowAngle/2),h=k+b.arrowRadius*N(t-b.arrowAngle/2),b=f+b.arrowRadius*R(t-b.arrowAngle/2),c.moveTo(a-d,e-B),c.lineTo(k-d,f-B),c.lineTo(h-d,b-B),c.moveTo(k-d,f-B),c.lineTo(k+d,f+B),c.moveTo(k,f))}function ga(d,c,a,b,e,h,k,f){b._arrowAngleConverted||(b.arrowAngle*=a._toRad,b._arrowAngleConverted=w);b.startArrow&&Ja(d,
c,a,b,e,h,k,f)}function ha(d,c,a,b,e,h,k,f){b._arrowAngleConverted||(b.arrowAngle*=a._toRad,b._arrowAngleConverted=w);b.endArrow&&Ja(d,c,a,b,e,h,k,f)}function Ka(d,c,a,b){var e,h,k;e=2;ga(d,c,a,b,b.x2+a.x,b.y2+a.y,b.x1+a.x,b.y1+a.y);for(b.x1!==r&&b.y1!==r&&c.moveTo(b.x1+a.x,b.y1+a.y);w;)if(h=b["x"+e],k=b["y"+e],h!==r&&k!==r)c.lineTo(h+a.x,k+a.y),e+=1;else break;e-=1;ha(d,c,a,b,b["x"+(e-1)]+a.x,b["y"+(e-1)]+a.y,b["x"+e]+a.x,b["y"+e]+a.y)}function La(d,c,a,b){var e,h,k,f,B;e=2;ga(d,c,a,b,b.cx1+a.x,
b.cy1+a.y,b.x1+a.x,b.y1+a.y);for(b.x1!==r&&b.y1!==r&&c.moveTo(b.x1+a.x,b.y1+a.y);w;)if(h=b["x"+e],k=b["y"+e],f=b["cx"+(e-1)],B=b["cy"+(e-1)],h!==r&&k!==r&&f!==r&&B!==r)c.quadraticCurveTo(f+a.x,B+a.y,h+a.x,k+a.y),e+=1;else break;e-=1;ha(d,c,a,b,b["cx"+(e-1)]+a.x,b["cy"+(e-1)]+a.y,b["x"+e]+a.x,b["y"+e]+a.y)}function Ma(d,c,a,b){var e,h,k,f,B,t,g,F;e=2;h=1;ga(d,c,a,b,b.cx1+a.x,b.cy1+a.y,a.x1+a.x,a.y1+a.y);for(a.x1!==r&&a.y1!==r&&c.moveTo(a.x1+a.x,a.y1+a.y);w;)if(k=b["x"+e],f=b["y"+e],B=b["cx"+h],t=b["cy"+
h],g=b["cx"+(h+1)],F=b["cy"+(h+1)],k!==r&&f!==r&&B!==r&&t!==r&&g!==r&&F!==r)c.bezierCurveTo(B+a.x,t+a.y,g+a.x,F+a.y,k+a.x,f+a.y),e+=1,h+=2;else break;e-=1;h-=2;ha(d,c,a,b,b["cx"+(h+1)]+a.x,b["cy"+(h+1)]+a.y,b["x"+e]+a.x,b["y"+e]+a.y)}function Na(d,c,a){c*=d._toRad;c-=H/2;return a*N(c)}function Oa(d,c,a){c*=d._toRad;c-=H/2;return a*R(c)}function Pa(d,c,a,b){var e,h,k,f,g,t,E;a===b?g=f=0:(f=a.x,g=a.y);e=1;h=f=t=b.x+f;k=g=E=b.y+g;ga(d,c,a,b,h+Na(a,b.a1,b.l1),k+Oa(a,b.a1,b.l1),h,k);for(b.x!==r&&b.y!==
r&&c.moveTo(h,k);w;)if(h=b["a"+e],k=b["l"+e],h!==r&&k!==r)f=t,g=E,t+=Na(a,h,k),E+=Oa(a,h,k),c.lineTo(t,E),e+=1;else break;ha(d,c,a,b,f,g,t,E)}function Qa(d,c){isNaN(Number(c.fontSize))||(c.fontSize+="px");d.font=c.fontStyle+" "+c.fontSize+" "+c.fontFamily}function Ra(d,c,a,b){var e,h;e=ba.propCache;if(e.text===a.text&&e.fontStyle===a.fontStyle&&e.fontSize===a.fontSize&&e.fontFamily===a.fontFamily&&e.maxWidth===a.maxWidth&&e.lineHeight===a.lineHeight)a.width=e.width,a.height=e.height;else{a.width=
c.measureText(b[0]).width;for(h=1;h<b.length;h+=1)e=c.measureText(b[h]).width,e>a.width&&(a.width=e);c=d.style.fontSize;d.style.fontSize=a.fontSize;a.height=ja(f.css(d,"fontSize"))*b.length*a.lineHeight;d.style.fontSize=c}}function Sa(d,c){var a=c.maxWidth,b=c.text.split("\n"),e=[],h,k,f,g,t;for(f=0;f<b.length;f+=1){g=b[f];t=g.split(" ");h=[];k="";if(1===t.length||d.measureText(g).width<a)h=[g];else{for(g=0;g<t.length;g+=1)d.measureText(k+t[g]).width>a&&(""!==k&&h.push(k),k=""),k+=t[g],g!==t.length-
1&&(k+=" ");h.push(k)}e=e.concat(h.join("\n").replace(/( (\n))|( $)/gi,"$2").split("\n"))}return e}var ma,$,Z=f.extend,ia=f.inArray,aa=f.type,ca=f.isFunction,H=ea.PI,Wa=ea.round,R=ea.sin,N=ea.cos,Ya=ea.atan2,sa=Ta.prototype.slice,Za=f.event.fix,Y={},ba={dataCache:{},propCache:{},imageCache:{}},oa={rotate:0,scaleX:1,scaleY:1,translateX:0,translateY:0,masks:[]},va={jCanvas:z},V={};f.fn.jCanvas=O;O.events={};O.eventHooks={};O.future={inheritance:!1};ma=new function(){Z(this,{align:"center",arrowAngle:90,
arrowRadius:0,autosave:w,baseline:"middle",bringToFront:z,ccw:z,closed:z,compositing:"source-over",concavity:0,cornerRadius:0,count:1,cropFromCenter:w,cursors:g,disableEvents:z,draggable:z,dragGroups:g,groups:g,data:g,dx:g,dy:g,end:360,eventX:g,eventY:g,fillStyle:"transparent",fontStyle:"normal",fontSize:"12pt",fontFamily:"sans-serif",fromCenter:w,height:g,imageSmoothing:w,inDegrees:w,index:g,lineHeight:1,layer:z,mask:z,maxWidth:g,miterLimit:10,name:g,opacity:1,r1:g,r2:g,radius:0,repeat:"repeat",
respectAlign:z,rotate:0,rounded:z,scale:1,scaleX:1,scaleY:1,shadowBlur:0,shadowColor:"transparent",shadowStroke:z,shadowX:0,shadowY:0,sHeight:g,sides:0,source:"",spread:0,start:0,strokeCap:"butt",strokeJoin:"miter",strokeStyle:"transparent",strokeWidth:1,sWidth:g,sx:g,sy:g,text:"",translate:0,translateX:0,translateY:0,type:g,visible:w,width:g,x:0,y:0})};wa.prototype=ma;$=new wa;J.prototype=$;O.extend=function(d){d.name&&(d.props&&Z(ma,d.props),f.fn[d.name]=function a(b){var e,h,k,f;for(h=0;h<this.length;h+=
1)if(e=this[h],k=K(e))f=new J(b),P(e,f,b,a),T(e,k,f),d.fn.call(e,k,f);return this},d.type&&(Y.drawings[d.type]=d.name));return f.fn[d.name]};f.fn.getEventHooks=function(){var d;d={};0!==this.length&&(d=this[0],d=D(d),d=d.eventHooks);return d};f.fn.setEventHooks=function(d){var c,a;for(c=0;c<this.length;c+=1)f(this[c]),a=D(this[c]),Z(a.eventHooks,d);return this};f.fn.getLayers=function(d){var c,a,b,e,h=[];if(0!==this.length)if(c=this[0],a=D(c),a=a.layers,ca(d))for(e=0;e<a.length;e+=1)b=a[e],d.call(c,
b)&&h.push(b);else h=a;return h};f.fn.getLayer=function(d){var c,a,b,e;if(0!==this.length)if(c=this[0],a=D(c),c=a.layers,e=aa(d),d&&d.layer)b=d;else if("number"===e)0>d&&(d=c.length+d),b=c[d];else if("regexp"===e)for(a=0;a<c.length;a+=1){if(ka(c[a].name)&&c[a].name.match(d)){b=c[a];break}}else b=a.layer.names[d];return b};f.fn.getLayerGroup=function(d){var c,a,b,e=aa(d);if(0!==this.length)if(c=this[0],"array"===e)b=d;else if("regexp"===e)for(a in c=D(c),c=c.layer.groups,c){if(a.match(d)){b=c[a];break}}else c=
D(c),b=c.layer.groups[d];return b};f.fn.getLayerIndex=function(d){var c=this.getLayers();d=this.getLayer(d);return ia(d,c)};f.fn.setLayer=function(d,c){var a,b,e,h,k,g,B;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=D(this[b]),h=f(this[b]).getLayer(d)){pa(a,e,h,c);qa(a,e,h,c);for(k in c)c.hasOwnProperty(k)&&(g=c[k],B=aa(g),"object"===B?h[k]=Z({},g):"array"===B?h[k]=g.slice(0):"string"===B?0===g.indexOf("+=")?h[k]+=ja(g.substr(2)):0===g.indexOf("-=")?h[k]-=ja(g.substr(2)):h[k]=g:h[k]=g);Ca(a,e,h);Ea(a,
e,h);f.isEmptyObject(c)===z&&Q(a,e,h,"change",c)}return this};f.fn.setLayers=function(d,c){var a,b,e,h;for(b=0;b<this.length;b+=1)for(a=f(this[b]),e=a.getLayers(c),h=0;h<e.length;h+=1)a.setLayer(e[h],d);return this};f.fn.setLayerGroup=function(d,c){var a,b,e,h;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=a.getLayerGroup(d))for(h=0;h<e.length;h+=1)a.setLayer(e[h],c);return this};f.fn.moveLayer=function(d,c){var a,b,e,h,k;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=D(this[b]),h=e.layers,k=a.getLayer(d))k.index=
ia(k,h),h.splice(k.index,1),h.splice(c,0,k),0>c&&(c=h.length+c),k.index=c,Q(a,e,k,"move");return this};f.fn.removeLayer=function(d){var c,a,b,e,h;for(a=0;a<this.length;a+=1)if(c=f(this[a]),b=D(this[a]),e=c.getLayers(),h=c.getLayer(d))h.index=ia(h,e),e.splice(h.index,1),pa(c,b,h,{name:g}),qa(c,b,h,{groups:g}),Q(c,b,h,"remove");return this};f.fn.removeLayers=function(d){var c,a,b,e,h,k;for(a=0;a<this.length;a+=1){c=f(this[a]);b=D(this[a]);e=c.getLayers(d);for(k=0;k<e.length;k+=1)h=e[k],c.removeLayer(h),
k-=1;b.layer.names={};b.layer.groups={}}return this};f.fn.removeLayerGroup=function(d){var c,a,b,e;if(d!==r)for(a=0;a<this.length;a+=1)if(c=f(this[a]),D(this[a]),c.getLayers(),b=c.getLayerGroup(d))for(b=b.slice(0),e=0;e<b.length;e+=1)c.removeLayer(b[e]);return this};f.fn.addLayerToGroup=function(d,c){var a,b,e,h=[c];for(b=0;b<this.length;b+=1)a=f(this[b]),e=a.getLayer(d),e.groups&&(h=e.groups.slice(0),-1===ia(c,e.groups)&&h.push(c)),a.setLayer(e,{groups:h});return this};f.fn.removeLayerFromGroup=
function(d,c){var a,b,e,h=[],k;for(b=0;b<this.length;b+=1)a=f(this[b]),e=a.getLayer(d),e.groups&&(k=ia(c,e.groups),-1!==k&&(h=e.groups.slice(0),h.splice(k,1),a.setLayer(e,{groups:h})));return this};V.cursors=["grab","grabbing","zoom-in","zoom-out"];V.prefix=function(){var d=getComputedStyle(ta.documentElement,"");return"-"+(sa.call(d).join("").match(/-(moz|webkit|ms)-/)||""===d.OLink&&["","o"])[1]+"-"}();f.fn.triggerLayerEvent=function(d,c){var a,b,e;for(b=0;b<this.length;b+=1)a=f(this[b]),e=D(this[b]),
(d=a.getLayer(d))&&Q(a,e,d,c);return this};f.fn.drawLayer=function(d){var c,a,b;for(c=0;c<this.length;c+=1)a=f(this[c]),K(this[c]),(b=a.getLayer(d))&&b.visible&&b._method&&(b._next=g,b._method.call(a,b));return this};f.fn.drawLayers=function(d){var c,a,b=Z({},d),e,h,k,L,B,t;b.index||(b.index=0);for(c=0;c<this.length;c+=1)if(d=f(this[c]),a=K(this[c])){L=D(this[c]);b.clear!==z&&d.clearCanvas();a=L.layers;for(k=b.index;k<a.length&&(e=a[k],e.index=k,b.resetFire&&(e._fired=z),B=d,t=e,h=k+1,t&&t.visible&&
t._method&&(t._next=h?h:g,t._method.call(B,t)),e._masks=L.transforms.masks.slice(0),e._method!==f.fn.drawImage||!e.visible);k+=1);e=L;var E=h=t=B=void 0;B=g;for(t=e.intersecting.length-1;0<=t;t-=1)if(B=e.intersecting[t],B._masks){for(E=B._masks.length-1;0<=E;E-=1)if(h=B._masks[E],!h.intersects){B.intersects=z;break}if(B.intersects)break}e=B;B=L.event;t=B.type;if(L.drag.layer){h=d;var E=L,F=t,y=void 0,u=void 0,p=void 0,C=p=void 0,m=void 0,p=y=y=p=void 0,p=E.drag,C=(u=p.layer)&&u.dragGroups||[],y=E.layers;
if("mousemove"===F||"touchmove"===F){if(p.dragging||(p.dragging=w,u.dragging=w,u.bringToFront&&(y.splice(u.index,1),u.index=y.push(u)),u._startX=u.x,u._startY=u.y,u._endX=u._eventX,u._endY=u._eventY,Q(h,E,u,"dragstart")),p.dragging)for(y=u._eventX-(u._endX-u._startX),p=u._eventY-(u._endY-u._startY),u.dx=y-u.x,u.dy=p-u.y,u.x=y,u.y=p,Q(h,E,u,"drag"),y=0;y<C.length;y+=1)if(p=C[y],m=E.layer.groups[p],u.groups&&m)for(p=0;p<m.length;p+=1)m[p]!==u&&(m[p].x+=u.dx,m[p].y+=u.dy)}else if("mouseup"===F||"touchend"===
F)p.dragging&&(u.dragging=z,p.dragging=z,Q(h,E,u,"dragstop")),E.drag={}}h=L.lastIntersected;h===g||e===h||!h._hovered||h._fired||L.drag.dragging||(L.lastIntersected=g,h._fired=w,h._hovered=z,Q(d,L,h,"mouseout"),d.css({cursor:L.cursor}));e&&(e[t]||Y.mouseEvents[t]&&(t=Y.mouseEvents[t]),e._event&&e.intersects&&(L.lastIntersected=e,!(e.mouseover||e.mouseout||e.cursors)||L.drag.dragging||e._hovered||e._fired||(e._fired=w,e._hovered=w,Q(d,L,e,"mouseover")),e._fired||(e._fired=w,B.type=g,Q(d,L,e,t)),!e.draggable||
e.disableEvents||"mousedown"!==t&&"touchstart"!==t||(L.drag.layer=e)));e!==g||L.drag.dragging||d.css({cursor:L.cursor});k===a.length&&(L.intersecting.length=0,L.transforms=la(oa),L.savedTransforms.length=0)}return this};f.fn.addLayer=function(d){var c,a;for(c=0;c<this.length;c+=1)if(a=K(this[c]))a=new J(d),a.layer=w,P(this[c],a,d);return this};V.props=["width","height","opacity","lineHeight"];V.propsObj={};f.fn.animateLayer=function(){function d(a,b,c){return function(){var d,e;for(e=0;e<V.props.length;e+=
1)d=V.props[e],c[d]=c["_"+d];for(var k in c)c.hasOwnProperty(k)&&-1!==k.indexOf(".")&&delete c[k];b.animating&&b.animated!==c||a.drawLayers();c._animating=z;b.animating=z;b.animated=g;h[4]&&h[4].call(a[0],c);Q(a,b,c,"animateend")}}function c(a,b,c){return function(d,e){var k,f,g=!1;"_"===e.prop[0]&&(g=!0,e.prop=e.prop.replace("_",""),c[e.prop]=c["_"+e.prop]);-1!==e.prop.indexOf(".")&&(k=e.prop.split("."),f=k[0],k=k[1],c[f]&&(c[f][k]=e.now));c._pos!==e.pos&&(c._pos=e.pos,c._animating||b.animating||
(c._animating=w,b.animating=w,b.animated=c),b.animating&&b.animated!==c||a.drawLayers());h[5]&&h[5].call(a[0],d,e,c);Q(a,b,c,"animate",e);g&&(e.prop="_"+e.prop)}}var a,b,e,h=sa.call(arguments,0),k,L;"object"===aa(h[2])?(h.splice(2,0,h[2].duration||g),h.splice(3,0,h[3].easing||g),h.splice(4,0,h[4].complete||g),h.splice(5,0,h[5].step||g)):(h[2]===r?(h.splice(2,0,g),h.splice(3,0,g),h.splice(4,0,g)):ca(h[2])&&(h.splice(2,0,g),h.splice(3,0,g)),h[3]===r?(h[3]=g,h.splice(4,0,g)):ca(h[3])&&h.splice(3,0,g));
for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=K(this[b]))e=D(this[b]),(k=a.getLayer(h[0]))&&k._method!==f.fn.draw&&(L=Z({},h[1]),L=Ua(this[b],k,L),Fa(L,w),Fa(k),k.style=V.propsObj,f(k).animate(L,{duration:h[2],easing:f.easing[h[3]]?h[3]:g,complete:d(a,e,k),step:c(a,e,k)}),Q(a,e,k,"animatestart"));return this};f.fn.animateLayerGroup=function(d){var c,a,b=sa.call(arguments,0),e,h;for(a=0;a<this.length;a+=1)if(c=f(this[a]),e=c.getLayerGroup(d))for(h=0;h<e.length;h+=1)b[0]=e[h],c.animateLayer.apply(c,
b);return this};f.fn.delayLayer=function(d,c){var a,b,e,h;c=c||0;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=D(this[b]),h=a.getLayer(d))f(h).delay(c),Q(a,e,h,"delay");return this};f.fn.delayLayerGroup=function(d,c){var a,b,e,h,k;c=c||0;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=a.getLayerGroup(d))for(k=0;k<e.length;k+=1)h=e[k],a.delayLayer(h,c);return this};f.fn.stopLayer=function(d,c){var a,b,e,h;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=D(this[b]),h=a.getLayer(d))f(h).stop(c),Q(a,e,h,"stop");
return this};f.fn.stopLayerGroup=function(d,c){var a,b,e,h,k;for(b=0;b<this.length;b+=1)if(a=f(this[b]),e=a.getLayerGroup(d))for(k=0;k<e.length;k+=1)h=e[k],a.stopLayer(h,c);return this};(function(d){var c;for(c=0;c<d.length;c+=1)f.fx.step[d[c]]=Va})("color backgroundColor borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor fillStyle outlineColor strokeStyle shadowColor".split(" "));Y.touchEvents={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"};Y.mouseEvents=
{touchstart:"mousedown",touchend:"mouseup",touchmove:"mousemove"};(function(d){var c;for(c=0;c<d.length;c+=1)Xa(d[c])})("click dblclick mousedown mouseup mousemove mouseover mouseout touchstart touchmove touchend".split(" "));f.event.fix=function(d){var c,a;d=Za.call(f.event,d);if(c=d.originalEvent)if(a=c.changedTouches,d.pageX!==r&&d.offsetX===r){if(c=f(d.currentTarget).offset())d.offsetX=d.pageX-c.left,d.offsetY=d.pageY-c.top}else a&&(c=f(d.currentTarget).offset())&&(d.offsetX=a[0].pageX-c.left,
d.offsetY=a[0].pageY-c.top);return d};Y.drawings={arc:"drawArc",bezier:"drawBezier",ellipse:"drawEllipse","function":"draw",image:"drawImage",line:"drawLine",path:"drawPath",polygon:"drawPolygon",slice:"drawSlice",quadratic:"drawQuadratic",rectangle:"drawRect",text:"drawText",vector:"drawVector"};f.fn.draw=function c(a){var b,e,h=new J(a);if(Y.drawings[h.type])this[Y.drawings[h.type]](a);else for(b=0;b<this.length;b+=1)if(f(this[b]),e=K(this[b]))h=new J(a),P(this[b],h,a,c),h.visible&&h.fn&&h.fn.call(this[b],
e,h);return this};f.fn.clearCanvas=function a(b){var e,h,k=new J(b);for(e=0;e<this.length;e+=1)if(h=K(this[e]))k.width===g||k.height===g?(h.save(),h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,this[e].width,this[e].height),h.restore()):(P(this[e],k,b,a),S(this[e],h,k,k.width,k.height),h.clearRect(k.x-k.width/2,k.y-k.height/2,k.width,k.height),k._transformed&&h.restore());return this};f.fn.saveCanvas=function b(e){var h,k,f,g,t;for(h=0;h<this.length;h+=1)if(k=K(this[h]))for(g=D(this[h]),f=new J(e),P(this[h],
f,e,b),t=0;t<f.count;t+=1)fa(k,g);return this};f.fn.restoreCanvas=function e(h){var k,f,g,t,E;for(k=0;k<this.length;k+=1)if(f=K(this[k]))for(t=D(this[k]),g=new J(h),P(this[k],g,h,e),E=0;E<g.count;E+=1){var F=f,y=t;0===y.savedTransforms.length?y.transforms=la(oa):(F.restore(),y.transforms=y.savedTransforms.pop())}return this};f.fn.rotateCanvas=function h(f){var g,B,t,E;for(g=0;g<this.length;g+=1)if(B=K(this[g]))E=D(this[g]),t=new J(f),P(this[g],t,f,h),t.autosave&&fa(B,E),za(B,t,E.transforms);return this};
f.fn.scaleCanvas=function k(f){var g,t,E,F;for(g=0;g<this.length;g+=1)if(t=K(this[g]))F=D(this[g]),E=new J(f),P(this[g],E,f,k),E.autosave&&fa(t,F),Aa(t,E,F.transforms);return this};f.fn.translateCanvas=function L(f){var g,E,F,y;for(g=0;g<this.length;g+=1)if(E=K(this[g]))y=D(this[g]),F=new J(f),P(this[g],F,f,L),F.autosave&&fa(E,y),Ba(E,F,y.transforms);return this};f.fn.drawRect=function B(f){var g,F,y,u,p,C,m,A;for(g=0;g<this.length;g+=1)if(F=K(this[g]))y=new J(f),P(this[g],y,f,B),y.visible&&(T(this[g],
F,y),S(this[g],F,y,y.width,y.height),F.beginPath(),u=y.x-y.width/2,p=y.y-y.height/2,(A=y.cornerRadius)?(C=y.x+y.width/2,m=y.y+y.height/2,0>C-u-2*A&&(A=(C-u)/2),0>m-p-2*A&&(A=(m-p)/2),F.moveTo(u+A,p),F.lineTo(C-A,p),F.arc(C-A,p+A,A,3*H/2,2*H,z),F.lineTo(C,m-A),F.arc(C-A,m-A,A,0,H/2,z),F.lineTo(u+A,m),F.arc(u+A,m-A,A,H/2,H,z),F.lineTo(u,p+A),F.arc(u+A,p+A,A,H,3*H/2,z),y.closed=w):F.rect(u,p,y.width,y.height),U(this[g],F,y),X(this[g],F,y));return this};f.fn.drawArc=function t(f){var g,y,u;for(g=0;g<
this.length;g+=1)if(y=K(this[g]))u=new J(f),P(this[g],u,f,t),u.visible&&(T(this[g],y,u),S(this[g],y,u,2*u.radius),y.beginPath(),Ia(this[g],y,u,u),U(this[g],y,u),X(this[g],y,u));return this};f.fn.drawEllipse=function E(f){var g,u,p,C,m;for(g=0;g<this.length;g+=1)if(u=K(this[g]))p=new J(f),P(this[g],p,f,E),p.visible&&(T(this[g],u,p),S(this[g],u,p,p.width,p.height),C=4/3*p.width,m=p.height,u.beginPath(),u.moveTo(p.x,p.y-m/2),u.bezierCurveTo(p.x-C/2,p.y-m/2,p.x-C/2,p.y+m/2,p.x,p.y+m/2),u.bezierCurveTo(p.x+
C/2,p.y+m/2,p.x+C/2,p.y-m/2,p.x,p.y-m/2),U(this[g],u,p),p.closed=w,X(this[g],u,p));return this};f.fn.drawPolygon=function F(g){var f,p,C,m,A,M,G,v,n,l;for(f=0;f<this.length;f+=1)if(p=K(this[f]))if(C=new J(g),P(this[f],C,g,F),C.visible){T(this[f],p,C);S(this[f],p,C,2*C.radius);A=2*H/C.sides;M=A/2;m=M+H/2;G=C.radius*N(M);p.beginPath();for(l=0;l<C.sides;l+=1)v=C.x+C.radius*N(m),n=C.y+C.radius*R(m),p.lineTo(v,n),C.concavity&&(v=C.x+(G+-G*C.concavity)*N(m+M),n=C.y+(G+-G*C.concavity)*R(m+M),p.lineTo(v,
n)),m+=A;U(this[f],p,C);C.closed=w;X(this[f],p,C)}return this};f.fn.drawSlice=function y(g){var p,C,m,A,M;for(p=0;p<this.length;p+=1)if(f(this[p]),C=K(this[p]))m=new J(g),P(this[p],m,g,y),m.visible&&(T(this[p],C,m),S(this[p],C,m,2*m.radius),m.start*=m._toRad,m.end*=m._toRad,m.start-=H/2,m.end-=H/2,m.start=Ha(m.start),m.end=Ha(m.end),m.end<m.start&&(m.end+=2*H),A=(m.start+m.end)/2,M=m.radius*m.spread*N(A),A=m.radius*m.spread*R(A),m.x+=M,m.y+=A,C.beginPath(),C.arc(m.x,m.y,m.radius,m.start,m.end,m.ccw),
C.lineTo(m.x,m.y),U(this[p],C,m),m.closed=w,X(this[p],C,m));return this};f.fn.drawLine=function u(f){var g,m,A;for(g=0;g<this.length;g+=1)if(m=K(this[g]))A=new J(f),P(this[g],A,f,u),A.visible&&(T(this[g],m,A),S(this[g],m,A),m.beginPath(),Ka(this[g],m,A,A),U(this[g],m,A),X(this[g],m,A));return this};f.fn.drawQuadratic=function p(g){var f,A,M;for(f=0;f<this.length;f+=1)if(A=K(this[f]))M=new J(g),P(this[f],M,g,p),M.visible&&(T(this[f],A,M),S(this[f],A,M),A.beginPath(),La(this[f],A,M,M),U(this[f],A,M),
X(this[f],A,M));return this};f.fn.drawBezier=function C(f){var g,M,G;for(g=0;g<this.length;g+=1)if(M=K(this[g]))G=new J(f),P(this[g],G,f,C),G.visible&&(T(this[g],M,G),S(this[g],M,G),M.beginPath(),Ma(this[g],M,G,G),U(this[g],M,G),X(this[g],M,G));return this};f.fn.drawVector=function m(g){var f,G,v;for(f=0;f<this.length;f+=1)if(G=K(this[f]))v=new J(g),P(this[f],v,g,m),v.visible&&(T(this[f],G,v),S(this[f],G,v),G.beginPath(),Pa(this[f],G,v,v),U(this[f],G,v),X(this[f],G,v));return this};f.fn.drawPath=
function A(f){var g,v,n,l,x;for(g=0;g<this.length;g+=1)if(v=K(this[g]))if(n=new J(f),P(this[g],n,f,A),n.visible){T(this[g],v,n);S(this[g],v,n);v.beginPath();for(l=1;w;)if(x=n["p"+l],x!==r)x=new J(x),"line"===x.type?Ka(this[g],v,n,x):"quadratic"===x.type?La(this[g],v,n,x):"bezier"===x.type?Ma(this[g],v,n,x):"vector"===x.type?Pa(this[g],v,n,x):"arc"===x.type&&Ia(this[g],v,n,x),l+=1;else break;U(this[g],v,n);X(this[g],v,n)}return this};f.fn.drawText=function M(G){var v,n,l,x,W,s,r;for(v=0;v<this.length;v+=
1)if(f(this[v]),n=K(this[v]))if(l=new J(G),x=P(this[v],l,G,M),l.visible){T(this[v],n,l);n.textBaseline=l.baseline;n.textAlign=l.align;Qa(n,l);W=l.maxWidth!==g?Sa(n,l):l.text.toString().split("\n");Ra(this[v],n,l,W);x&&(x.width=l.width,x.height=l.height);S(this[v],n,l,l.width,l.height);s=l.x;"left"===l.align?l.respectAlign?l.x+=l.width/2:s-=l.width/2:"right"===l.align&&(l.respectAlign?l.x-=l.width/2:s+=l.width/2);for(x=0;x<W.length;x+=1)n.shadowColor=l.shadowColor,r=l.y+x*l.height/W.length-(W.length-
1)*l.height/W.length/2,n.fillText(W[x],s,r),"transparent"!==l.fillStyle&&(n.shadowColor="transparent"),n.strokeText(W[x],s,r);r=0;"top"===l.baseline?r+=l.height/2:"bottom"===l.baseline&&(r-=l.height/2);l._event&&(n.beginPath(),n.rect(l.x-l.width/2,l.y-l.height/2+r,l.width,l.height),U(this[v],n,l),n.closePath());l._transformed&&n.restore()}ba.propCache=l;return this};f.fn.measureText=function(g){var f,v;f=this.getLayer(g);if(!f||f&&!f._layer)f=new J(g);if(g=K(this[0]))Qa(g,f),v=Sa(g,f),Ra(this[0],
g,f,v);return f};f.fn.drawImage=function G(v){function n(l,n,s,q,v){return function(){var x=f(l);T(l,n,q);q.width===g&&q.sWidth===g&&(q.width=q.sWidth=I.width);q.height===g&&q.sHeight===g&&(q.height=q.sHeight=I.height);v&&(v.width=q.width,v.height=q.height);q.sWidth!==g&&q.sHeight!==g&&q.sx!==g&&q.sy!==g?(q.width===g&&(q.width=q.sWidth),q.height===g&&(q.height=q.sHeight),q.cropFromCenter||(q.sx+=q.sWidth/2,q.sy+=q.sHeight/2),0>q.sy-q.sHeight/2&&(q.sy=q.sHeight/2),q.sy+q.sHeight/2>I.height&&(q.sy=
I.height-q.sHeight/2),0>q.sx-q.sWidth/2&&(q.sx=q.sWidth/2),q.sx+q.sWidth/2>I.width&&(q.sx=I.width-q.sWidth/2),S(l,n,q,q.width,q.height),n.drawImage(I,q.sx-q.sWidth/2,q.sy-q.sHeight/2,q.sWidth,q.sHeight,q.x-q.width/2,q.y-q.height/2,q.width,q.height)):(S(l,n,q,q.width,q.height),n.drawImage(I,q.x-q.width/2,q.y-q.height/2,q.width,q.height));n.beginPath();n.rect(q.x-q.width/2,q.y-q.height/2,q.width,q.height);U(l,n,q);n.closePath();q._transformed&&n.restore();ya(n,s,q);q.layer?Q(x,s,v,"load"):q.load&&q.load.call(x[0],
v);q.layer&&(v._masks=s.transforms.masks.slice(0),q._next&&x.drawLayers({clear:z,resetFire:w,index:q._next}))}}var l,x,W,s,da,H,I,O,N,R=ba.imageCache;for(x=0;x<this.length;x+=1)if(l=this[x],W=K(this[x]))s=D(this[x]),da=new J(v),H=P(this[x],da,v,G),da.visible&&(N=da.source,O=N.getContext,N.src||O?I=N:N&&(R[N]!==r?I=R[N]:(I=new ua,I.src=N,R[N]=I)),I&&(I.complete||O?n(l,W,s,da,H)():(f(I).bind("load",n(l,W,s,da,H)),I.src=I.src)));return this};f.fn.createPattern=function(G){function v(){s=l.createPattern(r,
x.repeat);x.load&&x.load.call(n[0],s)}var n=this,l,x,r,s,w;(l=K(n[0]))?(x=new J(G),w=x.source,ca(w)?(r=f("<canvas />")[0],r.width=x.width,r.height=x.height,G=K(r),w.call(r,G),v()):(G=w.getContext,w.src||G?r=w:(r=new ua,r.src=w),r.complete||G?v():(f(r).bind("load",v),r.src=r.src))):s=g;return s};f.fn.createGradient=function(f){var v,n=[],l,x,w,s,z,D,I;f=new J(f);if(v=K(this[0])){f.x1=f.x1||0;f.y1=f.y1||0;f.x2=f.x2||0;f.y2=f.y2||0;v=f.r1!==g&&f.r2!==g?v.createRadialGradient(f.x1,f.y1,f.r1,f.x2,f.y2,
f.r2):v.createLinearGradient(f.x1,f.y1,f.x2,f.y2);for(s=1;f["c"+s]!==r;s+=1)f["s"+s]!==r?n.push(f["s"+s]):n.push(g);l=n.length;n[0]===g&&(n[0]=0);n[l-1]===g&&(n[l-1]=1);for(s=0;s<l;s+=1){if(n[s]!==g){D=1;I=0;x=n[s];for(z=s+1;z<l;z+=1)if(n[z]!==g){w=n[z];break}else D+=1;x>w&&(n[z]=n[s])}else n[s]===g&&(I+=1,n[s]=x+(w-x)/D*I);v.addColorStop(n[s],f["c"+(s+1)])}}else v=g;return v};f.fn.setPixels=function v(f){var l,x,r,s,w,z,I,D,H;for(x=0;x<this.length;x+=1)if(l=this[x],r=K(l)){s=new J(f);P(l,s,f,v);
S(this[x],r,s,s.width,s.height);if(s.width===g||s.height===g)s.width=l.width,s.height=l.height,s.x=s.width/2,s.y=s.height/2;if(0!==s.width&&0!==s.height){z=r.getImageData(s.x-s.width/2,s.y-s.height/2,s.width,s.height);I=z.data;H=I.length;if(s.each)for(D=0;D<H;D+=4)w={r:I[D],g:I[D+1],b:I[D+2],a:I[D+3]},s.each.call(l,w,s),I[D]=w.r,I[D+1]=w.g,I[D+2]=w.b,I[D+3]=w.a;r.putImageData(z,s.x-s.width/2,s.y-s.height/2);r.restore()}}return this};f.fn.getCanvasImage=function(f,n){var l,x=g;0!==this.length&&(l=
this[0],l.toDataURL&&(n===r&&(n=1),x=l.toDataURL("image/"+f,n)));return x};f.fn.detectPixelRatio=function(g){var n,l,r,z,s,J,H;for(l=0;l<this.length;l+=1)n=this[l],f(this[l]),r=K(n),H=D(this[l]),H.scaled||(z=window.devicePixelRatio||1,s=r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1,z/=s,1!==z&&(s=n.width,J=n.height,n.width=s*z,n.height=J*z,n.style.width=s+"px",n.style.height=J+"px",r.scale(z,z)),H.pixelRatio=
z,H.scaled=w,g&&g.call(n,z));return this};O.clearCache=function(){for(var f in ba)ba.hasOwnProperty(f)&&(ba[f]={})};f.support.canvas=f("<canvas />")[0].getContext!==r;O.defaults=ma;O.prefs=$;O.setGlobalProps=T;O.transformShape=S;O.detectEvents=U;O.closePath=X;f.jCanvas=O})(jQuery,document,Image,Array,Math,parseFloat,console,!0,!1,null);
/*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};o.fn=o.prototype={jquery:n,constructor:o,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},o.extend=o.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||o.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(o.isPlainObject(d)||(e=o.isArray(d)))?(e?(e=!1,f=c&&o.isArray(c)?c:[]):f=c&&o.isPlainObject(c)?c:{},g[b]=o.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},o.extend({expando:"jQuery"+(n+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===o.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isPlainObject:function(a){if("object"!==o.type(a)||a.nodeType||o.isWindow(a))return!1;try{if(a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=o.trim(a),a&&(1===a.indexOf("use strict")?(b=m.createElement("script"),b.text=a,m.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":k.call(a)},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?o.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),o.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||o.guid++,f):void 0},now:Date.now,support:l}),o.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=o.type(a);return"function"===c||o.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="<select t=''><option selected=''></option></select>",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=jb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=kb(b);function nb(){}nb.prototype=d.filters=d.pseudos,d.setFilters=new nb;function ob(a,b){var c,e,f,g,h,i,j,k=x[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=Q.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?db.error(a):x(a,i).slice(0)}function pb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);o.find=t,o.expr=t.selectors,o.expr[":"]=o.expr.pseudos,o.unique=t.uniqueSort,o.text=t.getText,o.isXMLDoc=t.isXML,o.contains=t.contains;var u=o.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(o.isFunction(b))return o.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return o.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return o.filter(b,a,c);b=o.filter(b,a)}return o.grep(a,function(a){return g.call(b,a)>=0!==c})}o.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?o.find.matchesSelector(d,a)?[d]:[]:o.find.matches(a,o.grep(b,function(a){return 1===a.nodeType}))},o.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(o(a).filter(function(){for(b=0;c>b;b++)if(o.contains(e[b],this))return!0}));for(b=0;c>b;b++)o.find(a,e[b],d);return d=this.pushStack(c>1?o.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?o(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=o.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof o?b[0]:b,o.merge(this,o.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:m,!0)),v.test(c[1])&&o.isPlainObject(b))for(c in b)o.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=m.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=m,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):o.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(o):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),o.makeArray(a,this))};A.prototype=o.fn,y=o(m);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};o.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&o(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),o.fn.extend({has:function(a){var b=o(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(o.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?o(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&o.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?o.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(o(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(o.unique(o.merge(this.get(),o(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}o.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return o.dir(a,"parentNode")},parentsUntil:function(a,b,c){return o.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return o.dir(a,"nextSibling")},prevAll:function(a){return o.dir(a,"previousSibling")},nextUntil:function(a,b,c){return o.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return o.dir(a,"previousSibling",c)},siblings:function(a){return o.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return o.sibling(a.firstChild)},contents:function(a){return a.contentDocument||o.merge([],a.childNodes)}},function(a,b){o.fn[a]=function(c,d){var e=o.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=o.filter(d,e)),this.length>1&&(C[a]||o.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return o.each(a.match(E)||[],function(a,c){b[c]=!0}),b}o.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):o.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){o.each(b,function(b,c){var d=o.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&o.each(arguments,function(a,b){var c;while((c=o.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?o.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},o.extend({Deferred:function(a){var b=[["resolve","done",o.Callbacks("once memory"),"resolved"],["reject","fail",o.Callbacks("once memory"),"rejected"],["notify","progress",o.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return o.Deferred(function(c){o.each(b,function(b,f){var g=o.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&o.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?o.extend(a,d):d}},e={};return d.pipe=d.then,o.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&o.isFunction(a.promise)?e:0,g=1===f?a:o.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&o.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;o.fn.ready=function(a){return o.ready.promise().done(a),this},o.extend({isReady:!1,readyWait:1,holdReady:function(a){a?o.readyWait++:o.ready(!0)},ready:function(a){(a===!0?--o.readyWait:o.isReady)||(o.isReady=!0,a!==!0&&--o.readyWait>0||(H.resolveWith(m,[o]),o.fn.trigger&&o(m).trigger("ready").off("ready")))}});function I(){m.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),o.ready()}o.ready.promise=function(b){return H||(H=o.Deferred(),"complete"===m.readyState?setTimeout(o.ready):(m.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},o.ready.promise();var J=o.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===o.type(c)){e=!0;for(h in c)o.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,o.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(o(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};o.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=o.expando+Math.random()}K.uid=1,K.accepts=o.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,o.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(o.isEmptyObject(f))o.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,o.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{o.isArray(b)?d=b.concat(b.map(o.camelCase)):(e=o.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!o.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?o.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}o.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),o.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;
while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=o.camelCase(d.slice(5)),P(f,d,e[d]));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=o.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),o.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||o.isArray(c)?d=L.access(a,b,o.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=o.queue(a,b),d=c.length,e=c.shift(),f=o._queueHooks(a,b),g=function(){o.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:o.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),o.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?o.queue(this[0],a):void 0===b?this:this.each(function(){var c=o.queue(this,a,b);o._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&o.dequeue(this,a)})},dequeue:function(a){return this.each(function(){o.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=o.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===o.css(a,"display")||!o.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=m.createDocumentFragment(),b=a.appendChild(m.createElement("div"));b.innerHTML="<input type='radio' checked='checked' name='t'/>",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";l.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return m.activeElement}catch(a){}}o.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=o.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof o!==U&&o.event.triggered!==b.type?o.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n&&(l=o.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=o.event.special[n]||{},k=o.extend({type:n,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&o.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(n,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),o.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n){l=o.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||o.removeEvent(a,n,r.handle),delete i[n])}else for(n in i)o.event.remove(a,n+b[j],c,d,!0);o.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,p=[d||m],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||m,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+o.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[o.expando]?b:new o.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:o.makeArray(c,[b]),n=o.event.special[q]||{},e||!n.trigger||n.trigger.apply(d,c)!==!1)){if(!e&&!n.noBubble&&!o.isWindow(d)){for(i=n.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||m)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:n.bindType||q,l=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),l&&l.apply(g,c),l=k&&g[k],l&&l.apply&&o.acceptData(g)&&(b.result=l.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||n._default&&n._default.apply(p.pop(),c)!==!1||!o.acceptData(d)||k&&o.isFunction(d[q])&&!o.isWindow(d)&&(h=d[k],h&&(d[k]=null),o.event.triggered=q,d[q](),o.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=o.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=o.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=o.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((o.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?o(e,this).index(i)>=0:o.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||m,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[o.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new o.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=m),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&o.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return o.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=o.extend(new o.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?o.event.trigger(e,null,b):o.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},o.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},o.Event=function(a,b){return this instanceof o.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.getPreventDefault&&a.getPreventDefault()?Z:$):this.type=a,b&&o.extend(this,b),this.timeStamp=a&&a.timeStamp||o.now(),void(this[o.expando]=!0)):new o.Event(a,b)},o.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z,this.stopPropagation()}},o.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){o.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!o.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),l.focusinBubbles||o.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){o.event.simulate(b,a.target,o.event.fix(a),!0)};o.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),o.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return o().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=o.guid++)),this.each(function(){o.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,o(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){o.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){o.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?o.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return o.nodeName(a,"table")&&o.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)o.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=o.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&o.nodeName(a,b)?o.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}o.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=o.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||o.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,n=a.length;n>m;m++)if(e=a[m],e||0===e)if("object"===o.type(e))o.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;o.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===o.inArray(e,d))&&(i=o.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f,g,h=o.event.special,i=0;void 0!==(c=a[i]);i++){if(o.acceptData(c)&&(f=c[L.expando],f&&(b=L.cache[f]))){if(d=Object.keys(b.events||{}),d.length)for(g=0;void 0!==(e=d[g]);g++)h[e]?o.event.remove(c,e):o.removeEvent(c,e,b.handle);L.cache[f]&&delete L.cache[f]}delete M.cache[c[M.expando]]}}}),o.fn.extend({text:function(a){return J(this,function(a){return void 0===a?o.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?o.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||o.cleanData(ob(c)),c.parentNode&&(b&&o.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(o.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return o.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(o.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,o.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,n=k-1,p=a[0],q=o.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(c=o.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=o.map(ob(c,"script"),kb),g=f.length;k>j;j++)h=c,j!==n&&(h=o.clone(h,!0,!0),g&&o.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,o.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&o.contains(i,h)&&(h.src?o._evalUrl&&o._evalUrl(h.src):o.globalEval(h.textContent.replace(hb,"")))}return this}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){o.fn[a]=function(a){for(var c,d=[],e=o(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),o(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d=o(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:o.css(d[0],"display");return d.detach(),e}function tb(a){var b=m,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||o("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||o.contains(a.ownerDocument,a)||(g=o.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",e=m.documentElement,f=m.createElement("div"),g=m.createElement("div");g.style.backgroundClip="content-box",g.cloneNode(!0).style.backgroundClip="",l.clearCloneStyle="content-box"===g.style.backgroundClip,f.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",f.appendChild(g);function h(){g.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",e.appendChild(f);var d=a.getComputedStyle(g,null);b="1%"!==d.top,c="4px"===d.width,e.removeChild(f)}a.getComputedStyle&&o.extend(l,{pixelPosition:function(){return h(),b},boxSizingReliable:function(){return null==c&&h(),c},reliableMarginRight:function(){var b,c=g.appendChild(m.createElement("div"));return c.style.cssText=g.style.cssText=d,c.style.marginRight=c.style.width="0",g.style.width="1px",e.appendChild(f),b=!parseFloat(a.getComputedStyle(c,null).marginRight),e.removeChild(f),g.innerHTML="",b}})}(),o.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:0,fontWeight:400},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=o.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=o.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=o.css(a,"border"+R[f]+"Width",!0,e))):(g+=o.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=o.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===o.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(l.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):f[g]||(e=S(d),(c&&"none"!==c||!e)&&L.set(d,"olddisplay",e?c:o.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}o.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=o.camelCase(b),i=a.style;return b=o.cssProps[h]||(o.cssProps[h]=Fb(i,h)),g=o.cssHooks[b]||o.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(o.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||o.cssNumber[h]||(c+="px"),l.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]="",i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=o.camelCase(b);return b=o.cssProps[h]||(o.cssProps[h]=Fb(a.style,h)),g=o.cssHooks[b]||o.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||o.isNumeric(f)?f||0:e):e}}),o.each(["height","width"],function(a,b){o.cssHooks[b]={get:function(a,c,d){return c?0===a.offsetWidth&&zb.test(o.css(a,"display"))?o.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===o.css(a,"boxSizing",!1,e),e):0)}}}),o.cssHooks.marginRight=yb(l.reliableMarginRight,function(a,b){return b?o.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),o.each({margin:"",padding:"",border:"Width"},function(a,b){o.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(o.cssHooks[a+b].set=Gb)}),o.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(o.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=o.css(a,b[g],!1,d);return f}return void 0!==c?o.style(a,b,c):o.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?o(this).show():o(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}o.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(o.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?o.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=o.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){o.fx.step[a.prop]?o.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[o.cssProps[a.prop]]||o.cssHooks[a.prop])?o.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},o.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},o.fx=Kb.prototype.init,o.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(o.cssNumber[a]?"":"px"),g=(o.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(o.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,o.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=o.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k=this,l={},m=a.style,n=a.nodeType&&S(a),p=L.get(a,"fxshow");c.queue||(h=o._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,k.always(function(){k.always(function(){h.unqueued--,o.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],j=o.css(a,"display"),"none"===j&&(j=tb(a.nodeName)),"inline"===j&&"none"===o.css(a,"float")&&(m.display="inline-block")),c.overflow&&(m.overflow="hidden",k.always(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(n?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;n=!0}l[d]=p&&p[d]||o.style(a,d)}if(!o.isEmptyObject(l)){p?"hidden"in p&&(n=p.hidden):p=L.access(a,"fxshow",{}),f&&(p.hidden=!n),n?o(a).show():k.done(function(){o(a).hide()}),k.done(function(){var b;L.remove(a,"fxshow");for(b in l)o.style(a,b,l[b])});for(d in l)g=Ub(n?p[d]:0,d,k),d in p||(p[d]=g.start,n&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=o.camelCase(c),e=b[d],f=a[c],o.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=o.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=o.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:o.extend({},b),opts:o.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=o.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return o.map(k,Ub,j),o.isFunction(j.opts.start)&&j.opts.start.call(a,j),o.fx.timer(o.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}o.Animation=o.extend(Xb,{tweener:function(a,b){o.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),o.speed=function(a,b,c){var d=a&&"object"==typeof a?o.extend({},a):{complete:c||!c&&b||o.isFunction(a)&&a,duration:a,easing:c&&b||b&&!o.isFunction(b)&&b};return d.duration=o.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in o.fx.speeds?o.fx.speeds[d.duration]:o.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){o.isFunction(d.old)&&d.old.call(this),d.queue&&o.dequeue(this,d.queue)},d},o.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=o.isEmptyObject(a),f=o.speed(b,c,d),g=function(){var b=Xb(this,o.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=o.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&o.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=o.timers,g=d?d.length:0;for(c.finish=!0,o.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),o.each(["toggle","show","hide"],function(a,b){var c=o.fn[b];o.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),o.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){o.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),o.timers=[],o.fx.tick=function(){var a,b=0,c=o.timers;for(Lb=o.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||o.fx.stop(),Lb=void 0},o.fx.timer=function(a){o.timers.push(a),a()?o.fx.start():o.timers.pop()},o.fx.interval=13,o.fx.start=function(){Mb||(Mb=setInterval(o.fx.tick,o.fx.interval))},o.fx.stop=function(){clearInterval(Mb),Mb=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(a,b){return a=o.fx?o.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=m.createElement("input"),b=m.createElement("select"),c=b.appendChild(m.createElement("option"));a.type="checkbox",l.checkOn=""!==a.value,l.optSelected=c.selected,b.disabled=!0,l.optDisabled=!c.disabled,a=m.createElement("input"),a.value="t",a.type="radio",l.radioValue="t"===a.value}();var Yb,Zb,$b=o.expr.attrHandle;o.fn.extend({attr:function(a,b){return J(this,o.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){o.removeAttr(this,a)})}}),o.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?o.prop(a,b,c):(1===f&&o.isXMLDoc(a)||(b=b.toLowerCase(),d=o.attrHooks[b]||(o.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=o.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void o.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=o.propFix[c]||c,o.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!l.radioValue&&"radio"===b&&o.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?o.removeAttr(a,c):a.setAttribute(c,c),c}},o.each(o.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||o.find.attr;$b[b]=function(a,b,d){var e,f;
return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;o.fn.extend({prop:function(a,b){return J(this,o.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[o.propFix[a]||a]})}}),o.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!o.isXMLDoc(a),f&&(b=o.propFix[b]||b,e=o.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),l.optSelected||(o.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;o.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=o.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?o.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(o.isFunction(a)?function(c){o(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=o(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;o.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=o.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,o(this).val()):a,null==e?e="":"number"==typeof e?e+="":o.isArray(e)&&(e=o.map(e,function(a){return null==a?"":a+""})),b=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=o.valHooks[e.type]||o.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),o.extend({valHooks:{select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(l.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&o.nodeName(c.parentNode,"optgroup"))){if(b=o(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=o.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=o.inArray(o(d).val(),f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(a,b){return o.isArray(b)?a.checked=o.inArray(o(a).val(),b)>=0:void 0}},l.checkOn||(o.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),o.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){o.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),o.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=o.now(),dc=/\?/;o.parseJSON=function(a){return JSON.parse(a+"")},o.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&o.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=m.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(o.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,o.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=o.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&o.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":o.parseJSON,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,o.ajaxSettings),b):tc(o.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=o.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?o(l):o.event,n=o.Deferred(),p=o.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(n.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=o.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=o.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===o.active++&&o.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(o.lastModified[d]&&v.setRequestHeader("If-Modified-Since",o.lastModified[d]),o.etag[d]&&v.setRequestHeader("If-None-Match",o.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(o.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(o.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?n.resolveWith(l,[r,x,v]):n.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--o.active||o.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return o.get(a,b,c,"json")},getScript:function(a,b){return o.get(a,void 0,b,"script")}}),o.each(["get","post"],function(a,b){o[b]=function(a,c,d,e){return o.isFunction(c)&&(e=e||d,d=c,c=void 0),o.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){o.fn[b]=function(a){return this.on(b,a)}}),o._evalUrl=function(a){return o.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},o.fn.extend({wrapAll:function(a){var b;return o.isFunction(a)?this.each(function(b){o(this).wrapAll(a.call(this,b))}):(this[0]&&(b=o(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(o.isFunction(a)?function(b){o(this).wrapInner(a.call(this,b))}:function(){var b=o(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=o.isFunction(a);return this.each(function(c){o(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){o.nodeName(this,"body")||o(this).replaceWith(this.childNodes)}).end()}}),o.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},o.expr.filters.visible=function(a){return!o.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(o.isArray(b))o.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==o.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}o.param=function(a,b){var c,d=[],e=function(a,b){b=o.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=o.ajaxSettings&&o.ajaxSettings.traditional),o.isArray(a)||a.jquery&&!o.isPlainObject(a))o.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=o.prop(this,"elements");return a?o.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!o(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=o(this).val();return null==c?null:o.isArray(c)?o.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),o.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=o.ajaxSettings.xhr();a.ActiveXObject&&o(a).on("unload",function(){for(var a in Dc)Dc[a]()}),l.cors=!!Fc&&"withCredentials"in Fc,l.ajax=Fc=!!Fc,o.ajaxTransport(function(a){var b;return l.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort"),f.send(a.hasContent&&a.data||null)},abort:function(){b&&b()}}:void 0}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return o.globalEval(a),a}}}),o.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),o.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=o("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),m.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||o.expando+"_"+cc++;return this[a]=!0,a}}),o.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=o.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||o.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&o.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),o.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||m;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=o.buildFragment([a],b,e),e&&e.length&&o(e).remove(),o.merge([],d.childNodes))};var Ic=o.fn.load;o.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=a.slice(h),a=a.slice(0,h)),o.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&o.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?o("<div>").append(o.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},o.expr.filters.animated=function(a){return o.grep(o.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return o.isWindow(a)?a:9===a.nodeType&&a.defaultView}o.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=o.css(a,"position"),l=o(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=o.css(a,"top"),i=o.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),o.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},o.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){o.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,o.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===o.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),o.nodeName(a[0],"html")||(d=a.offset()),d.top+=o.css(a[0],"borderTopWidth",!0),d.left+=o.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-o.css(c,"marginTop",!0),left:b.left-d.left-o.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!o.nodeName(a,"html")&&"static"===o.css(a,"position"))a=a.offsetParent;return a||Jc})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;o.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),o.each(["top","left"],function(a,b){o.cssHooks[b]=yb(l.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?o(a).position()[b]+"px":c):void 0})}),o.each({Height:"height",Width:"width"},function(a,b){o.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){o.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return o.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?o.css(b,c,g):o.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),o.fn.size=function(){return this.length},o.fn.andSelf=o.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return o});var Lc=a.jQuery,Mc=a.$;return o.noConflict=function(b){return a.$===o&&(a.$=Mc),b&&a.jQuery===o&&(a.jQuery=Lc),o},typeof b===U&&(a.jQuery=a.$=o),o});
function jquery_list(list, msg, callback) {
var selectBoxContainer = $("#"+list);
//add the header box <div> to the list
selectBoxContainer.append("<div class='list_head'></div>");
//assign the default message to the list header
var selectBox = selectBoxContainer.find('.list_head');
selectBox.html(msg);
selectBoxContainer.attr('value',msg);
//process the list
var dropDown = selectBoxContainer.find('.list_view');
//console.log(dropDown);
//selectBoxContainer.append(dropDown.hide());
dropDown.hide();
dropDown.bind('show',function(){
selectBox.addClass('expanded');
dropDown.fadeIn();
}).bind('hide',function(){
selectBox.removeClass('expanded');
dropDown.fadeOut();
}).bind('toggle',function(){
if (selectBox.hasClass('expanded')) dropDown.trigger('hide');
else dropDown.trigger('show');
});
selectBox.click(function(){
dropDown.trigger('toggle');
return false;
});
$(document).click(function(){
dropDown.trigger('hide');
});
//process all the list elements
dropDown.find('li').each(function(i) {
var li = $(this);
li.click(function(){
selectBox.html(li.html());
selectBoxContainer.attr('value',li.html());
//selectBoxContainer.attr('value',i);
dropDown.trigger('hide');
//my function
callback("list",i);
return false;
});
});
}
\ No newline at end of file
/*
FILE NAME : lens_design.js
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
var medium = "air";
var x0=10;
var y0=10;
canvas_reference_scale = 200;
canvas_scale = 20;
var xO = 10*x0;
var yO = 200;
var e = Array();
var selected_elements = Array();
var epsilon = 0.0001;
var epsilon2 = 0.0001;
$(function(){
yO = $("#cnv1").height()/2;
console.log("Drawing axii");
draw_axii();
draw_reference_scale();
draw_scale();
$("#cnv1").on("click",function(){
deselect_all_elements();
});
//disable scroll over canvas and bind a new action
cnv_div = document.getElementById('cnv1_div');
if (cnv_div.addEventListener) cnv_div.addEventListener('DOMMouseScroll', wheelEvent, false);
cnv_div.onmousewheel = wheelEvent;
//ray_draw(0,0,0);
});
function element_add_button(){
//defaults
array_add_element(
0,//distance
1,//thickness
"BK7",//glass
"",//comment
8,//front height
15,//front curve radius
0,//front k
0,//front a1
0,//front a2
0,//front a3
0,//front a4
8,//back height
-1000,//back curve radius
0,//back k
0,//back a1
0,//back a2
0,//back a3
0 //back a4
);
}
function array_add_element(d,t,m,name,fh,fc,fk,fa1,fa2,fa3,fa4,bh,bc,bk,ba1,ba2,ba3,ba4){
console.log("Drawing at "+d);
var ind=e.length;
var id=0;
for(var i=0;i<e.length;i++){
if (e[i].id>=id) id = parseInt(e[i].id)+1;
}
e[ind] = new Object();
e[ind].id = parseInt(id);
e[ind].d = +d;
e[ind].t = +t;
e[ind].m = m;
e[ind].name = name;
e[ind].front = {
h: +fh,
c: +fc,
k: +fk,
a: [+fa1,+fa2,+fa3,+fa4]
};
e[ind].back = {
h: +bh,
c: +bc,
k: +bk,
a: [+ba1,+ba2,+ba3,+ba4]
};
canvas_draw_element(ind);
array_update_entries();
}
//and sort
function array_update_entries(){
//buffer object
var tmp = new Object();
//increment sorting and update selected_elements array
for(var i=0;i<e.length;i++){
for (var j=i+1;j<e.length;j++){
if (e[i].d>e[j].d) {
tmp = e[i];
e[i]=e[j];
e[j]= tmp;
}
}
}
table_update_all();
}
//do after sort - recreates a new table
function table_update_all(){
var html = "";
for(var i=0;i<e.length;i++){
html += "<table class='elements' id='element_"+e[i].id+"' value='"+e[i].id+"'>\n"
html += "\t<tr>\n";
html += "\t\t<td><button style='width:16px' id='number' class='number'>"+(i+1)+"</button></td>\n";
html += "\t\t<td><input type='text' id='distance' value='"+e[i].d+"'\></td>\n";
html += "\t\t<td><input type='text' id='thickness' value='"+e[i].t+"'\></td>\n";
html += "\t\t<td><input type='text' id='material' value='"+e[i].m+"'\></td>\n";
html += "\t\t<td><input type='text' id='name' value='"+e[i].name+"'\></td>\n";
//aperture stop if <0
if (e[i].front.h>=0) {
html += "\t<td><span style='font-size:0.8em;'>front</span></td>\n";
html += "\t\t<td><input type='text' id='front_height' value='"+e[i].front.h+"'\></td>\n";
html += "\t\t<td><input type='text' id='front_curve' value='"+e[i].front.c+"'\></td>\n";
html += "\t\t<td><input type='text' id='front_k' value='"+e[i].front.k+"'\></td>\n";
if (e[i].front.k!=0) {
html += "\t\t<td><input type='text' id='front_a1' value='"+e[i].front.a[0]+"'\></td>\n";
html += "\t\t<td><input type='text' id='front_a2' value='"+e[i].front.a[1]+"'\></td>\n";
html += "\t\t<td><input type='text' id='front_a3' value='"+e[i].front.a[2]+"'\></td>\n";
html += "\t\t<td><input type='text' id='front_a4' value='"+e[i].front.a[3]+"'\></td>\n";
}else{
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
}
html += "\t\t<td><button class='remove_button'><b>&ndash;</b></button></td>\n";
html += "\t</tr>\n";
html += "\t<tr>\n";
html += "\t<td></td>\n";
html += "\t<td></td>\n";
html += "\t<td></td>\n";
html += "\t<td></td>\n";
html += "\t<td></td>\n";
html += "\t<td><span style='font-size:0.8em;'>back</span></td>\n";
html += "\t<td><input type='text' id='back_height' value='"+e[i].back.h+"'\></td>\n";
html += "\t<td><input type='text' id='back_curve' value='"+e[i].back.c+"'\></td>\n";
html += "\t<td><input type='text' id='back_k' value='"+e[i].back.k+"'\></td>\n";
if (e[i].back.k!=0) {
html += "\t\t<td><input type='text' id='back_a1' value='"+e[i].back.a[0]+"'\></td>\n";
html += "\t\t<td><input type='text' id='back_a2' value='"+e[i].back.a[1]+"'\></td>\n";
html += "\t\t<td><input type='text' id='back_a3' value='"+e[i].back.a[2]+"'\></td>\n";
html += "\t\t<td><input type='text' id='back_a4' value='"+e[i].back.a[3]+"'\></td>\n";
}else{
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
}
}else{//aperture case
html += "\t<td width=24 ></td>\n";
html += "\t\t<td><input type='text' id='front_height' value='"+e[i].front.h+"'\></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=100 ></td>\n";
html += "\t\t<td width=102 ></td>\n";
html += "\t\t<td><button class='remove_button'><b>&ndash;</b></button></td>\n";
}
html += "\t</tr>\n";
html += "\t</table>\n";
}
$("#elements_table").html(html);
//rebind events
//unbind otherwise events would stack - don't want unique id's
$(".remove_button").unbind("click");
$(".remove_button").click(function(){
array_remove_element($(this).parent().parent().parent().parent().attr("value"));
});
//bind onchange
for(var i=0;i<e.length;i++){
$("#element_"+e[i].id).find("#distance").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#thickness").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#material").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#name").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_height").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_curve").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_k").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_a1").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_a2").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_a3").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#front_a4").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_height").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_curve").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_k").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_a1").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_a2").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_a3").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#back_a4").change(function(){element_onchange_redraw($(this).parent().parent().parent().parent().attr("value"));});
$("#element_"+e[i].id).find("#number").click(function(event){
//enable_deselect=false;
var val = +$(this).parent().parent().parent().parent().attr("value");
console.log(val);
element_toggle(val);
if (!event.ctrlKey) {
exception_element = val;
enable_deselect = true;
deselect_all_elements();
}
});
}
//need to update selected_elements array
//restore seleсted, multiple selection possible
for(var i=0;i<selected_elements.length;i++){
$("#element_"+selected_elements[i]).css({background:"rgba(20,100,255,0.5)"});
}
}
var drag_happened = false;
var exception_element = -1;
var enable_deselect = true;
var enable_mouseup = false;
function canvas_draw_element(i){
//console.log(e[i]);
var obj = {
layer: true,
groups: ['elements'],
name: "element_"+e[i].id,
value: e[i].id,
draggable: true,
bringToFront: true,
mousedown: function(layer){
enable_mouseup = true;
enable_deselect = false;
},
drag: function(layer){
layer.y=layer.y-layer.dy;
exception_element = layer.value;
//$("#element_"+layer.value).find("#distance").val( Math.round(((+layer.x)-xO)/canvas_scale*1000)/1000);
for(var k=0;k<e.length;k++){
if (e[k].id==exception_element){
e[k].d = Math.round(((+layer.x)-xO)/canvas_scale*1000)/1000;
}
}
array_update_entries();
if (event.ctrlKey) elements_redraw(layer.dx,0);
},
dragstart: function(layer){
drag_happened = true;
element_select(layer.value);
if (!event.ctrlKey) {
exception_element = layer.value;
enable_deselect = true;
deselect_all_elements();
enable_deselect = false;
}
},
mouseup: function(layer){
if (enable_mouseup){
if (!drag_happened) {
element_toggle(layer.value);
if (!event.ctrlKey) {
exception_element = layer.value;
enable_deselect = true;
deselect_all_elements();
enable_deselect = false;
}
}
drag_happened = false;
enable_mouseup = false;
}
},
strokeStyle: "rgba(0,0,0,1)",
fillStyle: "rgba(130,180,255,1)",
opacity: 0.5,
strokeWidth: 0.2,
cornerRadius: 0
};
var fc_sign = (+e[i].front.c<0)?-1:1;
var fc_r_px = Math.abs(e[i].front.c*canvas_scale);
var bc_sign = (+e[i].back.c<0)?-1:1;
var bc_r_px = Math.abs(e[i].back.c*canvas_scale);
var distance_px = +xO+(+e[i].d)*canvas_scale;
var thickness_px = e[i].t*canvas_scale;
var fheight_px = e[i].front.h*canvas_scale;
var bheight_px = e[i].back.h*canvas_scale;
var mheight_px = Math.max(fheight_px,bheight_px);
//important line
obj["x"] = distance_px;
if (e[i].front.h<0) {
//!!!APERTURE STOP!!!
obj["fillStyle"]="rgba(0,0,0,1)",
obj["p1"]=new Object();
obj["p1"].type='line';
obj["p1"].x1=0;
obj["p1"].y1=-fheight_px/2+yO;
obj["p1"].x2=-5;
obj["p1"].y2=-fheight_px/2+50+yO;
obj["p1"].x3=5;
obj["p1"].y3=-fheight_px/2+50+yO;
obj["p2"]=new Object();
obj["p2"].type='line';
obj["p2"].x1=0;
obj["p2"].y1=fheight_px/2+yO;
obj["p2"].x2=-5;
obj["p2"].y2=fheight_px/2-50+yO;
obj["p2"].x3=5;
obj["p2"].y3=fheight_px/2-50+yO;
$("#cnv1").drawPath(obj);
e[i].t = "";
e[i].front.c = "";
e[i].back.c = "";
e[i].m = "";
}else{
//!!!SOME CURVED ELEMENT!!!
var tmp_x = 0;
var tmp_y = 0;
var tmp_break = false;
var tmp_arr_fc = new Array();
var tmp_arr_bc = new Array();
//get front and back curves points varying y gently
for(var j=0;j<=mheight_px/2;j++){
tmp_y=j;
//tmp_x_fc=fc_sign*fc_r_px-fc_sign*Math.sqrt(fc_r_px*fc_r_px-tmp_y*tmp_y);
//tmp_x_bc=bc_sign*bc_r_px-bc_sign*Math.sqrt(bc_r_px*bc_r_px-tmp_y*tmp_y);
//in the layer we count from zero, so d=0
//calcs are in pixels!
if (tmp_y<=fheight_px/2) tmp_x_fc=canvas_scale*find_surf_point(tmp_y/canvas_scale,0,e[i].front);
if (tmp_y<=bheight_px/2) tmp_x_bc=canvas_scale*find_surf_point(tmp_y/canvas_scale,0,e[i].back);
if(tmp_x_fc>=(tmp_x_bc+thickness_px)) {
tmp_break = true;
}
tmp_arr_fc[tmp_y]=tmp_x_fc;
tmp_arr_bc[tmp_y]=tmp_x_bc;
if (tmp_break){
tmp_break=true;
j++;
break;
}
}
var N = j;
//console.log("That N is: "+N);
var apax = new Array();
var apay = new Array();
//reorder!
for(var j=0;j<=N;j++){
apax[(N-j)]=tmp_arr_fc[j];
apay[(N-j)]=-j+yO;
apax[(N+j)]=tmp_arr_fc[j];
apay[(N+j)]=j+yO;
apax[(3*N-j)]=tmp_arr_bc[j]+thickness_px;
apay[(3*N-j)]=j+yO;
apax[(3*N+j)]=tmp_arr_bc[j]+thickness_px;
apay[(3*N+j)]=-j+yO;
}
for(var j=1;j<4*N;j++){
//console.log(i+" "+apax[i]+" "+apay[i]);
obj["x"+j]=apax[j];
obj["y"+j]=apay[j];
}
$("#cnv1").drawLine(obj);
}
}
function array_remove_element(id){
console.log(id);
for (var i=0;i<e.length;i++) {
if (e[i].id==id) {
e.splice(i,1);//not working in IE7/8?
table_remove_element(id);
break;
}
}
}
function table_remove_element(id){
console.log("Removing table entry");
deselect_all_elements();
$("#element_"+id).remove();
$("#cnv1").removeLayer("element_"+id).drawLayers();
array_update_entries();
//table_update_entries();
}
function element_onchange_redraw(id){
console.log("Changing: layer "+id);
//layer = $("#cnv1").getLayer("element_"+id);
//layer.x = 0;
var tmp_d=+$("#element_"+id).find("#distance").val();
var tmp_t=+$("#element_"+id).find("#thickness").val();
var tmp_m=$("#element_"+id).find("#material").val();
var tmp_name=$("#element_"+id).find("#name").val();
var tmp_fh=+$("#element_"+id).find("#front_height").val();
var tmp_fc=+$("#element_"+id).find("#front_curve").val();
var tmp_fk=+$("#element_"+id).find("#front_k").val();
var tmp_fa1=+$("#element_"+id).find("#front_a1").val();
var tmp_fa2=+$("#element_"+id).find("#front_a2").val();
var tmp_fa3=+$("#element_"+id).find("#front_a3").val();
var tmp_fa4=+$("#element_"+id).find("#front_a4").val();
var tmp_bh=+$("#element_"+id).find("#back_height").val();
var tmp_bc=+$("#element_"+id).find("#back_curve").val();
var tmp_bk=+$("#element_"+id).find("#back_k").val();
var tmp_ba1=+$("#element_"+id).find("#back_a1").val();
var tmp_ba2=+$("#element_"+id).find("#back_a2").val();
var tmp_ba3=+$("#element_"+id).find("#back_a3").val();
var tmp_ba4=+$("#element_"+id).find("#back_a4").val();
//$("#cnv1").drawLayers();
$("#cnv1").removeLayer("element_"+id).drawLayers();
for(var i=0;i<e.length;i++){
if(e[i].id==id){
e[i].d=tmp_d;
e[i].t=tmp_t;
e[i].m=tmp_m;
e[i].name=tmp_name;
e[i].front.h=tmp_fh;
e[i].front.k=tmp_fk;
e[i].front.c=tmp_fc;
e[i].front.a[0]=(!isNaN(tmp_fa1)?tmp_fa1:0);
e[i].front.a[1]=(!isNaN(tmp_fa2)?tmp_fa2:0);
e[i].front.a[2]=(!isNaN(tmp_fa3)?tmp_fa3:0);
e[i].front.a[3]=(!isNaN(tmp_fa4)?tmp_fa4:0);
e[i].back.h=tmp_bh;
e[i].back.k=tmp_bk;
e[i].back.c=tmp_bc;
e[i].back.a[0]=(!isNaN(tmp_ba1)?tmp_ba1:0);
e[i].back.a[1]=(!isNaN(tmp_ba2)?tmp_ba2:0);
e[i].back.a[2]=(!isNaN(tmp_ba3)?tmp_ba3:0);
e[i].back.a[3]=(!isNaN(tmp_ba4)?tmp_ba4:0);
canvas_draw_element(i);
break;
}
}
table_update_all();
}
function element_select(id){
//get layer
var layer = $("#cnv1").getLayer("element_"+id);
//returns -1 if not in the array (=not selected)
var tmp = selected_elements.indexOf(id);
if (tmp==-1){
//no need to update the 'e' array
//add to selected_elements array
selected_elements.push(id);
//mark table entry
$("#element_"+id).css({background:"rgba(20,100,255,0.5)"});
//mark lens
//layer.fillStyle = "rgba(20,100,255,0.5)";
layer.opacity = 0.7;
$("#cnv1").drawLayers();
}
}
function element_deselect(id){
//get layer
var layer = $("#cnv1").getLayer("element_"+id);
//returns something else than -1 if in the array (selected)
var tmp = selected_elements.indexOf(id);
if (tmp!=-1) {
//no need to update the 'e' array
//remove from selected_elements array
selected_elements.splice(tmp,1);
//unmark table entry
$("#element_"+id).css({background:"rgba(20,100,255,0.0)"});
//unmark lens
//layer.fillStyle = "rgba(130,180,255,0.5)";
layer.opacity = 0.4;
$("#cnv1").drawLayers();
}
}
function element_toggle(id){
//layer.value same as id
tmp = selected_elements.indexOf(id);
if (tmp==-1) {
element_select(id);
}else{
element_deselect(id);
}
}
function deselect_all_elements(){
//deselect all except some or none elements if allowed
if (enable_deselect){
ls = $("#cnv1").getLayerGroup('elements');
if(typeof ls!=='undefined') {
for(i=0;i<ls.length;i++){
if (ls[i].value!=exception_element) element_deselect(ls[i].value);
}
}
}
exception_element = -1;
enable_deselect = true;
}
function elements_redraw(shiftx,shifty){
for (var i=0;i<selected_elements.length;i++){
if (selected_elements[i]!=exception_element) {
element_redraw(selected_elements[i],shiftx,shifty);
}
}
}
function element_redraw(index,shiftx,shifty){
//redrawing
layer = $("#cnv1").getLayer("element_"+index);
layer.x += shiftx;
//$("#cnv1").drawLayers();
//changing numbers
for(var k=0;k<e.length;k++){
if (e[k].id==index){
//here's a correct line
e[k].d = Math.round(((+layer.x)-xO)/canvas_scale*1000)/1000;
break;
}
}
array_update_entries();
}
function wheelEvent(event){
shiftKey= (event.shiftKey==1);
var delta = 0;
if (!event) event = window.event; // IE
if (event.wheelDelta) { //IE+Opera
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) { // Mozilla
if (shiftKey) delta = -event.detail;
else delta = -event.detail/3;
}
if (delta)
handleWheel(event,delta,shiftKey);
if (event.preventDefault)
event.preventDefault();
}
function handleWheel(event,delta,shiftKey) {
if (shiftKey) delta *= -1;
else delta *= -10;
elements_redraw(delta,0);
$("#cnv1").drawLayers();
}
function rays_draw(){
var x = (+e[e.length-1].d+e[e.length-1].t);
var y = +$("#rays_imhh").val();
var alpha = 0;//degrees
var dalpha = 2;//degrees
var old_cv = 0;
//find chief ray!
$("#cnv1").removeLayerGroup('rays').drawLayers();
//ray_draw("chief1",c1[0],c1[1],c1[2],$("#rays_color").val());
//find marginal ray
//var m1=find_aperture_stop_ray(x,0,alpha,1,dalpha,old_cv,100);
//ray_draw("margi0",m1[0],m1[1],0,$("#rays_color").val());
//ray_draw("margi1",m1[0],m1[1],m1[2],$("#rays_color").val());
//ray_draw("margi2",m1[0],m1[1],-m1[2],$("#rays_color").val());
var n = $("#rays_n").val();
//step1!
var hh1 = find_marginal_ray_half_height(0,0,0,0.1,old_cv,100);
var c1 = find_aperture_stop_ray(x,y,alpha,0,dalpha,old_cv,100);
var step = +2*hh1/(n-1);
if (n==1) {
ray_draw("center_"+0,0,0,0,$("#rays_color").val());
ray_draw("slant_"+0,c1[0],c1[1],c1[2],$("#rays_color").val());
}else{
for(var i=0;i<n;i++){
ray_draw("center_"+i,0,(-hh1+step*i),0,$("#rays_color").val());
ray_draw("slant_"+i,c1[0],c1[1]-hh1+step*i,c1[2],$("#rays_color").val());
}
}
//step2!
//ray_draw("some_chief_ray" ,c1[0],c1[1],c1[2],$("#rays_color").val());
}
function rays_draw2(){
$("#cnv1").removeLayerGroup('rays').drawLayers();
var n = $("#rays_n").val();
var step = (+$("#rays_width").val()/Math.cos(Math.PI/180*$("#rays_angle").val()))/(n-1);
for (var i=0;i<n;i++){
//$("#rays_y").val();
ray_draw("ray"+i,$("#rays_x").val(),(+$("#rays_y").val()+step*(n-1)/2-step*i),$("#rays_angle").val(),$("#rays_color").val());
//ray_draw("ray"+i,$("#rays_x").val(),20,$("#rays_angle").val(),$("#rays_color").val());
}
}
function ray_draw(name,x,y,angle,color){
//$("#cnv1").removeLayer(name).drawLayers();
console.log(name+" "+x+" "+y+" "+angle);
var obj = {
layer: true,
name: name,
groups: ['rays'],
opacity: 0.4,
strokeStyle: color,
strokeWidth: 1.0
}
var n = 1.7;
var tmp_point = Array();
var ray_angle = angle*Math.PI/180;
var ray_x = x;
var ray_y = y;
var ray_k = Math.tan(ray_angle);
//find location
for(var i=0;i<e.length;i++){
//console.log("Locating!");
if (ray_x<=+e[i].d||ray_x<(+e[i].d+e[i].t)) {
if (ray_x<=+e[i].d) console.log("The ray is to the left of "+i+" lens");
else console.log("The ray is 'inside' of "+i+" lens");
break;
}
}
//i is the closest lens index
var path="";
var npi = 1;
//trace forward!!!
/////////////////////////////////////////////////////////////////////////////////////////////////////////
path = "p1";
obj[path]=new Object();
obj[path].type='line';
tmp_point = [ray_x,ray_y,ray_k];
obj[path]["x1"]= cx(tmp_point[0]);
obj[path]["y1"]= cy(tmp_point[1]);
npi = 2;//Next Point Index
for(var j=0;j<(e.length-i);j++){
//console.log(j);
if (e[i+j].front.h>0){
n=Glass[e[i+j].m.toUpperCase()].n;
tmp_point = find_ray_surf_crosspoint(n,tmp_point[0],tmp_point[1],tmp_point[2],e[i+j].d,0,e[i+j].d,e[i+j].front);
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
console.log("x"+npi+" x:"+tmp_point[0]+" y:"+tmp_point[1]);
tmp_point = find_ray_surf_crosspoint(1/n,tmp_point[0],tmp_point[1],tmp_point[2],(e[i+j].d+e[i+j].t),0,(e[i+j].d+e[i+j].t),e[i+j].back);
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
console.log("x"+npi+" x:"+tmp_point[0]+" y:"+tmp_point[1]);
}else{
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
}
}
path = "p2";
obj[path]=new Object();
obj[path].type='line';
tmp_point = [ray_x,ray_y,ray_k];
obj[path]["x1"]= cx(tmp_point[0]);
obj[path]["y1"]= cy(tmp_point[1]);
npi = 2;
//tracing backward!
console.log("tracing backwards");
i--;//get index of element to the left
for(var k=0;k<=i;k++){
if (e[i-k].back.h>0){
n=Glass[e[i-k].m.toUpperCase()].n;
tmp_point = find_ray_surf_crosspoint(n,tmp_point[0],tmp_point[1],tmp_point[2],(e[i-k].d+e[i-k].t),0,(e[i-k].d+e[i-k].t),e[i-k].back);
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
//console.log("x"+npi+" x:"+tmp_point[0]+" y:"+tmp_point[1]);
tmp_point = find_ray_surf_crosspoint(1/n,tmp_point[0],tmp_point[1],tmp_point[2],e[i-k].d,0,e[i-k].d,e[i-k].front);
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
//console.log("x"+npi+" x:"+tmp_point[0]+" y:"+tmp_point[1]);
}else{
//console.log("Ray at aperture: "+tmp_point[0]+" "+tmp_point[1]+" "+tmp_point[2]);
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
obj[path]["x"+npi]= cx(tmp_point[0]);
obj[path]["y"+npi]= cy(tmp_point[1]);
npi++;
}
}
//extra point after all's finished
obj[path]["x"+npi]= cx(tmp_point[0]-5);
obj[path]["y"+npi]= cy(tmp_point[2]*(tmp_point[0]-5)+(tmp_point[1]-tmp_point[2]*tmp_point[0]));
/////////////////////////////////////////////////////////////////////////////////////////////////////////
$("#cnv1").drawPath(obj);
}
function find_ray_surf_crosspoint(n,ray_x,ray_y,ray_k,surf_x,surf_y,surf_d,surf){
var ray_b = ray_y-ray_k*ray_x;
//console.log("ITE");
var surf_k = find_surf_tangent(surf_y,surf);
if (surf_k=="inf") x_c = surf_x;
else{
surf_b = surf_y-surf_k*surf_x;
x_c = (ray_b-surf_b)/(surf_k-ray_k);
}
y_c = ray_k*x_c + ray_b;
x_delta = find_surf_point(y_c,surf_d,surf);
if (Math.abs(x_delta-x_c)>epsilon) {
//console.log("REPEAT! Delta is "+Math.abs(x_delta-x_c));
return find_ray_surf_crosspoint(n,ray_x,ray_y,ray_k,x_delta,y_c,surf_d,surf);
}else{
//console.log("GOT IT! Delta is "+Math.abs(x_delta-x_c)+" "+x_c+":"+y_c+" vs "+x_delta);
surf_n = ((surf_k=="inf")?(0):(-1/surf_k));
if (surf_k=="inf") beta = Math.PI/2;
else beta = (Math.atan(surf_k)<0)?(Math.PI+Math.atan(surf_k)):Math.atan(surf_k);
//console.log("surf_k= "+surf_k+" and then beta="+(beta*180/Math.PI));
alph_i = (Math.atan(ray_k)<0)?(Math.PI+Math.atan(ray_k)):Math.atan(ray_k);
if (ray_k>=0){
if(ray_k<surf_n) gamm_i = -alph_i + beta - Math.PI/2;
else gamm_i = alph_i - beta + Math.PI/2;
}else{
if(ray_k>surf_n) gamm_i = alph_i - beta - Math.PI/2;
else gamm_i = -alph_i + beta + Math.PI/2;
}
gamm_r = Math.asin(Math.sin(gamm_i)/n);
if (ray_k>=0){
if(ray_k<surf_n) alph_r = -gamm_r + beta - Math.PI/2;
else alph_r = gamm_r + beta - Math.PI/2;
}else{
if(ray_k>surf_n) alph_r = gamm_r + beta + Math.PI/2;
else alph_r = -gamm_r + beta + Math.PI/2;
}
ray_k_r = Math.tan(alph_r);
return [x_c,y_c,ray_k_r];
}
}
function find_surf_tangent(y,surf){
var c_px = surf.c;
var _sqrt_ = Math.sqrt(1-(1+surf.k)*y*y/(c_px*c_px));
var tmp = 2*(y/c_px)/(1+_sqrt_)+Math.pow(y,3)/Math.pow(c_px,3)/(1+_sqrt_)/(1+_sqrt_)/_sqrt_+2*surf.a[0]*y+4*surf.a[1]*Math.pow(y,3)+6*surf.a[2]*Math.pow(y,5)+8*surf.a[3]*Math.pow(y,7);
return (tmp==0)?"inf":1/tmp;
}
function find_surf_point(y,d,surf){
var c_px = surf.c;
var d_px = d;
var _sqrt_ = Math.sqrt(1-(1+surf.k)*y*y/(c_px*c_px));
var tmp = d_px+y*y/c_px/(1+_sqrt_)+surf.a[0]*Math.pow(y,2)+surf.a[1]*Math.pow(y,4)+surf.a[2]*Math.pow(y,6)+surf.a[3]*Math.pow(y,8);
return tmp;
}
function cx(x){
return (+x*canvas_scale+xO);
}
function cy(y){
return (-y*canvas_scale+yO);
}
//returns marginal ray height/2 when traced from center of the last element
function find_marginal_ray_half_height(x,y,height,dheight,old_cv,limit){
tmp_point = Array();
tmp_point[0]=x;
tmp_point[1]=height;
tmp_point[2]=0;
var i=0;
for(var j=0;j<(e.length-i);j++){
//console.log(j);
if (e[i+j].front.h>0){
n=Glass[e[i+j].m.toUpperCase()].n;
tmp_point = find_ray_surf_crosspoint(n,tmp_point[0],tmp_point[1],tmp_point[2],e[i+j].d,0,e[i+j].d,e[i+j].front);
tmp_point = find_ray_surf_crosspoint(1/n,tmp_point[0],tmp_point[1],tmp_point[2],(e[i+j].d+e[i+j].t),0,(e[i+j].d+e[i+j].t),e[i+j].back);
}else{
//analysis
cv = tmp_point[1]-tmp_point[2]*tmp_point[0]+tmp_point[2]*e[i+j].d+e[i+j].front.h/2;
if (Math.abs(cv)<epsilon2) {
return height;
}else{
limit--;
if (cv*old_cv<0){
//change direction
if (limit>0) return find_marginal_ray_half_height(x,y,height-dheight/2,-dheight/2,cv,limit);
else return -1;
}else{
//change direction if error increased
if (Math.abs(cv)>Math.abs(old_cv)) dheight = -dheight;
if (limit>0) return find_marginal_ray_half_height(x,y,height+dheight,dheight,cv,limit);
else return -2;
}
}
}
}
}
//returns alpha for chief ray for certain point
function find_aperture_stop_ray(x,y,alpha,height,dalpha,old_cv,limit){
var i = e.length-1;
tmp_point = Array();
tmp_point[0]=x;
tmp_point[1]=y;
tmp_point[2]=Math.tan(alpha*Math.PI/180);
for(var k=0;k<=i;k++){
if (e[i-k].back.h>0){
n=Glass[e[i-k].m.toUpperCase()].n;
tmp_point = find_ray_surf_crosspoint(n,tmp_point[0],tmp_point[1],tmp_point[2],(+e[i-k].d+e[i-k].t),0,(+e[i-k].d+e[i-k].t),e[i-k].back);
tmp_point = find_ray_surf_crosspoint(1/n,tmp_point[0],tmp_point[1],tmp_point[2],+e[i-k].d,0,+e[i-k].d,e[i-k].front);
}else{
cv = tmp_point[1]-tmp_point[2]*tmp_point[0]+tmp_point[2]*e[i-k].d-height;
if (Math.abs(cv)<epsilon2) {
console.log("chudo ray finder triumphantly returns x:"+x+" y:"+y+" alpha:"+alpha+" limit(left)="+limit+" delta= "+(cv)+"for the height="+height);
//finish tracing
for(l=1;l<=(i-k);l++){
n=Glass[e[(i-k-l)].m.toUpperCase()].n;
tmp_point = find_ray_surf_crosspoint(n,tmp_point[0],tmp_point[1],tmp_point[2],(+e[i-k-l].d+e[i-k-l].t),0,(+e[i-k-l].d+e[i-k-l].t),e[i-k-l].back);
tmp_point = find_ray_surf_crosspoint(1/n,tmp_point[0],tmp_point[1],tmp_point[2],+e[i-k-l].d,0,+e[i-k-l].d,e[i-k-l].front);
}
alpha = ((tmp_point[2]<0)?(Math.PI+Math.atan(tmp_point[2])):(Math.atan(tmp_point[2])));
return [tmp_point[0],tmp_point[1],alpha*180/Math.PI];
}else{
limit--;
if (cv*old_cv<0){
//change direction
if (limit>0) return find_aperture_stop_ray(x,y,alpha-dalpha/2,height,-dalpha/2,cv,limit);
else return -1;
}else{
//change direction if error increased
if (Math.abs(cv)>Math.abs(old_cv)) dalpha = -dalpha;
if (limit>0) return find_aperture_stop_ray(x,y,alpha+dalpha,height,dalpha,cv,limit);
else return -2;
}
}
}
}
}
var Glass = {
"BAF51" : {n:1.652242},
"BASF1" : {n:1.626061},
"BK7" : {n:1.516800},
"K50" : {n:1.522572},
"LAK11" : {n:1.658302},
"LAK21" : {n:1.640495},
"LASF14A" : {n:1.822230},
"N-BK7" : {n:1.516800},
"N-FK51" : {n:1.486561},
"N-FK51A" : {n:1.486560},
"N-SK15" : {n:1.622960},
"N-ZK7" : {n:1.508470},
"P-LAK35" : {n:1.693500},
"PSK52" : {n:1.603101},
"SF57" : {n:1.846660},
"SF58" : {n:1.917613},
"SF6HT" : {n:1.805180},
"SK16" : {n:1.620410}
}
\ No newline at end of file
.list
{
background:red;
}
.list_view ul{
position: relative;
top: -12px;
left: -40px;
width:280px;
}
.list_view li
{
list-style-type: none;
display: block;
border: 1px dotted rgba(220,220,220,1);
background: rgba(250,250,250,1);
z-index: 100;
padding-left: 5px;
color: black;
}
.list_view li:hover
{
background: rgba(200,128,128,1);
}
.list_head
{
/* font-family:"Times New Roman", Times, serif;*/
font-family:Arial;
position:absolute;
width: 285px;
height: 25px;
z-index: 50;
line-height: 25px; /*should be the same as height*/
font-size: 1em;
text-align:center;
color: rgba(256,256,256,1);
background: -webkit-gradient(linear, left top, left bottom, from(rgba(200,100,100,0.7)), to(rgba(200,100,100,0.7))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(200,100,100,0.7), rgba(200,100,100,0.7)); /* for firefox 3.6+ */
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
}
.list_head:hover
{
background: -webkit-gradient(linear, left top, left bottom, from(rgba(256,170,170,1)), to(rgba(230,130,130,1))); /* for webkit browsers */
background: -moz-linear-gradient(top, rgba(256,170,170,1), rgba(230,130,130,1)); /* for firefox 3.6+ */
cursor: default;
}
.list_view{
position: absolute;
top: 25px;
left: 3px;
/*background:black;*/
padding:0px;
line-height: 25px; /*should be the same as height*/
font-size: 14px;
width: 285px;
height: 200px;
overflow:hidden;
z-index:100;
}
\ No newline at end of file
$(function(){
get_designs_list("load_designs_list");
jquery_list("load_designs_list","Load",load_design);
//jquery_list("input_sensor_list",list_initial_value,update_sensor_fields);
//var list_div = document.getElementById('load_designs_list');
//if (list_div.addEventListener) list_div.addEventListener('DOMMouseScroll', wheelEvent_list, false);
//list_div.onmousewheel = wheelEvent_list;
});
function load_design(src,i){
console.log("Loading lens design: "+designs[i]);
getDesign(designs[i]);
}
function get_designs_list_sync(some_folder,type) {
$.ajax({
url: "./get_designs_list.php",
async: false,
dataType: "xml",
success: function(data){fill_designs_list(data.getElementsByTagName("file"));}
});
}
var designs = Array();
function fill_designs_list(designs_list){
designs = Array();
for (var i=0;i<designs_list.length;i++){
var tmp = designs_list[i];
if (tmp.length != 0) {
if (typeof(tmp.childNodes[0])!='undefined') designs[i] = tmp.childNodes[0].nodeValue;
else designs[i] = "";
}
}
}
function get_designs_list(element_id) {
var some_folder = "";
var folder_list = "";
if (some_folder!="Load") {
get_designs_list_sync();
var list = "<div class='list_view'><ul>";
for(var i=0; i<designs.length; i++) {
list = list + "<li>"+designs[i]+"</li>";
}
list = list + "</ul></div>";
}else{
list = "<div class='list_view'><ul></ul></div>";
}
$("#"+element_id).html(list);
}
function wheelEvent_list(event){
var delta = 0;
if (!event) event = window.event; // IE
if (event.wheelDelta) { //IE+Opera
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) { // Mozilla
delta = -event.detail;
}
if (delta)
handleWheel_list(event,delta);
if (event.preventDefault)
event.preventDefault();
event.returnValue = false;
}
function handleWheel_list(event,delta) {
var tmp = $(".list_view ul").position().top;
console.log($(".list_view ul").position().top+" "+$(".list_view ul").offset().top);
var tmp2 = +tmp+20*delta;
if (tmp2 > -12) tmp2=-12;
if (tmp2 < (-$(".list_view ul").height()+$(".list_view").height()-12) ) tmp2=-$(".list_view ul").height()+$(".list_view").height()-12;
$(".list_view ul").css({top:tmp2+'px'});
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
FILE NAME : 0353-70-64.xml
DESCRIPTION: potential design for Eyesis series
REVISION: 1.00
LICENSE: CERN OHL v.1.1 or later, see http://ohwr.org/cernohl
Copyright (C) 2014 Elphel, Inc.
-->
<Document>
<element>
<distance>0</distance>
<thickness>2</thickness>
<material>LASF14A</material>
<name></name>
<front>
<height>19</height>
<rcurve>44.1995256672</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>19</height>
<rcurve>246.6876684899</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>2.5000001103</distance>
<thickness>0.9798916508</thickness>
<material>SK16</material>
<name></name>
<front>
<height>13.2</height>
<rcurve>28.7407314472</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>8.4</height>
<rcurve>4.6429368608</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>5.523528887</distance>
<thickness>2.5000747341</thickness>
<material>BAF51</material>
<name></name>
<front>
<height>9.2</height>
<rcurve>10.1726461944</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>6.4</height>
<rcurve>4.6194936713</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>10.0236036211</distance>
<thickness>2.5344684091</thickness>
<material>SF57</material>
<name></name>
<front>
<height>9</height>
<rcurve>14.5286371088</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>9</height>
<rcurve>-20.3628934583</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>12.9906694879</distance>
<thickness></thickness>
<material></material>
<name>aperture stop</name>
<front>
<height>-2.0802795223</height>
<rcurve></rcurve>
<k>NaN</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>NaN</height>
<rcurve></rcurve>
<k>NaN</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>14.2945748147</distance>
<thickness>1.5</thickness>
<material>SF58</material>
<name></name>
<front>
<height>7.4</height>
<rcurve>-30.5356011642</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>7.4</height>
<rcurve>8.9309914413</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>15.7945748147</distance>
<thickness>1.9557993329</thickness>
<material>N-SK15</material>
<name></name>
<front>
<height>7.4</height>
<rcurve>8.9309914413</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>7.4</height>
<rcurve>-7.4851654525</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>18.2605400091</distance>
<thickness>1.5</thickness>
<material>N-FK51A</material>
<name></name>
<front>
<height>9</height>
<rcurve>24.7891335236</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>9</height>
<rcurve>-12.6157169321</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>20.4723519148</distance>
<thickness>2.0521328555</thickness>
<material>N-FK51</material>
<name></name>
<front>
<height>9</height>
<rcurve>11.3993328019</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>9</height>
<rcurve>-31.8291341955</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>28.2244847702</distance>
<thickness>0.5</thickness>
<material>N-BK7</material>
<name>field flattener</name>
<front>
<height>8</height>
<rcurve>-8</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>9</height>
<rcurve>-10000</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
<element>
<distance>28.7244847702</distance>
<thickness>0.4</thickness>
<material>N-BK7</material>
<name>sensor glass</name>
<front>
<height>8</height>
<rcurve>10000</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</front>
<back>
<height>8</height>
<rcurve>-10000</rcurve>
<k>0</k>
<a1>0</a1>
<a2>0</a2>
<a3>0</a3>
<a4>0</a4>
</back>
</element>
</Document>
\ No newline at end of file
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="css/reset.css" /> <!-- reset css -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<style>
body{ background-color: ivory; }
#canvas{border:1px solid red;}
</style>
<script>
$(function(){
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(66,21);
ctx.lineTo(79,35);
ctx.lineTo(79,53);
ctx.quadraticCurveTo(79-55,53+(185-53)/2,79,167);
ctx.lineTo(79,185);
ctx.lineTo(66,199);
ctx.quadraticCurveTo(66-60,21+(199-21)/2,66,21);
ctx.closePath();
ctx.fillStyle="skyblue";
ctx.fill();
ctx.lineWidth=2;
ctx.strokeStyle="black";
ctx.stroke();
}); // end $(function(){});
</script>
</head>
<body>
<canvas id="canvas" width=300 height=300></canvas>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment