var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && 
document.compatMode!="BackCompat")? document.documentElement : 
document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" 
//extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? 
window.pageYOffset*1+30+"px" : 
iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? 
window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? 
window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? 
window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? 
window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" 
//extra
}

var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : 
null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0;ShowPosition(this.targetobj.style.left,this.targetobj.style.top,this.targetobj.title);}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="drag"){
this.dragapproved=1
if 
(isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if 
(isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}

/**********************************************************************************   
*  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="#935591" //Remember that you have to change the images as well if you change this color
oWin.bgcolor="#FFFFFF" //Default background color
oWin.bgcoloron="#FFFFFF"  //The "active" background color
oWin.bgscroll="#C1A9C0" //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=10 //The height of the bottom "border"
oWin.headh=15 //The height of the head "border"
oWin.bordersize=1 //The left and right bordersize
oWin.scrollw=13 //The width of the scroll area
oWin.scrollimgh=12 //The width of the scroll images
oWin.buttonsw=39 //The width of the buttons image
oWin.resizeh=9 //The width of the resize img
oWin.resizew=13 //The height of the resize img

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

	
//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.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.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||innerWidth||0;
	if(bw.ns6) this.x2-=2
	this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
	if(bw.ns6) 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
	return this;
}
function lib_moveIt(x,y){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_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 - 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.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){
	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)
	oWin[i].oText=new lib_obj('divWinText'+i,'divWin'+i,'divWindow'+i)
	oWin[i].oHead=new lib_obj('divWinHead'+i,'divWin'+i)
	oWin[i].oButtons=new lib_obj('divWinButtons'+i,'divWin'+i)
	oWin[i].oResize=new lib_obj('divWinResize'+i,'divWin'+i)
	oWin[i].oHead.evnt.onmouseover=new Function("w_mmover("+i+")")
	oWin[i].oHead.evnt.onmouseout=new Function("w_mmout()")
	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].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].addZ=win_addZ;	oWin[i].state="reg"
	oWin[i].moveIt(x,y); oWin[i].resize(w,h); oWin[i].checkscroll(); 
	if(bw.opera5) setTimeout("oWin["+i+"].resize("+w+","+h+"); oWin["+i+"].showIt()",10)
	else oWin[i].showIt()
}
/*****************************************************************************
Window functions 
*****************************************************************************/
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(){
	if(this.state!="max"){
		if(this.state!="min"){this.lastx=this.x; this.lasty=this.y}
		mw=winpage.x2 - 10; mh=winpage.y2 - 10 - oWin.starty
		this.moveIt(5,5+oWin.starty,30,10)
		this.resize(mw,mh); this.oResize.showIt(); this.state="max"
		this.addZ()
	}else 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; x=0}
			for(j=0;j<wins;j++){
				couns++; if(oWin[j].x==x && oWin[j].y==y) a++
			}if(a==ok) break;
		}x=a*125;
		this.moveIt(x,y); this.oResize.hideIt()
		this.state="min"; this.resize(125,oWin.headh)
	}else this.regwin()
}
function win_close(){this.hideIt(); this.oUp.hideIt(); this.oDown.hideIt()}
function win_resize(w,h){
	this.oButtons.moveIt(w-oWin.buttonsw,0); 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,oWin.headh,0,1); this.oText.moveIt(2,3)
	this.oUp.hideIt(); this.oDown.hideIt()
}
function win_checkscroll(w,h){
	this.oText.height=this.oText.evnt.offsetHeight||this.oText.css.pixelHeight||this.oText.ref.height||0
	w=this.cr; h=this.cb
	if(this.oText.height>h-oWin.bottomh-oWin.headh && this.state!="min"){
		this.oWindow.clipTo(0,w-oWin.scrollw-oWin.bordersize*2,h-oWin.bottomh-oWin.headh,0,1); 
		this.oUp.moveIt(w-oWin.scrollw,oWin.headh)
		this.oUp.clipTo(0,oWin.scrollw-oWin.bordersize,h-oWin.bottomh-oWin.scrollimgh-oWin.headh,0,1); 
		this.oDown.moveIt(w-oWin.scrollw,h-oWin.bottomh-oWin.scrollimgh)
		this.oDown.clipTo(0,oWin.scrollw-oWin.bordersize,oWin.scrollimgh,0,1); this.oUp.showIt()
		this.oDown.showIt()
	}else{this.oUp.hideIt(); this.oDown.hideIt()}
}
var sctim=100;
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++; 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
*****************************************************************************/
function w_mmover(num,resize){if(!resize) oWin.dragover=num; else oWin.resizeover=num}
function w_mmout(){oWin.dragover=-1; oWin.resizeover=-1}
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 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
	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
		}
		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(e,y,rresize){ //Mousemove
	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)
	}else if(id1>-1){ //Move
		nx=x-oWin.clickedX; ny=y-oWin.clickedY
		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)
		if(oWin[id].state==0){oWin[id].lastx=nx; oWin[id].lasty=ny}
	}
	if(!bw.ns4) return false      
}
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
function addWindow(heading,content,x,y,w,h,bg,bga){
	var num=oWin.length; wins=num+1; var str=""
	str+='<div id="divWin'+num+'" class="clWin">\n'
	str+='<div class="clLogo"><img alt="Window Script from DHTMLCentral.com" src="usr/themes/gnuchile/img/popups/win_logo.gif" width="19" height="18" alt="" border="0" align="top"></div>\n'
	+'<div id="divWinHead'+num+'" class="clWinHead">       '+heading+'</div>\n'
	+'<div id="divWinButtons'+num+'" class="clWinButtons">\n'
		+'<map name="map'+num+'">\n'
			+'<area shape="rect" coords="26,2,35,11" href="#" alt="Window Script from DHTMLCentral.com"  onclick="oWin['+num+'].close(); return false">\n'
			+'<area shape="rect" coords="14,2,23,11" href="#" alt="Window Script from DHTMLCentral.com"  onClick="oWin['+num+'].maximize(); return false">\n'
			+'<area shape="rect" coords="2,2,11,11" href="#" alt="Window Script from DHTMLCentral.com"  onClick="oWin['+num+'].minimize(); return false">\n'
		+'</map>\n'
		+'<img usemap="#map'+num+'" alt="Window Script from DHTMLCentral.com"  src="usr/themes/gnuchile/img/popups/buttons.gif" width="38" height="14" alt="" border="0">\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'
		+'</div>\n'
		+'<div id="divWinUp'+num+'" class="clUp"><a href="#" onclick="return false" onmouseover="winScroll=1; oWin['+num+'].down();"  onmouseout="noScroll()"><img src="usr/themes/gnuchile/img/popups/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="usr/themes/gnuchile/img/popups/arrow_down.gif" width="11" height="12" alt="" border="0"></a></div>\n'
		+'</div>'
	}
	document.write(str)
	if(content) create_window(num,x,y,w,h,bg,bga)
}
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="usr/themes/gnuchile/img/popups/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="usr/themes/gnuchile/img/popups/arrow_down.gif" width="11" height="12" alt="" border="0"></a></div>\n'
	+'</div>'
	return str
}

//Funcion Evitar Reenvio Formulario

//Agregar Al Formulario
//onSubmit="return enviado()">
var cuenta=0;
function enviado(){
	if (cuenta == 0){
		cuenta++;
		return true;
	}else{
		alert("El siguiente formulario ya ha sido enviado una vez con exito, no es necesario que repita la operacion.");
		return false;
	}
}

var myConn = new XHConn();

if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

var include_terminado = function (oXML) { document.getElementById('include').innerHTML = oXML.responseText; };
var proc_terminado = function (oXML) { document.getElementById('proc').innerHTML = oXML.responseText; };

function include_dinamico (url)
{
	document.getElementById('include').innerHTML = "<img src='usr/pkgs/ajax/loading_ani2.gif' />";
	
	myConn.connect("mod/doclibrary/include.php", "GET", "variable="+url, include_terminado);
}

function dinproc2 (url)
{
	document.getElementById('proc').innerHTML = "<img src='usr/pkgs/ajax/loading_ani2.gif' />";
	
	myConn.connect("mod/groupcalendar/proc.php", "GET", "prog="+url, proc_terminado);
}

var ver_dia_terminado = function (oXML) { document.getElementById('include').innerHTML = oXML.responseText; };

function ver_dia (url)
{
	document.getElementById('include').innerHTML = "<img src='usr/pkgs/ajax/loading_ani2.gif' />";
	
	myConn.connect("mod/groupcalendar/viewday.php", "GET", "date="+url, ver_dia_terminado);
}

var dinproc_terminado = function (oXML) { document.getElementById('include').innerHTML = oXML.responseText; };

function dinproc (url)
{
	document.getElementById('include').innerHTML = "<img src='usr/pkgs/ajax/loading_ani2.gif' />";
	
	myConn.connect("mod/groupcalendar/viewday.php", "GET", "date="+url, dinproc_terminado);
}

function toggle( targetId ){
        target = document.getElementById( targetId );
           if (target.style.display == "none"){
              target.style.display = "block";
           } else {
              target.style.display = "none";
           }
}
function poppap(url,nom,details) {
 window.open(url,nom,details)
}

var maxWidth=100;
var maxHeight=100;
var fileTypes=["gif","png","jpg"];
var outImage="previewField";
var defaultPic="spacer.gif";

/***** DO NOT EDIT BELOW *****/

function preview(what){
  var source=what.value;
  var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
  for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
  globalPic=new Image();
  if (i<fileTypes.length) globalPic.src=source;
  else {
    globalPic.src=defaultPic;
    alert("NO ES UNA IMAGEN VALIDA\nIntente una imagen con extension:\n\n"+fileTypes.join(", "));
  }
  setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
  var field=document.getElementById(outImage);
  var x=parseInt(globalPic.width);
  var y=parseInt(globalPic.height);
  if (x>maxWidth) {
    y*=maxWidth/x;
    x=maxWidth;
  }
  if (y>maxHeight) {
    x*=maxHeight/y;
    y=maxHeight;
  }
  field.style.display=(x<1 || y<1)?"none":"";
  field.src=globalPic.src;
  field.width=x;
  field.height=y;
}

function redimen(){
  var field=document.getElementById(outImage);
  var x=parseInt(globalPic.width);
  var y=parseInt(globalPic.height);
  if (x>maxWidth) {
    y*=maxWidth/x;
    x=maxWidth;
  }
  if (y>maxHeight) {
    x*=maxHeight/y;
    y=maxHeight;
  }
  field.style.display=(x<1 || y<1)?"none":"";
  field.width=x;
  field.height=y;
}


function loadarr(val){
	document.getElementById("arrtodel").value = document.getElementById("arrtodel").value + "#!#" + val;
}





function ParceJS( ObjResponse )
{
    /**************************************
	funcion creada por Victor Manuel Agudelo : vicmany2k@hotmail.com 
           funcion encargada de recorrer el texto devuelto por el responseText de AJAX, e identificar codigo JavaScript
	y habilitarlos para modo ejecucion desde la pagina llamada
	
	 Nota: cualquier mejora sobre el codigo hacermela saber 
          *************************************/     

	 if ( "" == ObjResponse)
	   {
	      //alert("No se han enviado parametros a parcear");
	      return false;
	   }
      //variable que almacena el texto del codigo javascript
	  var TextJs = "";
	  //almacena la cadena de texto a recorrer para encontrar el archivo incluido en lso js's
	  var TextSrc="";
	  //arreglo que almacena cada uno de los archivos incluidos llamados por src
	  var FileJsSrc = new Array();
	  var counter=0;
	  //guarda las porciones siguientes de codigo de HTML que se van generando por cada recorrido del parceador
	  var TextNextHtml;
	  var PosJSTagStart;
	  var PosJSTagEnd;
	  //guarda la posicion de la primera ocurrencia del parametro src
	  var SrcPosIni;
	  //guarda la posicion de ocurrencia de las comillas
	  var SrcPosComilla;
	  while (ObjResponse.indexOf("<script") > 0)
	 {
			/*encuentra la primera ocurrencia del tag <script*/
			PosJSTagStart = ObjResponse.indexOf("<script");
            /*corta el texto resultante desde la primera ocurrencia hasta el final del texto					   */
			TextNextHtml = ObjResponse.substring( PosJSTagStart,ObjResponse.length);					   
			/*encuentra la primera ocurrencia de finalizacion del tag >, donde cierra la palabra javascript*/
            PosJSTagEnd = TextNextHtml.indexOf(">");	
            //captura el texto entre el tag <script>
			TextSrc = TextNextHtml.substring(0,PosJSTagEnd);
			//verficica si tiene le texto src de llamado a un archivo js
			if ( TextSrc.indexOf("src") > 0)
			{
				//posicion del src
				 SrcPosIni = TextSrc.indexOf( "src" );
				 //almacena el texto desde la primera aparicion del src hasta el final
				 TextSrc = TextSrc.substring(SrcPosIni, PosJSTagEnd);
				 //lee la posicion de la primer comilla
				 SrcPosComilla = TextSrc.indexOf( '"' );
				 //arma el texto, desde la primer comilla hasta el final,se le suma 1, para pasar la comilla inicial
				 TextSrc = TextSrc.substring(SrcPosComilla + 1,PosJSTagEnd);				
				 //posicion de la comilla final
				 SrcPosComilla = TextSrc.indexOf('"');
				 //lee el archivo
				 SrcFileJs = TextSrc.substring(0, SrcPosComilla);
				 FileJsSrc[counter] = SrcFileJs;
				 counter++;
						  
			}
					   
			//TextNextHtml, nuevo porcion de texto HTML empezando desde el tag script
			TextNextHtml = TextNextHtml.substring(PosJSTagEnd + 1,ObjResponse.length);
			//encuentra el final del script
			objJSTagEndSc = TextNextHtml.indexOf("script>");

			/*recorre desde la primera ocurrencia del tag > hasta el final del script < /script>*/
			//se le resta 2 al objJSTagEndSc, para restarle el < /
			objJSText = TextNextHtml.substring(0, objJSTagEndSc - 2);

			ObjResponse = TextNextHtml;
			TextJs = TextJs + "\n" + objJSText;
				   	  
     }					   
		//alert("FinalJS\n\n"+objJs);

		// Agrego los scripts dentro del encabezado
		EvalScript = document.createElement("script");
		EvalScript.text = TextJs;
		document.getElementsByTagName('head')[0].appendChild(EvalScript);
		// Agrego los scripts incluidos dentro del encabezado
		for (i = 0; i <  FileJsSrc.length ;i++ )
		{
			EvalScript = document.createElement("script");
			EvalScript.src = FileJsSrc[i];
			document.getElementsByTagName('head')[0].appendChild(EvalScript);
		}
		return true;
}
	

var RequestObject = false;
var Archivo = 'mod/stats/ajax.php';
window.setInterval("actualizacion_reloj()", 2000);
if (window.XMLHttpRequest)
RequestObject = new XMLHttpRequest();

if (window.ActiveXObject)
RequestObject = new ActiveXObject("Microsoft.XMLHTTP");

function ReqChange() {
if (RequestObject.readyState==4) {
if (RequestObject.responseText.indexOf('invalid') == -1)
{
var msgs = RequestObject.responseText.split('|');
document.getElementById("online").innerHTML = msgs[0];
	if ( ""  != msgs[0]){
		ParceJS(msgs[0]);
	}
}
else {
document.getElementById("online").innerHTML = "Error llamando";
}
}
}
function llamadaAjax() {
document.getElementById("online").innerHTML = "";
RequestObject.open("GET", Archivo , true);
RequestObject.onreadystatechange = ReqChange;
RequestObject.send(null);
}

function actualizacion_reloj() {
llamadaAjax();
}


/*GNU PROJECT*/

		
	var fromBoxArray = new Array();
	var toBoxArray = new Array();
	var selectBoxIndex = 0;
	var arrayOfItemsToSelect = new Array();
	
	
	function moveSingleElement()
	{
		var selectBoxIndex = this.parentNode.parentNode.id.replace(/[^\d]/g,'');
		var tmpFromBox;
		var tmpToBox;
		if(this.tagName.toLowerCase()=='select'){			
			tmpFromBox = this;
			if(tmpFromBox==fromBoxArray[selectBoxIndex])tmpToBox = toBoxArray[selectBoxIndex]; else tmpToBox = fromBoxArray[selectBoxIndex];
		}else{
		
			if(this.value.indexOf('>')>=0){
				tmpFromBox = fromBoxArray[selectBoxIndex];
				tmpToBox = toBoxArray[selectBoxIndex];			
			}else{
				tmpFromBox = toBoxArray[selectBoxIndex];
				tmpToBox = fromBoxArray[selectBoxIndex];	
			}
		}
		
		for(var no=0;no<tmpFromBox.options.length;no++){
			if(tmpFromBox.options[no].selected){
				tmpFromBox.options[no].selected = false;
				tmpToBox.options[tmpToBox.options.length] = new Option(tmpFromBox.options[no].text,tmpFromBox.options[no].value);
				
				for(var no2=no;no2<(tmpFromBox.options.length-1);no2++){
					tmpFromBox.options[no2].value = tmpFromBox.options[no2+1].value;
					tmpFromBox.options[no2].text = tmpFromBox.options[no2+1].text;
					tmpFromBox.options[no2].selected = tmpFromBox.options[no2+1].selected;
				}
				no = no -1;
				tmpFromBox.options.length = tmpFromBox.options.length-1;
											
			}			
		}
		
		
		var tmpTextArray = new Array();
		for(var no=0;no<tmpFromBox.options.length;no++){
			tmpTextArray.push(tmpFromBox.options[no].text + '___' + tmpFromBox.options[no].value);			
		}
		tmpTextArray.sort();
		var tmpTextArray2 = new Array();
		for(var no=0;no<tmpToBox.options.length;no++){
			tmpTextArray2.push(tmpToBox.options[no].text + '___' + tmpToBox.options[no].value);			
		}		
		tmpTextArray2.sort();
		
		for(var no=0;no<tmpTextArray.length;no++){
			var items = tmpTextArray[no].split('___');
			tmpFromBox.options[no] = new Option(items[0],items[1]);
			
		}		
		
		for(var no=0;no<tmpTextArray2.length;no++){
			var items = tmpTextArray2[no].split('___');
			tmpToBox.options[no] = new Option(items[0],items[1]);			
		}
	}
	
	function sortAllElement(boxRef)
	{
		var tmpTextArray2 = new Array();
		for(var no=0;no<boxRef.options.length;no++){
			tmpTextArray2.push(boxRef.options[no].text + '___' + boxRef.options[no].value);			
		}		
		tmpTextArray2.sort();		
		for(var no=0;no<tmpTextArray2.length;no++){
			var items = tmpTextArray2[no].split('___');
			boxRef.options[no] = new Option(items[0],items[1]);			
		}		
		
	}
	function moveAllElements()
	{
		var selectBoxIndex = this.parentNode.parentNode.id.replace(/[^\d]/g,'');
		var tmpFromBox;
		var tmpToBox;		
		if(this.value.indexOf('>')>=0){
			tmpFromBox = fromBoxArray[selectBoxIndex];
			tmpToBox = toBoxArray[selectBoxIndex];			
		}else{
			tmpFromBox = toBoxArray[selectBoxIndex];
			tmpToBox = fromBoxArray[selectBoxIndex];	
		}
		
		for(var no=0;no<tmpFromBox.options.length;no++){
			tmpToBox.options[tmpToBox.options.length] = new Option(tmpFromBox.options[no].text,tmpFromBox.options[no].value);			
		}	
		
		tmpFromBox.options.length=0;
		sortAllElement(tmpToBox);
		
	}
	
	
	/* This function highlights options in the "to-boxes". It is needed if the values should be remembered after submit. Call this function onsubmit for your form */
	function multipleSelectOnSubmit()
	{
	var stringarr="";
		for(var no=0;no<arrayOfItemsToSelect.length;no++){
			var obj = arrayOfItemsToSelect[no];
			for(var no2=0;no2<obj.options.length;no2++){
				obj.options[no2].selected = true;
				stringarr=stringarr+","+obj.options[no2].value;
			}
		}
		if(stringarr==""){
			stringarr=",";
		}
		document.getElementById('arrvalues').value=stringarr;
	}
	
	function createMovableOptions(fromBox,toBox,totalWidth,totalHeight,labelLeft,labelRight)
	{		
		fromObj = document.getElementById(fromBox);
		toObj = document.getElementById(toBox);
		
		arrayOfItemsToSelect[arrayOfItemsToSelect.length] = toObj;

		
		fromObj.ondblclick = moveSingleElement;
		toObj.ondblclick = moveSingleElement;

		
		fromBoxArray.push(fromObj);
		toBoxArray.push(toObj);
		
		var parentEl = fromObj.parentNode;
		
		var parentDiv = document.createElement('DIV');
		parentDiv.className='multipleSelectBoxControl';
		parentDiv.id = 'selectBoxGroup' + selectBoxIndex;
		parentDiv.style.width = totalWidth + 'px';
		parentDiv.style.height = totalHeight + 'px';
		parentEl.insertBefore(parentDiv,fromObj);
		
		
		var subDiv = document.createElement('DIV');
		subDiv.style.width = (Math.floor(totalWidth/2) - 15) + 'px';
		fromObj.style.width = (Math.floor(totalWidth/2) - 15) + 'px';

		var label = document.createElement('SPAN');
		label.innerHTML = labelLeft;
		subDiv.appendChild(label);
		
		subDiv.appendChild(fromObj);
		subDiv.className = 'multipleSelectBoxDiv';
		parentDiv.appendChild(subDiv);
		
		
		var buttonDiv = document.createElement('DIV');
		buttonDiv.style.verticalAlign = 'middle';
		buttonDiv.style.paddingTop = (totalHeight/2) - 50 + 'px';
		buttonDiv.style.width = '30px';
		buttonDiv.style.textAlign = 'center';
		parentDiv.appendChild(buttonDiv);
		
		var buttonRight = document.createElement('INPUT');
		buttonRight.type='button';
		buttonRight.value = '>';
		buttonDiv.appendChild(buttonRight);	
		buttonRight.onclick = moveSingleElement;	
		
		var buttonAllRight = document.createElement('INPUT');
		buttonAllRight.type='button';
		buttonAllRight.value = '>>';
		buttonAllRight.onclick = moveAllElements;
		buttonDiv.appendChild(buttonAllRight);		
		
		var buttonLeft = document.createElement('INPUT');
		buttonLeft.style.marginTop='10px';
		buttonLeft.type='button';
		buttonLeft.value = '<';
		buttonLeft.onclick = moveSingleElement;
		buttonDiv.appendChild(buttonLeft);		
		
		var buttonAllLeft = document.createElement('INPUT');
		buttonAllLeft.type='button';
		buttonAllLeft.value = '<<';
		buttonAllLeft.onclick = moveAllElements;
		buttonDiv.appendChild(buttonAllLeft);
		
		var subDiv = document.createElement('DIV');
		subDiv.style.width = (Math.floor(totalWidth/2) - 15) + 'px';
		toObj.style.width = (Math.floor(totalWidth/2) - 15) + 'px';

		var label = document.createElement('SPAN');
		label.innerHTML = labelRight;
		subDiv.appendChild(label);
				
		subDiv.appendChild(toObj);
		parentDiv.appendChild(subDiv);		
		
		toObj.style.height = (totalHeight - label.offsetHeight) + 'px';
		fromObj.style.height = (totalHeight - label.offsetHeight) + 'px';

			
		selectBoxIndex++;
		
	}

