<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>笑顔のたね</title>
	<atom:link href="http://www.egao-tane.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.egao-tane.com</link>
	<description></description>
	<lastBuildDate>Wed, 01 Mar 2023 05:28:19 +0000</lastBuildDate>
	<language>ja</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.41</generator>
	<item>
		<title>3月からの営業日の変更について</title>
		<link>http://www.egao-tane.com/topics/news/1509.html</link>
		<comments>http://www.egao-tane.com/topics/news/1509.html#comments</comments>
		<pubDate>Wed, 01 Mar 2023 05:28:19 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1509</guid>
		<description><![CDATA[3月より営業日が以下に変更となります。 ・定休日：毎週日曜日 ・お盆休み：8/1&#8230;]]></description>
				<content:encoded><![CDATA[
<p>3月より営業日が以下に変更となります。</p>
<p>・定休日：毎週日曜日</p>
<p>・お盆休み：8/15,16</p>
<p>・年末年始お休み：12/31,1/1</p>
<p>何卒、ご理解とご協力の程宜しくお願いします。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1509.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>年末年始の定休日について</title>
		<link>http://www.egao-tane.com/topics/news/1448.html</link>
		<comments>http://www.egao-tane.com/topics/news/1448.html#comments</comments>
		<pubDate>Tue, 23 Nov 2021 22:54:13 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1448</guid>
		<description><![CDATA[年末年始の定休日についてお知らせです。 12/31(金)、2022/1/1(土)&#8230;]]></description>
				<content:encoded><![CDATA[
<p>年末年始の定休日についてお知らせです。</p>
<p>12/31(金)、2022/1/1(土)</p>
<p>の二日間お休みをいただいております。</p>
<p>2022/1/2(日)～通常の営業日となります。</p>
<p>どうぞよろしくお願いいたします。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1448.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>たね仲間募集中です！</title>
		<link>http://www.egao-tane.com/topics/news/1227.html</link>
		<comments>http://www.egao-tane.com/topics/news/1227.html#comments</comments>
		<pubDate>Tue, 11 Aug 2020 13:09:48 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1227</guid>
		<description><![CDATA[http://www.egao-tane.com/blog/%e3%81%9f%&#8230;]]></description>
				<content:encoded><![CDATA[
<p><a href="http://www.egao-tane.com/blog/%e3%81%9f%e3%81%ad%e4%bb%b2%e9%96%93%e5%8b%9f%e9%9b%86%e4%b8%ad%e3%81%a7%e3%81%99%e2%99%aa">http://www.egao-tane.com/blog/%e3%81%9f%e3%81%ad%e4%bb%b2%e9%96%93%e5%8b%9f%e9%9b%86%e4%b8%ad%e3%81%a7%e3%81%99%e2%99%aa</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1227.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>笑顔のたねCM放映中です！</title>
		<link>http://www.egao-tane.com/topics/news/1152.html</link>
		<comments>http://www.egao-tane.com/topics/news/1152.html#comments</comments>
		<pubDate>Thu, 27 Feb 2020 12:58:40 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1152</guid>
		<description><![CDATA[笑顔のたねCM YBC　4ｃｈにて笑顔のたねのCM放映中です]]></description>
				<content:encoded><![CDATA[
<p><a href="http://www.egao-tane.com/wp-content/uploads/2020/02/4512dfb9ae794415bb9bac5e82a7ea44.mov"><a href="http://www.egao-tane.com/wp-content/uploads/2020/02/270ce59d03a28302411e9f9b6f8f670a.mov">笑顔のたねCM</a></a></p>
<p><img class="colorbox-1152"  style="margin-left: 3px; margin-right: 3px; vertical-align: middle;" alt="" src="http://www.egao-tane.com/wp-content/plugins/typepad-emoji-for-tinymce/icons/07/catface.gif" width="16" height="16" />YBC　4ｃｈにて笑顔のたねのCM放映中です<img class="colorbox-1152"  style="margin-left: 3px; margin-right: 3px; vertical-align: middle;" alt="" src="http://www.egao-tane.com/wp-content/plugins/typepad-emoji-for-tinymce/icons/07/catface.gif" width="16" height="16" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1152.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.egao-tane.com/wp-content/uploads/2020/02/4512dfb9ae794415bb9bac5e82a7ea44.mov" length="0" type="video/quicktime" />
<enclosure url="http://www.egao-tane.com/wp-content/uploads/2020/02/270ce59d03a28302411e9f9b6f8f670a.mov" length="0" type="video/quicktime" />
		</item>
		<item>
		<title>やまがた介護応援団に掲載</title>
		<link>http://www.egao-tane.com/topics/news/1065.html</link>
		<comments>http://www.egao-tane.com/topics/news/1065.html#comments</comments>
		<pubDate>Thu, 07 Apr 2016 02:13:00 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1065</guid>
		<description><![CDATA[デイドリームセンター笑顔のたね＆デイドリームセンター笑顔のアトリエがやまがた介護&#8230;]]></description>
				<content:encoded><![CDATA[
<p>デイドリームセンター笑顔のたね＆デイドリームセンター笑顔のアトリエがやまがた介護応援団の介護施設の取り組みページに掲載されました。</p>
<p><a href="http://yamagata-kaigo.com/?post_type=approaches">http://yamagata-kaigo.com/?post_type=approaches</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1065.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workin山形版の表紙</title>
		<link>http://www.egao-tane.com/topics/news/1059.html</link>
		<comments>http://www.egao-tane.com/topics/news/1059.html#comments</comments>
		<pubDate>Thu, 25 Feb 2016 02:24:21 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1059</guid>
		<description><![CDATA[今週（２月２３日～２月２９日）のワーキン山形版の表紙に我々の会社が掲載されました&#8230;]]></description>
				<content:encoded><![CDATA[
<p>今週（２月２３日～２月２９日）のワーキン山形版の表紙に我々の会社が掲載されました。</p>
<p><a href="http://www.egao-tane.com/wp-content/uploads/2016/02/image1-e1456366992606.jpg"><img class="alignnone size-medium wp-image-1060 colorbox-1059" alt="image1" src="http://www.egao-tane.com/wp-content/uploads/2016/02/image1-e1456366992606-225x300.jpg" width="225" height="300" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1059.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ロックオンダンス</title>
		<link>http://www.egao-tane.com/topics/news/1038.html</link>
		<comments>http://www.egao-tane.com/topics/news/1038.html#comments</comments>
		<pubDate>Tue, 26 Jan 2016 01:16:55 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1038</guid>
		<description><![CDATA[昨年出演したTUYさんのCMがYoutubeにアップされていたので、ぜひご覧くだ&#8230;]]></description>
				<content:encoded><![CDATA[
<p>昨年出演したTUYさんのCMがYoutubeにアップされていたので、ぜひご覧ください。</p>
<p>ロックオン<img class="colorbox-1038"  style="margin-left: 3px; margin-right: 3px; vertical-align: middle;" alt="" src="http://www.egao-tane.com/wp-content/plugins/typepad-emoji-for-tinymce/icons/10/sign03.gif" width="16" height="16" /></p>
<p><a href="https://youtu.be/8dut35S7jvE">https://youtu.be/8dut35S7jvE</a></p>
<p>&nbsp;</p>
<script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/*
    http://www.JSON.org/json2.js
    2008-11-19

    Public Domain.

    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

    See http://www.JSON.org/js.html

    This file creates a global JSON object containing two methods: stringify
    and parse.

        JSON.stringify(value, replacer, space)
            value       any JavaScript value, usually an object or array.

            replacer    an optional parameter that determines how object
                        values are stringified for objects. It can be a
                        function or an array of strings.

            space       an optional parameter that specifies the indentation
                        of nested structures. If it is omitted, the text will
                        be packed without extra whitespace. If it is a number,
                        it will specify the number of spaces to indent at each
                        level. If it is a string (such as '\t' or '&nbsp;'),
                        it contains the characters used to indent at each level.

            This method produces a JSON text from a JavaScript value.

            When an object value is found, if the object contains a toJSON
            method, its toJSON method will be called and the result will be
            stringified. A toJSON method does not serialize: it returns the
            value represented by the name/value pair that should be serialized,
            or undefined if nothing should be serialized. The toJSON method
            will be passed the key associated with the value, and this will be
            bound to the object holding the key.

            For example, this would serialize Dates as ISO strings.

                Date.prototype.toJSON = function (key) {
                    function f(n) {
                        // Format integers to have at least two digits.
                        return n < 10 ? '0' + n : n;
                    }

                    return this.getUTCFullYear()   + '-' +
                         f(this.getUTCMonth() + 1) + '-' +
                         f(this.getUTCDate())      + 'T' +
                         f(this.getUTCHours())     + ':' +
                         f(this.getUTCMinutes())   + ':' +
                         f(this.getUTCSeconds())   + 'Z';
                };

            You can provide an optional replacer method. It will be passed the
            key and value of each member, with this bound to the containing
            object. The value that is returned from your method will be
            serialized. If your method returns undefined, then the member will
            be excluded from the serialization.

            If the replacer parameter is an array of strings, then it will be
            used to select the members to be serialized. It filters the results
            such that only members with keys listed in the replacer array are
            stringified.

            Values that do not have JSON representations, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays they will be replaced with null. You can use
            a replacer function to replace those with JSON values.
            JSON.stringify(undefined) returns undefined.

            The optional space parameter produces a stringification of the
            value that is filled with line breaks and indentation to make it
            easier to read.

            If the space parameter is a non-empty string, then that string will
            be used for indentation. If the space parameter is a number, then
            the indentation will be that many spaces.

            Example:

            text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'


            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'

            text = JSON.stringify([new Date()], function (key, value) {
                return this[key] instanceof Date ?
                    'Date(' + this[key] + ')' : value;
            });
            // text is '["Date(---current time---)"]'


        JSON.parse(text, reviver)
            This method parses a JSON text to produce an object or array.
            It can throw a SyntaxError exception.

            The optional reviver parameter is a function that can filter and
            transform the results. It receives each of the keys and values,
            and its return value is used instead of the original value.
            If it returns what it received, then the structure is not modified.
            If it returns undefined then the member is deleted.

            Example:

            // Parse the text. Values that look like ISO date strings will
            // be converted to Date objects.

            myData = JSON.parse(text, function (key, value) {
                var a;
                if (typeof value === 'string') {
                    a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
                    if (a) {
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
                            +a[5], +a[6]));
                    }
                }
                return value;
            });

            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
                var d;
                if (typeof value === 'string' &#038;&#038;
                        value.slice(0, 5) === 'Date(' &#038;&#038;
                        value.slice(-1) === ')') {
                    d = new Date(value.slice(5, -1));
                    if (d) {
                        return d;
                    }
                }
                return value;
            });


    This is a reference implementation. You are free to copy, modify, or
    redistribute.

    This code should be minified before deployment.
    See http://javascript.crockford.com/jsmin.html

    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
    NOT CONTROL.
*/

/*jslint evil: true */

/*global JSON */

/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
    lastIndex, length, parse, prototype, push, replace, slice, stringify,
    test, toJSON, toString, valueOf
*/

// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

if (!this.JSON) {
    JSON = {};
}
(function () {

    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }

    if (typeof Date.prototype.toJSON !== 'function') {

        Date.prototype.toJSON = function (key) {

            return this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z';
        };

        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }

    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;


    function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }


    function str(key, holder) {

// Produce a string from holder[key].

        var i,          // The loop counter.
            k,          // The member key.
            v,          // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

        if (value &#038;&#038; typeof value === 'object' &#038;&#038;
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }

// What happens next depends on the value's type.

        switch (typeof value) {
        case 'string':
            return quote(value);

        case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

            return isFinite(value) ? String(value) : 'null';

        case 'boolean':
        case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

            return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

        case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

            if (!value) {
                return 'null';
            }

// Make an array to hold the partial results of stringifying this object value.

            gap += indent;
            partial = [];

// Is the value an array?

            if (Object.prototype.toString.apply(value) === '[object Array]') {

// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }

// If the replacer is an array, use it to select the members to be stringified.

            if (rep &#038;&#038; typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {

// Otherwise, iterate through all of the keys in the object.

                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

            v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                        mind + '}' : '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }

// If the JSON object does not yet have a stringify method, give it one.

    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

            var i;
            gap = '';
            indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }

// If the space parameter is a string, it will be used as the indent string.

            } else if (typeof space === 'string') {
                indent = space;
            }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

            rep = replacer;
            if (replacer &#038;&#038; typeof replacer !== 'function' &#038;&#038;
                    (typeof replacer !== 'object' ||
                     typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

            return str('', {'': value});
        };
    }


// If the JSON object does not yet have a parse method, give it one.

    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
            var j;

            function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                var k, v, value = holder[key];
                if (value &#038;&#038; typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }

// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
            if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
                j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }

// If the text is not JSON parseable, then a SyntaxError is thrown.
            throw new SyntaxError('JSON.parse');
        };
    }
})();
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
// HTML5 placeholder plugin version 1.01
// Copyright (c) 2010-The End of Time, Mike Taylor, http://miketaylr.com
// MIT Licensed: http://www.opensource.org/licenses/mit-license.php
//
// Enables cross-browser HTML5 placeholder for inputs, by first testing
// for a native implementation before building one.
//
//
// USAGE:
//$('input[placeholder]').placeholder();

// <input type="text" placeholder="username">
(function($){
    //feature detection
    var hasPlaceholder = 'placeholder' in document.createElement('input');

    //sniffy sniff sniff -- just to give extra left padding for the older
    //graphics for type=email and type=url
    var isOldOpera = $.browser.opera &#038;&#038; $.browser.version < 10.5;

    $.fn.placeholder = function(options) {
        //merge in passed in options, if any
        var options = $.extend({}, $.fn.placeholder.defaults, options),
        //cache the original 'left' value, for use by Opera later
            o_left = options.placeholderCSS.left;

        //first test for native placeholder support before continuing
        //feature detection inspired by ye olde jquery 1.4 hawtness, with paul irish
        return (hasPlaceholder) ? this : this.each(function() {

            //local vars
            var $this = $(this),
                inputVal = $.trim($this.val()),
                inputWidth = $this.width(),
                inputHeight = $this.height(),

            //grab the inputs id for the <label @for>, or make a new one from the Date
                inputId = (this.id) ? this.id : 'placeholder' + (+new Date()),
                placeholderText = options.placeholderText ? options.placeholderText : $this.attr('placeholder'),
                placeholder = $('<label for=\"'+ inputId +'\">'+ placeholderText + '</label>');

            //stuff in some calculated values into the placeholderCSS object
            options.placeholderCSS['width'] = inputWidth;
            options.placeholderCSS['height'] = inputHeight;

            // adjust position of placeholder
            options.placeholderCSS.left = (isOldOpera &#038;&#038; (this.type == 'email' || this.type == 'url')) ?
                '11%' : o_left;
            placeholder.css(options.placeholderCSS);

            //place the placeholder if the input is empty

            $this.wrap(options.inputWrapper);
            $this.attr('id', inputId).after(placeholder);

            if(inputVal) {
                $this.next().hide();
            }

            //hide placeholder on focus
            $this.focus(function(){
                $this.next().hide();
            });

            //show placeholder if the input is empty
            $this.blur(function(){
                if (!$.trim($this.val())){
                    $this.next().show();
                };
            });
        });
    };

    //expose defaults
    $.fn.placeholder.defaults = {
        //you can pass in a custom wrapper
        inputWrapper: '
<div style="position:relative;"></div>
',
        placeholderText: null,


        //more or less just emulating what webkit does here
        //tweak to your hearts content
        placeholderCSS: {
            'font':'0.75em sans-serif',
            'color':'#bababa',
            'position': 'absolute',
            'left':'5px',
            'top':'3px',
            'overflow': 'hidden'
        }
    };
})(jQuery);
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * SelectionFinder provides mechanism for finding selection on the page via
 * find(). It is able to traverse frames in order to find a selection. It will
 * report whether there's a selection via hasSelection(). After doing find(),
 * the selection is stored in the selection property, and the document property
 * will contain the document in which the selection was found. Find method will
 * only recurse documents if it was invoked as find(true), specifying to do
 * recursive search. You can use reset() to undo find().
 */
Evernote.SelectionFinder = function SelectionFinder( doc ) {
    this._document = doc;
};

Evernote.SelectionFinder.prototype._document = null;
Evernote.SelectionFinder.prototype._selection = null;

Evernote.SelectionFinder.prototype.hasSelection = function() {
    Evernote.Logger.debug( "SelectionFinder.hasSelection()" );

    var range = Evernote.Utils.fixIERangeObject(this.getRange());
    return range &#038;&#038; (range.startContainer != range.endContainer
        || (range.startContainer == range.endContainer &#038;&#038; range.startOffset != range.endOffset));
};

Evernote.SelectionFinder.prototype.find = function( deep ) {
    Evernote.Logger.debug( "SelectionFinder.find()" );
    var result = this.findSelectionInDocument( this._document, deep );
    this._document = result.document;
    this._selection = result.selection;
};

Evernote.SelectionFinder.prototype.getRange = function() {
    Evernote.Logger.debug( "SelectionFinder.getRange()" );
    if ( !this._selection || this._selection.rangeCount == 0 ) {
        return null;
    }

    if ( typeof this._selection.getRangeAt == 'function' ) {
        return this._selection.getRangeAt( 0 );
    }

    if ( (window.Range &#038;&#038; this._selection instanceof window.Range) || !this._selection.anchorNode ) {
        return this._selection;
    }
    var range = this._document.createRange();
    range.setStart( this._selection.anchorNode, this._selection.anchorOffset );
    range.setEnd( this._selection.focusNode, this._selection.focusOffset );

    return range;
};

Evernote.SelectionFinder.prototype.findSelectionInDocument = function( doc, deep ) {
    try {
        Evernote.Logger.debug( "SelectionFinder.findSelectionInDocument()" );

        var sel = null;
        var hasSelection = false;
        var win = null;

        try {
            win = (doc.defaultView) ? doc.defaultView : window;
        }
        catch ( e ) {
            win = window;
        }
        if ( typeof win.getSelection == 'function' ) {
            sel = win.getSelection();
            if ( sel &#038;&#038; typeof sel.rangeCount != 'undefined' &#038;&#038; sel.rangeCount > 0 ) {
                Evernote.Logger.debug("Found selection by win.getSelection()");
                hasSelection = true;
            }
        }
        else if ( win.selection &#038;&#038; typeof win.selection.createRange == 'function' ) {
            sel = win.selection.createRange();
            if ( win.selection.type == 'Text' &#038;&#038; typeof sel.htmlText == 'string' &#038;&#038; sel.htmlText.length > 0 ) {
                Evernote.Logger.debug("Found selection by win.selection");
                hasSelection = true;
            }
        }
        else if ( doc.selection &#038;&#038; (typeof doc.selection.createRange == 'function' || typeof doc.selection.createRange == 'object') ) {
            sel = doc.selection.createRange();
            if(doc.selection.type == "None")
                sel = undefined;
            if ( (doc.selection.type == 'Text') &#038;&#038; (typeof sel.htmlText == 'string') &#038;&#038; (sel.htmlText.length > 0) ) {
                Evernote.Logger.debug("Found selection by doc.selection");
                hasSelection = true;
            }
        }

        if ( sel &#038;&#038; !hasSelection &#038;&#038; deep ) {
            var nestedDocs = Evernote.Utils.getNestedDocuments( doc );
            for ( var i = 0; i < nestedDocs.length; ++i ) {
                if ( nestedDocs[ i ] ) {
                    var framedSel = this.findSelectionInDocument( nestedDocs[ i ], deep );
                    if ( framedSel &#038;&#038; framedSel.selection &#038;&#038; framedSel.selection.rangeCount > 0 ) {
                        return framedSel;
                    }
                }
            }
        }

        //if do not find any selection in document, try to find selection in HTMLTextArea|Input.
        //Get Selection object for TextArea, and set selection as a Range object
        if(doc.activeElement)
            Evernote.Logger.debug( "Check selection in INPUT TEXT area (input, textarea), for active element :" + doc.activeElement.nodeName );

        var activeEl = doc.activeElement;
        if ( activeEl &#038;&#038; ( (window.HTMLInputElement &#038;&#038; (activeEl instanceof window.HTMLInputElement &#038;&#038; activeEl.type == "text")) || ( window.HTMLTextAreaElement &#038;&#038; (activeEl instanceof window.HTMLTextAreaElement)) ) ) {
            if ( activeEl.selectionStart != activeEl.selectionEnd ) {
                var range = doc.createRange();
                var textNode = doc.createTextNode( activeEl.value );

                range.setStart( textNode, activeEl.selectionStart );
                range.setEnd( textNode, activeEl.selectionEnd );
                sel = range;
            }
        }

        return {
            document : doc,
            selection : sel
        };
    } catch(e) {
        Evernote.Logger.error("Failed to find selection on the page due to error " + e);
        //Do not throw exception here, it is better to not show error to user and allow to clip article or something else.
    }
    return {
        document: doc,
        selection: null
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.JSSerializer = {

    _selectionFinder : new Evernote.SelectionFinder(window.document),

    serializeAsync : function( element, fullPage, callback ) {
        try {
            var start = new Date().getTime();
            var root = element || document.body.parentNode || document.body;
            var serializer = new Evernote.NodeSerializer( window, new Evernote.ClipFullStylingStrategy() );
            var parser = new Evernote.DomParser( window, null );

            var resultFunc = function() {
                var images = [];
                var imageUrls = serializer.getImagesUrls();

                for(var i = 0; i < imageUrls.length; i++) {
                    images.push(Evernote.Utils.makeAbsolutePath(serializer.getDocumentBase(), imageUrls[i]).replace(/\s/g, "%20"));
                }
                callback( {
                    content : serializer.getSerializedDom(),
                    imageUrls : images,
                    docBase : serializer.getDocumentBase()
                    });
            };
            parser.parseAsync( root, fullPage ? true: false, serializer, resultFunc);
            var end = new Date().getTime();
            Evernote.Logger.debug( "Clip.clipFullPage(): clipped body in " + (end - start) + " milliseconds" );
        }
        catch ( e ) {
            Evernote.Logger.error( "JSSerializer.serialize() failed: error = " + e );
            throw e;
        }
    },

    serialize : function( element, fullPage ) {
        try {
            var start = new Date().getTime();
            var root = element || document.body.parentNode || document.body;
            var serializer = new Evernote.NodeSerializer( window, new Evernote.ClipFullStylingStrategy() );
            var parser = new Evernote.DomParser( window, null );
            parser.parse( root, fullPage ? true: false, serializer);
            var end = new Date().getTime();
            Evernote.Logger.debug( "Clip.clipFullPage(): clipped body in " + (end - start) + " milliseconds" );
            var images = [];
            var imageUrls = serializer.getImagesUrls();

            for(var i = 0; i < imageUrls.length; i++) {
                images.push(Evernote.Utils.makeAbsolutePath(serializer.getDocumentBase(), imageUrls[i]).replace(/\s/g, "%20"));
            }
            return {
                content : serializer.getSerializedDom(),
                imageUrls : images,
                docBase : serializer.getDocumentBase()
            }
        }
        catch ( e ) {
            Evernote.Logger.error( "JSSerializer.serialize() failed: error = " + e );
            throw e;
        }
    },

    serializeSelectionAsync : function( range, callback ) {

        try {
            if( !range ) {
                if ( !this.hasSelection() ) {
                    Evernote.Logger.warn( "JSSerializer.serializeSelection(): no selection to clip" );
                    callback();
                    return;
                }

                range = Evernote.Utils.fixIERangeObject(this._selectionFinder.getRange());


                if ( !range ) {
                    Evernote.Logger.warn( "JSSerializer.serializeSelection(): no range in selection" );
                    callback();
                    return;
                }
            }

            var start = new Date().getTime();
            var ancestor = (this._styleStrategy &#038;&#038; Evernote.Utils.Selection.getCommonAncestorContainer(range).nodeType == Evernote.Node.TEXT_NODE
                &#038;&#038; Evernote.Utils.Selection.getCommonAncestorContainer(range).parentNode) ? Evernote.Utils.Selection.getCommonAncestorContainer(range).parentNode : Evernote.Utils.Selection.getCommonAncestorContainer(range);

            while ( typeof Evernote.ClipRules.NON_ANCESTOR_NODES[ ancestor.nodeName.toUpperCase() ] != 'undefined' &#038;&#038; ancestor.parentNode ) {
                if ( ancestor.nodeName.toUpperCase() == "BODY" ) {
                    break;
                }
                ancestor = ancestor.parentNode;
            }

            var serializer = new Evernote.NodeSerializer( window, new Evernote.ClipFullStylingStrategy() );
            var parser = new Evernote.DomParser(window, Evernote.Utils.fixIERangeObject(range));

            var resultFunc = function() {
                var images = [];
                var imageUrls = serializer.getImagesUrls();

                for(var i = 0; i < imageUrls.length; i++) {
                    images.push(Evernote.Utils.makeAbsolutePath(serializer.getDocumentBase(), imageUrls[i]).replace(/\s/g, "%20"));
                }

                callback( {
                    content : serializer.getSerializedDom(),
                    imageUrls : images,
                    docBase : serializer.getDocumentBase()
                } );
            };
            parser.parseAsync( ancestor, false, serializer, resultFunc );
            var end = new Date().getTime();
            Evernote.Logger.debug( "JSSerializer.serializeSelection(): clipped selection in " + (end - start) + " milliseconds" );
        }
        catch ( e ) {
            Evernote.Logger.error( "JSSerializer.serializeSelection() failed: error = " + e );
            throw e;
        }
    },

    serializeSelection : function( range ) {
        try {
            if( !range ) {
                if ( !this.hasSelection() ) {
                    Evernote.Logger.warn( "JSSerializer.serializeSelection(): no selection to clip" );
                    return;
                }

                range = Evernote.Utils.fixIERangeObject(this._selectionFinder.getRange());


                if ( !range ) {
                    Evernote.Logger.warn( "JSSerializer.serializeSelection(): no range in selection" );
                    return;
                }
            }

            var start = new Date().getTime();
            var ancestor = (this._styleStrategy &#038;&#038; Evernote.Utils.Selection.getCommonAncestorContainer(range).nodeType == Evernote.Node.TEXT_NODE
                &#038;&#038; Evernote.Utils.Selection.getCommonAncestorContainer(range).parentNode) ? Evernote.Utils.Selection.getCommonAncestorContainer(range).parentNode : Evernote.Utils.Selection.getCommonAncestorContainer(range);

            while ( typeof Evernote.ClipRules.NON_ANCESTOR_NODES[ ancestor.nodeName.toUpperCase() ] != 'undefined' &#038;&#038; ancestor.parentNode ) {
                if ( ancestor.nodeName.toUpperCase() == "BODY" ) {
                    break;
                }
                ancestor = ancestor.parentNode;
            }

            var serializer = new Evernote.NodeSerializer( window, new Evernote.ClipFullStylingStrategy() );
            var parser = new Evernote.DomParser(window, Evernote.Utils.fixIERangeObject(range));
            parser.parse( ancestor, false, serializer );

            var end = new Date().getTime();
            Evernote.Logger.debug( "JSSerializer.serializeSelection(): clipped selection in " + (end - start) + " milliseconds" );
            var images = [];
            var imageUrls = serializer.getImagesUrls();

            for(var i = 0; i < imageUrls.length; i++) {
                images.push(Evernote.Utils.makeAbsolutePath(serializer.getDocumentBase(), imageUrls[i]).replace(/\s/g, "%20"));
            }

            return {
                content : serializer.getSerializedDom(),
                imageUrls : images,
                docBase : serializer.getDocumentBase()
            }
        }
        catch ( e ) {
            Evernote.Logger.error( "JSSerializer.serializeSelection() failed: error = " + e );
            throw e;
        }
    },

    hasSelection : function() {
        Evernote.Logger.debug( "Clip.hasSelection()" );

        if ( this._selectionFinder.hasSelection() ) {
            return true;
        }
        else {
            this._selectionFinder.find( true );
            return this._selectionFinder.hasSelection();
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * Represents JQuery loader that allow to have two versions of JQuery loaded on the same page
 * @type {Object}
 */
Evernote.JQueryLoader = {
    /**
     * Initializes jquery instance on global Evernote context
     */
    initJQuery : function() {
        Evernote.JQuery = $.noConflict(true);
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ClipNotificator = function ClipNotificator() {

};

Evernote.ClipNotificator.WAIT_CONTAINER_ID = "evernoteContentClipperWait";
Evernote.ClipNotificator.SHOW_WAIT_MIN_TIME = 2000;

Evernote.ClipNotificator.prototype.showCopyNotification = function( doc, useAutoHide ) {
    Evernote.Logger.debug( "ClipNotificator.showCopyNotification()" );

    try {
        var wait = this.getWaitContainer( doc, Evernote.Addin.getLocalizedMessage(Evernote.Messages.CLIPPING) );
        wait.style.opacity = "1";
        this.centerBox(wait);

        if ( doc.body ) {
            doc.body.appendChild( wait );
        }

        if (useAutoHide)
        {
            var self = this;
            var timeout = this.constructor.SHOW_WAIT_MIN_TIME;
            setTimeout( function() {
                self.clearWait( doc );
            }, timeout );
        }
    }
    catch ( e ) {
        Evernote.Logger.error( "ClipNotificator.showCopyNotification() failed: error = " + e );
    }
};

Evernote.ClipNotificator.prototype.centerBox = function( container ) {
    var topPosition = ((document.documentElement.scrollTop || document.body.scrollTop) + ((((document.documentElement.clientHeight || document.body.clientHeight) + (!container.offsetHeight &#038;&#038; 0)) / 2) >> 0));
    var leftPosition = (((document.documentElement.clientWidth || document.body.clientWidth) / 2) - (container.offsetWidth / 2));
    container.style.position = "absolute";
    container.style.top = (topPosition-20) + "px";
    container.style.left = (leftPosition - 90) + "px";
};

Evernote.ClipNotificator.prototype.getWaitContainer = function( doc, msg ) {
    Evernote.Logger.debug( "ClipNotificator.getWaitContainer()" );

    var container = doc.getElementById( this.constructor.WAIT_CONTAINER_ID );
    if ( !container ) {
        container = doc.createElement( "evernotediv" );
        if(Evernote.Utils.isQuirkMode()) {
            container.className = "quirk-mode-container";
        }
        container.id = this.constructor.WAIT_CONTAINER_ID;

        var wait = doc.createElement( "div" );
        wait.id = this.constructor.WAIT_CONTAINER_ID + "Content";
        if(Evernote.BrowserDetection.isLessThanIE9()) {
            wait.className = "content-less-than-nine-container";
        }
        container.appendChild( wait );

        var center = doc.createElement( "center" );
        wait.appendChild( center );

        var spinner = doc.createElement( "div" );
        spinner.id = "evernote-spinner-container";
        Evernote.GlobalUtils.absolutizeImages(spinner, "images/icon_scissors.png");
        center.appendChild( spinner );

        var text = doc.createElement( "span" );
        text.id = this.constructor.WAIT_CONTAINER_ID + "Text";
        center.appendChild( text );

        container._waitMsgBlock = text;
        container._waitMsgBlock.appendChild( doc.createTextNode( msg ) );
    }

    return container;
};

Evernote.ClipNotificator.prototype.clearWait = function( doc ) {
    Evernote.Logger.debug( "ClipNotificator.clearWait()" );

    var wait = doc.getElementById( this.constructor.WAIT_CONTAINER_ID );
    if ( wait ) {
        wait.style.opacity = "0";
        setTimeout( function() {
            if ( wait.parentNode ) {
                wait.parentNode.removeChild( wait );
            }
        }, 1000 );
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * Represents clipper object that is capable of clipping elements from pages or clip elements based on preferences.
 */
Evernote.Clipper = {

    _serializer : Evernote.JSSerializer,

    _clipNotifier : new Evernote.ClipNotificator(),

    _defaultOptions : {
        title: PageContext.title,
        tags: [],
        comments: "",
        notebookUid: -1
    },

    /**
     * Clips article element (one that user selected or default if no selection was made).
     */
    clipArticle : function(options) {
        var currentOptions = this.initOptions(options);
        this._clipNotifier.showCopyNotification(document);
        var self = this;
        setTimeout(function() {
            var article = Evernote.contentPreviewer.getArticleElement();
            if(!article) {
                article = Evernote.pageInfo.getDefaultArticle(function(article) {});
            }
            var resultFunc = function(serializedDom) {
                self._clipNotifier.clearWait(document);
                Evernote.Addin.clipNote(currentOptions.comments + serializedDom.content, currentOptions, PageContext.url, serializedDom.imageUrls, true, document);
            };
            self._serializer.serializeAsync(article, false, resultFunc);
        }, 100);
    },

    initOptions: function(options) {
        if(!options)
            options = this._defaultOptions;
        options = Evernote.JQuery.extend({}, this._defaultOptions, options);
        if(!options.title || Evernote.JQuery.trim(options.title).length == 0)
            options.title = Evernote.Addin.getLocalizedMessage(Evernote.Messages.UNTITLED_NOTE);
        options.title = Evernote.JQuery.trim(Evernote.Utils.cutToLength(options.title, 255, " "));
        return options;
    },

    /**
     * Clips full page.
     */
    clipFullPage : function(options) {
        Evernote.Logger.debug("Clipper: clipFullPage");
        var currentOptions = this.initOptions(options);
        this._clipNotifier.showCopyNotification(document);
        var self = this;
        setTimeout(function() {
            Evernote.Logger.debug("Start clipping of full page");
            var resultFunc = function(serializedDom) {
                self._clipNotifier.clearWait(document);
                Evernote.Logger.debug("Image urls " + JSON.stringify(serializedDom.imageUrls));
                Evernote.Logger.debug("Send clip to EN");
                Evernote.Addin.clipNote(currentOptions.comments + serializedDom.content, currentOptions, PageContext.url, serializedDom.imageUrls, true, document);
            };
            self._serializer.serializeAsync(null, true, resultFunc);
        }, 100);
    },

    /**
     * Clips url with favicon (if favicon is recognized)
     */
    clipUrl : function(options) {
        var currentOptions = this.initOptions(options);
        this._clipNotifier.showCopyNotification(document, true);
        setTimeout(function() {
            var content = Evernote.GlobalUtils.createUrlClipContent(PageContext.title, PageContext.url, PageContext.getFavIconUrl());
            Evernote.Addin.clipNote(currentOptions.comments + content, currentOptions, PageContext.url, PageContext.getFavIconUrl(), true, document);
        }, 100);
    },

    /**
     * Clips selection from the page.
     */
    clipSelection : function( range, options ) {
        var currentOptions = this.initOptions(options);
        this._clipNotifier.showCopyNotification(document);
        var self = this;
        setTimeout(function() {
            var resultFunc = function(serializedDom) {
                self._clipNotifier.clearWait(document);
                if(serializedDom) {
                    Evernote.Addin.clipNote(currentOptions.comments + serializedDom.content, currentOptions, PageContext.url, serializedDom.imageUrls, true, document);
                }
            };
            var serializedDom = self._serializer.serializeSelectionAsync( range, resultFunc );
        }, 100);
    },

    /**
     * Clips image from the page.
     */
    clipImage : function(options ) {
        if (!options.imageElement) {
            Evernote.Logger.debug("clipImage Empty element");
            return;
        }
        var currentOptions = this.initOptions(options);
        this._clipNotifier.showCopyNotification(document);
        var self = this;
        setTimeout(function() {
            Evernote.Logger.debug("Start clipping of image");
            var resultFunc = function(serializedDom) {
                self._clipNotifier.clearWait(document);
                Evernote.Logger.debug("Image urls " + JSON.stringify(serializedDom.imageUrls));
                Evernote.Logger.debug("Send clip to EN");
                Evernote.Addin.clipNote(currentOptions.comments + serializedDom.content, currentOptions, PageContext.url, serializedDom.imageUrls, true, document);
            };
            self._serializer.serializeAsync(options.imageElement, false, resultFunc);
        }, 100);
    },

    /**
     * Clips part of the page, defined in option (url, article or full page) or selection if presented.
     */
    clipWithOptions : function(clipOptions) {
        var options = {
            notebookUid: function() {
                var savedNotebookUid = Evernote.Options.selectedNotebookUid;
                var notebook = Evernote.NotebooksLoader.getNotebookByUid(savedNotebookUid);
                if(!notebook) {
                    return -1;
                } else {
                    return notebook.uid;
                }
            },
            imageElement: EvernoteExternal.imageElement
        };

        if(clipOptions.getClipAction() == Evernote.ClipperActions.CLIP_SELECTION &#038;&#038; Evernote.Utils.hasSelection(window)) {
            Evernote.Clipper.clipSelection(null, options);
        }
		 else if(clipOptions.getClipAction() == Evernote.ClipperActions.CLIP_URL) {
            Evernote.Clipper.clipUrl(options);
        } else if(clipOptions.getClipAction() == Evernote.ClipperActions.CLIP_FULL_PAGE) {
            Evernote.Clipper.clipFullPage(options);
        } else if(clipOptions.getClipAction() == Evernote.ClipperActions.CLIP_IMAGE) {
            Evernote.Clipper.clipImage(options);
        } else {
            Evernote.Logger.warn("Unknown option is specified : " + clipOptions.getClipAction());
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ClipOptions = function ClipOptions(data) {
    this.clipAction = data.clipAction;
};

Evernote.ClipOptions.prototype.getClipAction = function() {
    return this.clipAction;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
function ContentVeil() {
    Evernote.Logger.debug(document);
    var veil = document.createElement("div");
    var inner = document.createElement("div");
    veil.appendChild(inner);
    veil.style.boxSizing = "border-box";
    veil.style.borderStyle = "solid";
    var scroller = new Evernote.Scroller( window );
    try {
        veil.style.borderColor = "rgba(0, 0, 0, 0.7)";
    } catch (e) {
        veil.style.borderColor = "rgb(0, 0, 0)";
        veil.className = "evernote-top-fixed-position-quirks";
    }

    inner.style.borderWidth = "4px";
    inner.style.borderStyle = "solid";
    try {
        inner.style.borderColor = "rgba(255, 255, 0, 0.7)";
    } catch (e) {
        inner.style.borderColor = "rgb(255, 255, 0)";
    }

    inner.style.height = "100%";
    inner.style.width = "100%";
    inner.style.boxSizing = "border-box";

    // We keep a record of what we're currently showing (at least in some cases) so that we can update it in case the
    // state of the page changes (like if the user scrolls).
    var currentlyShownRect = null;
    var currentRectOffsetTop = 0;
    var currentRectOffsetLeft = 0;
    var currentlyStatic = false;

    function reset() {
        currentlyShownRect = null;
        currentRectOffsetTop = 0;
        currentRectOffsetLeft = 0;

        showElements("embed");
        showElements("object");
        showElements("iframe");
        veil.style.position = "fixed";
        veil.style.left = "0px";
        veil.style.zIndex = "2147483646";
        if(Evernote.Utils.isQuirkMode() &#038;&#038; !Evernote.BrowserDetection.isIE10orGreater()) {
            veil.style.position = "absolute";
            veil.className = "evernote-top-fixed-position-quirks";
        }
        else {
            veil.style.top = "0px";
        }

        blank();
    }

    function blank() {

        if((Evernote.Utils.isQuirkMode() || Evernote.BrowserDetection.isLessThanIE9()) &#038;&#038; !Evernote.BrowserDetection.isIE10orGreater()) {
            veil.style.width = "0px";
            veil.style.height = "0px";
        }
        else {
            veil.style.height = Evernote.Utils.innerHeight() + "px";
            veil.style.width = Evernote.Utils.innerWidth() + "px";
        }
    }

    function gray() {
        show();
        inner.style.display = "none";
    }

    function show() {
        Evernote.Logger.debug("Content veil show");
        inner.style.display = "";
        veil.style.backgroundColor = "";
        if (!Evernote.ElementExtension.hasParentNode(veil)) {
            document.body.appendChild(veil);
        }
    }

    function hide() {
        veil.style.borderLeftWidth = Evernote.Utils.innerWidth()/2 + "px";
        veil.style.borderRightWidth = Evernote.Utils.innerWidth()/2 + "px";

        veil.style.borderBottomWidth = Evernote.Utils.innerHeight()/2 + "px";
        veil.style.borderTopWidth = Evernote.Utils.innerHeight()/2 + "px";
        if (Evernote.ElementExtension.hasParentNode(veil)) {
            veil.parentNode.removeChild(veil);
        }
    }

    // Makes a rectangle bigger in all directions by the number of pixels specified (or smaller, if 'amount' is
    // negative). Returns the new rectangle.
    function expandRect(rect, amount) {
        return {
            top: (rect.top - amount),
            left: (rect.left - amount),
            bottom: (rect.bottom + amount),
            right: (rect.right + amount),
            width: (rect.width + (2 * amount)),
            height: (rect.height + (2 * amount))
        };
    }

    function scrollToRect(rect) {
        var sLeft = document.documentElement.scrollLeft;
        var sTop = document.documentElement.scrollTop;

        var left = rect.left - (Evernote.Utils.innerWidth() / 2) + sLeft;
        var top = rect.top - (Evernote.Utils.innerHeight() / 2) + sTop;
        scroller.scrollTo( { x: left, y: top }, 120, 20 );
    }

    // DrawStroke is obsolete, it is now always "true".
    function revealRect(rect, drawStroke, staticView) {

        // Save this info.
        currentlyShownRect = rect;
        currentRectOffsetTop = Evernote.Utils.scrollTop();
        currentRectOffsetLeft = Evernote.Utils.scrollLeft();
        currentlyStatic = staticView;

        // We expand the rectangle for two reasons.
        // 1) we want to expand it by the width of the stroke, so that when we draw out outline, it doesn't overlap our
        // content.
        // 2) We want to leave a little extra room around the content for aesthetic reasons.
        rect = expandRect(rect, 8);
        var x = rect.left;
        var y = rect.top;
        var width = rect.width;
        var height = rect.height;

        var veilWidth = Evernote.Utils.innerWidth(); //veil.style.width.replace("px", "");
        var veilHeight = Evernote.Utils.innerHeight(); //veil.style.height.replace("px", "");
        Evernote.Logger.debug("Veil width " + veilWidth);
        Evernote.Logger.debug("Veil height " + veilHeight);
        var offScreen = false;
        if (y + height < 0) {
            Evernote.Logger.debug("y + height < 0");
            offScreen = true;
        }
        else if (y > veilHeight) {
            Evernote.Logger.debug("y > veilHeight");
            offScreen = true;
        }
        else if (x + width < 0) {
            Evernote.Logger.debug("x + width < 0");
            offScreen = true;
        }
        else if (x > veilWidth) {
            Evernote.Logger.debug("x > veilWidth");
            offScreen = true;
        }
        Evernote.Logger.debug("Is offscreen " + offScreen);
        if (offScreen) {
            veil.style.borderLeftWidth = veilWidth/2 + "px";
            veil.style.borderRightWidth = veilWidth/2 + "px";
            veil.style.borderTopWidth = veilHeight/2 + "px";
            veil.style.borderBottomWidth = veilHeight/2 + "px";
            inner.style.display = "none";
            return;
        }
        Evernote.Logger.debug("Show rect " + JSON.stringify(rect));
        inner.style.display = "block";
        veil.style.borderLeftWidth = Math.max(x, 0) + "px";
        veil.style.borderTopWidth = Math.max(y, 0) + "px";
        veil.style.borderRightWidth = Math.max((veilWidth - x - width), 0) + "px";
        veil.style.borderBottomWidth = Math.max((veilHeight - y - height), 0) + "px";


            veil.style.width = veilWidth + "px";
            veil.style.height = veilHeight + "px";
        /*
            veil.style.width = (veilWidth - (Math.max(x, 0) + Math.max((veilWidth - x - width), 0))) + "px";
            veil.style.height = (veilHeight - (Math.max(y, 0) + Math.max((veilHeight - y - height), 0))) + "px";
        */
        Evernote.Logger.debug("revealRect finished");
    }

    function revealStaticRect(rect, drawStroke) {
        revealRect(rect, drawStroke, true);
    }

    function outlineElement(element, scrollTo) {
        // See notes in Preview.js for why we use this method instead of just calling element.getBoundingClientRect().
        if (scrollTo) {
            Evernote.Logger.debug("ContentVeil:scrollIntoViewIfNeeded ");
            element.scrollIntoView(true);
        }
        var rect = Evernote.contentPreviewer.computeDescendantBoundingBox(element);
        Evernote.Logger.debug("Calculated rect " + rect);
        if (rect) {
            var mutableRect = {
                top: rect.top,
                bottom: rect.bottom,
                left: rect.left,
                right: rect.right,
                width: rect.width,
                height: rect.height
            }

            // We don't want to adjust ourselves into odd positions if the page is scrolled.
            var sLeft = Evernote.Utils.scrollLeft();
            var sTop = Evernote.Utils.scrollTop();

            var BORDER_MIN = 9;
            if (mutableRect.left < (BORDER_MIN - sLeft)) {
                mutableRect.width -= (BORDER_MIN - sLeft) - mutableRect.left;
                mutableRect.left = (BORDER_MIN - sLeft);
            }
            if (mutableRect.top < (BORDER_MIN - sTop)) {
                mutableRect.height -= (BORDER_MIN - sTop) - mutableRect.top;
                mutableRect.top = (BORDER_MIN - sTop);
            }

            // Get the wider of our two possible widths.
            var width = Math.max(document.body.scrollWidth, Evernote.Utils.innerWidth());

            if (mutableRect.right > (width - BORDER_MIN - sLeft)) {
                mutableRect.right = (width - BORDER_MIN - sLeft);
                mutableRect.width = mutableRect.right - mutableRect.left;
            }
            Evernote.Logger.debug("Mutable record " + mutableRect.top + ", " + mutableRect.left + ", " + mutableRect.right + ", " + mutableRect.bottom + ", " + mutableRect.width + ", " + mutableRect.height);
            Evernote.Logger.debug("ContentVeil:reset ");

            reset();
            Evernote.Logger.debug("ContentVeil:revealRect ");

            revealRect(mutableRect, true);
            Evernote.Logger.debug("Hide elements embeded");
            hideElements("embed", element);
            hideElements("object", element);
            Evernote.Logger.debug("Hide elements iframe");
            hideElements("iframe", element);
            Evernote.Logger.debug("Show it");
            show();
        }
        else {
            Evernote.Logger.warn("Couldn't create rectangle from element: " + element.toString());
        }
    }

    function hideAllActiveObjects() {
        hideElements("embed");
        hideElements("object");
        hideElements("iframe");
    }

    function hideElements (tagName, exceptInElement) {
        var els = document.getElementsByTagName(tagName);
        for (var i = 0; i < els.length; i++) {
            els[i].enSavedVisibility = els[i].style.visibility;
            els[i].style.visibility = "hidden";
        }
    }

    function showElements (tagName, inElement) {
        if (!inElement) {
            inElement = document;
        }
        var els = inElement.getElementsByTagName(tagName);
        for (var i = 0; i < els.length; i++) {
            if (typeof els[i].enSavedVisibility !== "undefined") {
                els[i].style.visibility = els[i].enSavedVisibility;
                try {
                    delete els[i].enSavedVisibility;
                } catch(e) {
                    els[i].enSavedVisibility = undefined;
                }
            }
        }
    }

    // If we're currently showing a rectangle, and it's not static, we'll redraw on scroll.

    var onScrollHandle =  function(e) {
        Evernote.Logger.debug("On scroll start");
        Evernote.Logger.debug("currentlyShownRect " + JSON.stringify(currentlyShownRect));
        Evernote.Logger.debug("currentlyStatic " + currentlyStatic);
        if (currentlyShownRect &#038;&#038; !currentlyStatic) {
            var rect = {
                top: currentlyShownRect.top,
                bottom: currentlyShownRect.bottom,
                left: currentlyShownRect.left,
                right: currentlyShownRect.right,
                width: currentlyShownRect.width,
                height: currentlyShownRect.height
            };

            Evernote.Logger.debug("Evernote.Utils.scrollTop() " + Evernote.Utils.scrollTop());

            Evernote.Logger.debug("Evernote.Utils.scrollLeft() " + Evernote.Utils.scrollLeft());

            var vert = Evernote.Utils.scrollTop() - currentRectOffsetTop;
            var horiz = Evernote.Utils.scrollLeft() - currentRectOffsetLeft;
            if (!vert &#038;&#038; !horiz) {
                Evernote.Logger.debug("No vertical and horizontal");
                return;
            }

            rect.top -= vert;
            rect.bottom -= vert;
            rect.left -= horiz;
            rect.right -= horiz;
            blank();
            revealRect(rect);
        }
    };

    if (window.attachEvent)
        window.attachEvent("onscroll", onScrollHandle);
    else if (window.addEventListener)
        window.addEventListener("scroll", onScrollHandle, false);
    else
        Evernote.Logger.error( "ContentVeil can't attachEvent" );

    // Public API:
    this.reset = reset;
    this.show = show;
    this.gray = gray;
    this.hide = hide;
    this.revealRect = revealRect;
    this.revealStaticRect = revealStaticRect;
    this.outlineElement = outlineElement;
    this.expandRect = expandRect;
    this.hideAllActiveObjects = hideAllActiveObjects;
    this.scrollToRect = scrollToRect;
    Evernote.Logger.debug("End content veil");
}
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
function PageInfo() {

    // This is a map of hostnames (for hostnames that begin with 'www.', the 'www.' will be stripped off first, so don't
    // include it in your lookup string) to CSS selectors. When we try and locate an article in a page, we'll see if we
    // can find the doamin for the page in this list, and if so, we'll try and find an element that matches the given
    // selector. If no element is returned, we'll fall back to the heuristic approach.
    var specialCases = {
        "penny-arcade.com": "div.contentArea > div.comic > img",
        "aspicyperspective.com": "div.entry-content",
        "thewirecutter.com": "div#content",
        "katespade.com": "div#pdpMain",
        "threadless.com": "section.product_section",
        "yelp.com": "div#bizBox",
        "flickr.com": "div#photo",
        "instagr.am": "div.stage > div.stage-inner",
        "stackoverflow.com": "div#mainbar",
        "makeprojects.com": "div#guideMain",
        "cookpad.com": "div#main",
        "imgur.com": "div.image",
        "smittenkitchen.com": "div.entry",
        "allrecipes.com": "div#content-wrapper",
        "qwantz.com": "img.comic",
        "questionablecontent.net": "img#strip",
        "cad-comic.com": "div#content"
    }

    var useFoundImage = [
        "xkcd.com"
    ]

    // These are the items we're trying to collect. This first block is trivial.
    var containsImages = Boolean(document.getElementsByTagName("img").length > 0);
    var documentWidth = document.width;
    var documentHeight = document.height;
    var url = document.location.href;
    var documentLength = document.body.textContent ? document.body.textContent.length : 0;

    // These take slightly more work and are initialized only when requested.
    var article = null;
    var articleBoundingClientRect = null;
    var selection = false; // This is easy to get, but is always "false" at load time until the user selects something.
    var selectionIsInFrame = false;
    var documentIsFrameset = false;
    var selectionFrameElement = null;
    var recommendationText = null;

    // Internal state variables to keep us duplicating work.
    var hasCheckedArticle = false;

    // Experimental recognition of 'image' pages (like photo sites and comics).
    function findImage() {
        var imgs = document.getElementsByTagName("img");
        var biggest = null;
        var biggestArea = 0;
        for (var i = 0; i < imgs.length; i++) {
            var style = Evernote.ElementExtension.getComputedStyle(imgs[i]);
            var width = style.width.replace(/[^0-9.-]/g, "");
            var height = style.height.replace(/[^0-9.-]/g, "");
            var area = width * height;
            if (!biggest || area > biggestArea) {
                biggest = imgs[i];
                biggestArea = area;
            }
        }
        return biggest;
    }

    function getAncestors(node) {
        var an = [];
        while (node) {
            an.unshift(node);
            node = node.parentNode;
        }
        return an;
    }

    function getDeepestCommonNode(nodeList1, nodeList2) {
        var current = null;
        for (var i = 0; i < nodeList1.length; i++) {
            if (nodeList1[i] === nodeList2[i]) {
                current = nodeList1[i];
            }
            else {
                break;
            }
        }
        return current;
    }

    function getCommonAncestor(nodeList) {
        if (!nodeList.length) return null;

        if (nodeList.length == 1) return nodeList[0];
        var lastList = getAncestors(nodeList[0]);

        var node = null;
        for (var i = 1; i < nodeList.length; i++) {
            var list = getAncestors(nodeList[i]);
            node = getDeepestCommonNode(lastList, list);
            lastList = getAncestors(node);
        }
        return node;
    }

    function clearlyCallback(data, callback) {
        Evernote.Logger.debug("Clearly callback invoked");
        findImage();

        // See if we should special-case this.
        var host = getHostname();
        if (specialCases[host])
        {
            var candidate = Evernote.ElementExtension.querySelector(specialCases[host]);
            if (candidate) {
                Evernote.Logger.debug("Found article in specialCases");
                article = candidate;
                articleBoundingClientRect = Evernote.ElementExtension.getBoundingClientRect(article);
            }
        }

        // Or see if it's a special case image page.
        else if (Evernote.ArrayExtension.indexOf(useFoundImage, host) != -1) {
            article = findImage();
            if (article) {
                Evernote.Logger.debug("Found article in image");
                articleBoundingClientRect = Evernote.ElementExtension.getBoundingClientRect(article);
            }
        }

        // If it's not a special case, see if it's a single image.
        if (!article) {
            var imageTypes = ['jpeg', 'jpg', 'gif', 'png'];
            var urlExtension = document.location.href.replace(/^.*\.(\w+)$/, "$1");
            if (urlExtension &#038;&#038; (Evernote.ArrayExtension.indexOf(imageTypes, urlExtension) != -1)) {
                var candidate = Evernote.JQuery("body > img");
                if (candidate.length > 0) {
                    Evernote.Logger.debug("Found article in a single image");
                    article = candidate.get(0);
                    articleBoundingClientRect = Evernote.ElementExtension.getBoundingClientRect(article);
                }
            }
        }

        // If we still didn't find an article, let's see if maybe it's in a frame. Cleary fails on frames so we try this
        // check before we use our clearly info.
        if (!article) {
            if (document.body.nodeName.toLowerCase() == "frameset") {
                documentIsFrameset = true;
                var frame = findBiggestFrame();
                if (frame &#038;&#038; frame.contentDocument &#038;&#038; frame.contentDocument.documentElement) {
                    selectionFrameElement = frame;
                    article = frame.contentDocument.documentElement;
                    articleBoundingClientRect = Evernote.ElementExtension.getBoundingClientRect(article);
                }
            }
        }

        // If we didn't use any of our special case handling, we'll use whatever clearly found.
        if (!article) {
            Evernote.Logger.debug("Use clearly find article");
            if (data &#038;&#038; data._elements &#038;&#038; data._elements.length) {
                article = data._elements[0];
                if (data._elements.length > 1) {

                    // This will include *all* clearly elements (and whatever else in in between them).
                    article = getCommonAncestor(data._elements);

                    // This includes *just the last (and therefore most important)* element from the clearly detection.
                    // article = data._elements[data._elements.length - 1];
                }

                if (article.nodeType === ( window.Node ? window.Node.TEXT_NODE : 1)) {
                    article = article.parentNode;
                }
            }
        }

        if(article) {
            if(Evernote.JQuery(article).closest("#evernote-content").length != 0)
                article = undefined;
        }

        // If clearly found nothing (because it failed), then use the body of the document.
        if (!article) {
            article = document.body;
        }

        hasCheckedArticle = true;
        callback();
    }

    // This will try and determine the 'default' page article. It will only run once per page, but it's specifically
    // called only on demand as it can be expensive.
    function findArticle(callback) {

        function afterInject() {
            // If we'd previously computed an article element, but it's lost its parent or become invisible, then we'll try
            // and re-compute the article. This can happen if, for example the page dynamically udaptes itself (like showing
            // the latest news article in a box that updates periodically). This doesn't guarantee that we clip something
            // sane if this happens, (if the page re-writes itself while a clip is taking place, the results are
            // indeterminate), but it will make such things less likely.
            if (article &#038;&#038;
                (!article.parentNode || !article.getBoundingClientRect || Evernote.ElementExtension.getBoundingClientRect(article).width == 0)) {
                article = null;
                hasCheckedArticle = false;
            }
            Evernote.Logger.debug("afterInject");
            if (!hasCheckedArticle) {
                Evernote.Logger.debug("no article");
                if (!window || !window.ClearlyComponent)
                {
                    Evernote.Logger.warn("Couldn't find clearly!");
                    clearlyCallback(null, callback);
                }
                else {
                    Evernote.Logger.debug("Call clearly to select article");
                    try {
                        window.ClearlyComponent.getContentElementAndHTML(window, function(data){clearlyCallback(data, callback)});
                    } catch(e) {
                        Evernote.Logger.error("Failed to find article by clearly due to error " + e);
                        clearlyCallback(null, callback);
                    }
                }
            }
            // If the page is big enough, clearly is excruciatingly slow. We'll jsut get the whole page.
            // @TODO: Maybe clearly can get faster.
            else if (document.body.innerHTML.length > (1024 * 1024)) {
                Evernote.Logger.warn("Page over 1mb, skipping article detection.");
                clearlyCallback(null, callback);
            }
            else {
                Evernote.Logger.debug("callback");
                callback();
            }
        }

        afterInject();

    }

    function findBiggestFrame() {
        var frames = document.getElementsByTagName("frame");
        var candidate = null;
        var candidateSize = 0;
        for (var i = 0; i < frames.length; i++) {
            if (frames[i].width &#038;&#038; frames[i].height) {
                var area = frames[i].width * frames[i].height;
                if (area > candidateSize) {
                    candidate = frames[i];
                    candidateSize = area;
                }
            }
        }
        return candidate;
    }

    function getHostname() {
        var match = document.location.href.match(/^.*?:\/\/(www\.)?(.*?)(\/|$)/);
        if (match) {
            return match[2];
        }
        return null;
    }

    function getDefaultArticle(callback) {
        Evernote.Logger.debug("getDefaultArticle");
        findArticle(function(){callback(article)});
        // Article already exists, so we'll return it.
        if (article) return article;
    }

    // Looks for selections in the current document and descendent (i)frames.
    // Returns the *first* non-empty selection.
    function getSelection() {

        // First we check our main window and return a selection if that has one.
        var selection = window.getSelection();
        if (selection &#038;&#038; selection.rangeCount &#038;&#038; !selection.isCollapsed) {
            return selection;
        }

        // Then we'll try our frames and iframes.
        var docs = [];
        var iframes = document.getElementsByTagName("iframe");
        for (var i = 0; i < iframes.length; i++) {
            docs.push(iframes[i]);
        }
        var frames = document.getElementsByTagName("frame");
        for (var i = 0; i < frames.length; i++) {
            docs.push(frames[i]);
        }

        var urlBase = document.location.href.replace(/^(https?:\/\/.*?)\/.*/i, "$1").toLowerCase();
        for (var i = 0; i < docs.length; i++) {

            // If frames/iframes fail a same origin policy check, then they'll through annoying errors, and we wont be able
            // to access them anyway, so we attempt to skip anything that wont match.
            if (docs[i].src &#038;&#038; docs[i].src.toLowerCase().substr(0, urlBase.length) !== urlBase) {
                continue;
            }

            var doc = docs[i].contentDocument;

            if (doc) {
                var frameSelection = doc.getSelection();
                if (frameSelection &#038;&#038; frameSelection.rangeCount &#038;&#038; !frameSelection.isCollapsed) {
                    selectionIsInFrame = true;
                    selectionFrameElement = docs[i];
                    return frameSelection;
                }
            }
            else {
                Evernote.Logger.warn("iframe contained no Document object.");
            }
        }

        // Didn't find anything.
        return null;
    }

    function getText(node, soFar, maxLen) {
        if (node.nodeType == Evernote.Node.TEXT_NODE) {
            var trimmed = node.textContent.trim().replace(/\s+/g, " ");
            if (trimmed === " " || trimmed === "") return soFar;
            return soFar + " " + trimmed;
        }

        var banned = [
            "script",
            "noscript"
        ];

        if (node.nodeType == Evernote.Node.ELEMENT_NODE) {
            if (Evernote.ArrayExtension.indexOf(banned, node.nodeName.toLowerCase()) == -1) {
                for (var i = 0; i < node.childNodes.length; i++) {
                    soFar = getText(node.childNodes[i], soFar, maxLen);
                    if (soFar.length > maxLen) {
                        return soFar;
                    }
                }
            }
        }
        return soFar;
    }

    function getRecommendationText() {
        var text = "";
        var MAX_LEN = 5000;
        var selection = getSelection();
        if (selection) {
            var df = selection.getRangeAt(0).cloneContents();
            var div = document.createElement("div");
            div.appendChild(df);
            text = getText(div, "", MAX_LEN);
        }

        else if (article) {
            text = getText(article, "", MAX_LEN);
        }
        else {
            text = getText(document.body, "", MAX_LEN);
        }
        text = document.title + " " + text;
        return text;
    }

    // Note: you must call getSelection() first to populate this field!
    function getSelectionFrame() {
        return selectionFrameElement;
    }

    function checkClearly() {
        var clearlyDoc = Evernote.ElementExtension.querySelector("iframe#readable_iframe");
        if (clearlyDoc) clearlyDoc = clearlyDoc.contentDocument;
        if (clearlyDoc) clearlyDoc = Evernote.ElementExtension.querySelector("body#body div#box", clearlyDoc);
        if (clearlyDoc) {
            article = clearlyDoc;
            articleBoundingClientRect = Evernote.ElementExtension.getBoundingClientRect(article);
        }
    }

    // @TODO: This is fairly incomplete.
    function getFavIconUrl() {
        var links = document.getElementsByTagName("link");
        var i;
        for (i = 0; i < links.length; i++) {
            if (links[i].rel) {
                var rels = links[i].rel.toLowerCase().split(/\s+/);
                if (Evernote.ArrayExtension.indexOf(rels, "icon") !== -1) {
                    // Found it!
                    return links[i].href;
                }
            }
        }
        return null;
    }

    function _getInfoRequestHandler(data, request, sender, sendResponse) {
        var isSelected = getSelection();

        checkClearly();

        var response = {
            containsImages: containsImages,
            documentWidth: documentWidth,
            documentHeight: documentHeight,
            url: url,
            selection: (isSelected !== null),
            selectionIsInFrame: selectionIsInFrame,
            documentLength: document.body.textContent.length,
            articleBoundingClientRect: articleBoundingClientRect,
            article: (article != null),
            recommendationText: getRecommendationText(),
            favIconUrl: getFavIconUrl(),
            documentIsFrameset: documentIsFrameset
        };
        sendResponse(response);
    }

    function getInfoRequestHandler(request, sender, sendResponse) {
        findArticle(function(data){_getInfoRequestHandler(data, request, sender, respondWithInfo)});
    }

    // Public API:
    this.getDefaultArticle = getDefaultArticle;
    this.getSelection = getSelection;
    this.getSelectionFrame = getSelectionFrame;
    this.getFavIconUrl = getFavIconUrl;
}
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.Scroller = function Scroller( tab ) {
    this.initialize( tab );
};

Evernote.Scroller.prototype._tab = null;

Evernote.Scroller.prototype.initialize = function ( tab ) {
    this._tab = tab;
    var scrollX = (this._tab.pageXOffset !== undefined) ? this._tab.pageXOffset : (this._tab.document.documentElement || this._tab.document.body.parentNode ||this._tab.document.body).scrollLeft;
    var scrollY = (this._tab.pageYOffset !== undefined) ? this._tab.pageYOffset : (this._tab.document.documentElement || this._tab.document.body.parentNode || this._tab.document.body).scrollTop;
    this.initialPoint = {
        x: scrollX,
        y: scrollY
    };
};

Evernote.Scroller.prototype.scrollTo = function ( endPoint, time, resolution ) {
    this.abort();

    this.endPoint = endPoint;
    this.step = 0;
    this.calculatePath( time, resolution );
    var self = this;
    this.proc = setInterval( function () {
            if ( !self.doScroll() ) {
                self.abort();
            }
        },
        resolution );
};

Evernote.Scroller.prototype.calculatePath = function ( time, resolution ) {
    this.path = [];
    var sx = this.initialPoint.x;
    var sy = this.initialPoint.y;
    var ex = this.endPoint.x;
    var ey = this.endPoint.y;
    var k = (Math.PI * resolution) / time;
    for ( var i = -(Math.PI / 2); i < (Math.PI / 2); i += k ) {
        var c = ((1 + Math.sin( i )) / 2);
        this.path.push( {
            x:(sx + c * (ex - sx)),
            y:(sy + c * (ey - sy))
        } );
    }
};

Evernote.Scroller.prototype.doScroll = function () {
    var s = this.path[++this.step];
    if ( !s ) {
        return false;
    }
    var view = this._tab.document.defaultView || this._tab;
    view.scrollTo( s.x, s.y );
    return true;
};

Evernote.Scroller.prototype.abort = function () {
    if ( this.proc ) {
        clearInterval( this.proc );
        this.proc = null;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
function ContentPreview() {
    Evernote.Logger.debug("Start creating preview box");
    var contentVeil = new ContentVeil();
    Evernote.Logger.debug("End creating preview box");
    // Stores a reference to the last element that we used as a preview.
    var previewElement = null;
    var article = null;

    function buildPreviewLegend() {
        Evernote.Logger.debug("buildPreviewLegend: start");
        var legend = document.createElement("div");
        legend.id = "evernotePreviewLegend";
        legend.className = "evernotePreviewLegend";
        if(Evernote.Utils.isQuirkMode() || Evernote.BrowserDetection.isLessThanIE9()) {
            legend.className += " quirk-mode";
            legend.className += " evernote-preview-position-top";
        }
        legend.dir = "ltr"; // It ends up backwards on right-to-left pages otherwise.

        var nudgeImgs = [
            // Element class name                 Message identifier
            ["icon-arrow-up",   { message: Evernote.Messages.EXPAND_SELECTION, image: "images/nudge-icons/nudge-icon-arrow-up.png"} ],
            ["icon-arrow-down", { message: Evernote.Messages.SHRINK_SELECTION, image: "images/nudge-icons/nudge-icon-arrow-down.png"}],
            ["icon-arrow-lr",   { message: Evernote.Messages.MOVE_SELECTION, image: "images/nudge-icons/nudge-icon-arrow-lr.png"}],
            ["icon-return",     { message: Evernote.Messages.CLIP_ARTICLE_HINT, image: "images/nudge-icons/nudge-icon-return.png"}]
        ];

        var ul = document.createElement("UL");
        Evernote.Logger.debug("buildPreviewLegend: populate container");
        for (var i = 0; i < nudgeImgs.length; i++) {
            var li = document.createElement("li");
            if(i == nudgeImgs.length - 1)
                li.className = "last";
            var div = document.createElement("div");
            var message = document.createTextNode(Evernote.Addin.getLocalizedMessage(nudgeImgs[i][1].message));
            div.className = "keyIcon " + nudgeImgs[i][0];
            Evernote.GlobalUtils.absolutizeImages(div,  nudgeImgs[i][1].image);
            li.appendChild(div);
            var messageContainer = document.createElement("span");
            messageContainer.appendChild(message);
            li.appendChild(messageContainer);
            var clearDiv = document.createElement("div");
            div.style.clear = "both";
            li.appendChild(clearDiv);
            ul.appendChild(li);
        }
        Evernote.Logger.debug("buildPreviewLegend: populate container end");
        legend.appendChild(ul);
        return legend;
    }

    Evernote.Logger.debug("Build preview legend");
    var previewLegend = buildPreviewLegend();
    Evernote.Logger.debug("End Build preview legend");

    function showPreviewLegend() {
        if (!Evernote.ElementExtension.hasParentNode(previewLegend)) {
            document.body.appendChild(previewLegend);
        }
        var className = " visible";
        if(Evernote.Utils.isQuirkMode()) {
            className = " preview-visible";
        }
        previewLegend.className = previewLegend.className.replace(/\s*hidden|visible|preview-visible|preview-hidden\s*/, "");
        previewLegend.className += className;
    }

    function hidePreviewLegend() {
        var className = " hidden";
        if(Evernote.Utils.isQuirkMode()) {
            className = " preview-hidden";
        }
        previewLegend.className = previewLegend.className.replace(/\s*hidden|visible|preview-hidden|preview-visible\s*/, "");
        previewLegend.className += className;
    }

    function removePreviewLegend() {
        if (Evernote.ElementExtension.hasParentNode(previewLegend)) {
            previewLegend.parentNode.removeChild(previewLegend);
        }
    }

    function buildUrlElement() {
        var urlEl = document.createElement("div");
        urlEl.id = "evernotePreviewContainer";
        var className = "evernotePreviewContainer evernotePreviewUrlContainer";
        if(Evernote.Utils.isQuirkMode()) {
            className += " evernote-middle-fixed-position-quirks"
        }
        urlEl.className = className;
        return urlEl;
    }

    Evernote.Logger.debug("Build url element");
    var urlElement = buildUrlElement();

    function showUrlElement() {
        Evernote.Logger.debug("ContentPreview: showUrlElement start");
        if (!Evernote.ElementExtension.hasParentNode(urlElement)) {
            document.body.appendChild(urlElement);
        }

        // Make sure we're centered in the window.
        var elStyle = Evernote.ElementExtension.getComputedStyle(urlElement, '');
        var w = parseInt(Evernote.StyleElementExtension.getPropertyValue(elStyle, "width"));
        var h = parseInt(Evernote.StyleElementExtension.getPropertyValue(elStyle, "height"));

        if (w &#038;&#038; h) {
            urlElement.style.marginLeft = (0 - w / 2) + "px";
            urlElement.style.marginTop = (0 - h / 2) + "px";
        }
        Evernote.Logger.debug("ContentPreview: showUrlElement end");
    }

    function hideUrlElement() {
        if (Evernote.ElementExtension.hasParentNode(urlElement)) {
            urlElement.parentNode.removeChild(urlElement);
        }
    }

    function showOverlay()  {
        previewElement = null;
        clear();
        contentVeil.reset();
        contentVeil.show();
        contentVeil.hideAllActiveObjects();
    }

    function previewUrl() {
        previewElement = null;
        clear();
        contentVeil.reset();
        contentVeil.gray();
        var title = window.document.title;
        var url = PageContext.url;
        var favIconUrl =PageContext.getFavIconUrl();
        urlElement.innerHTML = Evernote.GlobalUtils.createUrlClipContent(title, url, favIconUrl);
        var element = Evernote.JQuery(urlElement);
        if(Evernote.Utils.isQuirkMode() &#038;&#038; !element.hasClass("evernote-fixed-position-fix")) {
            element.addClass("evernote-fixed-position-fix");
            Evernote.Utils.fixedPosition(window, element, function() {
                var clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                var containerHeight = element.outerHeight();
                return scrollTop + (clientHeight - containerHeight) / 2;
            }, true);
        }
        showUrlElement();
        contentVeil.hideAllActiveObjects();
    }

    // This doesn't remove internal state of previewElement, because another script may not have finished clipping until
    // after the page looks 'clear'.
    function clear() {
        contentVeil.reset();
        contentVeil.hide();
        hideUrlElement();
        removePreviewLegend();
    }

    function _previewArticle (showHelp) {
        Evernote.Logger.debug("Start previewing article element");
        if (previewElement)
        {
            var selectionFrame;
            if (typeof Evernote.pageInfo !== undefined) {
                selectionFrame = Evernote.pageInfo.getSelectionFrame();
            }
            Evernote.Logger.debug("Selection frame selected " + selectionFrame);
            if (selectionFrame) {

                var rect = {
                    width: selectionFrame.width,
                    height: selectionFrame.height,
                    top: selectionFrame.offsetTop,
                    bottom: (selectionFrame.height + selectionFrame.offsetTop),
                    left: selectionFrame.offsetLeft,
                    right: (selectionFrame.width + selectionFrame.offsetLeft)
                };
                Evernote.Logger.debug("contentVeil.revealStaticRect " + rect);
                contentVeil.revealStaticRect(contentVeil.expandRect(rect, -9), true);
                Evernote.Logger.debug("contentVeil.show ");
                contentVeil.show();
            }
            else {
                Evernote.Logger.debug("contentVeil.outlineElement");
                contentVeil.outlineElement(previewElement, true);
            }
            if (showHelp) {
                Evernote.Logger.debug("showPreviewLegend");
                showPreviewLegend();
                Evernote.Logger.debug("setTimeout:hidePreviewLegend");
                setTimeout(hidePreviewLegend, 6000);
            }
        }
        else {
            Evernote.Logger.warn("Couldn't find a preview element. We should switch to 'full page' mode.");
        }
    }

    /**
     * Finds and preview article element.
     * If reloadArticle is specified and equals to true, then discard previously found article and re-start search of article again.
     * Otherwise use article found on previous call (if this is the first call then article will be searched anyway).
     * @param reloadArticle
     */
    function previewArticle (reloadArticle) {
        var showHelp = Evernote.Options.articleSelection == Evernote.ArticleSelectionOptions.ENABLED;

        clear();
        previewElement = null;
        if(reloadArticle) {
            article = null;
        }
        Evernote.Logger.debug("Evernote.pageinfo " + Evernote.pageInfo);
        if (typeof Evernote.pageInfo !== undefined) {
            if(!article) {
                previewElement = Evernote.pageInfo.getDefaultArticle(function(el){
                    Evernote.Logger.debug("Article element " + el.nodeName);
                    previewElement = el;
                    article = el;
                    Evernote.Logger.debug("Preview article ");
                    _previewArticle(showHelp);
                });
                article = previewElement;
            } else {
                previewElement = article;
                _previewArticle(showHelp);
            }
        }
        else {
            Evernote.Logger.warn("Couldn't find a 'pageInfo' object.");
        }
    }

    // When nudging the preview around the page, we want to skip nodes that aren't interesting. This includes empty
    // nodes, containers that have identical contents to the already selected node, invisible nodes, etc.
    // @TODO: There's a lot more we could probably add here.
    function looksInteresting(candidate, given) {

        if (!candidate) {
            Evernote.Logger.warn("Can't determine if 'null' is interesting (it's probably not).");
            return false;
        }
        // This is the parent of our 'HTML' tag, but has no tag itself. There's no reason it's ever more interesting than
        // the HTML element.
        if (candidate === window.document) {
            return false;
        }

        //Disable clip of evernote main popup
        if(Evernote.JQuery(candidate).closest("#evernote-content").length != 0) {
            return false;
        }

        // We don't want to clip the clipper controls notification.
        // @TODO: Probably want something similar for the content veil.
        if (candidate === previewLegend) {
            return false;
        }

        // Elements with neither text nor images are not interesting.
        if (!candidate.textContent &#038;&#038; (candidate.getElementsByTagName("img").length === 0)) {
            return false;
        }

        // Elements with 0 area are not interesting.
        var rect = Evernote.ElementExtension.getBoundingClientRect(candidate);
        if (!rect.width || !rect.height) {
            return false;
        }

        // Invisible elements are not interesting.
        var style = Evernote.ElementExtension.getComputedStyle(candidate);
        if ((style.visibility === "hidden") || (style.display === "none")) {
            return false;
        }

        // If the nodes have a parent/child relationship, then they're only interesting if their visible contents differ.
        if (candidate.parentNode &#038;&#038; given.parentNode) {
            if ((candidate.parentNode == given) || (given.parentNode == candidate)) {
                if ((candidate.textContent === given.textContent) &#038;&#038;
                    (candidate.getElementsByTagName("img").length === given.getElementsByTagName("img").length)) {
                    return false;
                }
            }
        }
        return true;
    }

    // Returns the current article element, which may not be the same as the auto-detected one if the user has 'nudged'
    // the selection around the page.
    function getArticleElement() {
        return previewElement;
    }

    function nudgePreview(direction) {
        Evernote.Logger.debug("nudgePreview start");
        if (!previewElement) {
            return;
        }

        var oldPreview = previewElement;
        Evernote.Logger.debug("nudgePreview: direction is " + direction);
        Evernote.Logger.debug("nudgePreview: previewElement is " + previewElement.nodeName);
        switch (direction) {
            case "up":
                var temp = previewElement.parentNode;
                while (temp) {
                    if (looksInteresting(temp, previewElement)) {
                        // If we move up and then down, we want to move back to where we started, not the first child.
                        temp.enNudgeDescendToNode = previewElement;
                        previewElement = temp;
                        break;
                    }
                    temp = temp.parentNode;
                }
                break;
            case "down":
                Evernote.Logger.debug("nudgePreview: previewElement.enNudgeDescendToNode is " + previewElement.enNudgeDescendToNode);
                if (previewElement.enNudgeDescendToNode)
                {
                    var temp = previewElement.enNudgeDescendToNode;
                    // @TODO: make sure we clean these up somewhere else if we never reverse our nudging.
                    try {
                        delete previewElement.enNudgeDescendToNode;
                    } catch(e) {
                        previewElement.enNudgeDescendToNode = undefined;
                    }
                    previewElement = temp;
                    break;
                }
                Evernote.Logger.debug("nudgePreview: previewElement.children.length = " + previewElement.children.length);
                for (var i = 0; i < previewElement.children.length; i++) {
                    Evernote.Logger.debug("nudgePreview: checking child is " + previewElement.children[i].nodeName);
                    if (looksInteresting(previewElement.children[i], previewElement)) {
                        Evernote.Logger.debug("nudgePreview: found interesting child" + previewElement.children[i]);
                        previewElement = previewElement.children[i];
                        break;
                    }
                }
                break;
            case "left":
                var temp = previewElement.previousElementSibling;
                while (temp) {
                    if (looksInteresting(temp, previewElement)) {
                        previewElement = temp;
                        break;
                    }
                    temp = temp.previousElementSibling;
                }
                break;
            case "right":
                var temp = previewElement.nextElementSibling;
                while (temp) {
                    if (looksInteresting(temp, previewElement)) {
                        previewElement = temp;
                        break;
                    }
                    temp = temp.nextElementSibling;
                }
                break;
            default:
                Evernote.Logger.warn("Unhandled nudge direction: " + direction);
        }

        // Drawing is expensive so don't bother if nothing changed.
        if (oldPreview !== previewElement) {
            Evernote.Logger.debug("nudgePreview: draw new element.");
            contentVeil.outlineElement(previewElement, true);
        }
    }

    function previewFullPage() {

        var borderWidth = 10;
        var w = Evernote.Utils.innerWidth();
        var h = Evernote.Utils.innerHeight();

        var rect = {
            bottom: (h - borderWidth),
            top: (borderWidth),
            left: (borderWidth),
            right: (w - borderWidth),
            width: (w - (2 * borderWidth)),
            height: (h - (2 * borderWidth))
        }

        clear();
        contentVeil.reset();
        contentVeil.revealStaticRect(rect, true);
        contentVeil.show();
        contentVeil.hideAllActiveObjects();
    }

    // Creates the union of two rectangles, which is defined to be the smallest rectangle that contains both given
    // rectangles.
    function unionRectangles(rect1, rect2) {
        var rect = {
            top: (Math.min(rect1.top, rect2.top)),
            bottom: (Math.max(rect1.bottom, rect2.bottom)),
            left: (Math.min(rect1.left, rect2.left)),
            right: (Math.max(rect1.right, rect2.right))
        }
        rect.width = rect.right - rect.left;
        rect.height = rect.bottom - rect.top;

        return rect;
    }

    // Returns true if the rectangles match, false otherwise.
    function rectanglesEqual(rect1, rect2) {
        if (!rect1 &#038;&#038; !rect2) return true;
        if (!rect1) return false;
        if (!rect2) return false;
        if (rect1.top != rect2.top) return false;
        if (rect1.bottom != rect2.bottom) return false;
        if (rect1.left != rect2.left) return false;
        if (rect1.right != rect2.right) return false;
        if (rect1.width != rect2.width) return false;
        if (rect1.height != rect2.height) return false;
        return true;
    }

    // If the user triple-clicks a paragraph, we will often get a selection that includes the next paragraph after the
    // selected one, but only up to offset 0 in that paragraph. This causes the built in getBoundingClientRect to give a
    // box that includes the whole trailing paragraph, even though none of it is actually selected. Instead, we'll build
    // our own bounding rectangle that omits the trailing box.
    // @TODO: Currently this computes a box that is *too big* if you pass it a range that doesn't have start and/or end
    // offsets that are 0, because it will select the entire beginning and ending node, instead of jsut the selected
    // portion.
    function computeAlternateBoundingBox(range) {

        // If the end of selection isn't at offset 0 into an element node (rather than a text node), then we just return the
        // original matching rectangle.
        if ((range.endOffset !== 0) ||
            (range.endContainer &#038;&#038; range.endContainer.nodeType !== Evernote.Node.ELEMENT_NODE) ||
            ( range.startContainer &#038;&#038; range.startContainer &#038;&#038; range.startContainer.getBoundingClientRect) ||
            ( range.endContainer &#038;&#038; range.endContainer.getBoundingClientRect) ||
            ( range.commonAncestorContainer &#038;&#038; range.commonAncestorContainer.getBoundingClientRect)
            ) {
            var rect = Evernote.ElementExtension.getBoundingClientRect(range);
            if(rect.top == 0 &#038;&#038; rect.bottom == 0 &#038;&#038; rect.left == 0 &#038;&#038; rect.right == 0) {
                if(range.commonAncestorContainer &#038;&#038; range.commonAncestorContainer.getBoundingClientRect) {
                    rect = range.commonAncestorContainer.getBoundingClientRect();
                } else if(range.startContainer &#038;&#038; range.startContainer.getBoundingClientRect) {
                    rect = range.startContainer.getBoundingClientRect();
                } else if(range.endContainer &#038;&#038; range.endContainer.getBoundingClientRect) {
                    rect = range.endContainer.getBoundingClientRect();
                }
            }
            var mutableRect = {
                top: rect.top,
                bottom: rect.bottom,
                left: rect.left,
                right: rect.right,
                width: rect.width,
                height: rect.height
            };
            return mutableRect;
        }

        // This is the one we don't want.
        var endElementRect = null;
        try {
            endElementRect = Evernote.ElementExtension.getBoundingClientRect(range.endContainer);
        }
        catch(ex) {
            Evernote.Logger.warn("Couldn't get a bounding client rect for our end element, maybe it's a text node.");
        }

        // We look for a rectangle matching our end element, and if we find it, we don't copy it to our list to keep.
        // You'd think we could just grab the last element in range.getClientRects() here and trim that one, which might be
        // true, but the spec makes no claim that these are returned in order, so I don't want to rely on that.
        // We keep track if we remove a rectangle, as we're only trying to remove one for the trailnig element. If there are
        // more than one matching rectangle, we want to keep all but one of them.
        var foundEnd = false;
        var keptRects = [];
        var initialRects = range.getClientRects();
        for (var i = 0; i < initialRects.length; i++) {
            if (rectanglesEqual(endElementRect, initialRects[i]) &#038;&#038; !foundEnd) {
                foundEnd = true;
            }
            else {
                keptRects.push(initialRects[i]);
            }
        }

        // Now compute our new bounding box and return that.
        if (keptRects.length == 0) return Evernote.ElementExtension.getBoundingClientRect(range);
        if (keptRects.length == 1) return keptRects[0];

        var rect = keptRects[0];
        for (var i = 1; i < keptRects.length; i++) {
            rect = unionRectangles(rect, keptRects[i]);
        }

        return rect;
    }

    function applyElementRect(element, rect) {
        var newRect = rect;
        var tempRect = Evernote.ElementExtension.getBoundingClientRect(element);

        // We skip anything with an area of one px or less. This is anything that has "display: none", or single pixel
        // images for loading ads and analytics and stuff. Most hidden items end up at 0:0 and will stretch our rectangle
        // to the top left corner of the screen if we include them. Sometimes single pixels are deliberately placed off
        // screen.
        if ((tempRect.width * tempRect.height) > 1) {
            newRect = unionRectangles(Evernote.ElementExtension.getBoundingClientRect(element), rect);
        }
        if (element.children) {
            for (var i = 0; i < element.children.length; i++) {
                newRect = applyElementRect(element.children[i], newRect);
            }
        }
        return newRect;
    }

    // In the case of positioned elements, a bounding box around an element doesn't necessarily contain its child
    // elements, so we have this method to combine all of these into one bigger box. ContentVeil calls this function.
    function computeDescendantBoundingBox(element) {
        if (!element) return {top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0};
        return applyElementRect(element, Evernote.ElementExtension.getBoundingClientRect(element));
    }

    function previewSelection(sel) {

        var selection;
        var selectionFrame;
        if(sel) {
            selection = sel;
        }
        else if (typeof Evernote.pageInfo !== undefined) {
            selection = Evernote.pageInfo.getSelection();
            // If our selection is in a frame or iframe, we'll compute an offset relative to that, so we need to adjust it by
            // the offset of the frame.
            selectionFrame = Evernote.pageInfo.getSelectionFrame();
        }

        contentVeil.reset();

        var frameRect = null;
        if (selectionFrame) {
            frameRect = Evernote.ElementExtension.getBoundingClientRect(selectionFrame);
        }

        var range, rect, i;

        // If !selection, then something has gone awry.
        if (selection) {
            clear();
            contentVeil.reset();
            // We attempt to highlight each selection, but this hasn't been tested for more than a single selection.
            for (i = 0; i < Evernote.Utils.Selection.getRangeCount(selection); i++) {
                range = Evernote.Utils.Selection.getRangeAt(selection, i);

                rect = computeAlternateBoundingBox(Evernote.Utils.fixIERangeObject(range));

                // Actual adjustment mentioned earlier regarding frames.
                if (frameRect) {
                    rect.left += frameRect.left;
                    rect.right += frameRect.left;
                    rect.top += frameRect.top;
                    rect.bottom += frameRect.top;
                }

                contentVeil.revealRect(rect, true);
                contentVeil.scrollToRect(rect);
            }
        }
        contentVeil.show();
        contentVeil.hideAllActiveObjects();
    }

    // Public API:
    this.getArticleElement = getArticleElement;
    this.looksInteresting = looksInteresting;
    this.computeDescendantBoundingBox = computeDescendantBoundingBox;
    this.previewArticle = previewArticle;
    this.previewFullPage = previewFullPage;
    this.previewSelection = previewSelection;
    this.previewUrl = previewUrl;
    this.clear = clear;
    this.previewNudge = nudgePreview;
    this.showOverlay = showOverlay;
}
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ElementExtension = {
    querySelector : function(selector, doc) {
        if(!doc) {
            doc = document;
        }
        if(doc.querySelector) {
            return doc.querySelector(selector);
        }
        else {
            var head = doc.documentElement.firstChild;
            var styleTag = doc.createElement("STYLE");
            head.appendChild(styleTag);
            doc.__qsResult = [];

            styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsResult.push(this))}";
            window.scrollBy(0, 0);
            head.removeChild(styleTag);

            var result = [];
            for (var i in doc.__qsResult)
                result.push(doc.__qsResult[i]);
            return result;
        }
    },

    getComputedStyle : function(element, pseudoElement, win) {
        var pseudo = pseudoElement;
        var target = win;
        if(!target)
            target = window;
        if(!pseudo) {
            pseudo = null;
        }
        if(target.getComputedStyle)
            return target.getComputedStyle(element, pseudo);
        if(element.currentStyle) {
            try {
				var fixedElement = Evernote.Utils.cloneObject(element.currentStyle);
				fixedElement['fontSize'] = Evernote.Utils.getIEComputedStyle(element, 'fontSize');
				return fixedElement; 
			}             
            catch (err) {
                return element.currentStyle;
            }
        }
        return null;
    },

    hasParentNode : function(element) {
        return element.parentNode &#038;&#038; element.parentNode.nodeType != 9 &#038;&#038; element.parentNode.nodeType != 11;
    },

    getBoundingClientRect : function(element) {
        if(element &#038;&#038; element.getBoundingClientRect) {
            var rect = element.getBoundingClientRect();
            var width = rect.width || element.offsetWidth || element.boundingWidth;
            var height = rect.height || element.offsetHeight || element.boundingHeight;
            return {
                left : rect.left,
                right : rect.right,
                top : rect.top,
                bottom : rect.bottom,
                width : width,
                height : height
            }
        }
        return null;
    },

    hasAttribute : function(node, attrName) {
        if(node) {
            if(node.hasAttribute) {
                return node.hasAttribute(attrName);
            }
            if(node.attributes) {
                var attrValue = node.attributes[attrName];
                return typeof attrValue != typeof undefined;
            }
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ArrayExtension = {
    indexOf : function(element, searchStr) {
        if(!element) {
            return -1;
        }
        if (element.indexOf)
            return element.indexOf(searchStr);
        for(var i = 0; i < element.length; i++) {
            if(element[i] == searchStr)
                return i;
        }
        return -1;
    },

    remove : function(arr, element) {
        var elementPosition = Evernote.ArrayExtension.indexOf(arr, element);
        if(elementPosition != -1) {
            var rest = arr.slice(elementPosition  + 1 || arr.length);
            arr.length = elementPosition;
            return arr.push.apply(arr, rest);
        }
    },

    filter : function(arr, fun) {
        var len = arr.length >>> 0;
        if (typeof fun != "function")
            throw new TypeError();

        var res = [];
        var thisp = arguments[1];
        for (var i = 0; i < len; i++) {
            if (i in arr) {
                var val = arr[i];
                if (fun.call(thisp, val, i, arr))
                {
                    res.push(val);
                }
            }
        }
        return res;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.StyleElementExtension = {
    getPropertyValue : function(styleObj, propertyName) {
        var props = propertyName;
        if(!(props instanceof Array)) {
            props = [propertyName];
        }
        Evernote.Logger.debug("Evernote.StyleElementExtension.getPropertyValue: number of properties to check " + props.length);
        for(var i = 0; i < props.length; i++) {
            var propName = props[i];
            Evernote.Logger.debug("Evernote.StyleElementExtension.getPropertyValue: property name is " + propName);
            var val;
            if(styleObj.getPropertyValue) {
                val = styleObj.getPropertyValue(propName);
                Evernote.Logger.debug("Evernote.StyleElementExtension.getPropertyValue: value from getPropertyValue is " + val);
                if(val)
                    return val;
            }
            val = styleObj[propName];
            Evernote.Logger.debug("Evernote.StyleElementExtension.getPropertyValue: value from styleObj " + val);
            if(val)
                return val;
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.GlobalUtils = {};
(function(){
    var urlMatcher = /^(.*?):\/\/((www\.)?(.*?))(:\d+)?(\/.*?)(\?.*)?$/;

    var BAD_FAV_ICON_URLS = {"http://localhost/favicon.ico": true};

    Evernote.GlobalUtils.componentizeUrl = function(url) {
        var data = {
            protocol: null,
            domain: null,
            domainNoWww: null,
            port: null,
            path: null,
            queryString: null
        };
        var matches = urlMatcher.exec(url);
        data.protocol = matches[1];
        data.domain = matches[2];
        data.domainNoWww = matches[4];
        data.port = matches[5];
        data.path = matches[6];
        data.queryString = matches[7];
        return data;
    };

    Evernote.GlobalUtils.getMessageCode = function(messageConst) {
        Evernote.Logger.debug("getMessageCode: " + messageConst);
        return Evernote.Messages[messageConst];
    };

    Evernote.GlobalUtils.absolutizeImages = function(element, path) {
        if(path) {
            Evernote.Utils.changeBackgroundImage(element, Evernote.Addin.getPath("resources") + path);
        }
        else if(element.attributes &#038;&#038; element.attributes["background-image"]) {
            Evernote.Utils.changeBackgroundImage(element, Evernote.Addin.getPath("resources") + element.attributes["background-image"].value);
        }
        Evernote.Logger.debug("absolutizeImages: walk through children");
        for (var i = 0; i < element.children.length; i++) {
            Evernote.GlobalUtils.absolutizeImages(element.children[i]);
        }
        Evernote.Logger.debug("absolutizeImages: end");
    };

    Evernote.GlobalUtils.localize = function(element) {
        Evernote.Logger.debug("localize: Before lowercase");
        Evernote.Logger.debug("localize: element " + element);
        Evernote.Logger.debug("localize: element.nodeName " + element.nodeName);
        var node = element.nodeName.toLowerCase();
        Evernote.Logger.debug("localize: after lowercase");
        if (node == "input" || node == "textarea") {
            var type = element.type;
            if (node == "textarea") type = "textarea";
            switch (element.type) {
                case "text":
                case "textarea":
                case "button":
                case "submit":
                case "search":
                    if (element.attributes &#038;&#038; element.attributes["placeholder"]) {
                        var localizedMessage = Evernote.Addin.getLocalizedMessage(Evernote.GlobalUtils.getMessageCode(element.attributes["placeholder"].value));
                        Evernote.Logger.debug("localizedMessage is " + localizedMessage);
                        if (localizedMessage) {
                            try {
                                element.attributes["placeholder"].value = localizedMessage;
                            } catch(e) {
                                var placeHolderAttr = document.createAttribute("placeholder");
                                placeHolderAttr.nodeValue = localizedMessage;
                                element.setAttribute("placeholder", localizedMessage);
                            }
                        }
                    }

                    if (element.attributes &#038;&#038; element.attributes["message"]) {
                        var localizedMessage = Evernote.Addin.getLocalizedMessage(Evernote.GlobalUtils.getMessageCode(element.attributes["message"].value));
                        Evernote.Logger.debug("localizedMessage is " + localizedMessage);
                        if (localizedMessage) {
                            element.value = localizedMessage;
                        }
                    }
                    break;

                // unlocalizable.
                case "checkbox":
                case "password":
                case "hidden":
                    break;

                default:
                    throw new Error("We need to localize the value of input elements.");
            }
        }

        else if (element.attributes &#038;&#038; element.attributes["message"]) {
            var localizedMessage = Evernote.Addin.getLocalizedMessage(Evernote.GlobalUtils.getMessageCode(element.attributes["message"].value));
            if (localizedMessage) {
                element.innerHTML = localizedMessage;
            }
        }

        if (element.title){
            var localizedTitle = Evernote.Addin.getLocalizedMessage(Evernote.GlobalUtils.getMessageCode(element.title));
            if (localizedTitle) {
                element.title = localizedTitle;
            }
        }

        for (var i = 0; i < element.children.length; i++) {
            Evernote.GlobalUtils.localize(element.children[i]);
        }
    };

    Evernote.GlobalUtils.getQueryParams = function(url) {
        var data = Evernote.GlobalUtils.componentizeUrl(url);
        var queryString = data.queryString;
        var params = {};
        if (!queryString) {
            return params;
        };
        queryString = queryString.substr(1); // Don't want the question mark.
        queryString = queryString.split("#")[0]; // Get rid of any fragment identifier.
        var pairs = queryString.split("&#038;");
        var i;
        for (i = 0; i < pairs.length; i++) {
            var item = pairs[i].split("=");
            if (item[1]) {
                item[1] = item[1].replace(/\+/g, " ");
            }
            params[item[0].toLowerCase()] = item[1];
        }
        return params;
    };

    Evernote.GlobalUtils.escapeXML = function(str) {
        var map = {
            "&#038;" : "&amp;",
            "<" : "&lt;",
            ">" : "&gt;",
            "\"" : "&quot;",
            "'" : "&apos;"
        };

        var a = str.split("");
        for (var i = 0; i < a.length; i++) {
            if (map[a[i]]) {
                a[i] = map[a[i]];
            }
        }
        return a.join("");
    };

    Evernote.GlobalUtils.createUrlClipContentForOldClipper = function(title, url) {
        var style = "font-size: 12pt; line-height: 18px; display: inline;";
        var content = "<a title=\"" + title + "\" style=\"" + style + "\" href=\"" + url + "\">" + url + "</a>";
        var imgStyle = "display:inline;border: none; width: 16px; height: 16px; padding: 0px; margin: 0px 8px -2px 0px;";
        return "<span><img class="colorbox-1038"  title=\"" + title + "\" style=\"" + imgStyle + "\" src=\"" + Evernote.GlobalUtils.getFaviconImageUrlForOldClipper(url) +"\"/>" +
            content + "</span>";
    };

    Evernote.GlobalUtils.getFaviconImageUrlForOldClipper = function(url) {
        var re = new RegExp( "^[^:]+:\/+([^\/" + ":" + "]+).*$" );
        var domain = url.replace( re, "$1" );
        return "http://www.google.com/s2/favicons?domain=" + domain.toLowerCase();
    };


    Evernote.GlobalUtils.createUrlClipContent = function(title, url, favIcoUrl) {
        var titleAttr = (title) ? Evernote.GlobalUtils.escapeXML(title) : "";
        var style = "font-size: 12pt; line-height: 18px; display: inline;";
        var content = "<a title=\"" + titleAttr + "\" style=\"" + style + "\" href=\"" + Evernote.GlobalUtils.escapeXML(url) + "\">" + Evernote.GlobalUtils.escapeXML(url) + "</a>";
        if (favIcoUrl &#038;&#038; !BAD_FAV_ICON_URLS[favIcoUrl.toLowerCase()]) {
            var imgStyle = "display:inline;border: none; width: 16px; height: 16px; padding: 0px; margin: 0px 8px -2px 0px;";
            content = "<span><img class="colorbox-1038"  title=\"" + titleAttr + "\" style=\"" + imgStyle + "\" src=\"" + favIcoUrl + "\"/>" +
                content + "</span>"
        } else {
            content = "<span>" + content + "</span>";
        }
        return content;
    };

    Evernote.GlobalUtils.executeOnDomReady = function(callback) {
        Evernote.JQuery(document).ready(function() {
            callback();
        });
    };

    Evernote.GlobalUtils.isDocumentLoaded = function(doc) {
        return doc.readyState == "complete" || doc.readyState == "interactive";
    };
})();
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * Global utilities.
 */
Evernote.Utils = {

    getIEComputedStyle : function(elem, prop) {
        //Dean Edwards method. See first comment here: http://bit.ly/cMSs9R

        var value = elem.currentStyle[prop] || 0
        var leftCopy = elem.style.left
        var runtimeLeftCopy = elem.runtimeStyle.left

        elem.runtimeStyle.left = elem.currentStyle.left
        elem.style.left = (prop === "fontSize") ? "1em" : value
        value = elem.style.pixelLeft + "px";

        elem.style.left = leftCopy
        elem.runtimeStyle.left = runtimeLeftCopy
        return value
    },

    cloneObject : function(obj){
        if(obj == null || typeof(obj) != 'object')
            return obj;
        if(obj.constructor == Array)
            return [].concat(obj);
        var temp = {};
        for(var key in obj)
            temp[key] = this.cloneObject(obj[key]);
        return temp;
    },

    saveSelection : function(win) {
        Evernote.Logger.debug( "Utils.SaveSelection()" );
        var selectionFinder = new Evernote.SelectionFinder(win.document);
        selectionFinder.find( true );
        if(selectionFinder.hasSelection()) {
            return Evernote.Utils.cloneRange(selectionFinder.getRange());
        }
        return null;
    },

    clearSelection : function(doc) {
        if(doc.getSelection) {
            doc.getSelection().removeAllRanges();
        }
    },

    /**
     * Make selection of passed range in document.
     * @param doc - DOM object
     * @param range - selection range
     */
    selectRange : function(doc, range) {
        if(doc.getSelection) {
            doc.getSelection().addRange(range);
        }
        else if (doc.selection &#038;&#038; range) {
            range.select();
        }
    },

    /**
     * Creates copy of selection range only if it supports it, otherwise returns same range
     * @param range - Range object
     * @return {Range}
     */
    cloneRange : function(range) {
        Evernote.Logger.debug("cloneRange: start");
        if(range &#038;&#038; range.cloneRange) {
            return range.cloneRange();
        }
        if(range.duplicate) {
            Evernote.Logger.debug("cloneRange: result = " + range.duplicate());
            return range.duplicate();
        }
        return range;
    },

    /**
     * Checks whether selection is presented.
     * @param win - window object that should be checked.
     * @return true - if selection is presented, false otherwise.
     */
    hasSelection : function(win) {
        Evernote.Logger.debug( "Utils.hasSelection()" );
        var selectionFinder = new Evernote.SelectionFinder(win.document)
        if ( selectionFinder.hasSelection() ) {
            return true;
        }
        else {
            selectionFinder.find( true );
            return selectionFinder.hasSelection();
        }
    },

    /**
     * Gets favicon url from the document (if any)
     * @param doc - document to inspect.
     * @return url to the favicon or null.
     */
    getFavIconUrl : function(doc) {
        var links = doc.getElementsByTagName("link");
        var i;
        for (i = 0; i < links.length; i++) {
            if (links[i].rel) {
                var rels = links[i].rel.toLowerCase().split(/\s+/);
                if (Evernote.ArrayExtension.indexOf(rels, "icon") !== -1) {
                    // Found it!
                    return links[i].href;
                }
            }
        }
        return null;
    },

    /**
     * If passed string length is more than length argument, than string is trimmed to length and dots are added
     * (total length of the returned string does not exceed specified length).
     * @param str - string to trim
     * @param length - max number of characters in the string
     * @param addition - text to be added to truncated string
     * @return {*}
     */
    cutToLength : function(str, length, addition) {
        if(!addition) {
            addition = "...";
        }
        if(str.length > length) {
            return (str.substring(0, length-3) + addition);
        }
        return str;
    },

    /**
     * Change new line symbol to html 
     */
    newLineToBr : function(str) {
        return str.replace(/(\r\n|\n|\r)/gm, "
");
    },

    /**
     * Encodes html specific characters (<, >, &#038;, etc.) in specified string
     * @param str - string to encode.
     * @return new string with encoded characters.
     */
    htmlEncode : function( str ) {
        var result = "";
        for ( var i = 0; i < str.length; i++ ) {
            var charcode = str.charCodeAt( i );
            var aChar = str[ i ];
            if(!aChar) {
                aChar = str.charAt(i);
            }
            if(charcode >= 55296 )
                result += aChar;
            else if ( charcode > 0x7f ) {
                result += "&#" + charcode + ";";
            }
            else if ( aChar == '>' ) {
                result += "&gt;";
            }
            else if ( aChar == '<' ) {
                result += "&lt;";
            }
            else if ( aChar == '&#038;' ) {
                result += "&amp;";
            }
            else {
                result += str[ i ] ? str[ i ] : str.charAt(i);
            }
        }

        return result;
    },

    /**
     * Absolutize specified url by specified base.
     * @param base - base url
     * @param href - relative url (from base)
     */
    makeAbsolutePath : function ( base, href ) {
        function parseURI( url ) {
            var m = String( url ).replace( /^\s+|\s+$/g, '' ).match( /^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/ );
            // authority = '//' + user + ':' + pass '@' + hostname + ':' port
            return (m ? {
                href : m[ 0 ] || '',
                protocol : m[ 1 ] || '',
                authority : m[ 2 ] || '',
                host : m[ 3 ] || '',
                hostname : m[ 4 ] || '',
                port : m[ 5 ] || '',
                pathname : m[ 6 ] || '',
                search : m[ 7 ] || '',
                hash : m[ 8 ] || ''
            } : null);
        }

        function absolutizeURI( base, href ) {// RFC 3986
            function removeDotSegments( input ) {
                var output = [];
                input.replace( /^(\.\.?(\/|$))+/, '' )
                    .replace( /\/(\.(\/|$))+/g, '/' )
                    .replace( /\/\.\.$/, '/../' )
                    .replace( /\/?[^\/]*/g, function ( p ) {
                        if ( p === '/..' ) {
                            output.pop();
                        }
                        else {
                            output.push( p );
                        }
                    } );
                return output.join( '' ).replace( /^\//, input.charAt( 0 ) === '/' ? '/' : '' );
            }

            href = parseURI( href || '' );
            base = parseURI( base || '' );

            return !href || !base ? null : (href.protocol || base.protocol) +
                (href.protocol || href.authority ? href.authority : base.authority) +
                removeDotSegments( href.protocol || href.authority || href.pathname.charAt( 0 ) === '/' ? href.pathname :
                    (href.pathname ? ((base.authority &#038;&#038; !base.pathname ? '/' : '') +
                        base.pathname.slice( 0, base.pathname.lastIndexOf( '/' ) + 1 ) + href.pathname) : base.pathname) ) +
                (href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) +
                href.hash;
        }
        return absolutizeURI( base, href );

    },

    getNestedDocuments : function( doc ) {
        Evernote.Logger.debug( "Utils.getNestedDocuments()" );

        var docs = [ ];
        try {
            var frames = ( doc ) ? doc.getElementsByTagName( "frame" ) : [ ];
            for ( var i = 0; i < frames.length; ++i ) {
                if ( frames[ i ].contentDocument ) {
                    docs.push( frames[ i ].contentDocument );
                }
            }

            var iframes = ( doc ) ? doc.getElementsByTagName( "iframe" ) : [ ];
            for ( i = 0; i < iframes.length; ++i ) {
                if ( iframes[ i ].contentDocument ) {
                    docs.push( iframes[ i ].contentDocument );
                }
            }
        } catch (e) {
            Evernote.Logger.error("getNestedDocuments failed with error " + e);
        }
        Evernote.Logger.debug( "Utils.getNestedDocuments() end" );
        return docs;

    },

    isSupportedUrl : function(url) {
        return url.indexOf("http") == 0;
    },

    getFontSizeInPixels : function(elementFontSize) {
        function computedStyle(element, property){
            var s = false;
            if(window.getComputedStyle){
                s = window.getComputedStyle(element, null).getPropertyValue(property);
            } else if(element.currentStyle){
                var p = property.split('-');
                var str = new String('');
                for(var i = 0; i < p.length; i++){
                    str += (i > 0)?(p[i].substr(0, 1).toUpperCase() + p[i].substr(1)):p[i];
                }
                s = element.currentStyle[str];
            }
            return s;
        }

        function getPercentageSize(size) {
            var currentFontSize = parseFloat(size);
            var htmlFontSize = 16;
            var htmlElement = document.getElementsByTagName("html");
            if(htmlElement &#038;&#038; htmlElement.length > 0) {
                var htmlComputedFontSize = computedStyle(htmlElement[0], "font-size");
                if(htmlComputedFontSize &#038;&#038; htmlComputedFontSize.indexOf("%") == -1) {
                    htmlFontSize = Evernote.Utils.getFontSizeInPixels(htmlComputedFontSize);
                }
            }
            return htmlFontSize * currentFontSize / 100;
        }

        var size = elementFontSize;
        if(size.indexOf("em") > -1) {
            var defFont = computedStyle(document.body, "font-size");
            if(defFont.indexOf("pt") > -1){
                defFont = Math.round(parseInt(defFont)*96/72);
            } else if(defFont.indexOf("%") > -1)  {
                defFont = getPercentageSize(defFont);
            } else{
                defFont = parseInt(defFont);
            }
            size = Math.round(defFont * parseFloat(size));
        }
        else if(size.indexOf("pt") > -1){
            size = Math.round(parseInt(size)*96/72)
        } else if(size.indexOf("%") > -1) {
            size = getPercentageSize(size);
        }
        return parseInt(size);
    },

    innerWidth : function() {
        if(window.innerWidth)
            return window.innerWidth;

        var doc= (document.body.clientWidth)? document.body: document.documentElement;
        return doc.clientWidth;
    },

    innerHeight : function() {
        if(window.innerHeight)
            return window.innerHeight;

        var doc= (document.body.clientHeight)? document.body: document.documentElement;
        return doc.clientHeight;
    },

    scrollTop : function() {
        var doc = document.body.scrollTop ? document.body : document.documentElement;
        return doc.scrollTop;
    },

    scrollLeft : function() {
        var doc = document.body.scrollLeft ? document.body : document.documentElement;
        return doc.scrollLeft;
    },

    /**
     * Stopped propagation of keydown events for passed selector.
     * @param selector - could be element or jquery selector.
     */
    hardInput : function(selector) {
        this.elem = Evernote.JQuery(selector);
        this.elem.keydown(function(e) {
            e.stopPropagation();
        });
    },

    isQuirkMode : function() {
        return document.compatMode == "BackCompat" &#038;&#038; !Evernote.BrowserDetection.isIE11();
    },

    isInstanceOf : function(obj, type) {
        if(obj &#038;&#038; type) {
            try {
                return obj instanceof type;
            } catch (e) {
                return type.toString().indexOf(typeof obj) != -1;
            }
        }
        return false;
    },

    changeBackgroundImage : function(element, localpath) {
        if(element.style) {
            element.style.backgroundImage = "url('file:///" + localpath.replace(/\\/g, "/").replace(/\s/g, "%20") + "')";
        }
    },

    format: function(str) {
        var args = arguments;
        return str.replace(/\{(\d+)\}/g, function (m, n) { return args[(n | 0)+1]; });
    },

    fixIERangeObject : function(range,win) { //Only for IE8 and below.
        win=win || window;

        if(!range) return null;
        if(!range.startContainer &#038;&#038; win.document.selection) { //IE8 and below

            var _findTextNode=function(parentElement,text) {
                //Iterate through all the child text nodes and check for matches
                //As we go through each text node keep removing the text value (substring) from the beginning of the text variable.
                var container=null,offset=-1;
                for(var node=parentElement.firstChild; node; node=node.nextSibling) {
                    if(node.nodeType==3) {//Text node
                        var find=node.nodeValue;
                        var pos=text.indexOf(find);
                        if(pos==0 &#038;&#038; text!=find) { //text==find is a special case
                            text=text.substring(find.length);
                        } else {
                            container=node;
                            offset=text.length-1; //Offset to the last character of text. text[text.length-1] will give the last character.
                            break;
                        }
                    }
                }
                //Debug Message
                //alert(container.nodeValue);
                return {node: container,offset: offset}; //nodeInfo
            };

            var rangeCopy1=range.duplicate(), rangeCopy2=range.duplicate(); //Create a copy
            var rangeObj1=range.duplicate(), rangeObj2=range.duplicate(); //More copies <img src="http://www.egao-tane.com/wp-includes/images/smilies/icon_razz.gif" alt=":P" class="wp-smiley colorbox-1038" /> 

            rangeCopy1.collapse(true); //Go to beginning of the selection
            rangeCopy1.moveEnd('character',1); //Select only the first character
            rangeCopy2.collapse(false); //Go to the end of the selection
            rangeCopy2.moveStart('character',-1); //Select only the last character

            //Debug Message
            // alert(rangeCopy1.text); //Should be the first character of the selection
            var parentElement1=rangeCopy1.parentElement(), parentElement2=rangeCopy2.parentElement();

            //If user clicks the input button without selecting text, then moveToElementText throws an error.
            if(window.HTMLInputElement &#038;&#038; (parentElement1 instanceof window.HTMLInputElement || parentElement2 instanceof HTMLInputElement)) {
                return null;
            }
            rangeObj1.moveToElementText(parentElement1); //Select all text of parentElement
            rangeObj1.setEndPoint('EndToEnd',rangeCopy1); //Set end point to the first character of the 'real' selection
            rangeObj2.moveToElementText(parentElement2);
            rangeObj2.setEndPoint('EndToEnd',rangeCopy2); //Set end point to the last character of the 'real' selection

            var text1=rangeObj1.text; //Now we get all text from parentElement's first character upto the real selection's first character
            var text2=rangeObj2.text; //Here we get all text from parentElement's first character upto the real selection's last character

            var nodeInfo1=_findTextNode(parentElement1,text1);
            var nodeInfo2=_findTextNode(parentElement2,text2);

            //Finally we are here
            range.startContainer=nodeInfo1.node;
            range.startOffset=nodeInfo1.offset;
            range.endContainer=nodeInfo2.node;
            range.endOffset=nodeInfo2.offset+1; //End offset comes 1 position after the last character of selection.
        }
        return range;
    },

    fixedPosition : function(win, el, topOffset, immediate) {
        function applyPosition(elem) {
            if(elem) {
                var scrollPosition = win.document.documentElement.scrollTop || win.document.body.scrollTop;
                var offset;
                if(typeof topOffset == "function") {
                    offset = topOffset();
                } else {
                    offset = scrollPosition + topOffset;
                }
                elem.animate({top: offset}, 100);
            }
        }

        if(el) {
            var elem = Evernote.JQuery(el);
            if(Evernote.Utils.isQuirkMode())  {
                elem.css("position", "absolute");
                if (win.attachEvent)
                    win.attachEvent("onscroll", function() {applyPosition(elem);});
                else if (win.addEventListener)
                    win.addEventListener("scroll", function() {applyPosition(elem);}, false);
                else
                    Evernote.Logger.error( "Utils.fixedPosition() can't attachEvent" );
                if(immediate) {
                    applyPosition(elem);
                }
            }
        }
    },

    mergeCustomComboBoxStrings : function(notebook, owner, ownedByStr, maxLen) {

        var totalLen = notebook.length;
        if (owner.length) {
            // format: "space","(","<owned by localize string>","space","<owner>",")"
            // magic number "4" is: "space","(","space",")"
            totalLen += ownedByStr.length + owner + 4;
        }

        if (totalLen <= maxLen) {
            return {
                note: notebook,
                own: "",
                title: ""
            };
        }

        var half = maxLen / 2 - 2;

        if (owner.length == 0) {
            return {
                note: notebook.substr(0, half) + "..." + notebook.substring(notebook.length - half, notebook.length),
                own: "",
                title: notebook
            };
        }

        var ownerFormatStr = "(" + ownedByStr + " " + owner + ")";
        var title = notebook + ownerFormatStr;
        var resultString = title.substr(0, half) + "..." + title.substr(title.length - half);

        if (notebook.length <= half) {
            return  {
                note: notebook,
                own: "..." + title.substr(title.length - notebook.length),
                title: notebook + " " + ownerFormatStr
            };
        }else if (ownerFormatStr <= half) {
            return  {
                note: notebook.substr(0, maxLen - ownerFormatStr.length) + "...",
                own: ownerFormatStr,
                title: notebook + " " + ownerFormatStr
            };
        }else {
            return  {
                note: resultString.substr(0, resultString.length - half),
                own: resultString.substr(half + 3),
                title: notebook + " " + ownerFormatStr
            };
        }
    },

    setEvernoteLogo : function(selector) {
        var serverLocation = Evernote.Addin.getServerLocation();
        Evernote.Logger.debug("Evernote server location is " + serverLocation);
        if (serverLocation.length &#038;&#038; serverLocation.indexOf("international") == -1) {
            var evernoteLogoEl = Evernote.JQuery(selector);
            if (evernoteLogoEl) {
                var imageFileName = "images/web-clipper-logo_" + serverLocation + ".png";
                this.changeBackgroundImage(evernoteLogoEl.get(0), Evernote.Addin.getPath("resources") + imageFileName);
            }
        }
    },

    Selection : {
        getRangeCount : function(selection) {
            if(selection.rangeCount) {
                return selection.rangeCount;
            }
            return 1;
        },

        getRangeAt : function(selection, pos) {
            if(selection.getRangeAt) {
                selection.getRangeAt(pos);
            }
            return selection;
        },

        getCommonAncestorContainer : function(range) {
            if(range.commonAncestorContainer) {
                return range.commonAncestorContainer;
            }
            else if(range.parentElement) {
                return range.parentElement();
            }
            return null;
        }
    }





};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ClipperActions = {
    CLIP_URL : "0",
    CLIP_FULL_PAGE: "1",
    CLIP_ARTICLE: "2",
    CLIP_SELECTION: "3",
    CLIP_IMAGE: "4"

};

Evernote.ArticleSelectionOptions = {
    ENABLED : "0",
    DISABLED : "1",
    ENABLED_WITHOUT_HINTS : "2"
};

Evernote.Options = {
    defaultAction : Evernote.ClipperActions.CLIP_ARTICLE,
    articleSelection: Evernote.ArticleSelectionOptions.ENABLED,
    selectedNotebookUid: -1,

    /**
     * Return string representation of the object (you can use it in load method to restore object from string).
     */
    _serialize: function() {
        return JSON.stringify(this);
    },

    load : function() {
        var optionsContent = Evernote.FS.getFileContent(this._getOptionsFilePath());
        this._load(optionsContent);
    },

    _getOptionsFilePath : function() {
        return Evernote.Addin.getPath("options") + "options.json";
    },

    _load : function(str) {
        if(str) {
            var option;
            try {
                option = JSON.parse(str);
            }catch(ignore) {
            }
            if(option) {
                if(option.defaultAction) {
                    this.defaultAction = option.defaultAction;
                }
                if(option.articleSelection) {
                    this.articleSelection = option.articleSelection;
                }
                if(option.selectedNotebookUid) {
                    this.selectedNotebookUid = option.selectedNotebookUid;
                }
            }
        }
    },

    setDefaultAction : function(action) {
        this.defaultAction = action;
        this.save();
    },

    setNotebook : function(notebookUid) {
        this.selectedNotebookUid = notebookUid;
        this.save();
    },

    setArticleSelection : function(articleSelection) {
        this.articleSelection = articleSelection;
        this.save();
    },

    save : function() {
        var jsonSer = this._serialize();
        try {
            JSON.parse(jsonSer);
        }catch(e) {
            var tempJson = "";
            for (var el in this) {
                if (typeof (this[el]) == 'function')
                    continue;
                if (tempJson.length )
                    tempJson += ",";
                tempJson += "\"" + el + "\":\"" +  this[el] + "\"";
            }
            tempJson = "{" + tempJson + "}";
            jsonSer = tempJson;
        }
        Evernote.FS.writeToFile(this._getOptionsFilePath(), jsonSer);
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.BrowserDetection = {
    isIE11 : function() {				
        return navigator.userAgent.indexOf("Trident/7.0") != -1       
    },
	
	isIE10 : function() {
        return navigator.userAgent.indexOf("MSIE 10") != -1;
    },

    isIE7 : function() {
        return navigator.userAgent.indexOf("MSIE 7.0") != -1 &#038;&#038; navigator.userAgent.indexOf("Trident/7.0") == -1;
    },

    isIE8 : function() {
        return navigator.userAgent.indexOf("MSIE 8.0") != -1 &#038;&#038; navigator.userAgent.indexOf("Trident/7.0") == -1;
    },

    isLessThanIE9 : function() {
        return Evernote.BrowserDetection.isIE7() || Evernote.BrowserDetection.isIE8()
    },
	
	isIE10orGreater : function() {
		return Evernote.BrowserDetection.isIE10() || Evernote.BrowserDetection.isIE11()
	}
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.Node = {
    ELEMENT_NODE : 1,
    TEXT_NODE : 3
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.Messages = {
    CLIP_SELECTION: 113,			// Save Selection
    CLIP_URL: 115,					// Save URL
    CLIP_FULL_PAGE: 116,			// Save Full Page
    CLIP_ARTICLE: 117,				// Save Article
    ENTER: 118,						// enter
    OPTIONS: 119,					// Options
    DEFAULT_ACTION: 120,			// Default action
    ARTICLE_SELECTION: 121,			// Article selection
    ENABLED: 122,					// Enabled
    DISABLED: 123,					// Disabled
    ENABLED_NO_HINTS: 124,			// Enabled (no hints)
    ARTICLE_SELECTION_HINT: 125,	// When enabled, you can modify article selection using your keyboard before make a clip. Enabling with "no hints" will prevent displaying the informational message. When disabled - you cannot make any adjustments to the automatic article selection.
    EXPAND_SELECTION: 126,			// expand selection
    SHRINK_SELECTION: 127,			// shrink selection
    MOVE_SELECTION: 128,			// move selection
    CLIP_ARTICLE_HINT: 129,			// clip article
    CLIPPING: 130,					// Clipping...
    UNSUPPORTED_SCHEMA: 131,		// Clipping from this location is not supported.
    UNTITLED_NOTE: 132,				// Untitled note
    ADD_TAGS: 133,					// Add tags
    ADD_COMMENTS: 134,				// Add comments
    OWNED_BY: 135,					// owned by
    SHARED_NOTEBOOKS: 136,			// Shared Notebooks
    BUSINESS_NOTEBOOKS: 137,		// Business Notebooks
    LOADING_TAGS: 140,				// Loading tags...
    LOGIN_FAILED: 141,				// You need to be signed in to Evernote desktop to clip webpages
    CLOSE: 142,						// ﾐ厘ｰﾐｺﾑﾑ錦び・
    LOADING_NOTEBOOKS: 146,			// ﾐｷﾐｰﾐｳﾑﾑσｶﾐｰﾑ・ﾐｱﾐｻﾐｾﾐｺﾐｽﾐｾﾑび・..
    CLIP_FAILED_TITLE: 147,			// ﾐ斷ｵ ﾑσｴﾐｰﾐｻﾐｾﾑ・・ﾑ・ｾﾑ・ﾐｰﾐｽﾐｸﾑび・ﾐｷﾐｰﾐｼﾐｵﾑひｺﾑ・
    VERSION: 148,					// ﾐ漬ｵﾑﾑ・ｸﾑ・
    LIMIT_TAGS: 150,				// You've entered the maximum number of tags
    CLIP_HEADER: 151,				// Clip
    SKITCH_HEADER: 152,				// Markup
    FILE_HEADER: 153,				// File
    SAVE_BUTTON: 154,				// Save
    CLIP_SCREEN_SHOT: 155,			// Screenshot
    NOTEBOOK_SEARCH: 156,			// Find a notebook
    SHARE_BUTTON: 157,				// Share
    ARTICLE: 158,					// Article
    SIMPLIFIED_ARTICLE: 159,		// Simplified Article
    SELECTION: 160,					// Selection
    URL: 161,						// Bookmark
    SCREENSHOT: 162,				// Screenshot
    SOURCE_LINK: 163,				// Source link
    URL_COPIED: 164,				// Url copied to clipboard
    /* Messages below are not implemented yet*/
    FULL_PAGE: 165,					// Full Page
    TAGS_NOT_SUPPORTED: 166		    // Tags not supported
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ResponseReceiver = {
    parsers : [],
    receivers : [],

    onResponse: function(str) {
        Evernote.Logger.debug("Response received" + str);
        for(var i in Evernote.ResponseReceiver.parsers) {
            if(Evernote.ResponseReceiver.parsers[i].canParse &#038;&#038; Evernote.ResponseReceiver.parsers[i].canParse(str)) {
                Evernote.ResponseReceiver.notify(Evernote.ResponseReceiver.parsers[i].parse(str));
            }
        }
    },

    registerParser: function(parser) {
        Evernote.ResponseReceiver.parsers.push(parser);
    },

    subscribe: function(receiver) {
        Evernote.ResponseReceiver.receivers.push(receiver);
    },

    notify: function(data) {
        for(var i=0; i < Evernote.ResponseReceiver.receivers.length; i++) {
            Evernote.ResponseReceiver.receivers[i].onDataReceived(data);
        }
    }
};

function EvernoteGlobalReceiver(str) {
    Evernote.ResponseReceiver.onResponse(str);
}
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ProcessIDResponseParser = {
    parse : function(str) {
        Evernote.Logger.debug("ProcessIDResponseParser: response" + str);
        var xmlDom = Evernote.JQuery(str);
        var result = xmlDom.attr("process_id");
        return new Evernote.Response("process_id", result);
    },

    canParse: function(str) {
        var request = Evernote.JQuery(str).attr("request");
        return request &#038;&#038; (request == "get_process_id");
    }
};

Evernote.ResponseReceiver.registerParser(Evernote.ProcessIDResponseParser);
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ErrorResponseParser = {

    parse : function(str) {
        Evernote.Logger.warn("Received error " + str);
        var error = Evernote.JQuery(str);
        var errorCode = error.attr("code");
        var errorMessage = null;
        var problem = null;
        if(error.length == 1) {
            var problems = error.find("problem");
            if(problems &#038;&#038; problems.length > 0) {
                problem = Evernote.JQuery(problems[0]);
            }
        }
        else if(error.length > 2) {
            errorMessage = error[2].toString();
        }
        if(problem) {
            errorMessage = problem.text();
        } else if(!errorMessage) {
            errorMessage = error.attr("details");
        }
        switch (errorCode) {
            case Evernote.ErrorCodes.AUTHENTICATION_ERROR :
                errorMessage = Evernote.Addin.getLocalizedMessage(Evernote.Messages.LOGIN_FAILED);
                break;
            case Evernote.ErrorCodes.CLIP_ERROR :
                errorMessage = Evernote.Addin.getLocalizedMessage(Evernote.Messages.CLIP_FAILED_TITLE) + "\n" + errorMessage;
        }
        var msg = {
            message: errorMessage,
            code: errorCode
        };

        return new Evernote.Response("error", msg);
    },

    canParse: function(str) {
        var request = Evernote.JQuery(str).get(0);
        return (request &#038;&#038; (request.nodeName == "ERROR"));
    }
};

Evernote.ResponseReceiver.registerParser(Evernote.ErrorResponseParser);
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.AlertErrorHandler = {
    processError: function(error) {
        alert(error.message);
        return true;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ErrorHandler = {

    getHandler: function() {
        return [Evernote.Addin, Evernote.AlertErrorHandler, Evernote.evernotePopup];
    },

    onDataReceived : function(response) {
        if(response.type) {
            if(response.type == "error") {
                this.notifyHandlers(response.data);

            }
        }
    },

    notifyHandlers : function(error) {
        for(var i = 0; i < this.getHandler().length; i++) {
            var handler = this.getHandler()[i];
            if(handler &#038;&#038; handler.processError &#038;&#038; handler.processError(error)) {
                return;
            }
        }
    }
};

Evernote.ResponseReceiver.subscribe(Evernote.ErrorHandler);
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.Response = function(type, data) {
    this.data = data;
    this.type = type;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.FS = {
    _addon : null,

    init : function(addon) {
        this._addon = addon;
    },

    /**
     * Write content to the specified path.
     * @param path - file path.
     * @param content - content, that should be written to
     */
    writeToFile : function(path, content) {
        if (!this._addon)
            return;
        try {
            this._addon.WriteFileContent( path, content );
        } catch (e) {
            Evernote.Logger.error( "FS.WriteFileContent() failed " + e );
        }
    },

    /**
     * Read content of the file specified by path.
     * @param path - file path.
     * @return {string} - content of the file
     */
    getFileContent : function(path) {
        if (!this._addon)
            return null;
        try {
            return this._addon.ReadFileContent( path );
        } catch (e) {
            Evernote.Logger.error( "FS.ReadFileContent() failed " + e );
        }
        return null;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
//"use strict";

Evernote.AbstractElementSerializer = function AbstractElementSerializer( node, nodeStyle ) {
    this.initialize( node, nodeStyle );
};

Evernote.AbstractElementSerializer.isResponsibleFor = function( /*navigator*/ ) {
    return false;
};

Evernote.AbstractElementSerializer.prototype._node = null;
Evernote.AbstractElementSerializer.prototype._nodeStyle = null;

Evernote.AbstractElementSerializer.prototype.handleInheritance = function( child/*, parent */) {
    Evernote.ElementSerializerFactory.ClassRegistry.push( child );
};

Evernote.AbstractElementSerializer.prototype.initialize = function( node, nodeStyle ) {
    this._node = node;
    this._nodeStyle = nodeStyle;
};

Evernote.AbstractElementSerializer.prototype.serialize = function( /*docBase*/ ) {
    return "";
};

Evernote.AbstractElementSerializer.prototype.getImageUrl = function() {
    return "";
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
//"use strict";

Evernote.ElementSerializerFactory = {
    getImplementationFor : function( node ) {
        for ( var i = 0; i < this.ClassRegistry.length; ++i ) {
            if ( this.ClassRegistry[ i ].isResponsibleFor( node ) ) {
                return this.ClassRegistry[ i ];
            }
        }

        return null;
    }
};

Evernote.ElementSerializerFactory.ClassRegistry = [ ];
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
//"use strict";

Evernote.ClipStylingStrategy = function ClipStylingStrategy( ) {
    this.initialize( );
};

Evernote.ClipStylingStrategy.prototype.initialize = function( ) {

};

Evernote.ClipStylingStrategy.prototype.styleForNode = function(  /*node, root, fullPage, clipStyleType*/ ) {
    return null;
};

Evernote.ClipStylingStrategy.prototype.getNodeView = function ( node ) {
    var doc = node.ownerDocument;
    return (doc.defaultView) ? doc.defaultView : null;
};

Evernote.ClipStylingStrategy.prototype.getNodeStyle = function( node, filterFn, pseudo ) {
    Evernote.Logger.debug( "ClipStylingStrategy.getNodeStyle()" );

    var style = new Evernote.ClipStyle();
    if ( pseudo != "" ) {
        return style;
    }

    if ( node &#038;&#038; typeof node.nodeType == 'number' &#038;&#038; node.nodeType == 1 ) {
        var view = this.getNodeView( node );
        style = new Evernote.ClipStyle( Evernote.ElementExtension.getComputedStyle( node, null, view ), filterFn );
    }

    return style;
};

Evernote.ClipStyleType = {
    NodeStyle : 0x01,
    InheritedFontStyle: 0x02,
    InheritedBgStyle: 0x04,
    AllStyle : 0x01 | 0x02 | 0x04,
    Default : 0x01 | 0x02
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ClipFullStylingStrategy = function ClipFullStylingStrategy( ) {
    this.initialize( );
};

Evernote.inherit( Evernote.ClipFullStylingStrategy, Evernote.ClipStylingStrategy, true );

Evernote.ClipFullStylingStrategy.prototype.styleForNode = function ( node, root, fullPage, clipStyleType ) {
    Evernote.Logger.debug( "ClipStylingStrategy.styleForNode()" );

    if ( clipStyleType == null ) {
        clipStyleType = Evernote.ClipStyleType.Default;
    }

    var bodyStyles = new Evernote.ClipStyle( [ ], function ( prop, value ) {
        return value != ""
    } );
    var inhFontStyles = new Evernote.ClipStyle( [ ] );
    var inhBgStyles = [ ];

    if ( (clipStyleType &#038; Evernote.ClipStyleType.NodeStyle) == Evernote.ClipStyleType.NodeStyle ) {
        Evernote.Logger.debug( "ClipStylingStrategy.styleForNode(): get node style" );
        try {
            if ( node.nodeName.toLowerCase() == "body" ) {
                for ( var attrName in Evernote.ClipStyle.STYLE_ATTRIBUTES ) {
                    if ( Evernote.ElementExtension.hasAttribute(node, attrName) ) {
                        var cssPropName = Evernote.ClipStyle.STYLE_ATTRIBUTES[ attrName ];
                        var style = { };
                        style[ cssPropName ] = node.getAttribute( attrName );
                        bodyStyles.addStyle( style );
                    }
                }
            }
        } catch(e) {
            Evernote.Logger.error("ClipFullStylingStrategy.styleForNode failed to get attributes from body due to error " + e);
        }
        var evaluatedStyles = this.getNodeStyle( node );
        if ( node.nodeName.toLowerCase() == "table" &#038;&#038; !evaluatedStyles.getStyle( "font-size" ) ) {
            evaluatedStyles.addStyle( {"font-size":"1em"} );
        }

        if ( node.nodeName.toLowerCase() == "img" ) {
            style = new Evernote.ClipStyle( Evernote.ElementExtension.getComputedStyle( node, null, this.getNodeView( node ) ), function ( prop, value ) {
                return value != ""
            } );
            evaluatedStyles.addStyle( { height:style.getStyle( "height" ) } );
            evaluatedStyles.addStyle( { width:style.getStyle( "width" ) } );
        }

        if ( evaluatedStyles.getStyle( "background-image" ) ) {
            var regExp = /url\((.*?)\)/;
            evaluatedStyles.addStyle( { "background-image": Evernote.StyleElementExtension.getPropertyValue(Evernote.ElementExtension.getComputedStyle( node, null, this.getNodeView( node ) ),  Evernote.IEStylePropertiesMapping.getPropertyNameFor("background-image") ).replace( regExp, "url('$1')").replace(/('")|("')|('')/g, "'")} );
        }

        if ( evaluatedStyles.getStyle( "height" ) == "100%" &#038;&#038; Evernote.StyleElementExtension.getPropertyValue(Evernote.ElementExtension.getComputedStyle( node, null, this.getNodeView( node ) ), "height" ) == "0px" ) {
            evaluatedStyles.addStyle( { height:"0px" } );
        }
        bodyStyles.mergeStyle( evaluatedStyles, true );
    }

    if ( node == root &#038;&#038; !fullPage ) {
        if ( (clipStyleType &#038; Evernote.ClipStyleType.InheritedFontStyle) == Evernote.ClipStyleType.InheritedFontStyle ) {
            Evernote.Logger.debug( "ClipStylingStrategy.styleForNode(): get inherited font style" );
            inhFontStyles = this.inheritFontForNode( node, true );
            Evernote.Logger.debug( "ClipStylingStrategy.styleForNode(): inherited fonts " );
        }

        if ( (clipStyleType &#038; Evernote.ClipStyleType.InheritedBgStyle) == Evernote.ClipStyleType.InheritedBgStyle ) {
            Evernote.Logger.debug( "ClipStylingStrategy.styleForNode(): get inherited bg style" );
            inhBgStyles = this.inheritBackgroundForNode( node, true );
        }
    }

    bodyStyles.mergeStyle( inhFontStyles, true );
    return {
        nodeStyle:bodyStyles,
        inheritedFonts:inhFontStyles,
        inheritedBackground:inhBgStyles,
        evaluated:bodyStyles
    };
};

Evernote.ClipFullStylingStrategy.prototype.getNodeStyle = function ( node, filterFn, pseudo ) {
    Evernote.Logger.debug( "ClipStylingStrategy.getNodeStyle()" );

    if ( pseudo == null || typeof pseudo == "undefined" ) {
        pseudo = "";
    }
    var style = new Evernote.ClipStyle([ ], filterFn);
    Evernote.Logger.debug( "Pseudo : " + pseudo );
    if ( pseudo == "" &#038;&#038; node &#038;&#038; typeof node.nodeType == 'number' &#038;&#038; node.nodeType == 1 ) {
        var view = this.getNodeView( node );
        style = new Evernote.ClipStyle( Evernote.ElementExtension.getComputedStyle( node, null, view ), filterFn );
    }
    return style;
};

Evernote.ClipFullStylingStrategy.prototype.inheritFontForNode = function ( node, recur ) {
    Evernote.Logger.debug( "ClipFullStylingStrategy.inheritFontForNode()" );

    var fontStyle = new Evernote.ClipStyle();
    if ( !node ) {
        return fontStyle;
    }

    var parent = node;
    var styles = [ ];
    var nodes = [ ];

    var dynamicUnit = ["%", "em"];
    var sizeUnitRegExp = /(.*?)(em|%|px|pt)/;

    while ( parent ) {
        nodes.push( parent );
        styles.push( new Evernote.ClipStyle( this.getNodeStyle( parent ), function ( prop, value ) {
            return (Evernote.ArrayExtension.indexOf(Evernote.ClipStyle.INHERITED_STYLES,  prop ) > 0 &#038;&#038; value != "inherit" );
        } ) );


        Evernote.Logger.debug( "Inh parent style:" + styles[styles.length - 1].toString() );

        if ( !recur || parent == document.body ) {
            break;
        }
        else {
            parent = parent.parentElement;
        }
    }

    //merge styles starting from low-priority parent styles
    Evernote.Logger.debug( "Styles inh for processing:" + (styles.length - 1) );
    for ( var i = styles.length - 1; i >= 0; i-- ) {
        var style = styles[ i ];
        var fontSize = fontStyle.getStyle( "font-size" );
        var overFontStyle = style.getStyle( "font-size" );
        Evernote.Logger.debug( "fontSize:" + fontSize + "    ;overFontStyle: " + overFontStyle );
        if ( fontSize &#038;&#038; overFontStyle ) {
            var resFontSize = fontSize.match( sizeUnitRegExp );
            if ( resFontSize == null ) {
                continue;
            }
            var sizeVal = resFontSize[1];
            var sizeUnit = resFontSize[2];
            var resOverFontSize = overFontStyle.match( sizeUnitRegExp );

            if ( resOverFontSize == null ) {
                continue;
            }
            var overSizeVal = resOverFontSize[1];
            var overSizeUnit = resOverFontSize[2];

            if ( Evernote.ArrayExtension.indexOf(dynamicUnit, overSizeUnit ) != -1 ) {
                if ( overSizeUnit == "%" ) {
                    style.addStyle( { "font-size":(parseFloat( sizeVal ) * parseFloat( overSizeVal ) / 100).toString() + sizeUnit } );
                }
                else {
                    style.addStyle( { "font-size":(parseFloat( sizeVal ) * parseFloat( overSizeVal )).toString() + ((sizeUnit != "em") ? sizeUnit : overSizeUnit) } );
                }
            }
            Evernote.Logger.debug( "Style: " + i + "   ;Eval inh style:" + style.toString() );
        }

        fontStyle.mergeStyle( style, true );
    }

    return fontStyle;
};

Evernote.ClipFullStylingStrategy.prototype.inheritBackgroundForNode = function ( node, recur ) {
    Evernote.Logger.debug( "ClipFullStylingStrategy.inheritBackgroundForNode()" );

    var bgStyle = new Evernote.ClipStyle();
    if ( !node ) {
        return bgStyle;
    }

    var parent = node;
    var styles = [ ];
    var nodes = [ ];
    var topElement = (document.body.parentNode) ? document.body.parentNode : document.body;
    try {
        while ( parent ) {
            nodes.push( parent );
            var filterFn = function ( prop, value ) {
                return !(prop == "background-repeat" &#038;&#038; (value == "no-repeat" || value == "repeat-y"));
            };
            var nodeStyle = new Evernote.ClipStyle( this.getNodeStyle( parent ), filterFn, Evernote.ClipStyle.CSS_GROUP.getExtForStyle( "background" ) );

            if ( !nodeStyle.getStyle( "background-repeat" ) ) {
                nodeStyle.removeStyle( "background-image" );
            }
            if ( !nodeStyle.getStyle( "background-color" ) &#038;&#038; parent.getAttribute( "bgcolor" ) ) {
                Evernote.Logger.debug( "Set bgcolor attribute: " + parent.getAttribute( "bgcolor" ) );
                nodeStyle.addStyle( {"background-color":parent.getAttribute( "bgcolor" )} );
            }

            nodeStyle = this.evalBgPosition( node, parent, nodeStyle );
            if ( nodeStyle.getStylesNames().length > 0 ) {
                styles.push( nodeStyle );
                Evernote.Logger.debug( "Add inh bg style " + nodeStyle.toString() );
            }

            if ( !recur || parent == topElement ) {
                break;
            }
            else {
                parent = parent.parentNode;
            }
        }
    } catch(e) {
        Evernote.Logger.error("ClipFullStylingStrategy.prototype.inheritBackgroundForNode failed to error " + e);
    }

    return styles;
};

Evernote.ClipFullStylingStrategy.prototype.evalBgPosition = function ( node, inhNode, nodeBgStyle ) {
    Evernote.Logger.debug( "Dettermining background image offset" );

    var strPosToPercent = {
        "center":"50%",
        "top":"0%",
        "bottom":"100%",
        "right":"100%",
        "left":"0%"
    };

    var regExp = /url\((.*?)\)/;
    var bgImage = nodeBgStyle.getStyle( "background-image" );
    if ( !regExp.test( nodeBgStyle.getStyle( "background-image" ) ) || (bgImage &#038;&#038; nodeBgStyle.getStyle( "background-image" ).indexOf( "data:image" ) >= 0) ) {
        Evernote.Logger.debug( "bgStyle: " + nodeBgStyle.toString() );
        return nodeBgStyle;
    }

    nodeBgStyle.addStyle( { "background-image": Evernote.StyleElementExtension.getPropertyValue(Evernote.ElementExtension.getComputedStyle( inhNode, null, this.getNodeView( inhNode ) ), Evernote.IEStylePropertiesMapping.getPropertyNameFor("background-image") ).replace( regExp, "url('$1')" ) } );

    var actualImage = new Image();
    actualImage.src = nodeBgStyle.getStyle( "background-image" ).match( regExp )[ 1 ].replace( /["']/g, "" );
    var bgNodeRect = this.getOffsetRect( inhNode );
    var nodeRect = this.getOffsetRect( node );
    var yDelta = nodeRect.top - bgNodeRect.top;
    var xDelta = nodeRect.left - bgNodeRect.left;

    var bgNodeBgPosX = 0;
    var bgNodeBgPosY = 0;
    var origPosX = 0;
    var origPosY = 0;

    if ( nodeBgStyle.getStyle( "background-position" ) ) {
        var bgPosition = nodeBgStyle.getStyle( "background-position" ).split( " " );
        bgNodeBgPosX = strPosToPercent[bgPosition[ 0 ]] != null ? strPosToPercent[bgPosition[ 0 ]] : bgPosition[ 0 ];
        bgNodeBgPosY = strPosToPercent[bgPosition[ 1 ]] != null ? strPosToPercent[bgPosition[ 1 ]] : bgPosition[ 1 ];

        if ( bgNodeBgPosX &#038;&#038; bgNodeBgPosX.indexOf( "%" ) > 0 ) {
            origPosX = parseInt( bgNodeRect.width ) * (parseInt( bgNodeBgPosX ) / 100);
            origPosX -= parseInt(actualImage.width) * (parseInt(bgNodeBgPosX) / 100);
        }
        else {
            origPosX = parseInt( bgNodeBgPosX );
        }

        if ( bgNodeBgPosY &#038;&#038; bgNodeBgPosY.indexOf( "%" ) > 0 ) {
            origPosY = parseInt( bgNodeRect.height ) * (parseInt( bgNodeBgPosY ) / 100);
            origPosY -= parseInt(actualImage.height) * (parseInt(bgNodeBgPosY) / 100);
        }
        else {
            origPosY = parseInt( bgNodeBgPosY );
        }
    }

    if ( isNaN( origPosX ) ) {
        origPosX = 0;
    }
    if ( isNaN( origPosY ) ) {
        origPosY = 0;
    }

    var xOffset = 0 - xDelta + origPosX;
    var yOffset = 0 - yDelta + origPosY;

    nodeBgStyle.addStyle( { "background-position":(xOffset + "px " + yOffset + "px") } );
    Evernote.Logger.debug( "bgStyle: " + nodeBgStyle.toString() );
    return nodeBgStyle;
};

Evernote.ClipFullStylingStrategy.prototype.getOffsetRect = function ( elem ) {
    Evernote.Logger.debug( "ClipCSSStyleWalker.getOffsetRect()" );

    var box = Evernote.ElementExtension.getBoundingClientRect(elem);
    var body = elem.ownerDocument.body;
    var docElem = elem.ownerDocument.documentElement;

    var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
    var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;

    var clientTop = docElem.clientTop || body.clientTop || 0;
    var clientLeft = docElem.clientLeft || body.clientLeft || 0;

    var top = box.top + scrollTop - clientTop;
    var left = box.left + scrollLeft - clientLeft;

    return { top:Math.round( top ), left:Math.round( left ), width:box.width, height:box.height };
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
//"use strict";

Evernote.ClipRules = {
    isNoKeepNodeAttr : function( attribute, nodeName, node ) {
        if ( !attribute ) {
            return true;
        }

        var attrName = attribute.name.toLowerCase();
        var attrValue = attribute.value.toLowerCase();
        if((node.nodeName.toUpperCase() == "SPAN" || node.nodeName.toUpperCase() == "A") &#038;&#038; node.getElementsByTagName( "IMG" ).length > 0) {
            nodeName = "div";
        }
        var attributesToKeepForNode = this.KEEP_NODE_ATTRIBUTES[nodeName];
        if(attributesToKeepForNode) {
            var keepAttributeForNode = typeof attributesToKeepForNode[attrName] != 'undefined';
        }
        return typeof this.NOKEEP_NODE_ATTRIBUTES[ attrName ] != 'undefined'
            || !keepAttributeForNode
            || attrName.substring( 0, 2 ) == "on"
            || attrName.indexOf("xml") == 0
            || attrValue.indexOf("function(") >= 0
            || (attrName == "href" &#038;&#038; attrValue.substring( 0, 11 ) == "javascript:");
    },

    isConditionalNode : function( node ) {
        return node &#038;&#038; typeof this.CONDITIONAL_NODES[ node.nodeName.toUpperCase() ] != 'undefined';
    },

    translateNode : function( node ) {
        var nodeName = this.NODE_NAME_TRANSLATIONS[ node.nodeName.toUpperCase() ] || node.nodeName.toUpperCase();
        return (typeof this.SUPPORTED_NODES[ nodeName ] != "undefined") ? nodeName.toLowerCase() : this.NODE_NAME_TRANSLATIONS[ "*" ].toLowerCase();
    },

    isSupportedNode : function( node ) {
        return node &#038;&#038; typeof this.SUPPORTED_NODES[ node.nodeName.toUpperCase() ] != 'undefined';
    },

    isRejectedNode : function( node ) {
        return node &#038;&#038; typeof this.REJECTED_NODES[ node.nodeName.toUpperCase() ] != 'undefined';
    },

    isNonAncestorNode : function( node ) {
        return node &#038;&#038; typeof this.NON_ANCESTOR_NODES[ node.nodeName.toUpperCase() ] != 'undefined';
    },

    isSelfClosingNode : function( node ) {
        return node &#038;&#038; typeof this.SELF_CLOSING_NODES[ node.nodeName.toUpperCase() ] != 'undefined';
    }
};

Evernote.ClipRules.KEEP_NODE_ATTRIBUTES = {
    "a" : {
        "title": null,
        "dir" : null,
        "accesskey": null,
        "charset": null,
        "type": null,
        "name": null,
        "href": null,
        "hreflang": null,
        "rel": null,
        "rev": null,
        "shape": null,
        "coords": null,
        "target": null
    },

    "abbr" : {
        "title": null,
        "dir" : null
    },

    "acronym" : {
        "title": null,
        "dir" : null
    },

    "address" : {
        "title": null,
        "dir" : null
    },

    "area" : {
        "title": null,
        "dir" : null,
        "accesskey": null,
        "shape": null,
        "coords": null,
        "href": null,
        "nohref": null,
        "alt": null,
        "target": null
    },

    "b" : {
        "title": null,
        "dir" : null
    },

    "bdo" : {
        "title": null,
        "dir" : null
    },

    "big" : {
        "title": null,
        "dir" : null
    },

    "blockquote" : {
        "title": null,
        "dir" : null,
        "cite": null
    },

    "br" : {
        "title": null,
        "clear": null
    },

    "caption" : {
        "title": null,
        "dir" : null,
        "align": null
    },

    "center" : {
        "title": null,
        "dir" : null
    },

    "cite" : {
        "title": null,
        "dir" : null
    },

    "code" : {
        "title": null,
        "dir" : null
    },

    "col" : {
        "title": null,
        "dir" : null,
        "span" : null,
        "width" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null
    },

    "colgroup" : {
        "title": null,
        "dir" : null,
        "span" : null,
        "width" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null
    },

    "dd" : {
        "title": null,
        "dir" : null
    },

    "del" : {
        "title": null,
        "dir" : null,
        "cite" : null,
        "datetime" : null
    },

    "dfn" : {
        "title": null,
        "dir" : null
    },

    "div" : {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "dl": {
        "title": null,
        "dir" : null,
        "compact" : null
    },

    "dt": {
        "title": null,
        "dir" : null
    },

    "em": {
        "title": null,
        "dir" : null
    },

    "font": {
        "title": null,
        "dir" : null,
        "size" : null,
        "color" : null,
        "face" : null
    },

    "h1": {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "h2": {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "h3": {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "h4": {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "h5": {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "h6": {
        "title": null,
        "dir" : null,
        "align" : null
    },

    "hr": {
        "title": null,
        "dir" : null,
        "align" : null,
        "noshade" : null,
        "size" : null,
        "width" : null
    },

    "i": {
        "title": null,
        "dir" : null
    },

    "img": {
        "title": null,
        "dir" : null,
        "src" : null,
        "alt" : null,
        "name" : null,
        "longdesc" : null,
        "height" : null,
        "width" : null,
        "usemap" : null,
        "ismap" : null,
        "align" : null,
        "border" : null,
        "hspace" : null,
        "vspace" : null
    },

    "en-media": {
        "type" : null,
        "hash" : null,
        "title" : null,
        "dir" : null,
        "alt" : null,
        "longdesc" : null,
        "height" : null,
        "width" : null,
        "usemap" : null,
        "align" : null,
        "border" : null,
        "hspace" : null,
        "vspace" : null
    },

    "ins": {
        "title": null,
        "dir" : null,
        "cite" : null,
        "datetime" : null
    },

    "kbd": {
        "title": null,
        "dir" : null
    },

    "li": {
        "title": null,
        "dir" : null,
        "type" : null,
        "value" : null
    },

    "map": {
        "dir" : null,
        "title" : null,
        "name" : null
    },

    "ol": {
        "title" : null,
        "dir" : null,
        "type" : null,
        "compact" : null,
        "start" : null
    },

    "p": {
        "title" : null,
        "dir" : null,
        "align" : null
    },

    "pre": {
        "title" : null,
        "dir" : null,
        "width" : null
    },

    "s": {
        "title" : null,
        "dir" : null
    },


    "samp": {
        "title" : null,
        "dir" : null
    },

    "small": {
        "title" : null,
        "dir" : null
    },

    "span": {
        "title" : null,
        "dir" : null
    },

    "strike": {
        "title" : null,
        "dir" : null
    },

    "strong": {
        "title" : null,
        "dir" : null
    },

    "sub": {
        "title" : null,
        "dir" : null
    },

    "sup": {
        "title" : null,
        "dir" : null
    },

    "table": {
        "title" : null,
        "dir" : null,
        "summary" : null,
        "width" : null,
        "border" : null,
        "cellspacing" : null,
        "cellpadding" : null,
        "align" : null,
        "bgcolor" : null
    },

    "tbody": {
        "title" : null,
        "dir" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null
    },

    "td": {
        "title" : null,
        "dir" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null,
        "abbr" : null,
        "rowspan" : null,
        "colspan" : null,
        "nowrap" : null,
        "bgcolor" : null,
        "width" : null,
        "height" : null
    },

    "tfoot": {
        "title" : null,
        "dir" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null
    },

    "th": {
        "title" : null,
        "dir" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null,
        "abbr" : null,
        "rowspan" : null,
        "colspan" : null,
        "nowrap" : null,
        "bgcolor" : null,
        "width" : null,
        "height" : null
    },

    "thead": {
        "title" : null,
        "dir" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null
    },

    "tr": {
        "title" : null,
        "dir" : null,
        "align" : null,
        "char" : null,
        "charoff" : null,
        "valign" : null,
        "bgcolor" : null
    },

    "tt": {
        "title" : null,
        "dir" : null
    },

    "u": {
        "title" : null,
        "dir" : null
    },

    "ul": {
        "title" : null,
        "dir" : null,
        "type" : null,
        "compact" : null
    },

    "var": {
        "title" : null,
        "dir" : null
    }
};

Evernote.ClipRules.NOKEEP_NODE_ATTRIBUTES = {
    "style" : null,
    "tabindex" : null
};

Evernote.ClipRules.CONDITIONAL_NODES = {
    "EMBED" : null,
    "OBJECT" : null,
    "IMG" : null,
    "VIDEO" : null
};

Evernote.ClipRules.NODE_NAME_TRANSLATIONS = {
    "HTML" : "DIV",
    "BODY" : "DIV",
    "FORM" : "DIV",
    "CANVAS" : "DIV",
    "CUFON" : "DIV",
    "EMBED" : "IMG",
    "BUTTON" : "SPAN",
    "INPUT" : "SPAN",
    "LABEL" : "SPAN",
    "BDI" : "SPAN",
    "IMG" : "EN-MEDIA",
    "*" : "DIV"
};

Evernote.ClipRules.SUPPORTED_NODES = {
    "A" : null,
    "ABBR" : null,
    "ACRONYM" : null,
    "ADDRESS" : null,
    "AREA" : null,
    "B" : null,
    "BUTTON" : null,
    "BDO" : null,
    "BIG" : null,
    "BLOCKQUOTE" : null,
    "BR" : null,
    "CAPTION" : null,
    "CENTER" : null,
    "CITE" : null,
    "CODE" : null,
    "COL" : null,
    "COLGROUP" : null,
    "DD" : null,
    "DEL" : null,
    "DFN" : null,
    "DIV" : null,
    "DL" : null,
    "DT" : null,
    "EM" : null,
    "FONT" : null,
    "FORM" : null,
    "H1" : null,
    "H2" : null,
    "H3" : null,
    "H4" : null,
    "H5" : null,
    "H6" : null,
    "HR" : null,
    "HTML" : null,
    "I" : null,
    "IMG" : null,
    "EN-MEDIA" : null,
    "INPUT" : null,
    "INS" : null,
    "KBD" : null,
    "LI" : null,
    "MAP" : null,
    "OL" : null,
    "P" : null,
    "PRE" : null,
    "Q" : null,
    "S" : null,
    "SAMP" : null,
    "SMALL" : null,
    "SPAN" : null,
    "STRIKE" : null,
    "STRONG" : null,
    "SUB" : null,
    "SUP" : null,
    "TABLE" : null,
    "TBODY" : null,
    "TD" : null,
    "TFOOT" : null,
    "TH" : null,
    "THEAD" : null,
    "TR" : null,
    "TT" : null,
    "U" : null,
    "UL" : null,
    "VAR" : null
};

Evernote.ClipRules.REJECTED_NODES = {
    "SCRIPT" : null,
    "LINK" : null,
    "IFRAME" : null,
    "STYLE" : null,
    "SELECT" : null,
    "OPTION" : null,
    "OPTGROUP" : null,
    "NOSCRIPT" : null,
    "PARAM" : null,
    "HEAD" : null,
    "EVERNOTEDIV" : null,
    "CUFONTEXT" : null,
    "NOEMBED" : null
};

Evernote.ClipRules.NON_ANCESTOR_NODES = {
    "OL" : null,
    "UL" : null,
    "LI" : null
};

Evernote.ClipRules.SELF_CLOSING_NODES = {
    "IMG" : null,
    //"INPUT" : null,
    "BR" : null
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * ClipStyle is a container for CSS styles. It is able to add and remove
 * CSSStyleRules (and parse CSSRuleList's for rules), as well as
 * CSSStyleDeclaration's and instances of itself.
 * ClipStyle provides a mechanism to serialize itself via toString(), and
 * reports its length via length property. It also provides a method to clone
 * itself and expects to be manipulated via addStyle and removeStyle.
 */
Evernote.ClipStyle = function ClipStyle( css, filterFn, styleList ) {
    this.initialize( css, filterFn, styleList );
};

Evernote.ClipStyle.STYLES = [
    "background", "background-attachment", "background-clip", "background-color", "background-image", "background-origin", "background-position-x", "background-position-y", "background-position", "background-repeat", "background-size",
    "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width",
    "border-left", "border-left-color", "border-left-style", "border-left-width",
    "border-right", "border-right-color", "border-right-style", "border-right-width",
    "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width",
    "border-collapse", "border-spacing", "bottom", "box-shadow",
    "caption-side", "clear", "clip", "color", "content", "counter-increment", "counter-reset", "cursor",
    "direction", "display",
    "empty-cells",
    "float", "font", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight",
    "height",
    "ime-mode",
    "left", "letter-spacing", "line-height", "list-style", "list-style-image", "list-style-position", "list-style-type",
    "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "marker-offset", "max-height", "max-width", "min-height", "min-width",
    "opacity", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-x", "overflow-y",
    "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", "page-break-after", "page-break-before", "pointer-events", "position",
    "resize", "right",
    "table-layout", "text-align", "text-anchor", "text-decoration", "text-indent", "text-overflow", "text-shadow", "text-transform", "top",
    "vertical-align", "visibility",
    "white-space", "width", "word-spacing", "word-wrap",
    "z-index"
];

Evernote.ClipStyle.NO_INHERIT_STYLES = {
    "*":[ "background", "background-image", "background-color", "background-position", "background-repeat",
        "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width",
        "border-left", "border-left-color", "border-left-style", "border-left-width",
        "border-right", "border-right-color", "border-right-style", "border-right-width",
        "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width",
        "border-collapse", "border-spacing", "bottom",
        "clear",
        "display",
        "float",
        "height",
        "left", "list-style",
        "margin", "margin-bottom", "margin-left", "margin-right", "margin-top",
        "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
        "right",
        "text-decoration", "top",
        "width" ],
    "img":[ "height", "width" ]
};

Evernote.ClipStyle.CSS_GROUP = {
    "margin":[ "left", "right", "top", "bottom" ],
    "padding":[ "left", "right", "top", "bottom" ],
    "border":[ "width", "style", "color" ],
    "border-bottom":[ "width", "style", "color" ],
    "border-top":[ "width", "style", "color" ],
    "border-right":[ "width", "style", "color" ],
    "border-left":[ "width", "style", "color" ],
    "border-image":[ "outset", "repeat", "slice", "source", "width" ],
    "background":[ "attachment", "color", "image", "position", "repeat", "clip", "origin", "size" ],
    "font":[ "family", "size", "style", "variant", "weight", "size-adjust", "stretch", "+line-height" ],
    "list-style":[ "image", "position", "type" ]
};

Evernote.ClipStyle.CSS_GROUP.getExtForStyle = function ( name ) {
    var list = this[ name ];
    var extList = [ ];

    if ( list ) {
        for ( var i = 0; i < list.length; ++i ) {
            if ( list[ i ].indexOf( "+" ) >= 0 ) {
                var tmp = list[ i ];
                extList.push( tmp.replace( "+", "" ) );
            }
            else {
                extList.push( name + "-" + list[ i ] );
            }
        }
        return extList;
    }

    return null;
};

Evernote.ClipStyle.STYLE_ATTRIBUTES = {
    "bgcolor":"background-color",
    "text":"color"
};

Evernote.ClipStyle.INHERITED_STYLES = [
    "azimuth",
    "border-collapse", "border-spacing",
    "caption-side", "color", "cursor",
    "direction",
    "elevation", "empty-cells",
    "font-family", "font-size", "font-style", "font-weight", "font",
    "letter-spacing", "line-height", "list-style-image", "list-style-position", "list-style-type", "list-style",
    "orphans",
    "pitch-range", "pitch",
    "quotes",
    "richness",
    "speak-header", "speak-numeral", "speak-punctuation", "speak", "speak-rate", "stress",
    "text-align", "text-indent", "text-transform",
    "visibility", "voice-family", "volume",
    "white-space", "widows", "word-spacing"
];

Evernote.ClipStyle.prototype._collection = null;
Evernote.ClipStyle.prototype._filterFn = null;
Evernote.ClipStyle.prototype._styleList = null;

Evernote.ClipStyle.prototype.initialize = function ( css, filterFn, styleList ) {
    Evernote.Logger.debug( "ClipStyle.initialize()" );

    this._collection = new Evernote.StylesCollection();
    Evernote.Logger.debug( "ClipStyle.initialize: collection initialized()" );
    this._filterFn = (typeof filterFn == "function") ? filterFn : null;
    this._styleList = (styleList != null) ? styleList : Evernote.ClipStyle.STYLES;
    if(css) {
        if ( window.CSSStyleDeclaration &#038;&#038; css instanceof window.CSSStyleDeclaration ) {
            this.addStyle( css, this._styleList );
        }
        else if ( window.CSSStyleRule &#038;&#038; css instanceof window.CSSStyleRule ) {
            this.addStyle( css.style, this._styleList );
        }
        else if ( (window.CSSRuleList &#038;&#038; css instanceof window.CSSRuleList) || css instanceof Array ) {
            for ( var i = 0; i < css.length; ++i ) {
                this.addStyle( css[ i ].style, this._styleList );
            }
        }
        else if ( typeof css == 'object' &#038;&#038; css != null ) {
            this.addStyle( css, this._styleList );
        }
    }
    Evernote.Logger.debug( "ClipStyle.initialize() end ");
};

Evernote.ClipStyle.prototype.fixBackground = function ( prop, value ) {
    if(prop &#038;&#038; value) {
        if(prop.indexOf("background-image") != -1 &#038;&#038; value.indexOf("url") != -1) {
            Evernote.Logger.debug("Start replace");
            var regExp = /url\((.*?)\)/;
            var res = value.replace(regExp, "url('$1')").replace(/('")|("')|('')/g, "'");
            Evernote.Logger.debug("End replace");
            return Evernote.GlobalUtils.escapeXML(res);

        }
    }
    return value;
};

Evernote.ClipStyle.prototype.addStyle = function ( style, styleList ) {
    Evernote.Logger.debug( "ClipStyle.addStyle()" );
    if ( window.CSSStyleDeclaration &#038;&#038; style instanceof window.CSSStyleDeclaration &#038;&#038; style.length > 0 ) {
        var list = (styleList != null) ? styleList : this._styleList;
        for ( var i = 0; i < list.length; ++i ) {
            var prop = list[ i ];
            var value = Evernote.StyleElementExtension.getPropertyValue(style, prop );
            var importantPriority = !!((style.getPropertyPriority(prop) == 'important'));
            value = this.fixBackground(prop, value);
            this.addSimpleStyle( prop, value, importantPriority );
        }
    }
    else if ( style instanceof Evernote.ClipStyle ) {
        list = (styleList != null) ? styleList : style.getStylesNames();
        for ( var i = 0; i < list.length; ++i ) {
            var prop = list[ i ];
            value = style.getStyle( prop );
            importantPriority = style.isImportant( prop );
            value = this.fixBackground(prop, value);
            this.addSimpleStyle( prop, value, importantPriority );
        }
    }
    else if ( typeof style == 'object' &#038;&#038; style != null ) {
        list = (styleList != null) ? styleList : style;
        for ( var prop in list ) {
            // In some cases, attempt to get currentStyle.outline ( or outlineWidth ) property in IE8 throws
            // 'unspecified error' and crash whole serilization process. So we wrap it into try {...} catch.

            try {
                if ( list.hasOwnProperty( prop ) ) {
                    var usedStyle = style[ prop ];
                    var pName = prop;
                    if(!usedStyle) {
                        usedStyle = style [list[prop]];
                        pName = list[prop];
                        if(!usedStyle) {
                            var propName = Evernote.IEStylePropertiesMapping.getPropertyNameFor(list[prop]);
                            if(propName) {
                                usedStyle = style[propName[1]];
                            }
                        }
                    }
                    usedStyle = this.fixBackground(pName, usedStyle);
                    this.addSimpleStyle( pName, usedStyle );
                }
            }  catch (err) {}
        }
    }
};

Evernote.ClipStyle.prototype.removeStyle = function ( style ) {
    Evernote.Logger.debug( "ClipStyle.removeStyle()" );
    if(style) {
        if ( window.CSSStyleDeclaration &#038;&#038; Evernote.Utils.isInstanceOf(style, window.CSSStyleDeclaration) || style instanceof Array ) {
            for ( var i = 0; i < style.length; ++i ) {
                this.removeSimpleStyle( style[ i ] );
            }
        }
        else if ( style instanceof Evernote.ClipStyle ) {
            var stylesNames = style.getStylesNames();
            for ( i = 0; i < stylesNames.length; ++i ) {
                this.removeSimpleStyle( stylesNames[ i ] );
            }
        }
        else if ( typeof style == 'string' ) {
            this.removeSimpleStyle( style );
        }
    }
    Evernote.Logger.debug("ClipStyle.removeStyle() end")
};

Evernote.ClipStyle.prototype.mergeStyle = function ( style, override ) {
    Evernote.Logger.debug( "ClipStyle.mergeStyle()" );

    if ( style instanceof Evernote.ClipStyle ) {
        var stylesNames = style.getStylesNames();
        for ( var i = 0; i < stylesNames.length; ++i ) {
            var styleName = stylesNames[ i ];
            var styleValue = this._collection.getStyle( styleName );
            if ( styleValue == null || override || (style.isImportant( styleName ) &#038;&#038; !this._collection.isImportant( styleName )) ) {
                var newValue = style.getStyle( styleName );
                if ( style.isImportant( styleName ) ) {
                    this._collection.addStyle( styleName, newValue, true );
                }
                else if ( override &#038;&#038; !this._collection.isImportant( styleName ) ) {
                    this._collection.addStyle( styleName, newValue, false );
                }
                else if ( styleValue == null &#038;&#038; !override ) {
                    this._collection.addStyle( styleName, newValue, style.isImportant( styleName ) );
                }
            }
        }
    }
};

Evernote.ClipStyle.prototype.getStylesNames = function () {
    return this._collection.getStylesNames();
};

Evernote.ClipStyle.prototype.getStyle = function ( prop ) {
    return this._collection.getStyle( prop );
};

Evernote.ClipStyle.prototype.isImportant = function ( prop ) {
    return this._collection.isImportant( prop );
};

Evernote.ClipStyle.prototype.addSimpleStyle = function ( prop, value, importantPriority ) {
    if ( typeof this._filterFn == "function" &#038;&#038; !this._filterFn( prop, value ) ) {
        return;
    }
    var impl = Evernote.StylesReplacementRegistry.getImplementationFor(prop);
    if(impl &#038;&#038; impl.getValue) {
        value = impl.getValue(value);
    }
    this._collection.addStyle( prop, value, importantPriority );
};

Evernote.ClipStyle.prototype.removeSimpleStyle = function ( prop ) {
    this._collection.removeStyle( prop );
};

Evernote.ClipStyle.prototype.toString = function () {
    var str = "";
    var stylesNames = this.getStylesNames();
    for ( var i = 0; i < stylesNames.length; ++i ) {
        var styleName = stylesNames[ i ];
        var value = this._collection.getStyle( styleName );
        if ( value != null &#038;&#038; value.length > 0 ) {
            str += styleName + ":" + value + ";";
        }
    }

    return str;
};

Evernote.ClipStyle.CSSDefaultStyle = {
    "background-attachment": "scroll",
    "background-color" : "transparent",
    "background-image" : "none",
    "background-position-x" : "0px",
    "background-position-y" : "0px",
    "background-repeat" : "repeat",
    "border-bottom-style" : "none",
    "border-bottom-width" : "medium",
    "border-left-style" : "none",
    "border-left-width" : "medium",
    "border-right-style" : "none",
    "border-right-width" : "medium",
    "border-top-style" : "none",
    "border-top-width" : "medium",
    "border-collapse" : "separate",
    "bottom" : "auto",
    "clear" : "none",
    "height" : "auto",
    "left" : "auto",
    "margin-bottom" : "0px",
    "margin-left" : "0px",
    "margin-right" : "0px",
    "margin-top" : "0px",
    "max-height" : "none",
    "max-width" : "none",
    "min-height" : "0px",
    "min-width" : "0px",
    "overflow" : "visible",
    "overflow-x" : "visible",
    "overflow-y" : "visible",
    "padding" : "0px",
    "padding-bottom" : "0px",
    "padding-left" : "0px",
    "padding-right" : "0px",
    "padding-top" : "0px",
    "page-break-before" : "auto",
    "page-break-after" : "auto",
    "position" : "static",
    "right" : "auto",
    "text-align" : "left",
    "text-decoration" : "none",
    "text-indent" : "0px",
    "text-overflow" : "clip",
    "top" : "auto",
    "width" : "auto"
};

Evernote.ClipStyle.prototype.removeDefaultCssStyle = function () {
    var stylesNames = this.getStylesNames();
    for ( var i = 0; i < stylesNames.length; ++i ) {
        var styleName = stylesNames[ i ];
        var defaultCssValue = Evernote.ClipStyle.CSSDefaultStyle[styleName];
        var value = this.getStyle( styleName );
        if (!value)
            continue;
        if (defaultCssValue == value) {
            this.removeStyle(styleName);
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ClipStyleProperty = function ClipStyleProperty( name, value, isImportant ) {
    this.initialize( name, value, isImportant );
};

Evernote.ClipStyleProperty.prototype.initialize = function( name, value, isImportant ) {
    if ( typeof name == "string" &#038;&#038; typeof value == "string" ) {
        this._name = name;
        this._value = value;
    }

    this._isImportant = (isImportant) ? true : false;
};

Evernote.ClipStyleProperty.prototype._name = null;
Evernote.ClipStyleProperty.prototype._value = null;
Evernote.ClipStyleProperty.prototype._isImportant = null;

Evernote.ClipStyleProperty.prototype.name = function() {
    return this._name;
};

Evernote.ClipStyleProperty.prototype.value = function() {
    return this._value;
};

Evernote.ClipStyleProperty.prototype.isImportant = function() {
    return this._isImportant;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * Represents DOM parser that could able to traverse the DOM node tree from specified root.
 * @param tab - current window object
 * @param range - current selection on the page (if any)
 * @constructor
 */
Evernote.DomParser = function DomParser( tab, range ) {
    this.initialize( tab, range );
};

Evernote.DomParser.prototype._tab = null;

/**
 * Update current parser data
 * @param tab - current window object
 * @param range - current selection on the page (if any)
 */
Evernote.DomParser.prototype.initialize = function ( tab, range ) {
    Evernote.Logger.debug( "DomSerializer.initialize()" );

    this._tab = tab;
    this._range = range;
};

/**
 * Determines if passed node should be serialized.
 * Node should not be initialized if one of the following is true:
 *  - node is rejected according to configuration
 *  - there is the selection on the page and this node is out of selection range.
 * @param node - DOM node
 * @return {Boolean}
 */
Evernote.DomParser.prototype.isNodeForSerialize = function ( node ) {
    if ( !node || Evernote.ClipRules.isRejectedNode( node ) || node.id == "evernoteContentClipperWait" ) {
        return false;
    }
    if(Evernote.ClipperElementsIdentifiers.match(node)) {
        Evernote.Logger.debug("Node is rejected because it is clipper information " + node.id);
        return false;
    }
    return (!this._range || this.isNodeInRange( node )) ? true : false;
};

/**
 * Determines whether passed node is inside the selection range. Returns true if it is, false otherwise.
 * @param node - DOM node
 * @return {Boolean}
 */
Evernote.DomParser.prototype.isNodeInRange = function ( node ) {
    Evernote.Logger.debug( "DomParser.isNodeInRange()" );
    try {
        if ( node &#038;&#038; this._range ) {
            var nodeRange = node.ownerDocument.createRange();
            try {
                nodeRange.selectNode( node );
            }
            catch ( e ) {
                nodeRange.selectNodeContents( node );
            }

            return this._range.compareBoundaryPoints( Range.START_TO_END, nodeRange ) == 1
                &#038;&#038; this._range.compareBoundaryPoints( Range.END_TO_START, nodeRange ) == -1;
        }
    } catch(e) {
        //We're in quirk mode, allow to clip node
        return true;
    }
    //If we failed to find any
    return false;
};

/**
 * Determines whether passed node is visible on the page.
 * @param node - DOM node.
 * @return {Boolean}
 */
Evernote.DomParser.prototype.isNodeVisible = function ( node ) {
    Evernote.Logger.debug( "DomParser.isNodeVisible()" );

    if ( !node ) {
        return false;
    }

    var compStyles = Evernote.ElementExtension.getComputedStyle( node, null, this._tab );
    return Evernote.StyleElementExtension.getPropertyValue(compStyles, "display" ) != "none";
};

Evernote.DomParser.prototype.parseAsync = function ( root, fullPage, serializer, callback ) {
    var PARSING_TIMEOUT_INTERVAL = 1000; //milliseconds

    if (!callback) {
        this.parse(root, fullPage, serializer);
        return;
    }

    if ( !root ) {
        throw new Error( "No root element for parsing" );
    }

    var node = root;
    var parentNode = null;
    var thizz = this;

    var asyncParser = function()
    {
        var parsingEnd = true;
        var startTimeParsing = new Date().getTime();
        while ( node ) {
            if ( node != root &#038;&#038; node.parentNode ) {
                parentNode = node.parentNode.serializedNode;
            }

            if ( thizz.isNodeForSerialize( node ) ) {
                if ( node.nodeType == Evernote.Node.TEXT_NODE ) {
                    serializer.textNode( node, this._range );
                }
                else if ( node.nodeType == Evernote.Node.ELEMENT_NODE &#038;&#038; thizz.isNodeVisible( node ) ) {
                    node.serializedNode = serializer.startNode( new Evernote.SerializedNode( node, parentNode ), root, fullPage );
                    if ( node.hasChildNodes() ) {
                        node = node.childNodes[ 0 ];
                        continue;
                    }
                    else {
                        serializer.endNode( node.serializedNode );
                        if ( node.serializedNode ) {
                            try {
                                delete node.serializedNode;
                            } catch(e) {
                                //If we are failed to delete the property, than just set it to undefined
                                node.serializedNode = undefined;
                            }
                        }
                    }
                }
            }

            /**
             * Check if there is a next node available and it is not the root
             */
            if ( node.nextSibling &#038;&#038; node != root ) {
                node = node.nextSibling;
            }
            else if ( node != root ) {
                while ( node.parentNode &#038;&#038; node != root ) {
                    node = node.parentNode;
                    try {
                        serializer.endNode( node.serializedNode );
                    } catch (err) {
                        node.serializedNode = undefined;
                        continue;
                    };
                    try {
                        delete node.serializedNode;
                    } catch (e) {
                        //If we are failed to delete the property, than just set it to undefined
                        node.serializedNode = undefined;
                    }

                    if ( node.nextSibling &#038;&#038; node != root ) {
                        node = node.nextSibling;
                        break;
                    }
                }

                if ( node == root ) {
                    break;
                }
            }
            else {
                break;
            }

            var endTimeParsing = new Date().getTime();
            if ( (endTimeParsing - startTimeParsing) >= PARSING_TIMEOUT_INTERVAL ) {
                Evernote.Logger.debug("Parsing interval timeout: " + (endTimeParsing - startTimeParsing));
                parsingEnd = false;
                break;
            }
        }

        if (parsingEnd) {
            Evernote.Logger.debug("Parsing end");
            callback();
        }else {
            Evernote.Logger.debug("Parsing repeat");
            setTimeout(asyncParser, 0);
        }
    };
    setTimeout(asyncParser, 0);
};

/**
 * Starts parsing from specified root.
 * @param root - starting DOM node.
 * @param fullPage - is user selects to serialize the full page
 * @param serializer - current serializer to be used to serialize the DOM node to string
 */
Evernote.DomParser.prototype.parse = function ( root, fullPage, serializer ) {
    Evernote.Logger.debug( "DomParser.parse()" );

    if ( !root ) {
        throw new Error( "No root element for parsing" );
    }

    var node = root;
    var parentNode = null;

    while ( node ) {
        if ( node != root &#038;&#038; node.parentNode ) {
            parentNode = node.parentNode.serializedNode;
        }

        if ( this.isNodeForSerialize( node ) ) {
            if ( node.nodeType == Evernote.Node.TEXT_NODE ) {
                serializer.textNode( node, this._range );
            }
            else if ( node.nodeType == Evernote.Node.ELEMENT_NODE &#038;&#038; this.isNodeVisible( node ) ) {
                node.serializedNode = serializer.startNode( new Evernote.SerializedNode( node, parentNode ), root, fullPage );
                if ( node.hasChildNodes() ) {
                    node = node.childNodes[ 0 ];
                    continue;
                }
                else {
                    serializer.endNode( node.serializedNode );
                    if ( node.serializedNode ) {
                        try {
                            delete node.serializedNode;
                        } catch(e) {
                            //If we are failed to delete the property, than just set it to undefined
                            node.serializedNode = undefined;
                        }
                    }
                }
            }
        }

        /**
         * Check if there is a next node available and it is not the root
         */
        if ( node.nextSibling &#038;&#038; node != root ) {
            node = node.nextSibling;
        }
        else if ( node != root ) {
            while ( node.parentNode &#038;&#038; node != root ) {
                node = node.parentNode;
                try {
                    serializer.endNode( node.serializedNode );
                } catch (err) {
                    node.serializedNode = undefined;
                    continue;
                };

                try {
                    delete node.serializedNode;
                } catch (e) {
                    //If we are failed to delete the property, than just set it to undefined
                    node.serializedNode = undefined;
                }

                if ( node.nextSibling &#038;&#038; node != root ) {
                    node = node.nextSibling;
                    break;
                }
            }

            if ( node == root ) {
                break;
            }
        }
        else {
            break;
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.NodeSerializer = function NodeSerializer( tab, styleStrategy, includeBg ) {
    this.initialize( tab, styleStrategy, includeBg );
};

Evernote.NodeSerializer.prototype._tab = null;
Evernote.NodeSerializer.prototype._styleStrategy = null;
Evernote.NodeSerializer.prototype._docBase = null;
Evernote.NodeSerializer.prototype._imagesUrls = null;
Evernote.NodeSerializer.prototype._serializedDom = "";
Evernote.NodeSerializer.prototype._includeBgStyles = true;

Evernote.NodeSerializer.prototype.initialize = function ( tab, styleStrategy, includeBg ) {
    Evernote.Logger.debug( "DomSerializer.initialize()" );

    this._tab = tab;
    this._styleStrategy = (styleStrategy instanceof Evernote.ClipStylingStrategy) ? styleStrategy : null;
    this._imagesUrls = [ ];
    this._includeBgStyles = ( includeBg != null ) ? includeBg : true;
    this.getDocumentBase();
};

Evernote.NodeSerializer.prototype.startNode = function ( serializedNode, root, fullPage ) {
    Evernote.Logger.debug( "Start to serialize node :" + serializedNode.node.nodeName + ", class = " + serializedNode.node.className + ", id = " + serializedNode.node.id );
    try {
        var node = serializedNode.node;
        if ( Evernote.ClipRules.isConditionalNode( node ) &#038;&#038; Evernote.ElementSerializerFactory.getImplementationFor( node ) != null ) {
            var result = this.serializeConditionalNode( node, root, fullPage );
            this._serializedDom += result.content;
            // hack for desktop Win client
            if ( result.imageUrl ) {
                this._imagesUrls.push( result.imageUrl );
            }
            serializedNode.setStyle(result.nodeStyle);
            return serializedNode;
        }

        if ( node.nodeName.toLowerCase() == "embed" ) {
            var src = node.getAttribute( "src" );
            if ( src &#038;&#038; (src.indexOf(".swf", src.length - ".swf".length) !== -1) ) {
                serializedNode.setStyle(new Evernote.ClipStyle());
                return serializedNode;
            }
        }

        if ( node.nodeName.toLowerCase() == "img" ) {
            var src = node.getAttribute( "src" );

            if (src.indexOf('&#038;') != -1) {
                src =  src.slice(0, src.indexOf('&#038;'));
            }

            var absoluteSource = Evernote.Utils.makeAbsolutePath(this._docBase, src).replace(/\s/g, "%20");
            node.setAttribute( "type", "put-media-type-here-for-" + absoluteSource);
            node.setAttribute( "hash", "put-hash-type-here-for-" + absoluteSource);
            node.setAttribute( "src", src);

            if ( src &#038;&#038; src.indexOf( "data:image" ) < 0 ) {
                this._imagesUrls.push( src );
            }
        }

        var attrsStr = this.serializeAttributes( node );
        var stylesStr = "";

        var nodeName = Evernote.ClipRules.translateNode( node );

        if ( this._styleStrategy ) {

            var nodeStyle = this._styleStrategy.styleForNode( node, root, fullPage, Evernote.ClipStyleType.Default ).evaluated;

            var inhBgStyle = null;
            if ( this._includeBgStyles )
                inhBgStyle = this._styleStrategy.styleForNode( node, root, fullPage, Evernote.ClipStyleType.InheritedBgStyle ).inheritedBackground;

            if ( inhBgStyle != null )
                for ( var inhI = inhBgStyle.length - 1; inhI >= 0; inhI-- ) {
                    var inhStyle = inhBgStyle[inhI];
                    this._serializedDom += "
<div " + this.serializeStyles( node, inhStyle ) + " >";
                    serializedNode.translateTo.push( "div" );
                }

            var pseudoStyle = this._styleStrategy.getNodeStyle( node, null, ":before" );

            if ( fullPage &#038;&#038; node.nodeName.toLowerCase() == "body" ) {
                var wrapBodyStyle = new Evernote.ClipStyle( nodeStyle, null, Evernote.ClipStyle.CSS_GROUP.getExtForStyle( "background" ) );
                this._serializedDom += "<" + "div" + " " + this.serializeStyles( node, wrapBodyStyle ) + " >";
                serializedNode.translateTo.push( "div" );
                var bgGroup = Evernote.ClipStyle.CSS_GROUP.getExtForStyle( "background" );
                for ( var ind in bgGroup ) {
                    if ( bgGroup.hasOwnProperty( ind ) ) {
                        nodeStyle.removeStyle( bgGroup[ind] );
                    }
                }
            }

            if ( !fullPage &#038;&#038; node == root ) {
                nodeStyle.removeStyle( "float" );
            }
            if ( !serializedNode.node.hasChildNodes() &#038;&#038; !(nodeStyle.getStyle( "height" ) || node.getAttribute( "height" )) ) {
                nodeStyle.addStyle( {height:"0px"} );
            }
            if ( !serializedNode.node.hasChildNodes() &#038;&#038; !(nodeStyle.getStyle( "width" ) || node.getAttribute( "width" )) ) {
                nodeStyle.addStyle( {width:"0px"} );
            }
            if(nodeStyle.getStyle("position") == "fixed") {
                nodeStyle.addStyle({position: "absolute"});
            }

            if ( (node.nodeName.toUpperCase() == "SPAN"/* || node.nodeName.toUpperCase() == "A"*/) &#038;&#038; node.getElementsByTagName( "IMG" ).length > 0) {
                nodeName = "div";
                if ( !nodeStyle.getStyle( "display" ) )
                    nodeStyle.addStyle( {display:"inline"} );
            }
            if (node.nodeName.toUpperCase() == "TH" || node.nodeName.toUpperCase() == "TD") {
                nodeStyle.addStyle( {display:"table-cell"} );
            }

            nodeStyle.removeDefaultCssStyle();

            this._serializedDom += this.serializePseudoElement( node, pseudoStyle );
            stylesStr = this.serializeStyles( node, nodeStyle );

            if ( (nodeName.toLowerCase() == "div" /*|| nodeName.toLowerCase() == "span"*/) &#038;&#038; nodeStyle.getStyle( "float" ) &#038;&#038; nodeStyle.getStyle( "float" ) != "none" &#038;&#038; serializedNode.parentNode &#038;&#038; node.parentNode.nodeName.toLowerCase() != "a" ) {
                if ( !serializedNode.node.nextSibling || serializedNode.node.nextSibling.nodeType == 3 )
                    serializedNode.parentNode.isInlineBlock = true;
            }
        }

        Evernote.Logger.debug( node.nodeName + " " + attrsStr + " -> " + nodeName + " " + stylesStr );

        this._serializedDom += "<" + nodeName + " " + attrsStr + " " + stylesStr + " >";

        serializedNode.setStyle(nodeStyle);
        serializedNode.translateTo.push( nodeName );
        return serializedNode;
    }
    catch ( e ) {
        Evernote.Logger.error( "Failed to start serialize node :" + e );
        throw e;
    }
};

Evernote.NodeSerializer.prototype.serializePseudoElement = function ( node, pseudoStyle ) {
    try {
        var nodeName = Evernote.ClipRules.translateNode( node );
        if ( pseudoStyle.getStylesNames().length > 0 ) {
            var content = "&nbsp;";
            if ( pseudoStyle.getStyle( "content" ) ) {
                content = pseudoStyle.getStyle( "content" );
                pseudoStyle.removeStyle( "content" );
            }
            var beforeStylesStr = this.serializeStyles( node, pseudoStyle );
            return "<" + nodeName + " " + beforeStylesStr + " >" + content.replace( /"/g, '' ) + "</" + nodeName + ">";
        }
        return "";
    }
    catch ( e ) {
        Evernote.Logger.error( "Failed to  serialize pseudo element :" + e );
        throw e;
    }
};

Evernote.NodeSerializer.prototype.textNode = function ( node, range ) {
    this._serializedDom += this.serializeTextNode( node, range );
};

Evernote.NodeSerializer.prototype.endNode = function ( serializedNode ) {
    try {
        Evernote.Logger.debug( "end serialize node :" + serializedNode.translateTo );

        if ( serializedNode.isInlineBlock ) {
            var name = "div";
            if ( serializedNode.node.nodeName.toLowerCase() == "ul" ) {
                name = "li"
            }
            this._serializedDom += "<" + name + " style=\"clear: both; width: 0px; height: 0px;\">" + "&nbsp;" + "</" + name + ">"
        }

        var node = serializedNode.node;
        var serializedPseudo = "";
        var pseudoStyle = new Evernote.ClipStyle();
        if ( this._styleStrategy ) {
            pseudoStyle = this._styleStrategy.getNodeStyle( node, null, ":after" );
            if ( pseudoStyle.getStylesNames().length > 0 ) {
                var floatStyle = serializedNode.getStyle().getStyle( "float" );
                if ( floatStyle &#038;&#038; !pseudoStyle.getStyle( "float" ) )
                    pseudoStyle.addStyle( { "float" : floatStyle } );

                if ( node.nodeName.toLowerCase() == "ul" )
                    serializedPseudo = this.serializePseudoElement( document.createElement( "div" ), pseudoStyle );
            }
        }

        while ( serializedNode.translateTo.length > 0 ) {
            var nodeName = serializedNode.translateTo.pop();
            if ( !Evernote.ClipRules.isSelfClosingNode( serializedNode.node ) ) {
                if ( !serializedNode.node.hasChildNodes() )
                    this._serializedDom += "&nbsp;";
            }

            if ( nodeName.toLowerCase() == "ul" ) {
                this._serializedDom += this.serializePseudoElement( document.createElement( "li" ), pseudoStyle );
            }
            this._serializedDom += "</" + nodeName + ">";
        }

        this._serializedDom += serializedPseudo;
    }
    catch ( e ) {
        Evernote.Logger.error( "Failed to end serialize node :" + e );
        throw e;
    }
};


Evernote.NodeSerializer.prototype.serializeTextNode = function ( node, range ) {
    Evernote.Logger.debug( "DomSerializer.serializeTextNode()" );

    try {
        var nodeValue = node.nodeValue;
        if ( !range ) {
            return Evernote.Utils.htmlEncode( nodeValue );
        }
        else {
            if ( range.startContainer == node &#038;&#038; range.startContainer == range.endContainer ) {
                return Evernote.Utils.htmlEncode( nodeValue.substring( range.startOffset, range.endOffset ) );
            }
            else if ( range.startContainer == node ) {
                return Evernote.Utils.htmlEncode( nodeValue.substring( range.startOffset ) );
            }
            else if ( range.endContainer == node ) {
                return Evernote.Utils.htmlEncode( nodeValue.substring( 0, range.endOffset ) );
            }
            else if ( range.commonAncestorContainer != node ) {
                return Evernote.Utils.htmlEncode( nodeValue );
            }
        }
    }
    catch ( e ) {
        Evernote.Logger.error( "DomSerializer.serializeTextNode() failed " + e );
        throw e;
    }

    return "";
};

Evernote.NodeSerializer.prototype.serializeConditionalNode = function ( node, root, fullPage ) {
    Evernote.Logger.debug( "DomSerializer.serializeConditionalNode()" );
    var impl = Evernote.ElementSerializerFactory.getImplementationFor( node );
    if ( typeof impl == 'function' ) {
        var nodeStyle = (this._styleStrategy) ? this._styleStrategy.styleForNode( node, root, fullPage ).evaluated : null;
        if (nodeStyle)
            nodeStyle.removeDefaultCssStyle();
        var serializer = new impl( node, nodeStyle );
        var content = serializer.serialize( this._docBase );
        var imageUrl = serializer.getImageUrl();

        return { content:content, imageUrl:imageUrl, nodeStyle:nodeStyle };
    }

    return { content:"", imageUrl:"", nodeStyle:new Evernote.ClipStyle() };
};

Evernote.NodeSerializer.prototype.serializeAttributes = function ( node ) {
    Evernote.Logger.debug( "DomSerializer.serializeAttributes()" );

    try {
        var attrs = node.attributes;
        var str = "";

        for ( var i = 0; i < attrs.length; ++i ) {
            if ( !Evernote.ClipRules.isNoKeepNodeAttr( attrs[ i ], Evernote.ClipRules.translateNode( node ), node ) ) {
                var attrValue = (attrs[ i ].value) ? Evernote.GlobalUtils.escapeXML( attrs[ i ].value ) : "";
                if ( (attrs[ i ].name.toLowerCase() == "src" || attrs[ i ].name.toLowerCase() == "href") &#038;&#038; attrValue.toLowerCase().indexOf( "http" ) != 0 ) {
                    attrValue = Evernote.Utils.makeAbsolutePath( this._docBase, attrValue );
                }
                str += " " + attrs[ i ].name.toLowerCase() + "=\"" + attrValue + "\"";
            }
        }

        return str;
    }
    catch ( e ) {
        Evernote.Logger.error( "DomSerializer.serializeAttributes() failed: error = " + e );
    }

    return "";
};

Evernote.NodeSerializer.prototype.serializeStyles = function ( node, nodeStyle ) {
    Evernote.Logger.debug( "DomSerializer.serializeStyles()" );

    try {
        var str = "";
        if(node.nodeName.toLowerCase() == "map") {
            //Map should not have style attribute according to Evernote DTD
            return "";
        }
        if ( node &#038;&#038; nodeStyle instanceof Evernote.ClipStyle ) {
            str += " style=\"" + nodeStyle.toString().replace( /"/g, "" ) + "\"";
        }
        return str;
    }
    catch ( e ) {
        Evernote.Logger.error( "DomSerializer.serializeStyles() failed: error = " + e );
        throw e;
    }
    return "";
};

Evernote.NodeSerializer.prototype.getDocumentBase = function () {
    Evernote.Logger.debug( "DomSerializer.getDocumentBase()" );

    if ( !this._docBase ) {
        var baseTags = this._tab.document.getElementsByTagName( "base" );
        for ( var i = 0; i < baseTags.length; ++i ) {
            var baseTag = baseTags[ i ];
            if ( typeof baseTag == 'string' &#038;&#038; baseTag.indexOf( "http" ) == 0 ) {
                this._docBase = baseTag;
            }
            if ( this._docBase ) {
                break;
            }
        }

        if ( !this._docBase ) {
            var location = this._tab.document.location;
            this._docBase = location.protocol + "//" + location.host + location.pathname.replace( /[^\/]+$/, "" );
        }
    }

    return this._docBase;
};

Evernote.NodeSerializer.prototype.getImagesUrls = function () {
    return this._imagesUrls;
};

Evernote.NodeSerializer.prototype.getSerializedDom = function () {
    return '
<div style="position: relative;">' + this._serializedDom.replace(/[^\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD]+/g, "") + '</div>
';
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
//"use strict";

Evernote.SerializedNode = function SerializedNode( node, parent ) {
    this.node = node;
    this._parentSerializedNode = parent;
    this.translateTo = [ ];
};

Evernote.SerializedNode.prototype.translateTo = null;
Evernote.SerializedNode.prototype.node = null;
Evernote.SerializedNode.prototype._parentSerializedNode = null;

Evernote.SerializedNode.prototype.setStyle = function ( clipStyle ) {
    this._clipStyle = clipStyle;
};

Evernote.SerializedNode.prototype.getStyle = function () {
    return this._clipStyle;
};

Evernote.SerializedNode.prototype.parentNode = function () {
    return this._parentSerializedNode;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
//"use strict";

Evernote.StylesCollection = function StylesCollection() {
    this._styles = { };
};

Evernote.StylesCollection.prototype._styles = null;

Evernote.StylesCollection.prototype.addStyle = function( name, value, isImportant ) {
    if ( typeof name == "string" &#038;&#038; typeof value == "string" ) {
        Evernote.Logger.debug( "StylesCollection.addStyle(): name = " + name + ", value = " + value + ", isImportant = " + isImportant );
        this._styles[ name ] = new Evernote.ClipStyleProperty( name, value, isImportant);
    }
};

Evernote.StylesCollection.prototype.getStyle = function( name ) {
    if ( typeof name == "string" ) {
        Evernote.Logger.debug( "StylesCollection.getStyle(): name = " + name + " value: " + ((typeof this._styles[ name ] != "undefined") ? this._styles[ name ].value() : null) );
        return (typeof this._styles[ name ] != "undefined") ? this._styles[ name ].value() : null;
    }

    return null;
};

Evernote.StylesCollection.prototype.removeStyle = function( name ) {
    if ( typeof name == "string" ) {
        Evernote.Logger.debug( "StylesCollection.removeStyle(): name = " + name );

        this._styles[ name ] = null;
        delete this._styles[ name ];
    }
};

Evernote.StylesCollection.prototype.isImportant = function( name ) {
    if ( typeof name == "string" ) {
        return (typeof this._styles[ name ] != "undefined") ? this._styles[ name ].isImportant() : false;
    }
};

Evernote.StylesCollection.prototype.getStylesNames = function() {
    Evernote.Logger.debug( "StylesCollection.getStylesNames()" );

    var stylesNames = [ ];
    for ( var key in this._styles ) {
        if ( this._styles[ key ] != null ) {
            stylesNames.push( key );
        }
    }

    return stylesNames;
};

Evernote.StylesCollection.prototype.getStylesNumber = function() {
    Evernote.Logger.debug( "StylesCollection.getStylesNumber()" );

    var num = 0;
    for ( var key in this._styles ) {
        if ( this._styles[ key ] != null ) {
            ++num;
        }
    }

    return num;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.DataImageSerializer = function DataImageSerializer( node, nodeStyle ) {
    if ( !nodeStyle ) {
        nodeStyle = new Evernote.ClipStyle();
    }

    this.initialize( node, nodeStyle );
};

Evernote.inherit( Evernote.DataImageSerializer, Evernote.AbstractElementSerializer, true );

Evernote.DataImageSerializer.isResponsibleFor = function( node ) {
    try {
        if ( node &#038;&#038; node.nodeType == Evernote.Node.ELEMENT_NODE &#038;&#038; node.nodeName.toLowerCase() == "img" ) {
            var src = node.getAttribute( "src" );
            if ( src &#038;&#038; src.indexOf( "data:image" ) != -1 ) {
                return true;
            }
        }
    } catch(e) {
        Evernote.Logger.error("DataImageSerializer.isResponsibleFor failed due to error " + e);
    }
    return false;
};

Evernote.DataImageSerializer.prototype.serialize = function( /*docBase*/ ) {
    Evernote.Logger.debug( "DataImageSerializer.serialize()" );

    try {
        this._nodeStyle.addStyle( { "background-image" : "url('" + this._node.getAttribute( "src" ) + "')",
            "width" : this._node.offsetWidth + "px",
            "height" : this._node.offsetHeight + "px",
            "background-repeat" : "no-repeat",
            "display" : "block" } );

        return "<span style=\"" + this._nodeStyle.toString().replace( /"/g, "" ) + "\"" + ">&nbsp;</span>";
    }
    catch ( e ) {
        Evernote.Logger.error( "DataImageSerializer.serialize() failed: error = " + e );
    }

    return "";
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.VideoElementSerializer = function VideoElementSerializer( node, nodeStyle ) {
    this.initialize( node, nodeStyle );
};

Evernote.inherit( Evernote.VideoElementSerializer, Evernote.AbstractElementSerializer, true );

Evernote.VideoElementSerializer.isResponsibleFor = function( node ) {
    return node &#038;&#038; node.nodeType == Evernote.Node.ELEMENT_NODE &#038;&#038; node.nodeName.toLowerCase() == "video";
};

Evernote.VideoElementSerializer.prototype.serialize = function( /*docBase*/ ) {
    Evernote.Logger.debug( "VideoElementSerializer.serialize()" );

    try {
        var width = this._node.offsetWidth;
        var height = this._node.offsetHeight;
        var doc = this._node.ownerDocument;

        var canvas = doc.createElement( "CANVAS" );
        canvas.width = width;
        canvas.height = height;

        var context = canvas.getContext( "2d" );
        context.drawImage( this._node, 0, 0, width, height );

        var dataUrl = canvas.toDataURL( "image/png" );
        context.clearRect( 0, 0, width, height );

        this._nodeStyle.addStyle( { "background-image" : "url('" + dataUrl + "')",
            "width" : width + "px",
            "height" : height + "px",
            "display" : "block" } );

        return "<a style=\"" + this._nodeStyle.toString().replace( /"/g, "" ) + "\"" + "href='" + doc.defaultView.location.href + "'>&nbsp;</a>";
    }
    catch ( e ) {
        Evernote.Logger.error( "VideoElementSerializer.serialize() failed: error = " + e );
    }

    return "";
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
/**
 * Serializes DOM element into an img pointing to the thumbnail of the video
 *
 * Video ids are used for obtaining thumbnails via
 * https://i2.ytimg.com/vi/cAcxHQalWOw/hqdefault.jpg. These ids can be
 * obtained from:
 *
 *
<pre>
 *   - the URL of the document containing EMBED
 *   - iframe's src attribute that embeds the video via an iframe
 *   - src attribute of the embed object (though on actualy youtube.com it's not possible)
 *</pre>
*
 * Sample URLs are:
 *
 *
<pre>
 * http: //www.youtube.com/embed/IWJJBwKhvp4?wmode=opaque&amp;rel=0
 * http: //www.youtube.com/v/YZEbBZ2IrXE?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1
 * http: //www.youtube.com/v/J3mjFSTsKiM&amp;hl=en&amp;fs=1
 * http://www.youtube.com/watch?v=cAcxHQalWOw
 * http://www.youtube.com/user/IFiDieApp?v=sdzCELofGgE&#038;feature=pyv
 *</pre>
*/

Evernote.YoutubeElementSerializer = function YoutubeElementSerializer( doc, node, nodeStyle ) {
    this.initialize( doc, node, nodeStyle );
};

Evernote.inherit( Evernote.YoutubeElementSerializer, Evernote.AbstractElementSerializer, true );

Evernote.YoutubeElementSerializer.WATCH_URL_REGEX = /^https?:\/\/www\.youtube\.com\/watch\?.*v=([^&#038;]+)/i;
Evernote.YoutubeElementSerializer.USER_CHANNEL_URL_REGEX = /^https?:\/\/www\.youtube\.com\/user\/([a-zA-Z0-9]+)\?v=([^&#038;]+)/i;
Evernote.YoutubeElementSerializer.EMBED_URL_REGEX = /^https?:\/\/www\.youtube\.com\/embed\/([^\/\?&#038;]+)/i;
Evernote.YoutubeElementSerializer.VIDEO_URL_REGEX = /^https?:\/\/www\.youtube\.com\/v\/([^\/\?&#038;]+)/i;
Evernote.YoutubeElementSerializer.POSSIBLE_CONTAINER_NODES = [ "OBJECT" ];
Evernote.YoutubeElementSerializer.VIDEO_NODES = [ "EMBED", "IFRAME" ];
Evernote.YoutubeElementSerializer.WATCH_URL = "http://www.youtube.com/watch?v=$videoId$";
Evernote.YoutubeElementSerializer.USER_CHANNEL_URL = "http://www.youtube.com/user/$userId$?v=$videoId$";
Evernote.YoutubeElementSerializer.DEFAULT_THUMB_URL = "https://i2.ytimg.com/vi/$videoId$/default.jpg";
Evernote.YoutubeElementSerializer.HQ_THUMB_URL = "https://i2.ytimg.com/vi/$videoId$/hqdefault.jpg";
Evernote.YoutubeElementSerializer.DEFAULT_THUMB_WIDTH = 120;
Evernote.YoutubeElementSerializer.DEFAULT_THUMB_HEIGHT = 90;

Evernote.YoutubeElementSerializer.isResponsibleFor = function( node ) {
    var params = this.extractVideoParamsFromNode( node );
    return (params) ? true : false;
};

Evernote.YoutubeElementSerializer.extractVideoParamsFromNode = function( node ) {
    Evernote.Logger.debug( "YoutubeElementSerializer.extractVideoIdFromNode()" );
    try {
        if ( node &#038;&#038; node.nodeType == Evernote.Node.ELEMENT_NODE ) {
            var view = window;
            try {
                view = node.ownerDocument.defaultView;
            }
            catch ( e ) {
            }

            var matches = null;
            if ( view &#038;&#038; (node.nodeName.toLowerCase() == "embed" || node.nodeName.toLowerCase() == "object") &#038;&#038; view.location ) {
                if ( (matches = view.location.href.match( this.WATCH_URL_REGEX )) &#038;&#038; matches[ 1 ] ) {
                    return matches[ 1 ];
                }
                else if ( (matches = view.location.href.match( this.USER_CHANNEL_URL_REGEX )) &#038;&#038; matches[ 1 ] &#038;&#038; matches[ 2 ] ) {
                    return [ matches[ 1 ], matches[ 2 ] ];
                }
            }
            else {
                var videoNode = this.findVideoNode( node );
                if ( videoNode ) {
                    var src = videoNode.getAttribute( "src" );
                    if ( src &#038;&#038; (matches = src.match( this.EMBED_URL_REGEX )) &#038;&#038; matches[ 1 ] ) {
                        return matches[ 1 ];
                    }
                    else if ( src &#038;&#038; (matches = src.match( this.VIDEO_URL_REGEX )) &#038;&#038; matches[ 1 ] ) {
                        return matches[ 1 ];
                    }
                }
            }
        }
    } catch(e) {
        Evernote.Logger.error("failed to YoutubeElementSerializer.extractVideoParamsFromNode due to error " + e);
    }

    return null;
};

Evernote.YoutubeElementSerializer.findVideoNode = function( node ) {
    Evernote.Logger.debug( "YoutubeElementSerializer.findVideoNode()" );

    if ( node &#038;&#038; node.nodeType == Evernote.Node.ELEMENT_NODE ) {
        if ( Evernote.ArrayExtension.indexOf(this.VIDEO_NODES,  node.nodeName.toUpperCase() ) >= 0 ) {
            return node;
        }
        else if ( Evernote.ArrayExtension.indexOf(this.POSSIBLE_CONTAINER_NODES, node.nodeName.toUpperCase() ) >= 0 ) {
            try {
                var it = node.ownerDocument.createNodeIterator( node, NodeFilter.SHOW_ELEMENT, null, false );
                var next = null;

                while ( next = it.nextNode() ) {
                    if ( Evernote.ArrayExtension.indexOf(this.VIDEO_NODES, next.nodeName.toUpperCase() ) >= 0 ) {
                        return next;
                    }
                }
            } catch(e) {
                //We ignore exception here, because if node iterator is not supported, than we could skip old pages (not Youtube).
                return null;
            }
        }
    }

    return null;
};

Evernote.YoutubeElementSerializer.prototype._imageUrl = "";

Evernote.YoutubeElementSerializer.prototype.serialize = function( /*docBase*/ ) {
    Evernote.Logger.debug( "YoutubeElementSerializer.serialize()" );

    try {
        var userId = null;
        var videoId = null;
        var params = this.constructor.extractVideoParamsFromNode( this._node );
        if ( params instanceof Array ) {
            userId = params[ 0 ];
            videoId = params[ 1 ];
        }
        else if ( typeof params == "string" ) {
            videoId = params;
        }

        if ( videoId ) {
            var thumbUrl = null;
            var w = 0;
            var h = 0;

            if ( this._nodeStyle ) {

                var view = window;
                try {
                    view = this._node.ownerDocument.defaultView;
                }
                catch ( e ) {
                }

                var computedStyles = Evernote.ElementExtension.getComputedStyle( this._node, null, view );

                w = parseInt( Evernote.StyleElementExtension.getPropertyValue(computedStyles, "width" ) );
                w = (isNaN( w )) ? 0 : w;

                h = parseInt( Evernote.StyleElementExtension.getPropertyValue(computedStyles, "height" ) );
                h = (isNaN( h )) ? 0 : h;


                if ( w < this.constructor.DEFAULT_THUMB_WIDTH || h < this.constructor.DEFAULT_THUMB_HEIGHT ) {
                    thumbUrl = this.getDefaultThumbnailUrl( videoId );
                }
                else {
                    thumbUrl = this.getHQThumbnailUrl( videoId );
                }
            }
            else {
                thumbUrl = this.getDefaultThumbnailUrl( videoId );
            }

            if ( thumbUrl ) {
                var styleStr = (this._nodeStyle instanceof Evernote.ClipStyle) ? ("style=\"" + this._nodeStyle.toString() + "\"") : "";
                var attrs = this._node.attributes;
                var attrStr = "";

                for ( var i = 0; i < attrs.length; ++i ) {
                    var attr = attrs[ i ];
                    if(Evernote.ClipRules.KEEP_NODE_ATTRIBUTES["a"][attr.name]) {
                        attrStr += attr.name;
                        if ( attr.value ) {
                            attrStr += "=" + attr.value;
                        }
                        attrStr += " ";
                    }
                }

                var href = ( userId ) ? this.getUserChannelUrl( userId, videoId ) : this.getWatchUrl( videoId );
                var imgAttrStr = "";

                if ( w &#038;&#038; h ) {
                    var k = w / h;
                    // scale by height
                    if ( k > this.constructor.DEFAULT_THUMB_WIDTH / this.constructor.DEFAULT_THUMB_HEIGHT ) {
                        imgAttrStr += "height=\"" + h + "\"";
                    }
                    else { // scale by width
                        imgAttrStr += "width=\"" + w + "\"";
                    }
                }

                this._imageUrl = thumbUrl;
                return "<a " + styleStr + " " + attrStr + " href=\"" + href + "\"><img class="colorbox-1038"  src=\"" + thumbUrl + "\" " + imgAttrStr + "/></a>";
            }
        }
    }
    catch ( e ) {
        Evernote.Logger.error( "YoutubeElementSerializer.serialize() failed: error = " + e );
    }

    return "";
};

Evernote.YoutubeElementSerializer.prototype.getDefaultThumbnailUrl = function( videoId ) {
    return this.constructor.DEFAULT_THUMB_URL.replace( /\$videoId\$/, videoId );
};

Evernote.YoutubeElementSerializer.prototype.getHQThumbnailUrl = function( videoId ) {
    return this.constructor.HQ_THUMB_URL.replace( /\$videoId\$/, videoId );
};

Evernote.YoutubeElementSerializer.prototype.getWatchUrl = function( videoId ) {
    return this.constructor.WATCH_URL.replace( /\$videoId\$/, videoId );
};

Evernote.YoutubeElementSerializer.prototype.getUserChannelUrl = function( userId, videoId ) {
    return this.constructor.USER_CHANNEL_URL.replace( /\$userId\$/, userId ).replace( /\$videoId\$/, videoId );
};

Evernote.YoutubeElementSerializer.prototype.getImageUrl = function() {
    return this._imageUrl;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.IEStylePropertiesMapping = {

    _mapping : {
        "background-attachment" : "backgroundAttachment",
        "background-color" : "backgroundColor",
        "background-image" : "backgroundImage",
        "background-repeat" : "backgroundRepeat",
        "background-position-x" : "backgroundPositionX",
        "background-position-y" : "backgroundPositionY",

        "border-bottom-color" : "borderBottomColor",
        "border-bottom-style" : "borderBottomStyle",
        "border-bottom-width" : "borderBottomWidth",

        "border-left-color" : "borderLeftColor",
        "border-left-style" : "borderLeftStyle",
        "border-left-width" : "borderLeftWidth",

        "border-right-color" : "borderRightColor",
        "border-right-style" : "borderRightStyle",
        "border-right-width" : "borderRightWidth",

        "border-top-color" : "borderTopColor",
        "border-top-style" : "borderTopStyle",
        "border-top-width" : "borderTopWidth",
        "border-collapse" : "borderCollapse",

        "font-family" : "fontFamily",
        "font-size" : "fontSize",
        "font-style" : "fontStyle",
        "font-weight" : "fontWeight",

        "float" : "styleFloat",

        "ime-mode" : "imeMode",

        "letter-spacing" : "letterSpacing",

        "line-height" : "lineHeight",

        "list-style-image" : "listStyleImage",
        "list-style-position" : "listStylePosition",
        "list-style-type" : "listStyleType",

        "margin-bottom" : "marginBottom",
        "margin-left" : "marginLeft",
        "margin-right" : "marginRight",
        "margin-top" : "marginTop",

        "max-height" : "maxHeight",
        "max-width" : "maxWidth",
        "min-height" : "minHeight",
        "min-width" : "minWidth",

        "overflow-x" : "overflowX",
        "overflow-y" : "overflowY",

        "padding-bottom" : "paddingBottom",
        "padding-left" : "paddingLeft",
        "padding-right" : "paddingRight",
        "padding-top" : "paddingTop",

        "page-break-after" : "pageBreakAfter",
        "page-break-before" : "pageBreakBefore",

        "table-layout" : "tableLayout",

        "text-align" : "textAlign",
        "text-decoration" : "textDecoration",
        "text-indent" : "textIndent",
        "text-overflow" : "textOverflow",
        "text-transform" : "textTransform",

        "vertical-align" : "verticalAlign",
        "white-space" : "whiteSpace",
        "word-spacing" : "wordSpacing",
        "word-wrap" : "wordWrap",
        "z-index" : "zIndex"
    },

    getPropertyNameFor: function(styleName) {
        return [styleName, this._mapping[styleName]];
    },
    getPropertiesList: function() {
        return this._mapping;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.StylesReplacementRegistry = {

    registry: [],

    getImplementationFor: function(name) {
        if(name) {
            return this.registry[name];
        }
        return null;
    },

    register: function(name, impl) {
        this.registry[name] = impl;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.FontSizeReplacement = {

    SUPPORTED_FONT_SIZES: ["em", "%", "pt", "px"],

    getValue: function(val) {
        if(typeof val != "string")
            return val;
        if(this.isCalculationRequired(val)) {
            return Evernote.Utils.getFontSizeInPixels(val) + "px";
        } else {
            //Do not set browser dependant CSS since it does not supported by Evernote Chromium Viewer.
            return null;
        }
    },

    isCalculationRequired: function(val) {
        for(var i = 0; i < this.SUPPORTED_FONT_SIZES.length; i++) {
            if(val.indexOf(this.SUPPORTED_FONT_SIZES[i]) != -1) {
                return true;
            }
        }
        return false;
    }
};

Evernote.StylesReplacementRegistry.register("font-size", Evernote.FontSizeReplacement);
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ClipperElementsIdentifiers = {

    _clipperElementsIds : [Constants.CLIP_DIALOG_ID, Constants.OPTIONS_DIALOG_ID],

    match: function(node) {
        if(node &#038;&#038; node.id) {
            var position = Evernote.ArrayExtension.indexOf(this._clipperElementsIds, node.id);
            if(position) {
                return position != -1;
            }
        }
        return false;
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.NotebooksLoader = {

    notebooks: [],

    getNotebookByUid: function(uid) {
        Evernote.ResponseReceiver.subscribe(this);
        Evernote.Addin.getNotebooks(document);
        for(var i = 0; i < this.notebooks.length; i++) {
            if(this.notebooks[i].uid == uid) {
                return this.notebooks[i];
            }
        }
        return null;
    },

    onDataReceived: function(response) {
        if(response.type) {
            if(response.type == "notebooks") {
                this.notebooks = this.notebooks.concat(response.data);
            }
        }
    }
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.Notebook = function(type, name, uid, stack, author, hidden) {
    this.type = type;
    this.name = name;
    this.uid = uid;
    this.stack = stack;
    this.author = author;
    this.hidden = hidden;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.Tag = function(name, uid) {
    this.name = name;
    this.uid = uid;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.NotebookTypes = {
    PERSONAL: 1,
    BUSINESS: 2,
    LINKED: 3
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.ErrorCodes = {
    AUTHENTICATION_ERROR: "LoginFailure",
    CLIP_ERROR: "NoteImportFailure"
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
Evernote.AuthenticatedException = function(msg){
    this.msg = msg;
    this.code = Evernote.ErrorCodes.AUTHENTICATION_ERROR;
};
// ]]&gt;</script><script charset="ANSI" type="text/javascript" defer="defer">// <![CDATA[
try {
    Evernote.Addin.init(EvernoteExternal.Addin);
    Evernote.Addin.resetAuthenticatedState();
    Evernote.FS.init(EvernoteExternal.Addin);
    Evernote.Logger = Evernote.LoggerConfigurator.getLogger();
    if(!Evernote.JQuery)
        Evernote.JQueryLoader.initJQuery();
    window.jQueryForClearlyComponent = Evernote.JQuery;
    initClearly(window);
    if(Evernote.evernotePopup) {
        Evernote.evernotePopup.hide();
    }
    Evernote.Logger.debug("Init EnClipper");
    Evernote.EnClipper.init();
    Evernote.Logger.debug("EnClipper initialized");
    Evernote.pageInfo = new PageInfo();
    Evernote.contentPreviewer = new ContentPreview();
    Evernote.Options.load();
    if (EvernoteExternal.Addin.isServerAvailable()) {
        Evernote.Clipper.clipWithOptions(EvernoteExternal.clipOptions);
    }
} catch(e) {
    alert("Failed to clip via context menu" + e);
    throw e;
}
// ]]&gt;</script><style id="_clearly_component__css" type="text/css"><!--
#next_pages_container { width: 5px; hight: 5px; position: absolute; top: -100px; left: -100px; z-index: 2147483647 !important; }
--></style>]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1038.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>週刊！スマイルカンパニー♪</title>
		<link>http://www.egao-tane.com/topics/news/1028.html</link>
		<comments>http://www.egao-tane.com/topics/news/1028.html#comments</comments>
		<pubDate>Thu, 14 Jan 2016 01:29:53 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=1028</guid>
		<description><![CDATA[放送はすでに終わってしまいましたが、さくらんぼテレビさんの人気番組『週刊！スマイ&#8230;]]></description>
				<content:encoded><![CDATA[
<p>放送はすでに終わってしまいましたが、さくらんぼテレビさんの人気番組『週刊！スマイルカンパニー』に笑顔のアトリエが放送されました<img class="colorbox-1028"  style="margin-left: 3px; margin-right: 3px; vertical-align: middle;" alt="" src="http://www.egao-tane.com/wp-content/plugins/typepad-emoji-for-tinymce/icons/09/shine.gif" width="16" height="16" /></p>
<p>ウチの伊藤くんも爽やかにキマッてましたよ~<img class="colorbox-1028"  style="margin-left: 3px; margin-right: 3px; vertical-align: middle;" alt="" src="http://www.egao-tane.com/wp-content/plugins/typepad-emoji-for-tinymce/icons/04/scissors.gif" width="16" height="16" /><img class="colorbox-1028"  style="margin-left: 3px; margin-right: 3px; vertical-align: middle;" alt="" src="http://www.egao-tane.com/wp-content/plugins/typepad-emoji-for-tinymce/icons/06/heart04.gif" width="16" height="16" />笑</p>
<p><a href="http://www.sakuranbo.co.jp/special/smile/smile035.html">http://www.sakuranbo.co.jp/special/smile/smile035.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/1028.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>新年明けましておめでとうおめでとうございます！</title>
		<link>http://www.egao-tane.com/topics/news/983.html</link>
		<comments>http://www.egao-tane.com/topics/news/983.html#comments</comments>
		<pubDate>Thu, 14 Jan 2016 00:15:28 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=983</guid>
		<description><![CDATA[皆さま、新年明けましておめでとうございます。 長いこと更新ができずにおりましたが&#8230;]]></description>
				<content:encoded><![CDATA[
<p>皆さま、新年明けましておめでとうございます。</p>
<p>長いこと更新ができずにおりましたが、お客様の笑顔いっぱいのご様子を多く配信できるよう努めていこうと思います。</p>
<p>今後とも笑顔のたねならびに笑顔のアトリエをよろしくお願いいたします。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/983.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>笑顔のたねの動画をアップしました。</title>
		<link>http://www.egao-tane.com/topics/news/980.html</link>
		<comments>http://www.egao-tane.com/topics/news/980.html#comments</comments>
		<pubDate>Thu, 17 Sep 2015 03:13:10 +0000</pubDate>
		<dc:creator><![CDATA[たね笑顔の]]></dc:creator>
				<category><![CDATA[お知らせ]]></category>

		<guid isPermaLink="false">http://www.egao-tane.com/?p=980</guid>
		<description><![CDATA[笑顔のたねにあるリハビリゲームをご紹介した動画を公開しましたので、ぜひご覧下さい&#8230;]]></description>
				<content:encoded><![CDATA[
<p>笑顔のたねにあるリハビリゲームをご紹介した動画を公開しましたので、ぜひご覧下さい☆</p>
<p><a href="https://youtu.be/4Jznzm1zbMQ">https://youtu.be/4Jznzm1zbMQ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.egao-tane.com/topics/news/980.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
