var sPrevFGColor,sPrevBGColor,sLastMenu,blInMenu;
var mFrontPageImageTimeoutID,mPauseFrontPage,mNextFrontPageIndex,mLastHighlightProductTypeID;
var browser = new Browser();
var objDrag,lPageDragStartX,lPageDragStartY,lObjDragStartX,lObjDragStartY;
var divImgZoom,imgZoom,sZoomID;

function UpdateQueryParam(URL, Key, Value) {
   var sVals, sKV, sK, sV, sVal, sURL, sParms, sNewURL;
   var i, x, blFound;
   var sSRC = URL;

   x = sSRC.indexOf("?");
   sURL = sSRC.substr(0, x);
   sParms = sSRC.substr(x + 1);
   sVals = sParms.split("&");

   sNewURL = sURL;
   blFound = false;

   for (i = 1; i <= sVals.length; i++) {
      sKV = sVals[i - 1].split("=");
      sK = sKV[0];
      sV = sKV[1];

      if (sK == Key) {
         sV = Value;
         blFound = true;
      }

      if (i == 1)
         sNewURL = sNewURL + "?";
      else
         sNewURL = sNewURL + "&";

      sNewURL = sNewURL + sK + "=" + sV;
   }

   if (!blFound)
      sNewURL = sNewURL + "&" + Key + "=" + Value;

   return sNewURL;
}

function MainMenuShow(objA,MenuName,IfDown)
	{
	var mnu;
	var td;
	var iLeft,iTop;
	var sLeft,sTop;

	if (sLastMenu==null)
		sLastMenu='';

	if (IfDown==1 && sLastMenu=='')
		return(0);

	if (sLastMenu!='')
		{
		mnu=document.getElementById(sLastMenu);
		mnu.style.visibility='hidden';
		}
	td=objA.parentElement || objA.parentNode;
	mnu=document.getElementById(MenuName);
	
	if (mnu.style.display=='none')
		mnu.style.display='';
		
	if (mnu.filters)
		{
		//mnu.filters(0).Apply();
		mnu.style.visibility='visible';
		//mnu.filters(0).Play();
		}
	else
		mnu.style.visibility='visible';
	
	iLeft=absLeft(td);
	iTop=absTop(td)+td.clientHeight-2;
	sLeft=iLeft.toString()+'px';
	sTop=iTop.toString()+'px';
	
	mnu.style.left=sLeft;
	mnu.style.top=sTop;
	
	blInMenu=true;
	sLastMenu=MenuName;
	
	}
	
function MainMenuHide(ev,MenuName)
	{
	
	var mnu,sMenu;
	var obj;
	var blHide;
	
	obj=ev.toElement;
	if (obj==null)
		obj=ev.relatedTarget;
	
	sMenu=MenuName;
	blHide=true;
	if (obj!=null)
		{
		if (obj.id==MenuName)
			blHide=false;
		}
		
	if (blHide==true)
		{
		if (sMenu=='*')
			sMenu=sLastMenu;
			
		sLastMenu='';
		mnu=document.getElementById(sMenu);
		if (mnu!=null)
			{
			if (contains(mnu,obj))
				mnu.style.visibility='visible';
			else
				{
				if (mnu.filters)
					{
					//mnu.filters(0).Apply();
					mnu.style.visibility='hidden';
					//mnu.filters(0).Play();
					}
				else
					mnu.style.visibility='hidden';
				//* HideTags("SELECT",false);
				}
			}
		}
	}

function addBookmark(url, title)
{

   if (window.sidebar) // firefox
      window.sidebar.addPanel(title, url, "");
   else if (window.opera && window.print) // opera
      alert("Sorry, Opera does not support this function.  Please add your bookmark manually.");
   else if (document.all) // ie
      window.external.AddFavorite(url, title);
   else
      alert("Sorry, your browser does not support this function.  Please add your bookmark manually.");
      
}

function DivIFrame(div)
{
	var ifr;
	var sHTML;
	
	ifr=document.getElementById("ifrDiv");

	if (ifr==null)
		{
		sHTML="<IFRAME style='position:absolute;z-index:4;' src='/blank.htm' frameBorder='0' scrolling='no' id='ifrDiv'/>";
		div.insertAdjacentHTML("afterEnd",sHTML);
		ifr=document.getElementById("ifrDiv");
		}
		
	ifr.style.top=div.style.top;
	ifr.style.left=div.style.left
	ifr.style.width=div.offsetWidth;
	ifr.style.height=div.offsetHeight;
	ifr.style.visibility='visible';
}


function contains(a, b)
{
	// we climb through b parents
	// till we find a
 	while(b && (a!=b) && (b!=null))
		b = b.parentNode;
	return a == b;
}

function CancelKeyCode(e,KeyCode)
{
	var iKey;
	
	if (window.event) // IE
		iKey=e.keyCode;
	else if(e.which) // Netscape/Firefox/Opera
		iKey=e.which;

	if (iKey==KeyCode)
		return false;
	else
		return true;
}

function WriteBrowser()
{
   var sBrowser = navigator.appName;
   var lVersion = navigator.appVersion;

   document.write("Browser=" + sBrowser + ", Version=" + lVersion + "<br>");
}

function HideSelects(Hide)
{
   var i;
   var blSupported;
   var sVersion = navigator.appVersion;

   blSupported = true;
   if ((sVersion.indexOf("MSIE 6") > 0) || (sVersion.indexOf("MSIE 5") > 0))
      blSupported = false;

   if (!blSupported)
      {
      var el = document.getElementsByTagName("select");
      for (i = 0; i < el.length; i++)
         {
         if (Hide)
            el[i].style.visibility = 'hidden';
         else
            el[i].style.visibility = 'visible';
         }
      }
}

function HideTags(Tag,Hide)  
	{
	var i;
	var obj;

	if (document.forms.length>0)
		{
		obj=document.forms(0).tags(Tag);
		if (obj!=null)
			{
			for (i=0; i<obj.length; i++)
				{
				if (Hide)
      			obj[i].style.visibility='hidden';
      		else
      			obj[i].style.visibility='visible';
      		}
			}
		}
	}

function SetListIndex(ID,Value)
{
	var i;
	var lst=document.getElementById(ID);
	
	if (lst!=null)
		{
		for (i=0;i<lst.length; i++)
			{
			if (lst.options[i].value==Value)
				{
				lst.selectedIndex=i;
				}
			}
		}
}

function DoSearch()
{
	var sFind=document.getElementById("txtSearch").value;
	
	if (sFind=="")
		alert("Enter search criteria in search box and click Find");
	else
		window.location.href="/search.asp?find=" + sFind;
}

function absLeft(obj)
{
	var i=0;
	if (obj.offsetParent)
		{
		do
			{
			i+=obj.offsetLeft;
			}
		while (obj=obj.offsetParent);
		}
	return(i);
}

function absTop(obj)
{
	var i=0;
	if (obj.offsetParent)
		{
		do
			{
			i+=obj.offsetTop;
			}
		while (obj=obj.offsetParent);
		}
	return(i);
}

function absLeft2(oNode)
{
   var oCurrentNode=oNode;
   var iLeft=0;
   
	while(oCurrentNode.tagName!="BODY")
		{
		iLeft+=oCurrentNode.offsetLeft;
		oCurrentNode=oCurrentNode.offsetParent;
		}
   return(iLeft);
}

function absTop2(oNode)
{
   var oCurrentNode=oNode;
   var iTop=0;
   
	while(oCurrentNode.tagName!="BODY")
		{
		iTop+=oCurrentNode.offsetTop;
		oCurrentNode=oCurrentNode.offsetParent;
		}
   return(iTop);
}

function NoRightClick(e) {

   var iButton = 0;
   var dt = new Date();
   var sMsg = "Copyright © " + dt.getFullYear() + " Picture Me Perfect.  All rights reserved.";
	var ev = e || window.event;
	var blRet = true;
	
	if (ev) {
	   if (ev.button) {
	      iButton = ev.button;
	   }
	}

	if (iButton != 0 && iButton != 1) {
	   if (ev.cancelBubble)
	      ev.cancelBubble = true;
	   if (ev.returnValue)
	      ev.returnValue = false;
	   
	   alert(sMsg);
	   blRet = false;
	}

	return blRet;
}

function NewWindow(Name,URL,Width,Height,Sizable,Scrollable)
	{
	var iW,iH;
	var sOptions;
	
	iW=Width;
	iH=Height;
	if (iW==0) iW=100;
	if (iH==0) iH=100;
		
	sName=Name;
	
	sOptions="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + Scrollable + ",resizable=" + Sizable
	if (iW!=-1)
		sOptions+=",width=" + iW 
	if (iH!=-1)
		sOptions+=",height=" + iH
	
	win = window.open(URL,sName,sOptions);
	}
	
function ShowProduct(ProductID,Display)
	{
	win = window.open("product.asp?id=" + ProductID + "&display=" + Display, "pmpproduct", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500");
	}
function ShowHelp(Topic)
	{
	win = window.open("/help.asp?topic=" + Topic, "pmphelp", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=630,height=360");
	}
function ShowContactUs()
	{
	win = window.open("/contactus.asp", "pmpcontact", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=435,height=435");
	}
function ShowFontHelp(FontName,ProductCode)
	{
	win = window.open("/font.asp?fontname=" + FontName + "&productcode=" + ProductCode, "win", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=680,height=410");
	}
function ShowWording(Cat,CallingControl)
	{
	win = window.open("/help.asp?topic=28&tb=" + Cat + "&callingcontrol=" + CallingControl, "win", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=630,height=360");
	}
function ShowClipart(Cat,CallingControl)
	{
	win = window.open("/help.asp?topic=29&tb=" + Cat + "&callingcontrol=" + CallingControl, "win", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=630,height=360");
	}
function SetButton(img,file,color)
	{
	var th;
	
	if (file!="")
		img.src=file;
	if (color!="")
		{
		th=img.parentElement.parentElement;
		th.bgColor=color;
		}
	}
function ShowCallOut(Text)
{

	var iT;
	var iL;
	
	tdCallOut.innerHTML="<small>" + Text + "</small>";
	iT=document.body.scrollTop+window.event.clientY-window.event.offsetY;
	iL=document.body.scrollLeft+window.event.clientX-window.event.offsetX+window.event.srcElement.getAttribute("width");

	divCallOut.style.top=iT;
	divCallOut.style.left=iL;
	divCallOut.style.display="";
}

function HideCallOut(ID)
{
	divCallOut.style.display="none";
}
function ShowMenu(MenuName)
	{
	var mnu;
	
	mnu=document.getElementById(MenuName);
	mnu.style.top=document.body.scrollTop+(window.event.clientY-window.event.offsetY)+32;
	mnu.style.left=document.body.scrollLeft+window.event.clientX-window.event.offsetX;	
	if (mnu.style.display='')
		mnu.style.display='none';
	else
		mnu.style.display='';
	return(0);
	}
function HideMenu(MenuName)
	{
	var mnu;
	
	mnu=document.getElementById(MenuName);
	if (mnu!=null)
		{
		if (mnu.contains(window.event.toElement))
			mnu.style.display='';
		else
			{
			mnu.style.display='none';
			}
		}
	}
function HighlightCell(IfTag,Highlight)
{
	var obj;
	var blLoop;
	
	obj=window.event.srcElement;
	if (obj.tagName==IfTag || IfTag=='')
		{
		if (obj.tagName!="TD" && obj.tagName!="TH")
			{
			blLoop=0;
			while (blLoop==0)
				{
				obj=obj.parentElement;
				if (obj.tagName!="TD" || obj.tagName!="TH")
					blLoop=1;
				}
			}
			
		if (Highlight==1)
			{
			sPrevFGColor=window.event.srcElement.style.color;
			sPrevBGColor=obj.style.backgroundColor;
			window.event.srcElement.style.color="white";
			obj.style.backgroundColor="#6265ec";
			}
		else
			{
			window.event.srcElement.style.color=sPrevFGColor;
			obj.style.backgroundColor=sPrevBGColor;
			}
		}
}

function ShowSiteMapRows(rowid)
{
	var tbl=document.getElementById("tblSiteMap");
	var rows=tbl.rows(rowid);

	for (i=0;i<=rows.length-1;i++)
		{
		if (rows[i].style.display=="")
			rows[i].style.display="none";
		else
			rows[i].style.display="";
		}
}
function ShowFrontPageImage(ProductTypeID,Pause)
{
	var sURL;
	var sText,sVals,sTag;
	var i,iVals,iIndex,lID;
	var img=document.getElementById("imgFrontPage");
	var atag=document.getElementById("aFrontPage");
	var txt=document.getElementById("ProductTypeIDs");
	
	if (mFrontPageImageTimeoutID==null)
		mFrontPageImageTimeoutID=window.setInterval("ShowFrontPageImage(null,null)", 5000);
	if (mPauseFrontPage==null)
		mPauseFrontPage=0;
		
	if (Pause!=null)
		mPauseFrontPage=Pause;
	
	sText=txt.value;
	sVals=sText.split(",");
	iVals=sVals.length-1;
	
	if (mPauseFrontPage==0 && ProductTypeID==null)
		{
		if (mNextFrontPageIndex==null)
			iIndex=0;
		else
			iIndex=mNextFrontPageIndex;
		
		lID=sVals[iIndex];
		
		if (iIndex==iVals)
			mNextFrontPageIndex=0;
		else
			mNextFrontPageIndex=iIndex+1;
		}
	else
		lID=ProductTypeID;
	
	if (lID!=null)
		{
		if (img!=null)
			{
			sURL="getimage.asp?producttype=" + lID + "&max=380";
			
			if (img.filters)
				img.filters(0).Apply();
			img.src=sURL;
			if (img.filters)
				img.filters(0).Play();
			}
		if (atag!=null)
			{
			atag.href="products.asp?tb=" + lID;
			}
		}
}
function StopFrontPageImage()
{
	if (window.clearTimeout)
		{
		if (mFrontPageImageTimeoutID!=null)
			window.clearTimeout(mFrontPageImageTimeoutID);
		mFrontPageImageTimeoutID=null;
		}
}

function ResizeForm()
	{
	var ih;
	
	ih=tblMain.scrollHeight+80;
	if (ih>(window.screen.availHeight-100))
		ih=window.screen.availHeight-100
	
	window.resizeTo(tblMain.scrollWidth+30,ih+2)
	}

function HighlightProductType(ProductTypeID,ColorCode)
{

	var td,atag;

	if (mLastHighlightProductTypeID!=null)
		{
		td=document.getElementById("tdProductTypeID-" + mLastHighlightProductTypeID.toString());
		if (td!=null)
			td.style.backgroundColor="";
		atag=document.getElementById("aProductTypeID-" + mLastHighlightProductTypeID.toString());
		if (atag!=null)
			atag.style.color="";
		}
		
	td=document.getElementById("tdProductTypeID-" + ProductTypeID.toString());
	if (td!=null)
		td.style.backgroundColor=ColorCode;
	atag=document.getElementById("aProductTypeID-" + ProductTypeID.toString());
	if (atag!=null)
		atag.style.color="white";
		
	mLastHighlightProductTypeID=ProductTypeID;
}

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;
		}
}

function DragDown(e,ID) {
	var ev=window.event||e;
	
	if (ev.button==1 || ev.button==0) {
		objDrag=document.getElementById(ID);

		lDragObjStartX = absLeft(objDrag);
		lDragObjStartY = absTop(objDrag);

		if (document.attachEvent) {
			lDragPageStartX=ev.clientX+document.documentElement.scrollLeft+document.body.scrollLeft;
			lDragPageStartY=ev.clientY+document.documentElement.scrollTop+document.body.scrollTop;
			document.attachEvent("onmousemove",DragMove);
			document.attachEvent("onmouseup",DragUp);
			ev.cancelBubble=true;
			ev.returnValue = false;
		}
		else {
		   lDragPageStartX = ev.clientX + window.scrollX;
		   lDragPageStartY = ev.clientY + window.scrollY;
			document.addEventListener("mousemove", DragMove, true);
			document.addEventListener("mouseup", DragUp, true);
		}
	}
}

function DragMove(e) {
	var x,y;
	var ev = window.event || e;

	if (document.attachEvent) {
      x = ev.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
      y = ev.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
	else {
		x=ev.clientX+window.scrollX;
		y = ev.clientY + window.scrollY;
	}

	x=lDragObjStartX-(lDragPageStartX-x);
	y=lDragObjStartY-(lDragPageStartY-y);
	
	objDrag.style.left=x+"px";
	objDrag.style.top=y+"px";

	if (document.attachEvent) {
		window.event.cancelBubble=true;
		window.event.returnValue = false;
	}
	else
		ev.preventDefault();
}

function DragUp(e) {
   if (document.attachEvent) {
		document.detachEvent("onmousemove",DragMove);
		document.detachEvent("onmouseup",DragUp);
	}
	else {
		document.removeEventListener("mousemove",DragMove,true);
		document.removeEventListener("mouseup",DragUp,true);
	}
}
function DeleteUserPhoto(Location, LocationID, ClickType, FileName)
{
	var obj;
	var sURL,sRet,sFileName;
	var div;
	
	sFileName=unescape(FileName);
	var blDelete = window.confirm("Are you sure you want to delete " + sFileName + "?");
	
	if (blDelete)
		{
		div=document.getElementById("divUserPhotos")
		sURL = "/ajaxdata.asp?type=userphotos&location=" + Location + "&locationid=" + LocationID + "&clicktype=" + ClickType + "&action=delete&file=" + sFileName;
		
		if (window.XMLHttpRequest)
			obj=new XMLHttpRequest();
		else if (window.ActiveXObject)
			obj=new ActiveXObject("Microsoft.XMLHTTP");
		
		obj.open("GET",sURL,false);
		obj.send(null);
		sRet=obj.responseText;
		div.innerHTML=sRet;
		}
}

function DeleteUserPhotoX(Location, LocationID, FileName) {
   var obj;
   var sURL, sRet, sFileName;
   var div;

   sFileName = unescape(FileName);
   var blDelete = window.confirm("Are you sure you want to delete " + sFileName + "?");

   if (blDelete) {
      div = document.getElementById("divUserPhotosX")
      sURL = "/ajax.aspx?type=userphotos&location=" + Location + "&locationid=" + LocationID + "&action=delete" + "&filename=" + FileName;

      if (window.XMLHttpRequest)
         obj = new XMLHttpRequest();
      else if (window.ActiveXObject)
         obj = new ActiveXObject("Microsoft.XMLHTTP");

      obj.open("GET", sURL, false);
      obj.send(null);
      sRet = obj.responseText;
      div.innerHTML = sRet;
   }
}

function RenameUserPhoto(Location,LocationID,ClickType,FileName)
{
	var obj;
	var sURL,sRet,sFileName;
	var div;
	
	sFileName=FileName;
	var sNewName = window.prompt("Enter the new name for the photo, or click Cancel.",sFileName);
	
	if (sNewName!=null)
		{
		div=document.getElementById("divUserPhotos")
		sURL = "/ajaxdata.asp?type=userphotos&location=" + Location + "&locationid=" + LocationID + "&clicktype=" + ClickType + "&action=rename&file=" + escape(sFileName) + "&newname=" + escape(sNewName);
		
		if (window.XMLHttpRequest)
			obj=new XMLHttpRequest();
		else if (window.ActiveXObject)
			obj=new ActiveXObject("Microsoft.XMLHTTP");
		
		obj.open("GET",sURL,false);
		obj.send(null);
		sRet=obj.responseText;
		div.innerHTML=sRet;
		}
}

function RenameUserPhotoX(Location, LocationID, FileName) {
   var obj;
   var sURL, sRet, sFileName;
   var div;

   sFileName = FileName;
   var sNewName = window.prompt("Enter the new name for the photo, or click Cancel.", sFileName);

   if (sNewName != null) {
      div = document.getElementById("divUserPhotos")
      sURL = "/ajax.aspx?type=userphotos&location=" + Location + "&locationid=" + LocationID + "&action=delete" + "&filename=" + FileName + "&newfilename=" + sNewName;
      
      if (window.XMLHttpRequest)
         obj = new XMLHttpRequest();
      else if (window.ActiveXObject)
         obj = new ActiveXObject("Microsoft.XMLHTTP");

      obj.open("GET", sURL, false);
      obj.send(null);
      sRet = obj.responseText;
      div.innerHTML = sRet;
   }
}

function ZoomImageHide()
{
	if (divImgZoom!=null)
		{
		divImgZoom.style.visibility='hidden';
		}
}

function ZoomImage(e,img)
{
	var iZoom=2;
	var iSize=200;
	var ev;
	var x,y,iL,iT,iImgL,iImgT,iScrollTop,iScrollLeft;
	var sImgL,sImgT;

	if (divImgZoom == null) {
	   divImgZoom = document.createElement("DIV");
	   divImgZoom.id = "divImgZoom";
	   divImgZoom.style.position = "absolute";
	   divImgZoom.style.overflow = "hidden";
	   divImgZoom.style.border = "1px solid #c0c0c0";
	   divImgZoom.style.backgroundColor = "#ffffff";
	   divImgZoom.style.width = iSize;
	   divImgZoom.style.height = iSize;
	   document.body.appendChild(divImgZoom);
	}
	if (imgZoom == null) {
	   imgZoom = document.createElement("IMG");
	   imgZoom.id = "imgZoom";
	   divImgZoom.appendChild(imgZoom);
	}

	iScrollTop = 0;
	iScrollLeft = 0;
	if (document.documentElement) {
	   iScrollTop = document.documentElement.scrollTop;
	   iScrollLeft = document.documentElement.scrollLeft;
	}
	else if (document.pageYOffset) {
	   iScrollTop = document.pageYOffset;
	   iScrollLeft = document.pageXOffset;
	}
	else if (document.body.scrollTop) {
	   iScrollTop = document.body.scrollTop;
	   iScrollLeft = document.body.scrollLeft;
	}
   
	ev = window.event || e;
	x = ev.clientX - absLeft(img) + iScrollLeft;
	y = ev.clientY - absTop(img) + iScrollTop;
	
	iL = absLeft(img) - iSize;
	iT = absTop(img);
	
	divImgZoom.style.left=iL.toString() + "px";
	divImgZoom.style.top=iT.toString() + "px";
	
	imgZoom.src=img.src;
	imgZoom.width=img.width*iZoom;
	imgZoom.style.position="absolute";
	iImgL=((x*iZoom)-(iSize/2));
	iImgT=((y*iZoom)-(iSize/2));
	if (iImgL<0)
		{
		iImgL=iImgL*-1;
		sImgL=iImgL.toString() + "px";
		}
	else
		sImgL="-" + iImgL.toString() + "px";
		
	if (iImgT<0)
		{
		iImgT=iImgT*-1;
		sImgT=iImgT.toString() + "px";
		}
	else
		sImgT="-" + iImgT.toString() + "px";
		
	imgZoom.style.left=sImgL;
	imgZoom.style.top=sImgT;
	
	divImgZoom.style.visibility='visible';
	
}
function EndZoom()
{
	sZoomID="";
}
function StartZoom(img)
{
	sZoomID=img.id;
}
function ZoomImageNew(e)
{
	if (sZoomID=="")
		return;
		
	var iZoom=2;
	var iSize=200;
	var ev=window.event||e;
	var x=ev.clientX;
	var y=ev.clientY;
	var iL,iT;
	var iImgL,iImgT;
	var sImgL,sImgT;
	var img=document.getElementById(sZoomID);
	
	if (divImgZoom==null)
		{
		divImgZoom=document.createElement("DIV");
		divImgZoom.id="divImgZoom";
		divImgZoom.style.position="absolute";
		divImgZoom.style.overflow="hidden";
		divImgZoom.style.border="1px solid #c0c0c0";
		divImgZoom.style.backgroundColor="#ffffff";
		divImgZoom.style.width=iSize;
		divImgZoom.style.height=iSize;
		document.body.appendChild(divImgZoom);
		}
	if (imgZoom==null)
		{
		imgZoom=document.createElement("IMG");
		imgZoom.id="imgZoom";
		divImgZoom.appendChild(imgZoom);
		}
			
	iL=x-(iSize/2);
	iT=y-(iSize/2);
	divImgZoom.style.left=iL.toString() + "px";
	divImgZoom.style.top=iT.toString() + "px";
	
	imgZoom.src=img.src;
	imgZoom.width=img.width*iZoom;
	imgZoom.style.position="absolute";
	iImgL=((x*iZoom)-(iSize/2));
	iImgT=((y*iZoom)-(iSize/2));
	if (iImgL<0)
		{
		iImgL=iImgL*-1;
		sImgL=iImgL.toString() + "px";
		}
	else
		sImgL="-" + iImgL.toString() + "px";
		
	if (iImgT<0)
		{
		iImgT=iImgT*-1;
		sImgT=iImgT.toString() + "px";
		}
	else
		sImgT="-" + iImgT.toString() + "px";
		
	imgZoom.style.left=sImgL;
	imgZoom.style.top=sImgT;
	
	divImgZoom.style.visibility='visible';

}

function ScriptTestMode() {

   var blRet = false;

   var el = document.getElementById("chkScriptTestMode");
   if (el) {
      if (el.checked)
         blRet = true;
   }

   return blRet;
}

function LimitSize(obj, elName, Max) {
   var iLen;
   var el = document.getElementById(elName);

   if (obj.value.length > Max) {
      obj.value = obj.value.substring(0, Max);
   }
   iLen = Max - obj.value.length;
   if (el)
      el.innerHTML = "(maximum characters: " + Max + ", remaining:" + iLen + ")";
}

function SizeTextArea(el, DefaultRows, MaxRows, Action) {

   var sText;
   var lLines,lCurrentRows,lSetRows,x;

   //sText = el.value.split('\n');
   //lLines = sText.length;
   //lCurrentRows=el.rows;
   
   //lSetRows=0;
   switch (Action) {
      case 1: // focus
         //if (lCurrentRows<(lLines+1))
         //   lSetRows = lLines+1;
         el.rows = MaxRows;
         break;
      case 2: // blur
         //lSetRows = DefaultRows;
         el.rows = DefaultRows;
         break;
      case 3: // keyup
         //lSetRows = lLines + 1;
         break;
         
   }

   //if (lSetRows > 0 && lSetRows != lCurrentRows) {
   //   if (lSetRows < DefaultRows)
   //      el.rows = DefaultRows;
   //   else if (lSetRows>MaxRows)
   //      el.rows=MaxRows;
   //   else
   //      el.rows=lSetRows;
   //}
   
}