<!--
// .----------------------------------------------------------------------------.
// |.--------------------------------------------------------------------------.|
// || This script is the private property of                                   ||
// ||          Mobilit-e Limited (Company Registration Number: 351410)         ||
// ||          Dublin, Ireland                                                 ||
// ||                                                                          ||
// || No use/reuse is permitted without prior written permission of Mobilit-e. ||
// || Written permission is only valid in the form of a legally binding        ||
// ||      software licence contract with Mobilit-e.                           ||
// ||                                                                          ||
// ||                Copyright: 2002,2003,2004                                 ||
// |'--------------------------------------------------------------------------'|
// '----------------------------------------------------------------------------'
//

var _editor_alias = null;
var Tzv_ie = document.all
   ,Tzv_dom = document.getElementById
   ,Tzv_ns4 = document.layers
   ,Tzv_ua = navigator.userAgent.toLowerCase()
   ,Tzv_v = navigator.appVersion.substring(0,1)
   ,Tzv_vie = parseFloat(navigator.appVersion.split("MSIE")[1])
   ,Tzv_vi = parseInt(navigator.appVersion)
   ,Tzv_n = navigator.appName.toLowerCase();
if (navigator.userAgent.indexOf('Mac')        >= 0) { Tzv_vie = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { Tzv_vie = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { Tzv_vie = 0; }

/* Detect Frames/iFrames Location */
 function zSP_DetectFrameLocation(x)
  {if (window.frames[x]) {return window.frames[x].location;}
   elFrame = document.getElementById(x);
   if (elFrame && elFrame.src) {return elFrame.src;}
  }

/* Copies text to the Clipboard */
 function Tzu_ClipBoardCopy(x)
  {window.clipboardData.setData("text",x);
   alert('Copied to Clipboard - OK');
  }

/* Copies text to the Clipboard */
 function Tzu_ClipBoardCopyHTML(x)
  {var selectedHtml=(x.document.selection.createRange()).htmlText;
     // Set the clipboard with selected HTML, if there is any
     if(selectedHtml!= "")
         window.clipboardData.setData("Text",selectedHtml);
  }

/* Checks if an object exists */
function Tzv_TestIfValidObject(objname)
  {if (null == objname) {return false;}
   if ("undefined" == typeof(objname) ) {return false;}
   return true;
  }

/* hides <select> and <applet> objects (for IE only) */
function TzvhideElement( elmID, overDiv )
  {if( Tzv_ie )
     {for( i = 0; i < document.all.tags( elmID ).length; i++ )
       {obj = document.all.tags( elmID )[i];
        if( !obj || !obj.offsetParent ) { continue; }
        // Find the element's offsetTop and offsetLeft relative to the BODY tag.
        objLeft   = obj.offsetLeft;
        objTop    = obj.offsetTop;
        objParent = obj.offsetParent;
        while( objParent.tagName.toUpperCase() != "BODY" )
          {objLeft  += objParent.offsetLeft;
           objTop   += objParent.offsetTop;
           objParent = objParent.offsetParent;
          }
        objHeight = obj.offsetHeight;
        objWidth = obj.offsetWidth;
        if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft);
          else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop);
          else if ( overDiv.offsetTop >= ( objTop + objHeight ));
          else if ( overDiv.offsetLeft >= ( objLeft + objWidth ));
          else
            {obj.style.visibility = "hidden";}
       }
     }
  }      
 
/*
 * unhides <select> and <applet> objects (for IE only)
 */
function TzvshowElement( elmID )
  {if( Tzv_ie )
      {for( i = 0; i < document.all.tags( elmID ).length; i++ )
        {obj = document.all.tags( elmID )[i];
         if( !obj || !obj.offsetParent ) { continue; }
         obj.style.visibility = "";
        }
      }
  }

function encodeURIComponent(str) 
  {var result = ""
      ,intAsc = 0;
   for (i = 0; i < str.length; i++) 
     { //if (str.charAt(i) == " ") str.charAt(i) = "+";
      intAsc = str.charCodeAt(i);
      if ((intAsc > 47 && intAsc < 58) || (intAsc > 96 && intAsc < 123) || (intAsc > 64 && intAsc < 91))  {result += str.charAt(i);}
       else  {result += "%"; result += decToHex(str.charCodeAt(i), 16);}
     }
   return result;
  }

function decToHex(num, radix)
  {var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9","A", "B", "C", "D", "E", "F");
   var hexString = "";
   while (num >= radix)
     {temp = num % radix;
      num = Math.floor(num / radix);
      hexString += hexVals[temp];
     }
   hexString = hexVals[num] + hexString;
   return hexString;
  }

function basename(path, suffix) 
  {var bpb = path.replace(/^.*[\/\\]/g, '');
    if (typeof(suffix) == 'string' && bpb.substr(bpb.length-suffix.length) == suffix) 
      {bpb = bpb.substr(0, bpb.length-suffix.length);}
    return bpb;
  }

function UploadFile(uploader,storefield)
  {if (uploader.value != '')
     {eval("strResTo = (Tzv_dom)?document.getElementById('" + storefield + "') : Tzv_ie? document.all." + storefield + ": document." + storefield);
      //alert('xxx' + uploader.value + '---' + uploader + '---' + strResTo);
      uploader.form.submit();
      strResTo.value = basename(uploader.value);
     }
   return true;
  }

function StripSlashes (instrg)
  {if (typeof instrg != 'string') return instrg; 
    if (instrg.length > 1)
      {for(qqq=instrg.length-2; qqq>=0; qqq--)
        {if (instrg.substring(qqq,qqq+1) == "\\")
           {hlpchr = instrg.substring(qqq+1,qqq+2); 
            if ((hlpchr == "\'") || (hlpchr == "\"") || (hlpchr == "\\"))
              {helpstrg = instrg.substring(qqq+1,instrg.length); 
               instrg = instrg.substring(0,qqq); 
               instrg = instrg+helpstrg;
              }
           }
        }
      } 
    return instrg; 
  } 

var Tmw_ModalWindow;
 
function Tmw_ShowWindow(Tmw_URL)
  {if (window.showModalDialog)
    {window.showModalDialog(Tmw_URL,null,"dialogWidth=200px;dialogHeight=100px");}
     else
      {window.top.captureEvents (Event.CLICK|Event.FOCUS);
       window.top.onclick=Tmw_IgnoreEvents;
       window.top.onfocus=Tmw_HandleFocus; 
       Tmw_ModalWindow = window.open (Tmw_URL,"ModalChild","dependent=yes,width=200,height=100");
       Tmw_ModalWindow.focus();
      }
  }
 
function Tmw_IgnoreEvents(e)
  {return false;}

function Tmw_HandleFocus()
  {if (Tmw_ModalWindow)
    {if (!Tmw_ModalWindow.closed)
      {Tmw_ModalWindow.focus();}
        else
        {window.top.releaseEvents (Event.CLICK|Event.FOCUS);
         window.top.onclick = "";
        }
    }
   return false
  }

// -----------------------------------------------------------
// Tdi - Draggable iFrame
// -----------------------------------------------------------
var Tdi_dragging=false;
var Tdi_iframeBeingDragged="";
var Tdi_iframeObjects=new Object();
var Tdi_iframeWindows=new Object();
var Tdi_iframeMouseDownLeft = new Object();
var Tdi_iframeMouseDownTop = new Object();
var Tdi_pageMouseDownLeft = new Object();
var Tdi_pageMouseDownTop = new Object();
var Tdi_handles = new Object();
var Tdi_highestZIndex=99;
var Tdi_raiseSelectedIframe=false;
var Tdi_allowDragOffScreen=false;

function Tdi_bringSelectedIframeToTop(val) {
	Tdi_raiseSelectedIframe = val;
	}
	
function Tdi_allowDragOffScreen(val) {
	Tdi_allowDragOffScreen=val;
	}

// Method to be used by iframe content document to specify what object can be draggable in the window
function Tdi_addHandle(o, win) {
	if (arguments.length==2 && win==window) {
		// JS is included in the iframe who has a handle, search up the chain to find a parent window that this one is dragged in
		var p = win;
		while (p=p.parent) {
			if (p.Tdi_addHandle) { p.Tdi_addHandle(o,win,true); return; }
			if (p==win.top) { return; } // Already reached the top, stop looking
			}
		return; // If it reaches here, there is no parent with the addHandle function defined, so this frame can't be dragged!
		}
	var topRef=win;
	var topRefStr = "window";
	while (topRef.parent && topRef.parent!=window) {
		topRef = topRef.parent;
		topRefStr = topRefStr + ".parent";
		}
	// Add handlers to child window
	if (typeof(win.Tdi_mainHandlersAdded)=="undefined" || !win.Tdi_mainHandlersAdded) {
		// This is done in a funky way to make Netscape happy
		with (win) { 
			eval("function OnMouseDownHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.Tdi_begindrag(evt, "+topRefStr+") }");
			eval("document.onmousedown = OnMouseDownHandler;");
			eval("function OnMouseUpHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.Tdi_enddrag(evt, "+topRefStr+") }");
			eval("document.onmouseup = OnMouseUpHandler;");
			eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.Tdi_iframemove(evt, "+topRefStr+") }");
			eval("document.onmousemove = OnMouseMoveHandler;");
			win.Tdi_handlersAdded = true;
			win.Tdi_mainHandlersAdded = true;
			}
		}
	// Add handler to this window
	if (typeof(window.Tdi_handlersAdded)!="undefined" || !window.Tdi_handlersAdded) {
		eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}Tdi_mouseMove(evt, window) }");
		eval("document.onmousemove = OnMouseMoveHandler;");
		window.Tdi_handlersAdded=true;
		}
	o.style.cursor="move";
	var name = Tdi_getIframeId(topRef);
	if (Tdi_handles[name]==null) {
		// Initialize relative positions for mouse down events
		Tdi_handles[name] = new Array();
		Tdi_iframeMouseDownLeft[name] = 0;
		Tdi_iframeMouseDownTop[name] = 0;
		Tdi_pageMouseDownLeft[name] = 0;
		Tdi_pageMouseDownTop[name] = 0;
		}
	Tdi_handles[name][Tdi_handles[name].length] = o;
	}

// Generalized function to get position of an event (like mousedown, mousemove, etc)
function Tdi_getEventPosition(evt) {
	var pos=new Object();
	pos.x=0;
	pos.y=0;
	if (!evt) {
		evt = window.event;
		}
	if (typeof(evt.pageX) == 'number') {
		pos.x = evt.pageX;
		pos.y = evt.pageY;
	}
	else {
		pos.x = evt.clientX;
		pos.y = evt.clientY;
		if (!top.opera) {
			if ((!window.document.compatMode) || (window.document.compatMode == 'BackCompat')) {
				pos.x += window.document.body.scrollLeft;
				pos.y += window.document.body.scrollTop;
			}
			else {
				pos.x += window.document.documentElement.scrollLeft;
				pos.y += window.document.documentElement.scrollTop;
			}
		}
	}
	return pos;
}

// Gets the ID of a frame given a reference to a window object.
// Also stores a reference to the IFRAME object and it's window object
function Tdi_getIframeId(win) {
	// Loop through the window's IFRAME objects looking for a matching window object
	var iframes = document.getElementsByTagName("IFRAME");
	for (var i=0; i<iframes.length; i++) {
		var o = iframes.item(i);
		var w = null;
		if (o.contentWindow) {
			// For IE5.5 and IE6
			w = o.contentWindow;
			}
		else if (window.frames && window.frames[o.id].window) {
			w = window.frames[o.id];
			}
		if (w == win) {
			Tdi_iframeWindows[o.id] = win;
			Tdi_iframeObjects[o.id] = o;
			return o.id; 
			}
		}
	return null;
	}

// Gets the page x, y coordinates of the iframe (or any object)
function Tdi_getObjectXY(o) {
	var res = new Object();
	res.x=0; res.y=0;
	if (o != null) {
		res.x = o.style.left.substring(0,o.style.left.indexOf("px"));
		res.y = o.style.top.substring(0,o.style.top.indexOf("px"));
		}
	return res;
	}

// Function to get the src element clicked for non-IE browsers
function Tdi_getSrcElement(e) {
	var tgt = e.target;
	while (tgt.nodeType != 1) { tgt = tgt.parentNode; }
	return tgt;
	}

// Check if object clicked is a 'handle' - walk up the node tree if required
function Tdi_isHandleClicked(handle, objectClicked) {
	if (handle==objectClicked) { return true; }
	while (objectClicked.parentNode != null) {
		if (objectClicked==handle) {
			return true;
			}
		objectClicked = objectClicked.parentNode;
		}
	return false;
	}
	
// Called when user clicks an iframe that has a handle in it to begin dragging
function Tdi_begindrag(e, win) {
	// Get the IFRAME ID that was clicked on
	var iframename = Tdi_getIframeId(win);
	if (iframename==null) { return; }
	// Make sure that this IFRAME has a handle and that the handle was clicked
	if (Tdi_handles[iframename]==null || Tdi_handles[iframename].length<1) {
		return;
		}
	var isHandle = false;
	var t = e.srcElement || Tdi_getSrcElement(e);
	for (var i=0; i<Tdi_handles[iframename].length; i++) {
		if (Tdi_isHandleClicked(Tdi_handles[iframename][i],t)) {
			isHandle=true;
			break;
			}
		}
	if (!isHandle) { return false; }
	Tdi_iframeBeingDragged = iframename;
	if (Tdi_raiseSelectedIframe) {
		Tdi_iframeObjects[Tdi_iframeBeingDragged].style.zIndex=Tdi_highestZIndex++;
		}
	Tdi_dragging=true;
	var pos=Tdi_getEventPosition(e);
	Tdi_iframeMouseDownLeft[Tdi_iframeBeingDragged] = pos.x;
	Tdi_iframeMouseDownTop[Tdi_iframeBeingDragged] = pos.y;
	var o = Tdi_getObjectXY(Tdi_iframeObjects[Tdi_iframeBeingDragged]);
	Tdi_pageMouseDownLeft[Tdi_iframeBeingDragged] = o.x - 0 + pos.x;
	Tdi_pageMouseDownTop[Tdi_iframeBeingDragged] = o.y -0 + pos.y;
	}

// Called when mouse button is released after dragging an iframe
function Tdi_enddrag(e) {
	Tdi_dragging=false;
	Tdi_iframeBeingDragged="";
	}

// Called when mouse moves in the main window
function Tdi_mouseMove(e) {
	if (Tdi_dragging) {
		var pos = Tdi_getEventPosition(e);
		Tdi_drag(pos.x - Tdi_pageMouseDownLeft[Tdi_iframeBeingDragged] , pos.y - Tdi_pageMouseDownTop[Tdi_iframeBeingDragged]);
		}
	}

// Called when mouse moves in the IFRAME window
function Tdi_iframemove(e) {
	if (Tdi_dragging) {
		var pos = Tdi_getEventPosition(e);
		Tdi_drag(pos.x - Tdi_iframeMouseDownLeft[Tdi_iframeBeingDragged] , pos.y - Tdi_iframeMouseDownTop[Tdi_iframeBeingDragged]);
		}
	}

// Function which actually moves of the iframe object on the screen
function Tdi_drag(x,y) {
	var o = Tdi_getObjectXY(Tdi_iframeObjects[Tdi_iframeBeingDragged]);
	// Don't drag it off the top or left of the screen?
	var newPositionX = o.x-0+x;
	var newPositionY = o.y-0+y;
	if (!Tdi_allowDragOffScreen) {
		if (newPositionX < 0) { newPositionX=0; }
		if (newPositionY < 0) { newPositionY=0; }
		}
	Tdi_iframeObjects[Tdi_iframeBeingDragged].style.left = newPositionX + "px";
	Tdi_iframeObjects[Tdi_iframeBeingDragged].style.top  = newPositionY + "px";
	Tdi_pageMouseDownLeft[Tdi_iframeBeingDragged] += x;
	Tdi_pageMouseDownTop[Tdi_iframeBeingDragged] += y;
	}
//
// --------------- AlertBox function
//

function sphideAlert() 
 {spalertBox = (Tzv_dom) ? document.getElementById("spalertLayer").style : (Tzv_ie)? document.all["spalertLayer"].style : document.layers["spalertLayer"];
  spalertBox.visibility = "hidden";
 }

function spAlert(aTitle,aMessage)
  {spalertBox = (Tzv_dom) ? document.getElementById("spalertLayer").style : (Tzv_ie)? document.all["spalertLayer"].style : document.layers["spalertLayer"];
   document.all.spalertLayer.innerHTML = "<table border=0 width=100% height=100%>" +
         "<tr height=5><td colspan=4 class=spalertTitle>" + " " + aTitle + "</td></tr>" +
         "<tr height=5><td width=5></td></tr>" +
         "<tr><td width=5></td><td width=20 align=left><img src='images/spalert.gif'></td><td align=center class=spalertMessage>" + aMessage + "<BR></td><td width=5></td></tr>" + 
         "<tr height=5><td width=5></td></tr>" +
         "<tr><td width=5></td><td colspan=2 align=center><input type=button value='OK' onClick='sphideAlert()' class=spokButton><BR></td><td width=5></td></tr>" +
         "<tr height=5><td width=5></td></tr></table>";
   thisText = aMessage.length;
   if (aTitle.length > aMessage.length){ thisText = aTitle.length; }

   aWidth = (thisText * 5) + 80;
   aHeight = 100;
   if (aWidth < 150){ aWidth = 200; }
   if (aWidth > 350){ aWidth = 350; }
   if (thisText > 60){ aHeight = 110; }
   if (thisText > 120){ aHeight = 130; }
   if (thisText > 180){ aHeight = 150; }
   if (thisText > 240){ aHeight = 170; }
   if (thisText > 300){ aHeight = 190; }
   if (thisText > 360){ aHeight = 210; }
   if (thisText > 420){ aHeight = 230; }
   if (thisText > 490){ aHeight = 250; }
   if (thisText > 550){ aHeight = 270; }
   if (thisText > 610){ aHeight = 290; }

   spalertBox.width = aWidth;
   spalertBox.height = aHeight;
   spalertBox.left = (document.body.clientWidth - aWidth)/2;
   spalertBox.top = (document.body.clientHeight - aHeight)/2;
   spalertBox.visibility = "visible";
  }
//
// ---------------- Pad function
//
var STR_PAD_LEFT = 1;
var STR_PAD_RIGHT = 2;
var STR_PAD_BOTH = 3;
 
function sppad(str, len, pad, dir) 
  {if (typeof(len) == "undefined") { var len = 0; }
   if (typeof(pad) == "undefined") { var pad = ' '; }
   if (typeof(dir) == "undefined") { var dir = STR_PAD_RIGHT; }
   if (len + 1 >= str.length)
     {switch (dir)
        {case STR_PAD_LEFT:
	   str = Array(len + 1 - str.length).join(pad) + str;
	   break;
  	 case STR_PAD_BOTH:
	   var right = Math.ceil((padlen = len - str.length) / 2);
	   var left = padlen - right;
	   str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
	   break;
 	 default:
	   str = str + Array(len + 1 - str.length).join(pad);
	   break;
 	}
     }  
   return str;
  }

//-->