function OpenGridMenu()
    {
    try
        {
        var menu = document.getElementById("PopUp1");
        menu.visble=true;
        menu.style.zIndex= 200;
        menu.style.display="block";
        }
    catch(er)
        {
        }
    }


function CloseModal(divName)
    {
    try
        {
        var div = document.getElementById("divcover");
        div.style.display = "none";
        //var div2 = document.getElementById("divMenu");
        var div2 = document.getElementById(divName);
        div2.style.display = "none";
        }
    catch(er)
        {
        }
    }    

function OpenModal(divName)
    {
    try
        {
    
    var browser = navigator.appName;
    if (navigator.appName.indexOf('Microsoft') != -1)
          browser = 'IE'
     else browser = 'FF';
     
   
        var div = document.getElementById("divcover");
   
        div.visible= true;
        div.style.width = document.body.scrollWidth - 5;
        div.style.height = document.body.scrollHeight;    
        //div.style.display = "block";
        div.style.display = "none";
        div.style.backgroundColor = "Gray";
        
        if (browser == 'IE')
            {
            div.style.filter = 'alpha(opacity=50)';    
            }
        if (browser == 'FF')
            {    
            div.style.opacity = 0.50;       
            }
            
        div.style.verticalAlign = "middle";
        div.style.textAlign = "center";
        div.style.top = "5";
        div.style.left = "5";
        div.style.position = "absolute";
        div.style.zIndex = 0;
        //document.appendChild(div);
        
        //var div2 = document.getElementById("divMenu");
        var div2 = document.getElementById(divName);
        //var t1 = (document.body.scrollWidth / 2);
        //var t2 = (document.body.scrollHeight / 6);
        //div2.innerHTML ='<div><img src="images/loading.bmp" /></div>';
        div2.style.display = "block";
        //div2.style.verticalAlign = "middle";
        //div2.style.textAlign = "center";
        //div2.style.top = t2;
        //div2.style.left = t1;
        //div2.style.position = "absolute";
        //div2.style.zIndex = 100;
    
    
        }
    catch(er)
        {
        }
    }


function BlockIt()
    {
    try
        {
    
    var browser = navigator.appName;
    if (navigator.appName.indexOf('Microsoft') != -1)
          browser = 'IE'
     //else if (navigator.appName.indexOf('Netscape') != -1)
       //   browser = 'Netscape'
     else browser = 'FF';
     
   //if (browser == 'IE')
   //     {
        //var div = document.createElement('img');
        //div.id = 'loadingdiv'; 
        var div = document.getElementById("divcover");
        //div.cssclass = "divblock";
        div.visible= true;
        //div.src = 'images/loadingback.gif';
        div.style.width = document.body.scrollWidth - 5;
        div.style.height = document.body.scrollHeight;    
        
        //div.innerHTML ='<div><br/><br/><br/><br/><br/><br/><br/><br/><br/><div><img src="images/loading.bmp" /></div> </div>';
        div.style.display = "block";
        div.style.backgroundColor = "Gray";
        
        if (browser == 'IE')
            {
            div.style.filter = 'alpha(opacity=50)';    
            }
        if (browser == 'FF')
            {    
            div.style.opacity = 0.50;       
            }
            
        div.style.verticalAlign = "middle";
        div.style.textAlign = "center";
        div.style.top = "5";
        div.style.left = "5";
        div.style.position = "absolute";
        div.style.zIndex = 0;
        //document.appendChild(div);
        
        var div2 = document.getElementById("divtopcover");
        var t1 = (document.body.scrollWidth / 2);
        var t2 = (document.body.scrollHeight / 6);
        div2.innerHTML ='<div><img src="images/loading.bmp" /></div>';
        div2.style.display = "block";
        div2.style.verticalAlign = "middle";
        div2.style.textAlign = "center";
        div2.style.top = t2;
        div2.style.left = t1;
        div2.style.position = "absolute";
        div2.style.zIndex = 1;
    //    }
        
    //if (browser == 'FF')
    //    {
    //    var div = document.createElement('img');
    //    div.id = 'loadingdiv'; 
    //    div.src = 'images/loadingback.gif';
    //    div.style.width = document.body.scrollWidth - 5;
    //    div.style.height = document.body.scrollHeight;
    //    div.style.display='block';    
    //    div.style.opacity = 0.50;       
    //    div.style.position = 'absolute';
    //    div.style.top = 0;
    //    div.style.left = 0;
    //    div.style.zIndex = 1;
    //    document.getElementsByTagName('body')[0].appendChild(div);
        
    //    var im = document.createElement('img');
    //    im.id = 'loading'; 
    //    im.src = 'images/loading.bmp';
    //    im.style.display='block'    
    //    im.style.position = 'absolute';
    //    var t1 = (document.body.scrollWidth / 2);
    //    var t2 = (document.body.scrollHeight / 6);
    //    im.style.top = t2;
    //    im.style.left = t1;
    //    im.style.zIndex = 0;
    //    document.getElementsByTagName('body')[0].appendChild(im);
    //    }
    
    
        }
    catch(er)
        {
        }
    }


function UnBlockIt()
    {
    //$().loadStart($.blockUI).loadStop($.unblockUI);
    //$.unblockUI();
    }
    
function ventana(Mensaje){
	    var miVentana; 
	    
	    miventana=open("","miVentana","menubar=0,width=250,height=100,top=150,left=200")
	    miventana.document.write("<html>");
	    miventana.document.write("<head>");
	    miventana.document.write("<title>Login</title>");
	    miventana.document.write("</head>");
	    miventana.document.write("<body><center>");
	    miventana.document.write("<h3>" + Mensaje + "</h3>");
	    miventana.document.write("<form onload=WinThrill();>");
	    miventana.document.write("<input type=button value=Cerrar onclick=self.close()>")
	    miventana.document.write("</form>");
	    miventana.document.write("</body>");
	    miventana.document.write("</html>");
		y=0;
		z=0;
		WinThrill(miventana,y,z);
	                     }	

function  CheckStatus(){
                  if (document.Form1.txtstatus.value=="0"){
	                   ventana("Grabo!!!");
	                   document.Form1.txtstatus.value="";
	                        }
		         	}
		         	
function buscador(){
	OpenADocument("frmFind.aspx","",705,435);	
	/*window.open("frmFind.aspx","Search","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=705,height=435");*/
                   }

function qrybuilder(){
   window.open("frmQueryBuilder.aspx","Query","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=785,height=515");
                   }

/*
function buscadorField()
		{
	var theWindowName;
	theWindowName=RndForDocumentTitle();

	SearcherByField(document.getElementById("wfKey").value) ;
        }    
*/

function attachdoc(){
   //window.open("frmDocUpload.aspx","Attach","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=635,height=385,left = 194.5,top = 191.5");
   window.open("frameDocs.aspx?Wfkey=" + document.getElementById("wfKey").value,"Attach","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,ReSizable=yes,width=815,height=600");
                   }

                   
function roleuser(){
   window.open("frmRoleUser.aspx","RoleUser","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=360,height=90,top=339,left=332");
                   }                                                       

function writestatus(Text){
try
	{
	if(Text.value.length!="0"){
		var Txt=Text.value;
		if(Txt.substring(0,1) == "0"){window.status=Txt.substring(1,Txt.length);}
		if(Txt.substring(0,1) == "1"){alert(Txt.substring(1,Txt.length));}
		if(Txt.substring(0,1) == "2"){window.status=Txt.substring(1,Txt.length);alert(Txt.substring(1,Txt.length));}
		Text.value='';}
	else{
		window.status="";
		}
	}
	catch(er)
	{}
						}  
/*						
function refresh(Text){
try
	{
		window.parent.frames("bottom").location.href="frmGridFoot.aspx";
	}
	
					catch(er)
						{}
	}
*/						
/*
function loadgridfoot(){
if(window.parent.frames.length>1){
window.parent.frames("bottom").location.href="frmGridFoot.aspx";}
					   }
*/
function loadgridfoot(){

if(window.parent.frames.length>1){
window.parent.frames("bottom").location.href="frmGridFoot.aspx";}
					   }

function loadgridfoot1(wfKey){
					try 
						{
							if(window.parent.frames.length>1)
								{
									window.parent.frames("bottom").location.href="frmGridFoot.aspx?wfKey=" + wfKey;
								}
						}
						catch(er)
						{}
					   //Nueva Funcionalidad, abre un gridfoot nuevo con edit ALS 26/11/2003
					   try 
						{
							if(document.Form1.txtGrdEdit.value="TRUE")
								{
									window.parent.frames("bottom").location.href="frmGrdEdit.aspx?wfKey=" + wfKey;
								}
						}
						catch(er)
						{}
					   }
					   
					   
function openbdg(){
   window.open("frmBdg.aspx","Bdg","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,width=355,height=120");
                   }
                   
function OpenDemoInvoice(){
   window.open("frmDemoInvoice.aspx","Search","fullscreen=no,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=675,height=669");
                          } 
                          
function changestatus(){
   var Rnd;
   Rnd = Math.random();
   Rnd = Rnd.toString();
   Rnd = Rnd.substring(Rnd.length-5,Rnd.length);
   window.open("frmSC.aspx",Rnd,"fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=750,height=285,top=210,left=210");
                   }
                   
function openHelp(){                   
var page  = document.getElementById("stMsg").value;
document.getElementById("stMsg").value="";
//window.open("frmHelpFrame.htm","Help","fullscreen=no,toolbar=no,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,maximized=yes,width=1016,height=625,top=0,left=0");
window.open(page,"Help","fullscreen=no,toolbar=no,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,maximized=yes,width=1016,height=625,top=0,left=0");
					}
function xmlview(){
   window.open("frmviewxmlingrid.aspx","XmlView","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,ReSizable=yes,width=750,height=500");
                   }					
                   
function OpenCustomWindow(Page,Title,Status,Width,Height,ScrollBars,ToolBar,FullScreen,MenuBar,Location,Directories,ReSizable)
{
    var Top;
    var Left;
    var Att;

	var TheStatus;
	if (Status==undefined) 
		{TheStatus="no"}
	  else
		{
		if (Status!="") 
			{TheStatus=Status}
		else
			{TheStatus="no"}
		}
		
	var TheScrollBars;
	if (ScrollBars==undefined) 
		{TheScrollBars="auto"}
	  else
		{
		if (ScrollBars!="") 
			{TheScrollBars=ScrollBars}
		else
			{TheScrollBars="no"}
		}
		
   var TheToolBar;
   if (ToolBar==undefined)
		{TheToolBar="no"}	
	  else
		{
		if (ToolBar!="")
				{TheToolBar=ToolBar}
			else
				{TheToolBar="no"}
		}
		
   var TheFullScreen;
   if (FullScreen==undefined)
   		{TheFullScreen="no"}
	  else
		{
	     if (FullScreen!="")
			{TheFullScreen=FullScreen}
		   else
			{TheFullScreen="no"}
		}
		
   var TheMenuBar;
   if (MenuBar==undefined)
   		{TheMenuBar="no"}
   	  else
   		{
		if (MenuBar!="")
				{TheMenuBar=MenuBar}
			else
				{TheMenuBar="no"}
		}
		
   var TheLocation;
   if (Location==undefined)
   		{TheLocation="no"}
   	  else
   		{
		if (Location!="")
				{TheLocation=Location}
			else
				{TheLocation="no"}
		}
		
   var TheDirectories;
   if (Directories==undefined)
   		{TheDirectories="no"}
   		else
   			{
			if (Directories!="")
				{TheDirectories=Directories}
			else
				{TheDirectories="no"}
			}
			
   var TheReSizable;
   if (ReSizable==undefined)
		{TheReSizable="yes"}
	  else
		{
		 if (ReSizable!="")
		{TheReSizable=ReSizable}
	  else
		{TheReSizable="yes"}
		}
			
   var theWindowName;
   theWindowName=RndForDocumentTitle();
	
    Top = (((screen.height / 2) - 40) - (Height / 2));
    Left = (((screen.width / 2) - 10) - (Width / 2));
	Att = "fullscreen=" + TheFullScreen + ",toolbar=" + TheToolBar + ",location=" + TheLocation + ",directories=" + TheDirectories + ",status=" + TheStatus + ",menubar=" + TheMenuBar + ",scrollbars=" + TheScrollBars + ",resizable=" + TheReSizable + ", width=" + Width + ",height=" + Height + ",top=" + Top + ",left=" + Left;
    window.open(Page,theWindowName,Att);
														}         
														
function isWinClosed(Win){
	if(Win.document.all){
		var top=Win.self.screenTop;
		if (top>9000 && Win.parent.parent.frames.length < 3){
			return true
					}
					} 
	else   {
		var top=Win.outerWidth;
		if(top==0 && Win.parent.parent.frames.length < 3){
			return true
				} 
			}
	   		       } 
	   		       
function WinRtnTo(){
	if(isWinClosed(window)){
/*	window.self.opener.location.href=document.Form1.RtnTo.value;*/
	
	window.self.opener.location.href=window.self.opener.location.href;
									}
					}					   		       
	   		                         
function KeyPressed(){
					Tecla=window.event.keyCode;
					document.Form1.KeyPressed.value=Tecla
					}
						   		       
function gFormLoad(){
					document.Form1.KeyPressed.value="";
				
										}
										
	
function gConfirmMessage(doc){
		var conf = doc.Form1.ConfirmMsg.value;
		if(conf != ""){
		var result;
		result=window.confirm(conf.substring(6,conf.length));
		document.Form1.ConfirmResult.value = result.toString();
		doc.Form1.submit();
			
					}
		         			}

function LastWord(){
					Letra=window.event.keyCode;
					if(Letra==219){
					document.Form1.word.value="";}
					else{
					document.Form1.word.value=document.Form1.word.value+Letra}
					}

function WinPopUp(website,winwidth, winheight) {
		var heightspeed =35; 
		var widthspeed = 15;  
		var leftdist = screen.width/2-160;    
		var topdist = screen.height/2-120;    
		//var winwidth = 515;
		//var winheight = 165;
			var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=auto, title=''");
		for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
		sizer.resizeTo("1", sizeheight);
		}
		for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
		sizer.resizeTo(sizewidth, sizeheight);
		}
		sizer.location = website;
		}

function WinThrill(vent,i,j){
		if (i<10){
		vent.moveTo(j+10,j)
		vent.moveTo(j,j+10)
	    vent.moveTo(j+10,j+10)
		vent.moveTo(j,j)
		i++;
		}
		o=i;
		p=j;
		mivent=vent
		setTimeout("WinThrill(mivent,o,p);",10)
		}		
		
function ZoomIn() {
	if(window.parent.document.body.style.zoom!=0) {window.parent.document.body.style.zoom*=1.6;} else {window.parent.document.body.style.zoom=1.6};
	}
	
function ZoomOut() {
	if(window.parent.document.body.style.zoom!=0) {window.parent.document.body.style.zoom*=0.625;} else {window.parent.document.body.style.zoom=0.625};
	}

function ZoomInMain() {
	if(window.parent.frames('main').document.body.style.zoom!=0) {window.parent.frames('main').document.body.style.zoom*=1.6;} else {window.parent.frames('main').document.body.style.zoom=1.6};
	}

function ZoomOutMain() {
	if(window.parent.frames('main').document.body.style.zoom!=0) {window.parent.frames('main').document.body.style.zoom*=0.625;} else {window.parent.frames('main').document.body.style.zoom=0.625};
	}

function fKeyCopyFromTop() {
		        try{
					if(document.getElementById("wfKey").value==""){
						document.getElementById("wfKey").value=window.parent.frames("top").Form1.wfKey.value;
						Form1.submit();
													}
			       }
		       catch(er){
				   document.getElementById("wfKey").value="ERR";
				  Form1.submit();
						}
					}
											
function RndForDocumentTitle(){
   var Rnd;
   Rnd = Math.random();
   Rnd = Rnd.toString();
   Rnd = Rnd.substring(Rnd.length-5,Rnd.length);
   return Rnd;
	}						

function SearcherSimple(){
	OpenADocument("frmFind.aspx","",705,435);	
	}

function SearcherSimpleWfKey(wfkey){
	OpenADocument("frmFind.aspx?wfKey=" + wfkey,"",705,435);
	}


function OpenADocument(FormName,WinTitle, winWidth, winHeight){

   var theWindowName;
   theWindowName=RndForDocumentTitle();
/*   var leftdist = screen.width/2-160;    
   var topdist = screen.height/2-120;    */
   var leftdist = 10;    
   var topdist = 10;    
   if(WinTitle=="") {WinTitle=theWindowName};   
   var theWindow = window.open("",theWindowName,"fullscreen=no,toolbar=no,left=" + leftdist + ",top=" + topdist + ",width=" + winWidth + ",height=" + winHeight + ",scrollbars=auto, title=" + WinTitle);
   theWindow.location = FormName;
                      }

function OpenModalWindow(Page,Title,Status,Width,Height){
    var Top;
    var Left;
    var Att;
    Top = (((screen.height / 2) - 40) - (Height / 2));
    Left = (((screen.width / 2) - 10) - (Width / 2));
	Att = "fullscreen=no,toolbar=no,location=no,directories=no,status=" + Status + ",menubar=no,scrollbars=no,width=" + Width + ",height=" + Height + ",top=" + Top + ",left=" + Left;
    window.ShowModalDialog(Page,Title,Att);
}

function ReportViewer(){
("frmViewReport.aspx","TBS - Report Viewer",950,800);
  }
  
function frmMail(wfKey){

   var theWindowName;
   theWindowName=RndForDocumentTitle();

   window.open("frmMail.aspx?wfKey=" + wfKey,theWindowName,"fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=815,height=550");
                   }    

function ChangeStatusWFKey(wfKey)
	{
   var Rnd;
   Rnd = Math.random();
   Rnd = Rnd.toString();
   Rnd = Rnd.substring(Rnd.length-5,Rnd.length);
   window.open("frmSC.aspx?wfKey=" + wfKey,Rnd,"fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=700,height=285,top=210,left=210");
	}
	
function SearcherByField(wfkey){
	//OpenADocument("frmFindbyField.aspx?wfKey=" + wfkey,"",612,355);
	OpenADocument("frmFindbyField.aspx?wfKey=" + wfkey,"",800,410);
	}

function LogUserOut()
    {
    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    var sPage2 = sPath.substring(0,sPath.lastIndexOf('/') + 1)
    var tt = window.location.protocol + "//" + window.location.host + sPage2 + "SessionExpired.aspx";
    window.location = tt;
    }
    
function AlertSessionTimeout()
        {        
        ExtendSession()
            //Timer = setTimeout("closeWin()", 30000);
            //if (window.confirm('Your session will be timeout in one minute, do you want to extend it?'))
            //{
                //clearTimeout(iTimer);
            //    window.location = window.location;
            //}
            //else
            //{
                //clearTimeout(iTimer);
                //window.location = "Default.aspx";
            //}
            
        }
function CloseDiv()
    {
    try
        {
        window.location = "SessionExpired.aspx";
        }
    catch(er)
        {
        }
    }
            
function StayConnected()
    {
    try
        {
        window.location = window.location;
     
        }
    catch(er)
        {
        }
    }
            
function ExtendSession()
    {
    try
        {
    
    var browser = navigator.appName;
    if (navigator.appName.indexOf('Microsoft') != -1)
          browser = 'IE'
     //else if (navigator.appName.indexOf('Netscape') != -1)
       //   browser = 'Netscape'
     else browser = 'FF';
     
   //if (browser == 'IE')
   //     {
        //var div = document.createElement('img');
        //div.id = 'loadingdiv'; 
        div = document.getElementById("divcover");
        //div.cssclass = "divblock";
        div.visible= true;
        //div.src = 'images/loadingback.gif';
        div.style.width = document.body.scrollWidth - 5;
        div.style.height = document.body.scrollHeight;    
        //div.innerHTML ='<div><br/><br/><br/><br/><br/><br/><br/><br/><br/><div style=" color:Black; width:60%;background-color:White">Your session is about to expire. Do you want to extend your session?<br/> <br/> <input  type="button" onclick="StayConnected()" value="Yes" /> || <input  type="button" onclick="CloseDiv()" value="No" /></div> </div>';
        div.style.display = "block";
        div.style.backgroundColor = "Gray";
        
        
        if (browser == 'IE')
            {
            div.style.filter = 'alpha(opacity=50)';    
            }
        if (browser == 'FF')
            {    
            div.style.opacity = 0.50;       
            }
        
        div.style.verticalAlign = "middle";
        div.style.textAlign = "center";
        div.style.top = "5";
        div.style.left = "5";
        div.style.position = "absolute";
        div.style.zIndex = 0;
        
        //document.appendChild(div);
        var div2 = document.getElementById("divtopcover");
        var t1 = (document.body.scrollWidth / 2);
        var t2 = (document.body.scrollHeight / 6);
        div2.style.backgroundColor = "White";
        div2.innerHTML ='<div style=" color:Black; width:60%;background-color:White"><br/>Your session is about to expire. Do you want to extend your session?<br/> <br/> <input  type="button" onclick="StayConnected()" value="Yes" /> || <input  type="button" onclick="CloseDiv()" value="No" /><br/></div>';
        div2.style.display = "block";
        div2.style.verticalAlign = "middle";
        div2.style.textAlign = "center";
        div2.style.top = t2;
        div2.style.left = t1;
        div2.style.position = "absolute";
        div2.style.zIndex = 1;
        
        
    //    }
        
    
    
        }
    catch(er)
        {
        }
    }

function closeWin()
    {
    window.location = "Default.aspx";
    }

    
function wfFormLoad(WithGridFoot){

					try
					    {
					    //AlertSessionTimeout()
					    }
					    catch(er)
						{}
						
						
					try 
						{
				        if  (document.getElementById("sctotal") != null)
                            {
                            if (document.getElementById("sctotal").value != "")
                                {
                                document.getElementById("MainScTotal").value = document.getElementById("sctotal").value;
                                }
                            }
    					   
    					}    
						catch(er)
						{}
						
					try 
						{
							document.Form1.KeyPressed.value="";
						}
						catch(er)
						{}
						
					try 
					{
						
						 
					if (document.getElementById){ //NS4
                         
                           UnBlockIt();
                            }
                    else { //IE4
                            
                        }   
                    
					}
					catch(er)
						{}
							
					if (WithGridFoot=="Y"){
							loadgridfoot1(document.getElementById('wfKey').value);
						}
				    
				    try
				    {
				        if (document.getElementById("lbText").value=="CLOSETOCALLER")
				                  {
						    //window.self.opener.location.href="frmProducts01.aspx?wfKey=" + document.getElementById("CallerwfKey").value;
						    window.close();
						    var tt = window.self.opener.location.protocol + "//" + window.self.opener.location.host + window.self.opener.location.pathname + "?Wfkey=" + document.getElementById("CallerwfKey").value;
						    window.self.opener.location.href = tt;
						   
						          }
    				}
    				catch(er)
						{}
					
					try
					{
					if (document.getElementById("lbSearch").value=="")
						{
                            document.getElementById("lbSearch").value="*";
                            SearcherSimpleWfKey(document.getElementById("wfKey").value);
                        }                        

					if (document.getElementById("lbSearch").value=="FIELD")
						{
                            document.getElementById("lbSearch").value="*";
                            SearcherByField(document.getElementById("wfKey").value) ;
                        }                     
                                                
                    if (document.getElementById("lbSearch").value=="SC")
						{
                            document.getElementById("lbSearch").value="*";
                            ChangeStatusWFKey(document.getElementById("wfKey").value);
                        }       
                   
                   if (document.getElementById("lbSearch").value=="ADDSTOCK")
					{
				        window.open("frmStocks.aspx","Stock","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,width=800,height=600");
						document.getElementById("lbSearch").value="*";}
				
				   if (document.getElementById("lbSearch").value=="SENDMAIL")
					{
				        window.open("sendmail.aspx","sendmail","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,width=650,height=550");
						document.getElementById("lbSearch").value="*";}
						   
						   
                   if (document.getElementById("lbSearch").value=="TEMPLATES")
					{
				        window.open("frmRunTemplates.aspx?wfKey=" + document.getElementById("wfKey").value,"Templates","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,width=800,height=250");
						document.getElementById("lbSearch").value="*";}

                   if (document.getElementById("lbSearch").value=="LOGS")
					{
				        window.open("frmLogs.aspx?wfKey=" + document.getElementById("wfKey").value,"Logs","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=800,height=500");
						document.getElementById("lbSearch").value="*";}

				   if (document.getElementById("lbSearch").value=="PREVIEWPX")
					{
				        window.open("frmPreviewPH.aspx?wfKey=" + document.getElementById("wfKey").value,"PreviewPh","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=800,height=600");
						document.getElementById("lbSearch").value="*";}
						
						
                    if (document.getElementById("lbSearch").value=="SCMASS")
						{
						var Rnd;
						Rnd = Math.random();
						Rnd = Rnd.toString();
						Rnd = Rnd.substring(Rnd.length-5,Rnd.length);
						   
                            document.getElementById("lbSearch").value="*";
                            window.open("frmSC.aspx?wfKey=" + document.getElementById("wfKey").value + "&p=" + Rnd ,"SCMASS","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=700,height=285,top=210,left=210");
                        }       


    				if(document.getElementById("lbSearch").value=="CLOSE")
    					{
							window.close();
							try{
								 window.self.opener.location.href=document.Form1.lblRetTo.value;}
							catch(er){}
											  
						}              

    				if(document.getElementById("lbSearch").value=="CLOSEMSGBEFORE")
    					{
    						writestatus(Form1.stMsg);                                                                                 
							window.close();
							try{
								 window.self.opener.location.href=document.Form1.lblRetTo.value;}
							catch(er){}
							return				  
						}              

                    if(document.getElementById("lbSearch").value=="HELP")
						{
							document.getElementById("lbSearch").value="*";
							openHelp();		
						}						

                            
					if (document.getElementById("lbSearch").value=="RUNREPORT")
						{
//							OpenCustomWindow("frmViewReport.aspx?&wfKey=" + document.getElementById("wfKey").value,"VREPORT","yes",800,600);
//							window.open("frmViewReport.aspx","VREPORT","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600");
							window.open("frmViewReport.aspx?&wfKey=" + document.getElementById("wfKey").value,"VREPORT","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600");
							
							//OpenCustomWindow("frmViewReport.aspx","VREPORT","yes",800,600);
							document.getElementById("lbSearch").value="*";
						}    
					
                    if (document.getElementById("lbSearch").value=="QRYBUILDER")
						{
                            document.getElementById("lbSearch").value="*";
                            qrybuilder();                            
                        }

					if(document.getElementById("lbSearch").value=="XMLINGRID")
						{
							document.getElementById("lbSearch").value="*";
							xmlview();
						}			

					if (document.getElementById("lbSearch").value=="MAIL"){
                            OpenCustomWindow("frmMail.aspx?wfKey=" + document.getElementById("wfKey").value,"Mail","no",815,550);
                            document.getElementById("lbSearch").value="*";
                            }
                    
                    if (document.getElementById("lbSearch").value=="RELATE")
					{
						OpenCustomWindow("frmRelations.aspx?wfKey=" + document.Form1.wfKey.value,"Sel","yes",805,440);
						document.getElementById("lbSearch").value="*";
					}
                            
                    if (document.getElementById("lbSearch").value=="RATESH"){
                            OpenCustomWindow("frmRatesDetail.aspx?wfKey=" + document.getElementById("wfKey").value,"RatesH","no",800,270);
                            document.getElementById("lbSearch").value="*";
                            } 
                    if (document.getElementById("lbSearch").value=="IND"){
                            OpenCustomWindow("frmIndexes.aspx?wfKey=" + document.getElementById("wfKey").value,"RatesH","no",800,270);
                            document.getElementById("lbSearch").value="*";
                            }         
                    if (document.getElementById("lbSearch").value=="ATTACH")
						{
                            document.getElementById("lbSearch").value="*";
                            attachdoc();                            
                        } 															  

					if(document.getElementById("lbSearch").value=="CITY")
						{
							document.getElementById("lbSearch").value="*";
							window.open("frmAddCities.aspx?wfKey=" + document.getElementById("wfKey").value ,"AddCTy","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=515,height=165,top=302,left=275");
						}
						
					if(document.getElementById("lbSearch").value=="NEIG")
						{
							document.getElementById("lbSearch").value="*";
							window.open("frmAddNeighBorHood.aspx?wfKey=" + document.getElementById("wfKey").value ,"AddNeighBorHood","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=515,height=165,top=302,left=275");
						}													  
						
					 if(document.getElementById("lbSearch").value=="STATE")
						{
							document.getElementById("lbSearch").value="*";
							WinPopUp("frmAddStates.aspx?wfKey=" + document.getElementById("wfKey").value ,515,165);
                 		}													  
                 		
					 if(document.getElementById("lbSearch").value=="COUNTRY")
						{
							document.getElementById("lbSearch").value="*";
							window.open("frmAddCountries.aspx?wfKey=" + document.getElementById("wfKey").value,"AddCountries","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=515,height=165,top=302,left=275");
						}	
						
					 if(document.getElementById("lbSearch").value=="PERMONTB")
					 {
					 document.getElementById("lbSearch").value="*";
					 OpenCustomWindow("frmPermOnTb.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmPermOnTb","no",800,600);
					 } 
	               
	                 if(document.getElementById("lbSearch").value=="ADDQUERIES")
						{
							document.getElementById("lbSearch").value="*";
							window.open("frmAddQueries.aspx?wfKey=" + document.getElementById("wfKey").value,"AddQueries","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=600,height=270,top=302,left=275");
						}	
					 if(document.getElementById("lbSearch").value=="OLDCLOSE")
						{
						try{
//								window.self.opener.location.href=document.Form1.lblRetTo.value;
							window.self.opener.location.href=window.self.opener.location.href;
							}
							catch(er){}
						window.close();
						}
									
                      if (document.getElementById("lbSearch").value=="CLOSETOGRIDFOOT")
						{
						try{
                           window.self.opener.location.href=window.self.opener.location.href;
    
							}
						catch(er){}
						window.close();
						}   
                            
	                 if (document.getElementById("lbSearch").value=="TITLES")
						{
                            document.getElementById("lbSearch").value="*";
                            window.open("frmAddTitles.aspx?wfKey=" + document.getElementById("wfKey").value,"AddTitles","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=515,height=165,top=302,left=275");
                        }
                            

					 if(document.getElementById("lbSearch").value=="ADDRESS")
						{
							OpenCustomWindow("frmAddresses.aspx?wfKey=" + document.getElementById("wfKey").value,"ADDRESSES","no",720,350);
							document.getElementById("lbSearch").value="*";
						}			
					
					if(document.getElementById("lbSearch").value=="ENTITY")
						{
							OpenCustomWindow("frmEntities.asp?wfKey=" + document.getElementById("wfKey").value,"ENTITIY","no",800,600);
							document.getElementById("lbSearch").value="*";
						}
						
					if(document.getElementById("lbSearch").value=="CONFIRMINNUMBER")
						{
							document.getElementById("lbSearch").value="*";
                            window.open("frmConfirm.aspx?wfKey=" + document.getElementById("wfKey").value,"CONFIRMPRINTING","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,width=515,height=165,top=302,left=275");
                      
						}
					
					if(document.getElementById("lbSearch").value=="CONFIRMDELETE")
						{
							document.getElementById("lbSearch").value="*";
                            window.open("frmConfirmDelete.aspx?wfKey=" + document.getElementById("wfKey").value,"CONFIRMDELETE","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,width=400,height=110,top=302,left=160");
                      
						}
							
                      if (document.getElementById("lbSearch").value=="**")
						{
                            document.getElementById("lbSearch").value="*";
                            /*refresh();*/
						}
																			      
                      if (document.getElementById("lbSearch").value=="PICTURE")
						{
							OpenCustomWindow("frmPicture.aspx?wfKey=" + document.getElementById("wfKey").value,"Pictures","no",800,350);
							document.getElementById("lbSearch").value="*";
						}                    

					  if (document.getElementById("lbSearch").value=="PICTUREADD")
						{
							OpenCustomWindow("frmPictureAdd.aspx?wfKey=" + document.getElementById("wfKey").value,"Pictures","no",365,210);
						}

					  if(document.getElementById("lbSearch").value=="PCKCITY")
						{
							OpenCustomWindow("FrmPckCity.aspx?wfKey=" + document.getElementById("wfKey").value,"Pick a City","no",440,130);
							document.getElementById("lbSearch").value="*";
						}	
												
					  if(document.getElementById("lbSearch").value=="DESCRIP")
						{
							OpenCustomWindow("FrmDescrip.aspx?wfKey=" + document.getElementById("wfKey").value,"Descriptions","no",700,500);
							document.getElementById("lbSearch").value="*";
						}	

					  if (document.getElementById("lbSearch").value=="PCKSC"){
                            OpenCustomWindow("FrmPckSc.aspx?wfKey=" + document.getElementById("wfKey").value,"PckSC","no",450,200);
                            document.getElementById("lbSearch").value="*";
							}

                      if (document.getElementById("lbSearch").value=="FNDCOUNTRYSTATE"){
                            OpenCustomWindow("frmfndcountrystate.aspx?wfKey=" + document.getElementById("wfKey").value,"PckSC","no",300,150);
                            document.getElementById("lbSearch").value="*";
                            }

					  if (document.getElementById("lbSearch").value=="MAIL"){
                            OpenCustomWindow("frmMail.aspx?wfKey=" + document.getElementById("wfKey").value,"Mail","no",815,550);
                            document.getElementById("lbSearch").value="*";
                            }

					  if (document.getElementById("lbSearch").value=="EMAILSENDER"){
							OpenCustomWindow("frmMailSender.aspx?wfKey=" + document.getElementById("wfKey").value,"","no",711,100);  
							document.getElementById("lbSearch").value="*";
							}
							
					  if(document.getElementById("lbSearch").value=="PERIODS")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmPeriods.aspx?wfKey=" + document.getElementById("wfKey").value,"Periods","no",400,215);
							}	

                       if (document.getElementById("lbSearch").value=="CXBRIEF")
							{
	                            OpenCustomWindow("frmAxCxBrief.aspx?wfKey=" + document.getElementById("wfKey").value,"Mail","no",815,320);
		                        document.getElementById("lbSearch").value="*";
                            }
                            
                       if (document.getElementById("lbSearch").value=="AXBRIEF")
							{
	                            OpenCustomWindow("frmAxCxBrief.aspx?wfKey=" + document.getElementById("wfKey").value,"Mail","no",815,320);
		                        document.getElementById("lbSearch").value="*";
                            }

					   if (document.getElementById("lbSearch").value=="EDITAX")
							{
								//OpenCustomWindow("frmAx01.aspx?wfKey=" + document.getElementById("wfKey").value,"EDITAX01","yes",801,600);
								OpenCustomWindow("frmAx01.asp?wfKey=" + document.getElementById("wfKey").value,"EDITAX01","yes",801,600);
								document.getElementById("lbSearch").value="*";
							}  
				                
                
					   if (document.getElementById("lbSearch").value=="EDITCX")
							{
								//OpenCustomWindow("frmCx01.aspx?wfKey=" + document.getElementById("wfKey").value,"EDITCX01","yes",801,600);
								OpenCustomWindow("frmCx01.asp?wfKey=" + document.getElementById("wfKey").value,"EDITCX01","yes",801,600);
								document.getElementById("lbSearch").value="*";
							}   
					   if ((document.getElementById("lbSearch").value=="MOVETO") || (document.getElementById("lbSearch").value=="ASS"))
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmAssignTo.aspx?Wfkey=" + document.getElementById("wfKey").value,"AssignTo","no",490,224);
							}   	
						if (document.getElementById("lbSearch").value=="QUICKSEARCH")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmQuickSearch.aspx?Wfkey=" + document.getElementById("wfKey").value,"AssignTo","no",500,440);
							}   							

						if (document.getElementById("lbSearch").value=="ACTCOUNT")
							{
	                            OpenCustomWindow("frmActCount.aspx?wfKey=" + document.getElementById("wfKey").value,"ACTCOUNT","no",815,320);
		                        document.getElementById("lbSearch").value="*";
                            }
                            
						if (document.getElementById("lbSearch").value=="GRDZOOM")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmgrdZoom.aspx?Wfkey=" + document.getElementById("wfKey").value,"Grid's Zoom","no",700,500);
							}   							

						if(document.getElementById("lbSearch").value=="CODADD")
							{
								OpenCustomWindow("frmAddRelationCode.aspx?wfKey=" + document.getElementById("wfKey").value,"AddCod","yes",801,600);
								document.getElementById("lbSearch").value="*";
							}
							
						if(document.getElementById("lbSearch").value=="COD1")
							{
								OpenCustomWindow("frmCodeAdd.aspx.aspx?wfKey=" + document.getElementById("wfKey").value,"Code1","yes",801,600);
								document.getElementById("lbSearch").value="*";
							}
							
						if(document.getElementById("lbSearch").value=="COD2")
							 {
								OpenCustomWindow("frmCodeAdd.aspx.aspx?wfKey=" + document.getElementById("wfKey").value,"Code2","yes",801,600);
								document.getElementById("lbSearch").value="*";
							 }

						if(document.getElementById("lbSearch").value=="FRMDTL2")
							{

								document.getElementById("lbSearch").value="*";
						        OpenCustomWindow("frmFormsDtl2.aspx?wfKey=" + document.getElementById("wfKey").value,"FormsDtl2","no",800,350);
							} 


                       if(document.getElementById("lbSearch").value=="TBCOMP")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmtbComp.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmTbCOmp","no",700,600);
							} 
							
                       if(document.getElementById("lbSearch").value=="PERMONTB")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmPermOnTb.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmPermOnTb","no",800,400);
							} 
							
                       if(document.getElementById("lbSearch").value=="PERMTEST")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmPermissionTest.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmPermissionTest","no",800,600);
							} 				

						if (document.getElementById("lbSearch").value=="GRDEXP")
							{
								document.getElementById("lbSearch").value="*";
								if (document.Form1.grdLastExport.value!="")
								{
									OpenCustomWindow(document.Form1.grdLastExport.value + "?Wfkey=" + document.getElementById("wfKey").value,"Grid's Export","yes",700,500,"yes","yes","no","yes","yes","yes","yes");
								}
							}   							

						if(document.getElementById("lbSearch").value=="TREENODE")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmTreeNodes.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmTreeNodes","no",600,230);
							} 
							
						if(document.getElementById("lbSearch").value=="TOOLCOMP")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmToolComp.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmToolComp","no",600,280);
							} 
			 

						if(document.getElementById("lbSearch").value=="PROPCLASSES")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmPropClasses01.aspx?wfKey=" + document.getElementById("wfKey").value,"frmPropClasses01","no",820,550);
							} 

						if(document.getElementById("lbSearch").value=="BDGLIST")
							{
								document.getElementById("lbSearch").value="*";
//								OpenCustomWindow("frmBdgList.aspx?wfKey=" + document.getElementById("wfKey").value,"frmBdgList","no",300,230);
								//WinPopUp("frmBdgList.aspx?wfKey=" + document.getElementById("wfKey").value,468,400);
								WinPopUp("frmBdg.aspx?wfKey=" + document.getElementById("wfKey").value,468,400);
							}   

        				if (document.getElementById("lbSearch").value=="BDG")
		        			{
				    		window.open("frmBdg.aspx?wfKey=" + document.Form1.wfKey.value,"Bdg","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,width=355,height=120");
					    	document.getElementById("lbSearch").value="*";}

						if(document.getElementById("lbSearch").value=="RELATEDDATALIST")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmRelatedDataList.aspx?wfKey=" + document.getElementById("wfKey").value,"frmRelatedDataList","no",850,530);
							} 

						if(document.getElementById("lbSearch").value=="PTDTL")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmPropTrackDtl01.aspx?wfKey=" + document.getElementById("wfKey").value,"frmPropTrackDtl01","no",807,540);
							} 

						if(document.getElementById("lbSearch").value=="PTDTLABM")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmPropTrackDetailABM.aspx?wfKey=" + document.getElementById("wfKey").value,"frmPropTrackDetailABM","no",570,220);
							} 

						if(document.getElementById("lbSearch").value=="IPSDLIST")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmIPSDList.aspx?wfKey=" + document.getElementById("wfKey").value,"frmIPSDList","no",807,545);
							} 


						if(document.getElementById("lbSearch").value=="COMP")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmComp.aspx?wfKey=" + document.getElementById("wfKey").value,"FrmTbComp","no",550,280);
							} 
          
						if(document.getElementById("lbSearch").value=="CODES")
							{
								document.getElementById("lbSearch").value="*";
								OpenCustomWindow("frmCodes.aspx?wfKey=" + document.getElementById("wfKey").value,"frmCodes","no",804,540);
							} 

						if(document.getElementById("lbSearch").value=="LISTSTATUS")
							{
								document.getElementById("lbSearch").value="*";
								window.open("frmListStatus.aspx?wfKey=" + document.getElementById("wfKey").value,"LISTSTATUS","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=850,height=600,top=302,left=275");
							}	
                 		
                 	if(document.getElementById("lbSearch").value=="CLASSES")
						{
							document.getElementById("lbSearch").value="*";
							window.open("frmClasses01.aspx?wfKey=" + document.getElementById("wfKey").value,"Classes","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,ReSizable=yes,width=800,height=600,top=302,left=275");
						}

						if (document.getElementById("lbSearch").value=="OPENAWIN")
							{
								try
									{						
										document.getElementById("lbSearch").value="*";
										var WinName;
										var WinTitle;
										var WinStatus;
										var WinWidth;
										var WinHeight;
										var WinScrollbars;
										var WinToolBar;
										var WinFullScreen;
										var WinMenuBar;
										var WinLocation;
										var WinDirectories;
										var WinResizable;
										WinName=document.Form1.OpenAWin_WinUrl.value;
										WinTitle=document.Form1.OpenAWin_WinTitle.value;
										WinStatus=BitToStr(document.Form1.OpenAWin_WinStatus.value);
										WinWidth=document.Form1.OpenAWin_WinWidth.value;
										WinHeight=document.Form1.OpenAWin_WinHeight.value;
										WinScrollbars=BitToStr(document.Form1.OpenAWin_WinScrollbars.value);
										WinToolBar=BitToStr(document.Form1.OpenAWin_WinToolBar.value);
										WinFullScreen=BitToStr(document.Form1.OpenAWin_WinFullScreen.value);
										WinMenuBar=BitToStr(document.Form1.OpenAWin_WinMenuBar.value);
										WinLocation=BitToStr(document.Form1.OpenAWin_WinLocation.value);
										WinDirectories=BitToStr(document.Form1.OpenAWin_WinDirectories.value);
										WinResizable=BitToStr(document.Form1.OpenAWin_WinResizable.value);
										OpenCustomWindow(WinName + "?Wfkey=" + document.getElementById("wfKey").value,WinTitle,WinStatus,WinWidth,WinHeight,WinScrollbars,WinResizable);
									}
									catch(er)
									{}
							}   							
						}
						catch(er)
						{}
					
						writestatus(document.getElementById("stMsg"));                                                                                 
                        			
					}


function BitToStr(BitValue)
{
	try
		{
		if (BitValue==undefined)
			return "no";
			else
			{ 
				if (BitValue=="1")
					return "yes";
					else
					return "no";
			}
		}
	catch(er)
	{}
}			
		
function FilterGrid(GridName,FieldToSearchName)
       
        {
        try
            {
            var SearchFor = document.getElementById(FieldToSearchName).value;
            var Grid = igtbl_getGridById(GridName);
            //Activate all rows to search for
            
            for (i=0;i<Grid.Rows.length;i++)
                {
                //Grid.Rows.getRow(i).Element.style.backgroundColor = "#96FFFF";
                for (n=0;n<Grid.Rows.getRow(i).cells.length;n++)
                    {
                    
                    Grid.Rows.getRow(i).getCell(n).Element.style.backgroundColor = "";
                    }
	            Grid.Rows.getRow(i).setHidden(false);
	            Grid.Rows.getRow(i).setSelected(false);
                }
                
            if (SearchFor != "")
                {
                    var result;
                    result = Grid.find(SearchFor);
                    //var regExp=new RegExp("^a","i");
		            //var cell=grid.find(regExp);
    		        while(result!=null)
		            {
			            //alert(result.getValue());
			            Grid.setActiveCell(result);
			            var newcell = Grid.getActiveCell();
			            newcell.Element.style.backgroundColor = "#96FFFF";
                        
                        
                        var GridRow = Grid.getActiveRow();
                        GridRow.setSelected(true);
                        
			            result=Grid.findNext(SearchFor);
		            }

                    for (i=0;i<Grid.Rows.length;i++)
	                {
	                    if (Grid.Rows.getRow(i).getSelected()!=true)
	                    {    
		                    Grid.Rows.getRow(i).setHidden(true);
		                }
	                }
                 }
             
            }
        catch(er)
            {
            
            }
        }
function AddRow(FromGridName,ToGridName,phId)
        {
        try
            {
            var FromGrid = igtbl_getGridById(FromGridName);
            var ToGrid = igtbl_getGridById(ToGridName);
            var FromGridRow = FromGrid.getActiveRow();
		    
		    var prId = FromGridRow.getCellFromKey("prId").getValue();	
		    var prSDescrip = FromGridRow.getCellFromKey("prSDescrip").getValue();	
		    var deText = FromGridRow.getCellFromKey("deText").getValue();	
		    var Qtty = FromGridRow.getCellFromKey("Qtty").getValue();	
		    var Price = FromGridRow.getCellFromKey("Price").getValue();	
		    
		    var whId = FromGridRow.getCellFromKey("whId").getValue();
		    
		    var taxId = FromGridRow.getCellFromKey("tdTax").getValue();
		    var taxRate = FromGridRow.getCellFromKey("tdPercentage").getValue();
		    var TAmount = FromGridRow.getCellFromKey("Total").getValue();
		    var StockQtty = FromGridRow.getCellFromKey("StockQtty").getValue();
		    var FromWareHouse = FromGridRow.getCellFromKey("whId").getValue();
		    var ToWareHouse = document.getElementById("cmbToWarehouse").value;
		    
		    var RateWithTax = Price + (Price * taxRate);
		    var TaxAmount = Price * taxRate;  	
		    var pdBAmount = RateWithTax * Qtty;
		    
	    	var OrderGrid = igtbl_getGridById("Grid");
	    	igtbl_addNew(ToGridName,0)
	    	
	    	var ToGridRow = ToGrid.getActiveRow();
	        
            ToGridRow.getCellFromKey("pdId").setValue(0);	
            ToGridRow.getCellFromKey("phId").setValue(phId);	
		    ToGridRow.getCellFromKey("pdRelId").setValue(prId);	
		    ToGridRow.getCellFromKey("prSDescrip").setValue(prSDescrip);	
		    ToGridRow.getCellFromKey("deText").setValue(deText);	
		    ToGridRow.getCellFromKey("pdQtty").setValue(Qtty);	
		    ToGridRow.getCellFromKey("pdRate").setValue(Price);	
		    ToGridRow.getCellFromKey("pdTax").setValue(TaxAmount);
		    ToGridRow.getCellFromKey("RateWithTax").setValue(RateWithTax);
		    ToGridRow.getCellFromKey("pdBAmount").setValue(pdBAmount);	
		    ToGridRow.getCellFromKey("TaxAmount").setValue(TaxAmount);	
		    ToGridRow.getCellFromKey("TotalAmount").setValue(TAmount);	
		    ToGridRow.getCellFromKey("StockQtty").setValue(StockQtty);	
		    ToGridRow.getCellFromKey("FromWareHouse").setValue(FromWareHouse);	
		    ToGridRow.getCellFromKey("ToWareHouse").setValue(ToWareHouse);	
		    
		    CalculateTotal(ToGridName,"TotalAmount","txtTotal");
            }
        catch(er)        
            {
            
            }
        }

function DeleteRow(GridName,ColId,StoreIdsInField,SumCelName,SumFieldName)
    {
    try
        {
        var Grid = igtbl_getGridById(GridName);
        var GridRow = Grid.getActiveRow();
        var Ids = GridRow.getCellFromKey(ColId).getValue();
        var NewValue = document.getElementById(StoreIdsInField).value;
        
        
        if (NewValue==0)
            {
            document.getElementById(StoreIdsInField).value = Ids;
            }
        else
            {
            
            document.getElementById(StoreIdsInField).value = NewValue+","+Ids;
            }
        
	    GridRow.deleteRow(GridRow);
	    
	    CalculateTotal(GridName,SumCelName,SumFieldName);
        }
    catch(er)
        {
        }
    }

function calculate(GridName)
    {
    try
        {
        var Grid = igtbl_getGridById(GridName);
        var newcell = Grid.getActiveCell();
        var GridRow = Grid.getActiveRow();
        var Qtty = GridRow.getCellFromKey("Qtty").getValue();
        var Price = GridRow.getCellFromKey("Price").getValue();
        var Result = Qtty * Price;
        
        var Total = GridRow.getCellFromKey("Total").setValue(Result); 
        var column = igtbl_getColumnByKey("Total");
        //column.setFooterText(GrandTotal);
        }
    catch(error)
        {
        //
        }
    }
    
function CalculateTotal(GridName,CelName,FieldName)
    {
    try
        {
        var Total = 0;
        var Grid = igtbl_getGridById(GridName);
        for (i=0;i<Grid.Rows.length;i++)
	        {
	        if (Grid.Rows.getRow(i).getSelected()!=true)
	            {    
	            var GridRow = Grid.Rows.getRow(i);
		        Total = Total + GridRow.getCellFromKey(CelName).getValue();
		        }
	        }
	                
        document.getElementById(FieldName).value = Total;
        }
    catch(error)
        {
        }
    }
function OpenWindowFromGrid(GridName)
    {
    try
        {
        var Grid = igtbl_getGridById(GridName);
        var GridRow = Grid.getActiveRow();
        var IdCol = GridRow.getCellFromKey("IdCol").getValue();
        var WindowName = GridRow.getCellFromKey("WindowName").getValue();
        //var WindowName = "frmGLList.aspx";
        var WindowTitle = GridRow.getCellFromKey("WindowTitle").getValue();
        //var WindowTitle = "Hola";
        var WindowWidth = GridRow.getCellFromKey("WindowWidth").getValue();
        //var WindowWidth = "600";
        var WindowHeight = GridRow.getCellFromKey("WindowHeight").getValue();
        //var WindowHeight = "400";
        var WindowHeight = GridRow.getCellFromKey("WindowHeight").getValue();
        var Id = GridRow.getCellFromKey(IdCol).getValue();
        
        window.open(WindowName+"?ClassProps=doId-"+Id,WindowTitle,"fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,WindowWidth,WindowHeight,validateRequest=false");
        //window.open(WindowName+"?wfKey="+document.getElementById("wfKey").value,WindowTitle,"fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,WindowWidth,WindowHeight");
        //document.getElementById("wfKey").value
        //window.open("http://www.clarin.com","Bdg","fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=355,height=120");
        }
    catch (e)
        {
        }    
    }
    
  
  
function CalculateTax(){
	try 
		{
	    var sel = document.getElementById("InStore").status;
	    var taxrate = document.getElementById("taxrate").value;
	    var taxtotal;
	    if (sel == true)
	        {
	        document.getElementById("cmbBCountries").bcRequired = false;
	        document.getElementById("cmdBState").bcRequired = "false";
	        document.getElementById("txtBCity").bcRequired = "False";
	        document.getElementById("txtBStreet").bcRequired = false;
	        
	        
	        document.getElementById("cmbSCountries").bcRequired = false;
	        
	        var ordertotal = document.getElementById("txtAmount").value;    
	        taxtotal = ordertotal * taxrate;
	        var grandtotal = Math.abs(taxtotal) + Math.abs(ordertotal);
	        document.getElementById("txtTaxTotal").value = taxtotal;    
	        document.getElementById("txtGrandTotal").value = grandtotal;    
	        }
		}
	catch(er)
		{}
    }
    
