function Splitter (idSplitter,splitterType,idC1,idC2,callBack,initPos,sWidth){
if (sWidth == undefined) sWidth=4;
if (initPos== undefined) initPos=100;
	this.splitter= null;
	this.idSplitter=frameObj+idSplitter;
	this.idC1=frameObj+idC1;
	this.idC2=frameObj+idC2;
	this.splitterType=splitterType;
	this.sWidth=sWidth;
	this.initPos=initPos;
	this.callBack=callBack;
	this.splitbackW=250;
	
	
	
	this.control1 = null
	this.control2 = null
		
	this.idPanel=frameObj+idSplitter + '_panel';
	this.idSplitBar=frameObj+idSplitter + '_bar';
	this.idContainer=null;	
	this.Split_pos=initPos;
	this.Split_Min=0;
	this.loaded=false;
	
	
	var thisSpl = this;
	
	this.create = function() {	
	
		if ( $(this.idC1).parentNode.id !== $(this.idC2).parentNode.id ) {	alert(this.idC1 + ' and ' + this.idC2 + ' dont have a common parent container'); } 
		else {this.idContainer= $(this.idC1).parentNode.id }


		if (this.splitterType=="v") {
			sFloat="left"; sBordR="solid"; sBordRW=this.sWidth+"px"; sBordB="none"; sBordBW=""; sCursor="e-resize"; sInitW="250px"; sInitH=""; }
		else {	sFloat="top"; sBordR="none"; sBordRW=""; sBordB="solid"; sBordBW=this.sWidth+"px"; sCursor="n-resize"; sInitW=""; sInitH="250px"; }

		if(sFloat="top" && browser.msie) sFloat="" ;
		
		var cPanel= document.createElement('div');
		cPanel.id=this.idPanel;
		cPanel.style.position="absolute";
		cPanel.className="splitter";
		cPanel.style.width=sInitW;		cPanel.style.height=sInitH;
		browser.msie ? cPanel.style.styleFloat=sFloat : cPanel.style.cssFloat=sFloat;
		cPanel.style.borderRightStyle=sBordR;
		cPanel.style.borderRightWidth=sBordRW;		
		cPanel.style.borderBottomStyle=sBordB;
		cPanel.style.borderBottomWidth=sBordBW;
		cPanel.style.overflow="auto";
		
		
		var cSplitter= document.createElement('div');
		cSplitter.id=this.idSplitter;
		cSplitter.className="splitter";
		cSplitter.style.cursor=sCursor;
		cSplitter.style.position="absolute";//	cSplitter.style.visibility="hidden";
		cSplitter.style.zIndex="999";		
//		browser.msie ? cSplitter.style.filter='alpha(opacity=' + 0 + ')' : cSplitter.style.opacity = 0;
		//cSplitter.style.backgroundColor="#999";

		var cSplitBar= document.createElement('div');
		cSplitBar.id=this.idSplitBar;
		cSplitBar.className="splitBar";
		cSplitBar.style.cursor=sCursor;		cSplitBar.style.borderWidth="2px"; cSplitBar.style.fontSize="1px";
		cSplitBar.style.position="absolute";//		cSplitBar.style.visibility="hidden";
		cSplitBar.style.backgroundImage="url(vgrabber.gif)";
		cSplitBar.style.backgroundRepeat="no-repeat";
		cSplitBar.style.backgroundPosition="center";		
		
		cSplitBar.style.zIndex="999";	//	cSplitBar.style.backgroundColor="#999";
		
		cContainer=$(this.idContainer);
		if (cContainer.style.position!=='relative' && cContainer.style.position!=='absolute') cContainer.style.position ='relative';
		
		cPanel = cContainer.appendChild (cPanel);
		cSplitter = cContainer.appendChild (cSplitter);
		cSplitBar = cContainer.appendChild ( cSplitBar);
		cPanel.appendChild   ($(this.idC1) );
		cContainer.appendChild ($(this.idC2) );		
		browser.msie ? $(this.idC1).style.styleFloat=sFloat : $(this.idC1).style.cssFloat=sFloat;
		
		$(thisSpl.idC1).style.position='absolute';	
		$(thisSpl.idC2).style.position='absolute';
		cContainer.style.overflow="auto";

		linkEvent( $(this.idPanel) , 'onmousedown', this.splitDown );
		linkEvent( $(this.idPanel) , 'onmousemove', this.setCursor );
	//	this.setCursor($(this.idPanel));
		this.resize();
		
  	}

	this.resize = function(){
		if (thisSpl.idContainer==null) return
		
		cContainer=$(thisSpl.idContainer);
		cPanel=$(thisSpl.idPanel);
	
		if (xval(cContainer.style.width)==0) {	
			width= getWindowSize('w') ;			cContainer.style.width =width;
		}else {
			width=parseInt(cContainer.style.width)
		}
		if (xval(cContainer.style.height)==0) {	
			height= getWindowSize('h');			cContainer.style.height=height;
		}else {
			height=parseInt(cContainer.style.height)
		}			
	border=4;

		this.control1 = eval(this.idC1)
		this.control2 = eval(this.idC2) 

		c1= this.control1;
		c2= this.control2;
		
		if (this.splitterType=="v") { 

			cContainer.style.overflowY="hidden";  
			cPanel.style.overflowY="hidden";

			cPanel.style.top = 0;					cPanel.style.left = 0;
			cPanel.style.width = this.Split_pos;	cPanel.style.height = height ;

			c1.top		( 0 );
			c1.left 	( 0 );
			c1.width 	( cPanel.style.width.val()  );	
			c1.height 	( cPanel.style.height.val() - border);
			
			c2.top	 	( 0 );
			c2.left 	( cPanel.style.width.val() + (browser.msie ? 0:this.sWidth) );
			c2.width 	( width - c2.left() - 1*this.sWidth );
			c2.height 	( cPanel.style.height.val() - border );

			cContainer.style.overflowX="hidden";  
			cPanel.style.overflowX="hidden";
			

			cContainer.style.overflowY="auto";  cPanel.style.overflowY="auto";

			
		}else {		

			cContainer.style.overflowX="hidden";  
			cPanel.style.overflowX="hidden";

			cPanel.style.top = 0;			cPanel.style.left = 0;
			cPanel.style.width = width;		cPanel.style.height = thisSpl.Split_pos;

			c1.top		( 0) ;		
			c1.left 	( 0) ;
			c1.width 	( width - 2) ; 
			c1.height 	( cPanel.style.height.val() - border) ;	
			
			c2.top		( cPanel.style.height.val() + (browser.msie ? 0:this.sWidth)) ;		
			c2.left 	( 0) ;
			c2.width 	( width - 2) ;
			c2.height 	( height - cPanel.style.height.val() ) ;

			
			cContainer.style.overflowX="auto";  
			cPanel.style.overflowX="auto";
			
			cContainer.style.overflowY="hidden";  
			cPanel.style.overflowY="hidden";
		}
		
		
	//	raiseEvent(thisSpl.control1.id+'.resize')  ;
	//	raiseEvent(thisSpl.control2.id+'.resize')  ;
		
	cContainer.scrollTop=0
	cContainer.scrollLeft=0
	}

	
	this.setCursor = function (e){	
	    if (!document.addEventListener) {e=event}
   		if (thisSpl.splitterType=="v") { expr=(e.clientX -$(thisSpl.idContainer).offsetLeft> ($(thisSpl.idPanel).offsetWidth-parseInt($(thisSpl.idPanel).style.borderRightWidth)) ) }
		else { expr=(e.clientY - $(thisSpl.idContainer).offsetTop> ($(thisSpl.idPanel).offsetHeight-parseInt($(thisSpl.idPanel).style.borderBottomWidth)) ) }

        if (expr) { $(thisSpl.idPanel).style.cursor=sCursor; } 
        else {$(thisSpl.idPanel).style.cursor="default"; }
	}

    this.splitDown = function (e){    
        if (!document.addEventListener) {e=event}

		disableSelection($(thisSpl.idC1));            

   		if (thisSpl.splitterType=="v") { expr=(e.clientX-$(thisSpl.idContainer).offsetLeft > ($(thisSpl.idPanel).offsetWidth-parseInt($(thisSpl.idPanel).style.borderRightWidth)) ) }
		else { expr=(e.clientY - $(thisSpl.idContainer).offsetTop > ($(thisSpl.idPanel).offsetHeight-parseInt($(thisSpl.idPanel).style.borderBottomWidth)) ) }
    
        if (expr) {
        	if (thisSpl.splitterType=="v") { 
		        thisSpl.Split_pos        = e.clientX - $(thisSpl.idContainer).offsetLeft;		        
		        $(thisSpl.idSplitter).style.left    = thisSpl.Split_pos-thisSpl.splitbackW/2;
		        $(thisSpl.idSplitter).style.width    = thisSpl.splitbackW;
		        $(thisSpl.idSplitter).style.height= $(thisSpl.idPanel).style.height;
		        $(thisSpl.idSplitter).style.visibility='visible';
		        
		        $(thisSpl.idSplitBar).style.left    = thisSpl.Split_pos-(thisSpl.sWidth);
		        $(thisSpl.idSplitBar).style.width    = thisSpl.sWidth;
		        $(thisSpl.idSplitBar).style.height= $(thisSpl.idPanel).style.height;
		        $(thisSpl.idSplitBar).style.visibility='visible'; }
		    else {
   		        thisSpl.Split_pos        = e.clientY - $(thisSpl.idContainer).offsetTop;
//   		        $(thisSpl.idSplitter).style.left=getAllOffsets(thisSpl.idContainer,'marginLeft');
		        $(thisSpl.idSplitter).style.top    = thisSpl.Split_pos-thisSpl.splitbackW/2;
		        $(thisSpl.idSplitter).style.height    = thisSpl.splitbackW;
		        $(thisSpl.idSplitter).style.width= getElemStyle($(thisSpl.idPanel),'width');
		        $(thisSpl.idSplitter).style.visibility='visible';
		        
//		        $(thisSpl.idSplitBar).style.left=getAllOffsets(thisSpl.idContainer,'marginLeft');
		        $(thisSpl.idSplitBar).style.top    = thisSpl.Split_pos-(thisSpl.sWidth);
		        $(thisSpl.idSplitBar).style.height = thisSpl.sWidth;
		        $(thisSpl.idSplitBar).style.width= $(thisSpl.idPanel).style.width;//getElemStyle($(thisSpl.idPanel),'width');
		        $(thisSpl.idSplitBar).style.visibility='visible'; 
		        
		        }
		       
            linkEvent($(thisSpl.idContainer), 'onmousemove', thisSpl.splitMove);
            linkEvent($(thisSpl.idContainer), 'onmouseup', thisSpl.splitUp);
            
            
        }            
    }
    
    this.splitMove = function (e){
        if (!document.addEventListener) {e=event} {
                
	   		if (thisSpl.splitterType=="v") { 
		        sPos = (e.clientX >= thisSpl.Split_Min) ? e.clientX : thisSpl.Split_Min;
		        sPos =sPos - $(thisSpl.idContainer).offsetLeft;          
		        $(thisSpl.idSplitter).style.left=sPos -thisSpl.splitbackW/2 + "px";         
		        $(thisSpl.idSplitBar).style.left= sPos + "px"; 
			 }
			else { 
			    sPos = (e.clientY >= thisSpl.Split_Min) ? e.clientY : thisSpl.Split_Min;
			    sPos =sPos - $(thisSpl.idContainer).offsetTop;        
		        $(thisSpl.idSplitter).style.top=sPos -thisSpl.splitbackW/2 + "px";         
		        $(thisSpl.idSplitBar).style.top= sPos + "px"; 
			 }
			 thisSpl.Split_pos=sPos;
        }        
    }
    
    this.splitUp = function (e){
        if (!document.addEventListener) {e=event}

        $(thisSpl.idSplitter).style.visibility='hidden'; $(thisSpl.idSplitBar).style.visibility='hidden';        
        unlinkEvent($(thisSpl.idContainer), 'onmousemove', thisSpl.splitMove);
        unlinkEvent($(thisSpl.idContainer), 'onmouseup', thisSpl.splitUp);
               

		thisSpl.resize();
        if(thisSpl.callBack) thisSpl.callBack();
        
        enableSelection($(thisSpl.idC1));
        
    }
	
	
	this.tryLoad= function(){ 
		
	//	console.log(this, (this.idC1) , (this.idC2)  )
		
		if ( $(this.idC1) && $(this.idC2) ) { 
		
			if (!this.loaded) { this.loaded=true; 	this.create(); }
			return true; }
		else { setTimeout (function(){	thisSpl.tryLoad()	}, 200);
			return false }
	} 

this.tryLoad();

}
