jQuery.fn.extend({
    wwload: function(url, options){
		var off = url.indexOf(" ");
		if ( off >= 0 ) {
			var selector = url.slice(off+1, url.length);
			url = url.slice(0, off);
		}

		var callback = options.callback || function(){};
		var params = options.params || null;
		var eval_scripts = options.eval_scripts || false;

		// Default to a GET request
		var type = "GET";

		// If params were provided
		if ( params ) {
			params = jQuery.param( params );
			type = "POST";
		}

		var self = this;

		// Request the remote document
		jQuery.ajax({
			url: url,
			type: type,
			dataType: "html",
			data: params,
			complete: function(res, status){
			// If successful, inject the HTML into all the matched elements
			if ( status == "success" || status == "notmodified" )
				// See if a selector was specified
				if( selector ) {
					// inject the contents of the document in, removing the scripts
					// to avoid any 'Permission Denied' errors in IE
					if( eval_scripts ) {
						var filtered_text;
						filtered_text = $(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")).find(selector);
						self.html( jQuery("<div/>").append(filtered_text) );
						setTimeout(function(){
							$(res.responseText).find(selector).find('script').each(function(){
								jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
							});
						},50);
					} else {
						self.html( $(res.responseText).find(selector) );
					}
				} else {
					// no selector, just inject the full result
					self.html( res.responseText );
				}

				self.each( callback, [res.responseText, status, res] );
			}

		});
	    return this;
}});

if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

$(function(){
  if( window.wwe_actseq == undefined ) window.wwe_actseq=[87,87,69];
  window.killwwE_beactvtr = true;
  window.wwE_beactvtr_killer = function(){
      if( window.killwwE_beactvtr )
          $('#wwE_beactvtr').remove();
      else
          window.setTimeout(window.wwE_beactvtr_killer,1000)
  };
  $(window).keyup(function(e){
    if( e.which == 17 )
        window.killwwE_beactvtr = true;
  });

  $(window).keydown(function(e){
    if( e.which == 17 )
        window.killwwE_beactvtr = false;
    if( $.inArray(e.which,window.wwe_actseq) != -1 ) {
      if(window.wwe_actcnt == undefined) window.wwe_actcnt=0;

      if( window.wwe_actseq[window.wwe_actcnt] == e.which ) window.wwe_actcnt++;
      else window.wwe_actcnt=undefined;

      if(window.wwe_acttmr) window.clearTimeout(window.wwe_acttmr);
      window.wwe_acttmr = window.setTimeout(function(){window.wwe_actcnt=undefined;},500);

      if( window.wwe_actcnt == window.wwe_actseq.length && window.wwe_pageid) {
          target=$('<div id="wwE_beactvtr"><a href="'+location.href.replace(/(https?:\/\/[^/]+).*/,'$1/management/?id='+window.wwe_pageid)+'">wwEdit</a></div>').appendTo('body');
          target.height("10");
          target.width("10");
          target.css('position','fixed')
                .css('bottom',0).css('right',0).css('cursor','pointer')
                .css('background','#D8BD7D').css('padding','3px').find('a').css('color','#000')
                .css('font-size','8px');
          window.setTimeout(window.wwE_beactvtr_killer,1000);

      }
    } else {
        window.wwe_actcnt=undefined;
    }
  });
});

