$.ajaxSetup({cache: false});

function getFormData(targ) { 
   targ = $(targ);
   var params = {}; 
   var fields = [
      "input[checked]", 
      "input[type=text]",
      "input[type=hidden]",
      "input[type=password]", 
      "input[type=submit]:checked", 
      "option[selected]", 
      "textarea"
   ];
   $(targ).find(fields.join(",")).each(function() { 

      var key = this.name || this.id || this.parentNode.name || this.parentNode.id;
      if(!key) { key = this.parentNode.parentNode.name || this.parentNode.parentNode.id; }
      if(key && key.match && key.match(/\[\]$/)) { 
         log("getFormData: " + key);
         if(params[key]) { 
             params[key].push(this.value);
          } else { 
             params[key]=[this.value];
          }
      } else { 
         if(this.FCK) { 
            var oe = FCKeditorAPI.GetInstance(this.FCK.InstanceName);
            params[key] = oe.GetHTML();
         } else { 
            params[ key ] = this.value; 
         }
      }
   }); 
   return params;
}

function refresh() {   
   if($("form").length == 1){ 
      $("form").submit();
   } else { 
      document.location.reload();
   }
}

$.fn.hasClass = function(className){
   return $(this).attr("className").match(className) > "";
}

function log(x){ 
   if(window.console && window.console.log){
      window.console.log(x);
   }
}

function extractArg(findStr, inStr) { 
   var r = new RegExp(findStr+".+\S*");
   var m = false;
   log("Extracting with " + r);
   if(m = r.exec(inStr)) { 
      return m.toString().replace(findStr,"").split(" ")[0]; 
   }
   return false;
};
function navigate(link) {
   document.location.href=document.baseURI+"/"+link;
}
function array_unique(d) {
   var r = new Array();
   o:for(var i = 0, n = d.length; i < n; i++) {
      for(var x = 0, y = r.length; x < y; x++) {
         if(r[x]==d[i]) {
            continue o;
         }
      }
      r[r.length] = d[i];
   }
   return r;
}
