

function TypeWriter(input,target,interval,callBackInterval,callback,option){
     this.captionLength=input.length;
     this.pos=1;
     this.caption=input;
     this.dest=target;
     this.callback=callback;
     this.dest.value="";
     //this.curDate = new Date();
     //alert(this.captionLength);
     this.startTyping=function(){
    	 if(this.captionLength==0){
         	return;
         }
    	 if(this.captionLength==this.pos){
    		// alert("time to return");
    		 //return;
    		 this.dest.value=this.caption;
    		 //return;
    	 }
    	 this.typing();
     }	
  
     this.typing=function(){
    	 //alert(" in tyoing...");
    	 this.dest.focus();
    	 if(option==1){
    		 this.dest.value=this.caption.substr(0,this.pos++);
    	 }
    	 if(option==2){
    		 this.dest.innerHTML=this.caption.substr(0,this.pos++);
    	 }
    	 //alert()
    	 this.dest.focus();
    	 //setTimeout("this.type();", 400);
    	 if(this.pos<=this.captionLength){
    		 //alert("type again");
    		 //setInterval("",5000);
    		 
    		var callwrapper = new CCallWrapper(this, interval,'typing');
    		CCallWrapper.asyncExecute(callwrapper);
    		// window.setTimeout(\'this.typing,interval);
    		
    		 //this.typing();

    		//this.typing();
//    		 /setTimeout("this.typing();",300);
    		 //window.setTimeout(this.typing,300);
    	 }
    	 else{
    		 //alert()
    		 var callwrapper = new CCallWrapper(this, callBackInterval,'callback');
     		CCallWrapper.asyncExecute(callwrapper);
    		//(); 
    	 }
     }
   
}
