var dialogw = null;
var dropID = '';
var ctlID ='';
var dopost = true;
var postbackCtl = '';
var eventArg = '';
var returnAction= 'replace';
var delta = 0;
if(navigator.userAgent.indexOf("Firefox") != -1) {delta=10}

function disableEnterKey(e, that, DoTab){
	var key =  window.event ? window.event.keyCode : e.which;
	if (typeof DoTab == 'undefined'){DoTab = "yes"}
	if (key == 13) {
		if(navigator.userAgent.indexOf("Firefox") == -1) {
			if (DoTab == "yes") {
				event.returnValue=true;
				event.keyCode = 9;
				event.cancel = false;
			} else {
				event.returnValue=false;
				event.keyCode = 0;
				event.cancel = true;
			}
		} else {
			correctSubmitHandler(e);
		}
    }
}

function trapOnKeyPress(that) {
		var aevnt = document.createEvent('KeyEvents');
		aevnt.initKeyEvent('keypress',false,false,null,false,false,false,false,0,aevnt.DOM_VK_TAB);
		that.dispatchEvent(aevnt);
		//alert(that.value);
}


 function MoveFocusToNext(that){
	el =document.forms[0].elements;
	for (i = 0; i <= el.length; i++) {
	   if (el[i].id==that.id) {
	 	for (k = i+1; k <= el.length; i++) {
	 		if (el[k].tagName == 'INPUT' || el[k].tagName=='SELECT' || el[k].tagName=='TEXTAREA') {
	 	 	el[k].focus();
	 	 	that.value=that.value + el[k].id
	 	 	return null
	 		}
	 	}   
	   }
	 }
	 return null;
 }

function cascadedrop(drpS, drpD_ID) {
	var elarr = codbib[drpS.value];
	drpD = document.getElementById(drpD_ID);
	drpD.options.length = 0;
	for (k = 0; k < elarr.length; k++) {
		if (elarr[k][0].charCodeAt(0) == 167) {
			drpD.options[k] = new Option(elarr[k][1],elarr[k][0].substring(1), false, true)
		} else {
			drpD.options[k] = new Option(elarr[k][1],elarr[k][0], false, false)
		}
	}
}

function make(e){
		var new_event=document.createEvent("KeyEvents");
		new_event.initKeyEvent("keydown", false, true, null, false, false, false, false, 0x09,0);
		//alert(e.target);
		window.dispatchEvent(new_event);
}
        
function ToggleCheckers(that)
{
    var grid = wgGetGridByElement(that)
    var table = wgGetTableByElement(that);
    var grid = ISGetObject(wgGetGridByElement(that));
    var row = wgGetRowByElement(that);
    for (i=0; i < table.GetRowsCount(); i++){
       table.GetRow(i).Uncheck()
    }
    row.Check()
    table.UpdateUI()
    return true;
}

function HideHeaderChecker()
{
	var grid = ISGetObject(gridID);
	var r = grid.GetRootTable().GetElement(WG40.COLHEADER, WG40.HTMLTABLE).rows[0];
	var rcCell = wgGetCellByName(r, grid.GetRootTable().GetRowCheckerColumn());
	var TmpIH = rcCell.innerHTML.replace("class=DefChkBox", "class=\"DefChkBox\"")
	rcCell.innerHTML = TmpIH.replace("class=\"DefChkBox\"", "class='DefChkBox HIDDEN'")
	return true;
}


function ClientNodeClick(node){
	 var aspxPage = node.Value;
	 p = aspxPage.indexOf("_");
	 var wtitle = aspxPage;
	 if (p>-1) {wtitle = aspxPage.substring(0,p)}
	 var w=window.open('',wtitle + SID,'height=' + (600 + delta) + ',width=' + (800 + delta) + ',status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
     aspxPage = aspxPage.replace("_","&");
     w.location = 'ShowPage.aspx?Page=' + aspxPage
     w.focus();
     return;
}

function NavigateTo(pagename,id,args,w,h,aspx){
     if (typeof w == 'undefined'){w = 800}
     if (typeof h == 'undefined'){h = 600}
     if (typeof aspx == 'undefined'){aspx = 'ShowPage'}
     var wx=window.open('',pagename + SID,'height=' + (h + delta) + ',width=' + (w + delta) +',status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
     if (args !=undefined) { 
		wx.location = aspx + '.aspx?Page=' + pagename + '&ID=' + id + '&' + args;
     } else {
		wx.location = aspx + '.aspx?Page=' + pagename + '&ID=' + id
     }
     wx.focus();
     //setTimeout(wx.SetFocus, 500);
     return;
}


function SetFocus(){
	document.getElementById("txtRenderTime").value = document.getElementById("txtRenderTime").value;
	window.focus()
}

function ShowOPAC(web,id) {
		var wx=window.open('','opac' + SID);
		wx.location = 'opac.aspx?WEB=' + web + '&IDS=' + id;
		wx.focus();
		return;
}

function openWindow(URL, WindowName, status, toolbar, menubar, location, resizable, scrollbars){
   	if (typeof status == 'undefined'){status = "yes"}
	if (typeof toolbar == 'undefined'){toolbar = "yes"}
	if (typeof menubar == 'undefined'){menubar = "yes"}
	if (typeof location == 'undefined'){location = "no"}
	if (typeof resizable == 'undefined'){resizable = "yes"}
	if (typeof scrollbars == 'undefined'){scrollbars = "yes"}
	var wpc=window.open('',WindowName + SID,'height=' + (600 + delta) + ',width=' + (800 + delta) + ',status='+ status + ',toolbar=' + toolbar + ',menubar=' + menubar + ',location=' + location + ',resizable=' + resizable + ',scrollbars='+ scrollbars);
    wpc.location = URL;
	wpc.focus();
    return;
}

function fnTrapKD1(btn){
if (window.event.keyCode == 13)
   { 
     postbackCtl=btn.id;
     __doPostBack(postbackCtl.replace('_', '$'),'TEXTBOX');
     window.event.returnValue=false;
     window.event.keyCode = 0;
     window.event.cancel = true;
   } 
}

function fnTrapKDEVARG(btn, e, EvArg){
	//document.getElementById("__EVENTARGUMENT").value = EvArg;
	document.all("__EVENTARGUMENT").value = EvArg;
	fnTrapKD(btn, e)
}

function fnTrapKD(btn, e){
	var key =  window.event ? window.event.keyCode : e.which;
	if (key == 13)
	{ 
		//alert(document.getElementById("__EVENTARGUMENT").value);
		//if (window.event) {
		if (navigator.userAgent.indexOf("Firefox") == -1) {
			e.returnValue=false;
			e.cancel = true;
			btn.click();
		} else {
			correctSubmitHandler(e);
			btn.click();
		}
	} 
}

function correctSubmitHandler(e)
{
	if (e && e.preventDefault)
		e.preventDefault();
	return false;
}


function DefaultTextbox(that){
	var key =  window.event ? window.event.keyCode : e.which;
	if (key == 13) {
		if (navigator.userAgent.indexOf("Firefox") == -1){
			event.returnValue=false;
			event.cancel = true;
			event.keyCode = 0;
			__doPostBack(that.id.replace('_', '$'),'');
		}  else {
			correctSubmitHandler(e);
			__doPostBack(that.id.replace('_', '$'),'');
		}
	} 
}


function CloseDialogs(){
     if (dialogw && !dialogw.closed) {
		dialogw.close();
     }
     dialogw=null;
}

function ShowImage(ImgPath, tbl, ID)
{
	var wsv = window.open('DlgContainer.aspx?PAGE=ShowDialog&TITLE=Visualizzatore&ImgPath' + ImgPath + '&tbl=' + tbl + '&ID=' + ID,'Visualizzatore' + SID,'height=' + (h + delta) + ',width=' + (w + delta) + ',status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
	wsv.focus();
}

function ShowSNVDialog(aspx, page, title, mode, parm, retCtl, dropCtl, w, h, post, retAction, pbCtl, evArg) {
    dropID = dropCtl;
    ctlDrop = document.getElementById(dropID);
    if (ctlDrop != null) {
    	if (ctlDrop.options[ctlDrop.selectedIndex].value != '') {
			parm = parm + '&SNV=' +  ctlDrop.options[ctlDrop.selectedIndex].value;
       }
    }
    ShowDialog(aspx, page, title, mode, parm, retCtl, w, h, post, retAction, pbCtl, evArg)
}

function ShowCLCDialog(aspx, page, title, mode, parm, txtCtl, w, h, post, retAction, pbCtl, evArg) {
    ctlID = txtCtl;
    ctlTXT = document.getElementById(ctlID);
    if (ctlTXT != null) {
    	if (ctlTXT.value != '') {
			parm = parm + '&BASEVALUE=' +  ctlTXT.value;
       }
    }
    ShowDialog(aspx, page, title, mode, parm, txtCtl, w, h, post, retAction, pbCtl, evArg)
}

function ShowDialog(aspx, page, title, mode, parm, retCtl, w, h, post, retAction, pbCtl, evArg){
	ctlID = retCtl;
	postbackCtl = retCtl;
	eventArg = '';
	if (typeof post != 'undefined'){dopost = post}
	if (typeof retAction != 'undefined'){returnAction = retAction}
	if (typeof w == 'undefined'){w = 800}
	if (typeof h == 'undefined'){h = 600}
	if (typeof pbCtl != 'undefined'){postbackCtl = pbCtl}
	if (typeof evArg != 'undefined'){eventArg = evArg}
	scrollbars = 'no';
	if (title == 'PRINT') {
		scrollbars = 'yes';
	}
	CloseDialogs()
	dialogw = window.open('', page, 'height=' + (h + delta) + ',width=' + (w + delta) + ',scrollbars=' + scrollbars + ',status=yes,resizable=yes,toolbar=no');
	dialogw.location = aspx + '.aspx?page=' + page + '&title=' + title + '&parm=' + parm + '&mode=' + mode;
	dialogw.focus();
}

function SetReturnValue(returnValue){
	var lastCtlval = document.getElementById(window.ctlID).value;
	if (typeof returnValue != 'undefined'){
		switch (returnAction) {
		case 'replace':
			document.getElementById(window.ctlID).value=returnValue;
			break;
		case 'add':
			document.getElementById(window.ctlID).focus();
			lastChar = '';
			txt = getSel();
			if (txt.length > 0 && txt != ' '){;
				if (txt.substring(txt.length, txt.length-1) == ' ') {lastChar = ' ';}
			}
			setSel(returnValue + lastChar);
			break;
		}
	}
	if (dopost && (lastCtlval != document.getElementById(window.ctlID).value)){
		__doPostBack(postbackCtl.replace('_', '$'),window.eventArg);
	}
}

function getSel(){
	if (window.getSelection) {
		el =document.getElementById(ctlID);
		return el.value.substring(el.selectionStart,el.selectionEnd)
	}
	else if (document.getSelection) {return document.getSelection();}
	else if (document.selection) {return document.selection.createRange().text;}
	else {return '';}
}

function setSel(value){
	if (window.getSelection) {
		el =document.getElementById(ctlID);
		el.value = el.value.substring(0, el.selectionStart) + value + el.value.substring(el.selectionEnd, el.value.length); 
	}
	else if (document.getSelection) {}
	else if (document.selection) {
 document.getElementById(ctlID).caretPos = document.selection.createRange().duplicate()
 document.getElementById(ctlID).caretPos.text=value;}
	else {return;}
}

function print_window(){
	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	WebBrowser.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box 
	WebBrowser.outerHTML = '';
}

function ShowHelp(url,w,h)
{
	if (typeof w == 'undefined'){w = 800}
	if (typeof h == 'undefined'){h = 600}
	var wsh = window.open(url,'Help' +SID,'height=' + (h + delta) + ',width=' + (w + delta) + ',status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
	wsh.focus();
}

function SetSearchReturnValue(RetVal)
{
	if (!top.opener.closed){;
		top.opener.SetReturnValue(RetVal);
		top.opener.focus();
	}
	window.close();
}

function SetSearchReturnValue1(RetVal)
{
	parent.SetReturnValue(RetVal);
}

function MsgConfirm(msg)
{
	return confirm(msg)
}

function ToggleDIV(Img,obj1ID,caseType,ifrID){
     objDIV = document.getElementById(obj1ID);
     if (caseType == 'STYLE'){
 	ObjVisibility = objDIV.style.visibility;
 	objstate = 'visible';
     } else {
 	ObjVisibility = objDIV.className;
 	objstate = 'VISIBLE';
     }
     if (ObjVisibility.indexOf(objstate) != -1){
 	if (caseType == 'STYLE'){
     		objDIV.style.visibility = 'hidden';
     		objDIV.style.display = 'none';
 	} else {
     		objDIV.className = objDIV.className.replace('VISIBLE','HIDDEN');
 	}
	 MoveDiv(Img, objDIV, false, caseType, ifrID)
     } else {
	if (caseType == 'STYLE'){
	     objDIV.style.visibility = 'visible';
	     objDIV.style.display = 'block';
     	} else {
  	     objDIV.className = objDIV.className.replace('HIDDEN','VISIBLE');
     	}
     	MoveDiv(Img, objDIV, true, caseType, ifrID)
     }
}

function MoveDiv(Img, dv, show, caseType,ifrID){
     ifr = document.getElementById(ifrID);
     if (show){
 CloseDIV(ifrID, caseType);
 var y = GetElementTop(Img) + Img.offsetHeight
 var x = GetElementLeft(Img) + + Img.offsetWidth - dv.clientWidth
 var id = dv.id
 dv.style.top = y;
 dv.style.left = x;
 ifr.setAttribute('dv', dv.id);
 ifr.style.width = dv.clientWidth;
 ifr.style.height = dv.clientHeight;
 ifr.style.top = dv.style.top;
 ifr.style.left = dv.style.left;
 ifr.style.zIndex = dv.style.zIndex - 1;
 // make the div and the iframe visible
 ifr.style.display  = 'block';
     } else {
 ifr.style.display  = 'none';
     }
}

function CloseDIV(ifrID, caseType){
     ifr = document.getElementById(ifrID);
     if (ifr.style.display == 'block' && ifr.getAttribute('dv') != null){
 lastdv = document.getElementById(ifr.getAttribute('dv'));
 if (caseType == 'STYLE'){
     lastdv.style.visibility = 'hidden';
     lastdv.style.display = 'none';
 } else {
     lastdv.className=lastdv.className.replace('VISIBLE','HIDDEN')
 }
 ifr.setAttribute('dv', null);
 ifr.style.display  = 'none';
     }
}

function GetElementLeft(eElement){
	if (!eElement && this) {
   		eElement = this;
	}
	var nLeftPos = eElement.offsetLeft;
	var eParElement = eElement.offsetParent;
	while (eParElement != null){
		nLeftPos += eParElement.offsetLeft;
		eParElement = eParElement.offsetParent;
	}
	return nLeftPos;
}

function GetElementTop(eElement){
	if (!eElement && this) {
		eElement = this;
	}
	var nTopPos = eElement.offsetTop;
	var eParElement = eElement.offsetParent;
	while (eParElement != null){
		nTopPos += eParElement.offsetTop;
		eParElement = eParElement.offsetParent;
	}
	return nTopPos;
}

function ToggleState(ImgID,obj1ID,obj2ID,ImgExpandSrc,ImgCollapseSrc,TooltipExpand,TooltipCollapse,caseType){
if (caseType == 'STYLE'){
     ObjExpanded = document.getElementById(obj1ID).style.visibility;
     objstate = 'visible';
} else {
     ObjExpanded = document.getElementById(obj1ID).className;
     objstate = 'VISIBLE';
}
img=document.getElementById(ImgID);
Obj1=document.getElementById(obj1ID);
Obj2=document.getElementById(obj2ID);
if (ObjExpanded.indexOf(objstate) != -1){
     if (caseType == 'STYLE'){
     Obj1.style.visibility = 'hidden';
     Obj2.style.visibility = 'hidden';
     Obj1.style.display = 'none';
     Obj2.style.display = 'none';
     } else {
 Obj1.className = Obj1.className.replace('VISIBLE', 'HIDDEN');
 Obj2.className = Obj2.className.replace('VISIBLE', 'HIDDEN');
     }
     img.src= ImgExpandSrc;
     img.title=TooltipExpand;
} else {
     if (caseType == 'STYLE'){
     Obj1.style.visibility = 'visible';
     Obj2.style.visibility = 'visible';
     Obj1.style.display = 'block';
     Obj2.style.display = 'block';
     } else {
 Obj1.className = Obj1.className.replace('HIDDEN', 'VISIBLE');
 Obj2.className = Obj2.className.replace('HIDDEN', 'VISIBLE');
     }
     img.src= ImgCollapseSrc;
     img.title=TooltipCollapse;
}
}

function ToggleStateNL(ImgID,obj1ID,obj2ID,ImgExpandSrc,ImgCollapseSrc,TooltipExpand,TooltipCollapse,caseType){
if (caseType == 'STYLE'){
     ObjExpanded = document.getElementById(obj2ID).style.visibility;
     objstate = 'visible';
} else {
     //ObjExpanded = document.getElementById(obj1ID).className;
     
     //objstate = 'VISIBLE';
}
img=document.getElementById(ImgID);
if (ObjExpanded == objstate){
     if (caseType == 'STYLE'){
     var wcbo = wcGetComboById(obj1ID);
     wcbo.FrameObj.style.visibility = 'visible';
     wcbo.FrameObj.style.display = 'block';
     document.getElementById(obj2ID).style.visibility = 'hidden';
     document.getElementById(obj2ID).style.display = 'none';
     document.getElementById(obj2ID).value = '';
     } else {
 //document.getElementById(obj1ID).className = 'HIDDEN';
 //document.getElementById(obj2ID).className = 'HIDDEN';
     }
     img.src= ImgExpandSrc;
     img.title=TooltipExpand;
} else {
     if (caseType == 'STYLE'){
     var wcbo = wcGetComboById(obj1ID);
     wcbo.FrameObj.style.visibility = 'hidden';
     wcbo.FrameObj.style.display = 'none';
     wcbo.Value = '';
     document.getElementById(obj2ID).style.visibility = 'visible';
     document.getElementById(obj2ID).style.display = 'block';
     } else {
 //document.getElementById(obj1ID).className = 'VISIBLE';
 //document.getElementById(obj2ID).className = 'VISIBLE';
     }
     img.src= ImgCollapseSrc;
     img.title=TooltipCollapse;
}
}


// ***** Variables *************************************************************

var popup_dragging = false;
var popup_target;
var popup_bkg;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;


// ***** popup_mousedown *******************************************************

function popup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  popup_mouseposX = ie ? window.event.clientX : e.clientX;
  popup_mouseposY = ie ? window.event.clientY : e.clientY;
}


// ***** popup_mousedown_window ************************************************

function popup_mousedown_window(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  popup_dragging = true;
  popup_target   = this['target'];
  popup_mouseX   = ie ? window.event.clientX : e.clientX;
  popup_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       popup_oldfunction = document.onselectstart;
  else popup_oldfunction = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}


// ***** popup_mousemove *******************************************************

function popup_mousemove(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  var mouseX  = ie ? window.event.clientX : e.clientX;
  var mouseY  = ie ? window.event.clientY : e.clientY;

  if (!popup_dragging) return;

  element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-popup_mouseY)+'px';

  popup_mouseX = ie ? window.event.clientX : e.clientX;
  popup_mouseY = ie ? window.event.clientY : e.clientY;
}

// ***** popup_mouseup *********************************************************

function popup_mouseup(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);

  if (!popup_dragging) return;

  popup_dragging = false;

  if (ie)
       document.onselectstart = popup_oldfunction;
  else document.onmousedown   = popup_oldfunction;
}

// ***** popup_exit ************************************************************

function popup_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);
  popup_mouseup(e);
  element.style.display = 'none';
  popup_bkg.style.display = 'none';
}


// ***** popup_show ************************************************************

function popup_show(id, drag_id, exit_id, bkg_id, position, x, y, position_id)
{
  var element      = document.getElementById(id);
  var drag_element = document.getElementById(drag_id);
  var exit_element = document.getElementById(exit_id);
  var bkg_element = document.getElementById(bkg_id);
  popup_bkg = bkg_element;
	
  var width        = window.innerWidth  ? window.innerWidth  : document.body.clientWidth;
  var height       = window.innerHeight ? window.innerHeight : document.body.clientHeight;

  //bkg_element.style.position = "absolute";
  bkg_element.style.display  = "block";
  bkg_element.style.width = width + 'px';
  bkg_element.style.height = height + 'px';
  //bkg_element.style.left = '0px';
  //bkg_element.style.top  ='0px';
	
  element.style.position = "absolute";
  element.style.display  = "block";

  if (position == "element" || position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  if (position == "mouse")
  {
    element.style.left = (document.documentElement.scrollLeft+popup_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +popup_mouseposY+y)+'px';
  }

  if (position == "screen-top-left")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(height-element.clientHeight)/2+y)+'px';
  }

  if (position == "screen-bottom-right")
  {
	
    element.style.left = (document.documentElement.scrollLeft+(width -element.clientWidth )  +x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(height-element.clientHeight)  +y)+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = popup_mousedown_window;

  exit_element.onclick     = popup_exit;
}


function NoBIDAlert(that, alertmsg) {
	that.checked=false;
	alert(alertmsg);
}

function SetINvisibility (dropCrtID, nbxID, txtID) {
 dropCRT = document.getElementById(dropCrtID);
 nbx = document.getElementById(nbxID);
 txt = document.getElementById(txtID);
 if (dropCRT.value =="{0} IN ({1})") {
	nbx.className += " HIDDEN"
	txt.className = txt.className.replace(' HIDDEN', '');
  } else {
	txt.className += " HIDDEN"
	nbx.className = nbx.className.replace(' HIDDEN', '');
  }
}


// ***** grid events *********************************************************
function SelRow(that) {
	var grid=ISGetObject("ctlMain_WebGrid1");
	var row = grid.RootTable.GetRow(that.parentNode.recordIndex); 
	if (row != null) {
		//var row = that.parent.row
		var cells = row.GetCells();
		row.Select();
		return true;
	}
	//row.BeginEdit()
}



// ***** Attach Events *********************************************************

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent   ('onmousedown', popup_mousedown);
else document.addEventListener('mousedown', popup_mousedown, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent   ('onmousemove', popup_mousemove);
else document.addEventListener('mousemove', popup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent   ('onmouseup', popup_mouseup);
else document.addEventListener('mouseup', popup_mouseup, false);



