var jCT=function(dat,foo){
  var txt,ve=0,typ=typeof(foo),re=true;
  switch(typ){
    case'string':txt=foo;
    break;
    case'undefined':txt=document.body.innerHTML;
    break;
    case'object':txt='';
    return false
  }
  if(true==dat){
    while(del('<!--v-->','<!--v-->'));
    document.body.innerHTML=txt;
    return true
  }
  var __CTA__=parse();
  var funstr=toFunStr();
	//if(window.console)
	//	console.dir(__CTD__);
	funstr=new Function('__CTD__','__CTA__',funstr);//eval('""||'+funstr);
	//var t1=getMilliseconds();
	txt=funstr(dat,__CTA__);
	//window.Fun=__CTA__;
	//getMilliseconds(t1);
  switch(typ){
    case'string':re=re?txt:re;
    break;
    case'undefined':document.body.innerHTML=txt;
    break;
    case'object':txt='';
    return false
  }
  return re;
  function toFunStr(){
    var fun=[];
    //fun.push("(function (__CTD__){"+"var __CTV__ = []; "+"with(__CTD__){");
		fun.push("var __CTV__ = []; ")
		//fun.push("with(__CTD__){");
    for(var i=0;i<__CTA__.length;i++){
      if(typeof(__CTA__[i])=='string'){
        if(__CTA__[i]!='')
          fun.push('__CTV__.push(__CTA__['+i+']);')
      }
      else{
        __CTA__[i][1]=__CTA__[i][1]||'';
        switch(__CTA__[i][0]){
          case'@':case'=':if(__CTA__[i][1]!='')fun.push('__CTV__.push('+__CTA__[i][1]+');');
          break;
          case'end':fun.push('}');
          break;
          case'var':fun.push('var '+__CTA__[i][1]+';');
          break;
          case'continue':fun.push('continue '+__CTA__[i][1]+';');
          break;
          case'break':fun.push('break '+__CTA__[i][1]+';');
          break;
          case'elseif':fun.push("}else if("+__CTA__[i][1]+"){");
          break;
          case'else':fun.push("}else{"+__CTA__[i][1]);
          break;
          case'function':fun.push('function'+__CTA__[i][1]+';');
          break;
          case'with':fun.push("with("+__CTA__[i][1]+"){");
          break;
          case'if':fun.push("if("+__CTA__[i][1]+"){");
          break;
          case'while':fun.push("while("+__CTA__[i][1]+"){");
          break;
          case'for':fun.push("for("+__CTA__[i][1]+"){");
          break;
          case'switch':fun.push("switch("+__CTA__[i][1]+"){");
          break;
          case'case':fun.push('case '+__CTA__[i][1]+':');
          break;
          case'default':fun.push('default:');
          break;
          case'run':fun.push(__CTA__[i][1]);
          break
        }
      }
    }
    //fun.push("}return __CTV__.join('');})");
		//fun.push("}");
		fun.push("\nreturn __CTV__.join('');");
    return fun.join('')
  }
  function del(begin,end,nodel){
    var s=ve,b=txt.indexOf(begin,ve);
    if(b<0)
      return false;
    ve=txt.indexOf(end,b+begin.length);
    if(ve<0)
      return false;
    ve=ve+end.length;
    var re=txt.slice(b+begin.length,ve);
    if(!nodel){
      txt=txt.slice(s,b)+txt.slice(ve)
    }
    return re
  }
  function parse(){
    function parseV(txt){
      if(txt=='')
        return[];
      var rea=[];
      ve=0;
      var a=exev(txt);
      if(!a)
        return txt;
      while(a){
        if(a[1][0]==' ')
          rea.push(a[0]+'{'+a[1].slice(1)+'}');
        else{
          if(a[0]!='')
            rea.push(a[0]);
          rea.push(['@',a[1]])
        }
        a=exev(txt)
      }
      rea.push(txt.substring(ve));
      return rea
    }
    function exev(txt){
      var s=ve,b=txt.indexOf('+-',ve);
      if(b<0)
        return false;
      ve=txt.indexOf('-+',b+2);
      if(ve<0){
        ve=s;
        return false
      }
      ve=ve+2;
      return[txt.slice(s,b),unescape(txt.slice(b+2,ve-2))]
    }
    function exec(){
      var s=ce,b=txt.indexOf('<!--',ce);
      if(b<0)
        return false;
      ce=txt.indexOf('-->',b+4);
      if(ce<0){
        ce=s;
        return false
      }
      ce=ce+3;
      return[txt.slice(s,b),txt.slice(b+4,ce-3)]
    }
    var res=[],a,lasttxt,tag,ce=0;
    ve=0;
    while(del('<!--v-->','<!--v-->'));
    ve=0;
    while(del('<!--##','<!--#-->'));
    ve=0;
    while(del('<!--\/','-->'));
    ve=0;
    var tpl;
    while(true){
      tpl=del('<!--#!','<!--#-->');
      if(!tpl)
        break
    }
    ve=0;
    while(true){
      tpl=del('<!--# ','<!--#-->',true);
      if(!tpl)
        break
    }
    var tagre=/(?:^(run|var|with|function|if|elseif|while|for|continue|break|switch|case|default)\b((?:.|\r|\n)+))/im;
    ve=0;
    a=exec();
    while(a){
      if(a[0]!='')
        res=res.concat(parseV(a[0]));
      if(a[1]=='end'||a[1]=='else'||a[1]=='do')
        a[1]=[a[1]];
      else a[1]=(tagre.exec(a[1])||'').slice(1);
      if(a[1]!='')
        res.push(a[1]);
      a=exec()
    }
    txt=txt.substring(ce);
    if(txt!='')
      res=res.concat(parseV(txt));
    return res
  }
}
;
jCT.toString=function(){
  return{
  }
}
