diff --git a/doc/Appendix A   An Introduction to Preprocessor Metaprogramming.html b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming.html new file mode 100644 index 0000000..60f427c --- /dev/null +++ b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming.html @@ -0,0 +1,2497 @@ + + + + + + + + + Appendix A   An Introduction to Preprocessor Metaprogramming + + +
+
+

Appendix A   An Introduction to Preprocessor + Metaprogramming

+ + + + + + + + + + + + + +
Copyright:From "C++ Template Metaprogramming," by David Abrahams and + Aleksey Gurtovoy. Copyright (c) 2005 by Pearson Education, Inc. + Reprinted with permission.
ISBN:0321227255
+
+

A.1   Motivation

+

Even with the full power of template metaprogramming and the Boost Metaprogramming library + at our disposal, some C++ coding jobs still require a great deal of + boilerplate code repetition. We saw one example in Chapter 5, when we + implemented tiny_size:

+
template <class T0, class T1, class T2>
+struct tiny_size
+  : mpl::int_<3> {};
+
+ + +

Aside from the repeated pattern in the parameter list of the primary + template above, there are three partial specializations below, which + also follow a predictable pattern:

+
template <class T0, class T1>
+struct tiny_size<T0,T1,none>
+  : mpl::int_<2> {};
+
+template <class T0>
+struct tiny_size<T0,none,none>
+  : mpl::int_<1> {};
+
+template <>
+struct tiny_size<none,none,none>
+  : mpl::int_<0> {};
+
+ + +

In this case there is only a small amount of code with such a + "mechanical" flavor, but had we been implementing large instead of tiny, there might easily have been a great + deal more. When the number of instances of a pattern grows beyond two + or three, writing them by hand tends to become error-prone. Perhaps + more importantly, the code gets hard to read, because the important + abstraction in the code is really the pattern, not the individual + instances.

+
+

A.1.1   Code Generation

+

Rather than being written out by hand, mechanical-looking code + should really be generated mechanically. Having written a program to + spit out instances of the code pattern, a library author has two + choices: She can either ship pre-generated source code files, or she + can ship the generator itself. Either approach has drawbacks. If + clients only get the generated source, they are stuck with whatever + the library author generated—and experience shows that if they are + happy with three instances of a pattern today, someone will need + four tomorrow. If clients get the generator program, on the other + hand, they also need the resources to execute it (e.g., + interpreters), and they must integrate the generator into their + build processes...

+
+
+

A.1.2   Enter the Preprocessor

+

...unless the generator is a preprocessor metaprogram. Though not + designed for that purpose, the C and C++ preprocessors can be made + to execute sophisticated programs during the preprocessing phase of + compilation. Users can control the code generation process with + preprocessor #defines + in code or -D + options on the compiler's command line, making build integration + trivial. For example, we might parameterize the primary tiny_size template above as follows:

+
#include <boost/preprocessor/repetition/enum_params.hpp>
+
+#ifndef TINY_MAX_SIZE
+#  define TINY_MAX_SIZE 3  // default maximum size is 3
+#endif
+
+template <BOOST_PP_ENUM_PARAMS(TINY_MAX_SIZE, class T)>
+struct tiny_size
+  : mpl::int_<TINY_MAX_SIZE>
+{};
+
+ + +

To test the metaprogram, run your compiler in its "preprocessing" + mode (usually the -E + option), with the Boost root directory in your #include path. For instance:[1]

+
g++ -P -E -Ipath/to/boost_1_32_0 -I. test.cpp
+
+ + + + + + + + + +
[1]GCC's -P + option inhibits the generation of source file and line number + markers in preprocessed output.
+

Given the appropriate metaprograms, users would be able to adjust + not only the number of parameters to tiny_size, but the maximum size of the + entire tiny + implementation just by #define-ing + TINY_MAX_SIZE.

+

The Boost Preprocessor library [MK04] plays a role in preprocessor + metaprogramming similar to the one played by the MPL in template + metaprogramming: It supplies a framework of high-level components + (like BOOST_PP_ENUM_PARAMS) + that make otherwise-painful metaprogramming jobs approachable. In + this appendix we won't attempt to cover nitty-gritty details of how + the preprocessor works, nor principles of preprocessor + metaprogramming in general, nor even many details of how the + Preprocessor library works. We will show you + enough at a high level that you'll be able to use the library + productively and learn the rest on your own.

+ + + + + + + + +
[MK04]Paul Mensonides and Vesa Karvonen. "The Boost Preprocessor + Library." http://www.boost.org/libs/preprocessor.
+
+
+
+

A.2   Fundamental + Abstractions of the Preprocessor

+

We began our discussion of template metaprogramming in Chapter 2 by + describing its metadata (potential template arguments) and + metafunctions (class templates). On the basis of those two fundamental + abstractions, we built up the entire picture of compile-time + computation covered in the rest of this book. In this section we'll + lay a similar foundation for the preprocessor metaprogrammer. Some of + what we cover here may be a review for you, but it's important to + identify the basic concepts going into detail.

+
+

A.2.1   Preprocessing Tokens

+

The fundamental unit of data in the preprocessor is the preprocessing + token. Preprocessing tokens correspond roughly to the + tokens you're used to working with in C++, such as identifiers, + operator symbols, and literals. Technically, there are some + differences between preprocessing tokens and regular tokens + (see section 2 of the C++ standard for details), but they can be + ignored for the purposes of this discussion. In fact, we'll be using + the terms interchangeably here.

+
+
+

A.2.2   Macros

+

Preprocessor macros come in two flavors. Object-like + macros can be defined this way:

+
+
+
#define + identifier replacement-list
+
+
+ +

where the identifier names the macro being defined, and replacement-list + is a sequence of zero or more tokens. Where the identifier + appears in subsequent program text, it is expanded + by the preprocessor into its replacement-list.

+

Function-like macros, which act as the + "metafunctions of the preprocessing phase," are defined as follows:

+
+
+
#define + identifier(a1, a2, + ... an) replacement-list
+
+
+ +

where each ai is an identifier naming a macro + parameter. When the macro name appears in subsequent + program text followed by a suitable argument list, it is expanded + into its replacement-list, except that each argument is + substituted for the corresponding parameter where it appears in the + replacement-list.[2]

+ + + + + + + + +
[2]We have omitted many details of how macro expansion works. + We encourage you to take a few minutes to study section 16.3 + of the C++ standard, which describes that process in + straightforward terms.
+
+
+

A.2.3   Macro Arguments

+
+

Definition

+

A macro argument is a nonempty sequence of:

+
    +
  • Preprocessing tokens other than commas or parentheses, and/or
  • +
  • Preprocessing tokens surrounded by matched pairs of + parentheses.
  • +
+
+

This definition has consequences for preprocessor metaprogramming + that must not be underestimated. Note, first of all, that the + following tokens have special status:

+
+
,  (  )
+
+ +

As a result, a macro argument can never contain an unmatched + parenthesis, or a comma that is not surrounded by matched + parentheses. For example, both lines following the definition of FOO + below are ill-formed:

+
#define FOO(X) X // Unary identity macro
+FOO(,)           // un-parenthesized comma or two empty arguments
+FOO())           // unmatched parenthesis or missing argument
+
+ +

Note also that the following tokens do not have special + status; the preprocessor knows nothing about matched pairs of + braces, brackets, or angle brackets:

+
+
{  }  [  ]  <  >
+
+ +

As a result, these lines are also ill-formed:

+
FOO(std::pair<int, long>)                // two arguments
+FOO({ int x = 1, y = 2; return x+y; })   // two arguments
+
+ +

It is possible to pass either string of tokens above as + part of a single macro argument, provided it is parenthesized:

+
FOO((std::pair<int,int>))                 // one argument
+FOO(({ int x = 1, y = 2; return x+y; }))  // one argument
+
+ +

However, because of the special status of commas, it is impossible + to strip parentheses from a macro argument without knowing the + number of comma-separated token sequences it contains.[3] If you are writing a macro + that needs to be able to accept an argument containing a variable + number of commas, your users will either have to parenthesize that + argument and pass you the number of comma-separated token + sequences as an additional argument, or they will have to encode the + same information in one of the preprocessor data structures covered + later in this appendix.

+ + + + + + + + +
[3](1, 2) The C99 preprocessor, by virtue + of its variadic macros, can do that and more. The C++ + standardization committee is likely to adopt C99's + preprocessor extensions for the next version of the C++ + standard.
+
+
+
+

A.3   Preprocessor Library + Structure

+

Since in-depth coverage of the Boost Preprocessor library is beyond + the scope of this book, we'll try to give you the tools to + gain an in-depth understanding of the library here. To do that, you'll + need to use the electronic Preprocessor library documentation, which + begins with the index.html file in the libs/preprocessor/ subdirectory of your + Boost installation.

+

On the left of your browser window you'll see an index, and if you + follow the "Headers" link, it will reveal the structure of the boost/preprocessor/ directory. Most of the + library's headers are grouped into subdirectories according to related + functionality. The top-level directory contains only a few headers + that provide general-purpose macros, along with a header for each + subdirectory that simply #includes + all the headers in that subdirectory. For example, boost/preprocessor/selection.hpp does + nothing more than to #include + the min.hpp + and max.hpp + headers that comprise the contents of boost/preprocessor/selection/. The headers + whose names don't correspond to subdirectories generally + declare a macro whose name is the same as the name of the header, + without the extension, and with a BOOST_PP_ prefix. For example, boost/preprocessor/selection/max.hpp + declares BOOST_PP_MAX.

+

You'll also notice that often a header will declare an additional + macro with a _D, + _R, or _Z suffix.[4] + For instance, boost/preprocessor/selection/max.hpp + also declares BOOST_PP_MAX_D. + For the purposes of this appendix, you should ignore those macros. + Eventually you will want to understand how they can be used to + optimize preprocessing speed; consult the Topics section of the + library documentation under the subheading "reentrancy" for that + information.

+ + + + + + + + +
[4]Macros with _1ST, + _2ND, + or _3RD + suffixes, if they appear, should be ignored for a different + reason: They are deprecated and will be removed from the library + soon.
+
+
+

A.4   Preprocessor + Library Abstractions

+

In this section we'll discuss the basic abstractions of the + Preprocessor library, and give some simple examples of each.

+
+

A.4.1   Repetition

+

The repeated generation of class + T0, class T1... class Tn + that we achieved using BOOST_PP_ENUM_PARAMS + was a specific case of the general concept of horizontal + repetition. The library also has a concept of vertical + repetition, which we'll get to in a moment. Horizontal repetition + macros are all found in the library's repetition/ subdirectory.

+
+

A.4.1.1   Horizontal Repetition

+

To generate the tiny_size + specializations using horizontal repetition, we might write the + following:

+
#include <boost/preprocessor/repetition.hpp>
+#include <boost/preprocessor/arithmetic/sub.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+
+#define TINY_print(z, n, data) data
+
+#define TINY_size(z, n, unused)                                 \
+  template <BOOST_PP_ENUM_PARAMS(n, class T)>                   \
+  struct tiny_size<                                             \
+      BOOST_PP_ENUM_PARAMS(n,T)                                 \
+      BOOST_PP_COMMA_IF(n)                                      \
+      BOOST_PP_ENUM(                                            \
+          BOOST_PP_SUB(TINY_MAX_SIZE,n), TINY_print, none)      \
+  >                                                             \
+    : mpl::int_<n> {};
+
+BOOST_PP_REPEAT(TINY_MAX_SIZE, TINY_size, ~)
+
+#undef TINY_size
+#undef TINY_print
+
+ +

The code generation process is kicked off by calling BOOST_PP_REPEAT, a higher-order + macro that repeatedly invokes the macro named by its + second argument (TINY_size). + The first argument specifies the number of repeated invocations, + and the third one can be any data; it is passed on unchanged to + the macro being invoked. In this case, TINY_size doesn't use that data, so + the choice to pass ~ + was arbitrary.[5]

+ + + + + + + + +
[5]~ + is not an entirely arbitrary choice. Both @ and $ might have been good choices, + except that they are technically not part of the basic + character set that C++ implementations are required to + support. An identifier like ignored might be subject to + macro expansion, leading to unexpected results.
+

Each time the TINY_size + macro is invoked by BOOST_PP_REPEAT, + it generates a different specialization of tiny_size. The macro accepts three + parameters.

+
    +
  • z + is related to the _Z + macro suffix we mentioned earlier. You'll never need to use it + except for optimization purposes, and can safely ignore it for + now.
  • +
  • n + is the repetition index. In repeated invocations of TINY_size, n will be 0, then 1, then 2, and so on.
  • +
  • unused, + in this case, will be ~ + on each repetition. In general, the final argument to a macro + invoked by BOOST_PP_REPEAT + is always the same as its invoker's final argument.
  • +
+

Because its replacement-list covers several lines, all + but the last line of TINY_size + is continued with a trailing backslash. The first few of those + lines just invoke BOOST_PP_ENUM_PARAMS + (which we already used in the primary template) to generate + comma-separated lists, so each invocation of TINY_size produces something + equivalent to:[6]

+
template <class T0, class T1, ... class Tn-1>
+struct tiny_size<
+    T0, T1, ... Tn-1
+    ...more... 
+> 
+  : mpl::int_<n> {};
+
+ + + + + + + + +
[6]Note that the line continuation characters and + the newlines following them are removed by the preprocessor, + so the resulting code actually appears on a single line in + the preprocessed output.
+ +

BOOST_PP_COMMA_IF + generates a comma if its numeric argument is not 0. When n is 0, the list generated by the preceding + line will be empty, and a leading comma directly following the < + character would be ill-formed.

+

The next line uses BOOST_PP_ENUM + to generate TINY_MAX_SIZE-n + comma-separated copies of none. + BOOST_PP_ENUM + is just like BOOST_PP_REPEAT + except that it generates commas between repetitions, so its second + argument (TINY_print, + here) must have the same signature as TINY_size. In this case, TINY_print ignores its repetition + index n, + and simply yields its third argument, none.

+

BOOST_PP_SUB + implements token subtraction. It's crucial to understand that + although the preprocessor itself can evaluate ordinary + arithmetic expressions:

+
#define X 3
+...
+#if X - 1 > 0  // OK
+  whatever
+#endif
+
+ + +

preprocessor metaprograms can only operate on tokens. + Normally, when a macro in the Preprocessor library expects a + numeric argument, it must be passed as a single token. If we had + written TINY_MAX_SIZE-n + instead of BOOST_PP_SUB(TINY_MAX_SIZE,n) + above, the first argument to BOOST_PP_ENUM + would have contained three tokens at each invocation: first 3-0, then 3-1, and finally 3-2. BOOST_PP_SUB, though, generates + single-token results: first 3, + then 2, + and finally 1, + in successive repetitions.

+ +
+
+

A.4.1.2   Vertical Repetition

+

If you send the previous example through your preprocessor, + you'll see one long line containing something like this:

+
template <> struct tiny_size< none , none , none > : mpl::int_<0>
+ {}; template < class T0> struct tiny_size< T0 , none , none > :
+mpl::int_<1> {}; template < class T0 , class T1> struct tiny_size
+< T0 , T1 , none > : mpl::int_<2> {};
+
+ +

The distinguishing feature of horizontal repetition is that all + instances of the repeated pattern are generated on the same line + of preprocessed output. For some jobs, like generating the primary + tiny_size + template, that's perfectly appropriate. In this case, however, + there are at least two disadvantages.

+
    +
  1. It's hard to verify that our metaprogram is doing the right + thing without reformatting the resulting code by hand.
  2. +
  3. The efficiency of nested horizontal repetitions varies widely + across preprocessors. Each specialization generated by means of + horizontal repetition contains three other horizontal + repetitions: two invocations of BOOST_PP_ENUM_PARAMS and one + invocation of BOOST_PP_ENUM. + When TINY_MAX_SIZE + is 3, + you'll probably never care, but on at least one preprocessor + still in use today, compilation begins to slow noticeably when TINY_MAX_SIZE + reaches 8.[7]
  4. +
+
+ + + + + + + + +
[7]That said, other preprocessors can handle 256 * 256 + nested repetitions without any speed problems whatsoever.
+
+

The solution to these problems, naturally, is vertical + repetition, which generates instances of a pattern + across multiple lines. The Preprocessor library provides two means + of vertical repetition: local iteration and file + iteration.

+
+

Local Iteration

+

The most expedient way to demonstrate local iteration in our + example is to replace the invocation of BOOST_PP_REPEAT with the following:

+
#include <boost/preprocessor/iteration/local.hpp>
+
+#define BOOST_PP_LOCAL_MACRO(n)   TINY_size(~, n, ~)
+#define BOOST_PP_LOCAL_LIMITS     (0, TINY_MAX_SIZE - 1)
+#include BOOST_PP_LOCAL_ITERATE()
+
+ +

Local iteration repeatedly invokes the user-defined macro with + the special name BOOST_PP_LOCAL_MACRO, + whose argument will be an iteration index. Since we already had + TINY_size + lying around, we've just defined BOOST_PP_LOCAL_MACRO to invoke it. + The range of iteration indices are given by another user-defined + macro, BOOST_PP_LOCAL_LIMITS, + which must expand to a parenthesized pair of integer values + representing the inclusive range of index values + passed to BOOST_PP_LOCAL_MACRO. + Note that this is one of the rare places where the library + expects a numeric argument that can be an expression consisting + of multiple tokens.

+

Finally, the repetition is initiated by #include-ing the result of invoking + BOOST_PP_LOCAL_ITERATE, + which will ultimately be a file in the Preprocessor library + itself. You may find it surprising that many preprocessors can + handle repeated file inclusion more quickly than nested + horizontal repetition, but that is in fact the case.

+

If we throw the new example at our preprocessor, we'll see the + following, on three separate lines in the output:

+
template <> struct tiny_size< none , none , none > : mpl::int_<0>
+ {};
+
+template < class T0> struct tiny_size< T0 , none , none > : mpl::
+int_<1> {};
+
+template < class T0 , class T1> struct tiny_size< T0 , T1 , none
+> : mpl::int_<2> {};
+
+ +

That represents a great improvement in verifiability, but it's + still not ideal. As TINY_MAX_SIZE + grows, it gets harder and harder to see that the pattern is + generating what we'd like. If we could get some more line breaks + into the output it would retain a more recognizable form.

+

Both repetition methods we've used so far have another + drawback, though it doesn't show up in this example. Consider + what would happen if tiny_size + had a member function that we wanted to debug. If you've ever + tried to use a debugger to step through a function generated by + a preprocessor macro, you know that it's a frustrating + experience at best: The debugger shows you the line from which + the macro was ultimately invoked, which usually looks nothing at + all like the code that was generated. Worse, as far as the + debugger is concerned, every statement in that + generated function occupies that same line.

+
+
+

File Iteration

+

Clearly, debuggability depends on preserving the association + between generated code and the lines in the source file that + describe the code pattern. File iteration generates pattern + instances by repeatedly #include-ing + the same source file. The effect of file iteration on + debuggability is similar to that of templates: Although separate + instances appear to occupy the same source lines in the + debugger, we do have the experience of stepping through the + function's source code.

+

To apply file iteration in our example, we can replace our + earlier local iteration code and the definition of TINY_size, with:

+
#include <boost/preprocessor/iteration/iterate.hpp>
+#define BOOST_PP_ITERATION_LIMITS (0, TINY_MAX_SIZE - 1)
+#define BOOST_PP_FILENAME_1       "tiny_size_spec.hpp"
+#include BOOST_PP_ITERATE()
+
+

BOOST_PP_ITERATION_LIMITS + follows the same pattern as BOOST_PP_LOCAL_LIMITS did, allowing + us to specify an inclusive range of iteration indices. BOOST_PP_FILENAME_1 specifies the + name of the file to repeatedly #include (we'll show you that file + in a moment). The trailing 1 + indicates that this is the first nesting level of file + iteration—should we need to invoke file iteration again from + within tiny_size_spec.hpp, + we'd need to use BOOST_PP_FILENAME_2 + instead.

+

The contents of tiny_size_spec.hpp + should look familiar to you; most of it is the same as TINY_size's replacement-list, + without the backslashes:

+
#define n BOOST_PP_ITERATION()
+
+template <BOOST_PP_ENUM_PARAMS(n, class T)>
+struct tiny_size<
+    BOOST_PP_ENUM_PARAMS(n,T)
+    BOOST_PP_COMMA_IF(n)
+    BOOST_PP_ENUM(BOOST_PP_SUB(TINY_MAX_SIZE,n), TINY_print, none)
+>
+  : mpl::int_<n> {};
+
+#undef n
+
+ +

The Library transmits the iteration index to us in the result + of BOOST_PP_ITERATION(); + n is + nothing more than a convenient local macro used to reduce + syntactic noise. Note that we didn't use #include guards because we need tiny_size_spec.hpp + to be processed multiple times.

+

The preprocessed result should now preserve the line structure + of the pattern and be more verifiable for larger values of TINY_MAX_SIZE. + For instance, when TINY_MAX_SIZE + is 8, + the following excerpt appears in the output of GCC's + preprocessing phase:

+
...
+template < class T0 , class T1 , class T2 , class T3>
+struct tiny_size<
+    T0 , T1 , T2 , T3
+    ,
+    none , none , none , none
+>
+  : mpl::int_<4> {};
+
+template < class T0 , class T1 , class T2 , class T3 , class T4>
+struct tiny_size<
+    T0 , T1 , T2 , T3 , T4
+    ,
+    none , none , none
+>
+  : mpl::int_<5> {};
+...etc.
+
+ +
+
+

Self-Iteration

+

Creating an entirely new file like tiny_size_spec.hpp each time we want + to express a trivial code pattern for file repetition can be + inconvenient. Fortunately, the library provides a macro that + allows us to place the pattern right in the file that invokes + the iteration. BOOST_PP_IS_ITERATING + is defined to a nonzero value whenever we're inside an + iteration. We can use that value to select between the part of a + file that invokes the iteration and the part that provides the + repeated pattern. Here's a complete tiny_size.hpp file that demonstrates + self-iteration. Note in particular the placement and use of the + #include + guard TINY_SIZE_HPP_INCLUDED:

+
#ifndef BOOST_PP_IS_ITERATING
+
+#  ifndef TINY_SIZE_HPP_INCLUDED
+#    define TINY_SIZE_HPP_INCLUDED
+
+#    include <boost/preprocessor/repetition.hpp>
+#    include <boost/preprocessor/arithmetic/sub.hpp>
+#    include <boost/preprocessor/punctuation/comma_if.hpp>
+#    include <boost/preprocessor/iteration/iterate.hpp>
+
+#    ifndef TINY_MAX_SIZE
+#      define TINY_MAX_SIZE 3  // default maximum size is 3
+#    endif
+
+// primary template
+template <BOOST_PP_ENUM_PARAMS(TINY_MAX_SIZE, class T)>
+struct tiny_size
+  : mpl::int_<TINY_MAX_SIZE>
+{};
+
+// generate specializations
+#    define BOOST_PP_ITERATION_LIMITS (0, TINY_MAX_SIZE - 1)
+#    define BOOST_PP_FILENAME_1       "tiny_size.hpp" // this file
+#    include BOOST_PP_ITERATE()
+
+#  endif // TINY_SIZE_HPP_INCLUDED
+
+#else // BOOST_PP_IS_ITERATING
+
+#  define n BOOST_PP_ITERATION()
+
+#  define TINY_print(z, n, data) data
+
+// specialization pattern
+template <BOOST_PP_ENUM_PARAMS(n, class T)>
+struct tiny_size<
+    BOOST_PP_ENUM_PARAMS(n,T)
+    BOOST_PP_COMMA_IF(n)
+    BOOST_PP_ENUM(BOOST_PP_SUB(TINY_MAX_SIZE,n), TINY_print, none)
+>
+  : mpl::int_<n> {};
+
+#  undef TINY_print
+#  undef n
+
+#endif // BOOST_PP_IS_ITERATING
+
+
+
+

More

+

There's a good deal more to file iteration than what we've been + able to show you here. For more details, we encourage you to + delve into the library's electronic documentation of BOOST_PP_ITERATE and friends. Also, + it's important to note that no single technique for repetition + is superior to any other: Your choice may depend on convenience, + verifiability, debuggability, compilation speed, and your own + sense of "logical coherence."

+
+
+
+
+

A.4.2   Arithmetic, + Logical, and Comparison Operations

+

As we mentioned earlier, many of the Preprocessor library + interfaces require single-token numeric arguments, and when those + numbers need to be computed arithmetically, straightforward + arithmetic expressions are inappropriate. We used BOOST_PP_SUB to subtract two numeric + tokens in our tiny_size + examples. The library contains a suite of operations for + non-negative integral token arithmetic in its arithmetic/ subdirectory, as shown in + Table A.1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preprocessor Library Arithmetic Operations
ExpressionValue of Single Token Result
BOOST_PP_ADD(x,y)x + y
BOOST_PP_DEC(x)x - 1
BOOST_PP_DIV(x,y)x / y
BOOST_PP_INC(x)x + 1
BOOST_PP_MOD(x,y)x % y
BOOST_PP_MUL(x,y)x * y
BOOST_PP_SUB(x,y)x - y
+

The logical/ + subdirectory contains the convenient Boolean token operations shown + in Table A.2 and the more efficient operations shown in Table A.3, + which require that their operands are either 0 or 1 (a single bit).

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preprocessor Library Integer Logical Operations
ExpressionValue of Single Token Result
BOOST_PP_AND(x,y)x && y
BOOST_PP_NOR(x,y)!(x || y)
BOOST_PP_OR(x,y)x || y
BOOST_PP_XOR(x,y)(bool)x + != (bool)y   + ? 1 : 0
BOOST_PP_NOT(x)x ? 0 : + 1
BOOST_PP_BOOL(x)x ? 1 : + 0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preprocessor Library Bit Logical Operations
ExpressionValue of Single Token Result
BOOST_PP_BITAND(x,y)x && y
BOOST_PP_BITNOR(x,y)!(x || y)
BOOST_PP_BITOR(x,y)x || y
BOOST_PP_BITXOR(x,y)(bool)x + != (bool)y   + ? 1 : 0
BOOST_PP_COMPL(x)x ? 0 : + 1
+

Finally, the comparison/ + subdirectory provides the token integral comparison operations shown + in Table A.4.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preprocessor Library Comparison Operations
ExpressionValue of Single Token Result
BOOST_PP_EQUAL(x,y)x == y   ? 1 : + 0
BOOST_PP_NOT_EQUAL(x,y)x != y   ? 1 : + 0
BOOST_PP_LESS(x,y)x < y    ? 1 : + 0
BOOST_PP_LESS_EQUAL(x,y)x <= y   ? 1 : + 0
BOOST_PP_GREATER(x,y)x > y    ? 1 : + 0
BOOST_PP_GREATER_EQUAL(x,y)x >= y   ? 1 : + 0
+

Because it's common to have a choice among several workable + comparison operators, it may be useful to know that BOOST_PP_EQUAL and BOOST_PP_NOT_EQUAL are likely to be O(1) + while the other comparison operators are generally slower.

+
+
+

A.4.3   Control Structures

+

In its control/ + directory, the Preprocessor Library supplies a macro BOOST_PP_IF(c,t,f) that fulfills a + similar role to the one filled by mpl::if_. To explore the "control" + group, we'll generate code for a framework of generic function + objects: the Boost Function Library.[8] boost::function is partially specialized + to match function type arguments of each arity up to the maximum + supported by the library:

+
template <class Signature> struct function;   // primary template
+
+template <class R>                                   // arity = 0
+struct function<R()>
+  definition not shown...
+
+template <class R, class A0>                         // arity = 1
+struct function<R(A0)>
+  definition not shown...
+
+template <class R, class A0, class A1>               // arity = 2
+struct function<R(A0,A1)>
+  definition not shown...
+
+template <class R, class A0, class A1, class A2>     // arity = 3
+struct function<R(A0,A1,A2)>
+  definition not shown...
+
+etc.
+
+ + + + + + + + + +
[8]We touched briefly on the design of Boost Function when we + discussed type erasure in Chapter 9. See the Function library + documentation at boost_1_32_0/libs/function/index.html + on the CD that accompanies this book for more information.
+

We've already covered a few strategies that can be used to generate + the pattern above, so we won't belabor that part of the problem; the + file iteration approach we used for tiny_size would be fine:

+
#ifndef BOOST_PP_IS_ITERATING
+
+#  ifndef BOOST_FUNCTION_HPP_INCLUDED
+#    define BOOST_FUNCTION_HPP_INCLUDED
+
+#    include <boost/preprocessor/repetition.hpp>
+#    include <boost/preprocessor/iteration/iterate.hpp>
+
+#    ifndef FUNCTION_MAX_ARITY
+#      define FUNCTION_MAX_ARITY 15
+#    endif
+
+template <class Signature> struct function;   // primary template
+
+// generate specializations
+#    define BOOST_PP_ITERATION_LIMITS (0, FUNCTION_MAX_ARITY)
+#    define BOOST_PP_FILENAME_1    "boost/function.hpp" // this file
+#    include BOOST_PP_ITERATE()
+
+#  endif // BOOST_FUNCTION_HPP_INCLUDED
+
+#else // BOOST_PP_IS_ITERATING
+
+#  define n BOOST_PP_ITERATION()
+
+// specialization pattern
+template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>
+struct function<R ( BOOST_PP_ENUM_PARAMS(n,A) )>
+  definition not shown...
+
+#  undef n
+
+#endif // BOOST_PP_IS_ITERATING
+
+

BOOST_PP_ENUM_TRAILING_PARAMS, + used above, is just like BOOST_PP_ENUM_PARAMS + except that when its first argument is not 0, it generates a leading comma.

+ +
+

A.4.3.1   Argument Selection

+

For the sake of interoperability with C++ standard library + algorithms, it might be nice if functions of one or two arguments were + derived from appropriate specializations of std::unary_function or std::binary_function, respectively.[9] + BOOST_PP_IF + is a great tool for dealing with special cases:

+
#  include <boost/preprocessor/control/if.hpp>
+#  include <boost/preprocessor/comparison/equal.hpp>
+
+// specialization pattern
+template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>
+struct function<R ( BOOST_PP_ENUM_PARAMS(n,A) )>
+  BOOST_PP_IF(
+      BOOST_PP_EQUAL(n,2), : std::binary_function<A0, A1, R>
+    , BOOST_PP_IF(
+          BOOST_PP_EQUAL(n,1), : std::unary_function<A0, R>
+        , ...empty argument...
+      )
+  )
+{ ...class body omitted... };
+
+ + + + + + + + + +
[9]While derivation from std::unary_function or std::binary_function might be + necessary for interoperability with some older library + implementations, it may inhibit the Empty Base Optimization + (EBO) from taking effect when two such derived classes are + part of the same object. For more information, see section + 9.4. In general, it's better to expose first_argument_type, second_argument_type, and result_type typedefs directly.
+

Well, our first attempt has run into several problems. First off, + you're not allowed to pass an empty argument to the preprocessor.[3] + Secondly, because angle brackets don't get special treatment, the + commas in the std::unary_function + and std::binary_function + specializations above are treated as macro argument separators, + and the preprocessor will complain that we've passed the wrong + number of arguments to BOOST_PP_IF + in two places.

+

Because it captures all of the issues, let's focus on the inner BOOST_PP_IF + invocation for a moment. The strategy that mpl::eval_if uses, of selecting a + nullary function to invoke, could work nicely here. The + preprocessor doesn't have a direct analogue for mpl::eval_if, but it doesn't really + need one: We can get the right effect by adding a second set of + parentheses to BOOST_PP_IF.

+
#define BOOST_FUNCTION_unary()    : std::unary_function<A0,R>
+#define BOOST_FUNCTION_empty()    // nothing
+
+...
+
+    , BOOST_PP_IF(
+          BOOST_PP_EQUAL(n,1), BOOST_FUNCTION_unary
+        , BOOST_FUNCTION_empty
+      )()
+
+#undef BOOST_FUNCTION_empty
+#undef BOOST_FUNCTION_unary
+
+ +

A nullary macro that generates nothing is so commonly needed that + the library's "facilities" group provides one: BOOST_PP_EMPTY. To complete the + example we'll need to delay evaluation all the way to the outer BOOST_PP_IF + invocation, because std::binary_function<A0,A1,R> + also has a "comma problem":

+
#  include <boost/preprocessor/facilities/empty.hpp>
+
+#  define BOOST_FUNCTION_binary() : std::binary_function<A0,A1,R>
+#  define BOOST_FUNCTION_unary()  : std::unary_function<A0,R>
+
+// specialization pattern
+template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>
+struct function<R ( BOOST_PP_ENUM_PARAMS(n,A) )>
+  BOOST_PP_IF(
+      BOOST_PP_EQUAL(n,2), BOOST_FUNCTION_binary
+    , BOOST_PP_IF(
+          BOOST_PP_EQUAL(n,1), BOOST_FUNCTION_unary
+        , BOOST_PP_EMPTY
+      )
+  )()
+{ 
+    ...class body omitted...
+};
+
+#  undef BOOST_FUNCTION_unary
+#  undef BOOST_FUNCTION_binary
+#  undef n
+
+ +

Note that because we happened to be using file iteration, we + could have also used #if + on n's + value directly:

+
  template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>
+  struct function<R ( BOOST_PP_ENUM_PARAMS(n,A) )>
+#if n == 2
+    : std::binary_function<A0, A1, R>
+#elif n == 1
+    : std::unary_function<A0, R>
+#endif
+
+ +

BOOST_PP_IF + has the advantage of enabling us to encapsulate the logic in a + reusable macro, parameterized on n, that is compatible with all + repetition constructs:

+
#define BOOST_FUNCTION_BASE(n)                                \
+    BOOST_PP_IF(BOOST_PP_EQUAL(n,2), BOOST_FUNCTION_binary    \
+      , BOOST_PP_IF(BOOST_PP_EQUAL(n,1), BOOST_FUNCTION_unary \
+           , BOOST_PP_EMPTY                                   \
+        )                                                     \
+    )()
+
+
+
+

A.4.3.2   Other Selection + Constructs

+

BOOST_PP_IDENTITY, + also in the "facilities" group, is an interesting cousin of BOOST_PP_EMPTY:

+
#define BOOST_PP_IDENTITY(tokens) tokens BOOST_PP_EMPTY
+
+ +

You can think of it as creating a nullary macro that returns tokens: + When empty parentheses are appended, the trailing BOOST_PP_EMPTY is expanded leaving + just tokens + behind. If we had wanted inheritance from mpl::empty_base when function's arity is not one or two, we + could have used BOOST_PP_IDENTITY:

+
// specialization pattern
+template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>
+struct function<R ( BOOST_PP_ENUM_PARAMS(n,A) )>
+  BOOST_PP_IF(
+      BOOST_PP_EQUAL(n,2), BOOST_FUNCTION_binary
+    , BOOST_PP_IF(
+          BOOST_PP_EQUAL(n,1), BOOST_FUNCTION_unary
+        , BOOST_PP_IDENTITY(: mpl::empty_base)
+      )
+  )()
+{ 
+    ...class body omitted...
+};
+
+ +

It's also worth knowing about BOOST_PP_EXPR_IF, which generates its + second argument or nothing, depending on the Boolean value of its + first:

+
#define BOOST_PP_EXPR_IF(c,tokens)                           \
+   BOOST_PP_IF(c,BOOST_PP_IDENTITY(tokens),BOOST_PP_EMPTY)()
+
+ +

So BOOST_PP_EXPR_IF(1,foo) + expands to foo, + while BOOST_PP_EXPR_IF(0,foo) + expands to nothing.

+
+
+
+

A.4.4   Token Pasting

+

It would be nice if there were a generic way to access the return + and parameter types of all function objects, rather than + just the unary and binary ones. A metafunction returning the + signature as an MPL sequence would do the trick. We could just + specialize signature + for each function + arity:

+
template <class F> struct signature; // primary template
+
+// partial specializations for boost::function
+template <class R>
+struct signature<function<R()> > 
+  : mpl::vector1<R> {};
+
+template <class R, class A0>
+struct signature<function<R(A0)> > 
+  : mpl::vector2<R,A0> {};
+
+template <class R, class A0, class A1>
+struct signature<function<R(A0,A1)> > 
+  : mpl::vector3<R,A0,A1> {};
+
+...
+
+ +

To generate these specializations, we might add the following to + our pattern:

+
template <class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class A)>
+struct signature<function<R( BOOST_PP_ENUM_PARAMS(n,A) )> >
+  : mpl::BOOST_PP_CAT(vector,n)<
+      R BOOST_PP_ENUM_TRAILING_PARAMS(n,A)
+    > {};
+
+ +

BOOST_PP_CAT + implements token pasting; its two arguments are + "glued" together into a single token. Since this is a + general-purpose macro, it sits in cat.hpp at the top level of the + library's directory tree.

+

Although the preprocessor has a built-in token-pasting operator, ##, it only + works within a macro definition. If we'd used it here, it wouldn't + have taken effect at all:

+
template <class R>
+struct signature<function<R()> > 
+  : mpl::vector##1<R> {};
+
+template <class R, class A0>
+struct signature<function<R(A0)> > 
+  : mpl::vector##2<R,A0> {};
+
+template <class R, class A0, class A1>
+struct signature<function<R(A0,A1)> > 
+  : mpl::vector##3<R,A0,A1> {};
+
+...
+
+ +

Also, ## + often yields surprising results by taking effect before its + arguments have been expanded:

+
#define N           10
+#define VEC(i)      vector##i
+
+VEC(N)           // vectorN
+
+ +

By contrast, BOOST_PP_CAT + delays concatenation until after its arguments have been fully + evaluated:

+
#define N           10
+#define VEC(i)      BOOST_PP_CAT(vector,i)
+
+VEC(N)           // vector10
+
+ +
+
+

A.4.5   Data Types

+

The Preprocessor library also provides data types, + which you can think of as being analogous to the MPL's type + sequences. Preprocessor data types store macro arguments + instead of C++ types.

+
+

A.4.5.1   Sequences

+

A sequence (or seq for short) + is any string of nonempty parenthesized macro arguments. + For instance, here's a three-element sequence:

+
#define MY_SEQ   (f(12))(a + 1)(foo)
+
+ +

Here's how we might use a sequence to generate specializations of + the is_integral + template from the Boost Type Traits library (see Chapter 2):

+
#include <boost/preprocessor/seq.hpp>
+
+template <class T>
+struct is_integral : mpl::false_ {}; 
+
+// a seq of integral types with unsigned counterparts
+#define BOOST_TT_basic_ints            (char)(short)(int)(long)
+
+// generate a seq containing "signed t" and "unsigned t"
+#define BOOST_TT_int_pair(r,data,t)      (signed t)(unsigned t)
+
+// a seq of all the integral types
+#define BOOST_TT_ints                                           \
+    (bool)(char)                                                \
+    BOOST_PP_SEQ_FOR_EACH(BOOST_TT_int_pair, ~, BOOST_TT_basic_ints)
+
+// generate an is_integral specialization for type t
+#define BOOST_TT_is_integral_spec(r,data,t) \
+   template <>                              \
+   struct is_integral<t> : mpl::true_ {}; 
+
+BOOST_PP_SEQ_FOR_EACH(BOOST_TT_is_integral_spec, ~, BOOST_TT_ints)
+
+#undef BOOST_TT_is_integral_spec
+#undef BOOST_TT_ints
+#undef BOOST_TT_int_pair
+#undef BOOST_TT_basic_ints
+
+ +

BOOST_PP_SEQ_FOR_EACH + is a higher-order macro, similar to BOOST_PP_REPEAT, that invokes its + first argument on each element of its third argument.

+

Sequences are the most efficient, most flexible, and + easiest-to-use of the library's data structures, provided that you + never need to make an empty one: An empty sequence would contain + no tokens, and so couldn't be passed as a macro argument. The + other data structures covered here all have an empty + representation.

+

The facilities for manipulating sequences are all in the + library's seq/ + subdirectory. They are summarized in Table A.5, where t is the sequence (t0)(t1)...(tk). Where s, r, and + d appear, they have a similar purpose to the z parameters we discussed earlier (and + suggested you ignore for now).

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preprocessor Sequence Operations
ExpressionResult
BOOST_PP_SEQ_CAT(t)t0t1...tk
BOOST_PP_SEQ_ELEM(n,t)tn
BOOST_PP_SEQ_ENUM(t)t0, t1, ...tk
BOOST_PP_SEQ_FILTER(pred,data,t)t + without the elements that don't satisfy pred
BOOST_PP_SEQ_FIRST_N(n,t)(t0)(t1)...(tn-1)
BOOST_PP_SEQ_FOLD_LEFT(op, + x, t)...op(s,op(s,op(s,x,t0),t1),t2)...
BOOST_PP_SEQ_FOLD_RIGHT(op, + x, t)...op(s,op(s,op(s,x,tk),tk-1), + tk-2)...
BOOST_PP_SEQ_FOR_EACH(f, + x, t)f(r, x,t0) f(r, x,t1)...f(r, x,tk)
BOOST_PP_SEQ_FOR_EACH_I(g, + x, t)g(r, x, 0, + t0) + g(r, x, 1, t1)... g(r, x, k, tk)
BOOST_PP_SEQ_FOR_EACH_PRODUCT(h, + x, t) +
+
Cartesian product—
+
see online docs
+
+
BOOST_PP_SEQ_INSERT(t,i,tokens)(t0)(t1)...(ti-1)(tokens) + (ti)(ti+1)...(tk)
BOOST_PP_SEQ_POP_BACK(t)(t0)(t1)...(tk-1)
BOOST_PP_SEQ_POP_FRONT(t)(t1)(t2)...(tk)
BOOST_PP_SEQ_PUSH_BACK(t,tokens)(t0)(t1)...(tk)(tokens)
BOOST_PP_SEQ_PUSH_FRONT(t,tokens)(tokens)(t0)(t1)...(tk)
BOOST_PP_SEQ_REMOVE(t,i)(t0)(t1)...(ti-1)(ti+1)...(tk)
BOOST_PP_SEQ_REPLACE(t,i,tokens)(t0)(t1)...(ti-1)(tokens)(ti+1)...(tk)
BOOST_PP_SEQ_REST_N(n,t)(tn)(tn+1)...(tk)
BOOST_PP_SEQ_REVERSE(t)(tk)(tk-1)...(t0)
BOOST_PP_SEQ_HEAD(t)t0
BOOST_PP_SEQ_TAIL(t)(t1)(t2)...(tk)
BOOST_PP_SEQ_SIZE(t)k+1
BOOST_PP_SEQ_SUBSEQ(t,i,m)(ti)(ti+1)...(ti+m-1)
BOOST_PP_SEQ_TO_ARRAY(t)(k+1 + ,(t0,t1,...tk))
BOOST_PP_SEQ_TO_TUPLE(t)(t0, t1,...tk)
BOOST_PP_SEQ_TRANSFORM(f, + x, t)(f(r,x,t0)) (f(r,x,t1))...(f(r,x,tk))
+

It's worth noting that while there is no upper limit on the + length of a sequence, operations such as BOOST_PP_SEQ_ELEM that take numeric + arguments will only work with values up to 256.

+
+
+

A.4.5.2   Tuples

+

A tuple is a very simple data structure for + which the library provides random access and a few other basic + operations. A tuple takes the form of a parenthesized, + comma-separated list of macro arguments. For example, + this is a three-element tuple:

+
#define TUPLE3     (f(12), a + 1, foo)
+
+

The operations in the library's tuple/ subdirectory can handle tuples + of up to 25 elements. For example, a tuple's Nth element can be accessed via BOOST_PP_TUPLE_ELEM, as follows:

+
                 // length  index  tuple 
+BOOST_PP_TUPLE_ELEM(   3   ,  1  , TUPLE3)   // a + 1
+
+ +

Notice that we had to pass the tuple's length as the second + argument to BOOST_PP_TUPLE_ELEM; + in fact, all tuple operations require explicit + specification of the tuple's length. We're not going to summarize + the other four operations in the "tuple" group here—you can + consult the Preprocessor library's electronic documentation for + more details. We note, however, that sequences can be transformed + into tuples with BOOST_PP_SEQ_TO_TUPLE, + and nonempty tuples can be transformed back into sequences with BOOST_PP_TUPLE_TO_SEQ.

+

The greatest strength of tuples is that they conveniently take + the same representation as a macro argument list:

+
#define FIRST_OF_THREE(a1,a2,a3)    a1
+#define SECOND_OF_THREE(a1,a2,a3)   a2
+#define THIRD_OF_THREE(a1,a2,a3)    a3
+
+// uses tuple as an argument list
+# define SELECT(selector, tuple)    selector tuple
+
+SELECT(THIRD_OF_THREE, TUPLE3)   // foo
+
+
+
+

A.4.5.3   Arrays

+

An array is just a tuple containing a + non-negative integer and a tuple of that length:

+
#define ARRAY3     ( 3, TUPLE3 )
+
+

Because an array carries its length around with it, the library's + interface for operating on arrays is much more convenient than the + one used for tuples:

+
BOOST_PP_ARRAY_ELEM(1, ARRAY3)     // a + 1
+
+ +

The facilities for manipulating arrays of up to 25 elements are + all in the library's array/ + subdirectory. They are summarized in Table A.6, where a is the array (k, (a0,a1,...ak-1)).

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Preprocessor Array Operations
ExpressionResult
BOOST_PP_ARRAY_DATA(a)(a0,a1,... + ak-1)
BOOST_PP_ARRAY_ELEM(i,a)ai
BOOST_PP_ARRAY_INSERT(a, + i, tokens)(k+1,(a0,a1,...ai-1, tokens, ai,ai+1,... + ak-1))
BOOST_PP_ARRAY_POP_BACK(a)(k-1,(a0,a1,... + ak-2))
BOOST_PP_ARRAY_POP_FRONT(a)(k-1,(a1,a2,... + ak-1))
BOOST_PP_ARRAY_PUSH_BACK(a, + tokens)(k+1,(a0,a1,... + ak-1, + tokens))
BOOST_PP_ARRAY_PUSH_FRONT(a, + tokens)(k+1,(tokens, + a1,a2,... + ak-1))
BOOST_PP_ARRAY_REMOVE(a, + i)(k-1,(a0,a1,... + ai-1,ai+1,... + ak-1))
BOOST_PP_ARRAY_REPLACE(a, + i, tokens)(k,(a0,a1,... + ai-1, + tokens, ai+1,... + ak-1))
BOOST_PP_ARRAY_REVERSE(a)(k,(ak-1,ak-2,... + a1,a0))
BOOST_PP_ARRAY_SIZE(a)k
+
+
+

A.4.5.4   Lists

+

A list is a two-element tuple whose first + element is the first element of the list, and whose second element + is a list of the remaining elements, or BOOST_PP_NIL if there are no remaining + elements. Lists have access characteristics similar to those of a + runtime linked list. Here is a three-element list:

+
#define LIST3     (f(12), (a + 1, (foo, BOOST_PP_NIL)))
+
+ +

The facilities for manipulating lists are all in the library's list/ + subdirectory. Because the operations are a subset of those + provided for sequences, we're not going to summarize them here—it + should be easy to understand the list operations by reading the + documentation on the basis of our coverage of sequences.

+

Like sequences, lists have no fixed upper length bound. Unlike + sequences, lists can also be empty. It's rare to need more than 25 + elements in a preprocessor data structure, and lists tend to be + slower to manipulate and harder to read than any of the other + structures, so they should normally be used only as a last resort.

+
+
+
+
+

A.5   Exercise

+
+
A-0
+
Fully preprocessor-ize the tiny + type sequence implemented in Chapter 5 so that all boilerplate code + is eliminated and the maximum size of a tiny sequence can be adjusted by + changing TINY_MAX_SIZE.
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/analytics.js b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/analytics.js new file mode 100644 index 0000000..57b7031 --- /dev/null +++ b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/analytics.js @@ -0,0 +1,49 @@ +var archive_analytics = { + startTime: new Date(), + img_src: "//analytics.archive.org/0.gif", + values: { service: 'wb' }, + + onload_func: function() { + var now = new Date(); + var loadtime = now - archive_analytics.startTime; + + var v = archive_analytics.values; + v.loadtime = loadtime; + v.timediff = -(now.getTimezoneOffset()/60); + v.locale = archive_analytics.get_locale(); + // if no referrer set '-' as referrer + v.referrer = document.referrer || '-'; + + var string = archive_analytics.format_bug(v); + var loadtime_img = new Image(100,25); + loadtime_img.src = archive_analytics.img_src + "?" + string; + }, + format_bug: function(values) { + var ret = ['version=2'], count = 2; + + for (var data in values) { + ret.push(encodeURIComponent(data) + "=" + encodeURIComponent(values[data])); + count = count + 1; + } + ret.push('count=' + count); + return ret.join("&"); + }, + get_locale: function() { + if (navigator) { + return navigator.language || navigator.browserLanguage || + navigator.systemLanguage || navigator.userLanguage || ''; + } + return ''; + }, + get_cookie: function(name) { + var parts = document.cookie.split(name + "="); + if (parts.length == 2) return parts.pop().split(";").shift(); + return 0; + } +}; + +if (window.addEventListener) { + window.addEventListener('load', archive_analytics.onload_func, false); +} else if (window.attachEvent) { + window.attachEvent('onload', archive_analytics.onload_func); +} diff --git a/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/banner-styles.css b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/banner-styles.css new file mode 100644 index 0000000..4aeda46 --- /dev/null +++ b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/banner-styles.css @@ -0,0 +1,514 @@ + .__wb_overlay { + filter:alpha(opacity=60); /* IE */ + opacity: 0.6; /* Safari, Opera */ + -moz-opacity:0.6; /* FireFox */ + opacity: 0.6; + + background-color: #000; + position: fixed; + width:100%; + height:100%; + top: 0px; + left: 0px; + padding: 0px !important; + border: 0px !important; + margin: 0px !important; + border-radius: 0px !important; + z-index: 2147483643 !important; + } + + #__wb_record_overlay_div { + cursor: wait !important; + } + + + + .__wb_record_content { + opacity: 1.0; + position: fixed; + top: 50%; + left: 50%; + margin: 0px !important; + padding: 0px !important; + + background-color: #ffffff !important; + border-radius: 8px; + z-index: 2147483644 !important; + box-shadow: 0 0 30px 5px #000; + -moz-box-shadow: 0 0 30px 5px #000; + -webkit-box-shadow: 0 0 30px 5px #000; + } + + #__wb_record_content_loader { + cursor: wait !important; + padding-top: 30px !important; + margin-left: -287px !important; + margin-top: -177px !important; + width: 574px !important; + height: 355px !important; + } + + #__wb_record_content_done { + margin-left: -427px !important; + margin-top: -177px !important; + width: 855px !important; + height: 355px !important; + } + + .__wb_record_content > * { + margin: auto !important; + display: block !important; + + text-align: center !important; + font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif !important; + } + + .__wb_record_content > wb_h1 { + font-size: 36px !important; + color: #222 !important; + margin: 0px 0px 0px 0px !important; + padding: 0px !important; + line-height: 2em; + font-weight: normal !important; + width: auto !important; + height: auto !important; + } + + .__wb_record_content > wb_p { + font-size: 17px !important; + color: #222 !important; + margin: 8px 0px 8px 0px !important; + padding: 0px !important; + line-height: 2em; + } + + .__wb_record_content > #_wb_logo { + margin-bottom: 10px !important; + } + + .__wb_record_content > #_wb_spinner { + margin-top: 30px !important; + margin-bottom: 30px !important; + } + + .__wb_record_content > #_wb_curr_url { + text-decoration: underline !important; + font-weight: bold !important; + } + + #__wb_record_content_done > #__wb_link { + font-size: 20px !important; + border: 1px !important; + border-color: #aaa !important; + border-style: solid !important; + padding: 3px !important; + text-align: center !important; + width: 80% !important; + height: auto !important; + } + + #__wb_record_content_done > #__wb_link:focus { + outline: 0px !important; + border-color: #428bca !important; + } + + /* DONATE */ + + #__wb_record_content_done > #__wb_donate_close { + font-size: 18px !important; + width: auto !important; + float: right; + display: inline-block; + margin: 0px !important; + padding: 8px 8px 0px 0px !important; + } + + #__wb_donate_close > #__wb_record_done_close { + cursor: pointer !important; + display: inline-block; + vertical-align: bottom !important; + } + + #__wb_record_content_done > #__wb_donate_close a { + color: #428bca !important; + } + + #__wb_record_content_done > #__wb_donate_close a:link { + color: #428bca !important; + text-decoration: none !important; + margin-right: 16px !important; + } + + #__wb_record_content_done > #__wb_donate_close a:visited { + color: #428bca !important; + } + + #__wb_record_content_done > #__wb_donate_close a:hover { + color: #00B1F7 !important; + } + +#wm-ipp { + width:100%; + min-height:65px; + min-width:800px; + left:0; + top:0; + padding:0; + margin:0; + border-radius:0; + background-color:transparent; + font-size:11px; +} +#wm-ipp * { + font-family:Lucida Grande, Helvetica, Arial, sans-serif; + font-size:inherit; + line-height:1.2; + width:auto; + outline:none; + float:none; +} +#wm-ipp div, #wm-ipp tr, #wm-ipp td, #wm-ipp a, #wm-ipp form { + padding:0; + margin:0; + border:none; + border-radius:inherit; + background-color:transparent; + background-image:none; + z-index:2147483640; +} +#wm-ipp table { + border:none; + border-collapse:collapse; + margin:0; + padding:0; + width:auto; + font-size:inherit; +} +#wm-ipp form input { + padding:1px; + height:auto; + display:inline; + margin:0; +} +#wm-ipp form input[type=submit] { + padding:0 8px; + margin:1px 0 1px 5px; + width:auto !important; +} +#wm-ipp a:hover{ + text-decoration:underline !important; +} +#wm-ipp #wm-ipp-inside { + width:98% !important; + min-width:780px; + margin: 0 auto; + border:5px solid #000; + border-top:none; + background-color:rgba(255,255,255,0.9); + -moz-box-shadow:1px 1px 4px #333; + -webkit-box-shadow:1px 1px 4px #333; + box-shadow:1px 1px 4px #333; + border-radius:0 0 8px 8px; +} +/* selectors are intentionally verbose to ensure priority */ +#wm-ipp #wm-logo { + padding:0 10px; + vertical-align:middle; + min-width:110px; +} +#wm-ipp td.c { + vertical-align:top; + width:100%; +} +#wm-ipp td.c td.u { + padding: 3px 0; + text-align:center; +} +#wm-ipp td.c td.n { + padding-left:5px; +} +#wm-ipp td.c td.n a { + text-decoration:none; + color:#33f; + font-weight:bold; +} +#wm-ipp td.c td.n td.b { + padding-right:6px !important; + text-align:right !important; + overflow:visible; + white-space:nowrap; + color:#99a; + vertical-align:middle; +} +#wm-ipp td.c td.n td.c { + background:#000; + color:#ff0; + font-weight:bold; + text-align:center; +} +#wm-ipp.hi td.c td.n td.c { + color:#ec008c; +} +#wm-ipp td.c td.n td.f { + padding-left:6px !important; + text-align:left !important; + overflow:visible; + white-space:nowrap; + color:#99a; + vertical-align:middle; +} +#wm-ipp td.c td.n tr.m td { + text-transform:uppercase; + white-space:nowrap; + padding:2px 0; +} +#wm-ipp td.c td.s { + padding-right:5px; + text-align:center; + vertical-align:bottom; +} +#wm-ipp td.c td.s a.t { + color:#33f; + font-weight:bold; + line-height: 1.8; +} +#wm-ipp td.c td.s div.r { + color: #666; + font-size:9px; + white-space:nowrap; +} +#wm-ipp td.c td.k { + vertical-align:bottom; + padding-bottom:2px; +} +#wm-ipp td.c td.n tr.y td, #wm-ipp td.c td.s { + padding-bottom:2px; +} + +div#wm-ipp-sparkline { + position:relative;/* for positioning markers */ + white-space:nowrap; + background-color:#fff; + cursor:pointer; + border-right:1px solid #ccc; + line-height:0.9; +} +#sparklineImgId { + position:relative; + z-index:9012; +} +#wm-ipp-sparkline div.yt { + position:absolute; + z-index:9010 !important; + background-color:#ff0 !important; +} +#wm-ipp-sparkline div.mt { + position:absolute; + z-index:9011 !important; + background-color:#ec008c !important; +} +#wm-ipp td.r { + position:relative; + padding-left:65px;/* to push td.c to the left */ +} +#wm-ipp td.r a { + display:block; + padding:0 15px 0 0; + color:#33f; + border:none; + position:absolute; + right:5px; + background-color:transparent; + background-repeat:no-repeat !important; + background-position:100% 100% !important; +} +/* Spinner */ +#__wb_spinningSquaresG{ + position: relative; + width: 240px; + height: 20px; + + + padding: 0px !important; + margin: 30px 0px 30px 160px !important; + border: 0px !important; + border-radius: 0px !important; +} + +.__wb_spinningSquaresG { + + + margin: 0px !important; + padding: 0px !important; + border: 0px !important; + border-radius: 0px !important; + +position:absolute; +top:0; +background-color:#000000; +width:22px; +height:22px; +-moz-animation-name:bounce_spinningSquaresG; +-moz-animation-duration:1.9s; +-moz-animation-iteration-count:infinite; +-moz-animation-direction:linear; +-moz-transform:scale(.3); +-webkit-animation-name:bounce_spinningSquaresG; +-webkit-animation-duration:1.9s; +-webkit-animation-iteration-count:infinite; +-webkit-animation-direction:linear; +-webkit-transform:scale(.3); +-ms-animation-name:bounce_spinningSquaresG; +-ms-animation-duration:1.9s; +-ms-animation-iteration-count:infinite; +-ms-animation-direction:linear; +-ms-transform:scale(.3); +-o-animation-name:bounce_spinningSquaresG; +-o-animation-duration:1.9s; +-o-animation-iteration-count:infinite; +-o-animation-direction:linear; +-o-transform:scale(.3); +animation-name:bounce_spinningSquaresG; +animation-duration:1.9s; +animation-iteration-count:infinite; +animation-direction:linear; +transform:scale(.3); +} + +#__wb_spinningSquaresG_1{ +left:0; +-moz-animation-delay:0.76s; +-webkit-animation-delay:0.76s; +-ms-animation-delay:0.76s; +-o-animation-delay:0.76s; +animation-delay:0.76s; +} + +#__wb_spinningSquaresG_2{ +left:30px; +-moz-animation-delay:0.95s; +-webkit-animation-delay:0.95s; +-ms-animation-delay:0.95s; +-o-animation-delay:0.95s; +animation-delay:0.95s; +} + +#__wb_spinningSquaresG_3{ +left:60px; +-moz-animation-delay:1.14s; +-webkit-animation-delay:1.14s; +-ms-animation-delay:1.14s; +-o-animation-delay:1.14s; +animation-delay:1.14s; +} + +#__wb_spinningSquaresG_4{ +left:90px; +-moz-animation-delay:1.33s; +-webkit-animation-delay:1.33s; +-ms-animation-delay:1.33s; +-o-animation-delay:1.33s; +animation-delay:1.33s; +} + +#__wb_spinningSquaresG_5{ +left:120px; +-moz-animation-delay:1.52s; +-webkit-animation-delay:1.52s; +-ms-animation-delay:1.52s; +-o-animation-delay:1.52s; +animation-delay:1.52s; +} + +#__wb_spinningSquaresG_6{ +left:150px; +-moz-animation-delay:1.71s; +-webkit-animation-delay:1.71s; +-ms-animation-delay:1.71s; +-o-animation-delay:1.71s; +animation-delay:1.71s; +} + +#__wb_spinningSquaresG_7{ +left:180px; +-moz-animation-delay:1.9s; +-webkit-animation-delay:1.9s; +-ms-animation-delay:1.9s; +-o-animation-delay:1.9s; +animation-delay:1.9s; +} + +#__wb_spinningSquaresG_8{ +left:210px; +-moz-animation-delay:2.09s; +-webkit-animation-delay:2.09s; +-ms-animation-delay:2.09s; +-o-animation-delay:2.09s; +animation-delay:2.09s; +} + +@-moz-keyframes bounce_spinningSquaresG{ +0%{ +-moz-transform:scale(1); +background-color:#000000; +} + +100%{ +-moz-transform:scale(.3) rotate(90deg); +background-color:#FFFFFF; +} + +} + +@-webkit-keyframes bounce_spinningSquaresG{ +0%{ +-webkit-transform:scale(1); +background-color:#000000; +} + +100%{ +-webkit-transform:scale(.3) rotate(90deg); +background-color:#FFFFFF; +} + +} + +@-ms-keyframes bounce_spinningSquaresG{ +0%{ +-ms-transform:scale(1); +background-color:#000000; +} + +100%{ +-ms-transform:scale(.3) rotate(90deg); +background-color:#FFFFFF; +} + +} + +@-o-keyframes bounce_spinningSquaresG{ +0%{ +-o-transform:scale(1); +background-color:#000000; +} + +100%{ +-o-transform:scale(.3) rotate(90deg); +background-color:#FFFFFF; +} + +} + +@keyframes bounce_spinningSquaresG{ +0%{ +transform:scale(1); +background-color:#000000; +} + +100%{ +transform:scale(.3) rotate(90deg); +background-color:#FFFFFF; +} + +} + diff --git a/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/disclaim-element.js b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/disclaim-element.js new file mode 100644 index 0000000..ad43734 --- /dev/null +++ b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/disclaim-element.js @@ -0,0 +1,44 @@ +function getFrameArea(frame) { + if(frame.innerWidth) return frame.innerWidth * frame.innerHeight; + if(frame.document.documentElement && frame.document.documentElement.clientHeight) return frame.document.documentElement.clientWidth * frame.document.documentElement.clientHeight; + if(frame.document.body) return frame.document.body.clientWidth * frame.document.body.clientHeight; + return 0; +} + +function isLargestFrame() { + if(top == self) { + return true; + } + if(top.document.body.tagName == "BODY") { + return false; + } + largestArea = 0; + largestFrame = null; + for(i=0;i largestArea) { + largestFrame = frame; + largestArea = area; + } + } + return (self == largestFrame); +} + +function disclaimElement(element) { + if(isLargestFrame()) { + element.style.display="block"; + document.body.insertBefore(element,document.body.firstChild); + } +} + +function disclaimToggle(largest, nonLargest) { + if(isLargestFrame()) { + largest.style.display="block"; + nonLargest.style.display="none"; + } else { + largest.style.display="none"; + nonLargest.style.display="block"; + } +} + diff --git a/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/graph-calc.js b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/graph-calc.js new file mode 100644 index 0000000..26dfe86 --- /dev/null +++ b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/graph-calc.js @@ -0,0 +1,50 @@ +function getEventX(event) { + var posx = 0; + if (event.pageX || event.pageY) { + posx = event.pageX; + } + else if (event.clientX || event.clientY) { + posx = event.clientX + document.body.scrollLeft + + document.documentElement.scrollLeft; + } + return posx; +} +function getElementX(obj) { + var x = 0; + if (obj.offsetParent) { + do { + x += obj.offsetLeft; + } while (obj = obj.offsetParent); + } + return x; +} +function zeroPad(str,len) { + var i; + var pad = ""; + var s = str.toString(); + for(i=s.length; i < len; i++) { + pad = "0".toString() + pad.toString(); + } + return pad.toString() + s.toString(); +} + +function dateToTimestamp(date) { + return date.getFullYear() + + zeroPad(date.getMonth()+1,2) + + zeroPad(date.getDay()+1,2) + + zeroPad(date.getHours(),2) + + zeroPad(date.getMinutes(),2) + + zeroPad(date.getSeconds(),2); +} + +function calcTimestamp(event,element,firstMS,lastMS) { + var eventX = getEventX(event); + var elementX = getElementX(element); + var elementWidth = element.width; + var msWidth = lastMS - firstMS; + var x = eventX - elementX; + var pct = x / elementWidth; + var pctDate = pct * msWidth; + var date = pctDate + firstMS; + return dateToTimestamp(new Date(date)); +} diff --git a/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/jquery.js b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/jquery.js new file mode 100644 index 0000000..d8cc808 --- /dev/null +++ b/doc/Appendix A   An Introduction to Preprocessor Metaprogramming_files/jquery.js @@ -0,0 +1,19 @@ +/* + * jQuery JavaScript Library v1.3.2 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) + * Revision: 6246 + */ +(function(){var window=this,undefined,_jQuery=window.jQuery,_$=window.$,jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context)},quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,isSimple=/^.[^:#\[\.,]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;this.context=selector;return this}if(typeof selector==="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1]){selector=jQuery.clean([match[1]],context)}else{var elem=document.getElementById(match[3]);if(elem&&elem.id!=match[3]){return jQuery().find(selector)}var ret=jQuery(elem||[]);ret.context=document;ret.selector=selector;return ret}}else{return jQuery(context).find(selector)}}else{if(jQuery.isFunction(selector)){return jQuery(document).ready(selector)}}if(selector.selector&&selector.context){this.selector=selector.selector;this.context=selector.context}return this.setArray(jQuery.isArray(selector)?selector:jQuery.makeArray(selector))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(num){return num===undefined?Array.prototype.slice.call(this):this[num]},pushStack:function(elems,name,selector){var ret=jQuery(elems);ret.prevObject=this;ret.context=this.context;if(name==="find"){ret.selector=this.selector+(this.selector?" ":"")+selector}else{if(name){ret.selector=this.selector+"."+name+"("+selector+")"}}return ret},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this},each:function(callback,args){return jQuery.each(this,callback,args)},index:function(elem){return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this)},attr:function(name,value,type){var options=name;if(typeof name==="string"){if(value===undefined){return this[0]&&jQuery[type||"attr"](this[0],name)}else{options={};options[name]=value}}return this.each(function(i){for(name in options){jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name))}})},css:function(key,value){if((key=="width"||key=="height")&&parseFloat(value)<0){value=undefined}return this.attr(key,value,"curCSS")},text:function(text){if(typeof text!=="object"&&text!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text))}var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8){ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this])}})});return ret},wrapAll:function(html){if(this[0]){var wrap=jQuery(html,this[0].ownerDocument).clone();if(this[0].parentNode){wrap.insertBefore(this[0])}wrap.map(function(){var elem=this;while(elem.firstChild){elem=elem.firstChild}return elem}).append(this)}return this},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html)})},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html)})},append:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType==1){this.appendChild(elem)}})},prepend:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType==1){this.insertBefore(elem,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this)})},after:function(){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this.nextSibling)})},end:function(){return this.prevObject||jQuery([])},push:[].push,sort:[].sort,splice:[].splice,find:function(selector){if(this.length===1){var ret=this.pushStack([],"find",selector);ret.length=0;jQuery.find(selector,this[0],ret);return ret}else{return this.pushStack(jQuery.unique(jQuery.map(this,function(elem){return jQuery.find(selector,elem)})),"find",selector)}},clone:function(events){var ret=this.map(function(){if(!jQuery.support.noCloneEvent&&!jQuery.isXMLDoc(this)){var html=this.outerHTML;if(!html){var div=this.ownerDocument.createElement("div");div.appendChild(this.cloneNode(true));html=div.innerHTML}return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(events===true){var orig=this.find("*").andSelf(),i=0;ret.find("*").andSelf().each(function(){if(this.nodeName!==orig[i].nodeName){return }var events=jQuery.data(orig[i],"events");for(var type in events){for(var handler in events[type]){jQuery.event.add(this,type,events[type][handler],events[type][handler].data)}}i++})}return ret},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i)})||jQuery.multiFilter(selector,jQuery.grep(this,function(elem){return elem.nodeType===1})),"filter",selector)},closest:function(selector){var pos=jQuery.expr.match.POS.test(selector)?jQuery(selector):null,closer=0;return this.map(function(){var cur=this;while(cur&&cur.ownerDocument){if(pos?pos.index(cur)>-1:jQuery(cur).is(selector)){jQuery.data(cur,"closest",closer);return cur}cur=cur.parentNode;closer++}})},not:function(selector){if(typeof selector==="string"){if(isSimple.test(selector)){return this.pushStack(jQuery.multiFilter(selector,this,true),"not",selector)}else{selector=jQuery.multiFilter(selector,this)}}var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector})},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector==="string"?jQuery(selector):jQuery.makeArray(selector))))},is:function(selector){return !!selector&&jQuery.multiFilter(selector,this).length>0},hasClass:function(selector){return !!selector&&this.is("."+selector)},val:function(value){if(value===undefined){var elem=this[0];if(elem){if(jQuery.nodeName(elem,"option")){return(elem.attributes.value||{}).specified?elem.value:elem.text}if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0){return null}for(var i=one?index:0,max=one?index+1:options.length;i=0||jQuery.inArray(this.name,value)>=0)}else{if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0)});if(!values.length){this.selectedIndex=-1}}else{this.value=value}}})},html:function(value){return value===undefined?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(value)},replaceWith:function(value){return this.after(value).remove()},eq:function(i){return this.slice(i,+i+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(args,table,callback){if(this[0]){var fragment=(this[0].ownerDocument||this[0]).createDocumentFragment(),scripts=jQuery.clean(args,(this[0].ownerDocument||this[0]),fragment),first=fragment.firstChild;if(first){for(var i=0,l=this.length;i1||i>0?fragment.cloneNode(true):fragment)}}if(scripts){jQuery.each(scripts,evalScript)}}return this;function root(elem,cur){return table&&jQuery.nodeName(elem,"table")&&jQuery.nodeName(cur,"tr")?(elem.getElementsByTagName("tbody")[0]||elem.appendChild(elem.ownerDocument.createElement("tbody"))):elem}}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src){jQuery.ajax({url:elem.src,async:false,dataType:"script"})}else{jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"")}if(elem.parentNode){elem.parentNode.removeChild(elem)}}function now(){return +new Date}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2}if(typeof target!=="object"&&!jQuery.isFunction(target)){target={}}if(length==i){target=this;--i}for(;i-1}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name]}callback.call(elem);for(var name in options){elem.style[name]=old[name]}},css:function(elem,name,force,extra){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;if(extra==="border"){return }jQuery.each(which,function(){if(!extra){val-=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0}if(extra==="margin"){val+=parseFloat(jQuery.curCSS(elem,"margin"+this,true))||0}else{val-=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0}})}if(elem.offsetWidth!==0){getWH()}else{jQuery.swap(elem,props,getWH)}return Math.max(0,Math.round(val))}return jQuery.curCSS(elem,name,force)},curCSS:function(elem,name,force){var ret,style=elem.style;if(name=="opacity"&&!jQuery.support.opacity){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret}if(name.match(/float/i)){name=styleFloat}if(!force&&style&&style[name]){ret=style[name]}else{if(defaultView.getComputedStyle){if(name.match(/float/i)){name="float"}name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle){ret=computedStyle.getPropertyValue(name)}if(name=="opacity"&&ret==""){ret="1"}}else{if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase()});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft}}}}return ret},clean:function(elems,context,fragment){context=context||document;if(typeof context.createElement==="undefined"){context=context.ownerDocument||context[0]&&context[0].ownerDocument||document}if(!fragment&&elems.length===1&&typeof elems[0]==="string"){var match=/^<(\w+)\s*\/?>$/.exec(elems[0]);if(match){return[context.createElement(match[1])]}}var ret=[],scripts=[],div=context.createElement("div");jQuery.each(elems,function(i,elem){if(typeof elem==="number"){elem+=""}if(!elem){return }if(typeof elem==="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+">"});var tags=elem.replace(/^\s+/,"").substring(0,10).toLowerCase();var wrap=!tags.indexOf("",""]||!tags.indexOf("",""]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!tags.indexOf("",""]||(!tags.indexOf("",""]||!tags.indexOf("",""]||!jQuery.support.htmlSerialize&&[1,"div
","
"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--){div=div.lastChild}if(!jQuery.support.tbody){var hasBody=/"&&!hasBody?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j){if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length){tbody[j].parentNode.removeChild(tbody[j])}}}if(!jQuery.support.leadingWhitespace&&/^\s/.test(elem)){div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild)}elem=jQuery.makeArray(div.childNodes)}if(elem.nodeType){ret.push(elem)}else{ret=jQuery.merge(ret,elem)}});if(fragment){for(var i=0;ret[i];i++){if(jQuery.nodeName(ret[i],"script")&&(!ret[i].type||ret[i].type.toLowerCase()==="text/javascript")){scripts.push(ret[i].parentNode?ret[i].parentNode.removeChild(ret[i]):ret[i])}else{if(ret[i].nodeType===1){ret.splice.apply(ret,[i+1,0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))))}fragment.appendChild(ret[i])}}return scripts}return ret},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8){return undefined}var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&elem.parentNode){elem.parentNode.selectedIndex}if(name in elem&¬xml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode){throw"type property can't be changed"}elem[name]=value}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name)){return elem.getAttributeNode(name).nodeValue}if(name=="tabIndex"){var attributeNode=elem.getAttributeNode("tabIndex");return attributeNode&&attributeNode.specified?attributeNode.value:elem.nodeName.match(/(button|input|object|select|textarea)/i)?0:elem.nodeName.match(/^(a|area)$/i)&&elem.href?0:undefined}return elem[name]}if(!jQuery.support.style&¬xml&&name=="style"){return jQuery.attr(elem.style,"cssText",value)}if(set){elem.setAttribute(name,""+value)}var attr=!jQuery.support.hrefNormalized&¬xml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr}if(!jQuery.support.opacity&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+""=="NaN"?"":"alpha(opacity="+value*100+")")}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase()});if(set){elem[name]=value}return elem[name]},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"")},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||typeof array==="string"||jQuery.isFunction(array)||array.setInterval){ret[0]=array}else{while(i){ret[--i]=array[i]}}}return ret},inArray:function(elem,array){for(var i=0,length=array.length;i0?this.clone(true):this).get();jQuery.fn[original].apply(jQuery(insert[i]),elems);ret=ret.concat(elems)}return this.pushStack(ret,name,selector)}});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1){this.removeAttribute(name)}},addClass:function(classNames){jQuery.className.add(this,classNames)},removeClass:function(classNames){jQuery.className.remove(this,classNames)},toggleClass:function(classNames,state){if(typeof state!=="boolean"){state=!jQuery.className.has(this,classNames)}jQuery.className[state?"add":"remove"](this,classNames)},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).length){jQuery("*",this).add([this]).each(function(){jQuery.event.remove(this);jQuery.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){jQuery(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments)}});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0}var expando="jQuery"+now(),uuid=0,windowData={};jQuery.extend({cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id){id=elem[expando]=++uuid}if(name&&!jQuery.cache[id]){jQuery.cache[id]={}}if(data!==undefined){jQuery.cache[id][name]=data}return name?jQuery.cache[id][name]:id},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id]){break}if(!name){jQuery.removeData(elem)}}}else{try{delete elem[expando]}catch(e){if(elem.removeAttribute){elem.removeAttribute(expando)}}delete jQuery.cache[id]}},queue:function(elem,type,data){if(elem){type=(type||"fx")+"queue";var q=jQuery.data(elem,type);if(!q||jQuery.isArray(data)){q=jQuery.data(elem,type,jQuery.makeArray(data))}else{if(data){q.push(data)}}}return q},dequeue:function(elem,type){var queue=jQuery.queue(elem,type),fn=queue.shift();if(!type||type==="fx"){fn=queue[0]}if(fn!==undefined){fn.call(elem)}}});jQuery.fn.extend({data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length){data=jQuery.data(this[0],key)}return data===undefined&&parts[1]?this.data(parts[0]):data}else{return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value)})}},removeData:function(key){return this.each(function(){jQuery.removeData(this,key)})},queue:function(type,data){if(typeof type!=="string"){data=type;type="fx"}if(data===undefined){return jQuery.queue(this[0],type)}return this.each(function(){var queue=jQuery.queue(this,type,data);if(type=="fx"&&queue.length==1){queue[0].call(this)}})},dequeue:function(type){return this.each(function(){jQuery.dequeue(this,type)})}}); +/* + * Sizzle CSS Selector Engine - v0.9.3 + * Copyright 2009, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var chunker=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,done=0,toString=Object.prototype.toString;var Sizzle=function(selector,context,results,seed){results=results||[];context=context||document;if(context.nodeType!==1&&context.nodeType!==9){return[]}if(!selector||typeof selector!=="string"){return results}var parts=[],m,set,checkSet,check,mode,extra,prune=true;chunker.lastIndex=0;while((m=chunker.exec(selector))!==null){parts.push(m[1]);if(m[2]){extra=RegExp.rightContext;break}}if(parts.length>1&&origPOS.exec(selector)){if(parts.length===2&&Expr.relative[parts[0]]){set=posProcess(parts[0]+parts[1],context)}else{set=Expr.relative[parts[0]]?[context]:Sizzle(parts.shift(),context);while(parts.length){selector=parts.shift();if(Expr.relative[selector]){selector+=parts.shift()}set=posProcess(selector,set)}}}else{var ret=seed?{expr:parts.pop(),set:makeArray(seed)}:Sizzle.find(parts.pop(),parts.length===1&&context.parentNode?context.parentNode:context,isXML(context));set=Sizzle.filter(ret.expr,ret.set);if(parts.length>0){checkSet=makeArray(set)}else{prune=false}while(parts.length){var cur=parts.pop(),pop=cur;if(!Expr.relative[cur]){cur=""}else{pop=parts.pop()}if(pop==null){pop=context}Expr.relative[cur](checkSet,pop,isXML(context))}}if(!checkSet){checkSet=set}if(!checkSet){throw"Syntax error, unrecognized expression: "+(cur||selector)}if(toString.call(checkSet)==="[object Array]"){if(!prune){results.push.apply(results,checkSet)}else{if(context.nodeType===1){for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&(checkSet[i]===true||checkSet[i].nodeType===1&&contains(context,checkSet[i]))){results.push(set[i])}}}else{for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&checkSet[i].nodeType===1){results.push(set[i])}}}}}else{makeArray(checkSet,results)}if(extra){Sizzle(extra,context,results,seed);if(sortOrder){hasDuplicate=false;results.sort(sortOrder);if(hasDuplicate){for(var i=1;i":function(checkSet,part,isXML){var isPartStr=typeof part==="string";if(isPartStr&&!/\W/.test(part)){part=isXML?part:part.toUpperCase();for(var i=0,l=checkSet.length;i=0)){if(!inplace){result.push(elem)}}else{if(inplace){curLoop[i]=false}}}}return false},ID:function(match){return match[1].replace(/\\/g,"")},TAG:function(match,curLoop){for(var i=0;curLoop[i]===false;i++){}return curLoop[i]&&isXML(curLoop[i])?match[1]:match[1].toUpperCase()},CHILD:function(match){if(match[1]=="nth"){var test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(match[2]=="even"&&"2n"||match[2]=="odd"&&"2n+1"||!/\D/.test(match[2])&&"0n+"+match[2]||match[2]);match[2]=(test[1]+(test[2]||1))-0;match[3]=test[3]-0}match[0]=done++;return match},ATTR:function(match,curLoop,inplace,result,not,isXML){var name=match[1].replace(/\\/g,"");if(!isXML&&Expr.attrMap[name]){match[1]=Expr.attrMap[name]}if(match[2]==="~="){match[4]=" "+match[4]+" "}return match},PSEUDO:function(match,curLoop,inplace,result,not){if(match[1]==="not"){if(match[3].match(chunker).length>1||/^\w/.test(match[3])){match[3]=Sizzle(match[3],null,null,curLoop)}else{var ret=Sizzle.filter(match[3],curLoop,inplace,true^not);if(!inplace){result.push.apply(result,ret)}return false}}else{if(Expr.match.POS.test(match[0])||Expr.match.CHILD.test(match[0])){return true}}return match},POS:function(match){match.unshift(true);return match}},filters:{enabled:function(elem){return elem.disabled===false&&elem.type!=="hidden"},disabled:function(elem){return elem.disabled===true},checked:function(elem){return elem.checked===true},selected:function(elem){elem.parentNode.selectedIndex;return elem.selected===true},parent:function(elem){return !!elem.firstChild},empty:function(elem){return !elem.firstChild},has:function(elem,i,match){return !!Sizzle(match[3],elem).length},header:function(elem){return/h\d/i.test(elem.nodeName)},text:function(elem){return"text"===elem.type},radio:function(elem){return"radio"===elem.type},checkbox:function(elem){return"checkbox"===elem.type},file:function(elem){return"file"===elem.type},password:function(elem){return"password"===elem.type},submit:function(elem){return"submit"===elem.type},image:function(elem){return"image"===elem.type},reset:function(elem){return"reset"===elem.type},button:function(elem){return"button"===elem.type||elem.nodeName.toUpperCase()==="BUTTON"},input:function(elem){return/input|select|textarea|button/i.test(elem.nodeName)}},setFilters:{first:function(elem,i){return i===0},last:function(elem,i,match,array){return i===array.length-1},even:function(elem,i){return i%2===0},odd:function(elem,i){return i%2===1},lt:function(elem,i,match){return imatch[3]-0},nth:function(elem,i,match){return match[3]-0==i},eq:function(elem,i,match){return match[3]-0==i}},filter:{PSEUDO:function(elem,match,i,array){var name=match[1],filter=Expr.filters[name];if(filter){return filter(elem,i,match,array)}else{if(name==="contains"){return(elem.textContent||elem.innerText||"").indexOf(match[3])>=0}else{if(name==="not"){var not=match[3];for(var i=0,l=not.length;i=0)}}},ID:function(elem,match){return elem.nodeType===1&&elem.getAttribute("id")===match},TAG:function(elem,match){return(match==="*"&&elem.nodeType===1)||elem.nodeName===match},CLASS:function(elem,match){return(" "+(elem.className||elem.getAttribute("class"))+" ").indexOf(match)>-1},ATTR:function(elem,match){var name=match[1],result=Expr.attrHandle[name]?Expr.attrHandle[name](elem):elem[name]!=null?elem[name]:elem.getAttribute(name),value=result+"",type=match[2],check=match[4];return result==null?type==="!=":type==="="?value===check:type==="*="?value.indexOf(check)>=0:type==="~="?(" "+value+" ").indexOf(check)>=0:!check?value&&result!==false:type==="!="?value!=check:type==="^="?value.indexOf(check)===0:type==="$="?value.substr(value.length-check.length)===check:type==="|="?value===check||value.substr(0,check.length+1)===check+"-":false},POS:function(elem,match,i,array){var name=match[2],filter=Expr.setFilters[name];if(filter){return filter(elem,i,match,array)}}}};var origPOS=Expr.match.POS;for(var type in Expr.match){Expr.match[type]=RegExp(Expr.match[type].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var makeArray=function(array,results){array=Array.prototype.slice.call(array);if(results){results.push.apply(results,array);return results}return array};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(e){makeArray=function(array,results){var ret=results||[];if(toString.call(array)==="[object Array]"){Array.prototype.push.apply(ret,array)}else{if(typeof array.length==="number"){for(var i=0,l=array.length;i";var root=document.documentElement;root.insertBefore(form,root.firstChild);if(!!document.getElementById(id)){Expr.find.ID=function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?m.id===match[1]||typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id").nodeValue===match[1]?[m]:undefined:[]}};Expr.filter.ID=function(elem,match){var node=typeof elem.getAttributeNode!=="undefined"&&elem.getAttributeNode("id");return elem.nodeType===1&&node&&node.nodeValue===match}}root.removeChild(form)})();(function(){var div=document.createElement("div");div.appendChild(document.createComment(""));if(div.getElementsByTagName("*").length>0){Expr.find.TAG=function(match,context){var results=context.getElementsByTagName(match[1]);if(match[1]==="*"){var tmp=[];for(var i=0;results[i];i++){if(results[i].nodeType===1){tmp.push(results[i])}}results=tmp}return results}}div.innerHTML="";if(div.firstChild&&typeof div.firstChild.getAttribute!=="undefined"&&div.firstChild.getAttribute("href")!=="#"){Expr.attrHandle.href=function(elem){return elem.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var oldSizzle=Sizzle,div=document.createElement("div");div.innerHTML="

";if(div.querySelectorAll&&div.querySelectorAll(".TEST").length===0){return }Sizzle=function(query,context,extra,seed){context=context||document;if(!seed&&context.nodeType===9&&!isXML(context)){try{return makeArray(context.querySelectorAll(query),extra)}catch(e){}}return oldSizzle(query,context,extra,seed)};Sizzle.find=oldSizzle.find;Sizzle.filter=oldSizzle.filter;Sizzle.selectors=oldSizzle.selectors;Sizzle.matches=oldSizzle.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var div=document.createElement("div");div.innerHTML="
";if(div.getElementsByClassName("e").length===0){return }div.lastChild.className="e";if(div.getElementsByClassName("e").length===1){return }Expr.order.splice(1,0,"CLASS");Expr.find.CLASS=function(match,context,isXML){if(typeof context.getElementsByClassName!=="undefined"&&!isXML){return context.getElementsByClassName(match[1])}}})()}function dirNodeCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){var sibDir=dir=="previousSibling"&&!isXML;for(var i=0,l=checkSet.length;i0){match=elem;break}}}elem=elem[dir]}checkSet[i]=match}}}var contains=document.compareDocumentPosition?function(a,b){return a.compareDocumentPosition(b)&16}:function(a,b){return a!==b&&(a.contains?a.contains(b):true)};var isXML=function(elem){return elem.nodeType===9&&elem.documentElement.nodeName!=="HTML"||!!elem.ownerDocument&&isXML(elem.ownerDocument)};var posProcess=function(selector,context){var tmpSet=[],later="",match,root=context.nodeType?[context]:context;while((match=Expr.match.PSEUDO.exec(selector))){later+=match[0];selector=selector.replace(Expr.match.PSEUDO,"")}selector=Expr.relative[selector]?selector+"*":selector;for(var i=0,l=root.length;i0||elem.offsetHeight>0};Sizzle.selectors.filters.animated=function(elem){return jQuery.grep(jQuery.timers,function(fn){return elem===fn.elem}).length};jQuery.multiFilter=function(expr,elems,not){if(not){expr=":not("+expr+")"}return Sizzle.matches(expr,elems)};jQuery.dir=function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1){matched.push(cur)}cur=cur[dir]}return matched};jQuery.nth=function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir]){if(cur.nodeType==1&&++num==result){break}}return cur};jQuery.sibling=function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem){r.push(n)}}return r};return ;window.Sizzle=Sizzle})();jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8){return }if(elem.setInterval&&elem!=window){elem=window}if(!handler.guid){handler.guid=this.guid++}if(data!==undefined){var fn=handler;handler=this.proxy(fn);handler.data=data}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){return typeof jQuery!=="undefined"&&!jQuery.event.triggered?jQuery.event.handle.apply(arguments.callee.elem,arguments):undefined});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var namespaces=type.split(".");type=namespaces.shift();handler.type=namespaces.slice().sort().join(".");var handlers=events[type];if(jQuery.event.specialAll[type]){jQuery.event.specialAll[type].setup.call(elem,data,namespaces)}if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem,data,namespaces)===false){if(elem.addEventListener){elem.addEventListener(type,handle,false)}else{if(elem.attachEvent){elem.attachEvent("on"+type,handle)}}}}handlers[handler.guid]=handler;jQuery.event.global[type]=true});elem=null},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8){return }var events=jQuery.data(elem,"events"),ret,index;if(events){if(types===undefined||(typeof types==="string"&&types.charAt(0)==".")){for(var type in events){this.remove(elem,type+(types||""))}}else{if(types.type){handler=types.handler;types=types.type}jQuery.each(types.split(/\s+/),function(index,type){var namespaces=type.split(".");type=namespaces.shift();var namespace=RegExp("(^|\\.)"+namespaces.slice().sort().join(".*\\.")+"(\\.|$)");if(events[type]){if(handler){delete events[type][handler.guid]}else{for(var handle in events[type]){if(namespace.test(events[type][handle].type)){delete events[type][handle]}}}if(jQuery.event.specialAll[type]){jQuery.event.specialAll[type].teardown.call(elem,namespaces)}for(ret in events[type]){break}if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem,namespaces)===false){if(elem.removeEventListener){elem.removeEventListener(type,jQuery.data(elem,"handle"),false)}else{if(elem.detachEvent){elem.detachEvent("on"+type,jQuery.data(elem,"handle"))}}}ret=null;delete events[type]}}})}for(ret in events){break}if(!ret){var handle=jQuery.data(elem,"handle");if(handle){handle.elem=null}jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle")}}},trigger:function(event,data,elem,bubbling){var type=event.type||event;if(!bubbling){event=typeof event==="object"?event[expando]?event:jQuery.extend(jQuery.Event(type),event):jQuery.Event(type);if(type.indexOf("!")>=0){event.type=type=type.slice(0,-1);event.exclusive=true}if(!elem){event.stopPropagation();if(this.global[type]){jQuery.each(jQuery.cache,function(){if(this.events&&this.events[type]){jQuery.event.trigger(event,data,this.handle.elem)}})}}if(!elem||elem.nodeType==3||elem.nodeType==8){return undefined}event.result=undefined;event.target=elem;data=jQuery.makeArray(data);data.unshift(event)}event.currentTarget=elem;var handle=jQuery.data(elem,"handle");if(handle){handle.apply(elem,data)}if((!elem[type]||(jQuery.nodeName(elem,"a")&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false){event.result=false}if(!bubbling&&elem[type]&&!event.isDefaultPrevented()&&!(jQuery.nodeName(elem,"a")&&type=="click")){this.triggered=true;try{elem[type]()}catch(e){}}this.triggered=false;if(!event.isPropagationStopped()){var parent=elem.parentNode||elem.ownerDocument;if(parent){jQuery.event.trigger(event,data,parent,true)}}},handle:function(event){var all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);event.currentTarget=this;var namespaces=event.type.split(".");event.type=namespaces.shift();all=!namespaces.length&&!event.exclusive;var namespace=RegExp("(^|\\.)"+namespaces.slice().sort().join(".*\\.")+"(\\.|$)");handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||namespace.test(handler.type)){event.handler=handler;event.data=handler.data;var ret=handler.apply(this,arguments);if(ret!==undefined){event.result=ret;if(ret===false){event.preventDefault();event.stopPropagation()}}if(event.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(event){if(event[expando]){return event}var originalEvent=event;event=jQuery.Event(originalEvent);for(var i=this.props.length,prop;i;){prop=this.props[--i];event[prop]=originalEvent[prop]}if(!event.target){event.target=event.srcElement||document}if(event.target.nodeType==3){event.target=event.target.parentNode}if(!event.relatedTarget&&event.fromElement){event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement}if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0)}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode)){event.which=event.charCode||event.keyCode}if(!event.metaKey&&event.ctrlKey){event.metaKey=event.ctrlKey}if(!event.which&&event.button){event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)))}return event},proxy:function(fn,proxy){proxy=proxy||function(){return fn.apply(this,arguments)};proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy},special:{ready:{setup:bindReady,teardown:function(){}}},specialAll:{live:{setup:function(selector,namespaces){jQuery.event.add(this,namespaces[0],liveHandler)},teardown:function(namespaces){if(namespaces.length){var remove=0,name=RegExp("(^|\\.)"+namespaces[0]+"(\\.|$)");jQuery.each((jQuery.data(this,"events").live||{}),function(){if(name.test(this.type)){remove++}});if(remove<1){jQuery.event.remove(this,namespaces[0],liveHandler)}}}}}};jQuery.Event=function(src){if(!this.preventDefault){return new jQuery.Event(src)}if(src&&src.type){this.originalEvent=src;this.type=src.type}else{this.type=src}this.timeStamp=now();this[expando]=true};function returnFalse(){return false}function returnTrue(){return true}jQuery.Event.prototype={preventDefault:function(){this.isDefaultPrevented=returnTrue;var e=this.originalEvent;if(!e){return }if(e.preventDefault){e.preventDefault()}e.returnValue=false},stopPropagation:function(){this.isPropagationStopped=returnTrue;var e=this.originalEvent;if(!e){return }if(e.stopPropagation){e.stopPropagation()}e.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=returnTrue;this.stopPropagation()},isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse};var withinElement=function(event){var parent=event.relatedTarget;while(parent&&parent!=this){try{parent=parent.parentNode}catch(e){parent=this}}if(parent!=this){event.type=event.data;jQuery.event.handle.apply(this,arguments)}};jQuery.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(orig,fix){jQuery.event.special[fix]={setup:function(){jQuery.event.add(this,orig,withinElement,fix)},teardown:function(){jQuery.event.remove(this,orig,withinElement)}}});jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data)})},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments)});return this.each(function(){jQuery.event.add(this,type,one,fn&&data)})},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn)})},trigger:function(type,data){return this.each(function(){jQuery.event.trigger(type,data,this)})},triggerHandler:function(type,data){if(this[0]){var event=jQuery.Event(type);event.preventDefault();event.stopPropagation();jQuery.event.trigger(event,data,this[0]);return event.result}},toggle:function(fn){var args=arguments,i=1;while(i=0){var selector=url.slice(off,url.length);url=url.slice(0,off)}var type="GET";if(params){if(jQuery.isFunction(params)){callback=params;params=null}else{if(typeof params==="object"){params=jQuery.param(params);type="POST"}}}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified"){self.html(selector?jQuery("
").append(res.responseText.replace(//g,"")).find(selector):res.responseText)}if(callback){self.each(callback,[res.responseText,status,res])}}});return this},serialize:function(){return jQuery.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?jQuery.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:jQuery.isArray(val)?jQuery.map(val,function(val,i){return{name:elem.name,value:val}}):{name:elem.name,value:val}}).get()}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f)}});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type})},getScript:function(url,callback){return jQuery.get(url,null,callback,"script")},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json")},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={}}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type})},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!=="string"){s.data=jQuery.param(s.data)}if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre)){s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?"}}else{if(!s.data||!s.data.match(jsre)){s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?"}}s.dataType="json"}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data){s.data=(s.data+"").replace(jsre,"="+jsonp+"$1")}s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp]}catch(e){}if(head){head.removeChild(script)}}}if(s.dataType=="script"&&s.cache==null){s.cache=false}if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"")}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null}if(s.global&&!jQuery.active++){jQuery.event.trigger("ajaxStart")}var parts=/^(\w+:)?\/\/([^\/?#]+)/.exec(s.url);if(s.dataType=="script"&&type=="GET"&&parts&&(parts[1]&&parts[1]!=location.protocol||parts[2]!=location.host)){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset){script.charset=s.scriptCharset}if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();script.onload=script.onreadystatechange=null;head.removeChild(script)}}}head.appendChild(script);return undefined}var requestDone=false;var xhr=s.xhr();if(s.username){xhr.open(type,s.url,s.async,s.username,s.password)}else{xhr.open(type,s.url,s.async)}try{if(s.data){xhr.setRequestHeader("Content-Type",s.contentType)}if(s.ifModified){xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default)}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop")}xhr.abort();return false}if(s.global){jQuery.event.trigger("ajaxSend",[xhr,s])}var onreadystatechange=function(isTimeout){if(xhr.readyState==0){if(ival){clearInterval(ival);ival=null;if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop")}}}else{if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null}status=isTimeout=="timeout"?"timeout":!jQuery.httpSuccess(xhr)?"error":s.ifModified&&jQuery.httpNotModified(xhr,s.url)?"notmodified":"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s)}catch(e){status="parsererror"}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified")}catch(e){}if(s.ifModified&&modRes){jQuery.lastModified[s.url]=modRes}if(!jsonp){success()}}else{jQuery.handleError(s,xhr,status)}complete();if(isTimeout){xhr.abort()}if(s.async){xhr=null}}}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0){setTimeout(function(){if(xhr&&!requestDone){onreadystatechange("timeout")}},s.timeout)}}try{xhr.send(s.data)}catch(e){jQuery.handleError(s,xhr,null,e)}if(!s.async){onreadystatechange()}function success(){if(s.success){s.success(data,status)}if(s.global){jQuery.event.trigger("ajaxSuccess",[xhr,s])}}function complete(){if(s.complete){s.complete(xhr,status)}if(s.global){jQuery.event.trigger("ajaxComplete",[xhr,s])}if(s.global&&!--jQuery.active){jQuery.event.trigger("ajaxStop")}}return xhr},handleError:function(s,xhr,status,e){if(s.error){s.error(xhr,status,e)}if(s.global){jQuery.event.trigger("ajaxError",[xhr,s,e])}},active:0,httpSuccess:function(xhr){try{return !xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223}catch(e){}return false},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]}catch(e){}return false},httpData:function(xhr,type,s){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror"){throw"parsererror"}if(s&&s.dataFilter){data=s.dataFilter(data,type)}if(typeof data==="string"){if(type=="script"){jQuery.globalEval(data)}if(type=="json"){data=window["eval"]("("+data+")")}}return data},param:function(a){var s=[];function add(key,value){s[s.length]=encodeURIComponent(key)+"="+encodeURIComponent(value)}if(jQuery.isArray(a)||a.jquery){jQuery.each(a,function(){add(this.name,this.value)})}else{for(var j in a){if(jQuery.isArray(a[j])){jQuery.each(a[j],function(){add(j,this)})}else{add(j,jQuery.isFunction(a[j])?a[j]():a[j])}}}return s.join("&").replace(/%20/g,"+")}});var elemdisplay={},timerId,fxAttrs=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function genFx(type,num){var obj={};jQuery.each(fxAttrs.concat.apply([],fxAttrs.slice(0,num)),function(){obj[this]=type});return obj}jQuery.fn.extend({show:function(speed,callback){if(speed){return this.animate(genFx("show",3),speed,callback)}else{for(var i=0,l=this.length;i").appendTo("body");display=elem.css("display");if(display==="none"){display="block"}elem.remove();elemdisplay[tagName]=display}jQuery.data(this[i],"olddisplay",display)}}for(var i=0,l=this.length;i=0;i--){if(timers[i].elem==this){if(gotoEnd){timers[i](true)}timers.splice(i,1)}}});if(!gotoEnd){this.dequeue()}return this}});jQuery.each({slideDown:genFx("show",1),slideUp:genFx("hide",1),slideToggle:genFx("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(name,props){jQuery.fn[name]=function(speed,callback){return this.animate(props,speed,callback)}});jQuery.extend({speed:function(speed,easing,fn){var opt=typeof speed==="object"?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&!jQuery.isFunction(easing)&&easing};opt.duration=jQuery.fx.off?0:typeof opt.duration==="number"?opt.duration:jQuery.fx.speeds[opt.duration]||jQuery.fx.speeds._default;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false){jQuery(this).dequeue()}if(jQuery.isFunction(opt.old)){opt.old.call(this)}};return opt},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum}},timers:[],fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig){options.orig={}}}});jQuery.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(force){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;var self=this;function t(gotoEnd){return self.step(gotoEnd)}t.elem=this.elem;if(t()&&jQuery.timers.push(t)&&!timerId){timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim){if(this.options.curAnim[i]!==true){done=false}}if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){jQuery(this.elem).hide()}if(this.options.hide||this.options.show){for(var p in this.options.curAnim){jQuery.attr(this.elem.style,p,this.options.orig[p])}}this.options.complete.call(this.elem)}return false}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now)},_default:function(fx){if(fx.elem.style&&fx.elem.style[fx.prop]!=null){fx.elem.style[fx.prop]=fx.now+fx.unit}else{fx.elem[fx.prop]=fx.now}}}});if(document.documentElement.getBoundingClientRect){jQuery.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return jQuery.offset.bodyOffset(this[0])}var box=this[0].getBoundingClientRect(),doc=this[0].ownerDocument,body=doc.body,docElem=doc.documentElement,clientTop=docElem.clientTop||body.clientTop||0,clientLeft=docElem.clientLeft||body.clientLeft||0,top=box.top+(self.pageYOffset||jQuery.boxModel&&docElem.scrollTop||body.scrollTop)-clientTop,left=box.left+(self.pageXOffset||jQuery.boxModel&&docElem.scrollLeft||body.scrollLeft)-clientLeft;return{top:top,left:left}}}else{jQuery.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return jQuery.offset.bodyOffset(this[0])}jQuery.offset.initialized||jQuery.offset.initialize();var elem=this[0],offsetParent=elem.offsetParent,prevOffsetParent=elem,doc=elem.ownerDocument,computedStyle,docElem=doc.documentElement,body=doc.body,defaultView=doc.defaultView,prevComputedStyle=defaultView.getComputedStyle(elem,null),top=elem.offsetTop,left=elem.offsetLeft;while((elem=elem.parentNode)&&elem!==body&&elem!==docElem){computedStyle=defaultView.getComputedStyle(elem,null);top-=elem.scrollTop,left-=elem.scrollLeft;if(elem===offsetParent){top+=elem.offsetTop,left+=elem.offsetLeft;if(jQuery.offset.doesNotAddBorder&&!(jQuery.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(elem.tagName))){top+=parseInt(computedStyle.borderTopWidth,10)||0,left+=parseInt(computedStyle.borderLeftWidth,10)||0}prevOffsetParent=offsetParent,offsetParent=elem.offsetParent}if(jQuery.offset.subtractsBorderForOverflowNotVisible&&computedStyle.overflow!=="visible"){top+=parseInt(computedStyle.borderTopWidth,10)||0,left+=parseInt(computedStyle.borderLeftWidth,10)||0}prevComputedStyle=computedStyle}if(prevComputedStyle.position==="relative"||prevComputedStyle.position==="static"){top+=body.offsetTop,left+=body.offsetLeft}if(prevComputedStyle.position==="fixed"){top+=Math.max(docElem.scrollTop,body.scrollTop),left+=Math.max(docElem.scrollLeft,body.scrollLeft)}return{top:top,left:left}}}jQuery.offset={initialize:function(){if(this.initialized){return }var body=document.body,container=document.createElement("div"),innerDiv,checkDiv,table,td,rules,prop,bodyMarginTop=body.style.marginTop,html='
';rules={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(prop in rules){container.style[prop]=rules[prop]}container.innerHTML=html;body.insertBefore(container,body.firstChild);innerDiv=container.firstChild,checkDiv=innerDiv.firstChild,td=innerDiv.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(checkDiv.offsetTop!==5);this.doesAddBorderForTableAndCells=(td.offsetTop===5);innerDiv.style.overflow="hidden",innerDiv.style.position="relative";this.subtractsBorderForOverflowNotVisible=(checkDiv.offsetTop===-5);body.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(body.offsetTop===0);body.style.marginTop=bodyMarginTop;body.removeChild(container);this.initialized=true},bodyOffset:function(body){jQuery.offset.initialized||jQuery.offset.initialize();var top=body.offsetTop,left=body.offsetLeft;if(jQuery.offset.doesNotIncludeMarginInBodyOffset){top+=parseInt(jQuery.curCSS(body,"marginTop",true),10)||0,left+=parseInt(jQuery.curCSS(body,"marginLeft",true),10)||0}return{top:top,left:left}}};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,"marginTop");offset.left-=num(this,"marginLeft");parentOffset.top+=num(offsetParent,"borderTopWidth");parentOffset.left+=num(offsetParent,"borderLeftWidth");results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left}}return results},offsetParent:function(){var offsetParent=this[0].offsetParent||document.body;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,"position")=="static")){offsetParent=offsetParent.offsetParent}return jQuery(offsetParent)}});jQuery.each(["Left","Top"],function(i,name){var method="scroll"+name;jQuery.fn[method]=function(val){if(!this[0]){return null}return val!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val}):this[0]==window||this[0]==document?self[i?"pageYOffset":"pageXOffset"]||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method]}});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom",lower=name.toLowerCase();jQuery.fn["inner"+name]=function(){return this[0]?jQuery.css(this[0],lower,false,"padding"):null};jQuery.fn["outer"+name]=function(margin){return this[0]?jQuery.css(this[0],lower,false,margin?"margin":"border"):null};var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(document.documentElement["client"+name],document.body["scroll"+name],document.documentElement["scroll"+name],document.body["offset"+name],document.documentElement["offset"+name]):size===undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,typeof size==="string"?size:size+"px")}})})(); \ No newline at end of file