/**
 * TrimPath Template. Release 1.0.38.
 * Copyright (C) 2004, 2005 Metaha.
 * 
 * TrimPath Template is licensed under the GNU General Public License
 * and the Apache License, Version 2.0, as follows:
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed WITHOUT ANY WARRANTY; without even the 
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var PodTrimPath; // we have namespaced this to keep a separate instance for Pod to use.
(function() {               // Using a closure to keep global namespace clean.
    if (PodTrimPath == null)
        PodTrimPath = new Object();
    if (PodTrimPath.evalEx == null)
        PodTrimPath.evalEx = function(src) { return eval(src); };
    var UNDEFINED;
    if (Array.prototype.pop == null)  // IE 5.x fix from Igor Poteryaev.
        Array.prototype.pop = function() {
            if (this.length === 0) {return UNDEFINED;}
            return this[--this.length];
        };
    if (Array.prototype.push == null) // IE 5.x fix from Igor Poteryaev.
        Array.prototype.push = function() {
            for (var i = 0; i < arguments.length; ++i) {this[this.length] = arguments[i];}
            return this.length;
        };
    PodTrimPath.parseTemplate = function(tmplContent, optTmplName, optEtc) {
        if (optEtc == null)
            optEtc = PodTrimPath.parseTemplate_etc;
        var funcSrc = parse(tmplContent, optTmplName, optEtc);
        var func = PodTrimPath.evalEx(funcSrc, optTmplName, 1);
        if (func != null)
            return new optEtc.Template(optTmplName, tmplContent, funcSrc, func, optEtc);
        return null;
    }
    try {
        String.prototype.process = function(context, optFlags) {
            var template = PodTrimPath.parseTemplate(this, null);
            if (template != null)
                return template.process(context, optFlags);
            return this;
        }
    } catch (e) { // Swallow exception, such as when String.prototype is sealed.
    }
    PodTrimPath.parseTemplate_etc = {};            // Exposed for extensibility.
    PodTrimPath.parseTemplate_etc.statementTag = "forelse|for|if|elseif|else|var|macro";
    PodTrimPath.parseTemplate_etc.statementDef = { // Lookup table for statement tags.
        "if"     : { delta:  1, prefix: "if (", suffix: ") {", paramMin: 1 },
        "else"   : { delta:  0, prefix: "} else {" },
        "elseif" : { delta:  0, prefix: "} else if (", suffix: ") {", paramDefault: "true" },
        "/if"    : { delta: -1, prefix: "}" },
        "for"    : { delta:  1, paramMin: 3, 
                     prefixFunc : function(stmtParts, state, tmplName, etc) {
                        if (stmtParts[2] != "in")
                            throw new etc.ParseError(tmplName, state.line, "bad for loop statement: " + stmtParts.join(' '));
                        var iterVar = stmtParts[1];
                        var listVar = "__LIST__" + iterVar;
                        return [ "var ", listVar, " = ", stmtParts[3], ";",
                             "var __LENGTH_STACK__;",
                             "if (typeof(__LENGTH_STACK__) == 'undefined' || !__LENGTH_STACK__.length) __LENGTH_STACK__ = new Array();", 
                             "__LENGTH_STACK__[__LENGTH_STACK__.length] = 0;", // Push a new for-loop onto the stack of loop lengths.
                             "if ((", listVar, ") != null) { ",
                             "var ", iterVar, "_ct = 0;",       // iterVar_ct variable, added by B. Bittman     
                             "for (var ", iterVar, "_index in ", listVar, ") { ",
                             iterVar, "_ct++;",
                             "if (typeof(", listVar, "[", iterVar, "_index]) == 'function') {continue;}", // IE 5.x fix from Igor Poteryaev.
                             "__LENGTH_STACK__[__LENGTH_STACK__.length - 1]++;",
                             "var ", iterVar, " = ", listVar, "[", iterVar, "_index];" ].join("");
                     } },
        "forelse" : { delta:  0, prefix: "} } if (__LENGTH_STACK__[__LENGTH_STACK__.length - 1] == 0) { if (", suffix: ") {", paramDefault: "true" },
        "/for"    : { delta: -1, prefix: "} }; delete __LENGTH_STACK__[__LENGTH_STACK__.length - 1];" }, // Remove the just-finished for-loop from the stack of loop lengths.
        "var"     : { delta:  0, prefix: "var ", suffix: ";" },
        "macro"   : { delta:  1, 
                      prefixFunc : function(stmtParts, state, tmplName, etc) {
                          var macroName = stmtParts[1].split('(')[0];
                          return [ "var ", macroName, " = function", 
                                   stmtParts.slice(1).join(' ').substring(macroName.length),
                                   "{ var _OUT_arr = []; var _OUT = { write: function(m) { if (m) _OUT_arr.push(m); } }; " ].join('');
                     } }, 
        "/macro"  : { delta: -1, prefix: " return _OUT_arr.join(''); };" }
    }
    PodTrimPath.parseTemplate_etc.modifierDef = {
        "eat"        : function(v)    { return ""; },
        "escape"     : function(s)    { return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); },
        "capitalize" : function(s)    { return String(s).toUpperCase(); },
        "default"    : function(s, d) { return s != null ? s : d; }
    }
    PodTrimPath.parseTemplate_etc.modifierDef.h = PodTrimPath.parseTemplate_etc.modifierDef.escape;
    PodTrimPath.parseTemplate_etc.Template = function(tmplName, tmplContent, funcSrc, func, etc) {
        this.process = function(context, flags) {
            if (context == null)
                context = {};
            if (context._MODIFIERS == null)
                context._MODIFIERS = {};
            if (context.defined == null)
                context.defined = function(str) { return (context[str] != undefined); };
            for (var k in etc.modifierDef) {
                if (context._MODIFIERS[k] == null)
                    context._MODIFIERS[k] = etc.modifierDef[k];
            }
            if (flags == null)
                flags = {};
            var resultArr = [];
            var resultOut = { write: function(m) { resultArr.push(m); } };
            try {
                func(resultOut, context, flags);
            } catch (e) {
                if (flags.throwExceptions == true)
                    throw e;
                var result = new String(resultArr.join("") + "[ERROR: " + e.toString() + (e.message ? '; ' + e.message : '') + "]");
                result["exception"] = e;
                return result;
            }
            return resultArr.join("");
        }
        this.name       = tmplName;
        this.source     = tmplContent; 
        this.sourceFunc = funcSrc;
        this.toString   = function() { return "PodTrimPath.Template [" + tmplName + "]"; }
    }
    PodTrimPath.parseTemplate_etc.ParseError = function(name, line, message) {
        this.name    = name;
        this.line    = line;
        this.message = message;
    }
    PodTrimPath.parseTemplate_etc.ParseError.prototype.toString = function() { 
        return ("PodTrimPath template ParseError in " + this.name + ": line " + this.line + ", " + this.message);
    }
    var parse = function(body, tmplName, etc) {
        body = cleanWhiteSpace(body);
        var funcText = [ "var PodTrimPath_Template_TEMP = function(_OUT, _CONTEXT, _FLAGS) { with (_CONTEXT) {" ];
        var state    = { stack: [], line: 1 };                              // TODO: Fix line number counting.
        var endStmtPrev = -1;
        while (endStmtPrev + 1 < body.length) {
            var begStmt = endStmtPrev;
            begStmt = body.indexOf("{", begStmt + 1);
            while (begStmt >= 0) {
                var endStmt = body.indexOf('}', begStmt + 1);
                var stmt = body.substring(begStmt, endStmt);
                var blockrx = stmt.match(/^\{(cdata|minify|eval)/); // From B. Bittman, minify/eval/cdata implementation.
                if (blockrx) {
                    var blockType = blockrx[1]; 
                    var blockMarkerBeg = begStmt + blockType.length + 1;
                    var blockMarkerEnd = body.indexOf('}', blockMarkerBeg);
                    if (blockMarkerEnd >= 0) {
                        var blockMarker;
                        if( blockMarkerEnd - blockMarkerBeg <= 0 ) {
                            blockMarker = "{/" + blockType + "}";
                        } else {
                            blockMarker = body.substring(blockMarkerBeg + 1, blockMarkerEnd);
                        }                        
                        var blockEnd = body.indexOf(blockMarker, blockMarkerEnd + 1);
                        if (blockEnd >= 0) {                            
                            emitSectionText(body.substring(endStmtPrev + 1, begStmt), funcText);
                            var blockText = body.substring(blockMarkerEnd + 1, blockEnd);
                            if (blockType == 'cdata') {
                                emitText(blockText, funcText);
                            } else if (blockType == 'minify') {
                                emitText(scrubWhiteSpace(blockText), funcText);
                            } else if (blockType == 'eval') {
                                if (blockText != null && blockText.length > 0) // From B. Bittman, eval should not execute until process().
                                    funcText.push('_OUT.write( (function() { ' + blockText + ' })() );');
                            }
                            begStmt = endStmtPrev = blockEnd + blockMarker.length - 1;
                        }
                    }                        
                } else if (body.charAt(begStmt - 1) != '$' &&               // Not an expression or backslashed,
                           body.charAt(begStmt - 1) != '\\') {              // so check if it is a statement tag.
                    var offset = (body.charAt(begStmt + 1) == '/' ? 2 : 1); // Close tags offset of 2 skips '/'.
                    if (body.substring(begStmt + offset, begStmt + 10 + offset).search(PodTrimPath.parseTemplate_etc.statementTag) == 0) 
                        break;                                              // Found a match.
                }
                begStmt = body.indexOf("{", begStmt + 1);
            }
            if (begStmt < 0)                              // In "a{for}c", begStmt will be 1.
                break;
            var endStmt = body.indexOf("}", begStmt + 1); // In "a{for}c", endStmt will be 5.
            if (endStmt < 0)
                break;
            emitSectionText(body.substring(endStmtPrev + 1, begStmt), funcText);
            emitStatement(body.substring(begStmt, endStmt + 1), state, funcText, tmplName, etc);
            endStmtPrev = endStmt;
        }
        emitSectionText(body.substring(endStmtPrev + 1), funcText);
        if (state.stack.length != 0)
            throw new etc.ParseError(tmplName, state.line, "unclosed, unmatched statement(s): " + state.stack.join(","));
        funcText.push("}}; PodTrimPath_Template_TEMP");
        return funcText.join("");
    }
    var emitStatement = function(stmtStr, state, funcText, tmplName, etc) {
        var parts = stmtStr.slice(1, -1).split(' ');
        var stmt = etc.statementDef[parts[0]]; // Here, parts[0] == for/if/else/...
        if (stmt == null) {                    // Not a real statement.
            emitSectionText(stmtStr, funcText);
            return;
        }
        if (stmt.delta < 0) {
            if (state.stack.length <= 0)
                throw new etc.ParseError(tmplName, state.line, "close tag does not match any previous statement: " + stmtStr);
            state.stack.pop();
        } 
        if (stmt.delta > 0)
            state.stack.push(stmtStr);
        if (stmt.paramMin != null &&
            stmt.paramMin >= parts.length)
            throw new etc.ParseError(tmplName, state.line, "statement needs more parameters: " + stmtStr);
        if (stmt.prefixFunc != null)
            funcText.push(stmt.prefixFunc(parts, state, tmplName, etc));
        else 
            funcText.push(stmt.prefix);
        if (stmt.suffix != null) {
            if (parts.length <= 1) {
                if (stmt.paramDefault != null)
                    funcText.push(stmt.paramDefault);
            } else {
                for (var i = 1; i < parts.length; i++) {
                    if (i > 1)
                        funcText.push(' ');
                    funcText.push(parts[i]);
                }
            }
            funcText.push(stmt.suffix);
        }
    }
    var emitSectionText = function(text, funcText) {
        if (text.length <= 0)
            return;
        var nlPrefix = 0;               // Index to first non-newline in prefix.
        var nlSuffix = text.length - 1; // Index to first non-space/tab in suffix.
        while (nlPrefix < text.length && (text.charAt(nlPrefix) == '\n'))
            nlPrefix++;
        while (nlSuffix >= 0 && (text.charAt(nlSuffix) == ' ' || text.charAt(nlSuffix) == '\t'))
            nlSuffix--;
        if (nlSuffix < nlPrefix)
            nlSuffix = nlPrefix;
        if (nlPrefix > 0) {
            funcText.push('if (_FLAGS.keepWhitespace == true) _OUT.write("');
            var s = text.substring(0, nlPrefix).replace('\n', '\\n'); // A macro IE fix from BJessen.
            if (s.charAt(s.length - 1) == '\n')
            	s = s.substring(0, s.length - 1);
            funcText.push(s);
            funcText.push('");');
        }
        var lines = text.substring(nlPrefix, nlSuffix + 1).split('\n');
        for (var i = 0; i < lines.length; i++) {
            emitSectionTextLine(lines[i], funcText);
            if (i < lines.length - 1)
                funcText.push('_OUT.write("\\n");\n');
        }
        if (nlSuffix + 1 < text.length) {
            funcText.push('if (_FLAGS.keepWhitespace == true) _OUT.write("');
            var s = text.substring(nlSuffix + 1).replace('\n', '\\n');
            if (s.charAt(s.length - 1) == '\n')
            	s = s.substring(0, s.length - 1);
            funcText.push(s);
            funcText.push('");');
        }
    }
    var emitSectionTextLine = function(line, funcText) {
        var endMarkPrev = '}';
        var endExprPrev = -1;
        while (endExprPrev + endMarkPrev.length < line.length) {
            var begMark = "${", endMark = "}";
            var begExpr = line.indexOf(begMark, endExprPrev + endMarkPrev.length); // In "a${b}c", begExpr == 1
            if (begExpr < 0)
                break;
            if (line.charAt(begExpr + 2) == '%') {
                begMark = "${%";
                endMark = "%}";
            }
            var endExpr = line.indexOf(endMark, begExpr + begMark.length);         // In "a${b}c", endExpr == 4;
            if (endExpr < 0)
                break;
            emitText(line.substring(endExprPrev + endMarkPrev.length, begExpr), funcText);                
            var exprArr = line.substring(begExpr + begMark.length, endExpr).replace(/\|\|/g, "#@@#").split('|');
            for (var k in exprArr) {
                if (exprArr[k].replace) // IE 5.x fix from Igor Poteryaev.
                    exprArr[k] = exprArr[k].replace(/#@@#/g, '||');
            }
            funcText.push('_OUT.write(');
            emitExpression(exprArr, exprArr.length - 1, funcText); 
            funcText.push(');');
            endExprPrev = endExpr;
            endMarkPrev = endMark;
        }
        emitText(line.substring(endExprPrev + endMarkPrev.length), funcText); 
    }
    var emitText = function(text, funcText) {
        if (text == null ||
            text.length <= 0)
            return;
        text = text.replace(/\\/g, '\\\\');
        text = text.replace(/\n/g, '\\n');
        text = text.replace(/"/g,  '\\"');
        funcText.push('_OUT.write("');
        funcText.push(text);
        funcText.push('");');
    }
    var emitExpression = function(exprArr, index, funcText) {
        var expr = exprArr[index]; // Ex: exprArr == [firstName,capitalize,default:"John Doe"]
        if (index <= 0) {          // Ex: expr    == 'default:"John Doe"'
            funcText.push(expr);
            return;
        }
        var parts = expr.split(':');
        funcText.push('_MODIFIERS["');
        funcText.push(parts[0]); // The parts[0] is a modifier function name, like capitalize.
        funcText.push('"](');
        emitExpression(exprArr, index - 1, funcText);
        if (parts.length > 1) {
            funcText.push(',');
            funcText.push(parts[1]);
        }
        funcText.push(')');
    }
    var cleanWhiteSpace = function(result) {
        result = result.replace(/\t/g,   "    ");
        result = result.replace(/\r\n/g, "\n");
        result = result.replace(/\r/g,   "\n");
        result = result.replace(/^(\s*\S*(\s+\S+)*)\s*$/, '$1'); // Right trim by Igor Poteryaev.
        return result;
    }
    var scrubWhiteSpace = function(result) {
        result = result.replace(/^\s+/g,   "");
        result = result.replace(/\s+$/g,   "");
        result = result.replace(/\s+/g,   " ");
        result = result.replace(/^(\s*\S*(\s+\S+)*)\s*$/, '$1'); // Right trim by Igor Poteryaev.
        return result;
    }
    PodTrimPath.parseDOMTemplate = function(elementId, optDocument, optEtc) {
        if (optDocument == null)
            optDocument = document;
        var element = optDocument.getElementById(elementId);
        var content = element.value;     // Like textarea.value.
        if (content == null)
            content = element.innerHTML; // Like textarea.innerHTML.
        content = content.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
        return PodTrimPath.parseTemplate(content, elementId, optEtc);
    }
    PodTrimPath.processDOMTemplate = function(elementId, context, optFlags, optDocument, optEtc) {
        return PodTrimPath.parseDOMTemplate(elementId, optDocument, optEtc).process(context, optFlags);
    }
}) ();
/* Copyright (c) Pluck Corporation 2008. This software code and related intellectual property are the 
property of Pluck Corporation and are licensed for use solely on designated websites. Any distribution, 
copying, or other use of this intellectual property other than pursuant to a written agreement 
with Pluck Corporation is strictly prohibited. All Rights Reserved.
*/
(function(){
  if (typeof dmpod === 'undefined') {
    dmpod = {};
    dmpod.extendObject = function(obj, source) {
      for (var _var in source) {
        obj[_var] = source[_var];
      }
    }
    dmpod.extend = function(source) { dmpod.extendObject(dmpod, source); };
  };
  if (typeof dmpod.serviceFramework === 'undefined') {
    dmpod.serviceFramework = 1;
    var PODServiceDetails = {
      isIE: (navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Opera') == -1),
      getHost: function() { 
         var where = document.location.toString();
         if (where.match(/https/i)) {
           return 'https://pluckit.demandmedia.com/';
         } else {
           return 'http://pluckit.demandmedia.com/';
         }
      },
      getAssetsHost: function() { 
         var where = document.location.toString();
         if (where.match(/https/i)) {
           return 'https://pluckit.demandmedia.com/';
         } else {
           return 'http://cdn-docs.pluckit.pluck.com/';
         }
      },
      getServerUrl: function(apiKey, authToken) { var url = this.getHost()+'requests?apiKey=' + apiKey; if (typeof(authToken) !== 'undefined' && authToken != null) { url += '&at=' + escape(authToken); } return url; },
      getFlashTunnelUrl: function(apiKey) { return this.getHost()+'assets/v1/PluckFlashDAPIService.swf?apiKey=' + apiKey; },
      getFlashExpressInstallUrl: function(apiKey) { return this.getHost()+'assets/v1/expressinstall.swf?apiKey=' + apiKey; },
      getFlashFileUploaderUrl: function(apiKey) { return this.getHost()+'assets/v1/PluckItUploader.swf?apiKey=' + apiKey; },
      getFlashClipboardCopierUrl: function(apiKey) { return this.getHost()+'assets/v1/PluckItClipboard.swf?apiKey=' + apiKey; },
      prepareServerRequest: function(requests, service){
        if (requests.constructor != Array) { // handle single requests gracefully
          requests = [requests];
        }
        var envelopes = [];
        for (var i = 0, request; request = requests[i]; i++) {
          var envelope = new dmpod.RequestEnvelope();
          envelope.payloadType = request.objectType;
          envelope.payload = this.JSON.stringify(request);
          envelopes.push(envelope);
        }
        return {
            Envelopes: envelopes,
            returnDiagnostics: (service.debugging.on && service.debugging.firebug),
            executeMethod: requests.hasOwnProperty("executeMethod") ? requests.executeMethod : 'ExecuteAll'
        }
      },
      extractBatchResponse: function(response, service){
        if (typeof(response) == 'string') {
          if (response.indexOf("Envelopes") >= 0 || response.indexOf("envelopes") >= 0) {
            response = this.JSON.parse(response);
          } else {
            return response;
          }
        } else if (!response.hasOwnProperty("Envelopes")) {
          return response;
        }
        if (service.debugging.firebug && response.diagnostics != null) {
          console.group('RECEIVED DIAGNOSTICS FROM SERVER');
          console.dir(response.diagnostics);
          console.groupEnd();
        }
        var batchResponse = { Responses: [] };
        batchResponse.ContentTrackingJavaScript = response.ContentTrackingJavaScript;
        batchResponse.ContentTrackingSrc = response.ContentTrackingSrc;
        for (var i = 0, envelope; envelope = response.Envelopes[i]; i++) {
          batchResponse.Responses.push(this.JSON.parse(envelope.payload));
        }
        return batchResponse;
      },
      JSON: function(){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},s={'boolean':function(x){return String(x);},number:function(x){return isFinite(x)?String(x):'null';},string:function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}c=b.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);});}return'"'+x+'"';},object:function(x){if(x){var a=[],b,f,i,l,v;if(x instanceof Array){a[0]='[';l=x.length;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}a[a.length]=v;b=true;}}}a[a.length]=']';}else if(x instanceof Object){a[0]='{';for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}a.push(s.string(i));a.push(':');a.push(v);b=true;}}}a[a.length]='}';}else{return;}return a.join('');}return'null';}};return{copyright:'(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(v){var f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){return v;}}return null;},eval:function(text){try{return!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g,'')))&&eval('('+text+')');}catch(e){return false;}},parse:function(text){var at=0;var ch=' ';function error(m){throw{name:'JSONError',message:m,at:at-1,text:text};}function next(){ch=text.charAt(at);at+=1;return ch;}function white(){while(ch){if(ch<=' '){next();}else if(ch=='/'){switch(next()){case'/':while(next()&&ch!='\n'&&ch!='\r'){}break;case'*':next();for(;;){if(ch){if(ch=='*'){if(next()=='/'){next();break;}}else{next();}}else{error("Unterminated comment");}}break;default:error("Syntax error");}}else{break;}}}function string(){var i,s='',t,u;if(ch=='"'){outer:while(next()){if(ch=='"'){next();return s;}else if(ch=='\\'){switch(next()){case'b':s+='\b';break;case'f':s+='\f';break;case'n':s+='\n';break;case'r':s+='\r';break;case't':s+='\t';break;case'u':u=0;for(i=0;i<4;i+=1){t=parseInt(next(),16);if(!isFinite(t)){break outer;}u=u*16+t;}s+=String.fromCharCode(u);break;default:s+=ch;}}else{s+=ch;}}}error("Bad string");}function array(){var a=[];if(ch=='['){next();white();if(ch==']'){next();return a;}while(ch){a.push(value());white();if(ch==']'){next();return a;}else if(ch!=','){break;}next();white();}}error("Bad array");}function object(){var k,o={};if(ch=='{'){next();white();if(ch=='}'){next();return o;}while(ch){k=string();white();if(ch!=':'){break;}next();o[k]=value();white();if(ch=='}'){next();return o;}else if(ch!=','){break;}next();white();}}error("Bad object");}function number(){var n='',v;if(ch=='-'){n='-';next();}while(ch>='0'&&ch<='9'){n+=ch;next();}if(ch=='.'){n+='.';while(next()&&ch>='0'&&ch<='9'){n+=ch;}}if(ch=='e'||ch=='E'){n+='e';next();if(ch=='-'||ch=='+'){n+=ch;next();}while(ch>='0'&&ch<='9'){n+=ch;next();}}v=+n;if(!isFinite(v)){}else{return v;}}function word(){switch(ch){case't':if(next()=='r'&&next()=='u'&&next()=='e'){next();return true;}break;case'f':if(next()=='a'&&next()=='l'&&next()=='s'&&next()=='e'){next();return false;}break;case'n':if(next()=='u'&&next()=='l'&&next()=='l'){next();return null;}break;}error("Syntax error");}function value(){white();switch(ch){case'{':return object();case'[':return array();case'"':return string();case'-':return number();default:return ch>='0'&&ch<='9'?number():word();}}return value();}};}()
    }
    if (PODServiceDetails.isIE) {
      PODServiceDetails.JSON.parse = function(json) { return eval('('+json+')'); };
    }
    dmpod.createDAAPIRequestService = function(){
      return new PluckItService('00000000-0000-0000-0000-000000000000', DAAPIServiceDetails);
    };
    dmpod.createPODRequestService = function(apiKey) {
      return new PluckItService(apiKey, PODServiceDetails);
    }
    dmpod.createRequestService = function(apiKey) {
      return dmpod.createPODRequestService(apiKey); // default
    }
    dmpod.RequestServiceInstances = {};
    var PluckItService = function(){
      var debugging = 0;
      var match = location.search.match(new RegExp('[\?&]PLUCK_DEBUG=([^&]+)'));
      if (match) {
        debugging = match[1];
      } else if (typeof(_DEBUG) !== 'undefined') {
        debugging = _DEBUG;
      }
      if (debugging != false && debugging != 'false') {
        if (debugging == true || debugging == 'true') {
          debugging = 1;
        }
      } else {
        debugging = 0;
      }
      this.debugging = {
        level: debugging,
        on: debugging > 0,
        alerts: debugging > 1,
        firebug: false
      };
      if (typeof(window.console) !== 'undefined' && typeof(window.console.firebug) !== 'undefined') {
        try {
          if (parseFloat(window.console.firebug) >= 1.05 && document.location.toString().toLowerCase().indexOf('firebug=false') < 0) {
            this.debugging.firebug = true;
          }
        } catch (e) {
        }
      }
      this.init.apply(this, arguments);
    }
    PluckItService.prototype = (function(){
      function $(id){
        if (document.getElementById) {
          return document.getElementById(id);
        }
        if (document.all) {
          return document.all[id];
        }
      }
      var isIE = (navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Opera') == -1);
      var flashVersion = (function() {
          var versionNumber = 0;
          try {
            if (isIE) {
              try {
                activeXObject = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
                versionVariable = activeXObject.GetVariable('$version');
                versionNumber = versionVariable.match(/win[^\d]+?(\d+)[^\d].*/i)[1];
              } catch(e) {
              }
            }
            for (var i=0; i<navigator.plugins.length; i++) {
              var match = navigator.plugins[i].description.match(/shockwave flash.*?(\d+)[^\d].*/i);
              if (match != null && match.length == 2) {
                var version = parseInt(match[1]);
                if (version > versionNumber) {
                  versionNumber = version;
                }
              }
            }
          } catch(e) {
          }
          return versionNumber;
        })();
      var transport = "flash";
      if (typeof(PLUCKIT_TRANSPORT) !== 'undefined') {
        transport = PLUCKIT_TRANSPORT.toLowerCase();
      }
      var lowerurl = document.location.toString().toLowerCase();
      var m = lowerurl.match(new RegExp('pluckit_transport=([a-z]+)'));
      if (m && m.length > 0) {
        transport = m[1];
      }
      var jsonpmax = 4000;
      if (typeof(PLUCKIT_JSONPMAX) !== 'undefined') {
        jsonpmax = PLUCKIT_JSONPMAX;
      }
      m = lowerurl.match(new RegExp('pluckit_jsonpmax=([0-9]+)'));
      if (m && m.length > 0) {
        jsonpmax = m[1];
      }
      var flashNeeded = false;
      if (transport == "flashonly") {
        flashNeeded = flashVersion < 9;
      }
      return {
        constructor: PluckItService,
        FLASHONLY: "flashonly",
        JSONPONLY: "jsonponly",
        FLASH: "flash",
        JSONP: "jsonp",
        flashReady: false,
        jsonpReady: false,
        transport: transport,
        jsonpmax: jsonpmax,
        isIE: isIE,
        flashVersion: flashVersion, 
        flashNeeded: flashNeeded,
        init: function(apiKey, serviceDetails){
          this.serviceDetails = serviceDetails;
          this.apiKey = apiKey;
          this.requestQueue = [];
          this.instanceID = 'pluckit_' + this.uniqueID()
          this.jsonpCounter = Math.floor(Math.random()*0x7fffffff);
          this.callbackContexts = {};
          var my = this;
          this.initProxy = (function(my){
            return function(){
              var flashObject = document.body.appendChild(document.createElement('div'));
              flashObject.id = 'flashProxy_' + my.instanceID + '_DIV';
              if (my.transport == my.JSONPONLY) {
                flashObject.innerHTML = "&nbsp;";
                return;
              }
              var swfUrl = my.serviceDetails.getFlashTunnelUrl(my.apiKey);
              var swfId = 'flashProxy_' + my.instanceID;
              var swfWidth = '0';
              var swfHeight = '0';
              var swfVersion = '9.0.0';
              var params = {
                autostart: 'true',
                width: swfWidth,
                height: swfHeight,
                allowfullscreen: 'false',
                allowscriptaccess: 'always'
              };
              var attributes = {};
              window[my.instanceID+'flashready'] = function() { my.flashReadyCallback(); };
              window[my.instanceID+'flashstatus'] = function(status) { my.flashReadyCallback(status); };
              var podRevisionNumber = "7034";
              var fvars = 'onLoadCallbackName='+my.instanceID+'flashready&onStatusCallbackName='+my.instanceID+'flashstatus&podRevisionNumber='+podRevisionNumber;
              my.loadFlashCount = 0;
              my.loadFlash = function() {
                if (my.loadFlashCount <= 1) { // allow one addition load
                  my.loadFlashCount++;
                  my.flashReady = false;
                  my.safeEmbedSWF(flashObject, swfId, swfUrl, swfWidth, swfHeight, fvars, swfVersion, my.serviceDetails.getFlashExpressInstallUrl(my.apiKey));
                }
              }
              my.loadFlash();
            };
          })(my);
          this.serverUrl = my.serviceDetails.getServerUrl(my.apiKey,my.getUserAuthToken());
          dmpod.RequestServiceInstances[this.instanceID] = this;
          if (my.transport != my.FLASHONLY) {
            my.jsonpReady = true;
            my.processQueue();
          }
          if (document.body && ((typeof document.readyState == 'undefined') || /loaded|complete/.test(document.readyState))) { // setup the proxy
            this.initProxy();
          } else {
            this.addLoadEvent(this.initProxy);
          }
        },
        debug: function(data) {
          if (this.debugging.on) {
            if (window.opera) {
              opera.postError(data);
            } else if (window.console) {
              console.log(data);
            } else if (this.debugging.alerts) {
              alert(data);
            }
          }
        },
        getSafeEmbedSWFHTML: function(swfId, swfUrl, width, height, flashvars, version, expressInstallUrl) {
          var ie=(navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Opera') == -1);
          if (ie) {
            return '<OBJECT id='+swfId+' height='+height+' width='+width+' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000> \
              <PARAM NAME="FlashVars" VALUE="'+flashvars+'">\
              <PARAM NAME="Movie" VALUE="'+swfUrl+'&'+flashvars+'">\
              <PARAM NAME="Src" VALUE="'+swfUrl+'&'+flashvars+'">\
              <PARAM NAME="AllowScriptAccess" VALUE="always">\
              <PARAM NAME="AllowNetworking" VALUE="all">\
              <PARAM NAME="AllowFullScreen" VALUE="false">\
              <PARAM NAME="wmode" VALUE="window">\
              <PARAM NAME="Width" VALUE="'+width+'">\
              <PARAM NAME="Height" VALUE="'+height+'">\
              </OBJECT>';
          } else {
            return '<object id="'+swfId+'" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" data="'+swfUrl+'" style="visibility: visible;">\
              <param name="autostart" value="true"/>\
              <param name="width" value="'+width+'"/>\
              <param name="height" value="'+height+'"/>\
              <param name="allowfullscreen" value="false"/>\
              <param name="allowscriptaccess" value="always"/>\
              <param name="wmode" value="window"/>\
              <param name="flashvars" value="'+flashvars+'"/>\
              </object>';              
          }
        },
        safeEmbedSWF: function(hostObj, swfId, swfUrl, width, height, flashvars, version, expressInstallUrl) {
          hostObj.innerHTML = this.getSafeEmbedSWFHTML(swfId, swfUrl, width, height, flashvars, version, expressInstallUrl);
        },
        processQueue: function(){
          if (this.requestQueue.length > 0) {
            var func = this.requestQueue.pop();
            if (!func()) {
              this.requestQueue.push(func);
              var self = this;
              setTimeout(function() { self.processQueue(); }, 1000);
            }
          }
        },
        registerCallbackContext: function(context){
          var asyncToken = 'request_' + this.uniqueID();
          this.callbackContexts[asyncToken] = context;
          return asyncToken;
        },
        uniqueID: function() {
          var seed = (new Date()).getTime();
          return Math.floor(Math.random() * seed);// + '_' + Math.floor(Math.random() * seed);
        },
        DownloadUrl: function(serverUrl, queryString, callback){
          var me = this;
          this.requestQueue.push(function(){
            return me.doDownload(serverUrl, queryString, callback);
          });
          this.debug('[DownloadUrl/id:' + this.instanceID + '] queuing request -- total: ' + this.requestQueue.length);
          this.processQueue();
        },
        doDownload: function(serverUrl, queryString, callback){
          if (this.flashReady) {
            var asyncToken = this.registerCallbackContext({ callback: callback });
            if (queryString) {
              queryString = escape(queryString);
            }
            this.flashProxy.DownloadUrl(serverUrl, queryString, 'dmpod.RequestServiceInstances[\'' + this.instanceID + '\'].flashRequestCallback', asyncToken);
            return true;
          }
          return false;
        },
        PostForm: function(serverUrl, queryString, callback){
          var me = this;
          this.requestQueue.push(function(){
            return me.doPost(serverUrl, queryString, callback);
          });
          this.debug('[PostForm/id:' + this.instanceID + '] queuing request -- total: ' + this.requestQueue.length);
          this.processQueue();
        },
        doPost: function(serverUrl, queryString, callback){
          if (this.flashReady) {
            var asyncToken = this.registerCallbackContext({ callback: callback });
            if (queryString) {
              queryString = escape(queryString);
            }
            this.flashProxy.PostForm(serverUrl, queryString, 'dmpod.RequestServiceInstances[\'' + this.instanceID + '\'].flashRequestCallback', asyncToken,document.location.toString());
            return true;
          }
          return false;
        },
        SendRequests: function(requests, callback){
          if (requests) {
            if (requests.constructor != Array) { // handle single requests gracefully
              requests = [requests];
            }
            if (requests.length > 0) {
              var me = this;
              this.requestQueue.push(function() { return me.transmitRequests(requests, callback, false); });
              this.processQueue();
              return;
            }
          }
          this.debug("asked to send 0 requests");
        },
        transmitRequests: function(requests, context, useJsonp){
          if (!context.hasOwnProperty("asyncToken")) {
            context = { isBatchResponse: 1, callback: context }
            context.asyncToken = this.registerCallbackContext(context);
          }
          var method = null;
          if (useJsonp) {
            method = this.JSONP;
          } else {
            var flash = this.flashReady ? (typeof(this.flashProxy.CallDAPI) !== 'undefined') : false;
            var jsonp = this.jsonpReady;
            if (this.transport == this.JSONPONLY) {
              method = jsonp ? this.JSONP : null;
            } else if (this.transport == this.FLASHONLY) {
              method = flash ? this.FLASH : null;
            } else if (this.transport == this.FLASH) {
              if (flash) {
                method = this.FLASH;
              } else if (jsonp) {
                method = this.JSONP;
              }
            } else if (jsonp) {
              method = this.JSONP;
            } else if (flash) {
              method = flash;
            }
            if (method == null) {
              return false;
            }
          }
          context.method = method;
          if (this.debugging.on) {
            if (this.debugging.firebug) {
              console.group(method+': SENDING REQUESTS TO SERVER - %s', context.asyncToken);
              for (var i=0;i<requests.length;i++) { 
                console.group(requests[i].objectType); 
                console.dir(requests[i]);
                console.groupEnd(); 
              }
              console.groupEnd();
              console.time(context.asyncToken);
            }
          }
          if (method == this.FLASH) {
            var jsonRequest = this.serviceDetails.JSON.stringify(this.serviceDetails.prepareServerRequest(requests, this));
            this.flashProxy.CallDAPI(this.serverUrl, jsonRequest, 'dmpod.RequestServiceInstances[\'' + this.instanceID + '\'].flashRequestCallback', context.asyncToken,document.location.toString());
            return true;
          }
          this.buildJsonpRequest(context, requests);
          context.elem = null;
          context.scriptNode = null;
          context.elem = document.getElementsByTagName('head')[0];
          context.scriptNode = document.createElement('script');
          context.scriptNode.type = "text/javascript";
          context.scriptNode.src = this.serverUrl+'&jsonpCallback=dmpod.RequestServiceInstances[\'' + this.instanceID + '\'].jsonpCallback&jsonpContext='+context.asyncToken+'&jsonRequest='+escape(context.jsonRequest);
          context.elem.appendChild(context.scriptNode);
          return true;
        },
        buildJsonpRequest: function(context, requests) {
          var split = 1;
          var pos = requests.length / split;
          var set = requests;
          var maxurl = this.isIE ? 1500 : this.jsonpmax;
          do {
            context.jsonRequest = this.serviceDetails.JSON.stringify(this.serviceDetails.prepareServerRequest(set, this));
            if (set.length > 1) {
              if (escape(context.jsonRequest).length > maxurl && pos > 0) {
                split++;
                pos = requests.length / split;
                set = requests.slice(0, pos);
                context.moreRequests = requests.slice(pos);
              } else {
                break;
              }
            } else {
              break;
            }
          } while (true);
        },
        flashReadyCallback: function(){
          var proxy = $('flashProxy_' + this.instanceID);
          if (proxy != null && typeof(proxy.CallDAPI) !== 'undefined') {
            this.debug('flash is ready');
            this.flashProxy = proxy;
            this.flashReady = true;
            this.processQueue();
          } else {
            this.debug('Flash ready failed!');
          }
        },
        flashStatusCallback: function(status){
          this.debug('flash proxy status: '+status);
        },
        flashRequestCallback: function(successful, response, asyncToken){
          this.processRequestResponse(this.FLASH, successful, response, asyncToken);
        },
        jsonpCallback: function(response, asyncToken){
          var context = this.callbackContexts[asyncToken];
          delete context.elem;
          delete context.scriptNode;
          if (context.hasOwnProperty("response")) {
            context.response.isError = context.response.isError || response.isError;
            context.response.Envelopes = context.response.Envelopes.concat(response.Envelopes);
          } else {
            context.response = response;
          }
          if (context.hasOwnProperty("moreRequests")) {
            var requests = context.moreRequests;
            delete context.moreRequests;
            this.transmitRequests(requests, context, true);
          } else {
            this.processRequestResponse(this.JSONP, true, context.response, asyncToken);
          }
        },
        processRequestResponse: function(transport, successful, response, asyncToken){
          if (this.debugging.on && this.debugging.firebug) { console.timeEnd(asyncToken); }
          try {
            if (!successful) {
              this.onError('Communication error: '+response);
              return;
            }
            var context = this.callbackContexts[asyncToken];
            if (typeof(response) == 'string') {
              response = unescape(response);
            }
            if (context.hasOwnProperty("isBatchResponse")) {
              response = this.serviceDetails.extractBatchResponse(response, this);
              if (this.debugging.on && this.debugging.firebug) {
                console.group(transport+': RECEIVED RESPONSES FROM SERVER - %s', asyncToken);
                for (var i=0;i<response.Responses.length;i++) { console.group(response.Responses[i].objectType); console.dir(response.Responses[i]); console.groupEnd(); }
                console.groupEnd();
              }
            } else {
              this.debug(transport+': RECEIVED DATA FROM SERVER - ', asyncToken);
            }
            context.callback(response);
            delete this.callbackContexts[asyncToken];
          } catch (e) {
            this.onError(e);
            this.debug('exception: ',e.toString());
          }
        },
        addLoadEvent: function(func){
          if (window.addEventListener) 
            window.addEventListener('load', func, false);
          else 
            if (window.attachEvent) 
              window.attachEvent('onload', func);
            else { /* epic fail */
            }
        },
        getClipboardCopierHTML: function(flashId, getClipboardTextCallback, width, height, buttonUrl) {
          var swfUrl = this.serviceDetails.getFlashClipboardCopierUrl(this.apiKey);
          var flashvars = "getClipboardTextCallback="+getClipboardTextCallback+"&buttonUrl="+encodeURIComponent(buttonUrl);
          return this.getSafeEmbedSWFHTML(flashId, swfUrl, width, height, flashvars, '9.0.0', this.serviceDetails.getFlashExpressInstallUrl(this.apiKey));
        },
        getFileUploaderHTML: function(flashId, onLoadCallbackName, width, height, buttonUrl) {
          var swfUrl = this.serviceDetails.getFlashFileUploaderUrl(this.apiKey);
          var flashvars = "onLoadCallbackName="+onLoadCallbackName+"&buttonUrl="+encodeURIComponent(buttonUrl);
          return this.getSafeEmbedSWFHTML(flashId, swfUrl, width, height, flashvars, '9.0.0', this.serviceDetails.getFlashExpressInstallUrl(this.apiKey));
        },
        uploadFile: function(flashId, serverUrl, mediaTypesPrompt, mediaTypesFilter, callerThis, responseCallback, progressCallback) {
          var response = 'callback'+this.uniqueID();
          var progress = 'callback'+this.uniqueID();
          window[response] = function(success, data) {
            responseCallback.apply(callerThis,arguments);
          };
          window[progress] = function(percent) {
            progressCallback.apply(callerThis,arguments);
          };
          document.getElementById(flashId).PerformUpload(serverUrl,mediaTypesPrompt,mediaTypesFilter,response,progress);
        },
        JsonStringify: function(what){
          return this.serviceDetails.JSON.stringify(what);
        },
        JsonParse: function(what){
          return this.serviceDetails.JSON.parse(what);
        },
        getHost: function() {
          return this.serviceDetails.getHost();
        },
        getAssetsHost: function() {
          return this.serviceDetails.getAssetsHost();
        },
        getClientCookieName: function(){
          if (typeof PLUCKIT_CLIENTCOOKIENAME != 'undefined') {
            return PLUCKIT_CLIENTCOOKIENAME;
          } else {
            return 'piat';
          }
        },
        isUserLoggedIn: function(){
          return typeof(this.getUserAuthToken()) !== 'undefined';
        },
        getUserAuthToken: function(){
          var cookies = document.cookie;
          if (cookies) {
            cookies = ";" + cookies + ";";
            var matches = cookies.match(new RegExp(';\\s*' + this.getClientCookieName() + '=(.+?);'));
            if (matches && matches.length > 1) {
              return matches[1];
            }
          }
        },
        setUserAuthToken: function(token){
          if (token) {
            document.cookie = this.getClientCookieName() + '=' + escape(token) + '; path=/;';
          } else {
            var d = new Date();
            d.setTime(d.getTime() - 86400000 /* 1 earth day */);
            document.cookie = this.getClientCookieName() + '=; expires=' + d.toGMTString() + '; path=/;';
            ;
          }
          this.serverUrl = this.serviceDetails.getServerUrl(this.apiKey,escape(token));
        },
        getCookieValue: function(cookieName){
          var cookies = document.cookie;
          if (cookies) {
            cookies = ";" + cookies + ";";
            var matches = cookies.match(new RegExp(';\\s*' + cookieName + '=(.+?);'));
            if (matches && matches.length > 1) {
              return matches[1];
            }
          }
        },
        setCookieValue: function(cookieName, cookieValue, expiresDay){
            var d = new Date();
            d.setTime(d.getTime() + (expiresDay * 86400000));        
            document.cookie = cookieName + '=' + cookieValue + '; expires=' + d.toGMTString();
        },        
        changeApiKey: function(apiKey){
          this.apiKey = apiKey;
          this.serverUrl = this.serviceDetails.getServerUrl(this.apiKey,this.getUserAuthToken());
        },
        onError: function(e){
          this.debug('Error: ' + e);
          if (this.debugging.on && this.debugging.firebug) {
            console.trace();
          }
        }
      };
    })();
  }
})();
(function() {
  /* Demand Media Javascript Library Request Objects */
  dmpod.extend({
    UpdateContentSourceRequest: function(contentSource) {
      this.contentSource = contentSource;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateContentSourceRequest';
    },
    UpdateCustomerUserContentModeRequest: function(userContentMode) {
      this.userContentMode = userContentMode;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateCustomerUserContentModeRequest';
    },
    UpdateCustomerSDKAccessRequest: function(sdkAccessAllowed) {
      this.sdkAccessAllowed = sdkAccessAllowed;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateCustomerSDKAccessRequest';
    },
    UpdateCustomerSocialMediaAccessRequest: function(socialMediaEnabled) {
      this.socialMediaEnabled = socialMediaEnabled;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateCustomerSocialMediaAccessRequest';
    },
    UpdateCustomerSupportInfoRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateCustomerSupportInfoRequest';
    },
    UpdateCustomerNetworkRequest: function(publisherNetwork) {
      this.publisherNetwork = publisherNetwork;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateCustomerNetworkRequest';
    },
    GetAllContentSourcesRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetAllContentSourcesRequest';
    },
    MakeUserPluckAdminRequest: function(password, userKey) {
      this.password = password;
      this.userKey = userKey;
      this.callerSDK = 'js';
      this.objectType = 'Admin.MakeUserPluckAdminRequest';
    },
    GetCaptchaInfoRequest: function(width, height) {
      this.width = width;
      this.height = height;
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetCaptchaInfoRequest';
    },
    UpdateAllowedContentSourcesForWriteRequest: function(userKey, contentSourceKeys) {
      this.userKey = userKey;
      this.contentSourceKeys = contentSourceKeys;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateAllowedContentSourcesForWriteRequest';
    },
    UpdateAllowedContentSourcesForReadRequest: function(contentSourceKeys) {
      this.contentSourceKeys = contentSourceKeys;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UpdateAllowedContentSourcesForReadRequest';
    },
    GenerateNewCustomerKeyRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Admin.GenerateNewCustomerKeyRequest';
    },
    GetKeyForUserRequest: function(userEmail) {
      this.userEmail = userEmail;
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetKeyForUserRequest';
    },
    GetLoginTokenRequest: function(userEmail, password) {
      this.userEmail = userEmail;
      this.password = password;
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetLoginTokenRequest';
    },
    VerifyUsersPublisherNetworkRequest: function(network) {
      this.network = network;
      this.callerSDK = 'js';
      this.objectType = 'Admin.VerifyUsersPublisherNetworkRequest';
    },
    UnlockUserRequest: function(userEmail, newPassword) {
      this.userEmail = userEmail;
      this.newPassword = newPassword;
      this.callerSDK = 'js';
      this.objectType = 'Admin.UnlockUserRequest';
    },
    GetApiKeysRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetApiKeysRequest';
    },
    GetAssociatedCustomersRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetAssociatedCustomersRequest';
    },
    RegisterUserRequest: function(displayName, userEmail, password) {
      this.displayName = displayName;
      this.userEmail = userEmail;
      this.password = password;
      this.callerSDK = 'js';
      this.objectType = 'Admin.RegisterUserRequest';
    },
    MakeUserCustomerAdminRequest: function(userKey, apiKey) {
      this.userKey = userKey;
      this.apiKey = apiKey;
      this.callerSDK = 'js';
      this.objectType = 'Admin.MakeUserCustomerAdminRequest';
    },
    ResetPasswordRequest: function(userEmail) {
      this.userEmail = userEmail;
      this.callerSDK = 'js';
      this.objectType = 'Admin.ResetPasswordRequest';
    },
    ChangePasswordRequest: function(userKey, oldPassword, newPassword) {
      this.userKey = userKey;
      this.oldPassword = oldPassword;
      this.newPassword = newPassword;
      this.callerSDK = 'js';
      this.objectType = 'Admin.ChangePasswordRequest';
    },
    GetEnabledDomainsForCustomerRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Admin.GetEnabledDomainsForCustomerRequest';
    },
    EnableDomainForCustomerRequest: function(domain) {
      this.domain = domain;
      this.callerSDK = 'js';
      this.objectType = 'Admin.EnableDomainForCustomerRequest';
    },
    DisableDomainForCustomerRequest: function(domain) {
      this.domain = domain;
      this.callerSDK = 'js';
      this.objectType = 'Admin.DisableDomainForCustomerRequest';
    },
    AddDomainToExceptionListRequest: function(exceptionList, domain, reason) {
      this.exceptionList = exceptionList;
      this.domain = domain;
      this.reason = reason;
      this.callerSDK = 'js';
      this.objectType = 'Admin.AddDomainToExceptionListRequest';
    },
    RemoveDomainFromExceptionListRequest: function(exceptionList, domain) {
      this.exceptionList = exceptionList;
      this.domain = domain;
      this.callerSDK = 'js';
      this.objectType = 'Admin.RemoveDomainFromExceptionListRequest';
    },
    CreateBundleTemplateListRequest: function(name) {
      this.name = name;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.CreateBundleTemplateListRequest';
    },
    GetBundleTemplateListRequest: function(bundleTemplateListKey) {
      this.bundleTemplateListKey = bundleTemplateListKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.GetBundleTemplateListRequest';
    },
    MoveBundleTemplateListRequest: function(bundleTemplateListKey, parentKey) {
      this.bundleTemplateListKey = bundleTemplateListKey;
      this.parentKey = parentKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.MoveBundleTemplateListRequest';
    },
    UpdateBundleTemplateAliasRequest: function(aliasKey, bundleTemplateKey) {
      this.aliasKey = aliasKey;
      this.bundleTemplateKey = bundleTemplateKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.UpdateBundleTemplateAliasRequest';
    },
    DeleteBundleTemplateAliasRequest: function(aliasKey) {
      this.aliasKey = aliasKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.DeleteBundleTemplateAliasRequest';
    },
    GetBundleTemplateAliasesRequest: function(bundleTemplateKey) {
      this.bundleTemplateKey = bundleTemplateKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.GetBundleTemplateAliasesRequest';
    },
    UpdateBundleTemplateListRequest: function(bundleTemplateListKey, name) {
      this.bundleTemplateListKey = bundleTemplateListKey;
      this.name = name;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.UpdateBundleTemplateListRequest';
    },
    DeleteBundleTemplateListRequest: function(bundleTemplateListKey) {
      this.bundleTemplateListKey = bundleTemplateListKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.DeleteBundleTemplateListRequest';
    },
    MoveBundleTemplateRequest: function(bundleTemplateKey, parentKey) {
      this.bundleTemplateKey = bundleTemplateKey;
      this.parentKey = parentKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.MoveBundleTemplateRequest';
    },
    CreateBundleTemplateRequest: function(parentKey, name, criteria) {
      this.parentKey = parentKey;
      this.name = name;
      this.criteria = criteria;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.CreateBundleTemplateRequest';
    },
    UpdateBundleTemplateRequest: function(bundleTemplateKey, name, criteria) {
      this.bundleTemplateKey = bundleTemplateKey;
      this.name = name;
      this.criteria = criteria;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.UpdateBundleTemplateRequest';
    },
    UpdateCustomDataRequest: function(key, customData) {
      if (key.constructor != dmpod.BaseKey) {
        var typeName = (typeof key.objectType == 'string') && key.objectType.split('.')[1],
            key = new dmpod.BaseKey(key.key, typeName || null);
      }
      this.key = key;
      this.customData = customData;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.UpdateCustomDataRequest';
    },
    DeleteBundleTemplateRequest: function(bundleTemplateKey) {
      this.bundleTemplateKey = bundleTemplateKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.DeleteBundleTemplateRequest';
    },
    GetBundleTemplateRequest: function(bundleTemplateKey) {
      this.bundleTemplateKey = bundleTemplateKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.GetBundleTemplateRequest';
    },
    GetBundleTemplateByAliasRequest: function(aliasKey) {
      this.aliasKey = aliasKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.GetBundleTemplateByAliasRequest';
    },
    GetBundleRequest: function(bundleId) {
      this.bundleId = bundleId;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.GetBundleRequest';
    },
    DeleteContentActionRequest: function(deleteThisContentKey) {
      if (deleteThisContentKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof deleteThisContentKey.objectType == 'string') && deleteThisContentKey.objectType.split('.')[1],
            deleteThisContentKey = new dmpod.BaseKey(deleteThisContentKey.key, typeName || null);
      }
      this.deleteThisContentKey = deleteThisContentKey;
      this.callerSDK = 'js';
      this.objectType = 'Common.DeleteContentActionRequest';
    },
    HardDeleteContentActionRequest: function(deleteThisContentKey) {
      if (deleteThisContentKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof deleteThisContentKey.objectType == 'string') && deleteThisContentKey.objectType.split('.')[1],
            deleteThisContentKey = new dmpod.BaseKey(deleteThisContentKey.key, typeName || null);
      }
      this.deleteThisContentKey = deleteThisContentKey;
      this.callerSDK = 'js';
      this.objectType = 'Common.HardDeleteContentActionRequest';
    },
    GetArticlesRelatedToUrlRequest: function(url) {
      this.url = url;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetArticlesRelatedToUrlRequest';
    },
    GetArticlesRelatedToArticleRequest: function(articleId) {
      this.articleId = articleId;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetArticlesRelatedToArticleRequest';
    },
    GetArticlesRelatedToTagRequest: function(tag) {
      this.tag = tag;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetArticlesRelatedToTagRequest';
    },
    GetArticlesRelatedToTextRequest: function(text) {
      this.text = text;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetArticlesRelatedToTextRequest';
    },
    GetTagsForUrlRequest: function(url) {
      this.url = url;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetTagsForUrlRequest';
    },
    GetTagsForArticleRequest: function(articleId) {
      this.articleId = articleId;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetTagsForArticleRequest';
    },
    GetTagsForTagRequest: function(tag) {
      this.tag = tag;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetTagsForTagRequest';
    },
    GetTagsForTextRequest: function(text) {
      this.text = text;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetTagsForTextRequest';
    },
    GetPublisherLinksRelatedToUrlRequest: function(linkSource, url) {
      this.linkSource = linkSource;
      this.url = url;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetPublisherLinksRelatedToUrlRequest';
    },
    GetPublisherLinksRelatedToArticleRequest: function(linkSource, articleId) {
      this.linkSource = linkSource;
      this.articleId = articleId;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetPublisherLinksRelatedToArticleRequest';
    },
    GetPublisherLinksRelatedToTagRequest: function(linkSource, tag) {
      this.linkSource = linkSource;
      this.tag = tag;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetPublisherLinksRelatedToTagRequest';
    },
    GetPublisherLinksRelatedToTextRequest: function(linkSource, text) {
      this.linkSource = linkSource;
      this.text = text;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetPublisherLinksRelatedToTextRequest';
    },
    GetAdsForArticleRequest: function(articleId, adFormats) {
      this.articleId = articleId;
      this.adFormats = adFormats;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetAdsForArticleRequest';
    },
    GetAdsRequest: function(adFormats) {
      this.adFormats = adFormats;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetAdsRequest';
    },
    GetSponsoredLinksRequest: function(numberOfLinks) {
      this.numberOfLinks = numberOfLinks;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetSponsoredLinksRequest';
    },
    GetRelatedAdLinksRequest: function(pageUrl) {
      this.pageUrl = pageUrl;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetRelatedAdLinksRequest';
    },
    GetArticleRequest: function(articleId) {
      this.articleId = articleId;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetArticleRequest';
    },
    GetExternalUrlContentRequest: function(contentLabel, relativePath) {
      this.contentLabel = contentLabel;
      this.relativePath = relativePath;
      this.callerSDK = 'js';
      this.objectType = 'Content.GetExternalUrlContentRequest';
    },
    GetContentCategoriesRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Content.GetContentCategoriesRequest';
    },
    SearchArticlesRequest: function(query) {
      this.query = query;
      this.callerSDK = 'js';
      this.objectType = 'Content.SearchArticlesRequest';
    },
    SearchArticlesFilteredRequest: function(query) {
      this.query = query;
      this.callerSDK = 'js';
      this.objectType = 'Content.SearchArticlesFilteredRequest';
    },
    BlockArticleRequest: function(articleKey) {
      this.articleKey = articleKey;
      this.callerSDK = 'js';
      this.objectType = 'Content.BlockArticleRequest';
    },
    BlockPublisherLinkRequest: function(publisherLinkKey) {
      this.publisherLinkKey = publisherLinkKey;
      this.callerSDK = 'js';
      this.objectType = 'Content.BlockPublisherLinkRequest';
    },
    FindArticlesByKeywordsRequest: function(keywords, criteria) {
      this.keywords = keywords;
      this.criteria = criteria;
      this.callerSDK = 'js';
      this.objectType = 'Content.FindArticlesByKeywordsRequest';
    },
    FindArticlesSimilarToTextRequest: function(text, criteria) {
      this.text = text;
      this.criteria = criteria;
      this.callerSDK = 'js';
      this.objectType = 'Content.FindArticlesSimilarToTextRequest';
    },
    FindArticlesSimilarToArticleRequest: function(articleKey, criteria) {
      this.articleKey = articleKey;
      this.criteria = criteria;
      this.callerSDK = 'js';
      this.objectType = 'Content.FindArticlesSimilarToArticleRequest';
    },
    UpdateArticleRequest: function(publisherId, contentSourceKey, title, content, url, thumbnailUrl) {
      this.publisherId = publisherId;
      this.contentSourceKey = contentSourceKey;
      this.title = title;
      this.content = content;
      this.url = url;
      this.thumbnailUrl = thumbnailUrl;
      this.callerSDK = 'js';
      this.objectType = 'ContentRegistry.UpdateArticleRequest';
    },
    GetArticleByPublisherIdRequest: function(sourceKey, publisherId) {
      this.sourceKey = sourceKey;
      this.publisherId = publisherId;
      this.callerSDK = 'js';
      this.objectType = 'ContentRegistry.GetArticleByPublisherIdRequest';
    },
    RegisterUsersCustomerAccountRequest: function(apiKey, domain, customerType, publisherNetwork, inlineTextAdsAllowed, userContentMode, mpaaRating, captchaId, captchaText) {
      this.apiKey = apiKey;
      this.domain = domain;
      this.customerType = customerType;
      this.publisherNetwork = publisherNetwork;
      this.inlineTextAdsAllowed = inlineTextAdsAllowed;
      this.userContentMode = userContentMode;
      this.mpaaRating = mpaaRating;
      this.captchaId = captchaId;
      this.captchaText = captchaText;
      this.callerSDK = 'js';
      this.objectType = 'Customers.RegisterUsersCustomerAccountRequest';
    },
    GetCustomerRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.GetCustomerRequest';
    },
    GetCustomerByResellerIdRequest: function(publisherNetwork, publisherSubNetwork, resellerCustomerId) {
      this.publisherNetwork = publisherNetwork;
      this.publisherSubNetwork = publisherSubNetwork;
      this.resellerCustomerId = resellerCustomerId;
      this.callerSDK = 'js';
      this.objectType = 'Customers.GetCustomerByResellerIdRequest';
    },
    UpdateCustomerRequest: function(domain) {
      this.domain = domain;
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdateCustomerRequest';
    },
    UpdateCustomerAdDetailsRequest: function(inlineTextAdsAllowed, sponsoredLinksAllowed) {
      this.inlineTextAdsAllowed = inlineTextAdsAllowed;
      this.sponsoredLinksAllowed = sponsoredLinksAllowed;
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdateCustomerAdDetailsRequest';
    },
    UpdateCustomerDeploymentDetailsRequest: function() { /* This function has been deprecated. */
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdateCustomerDeploymentDetailsRequest';
    },
    UpdateCustomerPlatformRequest: function(platform) {
      this.platform = platform;
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdateCustomerPlatformRequest';
    },
    UpdateCustomerLandingPageUrlRequest: function(widgetLandingPageUrl, forDomain) {
      this.widgetLandingPageUrl = widgetLandingPageUrl;
      this.forDomain = forDomain;
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdateCustomerLandingPageUrlRequest';
    },
    ClearCustomerLandingPageUrlRequest: function(forDomain) {
      this.forDomain = forDomain;
      this.callerSDK = 'js';
      this.objectType = 'Customers.ClearCustomerLandingPageUrlRequest';
    },
    UseGlobalDefaultLandingPageUrlRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.UseGlobalDefaultLandingPageUrlRequest';
    },
    GetCustomerLandingPageUrlsRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.GetCustomerLandingPageUrlsRequest';
    },
    UpdateAdNetworksRequest: function(activeAdNetworks, adNetworkDetails) {
      this.activeAdNetworks = activeAdNetworks;
      this.adNetworkDetails = adNetworkDetails;
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdateAdNetworksRequest';
    },
    GetAdNetworksRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.GetAdNetworksRequest';
    },
    UpdatePaymentSystemsRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.UpdatePaymentSystemsRequest';
    },
    GetPaymentSystemsRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.GetPaymentSystemsRequest';
    },
    GetCustomerSearchRecordsRequest: function(numberPerPage, onPage, sort) {
      this.numberPerPage = numberPerPage;
      this.onPage = onPage;
      this.sort = sort;
      this.callerSDK = 'js';
      this.objectType = 'Customers.GetCustomerSearchRecordsRequest';
    },
    GetUserRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Users.GetUserRequest';
    },
    UpdateUserRequest: function(displayName) {
      this.displayName = displayName;
      this.callerSDK = 'js';
      this.objectType = 'Users.UpdateUserRequest';
    },
    BlockUserRequest: function(userKey) {
      this.userKey = userKey;
      this.callerSDK = 'js';
      this.objectType = 'Users.BlockUserRequest';
    },
    CheckDomainAgainstExceptionListRequest: function(exceptionList, domain) {
      this.exceptionList = exceptionList;
      this.domain = domain;
      this.callerSDK = 'js';
      this.objectType = 'Customers.CheckDomainAgainstExceptionListRequest';
    },
    GetMediaItemRequest: function(mediaItemKey) {
      this.mediaItemKey = mediaItemKey;
      this.callerSDK = 'js';
      this.objectType = 'Media.GetMediaItemRequest';
    },
    GetMediaGalleryRequest: function(mediaGalleryKey) {
      this.mediaGalleryKey = mediaGalleryKey;
      this.callerSDK = 'js';
      this.objectType = 'Media.GetMediaGalleryRequest';
    },
    GetMediaItemPageRequest: function(mediaGalleryKey, submissionState, numberPerPage, onPage, sort) {
      this.mediaGalleryKey = mediaGalleryKey;
      this.submissionState = submissionState;
      this.numberPerPage = numberPerPage;
      this.onPage = onPage;
      this.sort = sort;
      this.callerSDK = 'js';
      this.objectType = 'Media.GetMediaItemPageRequest';
    },
    UpdateMediaItemActionRequest: function(mediaItemKey, title, description, tags, attribution, attributionDate, attributionEmail) {
      this.mediaItemKey = mediaItemKey;
      this.title = title;
      this.description = description;
      this.tags = tags;
      this.attribution = attribution;
      this.attributionDate = attributionDate;
      this.attributionEmail = attributionEmail;
      this.callerSDK = 'js';
      this.objectType = 'Media.UpdateMediaItemActionRequest';
    },
    UpdateMediaGalleryActionRequest: function(mediaGalleryKey, title, description, tags) {
      this.mediaGalleryKey = mediaGalleryKey;
      this.title = title;
      this.description = description;
      this.tags = tags;
      this.callerSDK = 'js';
      this.objectType = 'Media.UpdateMediaGalleryActionRequest';
    },
    UpdateMediaGalleryPromotionActionRequest: function(mediaGalleryKey, mediaItemKey) {
      this.mediaGalleryKey = mediaGalleryKey;
      this.mediaItemKey = mediaItemKey;
      this.callerSDK = 'js';
      this.objectType = 'Media.UpdateMediaGalleryPromotionActionRequest';
    },
    UpdateMediaStateActionRequest: function(mediaGalleryKey, mediaItemKey, submissionState) {
      this.mediaGalleryKey = mediaGalleryKey;
      this.mediaItemKey = mediaItemKey;
      this.submissionState = submissionState;
      this.callerSDK = 'js';
      this.objectType = 'Media.UpdateMediaStateActionRequest';
    },
    UpdateMediaPositionActionRequest: function(moveThisMediaItemKey, moveBeforeMediaItemKey) {
      this.moveThisMediaItemKey = moveThisMediaItemKey;
      this.moveBeforeMediaItemKey = moveBeforeMediaItemKey;
      this.callerSDK = 'js';
      this.objectType = 'Media.UpdateMediaPositionActionRequest';
    },
    CommentOnRequest: function(reactionTargetKey, body) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.body = body;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.CommentOnRequest';
    },
    GetCommentPageRequest: function(reactionTargetKey, numberPerPage, onPage, sort) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.numberPerPage = numberPerPage;
      this.onPage = onPage;
      this.sort = sort;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.GetCommentPageRequest';
    },
    GetReactionSummaryRequest: function(reactionTargetKey) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.GetReactionSummaryRequest';
    },
    RecommendRequest: function(reactionTargetKey, recommendationCategory) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.recommendationCategory = (typeof recommendationCategory != 'undefined' ? recommendationCategory : '');
      this.callerSDK = 'js';
      this.objectType = 'Reactions.RecommendRequest';
    },
    ReportAbuseOnRequest: function(reactionTargetKey, abuseReason) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.abuseReason = abuseReason;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.ReportAbuseOnRequest';
    },
    ClearAbuseReportRequest: function(reactionTargetKey) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.ClearAbuseReportRequest';
    },
    GetAbuseReportPageRequest: function(numberPerPage, onPage, maxReportersPerReport) {
      this.numberPerPage = numberPerPage;
      this.onPage = onPage;
      this.maxReportersPerReport = maxReportersPerReport;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.GetAbuseReportPageRequest';
    },
    GetAbuseReportRequest: function(reactionTargetKey, maxReporters) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.maxReporters = maxReporters;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.GetAbuseReportRequest';
    },
    DiscoverArticlesRequest: function(activity, age) {
      this.activity = activity;
      this.age = age;
      this.callerSDK = 'js';
      this.objectType = 'Discovery.DiscoverArticlesRequest';
    },
    DiscoverUsersRequest: function(activity, age) {
      this.activity = activity;
      this.age = age;
      this.callerSDK = 'js';
      this.objectType = 'Discovery.DiscoverUsersRequest';
    },
    UserRecentActivityRequest: function(userKey) {
      this.userKey = userKey;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.UserRecentActivityRequest';
    },
    GetPublisherMonthlyReportRequest: function(month, year, apiKey) {
      this.month = month;
      this.year = year;
      this.apiKey = apiKey;
      this.callerSDK = 'js';
      this.objectType = 'Reporting.GetPublisherMonthlyReportRequest';
    },
    EchoRequest: function(message) {
      this.message = message;
      this.callerSDK = 'js';
      this.objectType = 'Util.EchoRequest';
    },
    ErrorRequest: function() {
      this.callerSDK = 'js';
      this.objectType = 'Util.ErrorRequest';
    }
  });
})();
(function() {
  /* Demand Media Javascript Library Model Objects */
  dmpod.extend({
    AdNetworkDetails: function() {
      this.callerSDK = 'js';
      this.objectType = 'AdNetworks.AdNetworkDetails';
    },
    AdDescription: function(width, height) {
      this.width = width;
      this.height = height;
      this.callerSDK = 'js';
      this.objectType = 'AdNetworks.AdDescription';
    },
    Advertisement: function(adDescription, source) {
      this.adDescription = adDescription;
      this.source = source;
      this.callerSDK = 'js';
      this.objectType = 'AdNetworks.Advertisement';
    },
    SponsoredLink: function(title, description, url, clickUrl) {
      this.title = title;
      this.description = description;
      this.url = url;
      this.clickUrl = clickUrl;
      this.callerSDK = 'js';
      this.objectType = 'AdNetworks.SponsoredLink';
    },
    RelatedAdLink: function(searchTerm, searchToken, searchLinkType, searchLinkRank, searchLinkIsGeneric) {
      this.searchTerm = searchTerm;
      this.searchToken = searchToken;
      this.searchLinkType = searchLinkType;
      this.searchLinkRank = searchLinkRank;
      this.searchLinkIsGeneric = searchLinkIsGeneric;
      this.callerSDK = 'js';
      this.objectType = 'AdNetworks.RelatedAdLink';
    },
    RelatedAdResultLink: function(title, description, displayUrl, clickUrl) {
      this.title = title;
      this.description = description;
      this.displayUrl = displayUrl;
      this.clickUrl = clickUrl;
      this.callerSDK = 'js';
      this.objectType = 'AdNetworks.RelatedAdResultLink';
    },
    BundleTemplateListKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.BundleTemplateListKey';
    },
    BundleTemplateList: function(parentKey, key, name) {
      this.parentKey = parentKey;
      this.key = key;
      this.name = name;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.BundleTemplateList';
    },
    BundleTemplateKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.BundleTemplateKey';
    },
    BundleTemplate: function(parentListKey, key, name, criteria) {
      this.parentListKey = parentListKey;
      this.key = key;
      this.name = name;
      this.criteria = criteria;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.BundleTemplate';
    },
    BundleTemplateAliasKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.BundleTemplateAliasKey';
    },
    BundleTemplateAlias: function(bundleTemplateKey) {
      this.bundleTemplateKey = bundleTemplateKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.BundleTemplateAlias';
    },
    Bundle: function(templateKey) {
      this.templateKey = templateKey;
      this.callerSDK = 'js';
      this.objectType = 'Bundles.Bundle';
    },
    Article: function(key, id) {
      this.key = key;
      this.id = id;
      this.callerSDK = 'js';
      this.objectType = 'Content.Article';
    },
    Tag: function(name) {
      this.name = name;
      this.callerSDK = 'js';
      this.objectType = 'Content.Tag';
    },
    ArticleKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Content.ArticleKey';
    },
    PublisherContentKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Content.PublisherContentKey';
    },
    ContentCategory: function(id, name) {
      this.id = id;
      this.name = name;
      this.callerSDK = 'js';
      this.objectType = 'Content.ContentCategory';
    },
    RelatedLink: function(title, url, key) {
      this.title = title;
      this.url = url;
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Content.RelatedLink';
    },
    QueryCriteria: function() {
      this.callerSDK = 'js';
      this.objectType = 'Content.QueryCriteria';
    },
    RequestEnvelope: function() {
      this.callerSDK = 'js';
      this.objectType = 'Core.RequestEnvelope';
    },
    ResponseEnvelope: function() {
      this.callerSDK = 'js';
      this.objectType = 'Core.ResponseEnvelope';
    },
    ItemEnvelope: function() {
      this.callerSDK = 'js';
      this.objectType = 'Core.ItemEnvelope';
    },
    BaseKey: function(key, keyType) {
      this.key = key;
      this.keyType = keyType;
      this.callerSDK = 'js';
      this.objectType = 'Core.BaseKey';
    },
    KeyValuePair: function(key, data) {
      this.key = key;
      this.data = data;
      this.callerSDK = 'js';
      this.objectType = 'Core.KeyValuePair';
    },
    Customer: function(domain, contactEmail, isInternalProperty, widgetLandingPageUrl, platform, enabledState, userContentMode, apiKey, publisherNetwork, publisherSubNetwork, resellerCustomerId, publisherNetworkCustomerId, publisherNetworkAccountId, inlineTextAdsAllowed, inlineImageAdsAllowed, sponsoredLinksAllowed, relatedAdLinksAllowed, sdkAccessAllowed, socialMediaEnabled, popupWidgetLandingPage) {
      this.domain = domain;
      this.contactEmail = contactEmail;
      this.isInternalProperty = isInternalProperty;
      this.widgetLandingPageUrl = widgetLandingPageUrl;
      this.platform = platform;
      this.enabledState = enabledState;
      this.userContentMode = userContentMode;
      this.apiKey = apiKey;
      this.publisherNetwork = publisherNetwork;
      this.publisherSubNetwork = publisherSubNetwork;
      this.resellerCustomerId = resellerCustomerId;
      this.publisherNetworkCustomerId = publisherNetworkCustomerId;
      this.publisherNetworkAccountId = publisherNetworkAccountId;
      this.inlineTextAdsAllowed = inlineTextAdsAllowed;
      this.inlineImageAdsAllowed = inlineImageAdsAllowed;
      this.sponsoredLinksAllowed = sponsoredLinksAllowed;
      this.relatedAdLinksAllowed = relatedAdLinksAllowed;
      this.sdkAccessAllowed = sdkAccessAllowed;
      this.socialMediaEnabled = socialMediaEnabled;
      this.popupWidgetLandingPage = popupWidgetLandingPage;
      this.callerSDK = 'js';
      this.objectType = 'Customers.Customer';
    },
    ContentSourceKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Content.ContentSourceKey';
    },
    ContentSource: function(key, displayName, url, contentCrawlingAllowed, inlineTextAdsAllowed, hasOwnAds) {
      this.key = key;
      this.displayName = displayName;
      this.url = url;
      this.contentCrawlingAllowed = contentCrawlingAllowed;
      this.inlineTextAdsAllowed = inlineTextAdsAllowed;
      this.hasOwnAds = hasOwnAds;
      this.callerSDK = 'js';
      this.objectType = 'Content.ContentSource';
    },
    UserKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Users.UserKey';
    },
    User: function(userKey) {
      this.userKey = userKey;
      this.callerSDK = 'js';
      this.objectType = 'Users.User';
    },
    CustomerSearchRecord: function(apiKey, widgetLandingPageUrl, platform, publisherSubNetwork, resellerCustomerId) {
      this.apiKey = apiKey;
      this.widgetLandingPageUrl = widgetLandingPageUrl;
      this.platform = platform;
      this.publisherSubNetwork = publisherSubNetwork;
      this.resellerCustomerId = resellerCustomerId;
      this.callerSDK = 'js';
      this.objectType = 'Customers.CustomerSearchRecord';
    },
    CustomerSearchRecordPage: function() {
      this.callerSDK = 'js';
      this.objectType = 'Customers.CustomerSearchRecordPage';
    },
    MediaGalleryKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Media.MediaGalleryKey';
    },
    MediaItemKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Media.MediaItemKey';
    },
    MediaGallery: function() {
      this.callerSDK = 'js';
      this.objectType = 'Media.MediaGallery';
    },
    MediaItem: function() {
      this.callerSDK = 'js';
      this.objectType = 'Media.MediaItem';
    },
    MediaItemPage: function() {
      this.callerSDK = 'js';
      this.objectType = 'Media.MediaItemPage';
    },
    PaymentSystemDetails: function() {
      this.callerSDK = 'js';
      this.objectType = 'PaymentSystems.PaymentSystemDetails';
    },
    CommentKey: function(key) {
      this.key = key;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.CommentKey';
    },
    ReactionSummary: function() {
      this.callerSDK = 'js';
      this.objectType = 'Reactions.ReactionSummary';
    },
    Comment: function() {
      this.callerSDK = 'js';
      this.objectType = 'Reactions.Comment';
    },
    CommentPage: function() {
      this.callerSDK = 'js';
      this.objectType = 'Reactions.CommentPage';
    },
    AbuseReport: function(reactionTargetKey, reactionTargetType, url, title, abuseReportTotalCount, abuseReportDetail, abuseReporters) {
      if (reactionTargetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof reactionTargetKey.objectType == 'string') && reactionTargetKey.objectType.split('.')[1],
            reactionTargetKey = new dmpod.BaseKey(reactionTargetKey.key, typeName || null);
      }
      this.reactionTargetKey = reactionTargetKey;
      this.reactionTargetType = reactionTargetType;
      this.url = url;
      this.title = title;
      this.abuseReportTotalCount = abuseReportTotalCount;
      this.abuseReportDetail = abuseReportDetail;
      this.abuseReporters = abuseReporters;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.AbuseReport';
    },
    AbuseReportPage: function() {
      this.callerSDK = 'js';
      this.objectType = 'Reactions.AbuseReportPage';
    },
    AbuseReportDetail: function(abuseReason, abuseReportCount) {
      this.abuseReason = abuseReason;
      this.abuseReportCount = abuseReportCount;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.AbuseReportDetail';
    },
    RecommendationDetail: function(category, count) {
      this.category = category;
      this.count = count;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.RecommendationDetail';
    },
    UserActivity: function(action, targetKey) {
      this.action = action;
      if (targetKey.constructor != dmpod.BaseKey) {
        var typeName = (typeof targetKey.objectType == 'string') && targetKey.objectType.split('.')[1],
            targetKey = new dmpod.BaseKey(targetKey.key, typeName || null);
      }
      this.targetKey = targetKey;
      this.callerSDK = 'js';
      this.objectType = 'Reactions.UserActivity';
    },
    PublisherMonthlyReport: function(month, year, dailyReports) {
      this.month = month;
      this.year = year;
      this.dailyReports = dailyReports;
      this.callerSDK = 'js';
      this.objectType = 'Reporting.PublisherMonthlyReport';
    },
    PublisherDailyReport: function(day, pageViews, totalAdRevenue) {
      this.day = day;
      this.pageViews = pageViews;
      this.totalAdRevenue = totalAdRevenue;
      this.callerSDK = 'js';
      this.objectType = 'Reporting.PublisherDailyReport';
    }
  });
})();

var PLUCKIT_TRACKING_URL = 'http://pod.dmtracker.com/images/zig.gif';

if (typeof(dmpod.service) === 'undefined') {
  dmpod.service = dmpod.createPODRequestService(PLUCKIT_APIKEY);
}
(function(base) {
  if (typeof(base.help) == 'undefined') {
    base.help = {};
    base.extendObject(base.help, {
      isArray: function(obj){
        if (obj.constructor.toString().indexOf("Array") == -1) {
          return false;
        } else {
          return true;
        }
      },
      arrayContains: function(obj, value) {
        for (var i=0; i<obj.length; i++) {
          if (obj[i] == value) {
            return true;
          }
        }
        return false;
      },
      createUniqueId: function(prefix){
        var seed = (new Date()).getTime();
        var id = Math.floor((Math.random() * seed));
        if (typeof prefix !== 'undefined') {
          id = prefix + '_' + id;
        }
        return id;
      },    // creates a unique div for the widget content
      addWidgetDiv: function(prefix, suffix, classvalue, content){
        var divId = null;
        if (typeof prefix === 'undefined') {
          prefix = 'div';
        }
        if (typeof suffix === 'undefined') {
          divId = this.createUniqueId(prefix);
        } else {
          divId = prefix + '_' + suffix;
        }
        var tag = null;
        if (typeof(classvalue) !== 'undefined') {
          tag = '<div class="'+classvalue+'" id="' + divId + '">';
        } else {
          tag = '<div id="' + divId + '">';
        }
        if (typeof(content) !== 'undefined') {
          document.write(tag+content+'<\/div>');
        } else {
          document.write(tag+'<\/div>');
        }
        return divId;
      },    // creates a unique textarea for the widget template
      addTemplateHolder: function(html){
        var id = this.createUniqueId('templateDiv-');
        document.write('<textarea id="' + id + '" style="display: none">' + html + '<\/textarea>');
        return id;
      },
      makeErrorSpan: function(text){
        if (base.service.debugging.on) {
          base.service.debug('WidgetError - ' + text);
          return '<span style="display: block;">WidgetError - ' + text + '</span>';
        } else {
          return '<span style="display: none;">WidgetError - ' + text + '</span>';
        }
      },    // adds the widget stylesheet to the top or bottom of the head
      addWidgetStylesheet: function(url, global, append){
        if (typeof(url) !== 'undefined') {
          if (!this.stylesheets.hasOwnProperty(url)) {
            this.stylesheets[url] = true;
            var headElem = document.getElementsByTagName('head')[0];
            if (headElem !== null) {
              var linkElem = this.os_createElement('link', {
                'rel': 'stylesheet',
                'type': 'text/css',
                'href': url
              }, '');
              if (typeof(append) !== 'undefined' && append == true) {
                headElem.appendChild(linkElem);
              } else {
                var first = headElem.firstChild;
                if (first == null) {
                    headElem.appendChild(linkElem);
                } else if (typeof(global) !== 'undefined' && global == true) {
                    headElem.insertBefore(linkElem, first);
                } else {
                  var second = first.nextSibling;
                  if (second == null) {
                    headElem.appendChild(linkElem);
                  } else {
                    headElem.insertBefore(linkElem, second);
                  }
                }
              }
            }
          }
        }
      },
      isBasicType: function(varType){
        return ":string:number:boolean:".indexOf(':' + varType + ':') > -1;
      },
      overrideOptions: function(from, to){
        for (var option in to) {
          if (from.hasOwnProperty(option)) {
            if (this.isBasicType(typeof(to[option]))) {
              to[option] = from[option];
            } else 
              if (to[option] != null && typeof(to[option]) == 'object') {
                if (to[option].constructor.toString() != "Function") {
                  this.overrideOptions(from[option], to[option]);
                }
              } else 
                if (typeof(to[option]) == 'function') {
                  to[option] = from[option];
                }
          }
        }
      },
      isOverridableOption: function(option) {
        return option!='templateId' && option!='layout' && option!='remoteTemplateUrl' && option!='customCss';
      },
      overrideSingleOptionRecursively: function(option,value,target,externalSource) {
        if (this.isOverridableOption(option)) {
          if (target.hasOwnProperty(option)) {
            if (target[option] != '_' || externalSource) {
              target[option] = value;
            }
          }
          for (var o in target) {
            if (o != option && target[o] != null && typeof(target[o]) == 'object') {
             this.overrideSingleOptionRecursively(option, value, target[o], externalSource);
            }
          }
        }
      },
      overrideOptionsRecursively: function(from, to) {
        var externalSource = from != to;
        for (var o in from) {
          if (typeof(from[o]) != 'object') {
            for (oo in to) {
              if (oo == o) {
                to[o] = from[o];
              } else if (to[oo] != null && typeof(to[oo]) == 'object') {
                this.overrideSingleOptionRecursively(o,from[o],to[oo],externalSource);
              }
            }
          } else {
            if (!to.hasOwnProperty(o)) {
              to[o] = new Object();
            }
            this.overrideOptionsRecursively(from[o],to[o]);
          }
        }
      },
      resolveWidgetResource: function(widgetName, resource){
        return (base.service.getHost()+'Widgets/v1/' + widgetName + '/' + resource + '?apiKey=' + PLUCKIT_APIKEY);
      },
      resolveAssetsResource: function(resource){
        return (base.service.getAssetsHost()+'assets/v1/' + resource + '?apiKey=00000000-0000-0000-0000-000000000000&vn=7034');
      },
      getTrimPathModifiers: function(){
        return {
          resolveWidgetResource: function(str){
            return dmpod.help.resolveWidgetResource(str);
          },
          resolveAssetsResource: function(str){
            return dmpod.help.resolveAssetsResource(str);
          },
          addQueryParam: function(str, name, value){
            return dmpod.help.addQueryParam(str, name, value);
          },
          addQueryParams: function(str, nameValuePairs){
            return dmpod.help.addQueryParams(str, nameValuePairs);
          },
          addPrefixedQueryParam: function(str, name, value){
            return dmpod.help.addPrefixedQueryParam(str, name, value);
          },
          addPrefixedQueryParams: function(str, nameValuePairs) {
            return dmpod.help.addPrefixedQueryParams(str, nameValuePairs);
          },
          showPrettyDate: function(milliseconds){
            return dmpod.help.showPrettyDate(milliseconds);
          },
          showPrettyTime: function(milliseconds){
            return dmpod.help.showPrettyTime(milliseconds);
          },
          titleEncode: function(str){
            return escape(str.replace(/ /g, '_'));
          },
          urlEscape: function(str){
            return escape(str);
          }
        }
      },    // Prefix for query params to avoid name collisions
      queryParamPrefix: 'PLUCK',
      getPrefixedQueryParam: function(parameterName, substituteUrl) {
        return this.getQueryParam(this.queryParamPrefix+parameterName, substituteUrl);
      },
      getQueryParam: function(parameterName, substituteUrl) {
        var search = substituteUrl ? substituteUrl : location.search;
        var match = search.match(new RegExp('[\?&]' + parameterName + '=([^&]+)'));
        var value = match ? match[1] : null;
        if (value == null) {
          return null;
        }
        value = value.replace(/\+/g, '%20');
        return unescape(value);
      },
      replaceQueryParams: function(url, newParams){
        if (url.indexOf('#') != -1) {
          url = url.substring(0, url.indexOf('#'));
        }
        var urlBase;
        var params = newParams;
        if (url.indexOf('?') != -1) {
          var urlParts = url.split('?');
          urlBase = urlParts[0];
          var search = urlParts[1];
          var paramArray = search.split('&');
          params = {};
          for (var index = 0; index < paramArray.length; index++) {
            var keyVal = paramArray[index].split('=');
            params[keyVal[0]] = keyVal[1];
          }
          for (newParam in newParams) {
            params[newParam] = newParams[newParam];
          }
        } else {
          urlBase = url;
        }
        var urlParams = "";
        for (param in params) {
          if (urlParams != "") {
            urlParams += "&";
          }
          urlParams += param + "=" + params[param];
        }
        return urlBase + "?" + urlParams;
      },
      ensureHostUrl: function(hostUrl, allowRelative){
        if (typeof(hostUrl) != 'undefined' && hostUrl != null && !allowRelative) {
          var lower = hostUrl.toLowerCase();
          if (lower.indexOf("http") != 0) {
            hostUrl = '';
          }
        }
        if (typeof(hostUrl) == 'undefined' || hostUrl == null || hostUrl == '') {
          hostUrl = document.location.href;
          var stopChars = "#"; // Stripping off in-page navigation. Query params are okay.
          for (i = 0; i < stopChars.length; ++i) {
            var index = hostUrl.indexOf(stopChars.charAt(i));
            if (index > 0) {
              hostUrl = hostUrl.substring(0, index);
            }
          }
        }
        return hostUrl;
      },
      addPrefixedQueryParam: function(url, name, value) {
        return this.addQueryParam(url, this.queryParamPrefix+name, value);
      },
      addPrefixedQueryParams: function(url, nameValuePairs) {
        for (var name in nameValuePairs) {
          url = this.addPrefixedQueryParam(url, name, nameValuePairs[name]);
        }
        return url;
      },
      addQueryParam: function(url, name, value){
        var regex = new RegExp('([\\?&])' + name + '=[^&;]+');
        var data = name + '=' + value.replace(/\s/g, '_');
        if (regex.test(url)) 
          return url.replace(regex, '$1' + data);
        return url + (url.indexOf('?') > -1 ? '&' : '?') + data;
      },
      addQueryParams: function(url, nameValuePairs) {
        for (var name in nameValuePairs) {
          url = this.addQueryParam(url, name, nameValuePairs[name]);
        }
        return url;
      },
      showPrettyDate: function(milliseconds){
        var monthName = new Array();
        monthName[0] = 'January';
        monthName[1] = 'February';
        monthName[2] = 'March';
        monthName[3] = 'April';
        monthName[4] = 'May';
        monthName[5] = 'June';
        monthName[6] = 'July';
        monthName[7] = 'August';
        monthName[8] = 'September';
        monthName[9] = 'October';
        monthName[10] = 'November';
        monthName[11] = 'December';
        var daySuffix = new Array();
        daySuffix[0] = 'th';
        daySuffix[1] = 'st';
        daySuffix[2] = 'nd';
        daySuffix[3] = 'rd';
        var d = new Date();
        d.setTime(milliseconds);
        var month = monthName[d.getMonth()];
        var day = d.getDate();
        var suffix = daySuffix[0];
        if (day < 21) {
          if (day < 4) {
            suffix = daySuffix[day];
          }
        } else {
          if (day%10 < 4) {
            suffix = daySuffix[day%10];
          }
        }
        var year = d.getFullYear();
        return month + ' ' + day + suffix + ', ' + year;
      },
      showPrettyTime: function(milliseconds){
        var d = new Date();
        d.setTime(milliseconds);
        var hours = d.getHours();
        var amPm = 'AM';
        if (hours == 0) {
          hours = 12;
        } else if (hours > 12) {
          hours = hours - 12;
          amPm = 'PM';
        }
        var minutes = d.getMinutes();
        if (minutes < 10) {
          minutes = '0' + minutes;
        }
        return hours + ':' + minutes + ' ' + amPm;
      },
      injectTrackingCode: function(trackingScript, trackingSrc){
        if (trackingScript.length > 0) {
          if (window.execScript) {
            window.execScript(trackingScript);
          } else {
            eval(trackingScript);
          }
        }
        if (trackingSrc.length > 0) {
          this.os_addScriptSrcNode(trackingSrc);
        }
      },
      trackGuiEvent: function(widgetType, queryParameters){
        var eventBeacon = new Image(1,1);
        var beaconUrl = PLUCKIT_TRACKING_URL + '?CustomerKey=' + PLUCKIT_APIKEY + '&WidgetType=' + widgetType;
        if (typeof queryParameters !== 'undefined') {
          for (param in queryParameters) {
            beaconUrl += '&' + param + '=' + this.encodeTrackingParameter(queryParameters[param]);
          }
        }
        beaconUrl += '&Log=1&v=JT01.02&lt=0&nocache=' + this.createUniqueId('beacon');
        beaconUrl += '&t=' + this.encodeTrackingParameter(document.title)
        beaconUrl += '&r=' + this.encodeTrackingParameter(document.referrer);
        eventBeacon.src= beaconUrl;
      },
      encodeTrackingParameter: function(str){
        return (typeof encodeURI!='undefined') ? encodeURI(str) : escape(str);
      },
      checkApiKey: function(widgetId, apiKey){
        var widget = document.getElementById(widgetId);
        if (apiKey == '00000000-0000-0000-0000-000000000000' && !document.getElementById('podApiKeyWarning')) {
          var apiWarningDiv = document.createElement('div');
          apiWarningDiv.className = 'podAlert podGlobal';
          apiWarningDiv.id = 'podApiKeyWarning';
          apiWarningDiv.style.marginTop = '10px';
          apiWarningDiv.style.marginBottom = '10px';
          apiWarningDiv.innerHTML = 'This sample Pluck On Demand widget contains an improper API key (' + apiKey + '). Please use your assigned API key to ensure complete functionality.';
          widget.insertBefore(apiWarningDiv, widget.firstChild);
        }
      },
      replaceHTMLDivIds: function(html, divId, newDivId){
        html = html.replace(/\r/gm, '---CR---');
        html = html.replace(/\n/gm, '---LF---');
        var m = html.match(new RegExp('^(.*<div.*\\sid\\s*=\\s*[\'\"])(' + divId + ')([\'\"].*?>.*$)', 'i'));
        if (m != null && m.length == 4) {
          html = m[1] + newDivId + m[3];
        }
        html = html.replace(/---CR---/gm, '\r');
        html = html.replace(/---LF---/gm, '\n');
        return html;
      },
      os_createElement: function(elementType, attributes, bodyText){
        var element = document.createElement(elementType);
        for (name in attributes) {
          element.setAttribute(name, attributes[name]);
        }
        if (bodyText.length > 0) {
          element.appendChild(document.createTextNode(bodyText));
        }
        return element;
      },
      os_addToHead: function(elem){
        var head = document.getElementsByTagName("head")[0];
        head.appendChild(elem);
      },
      os_addScriptSrcNode: function(scriptSrc){
        var scriptElement = this.os_createElement('script', {
          'src': scriptSrc,
          'type': 'text/javascript',
          'charset': 'utf-8'
        }, '');
        this.os_addToHead(scriptElement);
      },
      displayElement: function(elem, mode, retry) {
        if (retry && retry <= 1) {
          return;
        }
        if (document.getElementById(elem)) {
          document.getElementById(elem).style.display = mode;
        } else {
          var my = this;
          setTimeout(function() {
            my.displayElement(elem, mode, --retry);
          }, 500);
        }
      },
      swapElements: function(elemToHide, elemToShow, inline) {
        var hideMe = (typeof elemToHide == 'string' ? document.getElementById(elemToHide) : elemToHide),
            showMe = (typeof elemToShow == 'string' ? document.getElementById(elemToShow) : elemToShow);
        hideMe.style.display = 'none';
        if (inline) {
          showMe.style.display = 'inline';
        } else {
          showMe.style.display = 'block';
        }
      },
      addListener: function(element, type, expression, bubbling) {
        bubbling = bubbling || false;
        if (window.addEventListener) { // Non-IE browsers
            element.addEventListener(type, expression, bubbling);
            return true;
        } else if (window.attachEvent) { // IE
            element.attachEvent('on' + type, expression);
            return true;
        } else {
            return false;
        }
      },
      removeListener: function(element, type, expression, bubbling) {
        bubbling = bubbling || false;
        if (window.removeEventListener) { // Non-IE browsers
            element.removeEventListener(type, expression, bubbling);
            return true;
        } else if (window.detachEvent) { // IE
            element.detachEvent('on' + type, expression);
            return true;
        } else {
            return false;
        }
      },
      moveElement: function(elem,startPos,endPos,steps,intervals,powr, callback) {
        if (elem.posChangeMemInt) {
            window.clearInterval(elem.posChangeMemInt);
        }
        var actStep = 0;
        elem.posChangeMemInt = window.setInterval(
          function() {
            if (typeof(startPos[0]) !== 'undefined'
                && typeof(startPos[1]) !== 'undefined'
                && typeof(endPos[0]) !== 'undefined'
                && typeof(endPos[1]) !== 'undefined') {
              elem.currentPos = [
                dmpod.help.easeInOut(startPos[0],endPos[0],steps,actStep,powr),
                dmpod.help.easeInOut(startPos[1],endPos[1],steps,actStep,powr)
              ];
              elem.style.left = elem.currentPos[0]+"px";
              elem.style.top = elem.currentPos[1]+"px";
              actStep++;
              if (actStep > steps) {
                window.clearInterval(elem.posChangeMemInt);
                if (callback) {
                  callback();
                }
              }
            } else {
              window.clearInterval(elem.posChangeMemInt);
              if (callback) {
                callback();
              }
            }
          }
        ,intervals);
      },
      easeInOut: function(minValue,maxValue,totalSteps,actualStep,powr) {
        var delta = maxValue - minValue;
        var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
        return Math.ceil(stepp)
      },
      changeOpacity: function(elem,startOpacity,endOpacity,steps,intervals,powr, callback) {
        if (elem.opacityChangeMemInt) {
          window.clearInterval(elem.opacityChangeMemInt);
        }
        var actStep = 0;
        elem.opacityChangeMemInt = window.setInterval(
          function() { 
            elem.currentOpacity = dmpod.help.easeInOut(startOpacity,endOpacity,steps,actStep,powr);
            elem.style.opacity = elem.currentOpacity/100;
            elem.style.filter = 'alpha(opacity=' + elem.currentOpacity + ');';
            actStep++;
            if (actStep > steps) {
              if (elem.style.opacity == '0') {
                elem.style.display = 'none';
              }
              window.clearInterval(elem.opacityChangeMemInt);
              if (callback) {
                callback();
              }
            }
          }
        ,intervals)
      },
      submitForm: function(name) {
        var form = document.forms[name];
        if (form && form.onsubmit())
          form.submit();
        return false;
      },
      alert: function(msg) {
        var doc = document, div = doc.body.appendChild(document.createElement('div'));
        div.className = 'podStatusAlert';
        div.appendChild(doc.createTextNode(msg));
        setTimeout(function() {
          dmpod.help.changeOpacity(div, 100, 0, 20, 30, 1);
          setTimeout(function() { doc.body.removeChild(div) }, 3000);
        }, 3000)
      },
      showError: function(elementId, errorMessage) {
        var elem = document.getElementById(elementId);
        if (elem) {
          elem.innerHTML = '<a href="javascript:dmpod.help.hideError(\''+elementId+'\');" class="podClose">close</a>'
          elem.innerHTML += errorMessage;
          elem.style.display = 'block';
        } else {
          alert(errorMessage);
        }
      },
      hideError: function(elementId) {
        var elem = document.getElementById(elementId);
        if (elem) {
          elem.innerHTML = '';
          elem.style.display = 'none';
        } 
      },
      extractDomain: function(domainOrUrl) {
        domainOrUrl = domainOrUrl.replace(/^\s*/, '');
        domainOrUrl = domainOrUrl.replace(/^https?:\/\//i, '');
        domainOrUrl = domainOrUrl.replace(/^(www\.)?/i, '');
        domainOrUrl = domainOrUrl.replace(/\/.*/, '');
        return domainOrUrl;
      },
      convertUrlToPublisherKeyString: function (url) {
        url = url.replace(/https:\/\//i, '');
        url = url.replace(/http:\/\//i, '');
        url = url.replace(/www\./i, '');
        url = url.replace(/#.*/i, '');
        return url;
      },
      grabOption: function(widget, optionName, substituteUrl) {
        var optionSetting = widget.optionSpecified(optionName);
        if (!optionSetting) {
          optionSetting = this.getPrefixedQueryParam(optionName, substituteUrl);
        }
        if (!optionSetting) {
          optionSetting = '';
        }
        return optionSetting;
      },
      submitEnter: function(inputField,e) {
        var keycode;
        if (window.event) {
          keycode = window.event.keyCode;
        } else if (e) {
          keycode = e.which;
        } else {
          return true;
        }
        if (keycode == 13) {
           inputField.form.submit();
           return false;
        } else {
           return true;
        }
      },
      cleanInput: function (str) {
        str = str.replace(/</g, '&lt;');
        str = str.replace(/>/g, '&gt;');
        return str;
      },
      truncateOnBadChar: function (str) {
        var newStr = '';
        var goodChars = '01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
          for (var i = 0; i < str.length; i++) {
            if (goodChars.indexOf(str.charAt(i)) == -1) {
              return newStr + '_...';
            }
            newStr += str.charAt(i);
          }
        return newStr;
      },
      addAnchor: function (url, anchor) {
        url = url.replace(/#.*/i, '');
        url = url + '#' + anchor;
        return url;
      },
      getElementsByClassName: function (className) {
        if (document.getElementsByClassName) {
          return document.getElementsByClassName(className);
        }
        var nodes = [];
        var regex = new RegExp('(^| )' + cl + '( |$)');
        for (var i = 0, elems = document.getElementsByTagName('*'), elem; elem = elems[i]; i++) {
          if (regex.test(elem.className)) {
            nodes.push(elem);
          }
        }
        return nodes;
      },
      getErrorMessageFromResponses: function (responses) {
        for (var i=0; i < responses.length; i++) {
          if (responses[i].isError) {
            return responses[i].message;
          }
        }
        return '';
      },
      isIE: base.service.isIE,
      flashVersion: base.service.flashVersion,
      isValidUrl: function(url) {
        var isValid = false;
        var regex = /^(http|https):\/\/.+/;
        if (regex.test(url)) {
          isValid = true;
        }
        return isValid;
      },
      isEmptyOrNull: function(item) {
        var isEON = false;
        if (item == '' || item == null) {
          isEON = true;
        }
        return isEON;
      },
      setBaseUrl: function(optionUrl, landingPageUrl) {
        var baseUrl;
        if (!this.isEmptyOrNull(optionUrl)) {
          baseUrl = this.ensureHostUrl(optionUrl, true);
        } else if (!this.isEmptyOrNull(landingPageUrl)) {
          baseUrl = landingPageUrl;
        } else {
          baseUrl = this.ensureHostUrl(document.location.href, true);
        }
        return baseUrl;
      },
      eatBlanks: function(str) {
        return str.replace(/^\s*|\s*$/g, '');
      },
      stylesheets: {},
      showMessage: this.showError,
      hideMessage: this.hideError,
      isAncestor: function(childWidget, possibleAncestorClassName) {
        if (childWidget.parent) {
          if (childWidget.parent.classname == possibleAncestorClassName) {
            return true;
          } else {
            return this.isAncestor(childWidget.parent, possibleAncestorClassName);
          }
        }
        return false;
      }
    });
  }
})(dmpod);
(function(base) {
  if (typeof(base.widget) == 'undefined') {
    var aWidget = function() {}
    aWidget.runWidget = function(classname){
      var divSuffix = base.help.createUniqueId();
      if (!base.service) {
        base.help.addWidgetDiv(classname, divSuffix, 'podWidget', base.help.makeErrorSpan("PluckItService instance is null"));
        return;
      }
      if (base.service.flashNeeded) {
        base.help.addWidgetDiv(classname, divSuffix, 'podWidget', '<p>The Adobe Flash Player installed in this browser is out of date. <a href="http://www.adobe.com/go/getflashplayer/" target="_blank">Please upgrade Adobe Flash Player.<\/a></p>');
        return;
      }
      try {
        var defaultOptions = {};
        if (typeof(PLUCKIT_WIDGET_OPTIONS_DEFAULT) !== 'undefined') {
          defaultOptions = PLUCKIT_WIDGET_OPTIONS_DEFAULT;
          PLUCKIT_WIDGET_OPTIONS_DEFAULT = null;
        }
        var events = {};
        if (typeof(PLUCKIT_WIDGET_EVENTS) !== 'undefined') {
          events = PLUCKIT_WIDGET_EVENTS;
          PLUCKIT_WIDGET_EVENTS = null;
        }
        if (typeof(PLUCKIT_WIDGET_OPTIONS) != 'undefined' && PLUCKIT_WIDGET_OPTIONS != null) {
          base.help.overrideOptionsRecursively(PLUCKIT_WIDGET_OPTIONS, defaultOptions);
          PLUCKIT_WIDGET_OPTIONS = null;
        }
        if (base.service.debugging.on && base.service.debugging.firebug) {
          window.console.group('Creating widget '+classname+' with these options:');
          window.console.dir(defaultOptions);
          window.console.groupEnd();
        }
        var mainWidget = aWidget.createWidget(null, classname, classname, divSuffix, defaultOptions, events);
        base.help.addWidgetDiv(classname, divSuffix, 'podWidget', mainWidget.getPreloadHtml());        
        if (mainWidget.preloadImageUrls.length > 0) {
          for (var i=0; i<mainWidget.preloadImageUrls.length; i++) {
            var image = document.createElement('img');
            image.src = base.help.resolveAssetsResource('images/'+mainWidget.preloadImageUrls[i]);
          }
        }
        mainWidget.execute();
      } catch (ex) { alert(ex.message);
        base.help.addWidgetDiv(classname, divSuffix, 'podWidget', base.help.makeErrorSpan('[' + classname + '] ' + ex.name + ': ' + ex.message));
      }
    };
    aWidget.createWidget = function(parent, classname, instanceName, divSuffix, options, events){
      if (parent == null) {
        base.help.addWidgetStylesheet(base.help.resolveAssetsResource('stylesheets/pod.css'), true);
      }
      var widget = new window[classname];
      widget.service = base.service;
      widget.init(parent, classname, instanceName, divSuffix, options, events);
      window[widget.divId] = widget;
      return widget;
    };
    base.widget = aWidget;
    aWidget.prototype = (function(){
      return {
        constructor: aWidget,
        createWidget: aWidget.createWidget,
        init: function(parent, classname, instanceName, divSuffix, options, events){
          var my = this;
          this.help = base.help;
          this.eventInfo = {};
          this.parent = parent;
          this.classname = classname;
          this.instanceName = instanceName;
          this.divSuffix = divSuffix;
          this.divId = this.instanceName + '_' + divSuffix;
          this.context = {};
          this.context._MODIFIERS = this.help.getTrimPathModifiers();
          this.context.options = options;
          this.context.apiKey = PLUCKIT_APIKEY;
          this.context.konteraAds = false;
          this.madeAnyRequests = false;
          this.processedAnyResponses = false;
          this.requests = [];
          this.subWidgets = [];
          this.child = {};
          this.autoRender = true;
          this.currentResponses = [];
          this.content = '';
          this.contentTime = new Date().getTime();
          this.renderedTime = this.contentTime - 1000;
          this.errorText = '';
          this.events = events || {};
          for (var event in this.events) {
            if (this.events.hasOwnProperty(event)) {
              this.addEventCallback(event, this.events[event]);
            }
          }
          if (this.optionSpecified("customCss")) {
            base.help.addWidgetStylesheet(this.context.options.customCss, false, true);
          }
          this.addChildWidgets();
          if (this.optionSpecified("remoteTemplateUrl")) {
            this.template = null;
            this.downloadUrl(this.context.options.remoteTemplateUrl, null, function(template) {
              my.template = template;
            });
          } else {
            if (this.optionSpecified("templateId")) {
              this.template = document.getElementById(this.context.options.templateId).value;
            } else if (this.optionSpecified("layout") && (typeof(this.layouts) !== 'undefined')) {
              this.template = this.layouts[this.context.options.layout];
            }
          }
          this.postInit();
          this.fireEventOnce("onLoaded");
        },
        downloadUrl: function(url, queryString, callback) {
          var my = this;
          var func = function(data) {
            callback.call(my, data);
          }
          this.service.DownloadUrl(url, queryString, func);
        },
        postForm: function(formUrl, queryString, callback) {
          var my = this;
          var func = function(data) {
            callback.call(my, data);
          }
          this.service.PostForm(formUrl, queryString, func);
        },
        sendRequests: function(requests, callback){
          if (this.service.debugging.on) {
            if (requests.constructor != Array) { // handle single requests gracefully
              requests = [requests];
            }
            for (var i=0; i<requests.length; i++) {
              if (!requests[i].hasOwnProperty('requestedBy')) {
                requests[i].requestedBy = this.instanceName+'['+this.classname+']';
              }
            }
          }
          var my = this;
          this.service.SendRequests(requests, function(batchResponse){
            if (batchResponse.hasOwnProperty('ContentTrackingJavaScript')) {
              base.help.injectTrackingCode(batchResponse.ContentTrackingJavaScript, batchResponse.ContentTrackingSrc);
            }
            callback.call(my, batchResponse);
          });
        },
        showHtmlException: function(ex) {
          this.content = this.help.makeErrorSpan('[' + this.classname + ':' + this.instanceName + '] ' + ex.name + ': ' + ex.message);
          this.render();
        },
        execute: function(callback, overrideOptions){
          var my = this;
          try {
            if (typeof(overrideOptions) !== 'undefined') {
                this.help.overrideOptions(this.context.options, overrideOptions);
            }
            var requests = this.getRequests();
            if (requests != null && requests.length > 0) {
              this.sendRequests(requests, function(batchResponse){
                try {
                  my.waitForAllTemplates(function(all) {
                    if (all) {
                      my.replaceChildDivIds();
                      var responses = batchResponse.Responses;
                      my.processResponses(responses);
                      if (my.autoRender) {
                        my.processTemplates();
                      }
                      if (typeof callback !== 'undefined') {
                        callback(my);
                      } else if (my.autoRender) {
                        my.render();
                      }
                    } else { // not all templates were loaded
                      my.showHtmlException({ name : 'Remote Templates', message : 'Not all remote templates could be downloaded' });
                    }
                  });
                } catch (ex) {
                  my.showHtmlException(ex);
                }
              });
            } else {
              this.waitForAllTemplates(function(all) {
                if (all) {
                  my.replaceChildDivIds();
                  if (my.autoRender) {
                    my.processTemplates();
                  }
                  if (typeof callback !== 'undefined') {
                    callback(my);
                  } else if (my.autoRender) {
                    my.render();
                  }
                } else { // not all templates were loaded
                  my.showHtmlException({ name : 'Remote Templates', message : 'Not all remote templates could be downloaded' });
                }
              });
            }
          } catch(ex) {
            this.showHtmlException(ex);
          }
        },
        hasAllTemplates: function() {
          if (this.template) {
            if (this.subWidgets.length > 0) {
              for (var i = 0; i < this.subWidgets.length; i++) {
                if (!this.subWidgets[i].hasAllTemplates()) {
                  return false;
                }
              }
            }
            return true;
          }
          return false;
        },
        waitForAllTemplates: function(callback, retry) { // wait up to 10 seconds for remote templates to load
          var all = this.hasAllTemplates();
          if (all) {
            callback(true);
          } else {
            var retry = retry || 0;
            if (retry++ < 40) {
              var my = this; 
              setTimeout(function(){ my.waitForAllTemplates(callback, retry); }, 250 * retry);
            } else {
              callback(false);
            }
          }
        },
        replaceChildDivIds: function() {
          this.template = this.template.replace(/WIDGETINSTANCE/gm, 'window[\'' + this.divId + '\']');
          if (this.subWidgets.length > 0) {
            for (var i = 0; i < this.subWidgets.length; i++) {
              var child = this.subWidgets[i];
              this.template = this.help.replaceHTMLDivIds(this.template, child.instanceName, child.divId);
              child.replaceChildDivIds();
            }
          }
        },
        render: function(retry) {
          if (this.renderedTime < this.contentTime) {
            if (document.getElementById(this.divId) == null) {
              var retry = retry || 0;
              if (retry++ < 10) {
                var my = this; 
                setTimeout(function(){ my.render(retry); }, 100 * retry);
              }
            } else {
              document.getElementById(this.divId).innerHTML = this.content;
              if (this.parent == null) {
                this.help.checkApiKey(this.divId, PLUCKIT_APIKEY);
              }
              this.processPostRender(this.contentTime);
            }
          }
        },
        processPostRender: function(renderedTime){
          this.renderedTime = renderedTime;
          if (this.subWidgets.length > 0) {
            for (var i = 0; i < this.subWidgets.length; i++) {
              if (this.subWidgets[i].autoRender) {
                this.subWidgets[i].processPostRender(renderedTime);
              }
            }
          }
          if (typeof(this.postRender) === "function") {
            this.postRender();
          }
          this.fireEvent('onRendered');
          if (this.madeAnyRequests) {
            if (this.processedAnyResponses) {
              this.fireEventOnceAfterChildren('onCompleted', 5000);
            }
          } else {
            this.fireEventOnceAfterChildren('onCompleted', 5000);
          }
          if (this.context.konteraAds && typeof(PLUCKIT_INLINETEXTADS_CALLED) === 'undefined' && typeof(startKonaFlow)!== 'undefined') {
            startKonaFlow();
            PLUCKIT_INLINETEXTADS_CALLED = true;
          }
        },
        addChildWidget: function(classname, instanceName){
          var widget = this.createWidget(this, classname, instanceName, this.divSuffix, this.context.options[instanceName], this.events[instanceName]);
          this.subWidgets.push(widget);
          this.child[widget.instanceName] = widget;
          if (this.template != null) {
            this.template = this.help.replaceHTMLDivIds(this.template, instanceName, widget.divId);
          }
        },
        getRequests: function(){
          this.askedForRequests = true;
          this.requests = [];
          this.addRequests();
          this.madeAnyRequests = this.requests.length > 0;
          this.processedAnyRequests = false;
          var requests = this.requests;
          if (this.subWidgets.length > 0) {
            for (var i = 0; i < this.subWidgets.length; i++) {
              requests = requests.concat(this.subWidgets[i].getRequests());
            }
          }
          return requests;
        },
        addRequest: function(request){
          if (typeof request != 'undefined') {
            if (this.service.debugging.on) {
              request.requestedBy = this.instanceName+'['+this.classname+']';
              var p = this.parent;
              while (p != null) {
                 request.requestedBy = p.instanceName+':'+request.requestedBy;
                 p = p.parent;
              }
            }
            this.requests.push(request);
          }
        },
        getEventInfo: function(forEventName) {
          if (!this.eventInfo.hasOwnProperty(forEventName)) {
            this.eventInfo[forEventName] = { widget: this, name: forEventName, callbacks: [], fired: 0, enabled: true, waitingForChildren: false };
          }
          return this.eventInfo[forEventName];
        },
        addEventCallback: function(eventName, callback) {
          this.getEventInfo(eventName).callbacks.push(callback);
        },
        eventFired: function(eventName) {
          return this.getEventInfo(eventName).fired;
        },
        fireEvent: function(eventName) {
          var event = this.getEventInfo(eventName);
          if (event.enabled) {
            event.fired++;
            if (this.service.debugging.on) {
              this.service.debug('event: '+event.name+':'+event.fired+' '+this.instanceName);
            }
            if (event.callbacks !== null) {
                for (var i = 0; i < event.callbacks.length; i++) {
                    event.callbacks[i](event);
                }
            }
          }
        },
        fireEventOnce: function(eventName) {
          if (this.eventFired(eventName) == 0) {
            this.fireEvent(eventName);
          }
        },   
        fireEventAfterChildren: function(eventName, timeout) {
          var event = this.getEventInfo(eventName);
          if (!event.waitingOnChildren) {
            event.waitingOnChildren = true;
            var timeout = timeout || 0;
            var expire = (new Date()).getTime() + timeout;
            var my = this;
            var check = function() {
              for (var i=0; i<my.subWidgets.length; i++) {
                if (0 == my.subWidgets[i].eventFired(eventName)) {
                  if (timeout && ((new Date()).getTime() >= expire)) {
                    break;
                  }
                  setTimeout(check, 100);
                  return;
                }
              }
              my.fireEvent(eventName);
              event.waitingOnChildren = false;
              return;
            }; 
            setTimeout(check, 100);
          }
        },
        fireEventOnceAfterChildren: function(eventName, timeout) {
          if (this.eventFired(eventName) == 0) {
            this.fireEventAfterChildren(eventName, timeout);
          }
        },
        setEventEnabled: function(eventName, enabled) {
          var event = this.getEventInfo(eventName);
          event.enabled = enabled;
        },
        processTemplate: function(){
          this.replaceChildDivIds(); // may have been done initially, but repeat in case template changed
          var html = "";
          if (this.errorText > '') {
            html = this.help.makeErrorSpan(this.errorText);
          } else {
            try {
              html = this.processTemplateData(this.template, this.context);
            } catch (ex) {
              html = this.help.makeErrorSpan('[' + this.classname + ':' +
              this.instanceName +
              '] ' +
              ex.name +
              ': ' +
              ex.message);
            }
          }
          this.contentTime = new Date().getTime();
          return html;
        },
        processTemplateData: function(template, data) {
            var tmpl = PodTrimPath.parseTemplate(template);
            if (tmpl != null) {
              var flags = {};
              flags.throwExceptions = true;
              return html = tmpl.process(data, flags);
            }
            return '';
        },
        multipleShift: function(array, number){
          var returned = [];
          number = Math.min(number, array.length);
          for (var i = 0; i < number; i++) {
            returned.push(array.shift());
          }
          return returned;
        },
        getRequestsTreeLength: function() {
          var length = this.requests.length;
          for (var i=0; i<this.subWidgets.length; i++) {
            length += this.subWidgets[i].getRequestsTreeLength();
          }
          return length;
        },
        processChildResponses: function(responses){
          if (this.subWidgets.length > 0) {
            for (var i = 0; i < this.subWidgets.length; i++) {
              if (this.subWidgets[i].getRequestsTreeLength() > 0) {
                var subresponses = this.multipleShift(responses, this.subWidgets[i].getRequestsTreeLength());
                if (!this.help.isArray(subresponses)) {
                  subresponses = [subresponses];
                }
                this.subWidgets[i].processResponses(subresponses);
              }
            }
          }
        },
        processResponses: function(responses){
          this.currentResponses = responses;
          var _responses = null;
          if (this.requests.length > 0) {
            var _responses = this.multipleShift(responses, this.requests.length);
            if (!this.help.isArray(_responses)) {
              _responses = [_responses];
            }
          }
          this.processChildResponses(responses);
          if (_responses != null) {
            this.buildContextFromResponses(_responses);
            this.processedAnyResponses = true;
          }
          this.finalizeContext();
        },
        processTemplates: function(){
          if (this.subWidgets.length > 0) {
            for (var i = 0; i < this.subWidgets.length; i++) {
              var htmldata = '';
              if (this.subWidgets[i].autoRender) {
                htmldata = this.subWidgets[i].processTemplates();
              }
              this.context[this.subWidgets[i].instanceName] = htmldata;
            }
          }
          this.content = this.processTemplate();
          return this.content;
        },
        optionSpecified: function(option){
          return (this.context.options.hasOwnProperty(option) &&
          this.context.options[option]);
        },
        setRequestOption: function(request, option){
          if (this.optionSpecified(option)) {
            request[option] = this.context.options[option];
          }
        },
        setErrorText: function(text){
          this.errorText = '[' + this.classname + ':' + this.instanceName + '] ' + text;
        },
        appendErrorText: function(text){
          this.errorText = '  ' + text;
        },
        getResponseByType: function(responseType, index, askParents) {
          if (typeof(index) === 'undefined') {
            index = 0;
            askParents = false;
          } else if (typeof(askParents) === 'undefined') {
            askParents = false;
          }
          if (this.currentResponses.length > 0) {
            for (var i=0; i<this.currentResponses; i++) {
              if (this.currentResponses[i].indexOf(responseType) >= 0) {
                if (index == 0) {
                   return this.currentResponses[i];
                } else {
                  index--; // skip
                  askParents = false; // found, so no longer consider parents
                }
              }
            }
          }
          if (typeof(askParents) !== 'undefined') {
            if (parent != null && askParents) {
              return parent.getResponseByType(responseType, askParents);
            }
          }
          return null;
        },
        splitRenderResults: function(parms) {
          if (this.optionSpecified("splitRenderResults")) {
            var spec = this.context.options.splitRenderResults.split(',');
            var areas = [];
            while (spec.length > 0) {
              var area = this.multipleShift(spec,2);
              area[1] = parseInt(area[1]);
              areas.push(area);
            }
            if (areas.length > 0) {
              var wanted = 0;
              for (var i=0; i<areas.length; i++) {
                wanted += areas[i][1];
              }
              var extra = Math.max(parms.results.length - wanted, 0);
              if (extra > 0) {
                for (var i=0; i<areas.length; i++) {
                  if (areas[i][1] == 0) {
                    areas[i][1] = extra;
                    break;
                  }
                }
              }
              var main = this.multipleShift(parms.results, areas[0][1]);
              for (var i=1; i<areas.length; i++) {
                if (parms.results.length > 0) {
                  this.context[parms.data] = this.multipleShift(parms.results, areas[i][1]);
                  var html = this.processTemplateData(this.template, this.context);
                  if (html) {
                    document.getElementById(areas[i][0]).innerHTML = html;
                  }
                }
              }
              this.context[parms.data] = main;
            }
          }
        },
        setTimeout: function(func, timems) {
          var my = this;
          var callback = function() {
            func.call(my);
          }
          setTimeout(callback, timems);
        },
        getPreloadHtml: function() {
          return '';
        },
        postInit: function() {
        },
        addChildWidgets: function(){
        },
        addRequests: function(){
        },
        buildContextFromResponses: function(responses){
        },
        finalizeContext: function(){
        }
      };
    })();
  }
})(dmpod);

var PLUCKIT_WIDGET_OPTIONS_DEFAULT = {"articleId":"","customCss":"","direction":"vertical","layout":"","linkResultsType":"topicPage","numberOfTags":"5","remoteTemplateUrl":"","showBottomBorder":"false","showRelatedTags":"true","splitRenderResults":"","stringRelatedTagsSectionTitleHorizontal":"Related:","stringRelatedTagsSectionTitleVertical":"Related Key Words","tag":"","templateId":"","textClass":"","textId":"","textKeywords":"","topicPageUrl":"","url":""};

(function(){
  var widget = function() {};
  window['PluckItRelatedTagsWidget'] = widget;
  widget.prototype = new dmpod.widget(); 
  widget.prototype.template = '{eval}\r\n// Related Tags Widget\r\n{/eval}\r\n\r\n{if options.showRelatedTags == \'true\'}\r\n{if contentMatched}\r\n<div class="podRelatedKeywordsWidget"\> \r\n  {if (options.direction == \'horizontal\') }\r\n    <span class="podRelatedTagsLabel"\>${options.stringRelatedTagsSectionTitleHorizontal}</span\>\r\n    {for tag in tags}{if (tag_index \> 0) },{/if} <a \r\n      {if customer.popupWidgetLandingPage && iAmNotSmart} target="_dmpodWindow" {/if}\r\n      href="${tag.topicPageUrl}"\>${tag.name}</a\>{/for} \r\n  {else}\r\n  <div class="podSectionTitle"\>${options.stringRelatedTagsSectionTitleVertical}</div\> \r\n  <ul\>\r\n    {for tag in tags} \r\n      <li\><a \r\n        {if customer.popupWidgetLandingPage && iAmNotSmart} target="_dmpodWindow" {/if}\r\n        href="${tag.topicPageUrl}"\>${tag.name}</a\></li\>\r\n    {/for}\r\n  </ul\> \r\n  {/if}\r\n</div\>\r\n{else}\r\n<!-- No Content Matched --\>\r\n{/if}\r\n\r\n{if (options.showBottomBorder == \'true\' && contentMatched) }\r\n<hr /\>\r\n{/if}\r\n{/if}\r\n'; 
  widget.prototype.preloadImageUrls = []; 
    widget.prototype.addRequests = function() {
      this.autoRender = false;
      if ((this.parent != null) && ((this.optionSpecified('showRelatedTags') != 'true'))) {
        this.dontShowThisWidget = true;
        return;
      }
      this.setEventEnabled("onCompleted", false);
      var request = new dmpod.GetCustomerRequest();
      this.addRequest(request);
      var request = null;
      if (!this.optionSpecified("articleId") && !this.optionSpecified("tag") && !this.optionSpecified("url")) {
        this.context.options.articleId = this.help.getPrefixedQueryParam("articleId");
        if (!this.optionSpecified("articleId")) {
          this.context.options.tag = this.help.getPrefixedQueryParam("tag");
          if (!this.optionSpecified("tag")) {
            this.context.options.url = this.help.getPrefixedQueryParam("url");
          }
        }
      }
      this.maxTries = 4; // default
      if (this.optionSpecified('articleId')) {
        request = new dmpod.GetTagsForArticleRequest(this.context.options.articleId);
      } else if (this.optionSpecified('tag')) {
        request = new dmpod.GetTagsForTagRequest(this.optionSpecified('tag'));
        this.maxTries = 1;
      } else if (this.optionSpecified('textId')) {
        var names = this.optionSpecified('textId').split(/,/g), data = [];
        for (var i = 0, elem; i < names.length; i++) {
          if (elem = document.getElementById(names[i]))
            data.push(elem.innerHTML);
        }
        request = new dmpod.GetTagsForTextRequest(data.join('\n'));
      } else if (this.optionSpecified('textClass')) {
        var names = this.optionSpecified('textClass').split(/,/g), data = [];
        for (var i = 0; i < names.length; i++) {
          for (var j = 0, elems = this.help.getElementsByClassName(names[i]); j < elems.length; j++)
            data.push(elems[j].innerHTML);
        }
        request = new dmpod.GetTagsForTextRequest(data.join('\n'));
      } else if (this.optionSpecified('textKeywords')) {
        request = new dmpod.GetTagsForTextRequest(this.optionSpecified('textKeywords'));
      } else {
        this.context.options.url = this.help.ensureHostUrl(this.context.options.url, false);
        request = new dmpod.GetTagsForUrlRequest(this.context.options.url);
      }
      request['maxResults'] = this.context.options['numberOfTags'];
      this.deferredRelatedTagsRequest = request;
    }
    widget.prototype.buildContextFromResponses = function(responses) {
      if (this.dontShowThisWidget) {
        return;
      }
      var errorMessage = this.help.getErrorMessageFromResponses(responses);
      if (errorMessage.length > 0) {
        this.setErrorText(errorMessage);
      } else {
        this.context.customer = responses[0].customer;
        this.context.topicPageUrl = this.help.setBaseUrl(this.optionSpecified('topicPageUrl'), this.context.customer.widgetLandingPageUrl);
        if (this.help.isAncestor(this, 'PluckItSmartWidget')) {
          this.context.iAmNotSmart = false;
        } else {
          this.context.iAmNotSmart = true;
        }
        this.getRelatedTags(this.maxTries);
      }
    }
    widget.prototype.getRelatedTags = function(retry, callback) {
      retry--;
      if (retry < 0) {
        if (callback) {
          callback();
        }
        return;
      }
      this.sendRequests(this.deferredRelatedTagsRequest, function(response) {
        var responses = response.Responses[0];
        if (responses.isError) {
          this.setErrorText(responses.message);
        } else if (responses.tags.length == 0) {
          this.setTimeout(function(){
            this.getRelatedTags(retry, callback);
          }, 2000);
        } else {
          this.context.contentMatched = responses.contentMatched;
          for (var i=0; i<responses.tags.length; i++) {
            var tag = responses.tags[i];
            var topicPageUrl = this.context.topicPageUrl;
            if (this.optionSpecified('linkResultsType') == 'relatedAdLinks') {
              topicPageUrl = this.help.addPrefixedQueryParam(topicPageUrl, 'searchTerm', escape(tag.name));
              topicPageUrl = this.help.addPrefixedQueryParam(topicPageUrl, 'whichPage', 'relatedAdLinks');
            } else {
              topicPageUrl = this.help.addPrefixedQueryParam(topicPageUrl, 'tag', escape(tag.name));
              topicPageUrl = this.help.addPrefixedQueryParam(topicPageUrl, 'whichPage', 'topicPage');
            }
            topicPageUrl = this.help.addPrefixedQueryParam(topicPageUrl, 'apiKey', this.context.apiKey);
            responses.tags[i] = { 'name' : tag.name, 'topicPageUrl' : topicPageUrl };
          }
          this.context.tags = responses.tags;
          this.splitRenderResults({'data':'tags','results':responses.tags});
          this.processTemplates();
          this.setEventEnabled("onCompleted", true);
          this.render(callback);
          if (this.context.splitResults) {
            var save = this.context.tags;
            this.context.tags = this.context.splitResults;
            var html = this.processTemplateData(this.template, this.context);
            if (html) {
              document.getElementById(this.context.options.splitResultsDiv).innerHTML = html;
            }
            this.context.tags = save;
          }
        }
      });
    }

})();

dmpod.widget.runWidget('PluckItRelatedTagsWidget');
