﻿// JScript File - Images

var PrdSml=768;
var PrdLrg=1025;
var InsSml=0;
var InsLrg=0;
var PrdWid=0;
var PrdHgt=0;
var PrdOrn="N";

var DspWid=300;
var DspHgt=0;
var FulWid=0;
var FulHgt=0;
var ZomWid=0;
var ZomHgt=0;
var ActWid=300;
var ActHgt=0;
var ImgSpc="";
var TxtSpc="";
var MgmSpc="";

var DecWid=new Array();
var DecTWd=0;
var DecBWd=0;
var DecLWd=0;
var DecRWd=0;
var MrgWid=0;

var AlwMlt=true;
var ImgSel=false;
var ImgCnt=0
var ImgIdx=0;
var ImgLst=new Array();

var PanLst=new Array();
var PanSel=0;
var PanOvr=0;
var WrkImg;

var ImgXPs=0;
var ImgYPs=0;

var DspMod=0;
var CmpMod=0;
var SavMod=0;

var BckCol=0;

var ErsSel=0;

var ReqCnt=0;

function OwnImg()
{
	if (document.getElementById("chkOwnImg").checked && document.getElementById("chkDigImg").checked)
	{
		document.getElementById("divULdSec").style.display="";
		document.getElementById("frmImgULd").contentWindow.document.getElementById("cmdLodImg").disabled=false;
		document.getElementById("frmImgULd").contentWindow.document.getElementById("txtCerNum").value=CerNum;
		document.getElementById("frmImgULd").contentWindow.document.getElementById("txtSesHID").value=SesIDN;
	}
	else
	{
		document.getElementById("divULdSec").style.display="none";
		document.getElementById("frmImgULd").contentWindow.document.getElementById("cmdLodImg").disabled=true;
		document.getElementById("frmImgULd").contentWindow.document.getElementById("txtCerNum").value="";
		document.getElementById("frmImgULd").contentWindow.document.getElementById("txtSesHID").value=0;
	}
}

function SetSiz()
{
	var Ctl=document.getElementById("imgDspImg");
	ImgXPs=0;
	ImgYPs=0;
  ActWid=Ctl.width;
	ActHgt=Ctl.height;
	while (Ctl)
	{
		ImgXPs+=Ctl.offsetLeft;
		ImgYPs+=Ctl.offsetTop;
		Ctl=Ctl.offsetParent;
	}
}

function ImgULd()
{
	var Msg=document.getElementById("frmImgULd").contentWindow.document.getElementById("txtULdMsg").value;
	var INm=document.getElementById("frmImgULd").contentWindow.document.getElementById("txtImgFNm").value;
	var Lst;
	var IWd;
	var IHt;
	var DPI;
	if (Msg>"")
	{
	  Lst=Msg.split("|");
	  if (Lst[0]=="OK")
	  {
			IWd=1*Lst[1]; 
			IHt=1*Lst[2];
			DPI=1*Lst[3];
			RStDef=true;
			ImgSel=false;
	    AddILs(INm,IWd,IHt,DPI,"N");
	    PrpImg();
	    document.getElementById("frmImgULd").contentWindow.document.getElementById("cmdLodImg").src=PLbPth+"StrULd.jpg";
		}
		else
		{
			alert(Msg);
		}
	}
	return false;
}

function PrpImg()
{
	document.getElementById("imgDspImg").style.display="none";
	document.getElementById("txtImgDsc").innerHTML="Loading - Please Wait . . .";
	GetSpc(CerNum,ImgLst[ImgIdx].INm,ImgLst[ImgIdx].Orn)
}

function ImgBck(result, eventArgs)
{
	var Buf;
	var Msg;
	Buf=result.split('|');
	Msg=Buf[0]
	if (Msg=="OK")
	{
		ImgLst[ImgIdx].IWd=1*Buf[1]; 
		ImgLst[ImgIdx].IHt=1*Buf[2];
		ImgLst[ImgIdx].DPI=1*Buf[3];
		if (ImgLst[ImgIdx].Orn=="N") ImgLst[ImgIdx].Orn=Buf[4];
		LodImg(ImgIdx);
	}
	else
	{
		document.getElementById("txtImgSpc").innerHTML=Msg;		
	}
}

function DspImg(IIx)
{
  var Wid=DspWid;
  var Hgt;
  if (Wid==0)
  {
		if (ImgLst[IIx].Orn=="V")  Wid=300;
		if (ImgLst[IIx].Orn=="H")  Wid=375;
	}
	Hgt=Wid*(ImgLst[IIx].IHt/ImgLst[IIx].IWd);
	if (Hgt>350)
	{
		Wid=350*(ImgLst[IIx].IWd/ImgLst[IIx].IHt);
	}
	WrkImg=document.getElementById("imgDspImg");
	WrkImg.width=Wid;
	WrkImg.src=ImgLst[IIx].BIm.src;
	return false;
}

function DspPrd()
{
	var Cmd=""
	var Idx=0;
	var DMd=0;
  var ATx="N";
	CfgOrn(PrdOrn);
	if (PrdWid>0 && PrdHgt>0) // && ImgLst.length>0)
	{
	  ReqCnt++;
		WrkImg.width=DspWid;
		if (ActSec==8) ATx="Y";
		ImgSpc=NumRow + "|" + NumCol + "|";
		for (Idx=0; Idx<PanLst.length; Idx++)	BldSpc(Idx,PanLst[Idx].IIx)
		WrkImg.style.display="none";
		Cmd="BldImg.ashx"
		Cmd=Cmd + "?OrdIDN=" + OrdIDN + "&CerNum=" + CerNum + "&DspMod=" + DspMod + "&CmpMod=" + CmpMod + "&SavMod=" + "0"    + "&ImgSpc=" + ImgSpc + "&AddTex=" + ATx    + "&ReqCnt=" + ReqCnt + "&ZomVue=1";
		Cmd=Cmd + "&PrdWid=" + PrdWid + "&PrdHgt=" + PrdHgt + "&PrdOrn=" + PrdOrn + "&BrdOrn=" + BrdOrn + "&SizCod=" + SizCod + "&BrdIDN=" + BrdIDN + "&BrdTBd=" + BrdTBd + "&BrdIPt=" + BrdIPt + "&DecTyp=" + DecTyp + "&DspWid=" + DspWid;
		document.getElementById("txtImgDsc").innerHTML="Loading Product Image . . ."; 
		WrkImg.src=Cmd;
		if (ActSec==8)
		{
			CalZom();
			Cmd="BldImg.ashx"
			Cmd=Cmd + "?OrdIDN=" + OrdIDN + "&CerNum=" + CerNum + "&DspMod=" + DspMod + "&CmpMod=" + CmpMod + "&SavMod=" + SavMod + "&ImgSpc=" + ImgSpc + "&AddTex=" + ATx    + "&ReqCnt=" + ReqCnt + "&ZomVue=1";
			Cmd=Cmd + "&PrdWid=" + PrdWid + "&PrdHgt=" + PrdHgt + "&PrdOrn=" + PrdOrn + "&BrdOrn=" + BrdOrn + "&SizCod=" + SizCod + "&BrdIDN=" + BrdIDN + "&BrdTBd=" + BrdTBd + "&BrdIPt=" + BrdIPt + "&DecTyp=" + DecTyp + "&DspWid=" + ZomWid;
			document.getElementById("imgZomImg").src=Cmd;
			document.getElementById("imgOrgImg").src=PanLst[0].Img.src;
			DspDsn();
		}
		SndDsn();
	}
	else
	{
		document.getElementById("txtImgDsc").innerHTML="";
	}
}

function ImgCmp()
{
  var PSz;
	if (WrkImg!=null) WrkImg.style.display="";
	if (PrdOrn=="V") PSz=InsSml + '" x ' + InsLrg + '"'
	if (PrdOrn=="H") PSz=InsLrg + '" x ' + InsSml + '"'
	document.getElementById("txtImgDsc").innerHTML=PrdNam + "  " + PSz
	if (ActSec==4 || ActSec==5 || ActSec==6 || ActSec==7) 
	{
		if (FmtTyp==2) ShwTxt(true);
		RStPos();
		if (ActSec==5 || ActSec==7) ResPos(true); else ResPos(false);
	}
	if (ActSec==8)
	{
		document.getElementById("cmdZomVue").disabled=false;
		document.getElementById("cmdSumNxt").disabled=false;
	}
}

function CalZom()
{
	var IWd=0;
  var IHt=0;
	IWd=FulWid;
	IHt=FulHgt;
	if (IWd>WinWid) ZomWid=WinWid; else ZomWid=IWd;
	ZomHgt=ZomWid*(IHt/IWd)
	if (ZomHgt>(WinHgt-20)) ZomHgt=WinHgt-20;
	ZomWid=ZomHgt*(IWd/IHt);
}

function DspZom(Sel)
{
  if (Sel==0)
  {
		document.getElementById("ZomVue").style.display="none";  
  }
  if (Sel==1)
  {
		document.getElementById("ZomVue").style.display="";
		document.getElementById("imgZomImg").width=ZomWid;
		document.getElementById("imgZomImg").height=ZomHgt;
		document.getElementById("ZomVue").style.width=ZomWid+"px";
		document.getElementById("ZomVue").style.height=(ZomHgt+20)+"px";
		document.getElementById("ZomVue").style.left="0px";
		document.getElementById("ZomVue").style.top="0px";
		document.getElementById("colZomHdr").style.width=(ZomWid-20)+"px";	
	}
	return false;
}

function ZomCmp()
{
	return false;
}

function BldSpc(PIx,IIx)
{
  var CSp=1;
  var RSp=1;
  var BCl=0;
  var XPs=0;
  var YPs=0;
  var DWd=0;
  var DHt=0;
  var Scl=0;
  var Rot=0;
  var INm=""
  if (IIx!=99)	
  {
		if (PIx!=99)
		{
		  if (PanLst[PIx].OWd>0)
		  {
		    Scl=ImgLst[IIx].IWd/ImgLst[IIx].DWd;
		  	BCl=PanLst[PIx].BCl;
		  	CSp=PanLst[PIx].CSp;
		  	RSp=PanLst[PIx].RSp;
		  	XPs=ImgLst[IIx].XPs*Scl;
				YPs=ImgLst[IIx].YPs*Scl;
				DWd=PanLst[PIx].OWd*Scl;
				DHt=PanLst[PIx].OHt*Scl;
			}
		}
		Rot=ImgLst[IIx].Rot;
		INm=ImgLst[IIx].INm;
    ImgSpc += INm + "|" + IIx + "|" + CSp + "|" + RSp + "|" + BCl + "|" + Rot + "|" + XPs.toFixed(3) + "|" + YPs.toFixed(3) + "|" + DWd.toFixed(3) + "|" + DHt.toFixed(3) + "|"			
  }
  else 
  {
		if (PIx!=99)
		{
			BCl=PanLst[PIx].BCl;
			CSp=PanLst[PIx].CSp;
		  RSp=PanLst[PIx].RSp;
			ImgSpc += "|0|" + CSp + "|" + RSp + "|" + BCl + "|0|0|0|0|0|";	
		}
		else 
		{
			ImgSpc += "|0|0|0|0|0|0|0|0|0|";
		}
	}
}

function DspArg()
{
  var PIx=0;
  for (PIx=0; PIx<PanLst.length; PIx++) DspPan(PIx,false);
  ResPos();
  return false;
}

function DspPan(PIx,Sav)
{
	var Cmd="BldImg.ashx"
	var IIx=0;
	var Rot=0;
	var XAd=0;
	var YAd=0;
	if (PanLst[PIx].OWd>0 && PanLst[PIx].OHt>0)
	{
	  IIx=PanLst[PIx].IIx;
		if (PanLst[PIx].IIx==99)
		{
			Cmd="BldImg.ashx?OrdIDN=" + OrdIDN + "&CerNum=" + CerNum + "&BlkCol=2&ImgWid=" + PanLst[PIx].OWd + "&ImgHgt=" + PanLst[PIx].OHt + "&BlkGrd=1&TmbMod=3&DspWid=0"
			PanLst[PIx].Img.style.position="absolute";
			PanLst[PIx].Img.style.left  ="0px";
			PanLst[PIx].Img.style.top   ="0px";
			PanLst[PIx].Img.style.width =PanLst[PIx].OWd + "px";
			PanLst[PIx].Img.style.height=PanLst[PIx].OHt + "px";
			PanLst[PIx].Img.src=Cmd;
			PanLst[PIx].Img.style.display="none";
		}
		else
		{
		  if (BrwNam=="IE")
		  {
				try
				{
					PanLst[PIx].Img.style.filter="progid:DXImageTransform.Microsoft.BasicImage(rotation="+ImgLst[IIx].Rot+")";
					PanLst[PIx].Img.style.position="absolute";
					PanLst[PIx].Img.style.left  =-ImgLst[IIx].XPs + "px";
					PanLst[PIx].Img.style.top   =-ImgLst[IIx].YPs + "px";
					PanLst[PIx].Img.style.width =ImgLst[IIx].DWd + "px";
					PanLst[PIx].Img.style.height=ImgLst[IIx].DHt + "px";
					PanLst[PIx].Img.src=ImgLst[PanLst[PIx].IIx].BIm.src;
					PanLst[PIx].Img.style.display="";
				}
				catch (err)
				{
				}
			}
			else
			{
			  switch (ImgLst[IIx].Rot)
				{
					case 0: 
						Rot=0;								
						XAd=0;
						YAd=0;
						Wid=ImgLst[IIx].DWd;
						Hgt=ImgLst[IIx].DHt;
						break;
					case 1: 
						Rot=90*Math.PI/180;		
						XAd=0;
						YAd=-ImgLst[IIx].DHt;
						Wid=ImgLst[IIx].DHt;
						Hgt=ImgLst[IIx].DWd;
						break;
					case 2: 
						Rot=Math.PI;					
						XAd=-ImgLst[IIx].DWd;
						YAd=-ImgLst[IIx].DHt;
						Wid=ImgLst[IIx].DWd;
						Hgt=ImgLst[IIx].DHt;
						break;
					case 3: 
						Rot=270*Math.PI/180;
						XAd=-ImgLst[IIx].DWd;
						YAd=0;
						Wid=ImgLst[IIx].DHt;
						Hgt=ImgLst[IIx].DWd;
						break;
				}	
				try
				{
					PanLst[PIx].Cvs.style.position="absolute";
					PanLst[PIx].Cvs.style.left  =-ImgLst[IIx].XPs + "px";
					PanLst[PIx].Cvs.style.top   =-ImgLst[IIx].YPs + "px";
					PanLst[PIx].Cvs.setAttribute("width",Wid);
					PanLst[PIx].Cvs.setAttribute("height",Hgt);
					PanLst[PIx].Img.src=ImgLst[PanLst[PIx].IIx].BIm.src;
					PanLst[PIx].CTx.rotate(Rot);
					PanLst[PIx].CTx.drawImage(PanLst[PIx].Img,XAd,YAd,ImgLst[IIx].DWd,ImgLst[IIx].DHt);
					PanLst[PIx].Cvs.style.display="";
				}
				catch (err)
				{
				}
			}
		}
	}
}

function BldTxt(TIx)
{
	var Cmd="BldTxt.ashx";
	var Txt;
	var Fnt;
	var FSz;
	var TxC;
	var Aln;
	var TNm;
	var TSz;
	var Scl=FulWid/DspWid;
	var PWd=PrdWid;
	var TWd=PrdWid-(2*(Scl*MrgWid));
	var THt=PrdHgt;
	var DWd=DspWid-(DecLWd+DecRWd);
	if (TxtTyp==1 || TxtTyp==3)
	{
		Txt=escape(TxtBuf[TIx]);
		Fnt=TxtFnt[TIx];
		FSz=TxtFSz[TIx];
		TxC=TxtCol[TIx];
		Aln=TxtAln[TIx];
		if (TxtTyp==3 && BrdTLs!=null) 
		{
			TWd=(BrdTLs[0].XP2-BrdTLs[0].XP1);
			THt=(BrdTLs[0].YP2-BrdTLs[0].YP1);
		}
		if (Txt>"" && PWd>0)
		{
			Cmd=Cmd + "?TxtBuf=" + Txt;
			Cmd=Cmd + "&TxtNum=0";
			Cmd=Cmd + "&FntNam=" + Fnt + "&FntSiz=" + FSz;
			Cmd=Cmd + "&TxtCol=" + TxC + "&TxtAln=" + Aln;
			Cmd=Cmd + "&TxtWid=" + TWd + "&TxtHgt=" + THt;
			Cmd=Cmd + "&PrdWid=" + PWd + "&DspWid=" + DWd;
			if (TIx==0) 
			{
				document.getElementById("imgTx1Img").style.zIndex="2";
				document.getElementById("imgTx1Img").src=Cmd;
			}
			if (TIx==1)
			{
				document.getElementById("imgTx2Img").style.zIndex="2";
				document.getElementById("imgTx2Img").src=Cmd;
			}
		}
		else
		{
			if (TIx==0) document.getElementById("imgTx1Img").style.display="none";
			if (TIx==1) document.getElementById("imgTx2Img").style.display="none";
		}
	}
}

function BldMgm()
{
	var Cmd="BldMgm.ashx";
	var PWd=PrdWid;
	var DWd=DspWid-(DecLWd+DecRWd);
	if (MgmTxt>"" && BrdTLs!=null)
	{
		MgmCol=BrdTLs[1].Bgd;
		Cmd=Cmd + "?MgmTxt=" + MgmTxt;
		Cmd=Cmd + "&MgmCol=" + MgmCol;
		Cmd=Cmd + "&PrdWid=" + PWd + "&DspWid=" + DWd;
		document.getElementById("imgMgmImg").src=Cmd;
	}
}

function BldDte(DTp)
{
	var Cmd="BldDte.ashx";
	var PWd=PrdWid;
	var DWd=DspWid-(DecLWd+DecRWd);
	Cmd=Cmd + "?DteTyp=" + DTp;
	Cmd=Cmd + "&DteTxt=" + DteTxt;
	Cmd=Cmd + "&DteCol=" + DteCol;
	Cmd=Cmd + "&PrdWid=" + PWd + "&DspWid=" + DWd;
	if (DTp=="M") document.getElementById("imgMonImg").src=Cmd; 
	if (DTp=="D") document.getElementById("imgDayImg").src=Cmd;
	if (DTp=="Y") document.getElementById("imgYerImg").src=Cmd;
	if (DTp=="C") document.getElementById("imgClkImg").src=Cmd;
}

function AddILs(INm,IWd,IHt,DPI,Orn)
{
  if (AlwMlt)
  {
		ImgIdx=ImgCnt;
		ImgCnt++;
	}
	else
	{
	  ImgLst.length=0
	  ImgCnt=1;
		ImgIdx=0;
	}
	if (Orn=="N")
	{
	  if (IWd>IHt) Orn="H"; else Orn="V";
	}
	ImgLst[ImgIdx]=new Object();
	ImgLst[ImgIdx].INm=INm;
	ImgLst[ImgIdx].CDf=1;
	ImgLst[ImgIdx].IWd=IWd; 
	ImgLst[ImgIdx].IHt=IHt;
	ImgLst[ImgIdx].DPI=DPI;
	ImgLst[ImgIdx].Orn=Orn;
	ImgLst[ImgIdx].XPs=0;
	ImgLst[ImgIdx].YPs=0;
	ImgLst[ImgIdx].XP1=0;
	ImgLst[ImgIdx].YP1=0;
	ImgLst[ImgIdx].XP2=0;
	ImgLst[ImgIdx].YP2=0;
	ImgLst[ImgIdx].RWd=0;
	ImgLst[ImgIdx].Rot=0;
	ImgLst[ImgIdx].Img=new Image();
	ImgLst[ImgIdx].BIm=new Image();
	DspCtl();
}

function DelImg()
{
  var PIx;
  if (ImgCnt>0)
  {
		if (confirm("Are you sure you want to remove the selected image from your collection?"))
	  {
			for (PIx=0; PIx<PanLst.length; PIx++)
			{
				if (PanLst[PIx].IIx==ImgIdx) 
				{
					PanLst[PIx].IIx=99;
					PanLst[PIx].BCl=0;
					DspPan(PIx,false);
				}
			}
			RmvImg(ImgLst[ImgIdx].INm);
			ImgLst.splice(ImgIdx,1);
			ImgCnt--;
			DspILs();
			if (ImgIdx>=ImgCnt) ImgIdx=0;
			if (ImgCnt>0)	SelILs(ImgIdx);
			else					document.getElementById("imgDspImg").style.display="none";
			DspCtl();
		}
	}
	return false;
}

function DImBck(result, eventArgs)
{
	var Buf
	Buf=result.split('|');
	if (Buf[0]!="OK")
	{
		alert(Buf[1]);		
	}
}

function LodImg(IIx)
{
	var Cmd;
	ImgSpc=ImgSpc="1|1|";
	BldSpc(99,IIx)
	Cmd="BldImg.ashx?OrdIDN=" + OrdIDN + "&CerNum=" + CerNum + "&ImgSpc=" + ImgSpc + "&TmbMod=1&DspWid=0"
	ImgLst[IIx].Img.onload=function() { if (IIx+1==ImgCnt) { DspILs(); BldPan(NumRow,NumCol,SplCod); } }
	ImgLst[IIx].Img.src=Cmd;
	Cmd="BldImg.ashx?OrdIDN=" + OrdIDN + "&CerNum=" + CerNum + "&ImgSpc=" + ImgSpc + "&TmbMod=2&DspWid=" + DspWid;
	ImgLst[IIx].BIm.onload=function() { setTimeout("SelILs("+IIx+")",100); }
	ImgLst[IIx].BIm.src=Cmd;
}

function DspILs()
{
	var Tbl=document.getElementById("tblImgSel");
	var Idx=0;
	if (ImgCnt==0) document.getElementById("txtILsHdr").innerHTML="No Images";
	if (ImgCnt==1) document.getElementById("txtILsHdr").innerHTML=ImgCnt+" Image";
	if (ImgCnt>1)  document.getElementById("txtILsHdr").innerHTML=ImgCnt+" Images";
	while (Tbl.rows.length>0) Tbl.deleteRow(0);
	for (Idx=0; Idx<ImgCnt; Idx++) DspIIm(Tbl,Idx);
	return false;
}

function RStILs()
{
  var Idx=0;
	for (Idx=0; Idx<ImgLst.length; Idx++)
  {
		ImgLst[Idx].CDf=1;  
  }
}

function DspIIm(Tbl,IIx)
{
	var Bdy=document.createElement('tbody'); 
	var Row;
	var Hdr;
	var Img;
	var Thb;
	var Idx=0;
	var Buf="";
	var Wid=0;
	var Hgt=0;
	if (BrwNam!='IE')
	{
		Row=document.createElement('tr')
		Row.setAttribute("onclick","SelILs("+IIx+")");
		Row.setAttribute("onmousedown","SetDrg("+IIx+")");
	}
	else
	{
		Row=document.createElement('<tr onclick="SelILs('+IIx+')" onmousedown="SetDrg('+IIx+')">');
	}
	if (BrwNam!="IE")
	{
		Hdr=document.createElement('td');
		Img=document.createElement('td');
		SId=document.createElement('td');
		Hdr.setAttribute("class","ISlHdr");
		Img.setAttribute("class","ISlImg");
	}
	else 
	{
		Hdr=document.createElement('<td class="ISlHdr">');
		Img=document.createElement('<td class="ISlImg">');
	}
	Hdr.innerHTML=String.fromCharCode(IIx+65);
	Wid=60;
	Hgt=Wid*(ImgLst[IIx].IHt/ImgLst[IIx].IWd)
	Thb=document.createElement("img");
	Thb.src=ImgLst[IIx].Img.src;
	Thb.width=Wid;
	Thb.height=Hgt;
	Img.appendChild(Thb);
	Row.appendChild(Hdr);
	Row.appendChild(Img);
	Bdy.appendChild(Row);
	Tbl.appendChild(Bdy);
	return false;
}

function SelILs(RIx)
{
 	var Tbl=document.getElementById("tblImgSel");
 	var Row;
  var Grd;
  var Buf;
  var Chg;
  var IIx;
 	if (Tbl.rows.length>0)
 	{
 		for (Idx=0; Idx<Tbl.rows.length; Idx++) 
		{
			Row=Tbl.rows[Idx]; 
			if (Idx==RIx)	Row.style.backgroundColor="#b22222"; 
			else					Row.style.backgroundColor="#d6c7a0";
		}
		if (ImgIdx!=RIx) Chg=true;
		ImgIdx=RIx; 
		if (BrdIDN==0 && NumRow==1 && NumCol==1 && (PrdOrn=="N" || !AlwArg))
		{
			if (SupOrn=="B") CfgOrn(ImgLst[ImgIdx].Orn); else CfgOrn(SupOrn);
			Chg=true;
		}
		if (ActSec==2)
		{
		  if (Chg || !ImgSel) CalDef(0,ImgIdx);
			ImgSel=true;
		  Grd=EvlImg(0,0,ImgIdx);	  
			document.getElementById("txtImgDsc").innerHTML="Your Image Size: " + ImgLst[ImgIdx].IWd + " x " + ImgLst[ImgIdx].IHt;
			document.getElementById("txtEdtSpc").innerHTML=ImgLst[ImgIdx].IWd + " x " + ImgLst[ImgIdx].IHt + "  " + ImgLst[ImgIdx].DPI + " DPI";
			Buf=Grd.toFixed(0) + "%"
			if (Grd>=98) 
			{
				document.getElementById("txtEdtGrd").style.color="Green";
				document.getElementById("txtImgWrn").innerHTML="";
				Buf+=" Good Image"
			}
			else
			{
				document.getElementById("txtEdtGrd").style.color="Red";
				document.getElementById("txtImgWrn").innerHTML="This will NOT weave a high quality product.\nPlease rescan at a higher resolution or choose a different photograph.";
				Buf+=" Too Small"
			}
			document.getElementById("txtEdtGrd").innerHTML=Buf;
			if (PrdOrn=="V") document.getElementById("txtEdtReq").innerHTML=PrdSml + " x " + PrdLrg
			if (PrdOrn=="H") document.getElementById("txtEdtReq").innerHTML=PrdLrg + " x " + PrdSml
			DspImg(ImgIdx);
			if (Chg && NumRow==1 && NumCol==1)
			{
			  BldPan(NumRow,NumCol,SplCod);
				for (IIx=0; IIx<ImgCnt; IIx++) if (ImgLst[IIx].PIx==0) ImgLst[IIx].PIx=99;
				PanLst[0].IIx=ImgIdx;
				ImgLst[ImgIdx].PIx=0;
				ImgLst[ImgIdx].Rot=0;
				CalDef(0,ImgIdx,true);
				DspPan(0,true);
			}
		}
	}
}

function EdtGrd(PIx,IIx)
{
  var Grd=0;
  var Buf="";
	Grd=EvlImg(1,PIx,IIx);	  
	if (Grd>0)
	{
		document.getElementById("txtEdtSpc").innerHTML=ImgLst[IIx].IWd + " x " + ImgLst[IIx].IHt + "  " + ImgLst[IIx].DPI + " DPI";
		Buf=Grd.toFixed(0) + "%"
		if (Grd>=98) 
		{
			document.getElementById("txtEdtGrd").style.color="Green";
			document.getElementById("txtEdtWrn").innerHTML="";
			Buf+=" Good Image"
		}
		else
		{
			document.getElementById("txtEdtGrd").style.color="Red";
			document.getElementById("txtEdtWrn").innerHTML="This will NOT weave a high quality product.\nPlease rescan at a higher resolution.";
			Buf+=" Too Small"
		}
		document.getElementById("txtEdtGrd").innerHTML=Buf;	
		if (PrdOrn=="V") document.getElementById("txtEdtReq").innerHTML=PrdSml + " x " + PrdLrg
		if (PrdOrn=="H") document.getElementById("txtEdtReq").innerHTML=PrdLrg + " x " + PrdSml
	}
	else
	{
		document.getElementById("txtEdtSpc").innerHTML="";
		document.getElementById("txtEdtGrd").innerHTML="";
		document.getElementById("txtEdtReq").innerHTML="";
	}
}

function EvlImg(Lvl,PIx,IIx)
{
	var Scl=1;
	var DWd;
	var DHt;
	var OWd;
	var OHt;
	var Pct=0;
	if (ImgLst.length>0 && IIx<ImgLst.length)
	{
		if (Lvl==0)
		{
			if (ImgLst[IIx].IWd>ImgLst[IIx].IHt) { OWd=PrdLrg; OHt=PrdSml; } else  { OWd=PrdSml; OHt=PrdLrg; }
			if ((ImgLst[IIx].IHt/ImgLst[IIx].IWd)<(OHt/OWd))
			{
				DHt=OHt;
				DWd=OHt*(ImgLst[IIx].IWd/ImgLst[IIx].IHt)
			}
			else
			{
				DWd=OWd;
				DHt=OWd*(ImgLst[IIx].IHt/ImgLst[IIx].IWd)
			}
			Scl=ImgLst[IIx].IWd/DWd;
			DWd=OWd*Scl;
			DHt=OHt*Scl;	
			Pct=((DWd*DHt)/(PrdSml*PrdLrg))*100;
		}
		if (Lvl==1)
		{
			Scl=ImgLst[IIx].IWd/ImgLst[IIx].DWd;
			DWd=PanLst[PIx].OWd*Scl;
			DHt=PanLst[PIx].OHt*Scl;	
			if (BrdIDN==0) Pct=((DWd*DHt)/(PrdSml*PrdLrg))*100;
			else					 Pct=((DWd*DHt)/(BrdILs.Wid*BrdILs.Hgt))*100;	
		}
		if (Pct>100) Pct=100;
	}
	return Pct;
}


