/**
 *
 *  (C) 2001 - 2006 Glimworm Information Technology BV
 *
 *                  http://www.glimworm.nl
 */

var dot=".";

try { console.log('init console... done'); } catch(e) { console = { log: function() {} } }

function GWhelpWindow(page) {
	var sx = screen.width - 550-10;
	var sy = screen.height - 550;
	GWhelpWindowID = window.open('','GWhelpWindow','top='+sy+' left='+sx+' toolbar=no,scrollbars=yes,location=no,width=550,height=450')
	GWhelpWindowID.focus()
	GWhelpWindowID.location.href = page
	top.window.moveTo(0,0);
}

function GWtryWindow(page) {
	GWtryWindowOpen = true
	var sx = screen.width - 700;
	sx = sx /2;
	var sy = screen.height - 535;
	sy = sy /2;
	GWtryWindowID = window.open('','GWtryWindow','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width=700,height=535')
	GWtryWindowID.location.href = page
}

function GWbuyWindow(page) {
	GWbuyWindowOpen = true
	GWbuyWindowID = window.open('','GWbuyWindow','toolbar=no,scrollbars=yes,location=no,width=550,height=550')
	GWbuyWindowID.focus()
	GWbuyWindowID.location.href = page
}

function GWleWindow(page) {
	leWidth = leWidthA;
	if (leWidth > screen.width) {
		leWidth = screen.width - 10;
	}
	var sx = screen.width - leWidth;
	if (sx < 0) {
		sx = 0;
	} else {
	  sx = sx /2;
	}
	var sy = screen.height - 570;
	sy = sy /2;
	GWleWindowOpen = true
	GWleWindowID = window.open('','GWleWindow','top='+sy+' left='+sx+' toolbar=no,status=1,scrollbars=no,location=no,width='+leWidth+',height=570')
	GWleWindowID.focus()
	GWleWindowID.location.href = page
}

function GWNewsFeedWindow(page) {
	//GWbuyWindowOpen = true
	GWNewsFeedWindowID = window.open('','GWbuyWindow','toolbar=no,scrollbars=yes,location=no,width=650,height=550')
	GWNewsFeedWindowID.focus()
	GWNewsFeedWindowID.location.href = page
}

GWpreWindowOpen = false

function GWpreWindow(page) {
	GWpreWindowOpen = true
	GWpreWindowID = window.open('','GWpreWindow','toolbar=no,scrollbars=no,location=no,width=750,height=550')
	with (GWpreWindowID.document) {
		write("<html><frameset rows=45,* frameborder=NO border=0 framespacing=0>");
		write("<frame src=\"_assets/ldedit/glimworm_branding"+dot+"html\" scrolling=NO noresize>");
		write("<frame src="+page+" frameborder=NO>");
		write("</frameset></html>");
	}
	return false;
}
function GWextPreWindow(page) {
	GWpreWindowOpen = true
	GWpreWindowID = window.open('','GWpreWindow','toolbar=no,scrollbars=no,location=no,width=750,height=550')
	with (GWpreWindowID.document) {
		write("<html><frameset rows=45,* frameborder=NO border=0 framespacing=0>");
		write("<frame src=\"_assets/ldedit/glimworm_branding_Ext"+dot+"html\" scrolling=NO noresize>");
		write("<frame src="+page+" frameborder=NO>");
		write("</frameset></html>");
	}
	return false;
}
function gw_frameset(page,pagename) {
	GWpreWindowOpen = true
	page = "std_frameset"+dot+"jsp?Page="+escape(page)+"&pagename="+escape(pagename);
	GWpreWindowID = window.open(page,'GWpreWindow','toolbar=no,scrollbars=no,location=no,width=750,height=550')
	return false;
}

var GWloginWindowOpen = false

function GWloginWindow(page) {
	GWloginWindowOpen = true
	var sx = screen.width - 350;
	sx = sx /2;
	var sy = screen.height - 300;
	sy = sy /2;
	GWloginWindowID = window.open('','GWloginWindow','top='+sy+' left='+sx+' toolbar=no,scrollbars=no,location=no,width=350,height=300')
	GWloginWindowID.focus()
	//GWartWindowID.location.reload(false)
	GWloginWindowID.location.href = page
}

function GWpopWindow(pageImage,H,W) {
	GWpopWindowOpen = true;
	maxW = screen.width - 10;
	maxH = screen.height - 100;
	if (H > maxH) {
		H = maxH;
	}
	if (W > maxW) {
		W = maxW;
	}
	var sx = screen.width - H;
	sx = sx /2;
	var sy = screen.height - W;
	sy = sy /2;
	GWpopWindowID = window.open('','GWpopWindowID','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width='+W+',height='+H)
	var page="<html>\n<head>\n<title>"+LL_js_clickimagetoclose+"</title>\n</head>\n<body onBlur='self.focus()' marginheight=0 marginwidth=0 topmargin=0 leftmargin=0>\n<a href='javascript:window.close();'><img src='"+pageImage+"' border='0'  alt='"+LL_js_clickimagetoclose+"'></a>\n</body>\n</html>";

	GWpopWindowID.document.open();
	GWpopWindowID.document.write(page);
	GWpopWindowID.document.close();
}


function GWpopWindowFla(pageImage,H,W,Title) {
	GWpopWindowOpen = true;
	maxW = screen.width - 10;
	maxH = screen.height - 100;
	if (H > maxH) {
		H = maxH;
	}
	if (W > maxW) {
		W = maxW;
	}
	var sx = screen.width - H;
	sx = sx /2;
	var sy = screen.height - W;
	sy = sy /2;
	//GWpopWindowID = window.open(pageImage,'GWpopWindowID','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width='+W+',height='+H)
	GWpopWindowID = window.open('','GWpopWindowID','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width='+W+',height='+H)
	fla=	"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width="+W+" height="+H+">"+
		"<param name=movie value="+pageImage+">"+
		"<param name=quality value=high>"+
		"<param name=\"SCALE\" value=\"exactfit\">"+
		"<embed src="+pageImage+" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" scale=\"exactfit\" width="+W+" height="+H+">"+
		"</embed>"+
		"</object>";

	var page="<html>\n<head>\n<title>"+Title+"</title>\n</head>\n<body onBlur='self.focus()' marginheight=0 marginwidth=0 topmargin=0 leftmargin=0>\n"+fla+"\n</body>\n</html>";

	GWpopWindowID.document.open();
	GWpopWindowID.document.write(page);
	GWpopWindowID.document.close();
}

function GWemailpage2(to) {
	ltaf_body2 = ltaf_body;
	if (ltaf_body2.indexOf("{link}") > -1) {
		ltaf_body2 = ltaf_body2.replace("{link}",escape(document.location.href));
	} else {
		ltaf_body2 = ltaf_body2+escape(document.location.href);
	}
	document.location.href="mailto:"+to+"?subject="+ltaf_subject+"&body="+ltaf_body2;
}
function GWemailpage() {
        ltaf_body2 = ltaf_body;
	if (ltaf_body2.indexOf("{link}") > -1) {
		ltaf_body2 = ltaf_body2.replace("{link}",escape(document.location.href));
	} else {
		ltaf_body2 = ltaf_body2+escape(document.location.href);
	}
	document.location.href="mailto:?subject="+ltaf_subject+"&body="+ltaf_body2;
}
function GWprintpage_nohead(extra) {
		GWpopWindowOpen = true;
		H = screen.height - 300;
		W = 800;
		var sx = screen.width - H;
		sx = sx /2;
		var sy = screen.height - W;
		sy = sy /2;
		GWpopWindowID = window.open('','GWpopWindowID','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width='+W+',height= '+H)
		GWpopWindowID.location.href="fm_print"+dot+"jsp";

}
function GWprintpageAfter() {
	GWpopWindowOpen = true;
	H = screen.height - 300;
	W = catwidth();
	var sx = screen.width - H;
	sx = sx /2;
	var sy = screen.height - W;
	sy = sy /2;
	GWpopWindowID = window.open('','GWpopWindowID','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width='+W+',height='+H)
	GWpopWindowID.location.href="print"+dot+"jsp";
	//setTimeout("GWprintpage2()",500)

}
function GWprintpage() {
	GWpopWindowOpen = true;
	H = screen.height - 300;
	W = catwidth();
	var sx = screen.width - H;
	sx = sx /2;
	var sy = screen.height - W;
	sy = sy /2;
	GWpopWindowID = window.open('','GWpopWindowID','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width='+W+',height='+H)
	GWpopWindowID.location.href="print"+dot+"jsp";
	//setTimeout("GWprintpage2()",500)

}
var printareaName="printarea";
function GWsetprintarea(PA) {
	printareaName=PA;
}
function GWgetprintContent() {
	return document.getElementById(printareaName).innerHTML;
}
function GWprintpage2() {
	poptext=document.getElementById(printareaName).innerHTML;
	GWpopWindowID.document.write(poptext);
	GWpopWindowID.print();
	//GWpopWindowID.close();
}

function WhichURL() {
	return document.location.href;
}

function GWcheckWin() {
	setTimeout('GWcheckWin2()',500);
}
function GWcheckWin2() {
	if (GWeditWindowOpen) {
	   if (!GWeditWindowID.closed) {
		GWeditWindowID.focus()
	   }
	}
	if (GWleWindowOpen) {
	   if (!GWleWindowID.closed) {
		GWleWindowID.focus()
	   }
	}
	if (GWbuyWindowOpen) {
	   if (!GWbuyWindowID.closed) {
		GWbuyWindowID.focus()
	   }
	}
	if (GWtryWindowOpen) {
	   if (!GWtryWindowID.closed) {
		GWtryWindowID.focus()
	   }
	}
	if (GWartWindowOpen) {
	   if (!GWartWindowID.closed) {
		GWartWindowID.focus()
	   }
	}
	if (GWloginWindowOpen) {
	   if (!GWloginWindowID.closed) {
		GWloginWindowID.focus()
	   }
	}
	if (GWpopWindowOpen) {
	   if (!GWpopWindowID.closed) {
		GWpopWindowID.focus()
	   }
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}

function GWconfirm (url) {
	if (confirm("<%=LL_AreUSure%>") ) {
		timerOn();
		document.location.href=url;
		return true;
	} else {
		return false;
	}
}

var GWselected;

function setGWselected(num) {
	GWselected=num;
	document.EDITWIN.layout.value=num;
}

var imagename = new Array("","image_top","image_left","image_right","image_bottom","no_image");


function orderby(orderBy) {
		 self.document.memlistform.ORDERBY.value=orderBy;
		 self.document.memlistform.submit();
}
function timerOn() {
	MM_showHideLayers("timer","","show");
}

function download(file) {
	var sx = screen.width - 450;
	sx = sx /2;
	var sy = screen.height - 250;
	sy = sy /2;
	window.open('download1'+dot+'jsp?fname='+escape(file),'Download','top='+sy+' left='+sx+' toolbar=no,scrollbars=no,location=no,width=450,height=250');
}

function GWrefresh(address) {
	if (top.bottom != null) {
		top.bottom.location.href="manager"+dot+"jsp";
	}
	document.location.href=address;
}
function working() {
	if (top != document && top.bottom != undefined) {
		top.bottom.working();
	}
}
function workingDone() {
	if (top != document  && top.bottom != undefined) {
		top.bottom.done();
	}
}
function GWswap(img,gwimage) {
	document[img].src=gwimage
}

function GWrest(img) {
	document[img].src=StoreTemplate+img+".gif"
}
function showImage(img,H,W) {
	GWpopWindow(img,H,W);
}
function bigImage(img) {
	document["bigimg"].src=img;
}

function noaction(){
	f = true;
}
function GWmyAccount() {
	GWeditWindow2("editwin"+dot+"jsp?AREA=MYACCOUNT&nopublish=on&cancel="+LL_EW_Close);
}
function GWchangestyle() {
	GWeditWindow2("editwin"+dot+"jsp?AREA=SWAPSKIN&publish="+ub_LL_Apply+"&cancel="+ub_LL_Close);
}
function GWconfirm (url) {
	if (confirm(ub_LL_AreUSure) ) {
		timerOn();
		document.location.href=url;
		return true;
	} else {
		return false;
	}
}
function sid() {
	return Ses_SID;
}
function startout() {
		 document["start"].src="/_assets/signup/steps/step0-start"+pop_Suffix+".gif";
}
function startover() {
		 document["start"].src="/_assets/signup/steps/step0-start-over"+pop_Suffix+".gif";
}
function deleteout() {
		 document["delete"].src="/_assets/signup/steps/step0-delete"+pop_Suffix+".gif";
}
function deleteover() {
		 document["delete"].src="/_assets/signup/steps/step0-delete-over"+pop_Suffix+".gif";
}

function GWeditWindowPop(page) {
	GWeditWindowOpen = true;
	var sx = screen.width - 500;
	sx = sx /2;
	var sy = screen.height - 535;
	sy = sy /2;
	GWeditWindowID = window.open('','GWeditWindow','top='+sy+' left='+sx+' toolbar=no,titlebar=no,scrollbars=auto,location=no,width=500,height=535')
	GWeditWindowID.location.href = page
}
function glimrefresh() {
	   //document.location.href="index"+dot+"jsp";
}

function GWtoggleDisplay(id){ 
 if(this.document.getElementById( id).style.display=='none'){ 
                this.document.getElementById( id).style.display='inline';
                if(this.document.getElementById(id+"link") != undefined){ 
                        this.document.getElementById(id+"link").style.display='none'; 
                } 
        }else{ 
                this.document.getElementById(  id).style.display='none'; 
                if(this.document.getElementById(id+"link") != undefined){ 
                        this.document.getElementById(id+"link").style.display='inline'; 
                } 
        } 
} 
function GWToggleDisplayOn(id){ 
	this.document.getElementById( id).style.display='inline'; 
	if(this.document.getElementById(id+"link") != undefined){ 
		this.document.getElementById(id+"link").style.display='none'; 
	} 
} 
function GWToggleDisplayOff(id){ 
	this.document.getElementById(  id).style.display='none'; 
	if(this.document.getElementById(id+"link") != undefined){ 
		this.document.getElementById(id+"link").style.display='inline'; 
	} 
} 
function ShowCalendarSQL(name) {
        startDate = document.all[name].value;
        tempDate = startDate.split("-");
        startDate = tempDate[1]+"/"+tempDate[2]+"/"+tempDate[0];
        endDate = window.showModalDialog('/_assets/htc/Calendar'+dot+'htm',startDate , 'dialogLeft:500px;dialogTop:500px;dialogHeight:210px;dialogWidth:265px;center:No;help:No;scroll:No;resizable:No;status:No;');
        tempDate = endDate.split("/");
        endDate = tempDate[2]+"-"+tempDate[0]+"-"+tempDate[1];
        document.all[name].value = endDate;
}

function ShowCalendar(name) {
        startDate = document.all[name].value;
        tempDate = startDate.split("-");
        startDate = tempDate[1]+"/"+tempDate[0]+"/"+tempDate[2];
        endDate = window.showModalDialog('/_assets/htc/Calendar'+dot+'htm',startDate , 'dialogLeft:500px;dialogTop:500px;dialogHeight:210px;dialogWidth:265px;center:No;help:No;scroll:No;resizable:No;status:No;');
        tempDate = endDate.split("/");
        endDate = tempDate[1]+"-"+tempDate[0]+"-"+tempDate[2];
        document.all[name].value = endDate;
}
function ShowCalendar2(name) {
        startDate = document.all[name].value;
        tempDate = startDate.split("-");
        startDate = tempDate[1]+"/"+tempDate[0]+"/"+tempDate[2];
        endDate = window.showModalDialog('/_assets/htc/Calendar'+dot+'htm',startDate , 'dialogLeft:500px;dialogTop:500px;dialogHeight:210px;dialogWidth:265px;center:No;help:No;scroll:No;resizable:No;status:No;');
        tempDate = endDate.split("/");
        endDate = tempDate[1]+"-"+tempDate[0]+"-"+tempDate[2];
        document.all[name].value = endDate;
        checkdate(name);
}
function dateFormat(da) {
  var day = da.getDate();
  var mon = da.getMonth();
  var yr = da.getFullYear();
  day++;
  mon++;
  var _day = ""+day;
  var _mon = ""+mon;
  if (day < 10) _day = "0"+day;
  if (mon < 10) _mon = "0"+mon;
  return _day+"-"+mon+"-"+yr;
}

/* Javascript callender functions
   ============================== */
function fixPosition(divname) {
 divstyle = getDivStyle(divname);
 positionerImgName = divname + 'Pos';
 isPlacedUnder = false;
 if (isPlacedUnder) {
  setPosition(divstyle,positionerImgName,true);
 } else {
  setPosition(divstyle,positionerImgName)
 }
}

function toggleDatePicker(eltName,formElt,fhtml,postFunction) {
  var x = formElt.indexOf('.');
  var formName = formElt.substring(0,x);
  var formEltName = formElt.substring(x+1);
  newCalendar(eltName,document.forms[formName].elements[formEltName],fhtml,postFunction);
  toggleVisible(eltName);
}

var calNum=0;
function hwCallender(f,n,d) {
  this.frm=f;
  this.name=n;
  this.date=d;
  if (this.date == "") this.startDate="dd-mm-jjjj"; else this.startDate=d; 
  this.num=calNum;
  calNum++;
  this.disp = function() {
	document.write("<span id=calDuiv"+this.num+" name=calDuiv"+this.num+" style='font-family:Arial, Helvetica, sans-serif; font-size:12px; width:6em; height:10px;background-color:#ffffff; padding:2px; border-bottom:1px inset #ccc;border-right:1px solid #ccc;border-top:2px outset #666;border-left:2px outset #666;'>"+this.startDate+"</span>");
	document.write("<input name='"+this.name+"' value='"+this.date+"' type='hidden'>");
	document.write("&nbsp;<img onmouseup=\"toggleDatePicker('daysOfMonth"+this.num+"','"+this.frm+"."+this.name+"','calDuiv"+this.num+"')\" id=daysOfMonth"+this.num+"Pos name=daysOfMonth"+this.num+"Pos width=16 height=15 src='/_assets/htc/Calendar.gif' align=absmiddle border=0 alt='Selecteer datum'>");
	document.write("<div id='daysOfMonth"+this.num+"' style='position:absolute;'></div>");	
	
  }
  this.toString = function() {
    return document[this.frm][this.name].value;
  }
}
function convdateDMY(S) {
  sd = S.split("-");
  da = new Date();
  da.setYear((1*sd[2]));
  da.setMonth((1*sd[1])-1);
  da.setDate((1*sd[0]));
  da.setHours(00);
  da.setMinutes(00);
  da.setSeconds(00);
  da.setMilliseconds(01);

/*
  alert(S+" "+parseInt(sd[0])+" "+parseInt(sd[1])+" "+parseInt(sd[2]));
  alert(S+" ["+sd[0]+"] ["+sd[1]+"] ["+sd[2]+"]");
  alert(S+" ["+(1*sd[0])+"] ["+(1*sd[1])+"] ["+(1*sd[2])+"]");
*/
  return da;
}



//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id, _x, _y , _xx, _yy) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.
  dragObj._x = -9999;
  dragObj._y = -9999;
  dragObj._xx = -9999;
  dragObj._yy = -9999;

  if (_x) dragObj._x = _x;
  if (_y) dragObj._y = _y;
  if (_xx) dragObj._xx = _xx;
  if (_yy) dragObj._yy = _yy;

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  var posx = (dragObj.elStartLeft + x - dragObj.cursorStartX);
  var posy = (dragObj.elStartTop  + y - dragObj.cursorStartY);
  //dragObj.elNode.innerHTML="posy="+posy+" dragObj.elStartTop="+dragObj.elStartTop+" dragobj._y="+dragObj._y+" dragobj._yy="+dragObj._yy;
  if (dragObj._x > -9999 && posx < dragObj._x) posx = dragObj._x;
  if (dragObj._xx > -9999 && posx > dragObj._xx) posx = dragObj._xx;
  if (dragObj._y > -9999 && posy < dragObj._y) posy = dragObj._y;
  if (dragObj._yy > -9999 && posy > dragObj._yy) posy = dragObj._yy;

  scrollbar_scroll(posy);

  dragObj.elNode.style.left = (posx) + "px";
  dragObj.elNode.style.top  = (posy) + "px";

  //dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  //dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
function setJ(myJSONtext) {
	return eval('(' + myJSONtext + ')');
}


/* firefly variable */
var firefly = new Object();
firefly.data = {};
firefly.data.cnt=0;
firefly.data.getNewId = function() {
	firefly.data.cnt++;
	return "firefly-gen-id-"+firefly.data.cnt;
};

// firfly.user
firefly.user = {"uid":"","loggedin":false};

// firefly.ses
firefly.ses = {"sessionID":""};

//firefly.MATH
firefly.MATH = new Object();
firefly.MATH.toInt = function(S) {
	if (S == "") return 0;
	if (isNaN(S) == true) return 0;
	try{ 
		ret = parseInt(S); 
		return ret;
	} catch (e) {
		return 0;
	}
};
firefly.MATH.toDouble = function(S) {
	if (S == "") return 0;
	if (isNaN(S) == true) return 0;
	if (S.indexOf(",") > -1) S = S.replace(",",".");
	try{ 
		ret = S * 1;
		return ret;
	} catch (e) {
		return 0;
	}
};
firefly.MATH.toCurrency = function(S) {
	if (S == "") return (0).toFixed(2);
	if (isNaN(S) == true) return (0).toFixed(2);
	if (S.indexOf(",") > -1) S = S.replace(",",".");
	try{ 
		ret = S * 1;
		return ret.toFixed(2);
	} catch (e) {
		return (0).toFixed(2);
	}
};
firefly.MATH.boolean2int = function(S) {
  if (S) return 1;
  return 0;
};
firefly.MATH.int2boolean = function(S) {
  if (S && S == 1) return true;
  return false;
};
// firefly.cms
firefly.cms = firefly.cms || {};

// firefly.cms.sifr
firefly.cms.sifr = {};
firefly.cms.sifr.cnt=0;
firefly.cms.sifr.sifr = function(selector,params) {
	params.version='3';
	params.path='/_assets/sifr/3/';
	$j(selector).each(function() {
		var txt = $j(this).text();
		firefly.cms.sifr.cnt++;
		$j(this).html("<span id='random"+firefly.cms.sifr.cnt+"'>"+txt+"</span>");
		$j("#random"+firefly.cms.sifr.cnt).sifr(params);
	});
};

// firefly.popup
firefly.cms.popup = function(params) {
	params = params || {};
	this.id = params.id || firefly.data.getNewId();
	$j("body").append("<div id='"+this.id+"' style='display:none;' class='jqmWindow'> </div>");
};
firefly.cms.popup.prototype.show = function(text, ob) {
	$j("#"+this.id).html(text);
	$j("#"+this.id).jqm().jqmShow();
};
firefly.popup = function(text,params) {
	var obj = new firefly.cms.popup(params);
	if (text) obj.show(text,params);
	return obj;
};

// firefly.map
firefly.map = {};
firefly.map.add = function(MAP,obj) {
	var map = MAP || new Array();
	try{
		if (obj && obj.id) {
			for (var i=0; i < map.length; i++) {
				if (map[i].id == obj.id) {
					map[i] = obj;
					return map;
				}
			}
			map.push(obj);
		} 
	} catch(e) {console.log(e);}
	return map;
}
firefly.map.del = function(MAP,obj) {
	var map = MAP || new Array();
	try{
		if (obj && obj.id) {
			for (var i=0; i < map.length; i++) {
				if (map[i].id == obj.id) {
					map.splice(i,1);
					return map;
				}
			}
		} 
	} catch(e) {console.log(e);}
	return map;
}
firefly.map.append = function(MAP,obj) {
	var map = MAP || new Array();
	try{
		if (obj && obj.id) map.push(obj);
	} catch(e) {console.log(e);}
	return map;
}

// firefely.json
firefly.json = {};
firefly.json.getcookie = function(S, def) {
	var jar = "";
	try {
		jar = $j.cookie(S);
		if (jar) return $j.evalJSON(jar);
	} catch (e) { console.log(e); }
	return def;
};
firefly.json.getcookieArray = function(S) {
	var jar = "";
	try {
		jar = $j.cookie(S);
		if (jar) return $j.evalJSON(jar);
	} catch (e) { console.log(e); }
	return new Array();
};
firefly.json.setcookie = function(S,OB) {
	$j.cookie(S,$j.toJSON(OB));
};
	

// firefely.cookiejar
firefly.cms.cookiejarManager = function() {
};
firefly.cookiejar = {};
firefly.cookiejar.add = function(jarname, ob) {
	var jar = firefly.json.getcookieArray("firefly-cjar-"+jarname);
	console.log("jar add");
	console.log(jar);
	firefly.map.add(jar,ob);
	console.log(jar);
	firefly.json.setcookie("firefly-cjar-"+jarname,jar);
};
firefly.cookiejar.del = function(jarname, ob) {
	var jar = firefly.json.getcookieArray("firefly-cjar-"+jarname);
	console.log("jar del");
	console.log(jar);
	firefly.map.del(jar,ob);
	firefly.json.setcookie("firefly-cjar-"+jarname,jar);
};
firefly.cookiejar.append = function(jarname, ob) {
	var jar = firefly.json.getcookieArray("firefly-cjar-"+jarname);
	console.log("jar append");
	console.log(jar);
	firefly.map.append(jar,ob);
	firefly.json.setcookie("firefly-cjar-"+jarname,jar);
};
firefly.cookiejar.get = function(jarname) {
	var jar = firefly.json.getcookieArray("firefly-cjar-"+jarname);
	console.log("jar get");
	console.log(jar);
	return jar;
};


// $ff and $firefly
var $ff = firefly;
var $firefly = firefly;

