
	function createCookie(name,value,days) 
	{
	    if (days) 
	    {
		    var date = new Date();
		    date.setTime(date.getTime()+(days*24*60*60*1000));
		    var expires = "; expires="+date.toGMTString();
	    }
	    else var expires = "";
	    document.cookie = name+"="+value+expires+"; path=/";
    }

    function readCookie(name) 
    {
        var nameEQ = name + "=";
	    var ca = document.cookie.split(';');
	    for(var i=0;i < ca.length;i++) 
	    {
		    var c = ca[i];
		    while (c.charAt(0)==' ') c = c.substring(1,c.length);
		    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	    }
	    return "";
    }

    function eraseCookie(name) 
    {
	    createCookie(name,"",-1);
    }
    
    var HookedHides = new Array();
    var HookedHidesSet = new Array();
    function HookHide(wndname, divname)
    {
        if( HookedHidesSet[wndname] != 'true' )
        {
            HookedHides[wndname] = new Array();
            HookedHidesSet[wndname] = 'true';
        }   
        HookedHides[wndname].push(divname);
    }
    
   
	var windowstatuses = new Array();

	var restorex = new Array();
	var restorey = new Array();
	var restorew = new Array();
	var restoreh = new Array();
	
	var zindexes    = new Array();
	
	function SaveWnd(wndname)
	{
	    if(wndname == '')
	        return;
	    createCookie(wndname + 'exists', 'true' );
	    
	    createCookie(wndname + 'x', strippx( document.getElementById(wndname).style.left ) );
	    createCookie(wndname + 'y', strippx( document.getElementById(wndname).style.top  ) );
	    createCookie(wndname + 'w', strippx( document.getElementById(wndname).style.width ) );
	    createCookie(wndname + 'h', strippx( document.getElementById(wndname).style.height ) );
	    createCookie(wndname + 'rx', ( restorex[wndname] ) );
	    createCookie(wndname + 'ry', ( restorey[wndname] ) );
	    createCookie(wndname + 'rw', ( restorew[wndname] ) );
	    createCookie(wndname + 'rh', ( restoreh[wndname] ) );
	    
	    createCookie(wndname + 'status', windowstatuses[wndname] );
	    
	    createCookie(wndname + 'visibility', document.getElementById(wndname).style.visibility ); 
	}
	
	// Only call on newly created, non-minimized or maximized windows
	function RestoreWnd(wndname)
	{
	
	    var exists = readCookie(wndname + 'exists');
	    if(exists != 'true')
	        return;
	
	    document.getElementById(wndname).style.left = readCookie(wndname + 'x') + 'px';
	    document.getElementById(wndname).style.top  = readCookie(wndname + 'y') + 'px';
	    setwndwidth( wndname, readCookie(wndname + 'w'));
	    setwndheight(wndname, readCookie(wndname + 'h'));
        restorex[wndname] = readCookie(wndname + 'rx');
        restorey[wndname] = readCookie(wndname + 'ry');
        restorew[wndname] = readCookie(wndname + 'rw');
        restoreh[wndname] = readCookie(wndname + 'rh');
        
        var visibility = readCookie(wndname + 'visibility');
        if(visibility == 'visible')
            showwnd(wndname);
        
        var status = readCookie(wndname + 'status');
        if(status == 'minimized')
            minwnd(wndname);
        if(status == 'maximized')
            maxwnd(wndname);
        
	}
	
    function settop(divname)
    {
        var max = 0;
        for(zindex in zindexes)
		{
			if(zindexes[zindex] > max)
				max = zindexes[zindex];
		}
		document.getElementById(divname).style.zIndex = max + 1;
		zindexes[divname] = max + 1;
    }
    
    function setwndwidth(wndname, newwidth)
	{
	    document.getElementById(wndname).style.width = newwidth + 'px';
	    
		document.getElementById('head' + wndname).style.width = (newwidth - 3*18) + 'px';
		document.getElementById('status' + wndname).style.width = (newwidth - 25) + 'px';
		
	}
	
	function setwndheight(wndname, newheight)
	{
	    if(newheight < 100)
	        newheight = 100;
	    document.getElementById(wndname).style.height = newheight + 'px';
	    
	    //var divh = (newheight - 44) + 'px';
	    var divh = (newheight ) + 'px';
	    document.getElementById(wndname + 'content').style.height = divh;
	}
	
	function setstatus(wndname, statustext)
	{
	    document.getElementById('status' + wndname).innerHTML = statustext;  
	}

	function strippx(input)
	{
		var NoPt = input.split('p');
		return parseInt(NoPt[0]);
	}
	
	function showlinkcursor()
    {
	     document.body.style.cursor = "pointer";
    }
    
    function showmovecursor()
    {
	     document.body.style.cursor = "move";
    }
    
    function shownormalcursor()
    {
	     document.body.style.cursor = "auto";
    }
    
    function showresizehorizcursor()
    {
        document.body.style.cursor = "e-resize";
    }

    function showresizevertcursor()
    {
        document.body.style.cursor = "s-resize";
    }
    
    function showresizeverthorizcursor()
    {
        document.body.style.cursor = "se-resize";
    }

	function createwnd(wndname, wndsrc, headerbgcol, bodybgcol, statusbgcol, title, initialwidth, initialheight, initialleft, initialtop)
	{
	
        restorex[wndname] = initialleft;
        restorey[wndname] = initialtop;
        restorew[wndname] = initialwidth;
        restoreh[wndname] = initialheight;
	    
	    var output = "";
		// Start
		var divdeclare = '<div name="' + wndname + '" id="' + wndname;
		divdeclare += '" style="visibility: hidden; position: absolute; width: ';
		divdeclare += initialwidth + 'px; height: ' + initialheight + 'px; z-index: 100; left: ' 
		divdeclare += initialleft + 'px; top: ' + initialtop + 'px;" ';
		divdeclare += 'onmousedown="settop(\'' + wndname + '\'); return true;">';
		
		output += divdeclare;
		
		output += '<table border=0 cellpadding="0" cellspacing="0" ';
		output += 'style="line-height: 1; margin: 0; width: 100%; height: 100%;"';
		output += ' id="tbl' + wndname + '" name="tbl' + wndname + '">';
        
        // Top border row...
        output += '<Tr>';
        // Colspan & rowspan bugs out fixed height in ie...
        output += '<td style="background: #a6a6a6; height: 2px; padding:0px 0px;"></td>';
        output += '<td style="background: #a6a6a6; height: 2px; padding:0px 0px;"></td>';
        output += '<td style="background: #a6a6a6; height: 2px; padding:0px 0px;"></td>';
        
        output += '</Tr>';
        
		// Title row
		output += '<Tr>';
		
		// Left border cell...
		// Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; padding:0px 0px;"></td>';
		    
       	// Title cell colspan="4"
		output += '<td class="shop_head" style="overflow: hidden; height: 25px;  padding:0px 0px; vertical-align: middle; color: #FFF; font-weight:bold;">';
		
		output +=  '<div name="head' + wndname + '" id="head' + wndname + '" style="overflow: hidden; padding: 2px 0px; ';
		
		output += 'float: left; height: 25px; display: inline; width: ' + (initialwidth - 3*18) + 'px; vertical-align: middle; " ';
		
		output += 'onmousedown="javascript: startdrag(';
		output += "'";
		output += wndname;
		output += "'";
		output += '); return false;" onmouseup="javascript: enddrag(); return true;"';
		
		output += 'onDblClick="javascript: titledoubleclicked(\'' + wndname + '\'); return false;" ';
		
		output += 'onmouseover="javascript: showmovecursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;">';
		
		output += '<p style="vertical-align: middle;text-align: center;">' + title + '</p></div>';
		

		// Minimize button
		output += '<div class="shop_head" style="float: right; display: inline;">';
		output += '<img src="/js/mimimize.gif" onclick="javascript: minwnd(\'' + wndname + '\'); return true;">';
		
		// Maximize button
		output += '<img src="/js/maximize.gif" onclick="javascript: maxwnd(\'' + wndname + '\'); return true;">';
		
		// Close button
		output += '<img src="/js/x.gif" onclick="javascript: hidewnd(\'' + wndname + '\'); return true;">';
		output += '</div>';
		output += '</td>';
		
		// rigth border cell...
		// Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; padding:0px 0px;"';
		output += ' onmousedown="javascript: startresizeright(\'' + wndname + '\'); return false;" ';
		output += ' onmouseup="javascript: enddrag(); return true;" ';
		output += 'onmouseover="javascript: showresizehorizcursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;"';
        output += '></td>';
		

		// End title row
		output += '</tr>';
		
		// Body row
		output += '<tr >';
		// Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; height: 100%; padding:0px 0px;"></td>';
		
		output += '<td style="background: ' + bodybgcol + '; padding:0px 0px;';
		//output += '<td style="background: #0000FF; padding:0px 0px;';
		output += 'vertical-align: top;">';
		//               name="sc_js_wndcontent" id="sc_js_wndcontent&quot;"
		output +=  '<div name="' + wndname + 'content" id="' + wndname + 'content" ';
		output +=  'style="background: ' + bodybgcol + '; vertical-align: top; overflow: auto;'; 
		//output +=  'style="background: #FF0000; vertical-align: top; overflow: auto;'; 
		output +=  ' width: 100%; ';
		//output += 'height: auto !important; height: 100%; min-height: 100%; ';
		output += 'height: ' + (initialheight) + 'px';
		//output += 'height: 500px';
		
		//output +=  '; border: 3px blue solid"' ;
		output += '">';
		//  
		output +=  wndsrc ;
		
		output +=  '</div>';
		
		
		output += '</td>';
		
		// Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; padding:0px 0px;"';
		output += ' onmousedown="javascript: startresizeright(\'' + wndname + '\'); return false;" ';
		output += ' onmouseup="javascript: enddrag(); return true;" ';
		output += 'onmouseover="javascript: showresizehorizcursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;"';
        output += '></td>';
        
		output += '</tr>';
		
		
		// 'status row' cell
		output += '<tr >';
		// Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; height: 18px; padding:0px 0px;"></td>';
		
		output += '<td class="shop_status" style="height: 18px; padding:0px 0px; vertical-align: bottom;">';
		
		output +=  '<div class="shop_status" name="status' + wndname + '" id="status' + wndname + '" style="overflow: hidden; ';
		output += ' float: left; height: 18px; display: inline; width: ' 
		output += (initialwidth - 25) + 'px; vertical-align: bottom; "';
		output += '>';
		
		output += '</div>';
		

		// Gripper
		output += '<div class="shop_status" style="float: right; display: inline; width: 20px;';
		output += ' vertical-align: bottom; " ';
		output += ' onmousedown="javascript: startresizebottomright(\'' + wndname + '\'); return false;" ';
		output += ' onmouseup="javascript: enddrag(); return true;" ';
        
        output += 'onmouseover="javascript: showresizeverthorizcursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;"';
        output += '><img src="/js/resize.gif" style="float:right; vertical-align: bottom;"></div></td>';
        
        // Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; padding:0px 0px;"';
		output += ' onmousedown="javascript: startresizeright(\'' + wndname + '\'); return false;" ';
		output += ' onmouseup="javascript: enddrag(); return true;" ';
		output += 'onmouseover="javascript: showresizehorizcursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;"';
        output += '></td>';
        
        output += '</Tr>';

		// Bottom border row...
        output += '<Tr>';
        // Colspan & rowspan bugs out fixed height in ie...
		output += '<td style="background: #a6a6a6; width: 2px; padding:0px 0px;"></td>';
		
		output += '<td style="background: #a6a6a6; height: 2px; padding:0px 0px;"';
        
        output += ' onmousedown="javascript: startresizebottom(\'' + wndname + '\'); return false;" ';
		output += ' onmouseup="javascript: enddrag(); return true;" ';
        
        output += 'onmouseover="javascript: showresizevertcursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;"';
        
        output += ' ></td>';
        
        // Corner cell...
        output += '<td style="background: #a6a6a6; height: 2px; width: 2px; padding:0px 0px;"';
        
        output += ' onmousedown="javascript: startresizebottomright(\'' + wndname + '\'); return false;" ';
		output += ' onmouseup="javascript: enddrag(); return true;" ';
        
        output += 'onmouseover="javascript: showresizeverthorizcursor(); return true;" ';
		output += 'onmouseout="javascript: shownormalcursor(); return true;"';
        
        output += ' ></td>';
        
        output += '</Tr>';
                
		// End
		output += '</table>';
		
		output += '</div>';
		return output;
	}
	
	function setwndcontent(wndname, content)
	{
	    document.getElementById(wndname + 'content').innerHTML = content;
	}
	
	function movewndto(wndname, x, y)
	{
	    document.getElementById(wndname).style.top = y + 'px';
		document.getElementById(wndname).style.left = x + 'px';
		SaveWnd(wndname);
	}

	function showwnd(wndname)
	{
	    if( HookedHidesSet[wndname] == 'true' )
        {
            for(var i = 0; i < HookedHides[wndname].length; i++)
            {
                document.getElementById(HookedHides[wndname][i]).style.visibility = 'visible';
            }
        }   
        
		document.getElementById(wndname).style.visibility = 'visible';
		settop(wndname);
		SaveWnd(wndname);
		
		return true;
	}
	
	function showwndusr(wndname)
	{
	    if(windowstatuses[wndname] == 'minimized' || windowstatuses[wndname] == 'maximized')
	        maxwnd(wndname);
	    if( HookedHidesSet[wndname] == 'true' )
        {
            for(var i = 0; i < HookedHides[wndname].length; i++)
            {
                document.getElementById(HookedHides[wndname][i]).style.visibility = 'visible';
            }
        }   
        
		document.getElementById(wndname).style.visibility = 'visible';
		settop(wndname);
		SaveWnd(wndname);
		
		return true;
	}

	function hidewnd(wndname)
	{
	    if(windowstatuses[wndname] == 'minimized' || windowstatuses[wndname] == 'maximized')
	        restorewnd(wndname);
		document.getElementById(wndname).style.visibility = 'hidden';

		windowstatuses[wndname] = '';
		SaveWnd(wndname);
		// minwnd(wndname);
		internal_min_wnd(wndname);
		
        
        if( HookedHidesSet[wndname] == 'true' )
        {
            for(var i = 0; i < HookedHides[wndname].length; i++)
            {
                document.getElementById(HookedHides[wndname][i]).style.visibility = 'hidden';
            }
        }   
        	
	}

	function GetAbsWindowBottom()
	{
	    // Compute the bottom of the popup window and the bottom of
	    // the browser window, in absolute co-ordinates - different
	    // on all browsers but the below should be accurate usually!
 
 	   var abswindowbottom = 0;
	    if (typeof(window.innerHeight) == 'number')
        	abswindowbottom = window.innerHeight;
	    else if (document.documentElement && document.documentElement.clientHeight)
	        abswindowbottom = document.documentElement.clientHeight;
	    else if (document.body && document.body.clientHeight)
	        abswindowbottom = document.body.clientHeight;
 
 	   if (typeof(window.pageYOffset) == 'number')
	        abswindowbottom = abswindowbottom + window.pageYOffset;
	    else if (document.body && document.body.scrollTop)
	        abswindowbottom = abswindowbottom + document.body.scrollTop;
	    else if (document.documentElement && document.documentElement.scrollTop)
	        abswindowbottom = abswindowbottom + document.documentElement.scrollTop;
	    return abswindowbottom;
	}

	function GetAbsWindowRight()
	{
	    // Compute the bottom of the popup window and the bottom of
	    // the browser window, in absolute co-ordinates - different
	    // on all browsers but the below should be accurate usually!
 
 	   var abswindowbottom = 0;
	    if (typeof(window.innerWidth) == 'number')
        	abswindowbottom = window.innerWidth;
	    else if (document.documentElement && document.documentElement.clientWidth)
	        abswindowbottom = document.documentElement.clientWidth;
	    else if (document.body && document.body.clientWidth)
	        abswindowbottom = document.body.clientWidth;
 
 	   if (typeof(window.pageXOffset) == 'number')
	        abswindowbottom = abswindowbottom + window.pageXOffset;
	    else if (document.body && document.body.scrollLeft)
	        abswindowbottom = abswindowbottom + document.body.scrollLeft;
	    else if (document.documentElement && document.documentElement.scrollLeft)
	        abswindowbottom = abswindowbottom + document.documentElement.scrollLeft;
	    return abswindowbottom;
	}

    
    function toggleRows(tableId, show)
    {
        tbl = document.getElementById(tableId);
	    var len = tbl.rows.length;
	    
	    var vStyle = (show)? "":"none";

	    for(i=2 ; i< len; i++)
	    {
		    tbl.rows[i].style.display = vStyle;
	    }

    }

    function titledoubleclicked(wndname)
    {
        maxwnd(wndname);
    }
    
    function internal_min_wnd(wndname)
    {
        if(windowstatuses[wndname] == 'minimized')
			return; // Do nothing
		
		// Count minimized windows...
		var mimimized = 0;
		for(wnd in windowstatuses)
		{
		    if(windowstatuses[wnd] == 'minimized')
			{
			    mimimized += strippx( document.getElementById(wnd).style.width ) + 2;
			}
		}	
		

		if(windowstatuses[wndname] != 'maximized')
		{
			restorex[wndname] = strippx( document.getElementById(wndname).style.left );
			restorey[wndname] = strippx( document.getElementById(wndname).style.top );
			
			restorew[wndname] = strippx( document.getElementById(wndname).style.width );
			restoreh[wndname] = strippx( document.getElementById(wndname).style.height );
		}
		
		toggleRows('tbl' + wndname, false);
		
				
		
		document.getElementById(wndname).style.top  = (GetAbsWindowBottom() - 22) + 'px';
		document.getElementById(wndname).style.left = mimimized + 'px';

        setwndwidth(wndname, 100);
		//document.getElementById(wndname).style.width = 100 + 'px';
		document.getElementById(wndname).style.height = 18 + 'px';
		
		windowstatuses[wndname] = 'minimized';
    }

	function minwnd(wndname)
	{
		
		internal_min_wnd(wndname);
		SaveWnd(wndname);
	}

	function maxwnd(wndname)
	{
		// Restore?
		if(windowstatuses[wndname] == 'minimized' || windowstatuses[wndname] == 'maximized')
		{
			document.getElementById(wndname).style.left 	= restorex[wndname] + 'px';
			document.getElementById(wndname).style.top 	    = restorey[wndname] + 'px';
			
			setwndwidth(wndname, restorew[wndname])
			//document.getElementById(wndname).style.width 	= restorew[wndname] + 'px';
			setwndheight(wndname, restoreh[wndname])
			//document.getElementById(wndname).style.height 	= restoreh[wndname] + 'px';
			
			if(windowstatuses[wndname] == 'minimized')
			    toggleRows('tbl' + wndname, true);
			    
			windowstatuses[wndname] = '';
			
			SaveWnd(wndname);
			return;
		}
		// Maximize
		windowstatuses[wndname] = 'maximized'

		restorex[wndname] = strippx( document.getElementById(wndname).style.left );
		restorey[wndname] = strippx( document.getElementById(wndname).style.top );
		restorew[wndname] = strippx( document.getElementById(wndname).style.width );
		restoreh[wndname] = strippx( document.getElementById(wndname).style.height );

		document.getElementById(wndname).style.top  = 0;
		document.getElementById(wndname).style.left = 0;

        

		//document.getElementById(wndname).style.width = GetAbsWindowRight() + 'px';
		setwndwidth(wndname, GetAbsWindowRight());
		//document.getElementById(wndname).style.height = GetAbsWindowBottom() + 'px';
		setwndheight(wndname, GetAbsWindowBottom());
		
		
        SaveWnd(wndname);
	}
	
	


	// Globals needed for dragging...
	var draggingwnd = '';
	var startx;
	var starty;

	var mousex;
	var mousey;

	var offsetx;
	var offsety;	
	
	var draggingact = '';
	
	function startdrag(wndname)
	{
	    draggingact = 'move';
		draggingwnd = wndname;

		var posx = document.getElementById(wndname).style.left;
		var posxNoPt = posx.split('p');
		posx = parseInt(posxNoPt[0]);

		var posy = document.getElementById(wndname).style.top;
		var posyNoPt = posy.split('p');
		posy = parseInt(posyNoPt[0]);

		startx = posx;
		starty = posy;

		offsetx = mousex - posx;
		offsety = mousey - posy;
		
		return false;
	}
	
	function startresizeright(wndname)
	{
	    draggingact = 'resizeright';
	    draggingwnd = wndname;

		var posx = document.getElementById(wndname).style.width;
		var posxNoPt = posx.split('p');
		posx = parseInt(posxNoPt[0]);

		var posy = document.getElementById(wndname).style.height;
		var posyNoPt = posy.split('p');
		posy = parseInt(posyNoPt[0]);

		startx = posx;
		starty = posy;

		offsetx = mousex - posx;
		offsety = mousey - posy;
		
		return false;
	}
	
	function startresizebottom(wndname)
	{
	    draggingact = 'resizebottom';
	    draggingwnd = wndname;

		var posx = document.getElementById(wndname).style.width;
		var posxNoPt = posx.split('p');
		posx = parseInt(posxNoPt[0]);

		var posy = document.getElementById(wndname).style.height;
		var posyNoPt = posy.split('p');
		posy = parseInt(posyNoPt[0]);

		startx = posx;
		starty = posy;

		offsetx = mousex - posx;
		offsety = mousey - posy;
		
		return false;
	}
	
	function startresizebottomright(wndname)
	{
	
	    draggingact = 'resizebottomright';
	    draggingwnd = wndname;

		var posx = document.getElementById(wndname).style.width;
		var posxNoPt = posx.split('p');
		posx = parseInt(posxNoPt[0]);

		var posy = document.getElementById(wndname).style.height;
		var posyNoPt = posy.split('p');
		posy = parseInt(posyNoPt[0]);

		startx = posx;
		starty = posy;

		offsetx = mousex - posx;
		offsety = mousey - posy;
		
		return false;
	}
	
	function enddrag()
	{
	    SaveWnd(draggingwnd);
	    draggingact = '';
		draggingwnd = '';	
		
	}
	

	function getMouseXY(e) 
	{
	
	    if (navigator.userAgent.indexOf("Firefox")!=-1)
	    {
		    mousex = e.clientX + document.body.scrollLeft;
		    mousey = e.clientY + document.body.scrollTop;
		}
		else
		{
		    mousex = window.event.clientX + document.body.scrollLeft;
		    mousey = window.event.clientY + document.body.scrollTop;

		}

		if(draggingwnd != '' && draggingact == 'move')
		{
			var movex = mousex - startx;
			var movey = mousey - starty;

			var posx = document.getElementById(draggingwnd).style.left;
			
			var posxNoPt = posx.split('p');
			posx = parseInt(posxNoPt[0]);

			var posy = document.getElementById(draggingwnd).style.top;
			var posyNoPt = posy.split('p');
			posy = parseInt(posyNoPt[0]);

            startx = posx + movex- offsetx;
            starty = posy + movey- offsety;
            
            if(startx < 0)
                startx = 0;
            if(starty < 0)
                starty = 0;
			document.getElementById(draggingwnd).style.left = (startx) + 'px';
			document.getElementById(draggingwnd).style.top  = (starty) + 'px';
			
			return false;
		}
		
		if(draggingwnd != '' && draggingact == 'resizeright')
		{
			var movex = mousex - startx;
			var movey = mousey - starty;

			var posx = document.getElementById(draggingwnd).style.width;
			var posxNoPt = posx.split('p');
			posx = parseInt(posxNoPt[0]);

			var posy = document.getElementById(draggingwnd).style.height;
			var posyNoPt = posy.split('p');
			posy = parseInt(posyNoPt[0]);

            var newwidth = posx + movex - offsetx;
            if( newwidth < 100 )
                newwidth = 100;
			//document.getElementById(draggingwnd).style.width = newwidth + 'px';
			setwndwidth(draggingwnd, newwidth);
			//document.getElementById('head' + wndname ).style.width = (newwidth - 3*18) + 'px'
			//document.getElementById(draggingwnd).style.top  = posy + movey - offsety;

			startx = newwidth;
			starty = posy + movey- offsety;
			
			return false;
		}
		
		if(draggingwnd != '' && draggingact == 'resizebottom')
		{
			var movex = mousex - startx;
			var movey = mousey - starty;

			var posx = document.getElementById(draggingwnd).style.width;
			var posxNoPt = posx.split('p');
			posx = parseInt(posxNoPt[0]);

			var posy = document.getElementById(draggingwnd).style.height;
			var posyNoPt = posy.split('p');
			posy = parseInt(posyNoPt[0]);

            var newheight = posy + movey - offsety;
            if( newheight < 50 )
                newheight = 50;
			//document.getElementById(draggingwnd).style.width = posx + movex - offsetx;
			//document.getElementById(draggingwnd).style.height  = newheight + 'px';
			setwndheight(draggingwnd, newheight);

			startx = posx + movex- offsetx;
			starty = newheight;
			
			return false;
		}
		
		if(draggingwnd != '' && draggingact == 'resizebottomright')
		{
		
			var movex = mousex - startx;
			var movey = mousey - starty;

			var posx = document.getElementById(draggingwnd).style.width;
			var posxNoPt = posx.split('p');
			posx = parseInt(posxNoPt[0]);

			var posy = document.getElementById(draggingwnd).style.height;
			var posyNoPt = posy.split('p');
			posy = parseInt(posyNoPt[0]);

            var newwidth = posx + movex - offsetx;
            if( newwidth < 100 )
                newwidth = 100;
                
            var newheight = posy + movey - offsety;
            if( newheight < 50 )
                newheight = 50;
			
			//document.getElementById(draggingwnd).style.width = newwidth + 'px';
			setwndwidth(draggingwnd, newwidth);
			//document.getElementById(draggingwnd).style.height  = newheight + 'px';
			setwndheight(draggingwnd, newheight);

			startx = newwidth;
			starty = newheight;
			
			return false;
		}
	
		return true;
	}

	document.onmousemove = getMouseXY;
    document.onmouseup = enddrag;

	