
/**********************************************************************************   
WindowScript 
*   Copyright (C) 2001 Thomas Brattli
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by Thomas Brattli
*
*   Script date: 07/03/2001 (keep this date to check versions) 
*********************************************************************************/

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=lib_bwcheck();
var oWin=new Array; oWin.zIndex=10; oWin.dragobj=-1; oWin.resizeobj=-1; oWin.zIndex=100; 
//Start Variables to set ******************************************************************

//This script works in IE4+, NS4+ and Opera5. 
//Just remember that NS4 and Opera5 does not reflow the content when you resize the windows.


oWin.bordercolor = "#ffffff" //Remember that you have to change the images as well if you change this color
oWin.bgcolor = "" //Default background color
oWin.bgcoloron = ""  //The "active" background color
oWin.bgscroll = "#08246B" //The background-color for the scroll area"

//The rest of the style variables have to be set in the stylesheet above. 
//To change styles on the text change .clText

//If you change these variables I assume you would like to change the images, image sizes and the imagemap for 
//the windows. If so you'll have to do that manually in the addWindow function for now.

oWin.bottomh=20 //The height of the bottom "border"
oWin.headh=18; //The height of the head "border"
oWin.bordersize=2 //The left and right bordersize
oWin.scrollw=13 //The width of the scroll area
oWin.scrollimgh=12 //The width of the scroll images
oWin.btnMinw=49//The width of the buttons image
oWin.btnMaxw=34//The width of the buttons image
oWin.btnClosew=19//The width of the buttons image
oWin.resizeh=13 //The width of the resize img
oWin.resizew=13 //The height of the resize img
oWin.statusbarh=28 // the height of status bar

oWin.starty=5 //If you have a header or something on the page that you want the setWindows and the dragdrop to care about set it here.
oWin.defwidth=200 //Default width for the windows if nothing is spesified
oWin.defheight=200 //Default height for the windows if nothing is spesified
oWin.between=15 //This variable controls how much space there will be between the windows when you use setWindows

//Set this variable to 1 if you want to be able to control the area the windows can be scrolled.
oWin.keepinside=0 //VALUE: 1 || 0
	oWin.maxX=500 //This is the maximum X value the windows can go to. Set this to "winpage.x2" to keep them inside the window. VALUE: "winpage.x2" || px
	oWin.maxY=500 //This is the maximum Y value the windows can go to. Set this to "winpage.y2" to keep them inside the window. VALUE: "winpage.y2" || px
	oWin.minX=50 //This is the minimun X value the windows can go to. Set to 0 to keep them inside the window. VALUE: px
	oWin.minY=50 //This is the minimum Y value the windows can go to. Set to 0 to keep them inside the window. VALUE: px
oWin.widthDiff = 8; //this is the difference between iframe width and window div width
//oWin.heightDiff = 35; //this is the difference between iframe height and window div height
//In the next version of this script all variables can be set on each individual window as well

//End Variables to set ********************************************************************

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.ie7 || this.opera5)
	return this
}
var bw=new lib_bwcheck(); 
//Uncomment the next line if you want the user to be sent to another page if he's using an old browser
//if(!bw.bw) location.href='sorry.html'

function lib_doc_size(){ //Page positions - needed!
	this.x=0;
	this.x2=bw.ie && document.body.offsetWidth-20||0;//innerWidth||0;
	if(bw.ns6) this.x2-=2
	if(bw.ie7) this.x2-=2
	this.y=0;
	this.y2=bw.ie && document.body.offsetHeight-5||0;//innerHeight||0;
	if(bw.ns6) this.y2-=4
	if(bw.ie7) this.y2-=4
	
	if(!this.x2||!this.y2) return message('Document has no width or height') 
	this.x50=this.x2/2;     this.y50=this.y2/2;
	this.x10=(this.x2*10)/100;this.y10=(this.y2*10)/100
	this.ytop=140*100/this.y2
	this.avail=(this.y2*(100-this.ytop))/100
	this.origy=this.y2
	//alert('Inside lib_doc_size');
	return this;
}
function lib_moveIt(x,y){  
	// alert ( x, y );
	if( bw.ns4 || bw.ns6 ) { // alert("in firefox");

	}

	this.x=x;this.y=y; this.css.left=x;this.css.top=y  
}

function lib_moveBy( x, y ){ 
	   this.moveIt ( this.x+x, this.y+y )   
	}
//function lib_statusBarDiv(){}
function lib_showIt(){this.css.visibility="visible";}
function lib_hideIt(){this.css.visibility="hidden";}
function lib_bg(color){
	if(bw.opera5) this.css.background=color
	else if(bw.dom || bw.ie4) this.css.backgroundColor=color
	else if(bw.ns4) this.css.bgColor=color  
}

function lib_clipTo(t,r,b,l,setwidth){ 
	if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
	this.ct=t; this.cr=r; this.cb=b; this.cl=l
	if(bw.ns4){
		this.css.clip.top=t;this.css.clip.right=r
		this.css.clip.bottom=b;this.css.clip.left=l
	}else if(bw.opera5){this.css.pixelWidth=r; this.css.pixelHeight=b; this.w=r; this.h=b
	}else{
		this.css.clip="rect("+t+","+r+","+b+","+l+")";
		if(setwidth){this.css.width=r; this.css.height=b; this.w=r; this.h=b}
	}
}
function lib_writeIt(text,startHTML,endHTML){
	if(bw.ns4){
		if(!startHTML){startHTML=""; endHTML=""}
		this.ref.open("text/html"); this.ref.write(startHTML+text+endHTML); this.ref.close()
	}else this.evnt.innerHTML=text
}
//Default lib functions
function lib_obj(obj,nest,dnest,ddnest,num){
	
	if(!bw.bw) return lib_message('Old browser');
	if(!bw.ns4) this.evnt=bw.dom && document.getElementById(obj)||bw.ie4 && document.all[obj]
	else{
		if(ddnest){this.evnt=document[nest].document[dnest].document[ddnest].document[obj]?document[nest].document[dnest].document[ddnest].document[obj]:0;
		}else if(dnest){this.evnt=document[nest].document[dnest].document[obj]?document[nest].document[dnest].document[obj]:0;
		}else if(nest){this.evnt=document[nest].document[obj]?document[nest].document[obj]:0;
		}else{this.evnt=document.layers[obj]?document.layers[obj]:0;}	
	}
	
	if(!this.evnt) return lib_message('The layer does not exist ('+obj+') - Exiting script\n\nIf your using Netscape please check the nesting of your tags!')
	this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;  
	this.ref=bw.dom||bw.ie4?document:this.css.document;   
	this.moveIt=lib_moveIt; this.moveBy=lib_moveBy; 
	//this.statusBarDiv=lib_statusBarDiv; 
	this.showIt=lib_showIt; this.hideIt=lib_hideIt;
	this.bg=lib_bg; this.num=num; this.writeIt=lib_writeIt; 	
	this.clipTo=lib_clipTo;	this.obj = obj + "Object"; 	eval(this.obj + "=this")
	return this
}


/*****************************************************************************
Creating windows
*****************************************************************************/
function create_window(i,x,y,w,h,bg,bga,heading,isFolder){

	if(!w) w = oWin.defwidth; if(!h) h=oWin.defheight
	if(!bg) bg = oWin.bgcolor; if(!bga) bga=oWin.bgcoloron
	oWin[i] = new lib_obj('divWin'+i,"","","",i);		
	oWin[i].oWindow = new lib_obj('divWindow'+i,'divWin'+i)
	oWin[i].oWindow.moveIt(oWin.bordersize,oWin.headh+3)
	oWin[i].oText = new lib_obj('divWinText'+i,'divWin'+i,'divWindow'+i)
	oWin[i].oHead = new lib_obj('divWinHead'+i,'divWin'+i)
	oWin[i].oBtnMin = new lib_obj('divWinBtnMin'+i,'divWin'+i)
	oWin[i].oBtnMax = new lib_obj('divWinBtnMax'+i,'divWin'+i)
	oWin[i].oBtnClose = new lib_obj('divWinBtnClose'+i,'divWin'+i)
	oWin[i].oResize = new lib_obj('divWinResize'+i,'divWin'+i)
	if(isFolder)
		oWin[i].oMenu=new lib_obj('divWinMenu'+i,'divWin'+i,'divWindow'+i);
	oWin[i].oIframe=new lib_obj('newFrame'+i,'divWin'+i,'divWindow'+i,'divWinText'+i,i);
	oWin[i].oHead.evnt.onmouseover= new Function("w_mmover("+i+")")
	oWin[i].oHead.evnt.onmouseout= new Function("w_mmout()")
	oWin[i].oBtnMin.evnt.onmousedown= new Function("btn_mdown("+i+",\'min\')")
	oWin[i].oBtnMax.evnt.onmousedown= new Function("btn_mdown("+i+",\'max\')")
	oWin[i].oBtnClose.evnt.onmousedown= new Function("btn_mdown("+i+",\'close\')")
	oWin[i].oBtnMin.evnt.onmouseup= new Function("btn_mup("+i+",\'min\')")
	oWin[i].oBtnMax.evnt.onmouseup= new Function("btn_mup("+i+",\'max\')")
	oWin[i].oBtnClose.evnt.onmouseup= new Function(" btn_mup("+i+",\'close\')")
	if(!bw.ns4) oWin[i].oHead.evnt.ondblclick=new Function("mdblclick(0,"+i+")")
	oWin[i].oResize.evnt.onmouseover=new Function("w_mmover("+i+",1)")
	oWin[i].oResize.evnt.onmouseout=new Function("w_mmout()")	
	
	if(!bw.ns4){
		oWin[i].oHead.css.cursor="move"; oWin[i].oResize.css.cursor="w-resize"
		oWin[i].oWindow.css.overflow="hidden"; oWin[i].css.overflow="hidden";
		oWin[i].oText.css.overflow="hidden";
	}		
	oWin[i].defbg=bg; oWin[i].defbga=bga	
	oWin[i].bg(oWin.bordercolor); oWin[i].oWindow.bg(oWin[i].defbg)
	//oWin[i].oUp=new lib_obj('divWinUp'+i,'divWin'+i); oWin[i].oDown=new lib_obj('divWinDown'+i,'divWin'+i)
	//oWin[i].oUp.bg(oWin.bgscroll); oWin[i].oDown.bg(oWin.bgscroll); 
	oWin[i].idty=i;
	oWin[i].heading = heading;
	if(!isFolder)
	{
		oWin[i].heightDiff = 45;
		oWin[i].IsFolder = false;
	}
	else 
	{
		oWin[i].heightDiff = 65;
		oWin[i].IsFolder = true;
	}
	oWin[i].lastx=x;oWin[i].lasty=y;oWin[i].origw=w; oWin[i].origh=h
	oWin[i].resize=win_resize;	oWin[i].close=win_close; oWin[i].maximize=win_maximize;
	oWin[i].minimize=win_minimize;	oWin[i].regwin=win_regwin; //oWin[i].checkscroll=win_checkscroll;
	//oWin[i].up=win_up;	oWin[i].down=win_down;	
	//oWin[i].sep_button=win_buttons;
	oWin[i].addZ=win_addZ;	oWin[i].state="reg";
	oWin[i].moveIt(x,y); oWin[i].resize(w,h); //oWin[i].checkscroll();
	//oWin[i].sep_button();
	
	if(bw.opera5) setTimeout("oWin["+i+"].resize("+w+","+h+"); oWin["+i+"].showIt()",10)
	else oWin[i].showIt()
	
}
/*****************************************************************************
Window functions 
*****************************************************************************/
function win_buttons()
{
	var	oMinimizeButton=document.createElement("DIV");
	oMinimizeButton.className = "clMinButton";
	this.oButtons.evnt.appendChild(oMinimizeButton);
	var oMaxButton=document.createElement("DIV");
	oMaxButton.className = "clMaxButton";
	this.oButtons.evnt.appendChild(oMaxButton);
	var oCloseButton=document.createElement("DIV");
	oCloseButton.className = "clCloseButton";
	this.oButtons.evnt.appendChild(oCloseButton);
	this.addZ()
}

function win_regwin(){
	this.oResize.css.visibility="inherit"
	this.resize(this.origw,this.origh)
	this.moveIt(this.lastx,this.lasty)
	this.state="reg"; this.addZ()
	//this.checkscroll()
}
function win_maximize(){
	
	/*var ver=navigator.appVersion;
	var ie7=(ver.indexOf("MSIE 7")>-1)?1:0;
	var browser=(ie7);
	if(browser!=1)
	{*/
	
		if(this.state!="max"){
			if(this.state!="min")
			{
				this.lastx=this.x; 
				this.lasty=this.y
			}
			//mw=winpage.x2;
			
			mw=document.body.clientWidth;
			//mh=winpage.y2 - oWin.statusbarh;
			mh=document.body.clientHeight;//winpage.y2 - oWin.statusbarh;

			this.moveIt(1,1);
			this.resize(mw,mh);
			this.showIt(); 
			//this.oResize.showIt(); hide resize when window is maximize
			this.oResize.hideIt();
			this.state="max";
			this.addZ();
		}else{ this.regwin()}
	/*}
	else
	{
		alert("Not supported in Internet Explorer 7.x");
		this.regwin()
	}*/
}
/*function win_minimize(){
	
	if(this.state!="min"){ couns=0;
		if(this.state!="max"){this.lastx=this.x; this.lasty=this.y}
		y=winpage.y2 - oWin.headh; ox=winpage.x2-126; a=0; headWidth=125;
		
		for(i=0;i<wins;i++){
			
			x=(i*headWidth)+80; ok=a
			
			if((a*headWidth)+80>ox){if(ox>126) i=0; a=0; y-=oWin.headh;x=80}
			for(j=0;j<wins;j++){
				couns++;if(oWin[j].x==x && oWin[j].y==y) a++
			}if(a==ok) break;
		}x=(a*headWidth)+80;
		
		this.moveIt(x,y); this.oResize.hideIt()
		this.state="min"; this.resize(125,oWin.headh)
	}else this.regwin()
}*/

/*function win_minimize(){
	if(this.idty==null)  
	{
		
		if(oWin[this.value].state!="min")
		{
			x=0;y=0;
			this.className="clStatusBarChanged";
			oWin[this.value].hideIt(); oWin[this.value].oResize.hideIt();
			oWin[this.value].state="min"; 
		}
		else
		{
			this.className="clStatusBar";
			oWin[this.value].showIt();
			oWin[this.value].regwin();
		}
	}
	else
	{
		var statusBarDivObj = document.getElementById("divStatus"+this.idty);
		if(this.state!="min")
		{ 
			couns=0;
			if(this.state!="max"){this.lastx=this.x; this.lasty=this.y}
			y=winpage.y2 - oWin.headh; ox=winpage.x2-126; a=0; headWidth=125;
			statusBarDivObj.className="clStatusBarChanged";
			this.hideIt(); this.oResize.hideIt();
			this.state="min";
		
		}
		else
		{
			statusBarDivObj.className="clStatusBar";
			this.showIt();
			this.regwin();
		}
	}
}*/
function win_minimize(){
	
	
	if(this.state!="min"){ couns=0;
		if(this.state!="max"){this.lastx=this.x; this.lasty=this.y}
		
		
		y=winpage.y2 - oWin.headh; ox=winpage.x2-126; a=0;
		for(i=0;i<wins;i++){
			x=(i*125); ok=a
			
			if((a*125)>ox){if(ox>126) i=0; a=0; y-=oWin.headh;}
			for(j=0;j<wins;j++){
				couns++; if(oWin[j].x==x && oWin[j].y==y) a++
			}if(a==ok) break;
		}x=(a*125);
		//alert(x+' '+y);
		//this.moveIt(x,y);
		this.oResize.hideIt();
		this.state="min"; this.resize(this.origw,oWin.headh)
	}else this.regwin()
}



function win_close()
	{
		var ids = document.getElementById("divWin"+this.idty);


/* Assign dummy events on closing window, so that these events will not effect on main window*/
/* Specially done for Mozilla */
		 document.onmousemove = changeToDummy ;
		 document.onmousedown = changeToDummy ; 
		 document.onmouseup = changeToDummy ; 
/********************************************************************************************/
		document.body.removeChild(ids);
		/*this.hideIt();*/ /*this.oUp.hideIt(); this.oDown.hideIt()*/
	}
	
function win_resize(w,h){
	
	this.oBtnMin.moveIt(w-oWin.btnMinw,2);this.oBtnMax.moveIt(w-oWin.btnMaxw,2);this.oBtnClose.moveIt(w-oWin.btnClosew,2); this.oResize.moveIt(w-oWin.resizew,h-oWin.resizeh);
	this.oWindow.clipTo(0,w-oWin.bordersize*2,h-oWin.bottomh-oWin.headh,0,1); this.clipTo(0,w,h,0,1)
	this.oHead.clipTo(0,w-5,oWin.headh,0,1);
	
	if(this.IsFolder==false)
	{
		this.oText.clipTo(0,w-4,h-38,0,1);
		this.oText.moveIt(0,0);
	}
	else
	{
		this.oMenu.moveIt(0,20);
		this.oText.clipTo(0,w,h-56,0,1);
		this.oText.moveIt(0,21);
	}
	this.oIframe.clipTo(0,w-oWin.widthDiff,h-this.heightDiff,0,1);
	//this.oIframe.evnt.setAttribute('width',(w-oWin.widthDiff));this.oIframe.evnt.setAttribute('height',(h-this.heightDiff));
	this.oIframe.moveIt(0,0);
	this.addZ();
	//this.oUp.hideIt(); this.oDown.hideIt()
}

/*var sctim=50;
var winScroll;
function win_up(){
	clearTimeout(sctim);
	
	if(this.oText.y>=this.oWindow.cb-this.oText.height-10 && winScroll){
		this.oText.moveBy(0,-8); 
		setTimeout(this.obj+".up()",30)
	}
}
function win_down(){
	
	clearTimeout(sctim);
	if(this.oText.y<=0 && winScroll){
		this.oText.moveBy(0,8);
		setTimeout(this.obj+".down()",30)
	}
}
function noScroll(){clearTimeout(sctim);winScroll=false}*/
function win_addZ(){   oWin.zIndex = oWin.zIndex ++ ; this.css.zIndex=oWin.zIndex   }
/*****************************************************************************
Initiating winpage
*****************************************************************************/

function win_init(){
		
	if(document.layers){
		document.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP | Event.DBLCLICK)
		document.ondblclick=mdblclick;		
	}

	 document.onmousemove = mmove ;
	 document.onmousedown = mdown ; 
	 document.onmouseup = mup ; 
	
}
/*****************************************************************************
Event functions
*****************************************************************************/
var oStBarPopup = '';

/*this function is used to hide popup(generated by right click on status bar)*/

function HidePopup(id)
{
	
	oStBarPopup.hide();
}

/*function StatusbarMClick(pintChildStatusDivId)
{
	if((navigator.appName == 'Netscape' && e.which == 3) || (navigator.appName == 'Microsoft Internet Explorer'
          && event.button==2))
	{
			  
			var oStatusDiv1=document.getElementById("divStatus"+pintChildStatusDivId);
			//X = parseInt(oStatusDiv1.style.left)+parseInt(oStatusDiv1.style.width);
			X = event.clientX;
			Y = winpage.y2 - 90;
			var minstate = 't';
			var maxstate = 't';
			if(oWin[pintChildStatusDivId].state=='min')
				minstate = 'f';
			if(oWin[pintChildStatusDivId].state=='max')
				maxstate = 'f';
			var strURL='<?php echo _WWWROOT?>/admin/common/get_rclick_menu.php?WinId='+pintChildStatusDivId+'&minstate='+minstate+'&maxstate='+maxstate;
			var objHTTP=new ActiveXObject("MSXML2.XMLHTTP")
			var a=objHTTP.Open("GET", strURL, false);                        
			objHTTP.Send();
			strResult = objHTTP.ResponseText;
			
			 oStBarPopup = window.createPopup();
			 var oStBarPopBody = oStBarPopup.document.body;
			 if(oStBarPopup.document.styleSheets.length != 1)
	            oStBarPopup.document.createStyleSheet("<?echo _ADMIN_IMG_PATH?>/Css/rclick_popup.css");
			oStBarPopBody.style.backgroundColor = "";
			oStBarPopBody.innerHTML = strResult; 
			oStBarPopBody.onclick=new Function("HidePopup("+pintChildStatusDivId+")");
			oStBarPopBody.onblur=new Function("HidePopup("+pintChildStatusDivId+")");
			oStBarPopup.show(X, Y, 130, 80, document.body);
			
			
			
	}
	else
	{
		oWin[pintChildStatusDivId].minimize();
	}
}*/





/**************************************************************************************************************/
/*****iframe content loading functions when resize*******/

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] 
var FFextraHeight=getFFVersion>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers 

function resizeiframe(frameid)
{ 
	var currentfr=document.getElementById(frameid) 
	if (currentfr &&!window.opera)
	{ 
		currentfr.style.display="block" 
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax 
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax 
			currentfr.height = currentfr.Document.body.scrollHeight; 
		if (currentfr.addEventListener) 
			currentfr.addEventListener("load", readjustiframe, false) 
		else if (currentfr.attachEvent)
		{ 
			currentfr.detachEvent("onload", readjustiframe) // Bug fix line 
			currentfr.attachEvent("onload", readjustiframe) 
		} 
	} 
} 

function readjustiframe(loadevt) 
{ 
	var crossevt=(window.event)? event : loadevt 
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement 
	if (iframeroot) 
		resizeiframe(iframeroot.id);
} 

/**************************************************************************************************************/

function w_mmover(num,resize){if(!resize) oWin.dragover=num; else oWin.resizeover=num}
function w_mmout(){oWin.dragover=-1; oWin.resizeover=-1}
function btn_mdown(num,strBtnName)
{   
	
	if(strBtnName == 'min')
	{
		var oImgMin = document.getElementById('imgBtnMin'+num);
		oImgMin.src = _POPUP_IMAGE_PATH+"/btn_min_click.gif";
		

	}
	else if(strBtnName == 'max')
	{

		var oImgMax = document.getElementById('imgBtnMax'+num);
		oImgMax.src = _POPUP_IMAGE_PATH+"/btn_max_click.gif";
	}
	else
	{
		var oImgClose = document.getElementById('imgBtnClose'+num);
		oImgClose.src = _POPUP_IMAGE_PATH+"/btn_close_click.gif";
	}


}

function btn_mup(num,strBtnName)
{
	if(strBtnName == 'min')
	{
		var oImgMin = document.getElementById('imgBtnMin'+num);
		oImgMin.src = _POPUP_IMAGE_PATH+"/btn_min.gif";
		oWin[num].minimize();

	}
	else if(strBtnName == 'max')
	{
		
		var oImgMax = document.getElementById('imgBtnMax'+num);
		oImgMax.src = _POPUP_IMAGE_PATH+"/btn_max.gif";
		oWin[num].maximize();
	}
	else
	{
		var oImgClose = document.getElementById('imgBtnClose'+num);
		oImgClose.src = _POPUP_IMAGE_PATH+"/btn_close.gif";
		oWin[num].close();
	}

}
function mup(e){ //Mouseup

	if((oWin.dragobj!=-1 || oWin.resizeobj!=-1) && oWin.setposition) setPos();
	if(oWin.dragobj!=-1){oWin[oWin.dragobj].lastx=oWin[oWin.dragobj].x; oWin[oWin.dragobj].lasty=oWin[oWin.dragobj].y}
	oWin.dragobj=-1	
	if(oWin.resizeobj!=-1){
		//oWin[oWin.resizeobj].checkscroll()
		oWin[oWin.resizeobj].origw=oWin[oWin.resizeobj].cr
		oWin[oWin.resizeobj].origh=oWin[oWin.resizeobj].cb		
	}else if(bw.ns4) routeEvent(e)		
	oWin.resizeobj=-1;
}

function changeToDummy(e)
{
	return true;
}
function mdown(e){ //Mousedown	

	x=(bw.ns4 || bw.ns6)?e.pageX:event.x||event.clientX
    y=(bw.ns4 || bw.ns6)?e.pageY:event.y||event.clientY
	if(bw.ie5 || bw.ie6) y+=document.body.scrollTop

	id1 = oWin.dragover
	id2 = oWin.resizeover
	
	//alert(oWin +" = hello = "+id2);

	if(id1>-1 || id2>-1){
		if(id2>-1){ id=id2; oWin.resizeobj=id;
		}else{ 
			id=id1; oWin.dragobj=id;
			oWin.clickedX = x-oWin[id].x; 
			oWin.clickedY = y-oWin[id].y;
			//alert(x+","+oWin.clickedX+","+y+","+oWin.clickedY)
		}
		
		oWin[id].addZ();
		//Setting background-colors	
		/*for(i=0;i<wins;i++){
			if(i!=id1&&i!=id2){
				oWin[i].oWindow.bg(oWin[i].defbg)
			}else oWin[i].oWindow.bg(oWin[i].defbga)
		}*/
	} else if(bw.ns4) routeEvent(e)
	if(!bw.ns4) return false;    
}

function mmove(pos){ //Mousemove
	
	if(pos)
		{			
			x=pos.x;y=pos.y;		
			
			/* Code added by vikas as to move div popup in mozilla */	
					if( bw.ns4 || bw.ns6 )
						{				
							x = pos.clientX ;
							y = pos.clientY ;
						}			
			/*************************************************************************/
		}
	else
		{
			x=( bw.ns4 || bw.ns6 )? e.pageX:event.x||event.clientX ;
			y=( bw.ns4 || bw.ns6 )? e.pageY:event.y||event.clientY ;			
		}
	

	if(bw.ie5 || bw.ie6) y+=document.body.scrollTop	;	
	
	id1 = oWin.dragobj
	id2 = oWin.resizeobj
	
	if(id2>-1){ //Resize
		nx=x; ny=y
		oldw=oWin[id2].cr; oldh=oWin[id2].cb
		cw= nx -oWin[id2].x; ch= ny - oWin[id2].y
		if(cw<120) cw=120; if(ch<100) ch=100
		oWin[id2].resize(cw,ch);resizeiframe('newFrame'+id2);
	}else if(id1>-1){ //Move
		
		nx=x-oWin.clickedX; ny=y-oWin.clickedY
		//nx+=oWin[id1].x;ny+=oWin[id1].y;
		if(ny<oWin.starty) ny=oWin.starty
		if(oWin.keepinside){
			if(nx+oWin[id1].cr>eval(oWin.maxX)) nx=eval(oWin.maxX)-oWin[id1].cr
			else if(nx<eval(oWin.minX)) nx=eval(oWin.minX)
			if(ny+oWin[id1].cb>eval(oWin.maxY)) ny=eval(oWin.maxY)-oWin[id1].cb
			else if(ny<eval(oWin.minY)) ny=eval(oWin.minY)
		}
	
		oWin[id1].moveIt(nx,ny);resizeiframe('newFrame'+id1);
		if(oWin[id].state==0){oWin[id].lastx=nx;oWin[id].lasty=ny}
	}
	
	/*
	if(!bw.ns4)		// return false      
	{
		 
		 var oEditor = eval('MainFrame');
		 	
		 alert (oEditor);

	     oEditor.document.execCommand("Unlink", false);
	  	 document.execCommand("2D-position",false,true);

		if(id1>-1)
		{
			 var oEditor = parent.document.getElementById('mainFrame');
			 alert(oEditor);
			 oEditor.document.execCommand("Unlink", false);
			 var oSel = oEditor.document.selection.createRange();
			 var sType = oEditor.document.selection.type;

		}
	}
	*/

}
function mdblclick(e,num){if(num>-1) oWin[num].maximize(); else if(oWin.dragover>-1) oWin[oWin.dragover].maximize()}
function setWindows(placeit,rez){
	between=oWin.between
	oWin.rows=Math.round((wins/3)+0.2)
	oWin.columns=1
	j=0;a=0;c=0;
	for(i=0;i<wins;i++){
		if(j==oWin.columns-1){
			oWin.columns=wins-a<3?wins-a:wins-a==4?2:3
			if(wins!=1 && a!=0) c++; j=0
		}else if(a!=0) j++
		oWin[i].origw=(winpage.x2-between-(between*oWin.columns))/oWin.columns 
		oWin[i].origh=((winpage.y2-3-oWin.starty-(between*oWin.rows))/oWin.rows)
		oWin[i].lastx=oWin[i].origx=oWin[i].origw*(j)+(between*j)+between
		oWin[i].lasty=oWin[i].origy=oWin[i].origh*c+(between*c) + oWin.starty
		oWin[i].resize(oWin[i].origw,oWin[i].origh); oWin[i].moveIt(oWin[i].lastx,oWin[i].lasty)
		oWin[i].showIt(); a++;
	}
}
/*****************************************************************************
Adding window to winpage!
*****************************************************************************/
var lastx,lasty,lastw,lasth,idty,closeWins=0;
function addWindow(heading,content,x,y,w,h,isFolder,sectionName,intSrcWinId,bg,bga){
	
	//alert( _POPUP_IMAGE_PATH );
	var num=oWin.length;wins=num+1; var str="";
	//str+='<div id="divWin'+num+'" class="clWin">\n'
	str='<table width="100%" height="100%"  border="0" align="center" cellpadding="0" cellspacing="0" class="popuptable"><tr><td height="43" align="center" bgcolor="#FFFFFF"><table class="" width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF" height="100%"><tr><td width="100%" align="center" bgcolor="#FFFFFF">';
	str+='\n'
	+'<div id="divWinHead'+num+'" class="clWinHead">'+heading+'</div>\n'
	+'<div id="divWinBtnMin'+num+'" class="clMinButton">\n'
	+'<img id="imgBtnMin'+num+'" src="'+_POPUP_IMAGE_PATH+'/btn_min.gif">\n'
	+'</div>\n'
	+'<div id="divWinBtnMax'+num+'" class="clMaxButton">\n'
	+'<img id="imgBtnMax'+num+'" src="'+_POPUP_IMAGE_PATH+'/btn_max.gif">\n'
	+'</div>\n'
	+'<div id="divWinBtnClose'+num+'" class="clCloseButton">\n'
	+'<img id="imgBtnClose'+num+'" src="'+_POPUP_IMAGE_PATH+'/btn_close.gif">\n'
	+'</div>\n'
	+'<div id="divWinResize'+num+'" class="clWinResize">\n'
	+'</div>\n'
	+'<div id="divWindow'+num+'" class="clWindow">\n'
		+'<div id="divWinText'+num+'" class="clText">';
		
	if(content){
		str+=content+'</div>\n'+'</td></tr></table></td></tr></table>';
		+'</div>\n'
		//+'<div id="divWinUp'+num+'" class="clUp"><a href="#" onclick="return false" onmouseover="winScroll=true; oWin['+num+'].down();"  onmouseout="noScroll()"><img src="../images/popup/up_arrow.jpg" width="11" height="12" alt="" border="0"></a></div>\n'
		//+'<div id="divWinDown'+num+'" class="clDown"><a href="#" onclick="return false" onmouseover="winScroll=true;oWin['+num+'].up();" onmouseout="noScroll()"><img src="../images/popup/down_arrow.jpg" width="11" height="12" alt="" border="0"></a></div>\n'
		//+'</div>'
	}
	//document.write(str); 
	var oDiv1=document.createElement("DIV");
	oDiv1.id = "divWin"+num;
	oDiv1.className ="clWin";
	oDiv1.innerHTML = str;

	document.body.appendChild(oDiv1);
	var objNewFrame = document.getElementById('newFrame');
	objNewFrame.setAttribute('id','newFrame'+num);
	
	/* this attribute is set to get the source window id for destination window document.
	firstly this attribute was used to store own id to close the window */

	if(!isNaN(intSrcWinId) && intSrcWinId!=null)
		objNewFrame.setAttribute('Value',intSrcWinId);
	else
		objNewFrame.setAttribute('Value',null);

	/*************************************************************************************/	
	
	//var objChild=oDiv1.childNodes[0].nodeValue;
	//oDiv1.applyElement(objChild);
	/*oDiv1.setActive();
	oDiv1.focus();
	mainDiv.visibility = 'visible';*/
	if(content) create_window(num,x,y,w,h,bg,bga,heading,isFolder)
	
}

function endWin(){
	num=wins-1
	str='\n</div>\n'
	+'</div>\n'
		+'<div id="divWinUp'+num+'" class="clUp"><a href="#" onclick="return false" onmouseover="winScroll=1; oWin['+num+'].down();"  onmouseout="noScroll()"><img src="arrow_up.gif" width="11" height="12" alt="" border="0"></a></div>\n'
		+'<div id="divWinDown'+num+'" class="clDown"><a href="#" onclick="return false" onmouseover="winScroll=1; oWin['+num+'].up();" onmouseout="noScroll()"><img src="arrow_down.gif" width="11" height="12" alt="" border="0"></a></div>\n'
	+'</div>'
	return str
}

function lib_message(str)
{
	alert(str);
	return false;
}

		

