/*
Foundation
Copyright © 2005-2009 Scott Nesin, all rights reserved.
Documentation: http://FoundationDotJS.org/
*/
/*
   ***** Preprocessed code, any modifications will be lost. *****
     Foundation.js, object oriented JavaScript framework:
     http://FoundationDotJS.org/
     Preprocessed for speed:
     http://FoundationDotJS.org/Foundation.Preprocessor.htm
*/
var Foundation;
if (!Foundation)
{
String.prototype.htmlEncode=function(){return this.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");};
String.prototype.xmlEncode=function(){return this.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;");};
String.prototype.urlEncode=function(){return escape(this).replace(/\+/g,"%2B").replace(/\//g,"%2F").replace(/@/g,"%40").replace(/%20/g,"+").replace(/%21/g,"!").replace(/%27/g,"'").replace(/%28/g,"(").replace(/%29/g,")");};
String.prototype.cEncode=function(){return this.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,"\\\"").replace(/\r/g,"\\r").replace(/\n/g,"\\n");};
String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"");};
String.prototype.setAt=function(index,value){value=value.toString();return this.substr(0,index)+value+this.substr(index+value.length);};

/*@cc_on @*/
/*@if (@_jscript_version >= 5.5)
String.prototype.regExpEncode=function(){return this.replace(/\\|\^|\$|\*|\+|\?|\.|\||\-|\{|\}|\(|\)|\[|\]/g,"\\$&");};
String.prototype.replaceEncode=function(){return this.replace(/\$/g,"$$$$");};
  @else @*/
String.prototype.regExpEncode=function(){return this.replace(/\\/g,"\\\\").replace(/\^/g,"\\^").replace(/\$/g,"\\$").replace(/\*/g,"\\*").replace(/\+/g,"\\+").replace(/\?/g,"\\?").replace(/\./g,"\\.").replace(/\|/g,"\\|").replace(/\-/g,"\\-").replace(/\{/g,"\\{").replace(/\}/g,"\\}").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/\[/g,"\\[").replace(/\]/g,"\\]");};
String.prototype.replaceEncode=function(){return this;};
/*@end @*/
if (typeof(Array.prototype.push)!="function")Array.prototype.push=new Function("var l=this.length;var i;for(i=0;i<arguments.length;i++)this[l+i]=arguments[i];return l+i;");
if (typeof(Array.prototype.pop)!="function")Array.prototype.pop=new Function("if (this.length>1){var v=this[this.length-1];this.length--;return v;}");
if (typeof(Function.prototype.apply)!="function")Function.prototype.apply=new Function("o","a","o.$=this;var c='o.$(';var i;for(i=0;i<a.length;i++){if(i>0)c+=',';c+='a['+i+']';}c+=')';var v=eval(c);o.$=(function(){})();return v;");
if (typeof(Function.prototype.call)!="function")Function.prototype.call=new Function("o","o.$=this;var c='o.$(';var i;for(i=1;i<arguments.length;i++){if(i>1)c+=',';c+='arguments['+i+']';}c+=')';var v=eval(c);o.$=(function(){})();return v;");

Foundation=function(namespace)
{
   if(namespace)
      return namespace;
};
Foundation.prototype.constructor=Foundation;
Foundation=new Foundation();
Foundation.Namespace=Foundation.constructor;
Foundation.namespace=function(namespace,propertyList)
{
   namespace=new Foundation.Namespace(namespace);
   if (propertyList)
      for (var i in propertyList)
         if (i!="prototype" && i!="constructor")
            namespace[i]=propertyList[i];
   return namespace;
};
Foundation.Class=function()
{
};
Foundation.Class.prototype.constructor=Foundation.Class;
Foundation.Class.isInstanceOf=function(theClass)
{
   for (var c=this;c;c=c.$parentClass)
      if (c==theClass)
         return true;
      else
         if (c.$interfaces)
            for (var i=0;i<c.$interfaces.length;i++)
               if (c.$interfaces[i]==theClass)
                  return true;
   return false;
};
Foundation.Interface=function()
{
};
Foundation.Interface.prototype.constructor=Foundation.Interface;
Foundation.$registry=new Array(null);
Foundation.createClass=function()
   {
      var parentClass=null;
      var interfaces=new Array();
      var classConstructor=null;
      var virtualProperties=null;
      var staticProperties=null;
      var isInterface=false;
      for (var constructorIndex=arguments.length-1;constructorIndex>=0;constructorIndex--)
         if (typeof(arguments[constructorIndex])=="function")
         {
            classConstructor=arguments[constructorIndex];
            if (constructorIndex>0)
               parentClass=arguments[0];
            for (var i=1;i<constructorIndex;i++)
               interfaces.push(arguments[i]);
            break;
         }
      if (arguments.length>constructorIndex+1 && typeof(arguments[constructorIndex+1])=="object")
          virtualProperties=arguments[constructorIndex+1];
      if (arguments.length>constructorIndex+2 && typeof(arguments[constructorIndex+2])=="object")
          staticProperties=arguments[constructorIndex+2];
      if (arguments.length>0 && typeof(arguments[arguments.length-1])=="boolean" && arguments[arguments.length-1])
         isInterface=true;
      return Foundation.$createClass(parentClass,interfaces,classConstructor,virtualProperties,staticProperties,isInterface);
   };
Foundation.createInterface=function()
   {
      arguments[arguments.length++]=true;
      return Foundation.createClass.apply(this,arguments);
   };
Foundation.$createClass=function(parentClass,interfaces,classConstructor,virtualProperties,staticProperties,isInterface)
   {
      if (!classConstructor)
         classConstructor=new Function();
      if (parentClass)
      {
         classConstructor=Foundation.transformConstructor(classConstructor,parentClass);
         classConstructor.$parentClass=parentClass;
         if (!classConstructor.$parentClass.$childClasses)
            classConstructor.$parentClass.$childClasses=new Array();
         classConstructor.$parentClass.$childClasses.push(classConstructor);
      }
      else
         classConstructor.$parentClass=null;
      classConstructor.$interfaces=new Array();
      classConstructor.$childClasses=new Array();
      if (isInterface)
         classConstructor.$interfaces.push(Foundation.Interface);
      else
         if (!parentClass || !parentClass.isInstanceOf)
            classConstructor.$interfaces.push(Foundation.Class);
      for (var i=0;i<interfaces.length;i++)
         classConstructor.$interfaces.push(interfaces[i]);
      interfaces=classConstructor.$interfaces;
      for (var i=interfaces.length-1;i>=0;i--)
         Foundation.inheritInterface(classConstructor,interfaces[i]);
      if (parentClass)
         Foundation.inheritInterface(classConstructor,parentClass);
      for (var i=0;i<interfaces.length;i++)
         Foundation.inheritInterface(classConstructor,interfaces[i],true);
      if (virtualProperties)
         Foundation.addVirtualProperties(classConstructor,virtualProperties);
      if (staticProperties)
         Foundation.addStaticProperties(classConstructor,staticProperties);
      return classConstructor;
   };
Foundation.addVirtualProperties=function(theClass,properties)
   {
      var n=null;
      var noTransform=(!theClass.$parentClass);
      while (n=Foundation.getNextCustomPropertyName(properties,n))
      {
         var p=properties[n];
         theClass.prototype[n]=(noTransform || typeof(p)!="function" ? p : Foundation.transformMethodSupers(p,theClass.$parentClass.prototype));
      }
   };
Foundation.addStaticProperties=function(theClass,properties)
   {
      var n=null;
      var noTransform=!theClass.$parentClass;
      while (n=Foundation.getNextCustomPropertyName(properties,n))
      {
         var p=properties[n];
         theClass[n]=(noTransform || typeof(p)!="function" ? p : Foundation.transformMethodSupers(p,theClass.$parentClass));
      }
   };
Foundation.inheritInterface=function(theClass,theInterface,precedenceOnly)
   {
      Foundation.copyProperties(theClass.prototype,theInterface.prototype,precedenceOnly);
      Foundation.copyProperties(theClass,theInterface,precedenceOnly);
   };
Foundation.copyProperties=function(object,properties,precedenceOnly)
   {
      var n=null;
      while (n=Foundation.getNextCustomPropertyName(properties,n,true,true))
         if (n.length>11 && n.substr(0,11)=="precedence$")
            object[n.substr(11)]=properties[n];
         else
            if (!precedenceOnly)
               object[n]=properties[n];
   };
Foundation.getFunctionParts=function(theFunction)
   {
      if (theFunction.toString().search(/function[^\(]*\(([^)]*)\)[^\{]*\{([\w\W]*)\}[^\}]*$/)<0)
         return null;
      return {parameters:RegExp.$1,body:RegExp.$2};
   };
Foundation.getNativeClassName=function(theClass)
   {
      if (theClass==Array) return "Array";
      if (theClass==String) return "String";
      if (theClass==Number) return "Number";
      if (theClass==Object) return "Object";
      if (theClass==Date) return "Date";
      if (theClass==Boolean) return "Boolean";
      if (theClass==Function) return "Function";
      return null;
   };
Foundation.transformConstructor=function(classConstructor,parentClass)
   {
      var constructorParts=Foundation.getFunctionParts(classConstructor);
      var nativeParentName=Foundation.getNativeClassName(parentClass);
      var parentParts=Foundation.getFunctionParts(parentClass);
      var constructorCode="function("+constructorParts.parameters+"){";
      if (constructorParts.body.search(/^([\w\W]*[^\$\w])Super\s*\(([^\)]*)\)([\w\W]*)$/)==0)
      {
         var p1=RegExp.$1;
         var p2=RegExp.$2;
         var p3=RegExp.$3;
         constructorCode+=p1;
         if (nativeParentName)
            constructorCode+=nativeParentName+".call(this";
         else
            constructorCode+="(function("+parentParts.parameters+"){"+parentParts.body+"}).call(this";
         if (p2.trim().length>0)
            constructorCode+=","+p2;
         constructorCode+=")"+p3;
      }
      else
      {
         if (!nativeParentName)
            constructorCode+="(function("+parentParts.parameters+"){"+parentParts.body+"}).apply(this,arguments);";
         constructorCode+=constructorParts.body;
      }
      constructorCode+="}";
      var rootParent=parentClass;
      while (rootParent.$parentClass)
         rootParent=rootParent.$parentClass;
      var nativeRootParentName=Foundation.getNativeClassName(rootParent);
      if (nativeRootParentName)
         constructorCode=Foundation.wrapConstructorForNatives(constructorCode,nativeRootParentName);
      try
      {
         eval("classConstructor="+constructorCode);
      }
      catch (e)
      {
         alert("error transforming constructor\n\n"+constructorCode);
         throw(e);
      }
      return Foundation.transformMethodSupers(classConstructor,parentClass.prototype);
   };
Foundation.wrapConstructorForNatives=function(constructorCode,nativeName)
   {
      var newCode="";
      newCode+="function(){var $_=null;if(this.constructor==arguments.callee){";
      if (nativeName=="Function")
         newCode+="$_=Function.apply(null,arguments.length<1||typeof(arguments[0])==\"string\"?arguments:arguments[0]);";
      else if (nativeName=="Array")
         newCode+="$_=new Array;";
      else
         newCode+="$_="+nativeName+".call(null,arguments[0]);";
      newCode+="$_.constructor=arguments.callee;for(var i in arguments.callee.prototype)$_[i]=arguments.callee.prototype[i];}";
      if (constructorCode)
      {
         newCode+="(";
         newCode+=constructorCode;
         newCode+=").apply($_!=null?$_:this,arguments);";
      }
      newCode+="if($_!=null)return $_;}";
      return newCode;
   };
Foundation.transformMethodSupers=function(theFunction,parentObject)
   {
      var parts=Foundation.getFunctionParts(theFunction);
      var transformedCode=Foundation.transformSuperCode(parts.body,parentObject);
      if (transformedCode!=parts.body)
      {
         var functionCode="function("+parts.parameters+"){"+transformedCode+"}";
         try
         {
            eval("theFunction="+functionCode);
         }
         catch (e)
         {
            alert("Error transforming method:\n\n"+functionCode);
            throw(e);
         }
      }
      return theFunction;
   };
Foundation.transformSuperCode=function(code,parentObject)
   {
      var outCode="";
      var s;
      while ((s=code.search(/(^|[^\$\w]+)Super\s*\.\s*([\$\w]+)\s*\(([\w\W]*)$/))>=0)
      {
         outCode+=code.substr(0,s+RegExp.$1.length);
         var name=RegExp.$2;
         code=RegExp.$3;
         if (typeof(parentObject)=="string")
            outCode+=parentObject+"."+name+".call(this";
         else
         {
            var parentParts=Foundation.getFunctionParts(parentObject[name]);
            if (parentParts==null)
               throw("method "+name+" not implemented in parent class");
            outCode+="(function("+parentParts.parameters+"){"+parentParts.body+"}).call(this";
         }
         if (code.search(/^\s*\)/)<0)
            outCode+=",";
      }
      outCode+=code;
      return outCode;
   };
Foundation.isNativeFunction=function(theFunction)
   {
      theFunction=theFunction.toString();
      var b=theFunction.indexOf("{");
      if (b>0)
         theFunction=theFunction.substr(b+1);
      b=theFunction.lastIndexOf("}");
      if (b>0)
         theFunction=theFunction.substr(0,b);
      theFunction=theFunction.trim().toLowerCase();
      return (theFunction=="[native code]" || theFunction=="(internal function)");

   };
Foundation.getNextCustomPropertyName=function(object,property,functionsOnly,noHidden)
   {
      if (!property) property=null;
      for (var i in object)
         if (i!="prototype" && i!="constructor" && i!="toString" && i!="valueOf" && (!functionsOnly || typeof(object[i])=="function") && (!noHidden || i.charAt(0)!='$'))
            if (property==null)
               return i;
            else
               if (i==property)
                  property=null;
      if (!Foundation.isNativeFunction(object.toString))
         if (property==null)
            return "toString";
         else
            if ("toString"==property)
               property=null;
      if (!Foundation.isNativeFunction(object.valueOf))
         if (property==null)
            return "valueOf";
         else
            if ("valueOf"==property)
               property=null;
      return null;
   };
Foundation.getXmlHttpRequest=function()
   {
      if (typeof(XMLHttpRequest)!="undefined")
         return new XMLHttpRequest();
      if (typeof(ActiveXObject)!="undefined")
         return new ActiveXObject("Microsoft.XMLHTTP");
      return null;
   };
Foundation.urlDomain=function(url)
   {
      if (url.search(/\:\/\/([^\/\:]+)\//)>0)
                     return RegExp.$1;
      return document.domain;
   };
Foundation.conformUrlToDocumentDomain=function(url)
   {
      if (!document.domain)
         return url;
      var urlDomain=Foundation.urlDomain(url);
      var docDomain=document.domain;
      if (urlDomain.toLowerCase()!=docDomain.toLowerCase() &&
          ("www."+urlDomain.toLowerCase()==docDomain.toLowerCase() ||
           urlDomain.toLowerCase()=="www."+docDomain.toLowerCase()))
         url=url.replace(urlDomain,docDomain);
      return url;
   };
Foundation.loadScriptDomainsMustMatch=(function()
   {
      if (typeof(document)!="undefined" && document.domain &&
          window.navigator.appVersion.search(/Safari\/(\d+)/i)>=0)
         return (parseFloat(RegExp.$1)<412.5);
      return false;
   })();
Foundation.loadScriptDomainMismatch=function(url)
   {
      if (Foundation.loadScriptDomainsMustMatch)
      {
         var domain=Foundation.urlDomain(url);
         var dir=domain.split('.')[0];
         return url.replace(domain,document.domain+'/'+dir);
      }
      throw("domain mismatch");
   };
Foundation.scriptsToExec=new Array();
Foundation.handleXmlHttpRequestOnreadystatechange=function(request,url,postData,catchFunction)
   {
      if (request && request.readyState==4)
         if (typeof(request.responseText)=="string" && request.responseText.length>0)
         {
            postData=(postData ? "'"+postData.cEncode()+"'" : "null");
            if(window.execScript)
               if (catchFunction)
               {
                  var i=Foundation.scriptsToExec.length;
                  Foundation.scriptsToExec[i]=request.responseText;
                  window.setTimeout("try{eval(Foundation.scriptsToExec["+i+"]);}catch(e){"+catchFunction+"('"+url.cEncode()+"',"+postData+",Foundation.scriptsToExec["+i+"],e);}Foundation.scriptsToExec["+i+"]=null;",1);
               }
               else
                  window.execScript(request.responseText);
            else
            {
               var i=Foundation.scriptsToExec.length;
               Foundation.scriptsToExec[i]=request.responseText;
               if (catchFunction)
               {
                  window.setTimeout("try{eval(Foundation.scriptsToExec["+i+"]);}catch(e){"+catchFunction+"('"+url.cEncode()+"',"+postData+",Foundation.scriptsToExec["+i+"],e);}Foundation.scriptsToExec["+i+"]=null;",1);
               }
               else
                  window.setTimeout("eval(Foundation.scriptsToExec["+i+"]);Foundation.scriptsToExec["+i+"]=null;",1);
            }
            return 1;
         }
         else
            return -1;
      return 0;
   };
Foundation.loadScript=function(url,postData,debug,catchFunction)
   {
      if (typeof(catchFunction)=="string")
         catchFunction="'"+catchFunction.cEncode()+"'";
      else
         catchFunction="null";
      if (arguments.length>4 && arguments[4])
      {
         url=Foundation.conformUrlToDocumentDomain(url);
         if (debug)
            window.open(url,"_blank");
         else
         {
            try
            {
               if (document.domain &&
                   Foundation.urlDomain(url).toLowerCase()!=document.domain.toLowerCase())
                  url=Foundation.loadScriptDomainMismatch(url);
               var callback=new Function("var r=Foundation.handleXmlHttpRequestOnreadystatechange(arguments.callee.request,arguments.callee.url,arguments.callee.postData,"+catchFunction+");if(r!=0)arguments.callee.request=null;if(r<0)throw('xmlhttprequestfailed');");
               callback.url=url;
               callback.request=Foundation.getXmlHttpRequest();
               callback.request.onreadystatechange=callback;
               if (typeof(postData)=="string")
               {
                  callback.postData=postData;
                  callback.request.open("POST",url,true);
                  callback.request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                  callback.request.send(postData);
               }
               else
               {
                  callback.postData=null;
                  callback.request.open("GET",url,true);
                  callback.request.send("");
               }
            }
            catch (e)
            {
               if (typeof(postData)=="string")
                  return false;
               var script=document.createElement("SCRIPT");
               script.src=url;
               document.body.appendChild(script);
            }
         }
         if (Foundation.onScriptStartLoad)
            Foundation.onScriptStartLoad();
      }
      else
         window.setTimeout("Foundation.loadScript(\""+url.cEncode()+"\","+(typeof(postData)=="string" ? "\""+postData.toString().cEncode()+"\"" : "null")+","+(debug ? "true" : "false")+","+catchFunction+",true);",1);
      return true;
   };
Foundation.debug=function()
   {
      if (typeof(Foundation.console)!="undefined")
         Foundation.console.write.apply(Foundation.console,arguments);
   };
Foundation.StringBuilder=function(initialSize)
   {
      if(!initialSize)initialSize=1000;this.strings=new Array(initialSize+1);this.strings[0]="";
   };
Foundation.StringBuilder.$parentClass=null;
Foundation.StringBuilder.$interfaces=new Array();
Foundation.StringBuilder.$interfaces.push(Foundation.Class);
Foundation.StringBuilder.prototype={
   constructor:Foundation.StringBuilder,   
   append:function(value){this.strings.push(value);return this;},   
   clear:function(){this.strings.length=1;return this;},   
   toString:function(){this.strings[1]=this.strings.join("");this.strings.length=2;return this.strings[1];}
};
Foundation.StringBuilder.isInstanceOf=Foundation.Class.isInstanceOf;
   Foundation.Elemental=function() {

};
Foundation.Elemental.$parentClass=null;
Foundation.Elemental.$interfaces=new Array();
Foundation.Elemental.$interfaces.push(Foundation.Interface);
Foundation.Elemental.prototype={
   constructor:Foundation.Elemental,   
   event:function(code,delayed,disable)
      {
         if (!this.$Foundation_$registry_index)
            Foundation.$registry[this.$Foundation_$registry_index=Foundation.$registry.length]=this;
         code="Foundation.$registry["+this.$Foundation_$registry_index+"]"+(code ? "."+code : "");
         if (delayed)
         {
            if (arguments.length<3)
               disable=true;
            code=(disable ? "this.disabled=true;" : "")+"window.setTimeout('"+code.cEncode()+"',1);";
         }
         return code;
      },   
   elementId:function(id,index)
      {
         if (!this.$Foundation_$registry_index)
            this.event();
         return "Foundation_Elemental_"+this.$Foundation_$registry_index+"_"+id+(typeof(index)=="number" ? "_"+index : "");
      },   
   getElement:function(id,index)
      {
         return document.getElementById(this.elementId(id,index));
      },   
   getElementValue:function(id,defaultValue)
      {
         var element=this.getElement(id);
         if (element)
            return element.value;
         return defaultValue;
      },   
   parseElementId:function(id)
      {
         var subId=this.elementId("");
         if (!id || id.length<subId.length || id.substr(0,subId.length)!=subId)
            return null;
         return id.substr(subId.length);
      },   
   attachEvent:function(element,eventName,code)
      {
         var f;
         if (document.all && eventName=="ondeactivate") eventName="onblur";
         if (!document.all && eventName=="onblur") eventName="ondeactivate";
         if (typeof(element)=="string")
            element=document.getElementById(element);
         if (document.attachEvent)
            element.attachEvent(eventName,f=new Function("return "+this.event(code)));
         else
            if (eventName=="onkeypress" && Foundation.loadScriptDomainsMustMatch && !element.onkeypress)
               element.onkeypress=f=new Function("event","return "+this.event(code));
            else
               element.addEventListener(eventName.substr(2),f=new Function("event","return "+this.event(code)),false);
         return f;
      },   
   detachEvent:function(element,eventName,f)
      {
         if (document.all && eventName=="ondeactivate") eventName="onblur";
         if (!document.all && eventName=="onblur") eventName="ondeactivate";
         if (typeof(element)=="string")
            element=document.getElementById(element);
         if (document.detachEvent)
            element.detachEvent(eventName,f);
         else
            if (eventName=="onkeypress" && Foundation.loadScriptDomainsMustMatch && element.onkeypress)
               element.onkeypress=null;
            else
               element.removeEventListener(eventName.substr(2),f,false);
      },   
   copyProperty:function(name,value)
      {
         this[name]=value;
      },   
   copyProperties:function(properties)
      {
         var a;
         for (var i=0;i<arguments.length;i++)
            if (a=arguments[i])
               for (var j in a)
                  if (j!="prototype" && j!="constructor")
                     this.copyProperty(j,a[j]);
      },   
   elementalDispose:function()
      {
         if (this.$Foundation_$registry_index)
         {
            Foundation.$registry[this.$Foundation_$registry_index]=null;
            this.$Foundation_$registry_index=null;
         }
      }
};
Foundation.Resourceful=function(resource,args)
   {
      if (typeof(resource)=="string" && args.length>2)
      {
         resource=resource.split('%');
         var cookedResource=new Array(resource.length);
         for (var ia=2;ia<args.length;ia+=2)
         {
            var a=args[ia-1].toString();
            for (var ir=1;ir<resource.length;ir++)
            {
               var r=resource[ir];
               if (r!=null &&
                   r.length>=a.length &&
                   r.substr(0,a.length)==a)
               {
                  cookedResource[ir]=args[ia]+r.substr(a.length);
                  resource[ir]=null;
               }
            }
         }
         for (var ir=0;ir<resource.length;ir++)
            if (resource[ir]!=null)
               cookedResource[ir]=(ir>0 ? '%' : '')+resource[ir];
         resource=cookedResource.join("");
      }
      return resource;
   };
Foundation.Resourceful.$parentClass=null;
Foundation.Resourceful.$interfaces=new Array();
Foundation.Resourceful.$interfaces.push(Foundation.Interface);
Foundation.Resourceful.prototype={
   constructor:Foundation.Resourceful,   
   resource:function(index)
      {
         var resource=null;
         if (this.resourcePack && typeof(this.resourcePack[index])!="undefined")
            resource=this.resourcePack[index];
         else
            resource=this.constructor.resource(index);
         return Foundation.Resourceful(resource,arguments);
      }
};
Foundation.Resourceful.resource=function(index)
      {
         var resource=null;
         if (this.resourcePack && typeof(this.resourcePack[index])!="undefined")
            resource=this.resourcePack[index];
         else
            if (this.$parentClass && this.$parentClass.resource)
               resource=this.$parentClass.resource(index);
         return Foundation.Resourceful(resource,arguments);
      };
Foundation.ClientLoader=function()
      {
         this.debug=this.constructor.debug;
         this.parameterStore=new Object();
         this.scripts=null;
         this.timerHandle=0;
         this.testInterval=this.resource("testInterval");;
      };
Foundation.ClientLoader.$parentClass=null;
Foundation.ClientLoader.$interfaces=new Array();
Foundation.ClientLoader.$interfaces.push(Foundation.Class);
Foundation.ClientLoader.$interfaces.push(Foundation.Elemental);
Foundation.ClientLoader.$interfaces.push(Foundation.Resourceful);
Foundation.ClientLoader.prototype={
   constructor:Foundation.ClientLoader,   
   requestScriptList:function(resourceKey,parameters)
         {
            var url=this.resource(resourceKey);
            url+=(url.indexOf('?')<0 ? "?" : "&")+(parameters ? parameters+"&" : "")+"callback="+this.event("receiveScriptList").urlEncode()+"&debug="+(this.debug?"true":"false")+"&nocache="+Date.parse(new Date());
            Foundation.loadScript(url,null,this.debug);
         },   
   receiveScriptList:function(scripts)
         {
            this.scripts=scripts;
            this.loadScriptList();
         },   
   abort:function()
         {
            var inProgress=this.timerHandle!=0;
            this.clearTestInterval();
            return inProgress;
         },   
   clearTestInterval:function()
         {
            if (this.timerHandle!=0)
            {
               window.clearInterval(this.timerHandle);
               this.timerHandle=0;
            }
         },   
   loadScriptList:function()
         {
            for (var i=0;i<this.scripts.length;i++)
            {
               if (eval(this.scripts[i].test))
                  if (this.scripts[i].execute)
                  {
                     eval(this.scripts[i].execute);
                     this.scripts[i].test="false";
                  }
                  else
                  {
                     if (!this.scripts[i].requested)
                     {
                        if (this.timerHandle==0)
                           this.timerHandle=window.setInterval(this.event("loadScriptList();"),this.testInterval);
                        this.scripts[i].requested=true;
                        Foundation.loadScript(this.scripts[i].src);
                     }
                     return;
                  }
            }
            this.clearTestInterval();
            window.setTimeout(this.event("readyToProcess()"),1);
         },   
   readyToProcess:function()
         {
         },   
   resource:Foundation.Resourceful.prototype.resource,   
   event:Foundation.Elemental.prototype.event,   
   elementId:Foundation.Elemental.prototype.elementId,   
   getElement:Foundation.Elemental.prototype.getElement,   
   getElementValue:Foundation.Elemental.prototype.getElementValue,   
   parseElementId:Foundation.Elemental.prototype.parseElementId,   
   attachEvent:Foundation.Elemental.prototype.attachEvent,   
   detachEvent:Foundation.Elemental.prototype.detachEvent,   
   copyProperty:Foundation.Elemental.prototype.copyProperty,   
   copyProperties:Foundation.Elemental.prototype.copyProperties,   
   elementalDispose:Foundation.Elemental.prototype.elementalDispose
};
Foundation.ClientLoader.resourcePack={
            testInterval:100
         }
      ;
Foundation.ClientLoader.resource=Foundation.Resourceful.resource;
Foundation.ClientLoader.isInstanceOf=Foundation.Class.isInstanceOf;

}
