//***********************************************************************************
//                                ClientTree.js
//***********************************************************************************

var direction;
//var theme_path = "../theme_1/clienttree/";
//***********************************************************************************
//***********************************************************************************
//r1{
function Set_Sel_Fcombobox1(Combo,Even)
{

 var IU=Get_Element_By_Id(document, Combo);   
 var Sel=0;
 var i=0;
 for (i=0;i<IU.length;i++)
 {
    if (IU[i].selected)
    {
      Sel=i;
      break;
    }
 }
    M_Sub_Server(Even+"$"+Sel,Go_UpdatePanel_No(Combo));
 
}
//*********************************************************
function M_breakerToggleW(base_id,lbl2,lbl)
{
    var s1=this.location.pathname;
    var i1=s1.indexOf('MWebForm');
    var id='';
    if(i1>=0)
    {
        for(var i2=i1+8;i2<i1+14;i2++)
        {
            if((s1.charAt(i2)=='.')||(s1.charAt(i2)=='_'))
            {
                break;
            }
            else id+=s1.charAt(i2);
        }
    }

    var lbl3=document.getElementById(base_id+'id1');
    var lbl4=document.getElementById(base_id+'id2');
    if(lbl3.className.indexOf('collapsed')>0)
    {
        lbl3.className="h_expand_gif";
        lbl4.className="h_expand_gif";
    }
    else
    {
        lbl3.className="h_collapsed_gif";
        lbl4.className="h_collapsed_gif";
    }
    if (typeof lbl == 'string') 
    {
        lbl = document.getElementById(lbl);
    }
    var mf = FindMainForm();
    var x = mf.isNotFast;
    var index = parseInt(lbl.id.substring(13,14));
    var img1 = lbl.getElementsByTagName('img')[0];
    var b = lbl.parentNode.parentNode.parentNode.rows[1];
    var b2 = b;
    var b1 = null;
    var state = b.getAttribute('isshowing');
    if ((index == 1) && (b.innerHTML.indexOf('LinePanel1')>=0))
    {
        b = Get_Element_By_Id(document, 'LinePanel1');
        b1 = Get_Element_By_Id(document, 'LinePanel2');
    }
    if (state)
    {
        b2.removeAttribute('isshowing');
        if (x)
        {
            $(b).css({display:''}).slideUp(mf.speedCommand, function(){M_toggleImage(img1);});
            $(b1).css({display:''}).slideDown(mf.speedCommand, function(){});                            
        }    
        else
        {
            $(b).css({display:''}).hide();
            $(b1).css({display:''}).show();
            //if (b1)
                //b1.scrollIntoView();
        }    
    }
    else
    {
        if (!b2.getAttribute('loaded'))
        {
            b2.setAttribute('loaded', 'true');
            ///M_Sub_Server(id+'_Page_'+index,index);

        }
        b2.setAttribute('isshowing', 'true');            
        if (x)
        {
            $(b1).css({display:''}).slideUp(mf.speedCommand, function(){});
            $(b).css({display:''}).slideDown(mf.speedCommand, function(){M_toggleImage(img1);/*b.scrollIntoView();*/});
        }    
        else
        {
            $(b1).css({display:''}).hide();
            $(b).css({display:''}).show();
            //if (b)
                //b.scrollIntoView();
        }    
    }
    if (!x)
        M_toggleImage(img1);
        
    var lbl = Get_Element_By_Id_3(document, 'chkLock_1');
    if (lbl && !lbl.checked && index > 1)
    {
        b2 = Get_Element_By_Id_3(document, 'Row1');
        if (b2.getAttribute('isshowing'))
        {
            b2.removeAttribute('isshowing');
            b = Get_Element_By_Id(document, 'LinePanel1');
            b1 = Get_Element_By_Id(document, 'LinePanel2');
            
            if (x)
            {
                $(b).css({display:''}).slideUp(mf.speedCommand, function(){M_toggleImage(img1);});
                $(b1).css({display:''}).slideDown(mf.speedCommand, function(){/*b1.scrollIntoView();*/});
            }    
            else
            {
                $(b).css({display:''}).hide();
                $(b1).css({display:''}).show();
                //if (b1)
                    //b1.scrollIntoView();
            }
        }    
    }
}
//r1}
function initTree(treename, direction1)
{
    if (direction1 == undefined)
        direction = "rtl";
    else 
        direction = direction1;    
    var dir;
    var Dir;
    if (direction == "rtl")
    {
        Dir = "Right";
        dir = "right";
    }
    else
    {
        Dir = "Left";
        dir = "left";
    }    
    var firstitem=true;
    treename = document.getElementById(treename);
    treename.setAttribute('align', dir);
    treename.setAttribute('dir', direction);
    var ullist = treename.getElementsByTagName('ul');
    if (ullist.length > 0)
    {
        ullist[0].style.direction = direction;
        ullist[0].style["margin"+Dir] = "0px";          
        for(var i=1;i<ullist.length;i++)
        {
            ullist[i].style.direction = direction;
            ullist[i].style["margin"+Dir] = "0px";          
            ullist[i].style.backgroundPosition = dir+" top";
            ullist[i].className="Tree_line";//style.backgroundImage = "url("+theme_path+"line.gif)";      
        }
    }
    var lilist = treename.getElementsByTagName('li');
    for(var i=0;i<lilist.length;i++)
    {
        var item = lilist[i];
        if(lilist[i].innerHTML.indexOf("<DIV unselectable=")>0)lilist[i].disabled=true;
        var icon;
        if (i == 0) icon = "top";
        else if ((i == lilist.length - 1) || (item == item.parentNode.lastChild)) icon = "bottom";
        else icon = "middle";
        item.icon = icon;
        item.style["padding"+Dir] = "19px";
        var imgpic = document.createElement('div');
        var img_mp = document.createElement('div');
        var imgsrc = item.getAttribute('imagesource');
        if (item.childNodes.length > 1)
        {
            img_mp.onclick = toggle;
            imgpic.ondblclick = toggle;
            if (item.getAttribute('isopen'))
            {
                img_mp.className = /*theme_path +*/ 'h_minus'+item.icon+direction+'_gif';
                imgpic.className = /*theme_path +*/ 'h_'+imgsrc + 'open_gif';
            }
            else 
            {
                img_mp.className = /*theme_path +*/ 'h_plus'+item.icon+direction+'_gif';
                imgpic.className = /*theme_path +*/ 'h_'+imgsrc + 'close_gif';
                item.childNodes[1].style.display = 'none';
            }
            var ne = item.nextSibling;
            if ((ne == null))
            {
                if (isIE)
                {
                    item.getElementsByTagName('ul')[0].style.removeAttribute("backgroundImage");
                }
                else
                {
                    item.getElementsByTagName('ul')[0].style.removeProperty("background-image");                    
                }
            }    
        }
        else 
        {
            img_mp.className = /*theme_path+*/'h_line'+item.icon+direction+'_gif';
            imgpic.className = /*theme_path + */'h_'+imgsrc + "_gif";
        }
        item.getElementsByTagName('tr')[0].insertCell(0).appendChild(imgpic);
        item.getElementsByTagName('tr')[0].insertCell(0).appendChild(img_mp);        
    }       
}
//***********************************************************************************
//***********************************************************************************
function toggle(e)
{
    if (!e) e = window.event;
    var item1 = (window.event) ? e.srcElement.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode : e.target.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
    var tr = item1.getElementsByTagName('tr')[0];
    if (item1.getAttribute('isopen'))
    {
        item1.childNodes[1].style.display = 'none';
        item1.removeAttribute('isopen');
        tr.cells[0].childNodes[0].className = /*theme_path+*/'h_plus'+item1.icon+direction+'_gif';
        tr.cells[1].childNodes[0].className = /*theme_path+*/'h_'+item1.getAttribute('imagesource')+'close_gif';
    }
    else 
    {
        item1.childNodes[1].style.display = 'block';
        item1.setAttribute('isopen','true');
        tr.cells[0].childNodes[0].className = /*theme_path+*/'h_minus'+item1.icon+direction+'_gif';
        tr.cells[1].childNodes[0].className = /*theme_path+*/'h_'+item1.getAttribute('imagesource')+'open_gif';
    }             
}

function Change_Color_Selected(Sel,color)
{
Get_Element_By_Id (document,Sel).style.backgroundColor=color;
}
//***********************************************************************************
//***********************************************************************************
//***********************************************************************************
//                                dhtmlwindow.js
//***********************************************************************************

var dhtmlwindow=
{
    zIndexvalue:100000,
    tobjects: [], 
    temp1:"",
    w:0,
    h:0,
    etarget:null,
    init:function(t,close_show, help_show)
    {
        var styletpath1 = '../Themes/Skin' + GetSkinId() + '/image/';
        
        var	domwindow=FindMainForm().doc.createElement("div");
	    domwindow.id=t;
	    domwindow.style.zIndex=1;
	    domwindow.className="dhtmlwindowS";
	    var domwindowdata='';
	    domwindowdata+='<div class="drag-handle" dir="ltr" align="right">';
	    domwindowdata+='<table cellpadding="0" cellspacing="0" border="0" width="100%" height="18px" style="padding:0px;spacing:0px;top:0px;background-image:url('+styletpath1+'middle1.bmp);"><tr><td class="drag_control_left"><div class="h_left1_bmp" /></td>';
	    
       	domwindowdata+='<td width=100%><input readonly="readonly" id="fns_title_box'+t+'" type="text" value="untitled" style="width:100%;background-color:Transparent; height:18px; clear:both;text-align:center;cursor:move;font-family:Tahoma_f;color:White;border-style:none;top:0px; "/></td>';

	    if (help_show) domwindowdata+='<td dir="rtl" style="padding:2px;top:0;background-image:url('+styletpath1+'middle1.bmp);"><div class="drag-controls1" id='+cid+'_help><div id="help_id" class="h_help_png" width="16px" height="16px" style="display:none" title="راهنمای پنجره" /></div></td>';

	    var cid= "close_div_id_fns"+t;
	    if(close_show) domwindowdata+='<td dir="rtl" style="padding-right:2px;top:0;background-image:url('+styletpath1+'middle1.bmp);"><div class="drag-controls" Onclick="M_CallClose(this._parent);" id='+cid+'><div id="close_id" class="h_close1_gif" title="بستن پنجره (Esc)" /></div></td>'; 

	    domwindowdata+='<td class="drag_control_right"><div class="h_right1_bmp" /></td></tr></table>';
	    domwindowdata+='</div>';
	    domwindowdata+='<div id="contentarea2" class="drag-contentarea"></div>';
	    domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea2" style="background: transparent top right no-repeat;">&nbsp;</div></div>';

	    domwindow.innerHTML=domwindowdata;
        
        domwindow.style.top = FindMainForm().doc.documentElement.scrollTop;
	    FindMainForm().doc.body.appendChild(domwindow);	    
    	
	    var t=FindMainForm().doc.getElementById(t);
	    var divs=t.getElementsByTagName("div");
	    for (var i=0; i<divs.length; i++)
	    { 
		    if (/drag-/.test(divs[i].className))
		    {
			    t[divs[i].className.replace(/drag-/, "")]=divs[i] ;
            }
	    }
   	
	    t.handle._parent=t;
	    t.resizearea2._parent=t;
	    if(help_show) t.controls1._parent=t; 
	    if(close_show) t.controls._parent=t; 
	    t.onclose1=function()
	    {
	       return true
	    } 
	    t.onclose=function()
	    {
	       return true
	    } 
	    t.onmousedown=function()
	    {
	        dhtmlwindow.setfocus(this)
	    } 
	    
	    t.handle.onmousedown=dhtmlwindow.setupdrag;
	    t.resizearea2.onmousedown=dhtmlwindow.setupdrag;
	    if (t.controls1!=undefined) t.controls1.onclick=dhtmlwindow.enablecontrols;
	    if (t.controls!=undefined) t.controls.onclick=dhtmlwindow.enablecontrols;
	    t.close=function()
	    {
	        dhtmlwindow.close(this);
	    } 
	     t.show=function()
	    {
           
	        dhtmlwindow.close(this);
	    } 
	    t.setSize=function(w, h)
	    {
	        dhtmlwindow.setSize(this, w, h);
	    } 
	    t.moveTo=function(x, y)
	    {
	        dhtmlwindow.moveTo(this, x, y);
	    } 
	    t.isResize=function(bol)
	    {
	        dhtmlwindow.isResize(this, bol);
	    } 
	    t.isScrolling=function(bol)
	    {
	        dhtmlwindow.isScrolling(this, bol);
	    } 
	    t.load=function(contentsource, title)
	    {
	        dhtmlwindow.load(this, contentsource, title);
	    } 
	    this.tobjects[this.tobjects.length]=t;
	    return t; 
    },show:function()
    {
    }
    ,hide:function()
    {
    }
    ,
    open:function(t, contentsource, title, attr, recalonload,close_show)
    {
	    function getValue(Name)
	    {
		    var config=new RegExp(Name+"=([^,]+)", "i") 
		    return (config.test(attr))? parseInt(RegExp.$1) : 0 
	    }
	    if (FindMainForm().doc.getElementById(t)==null) 
	    {
		    t=this.init(t,close_show,contentsource.indexOf('WebModalFormMessage')<0) 
	    }
	    else
	    {
		    t=FindMainForm().doc.getElementById(t);
	    }
	    
	    this.setfocus(t)
	    t.setSize(getValue(("width")), (getValue("height"))) 

	    var xpos=getValue("center")? "middle" : getValue("left") 
	    var ypos=getValue("center")? "middle" : getValue("top") 
    	
    	var pf = parent.FindMainForm().doc.body.childNodes[parent.FindMainForm().doc.body.childNodes.length - 1];
    	if (pf.id)
    	{
            if ((pf.id.substring(0,9)=="googlebox") && (t.id != pf.id))
            {
                //parent.FindMainForm().doc.getElementById("close_div_id_fns"+pf.id).style.visibility = "hidden";
            }
        }        
	    if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0)
	    { 
		    if (window.attachEvent && !window.opera) 
		    {
			    this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		    }
		    else
		    {
			    this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	        }
	    }
	    
	    t.isResize(getValue("resize")) 
	    t.isScrolling(getValue("scrolling")) 
	    //t.style.visibility="visible"
	    //t.style.display="none"
	    t.contentarea.style.display="block"
	    t.moveTo(xpos, ypos) 
	    t.load(contentsource, title)
	    return t
    },

    setSize:function(t, w, h)
    { 
	    t['_width'] = parseInt(w);
	    t['_height'] = parseInt(h + 18);
	    t.style.width=Math.max(parseInt(w), 150)+"px";
	    t.contentarea.style.height=Math.max(parseInt(h), 100)+"px";
    },

    moveTo:function(t, x, y)
    { 
	    this.getviewpoint();
	    var w1=0;
	    var h1=0;
	    
	    w1=FindMainForm_ParWin().screen.availWidth;
	    h1=FindMainForm_ParWin().screen.availHeight;
	    var l1=(x=="middle")? (((w1-t._width-this.scroll_left) / 2)+this.scroll_left)  : this.scroll_left+parseInt(x);
	    var h1=(y=="middle")? (((h1-t._height-this.scroll_top) / 2)+this.scroll_top)  : this.scroll_top+parseInt(y);
        if(h1<15)h1=15;
        t.style.left=l1+ "px";
        t.style.top=h1+ "px";
    },

    isResize:function(t, bol)
    { 
	    t.statusarea.style.display=(bol)? "block" : "none"
	    t.resizeBool=(bol)? 1 : 0
    },

    isScrolling:function(t, bol)
    { 
	    t.contentarea.style.overflow=(bol)? "auto" : "hidden"
    },

    load:function(t,contentsource, title)
    { 
	    if (typeof title!="undefined")
	    {
		    t.handle.getElementsByTagName('*')[6].value=title
        }
	    t.contentarea.style.overflow="hidden" 
	    if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") 
	    {
		    t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
	    }
	    FindMainForm_ParWin().frames["_iframe-"+t.id].location.replace(contentsource) 
	    t.contentarea.datatype="iframe"
    },

    setupdrag:function(e)
    {
	    var d=dhtmlwindow 
	    var t=this._parent 
	    if (t==null) t=dhtmlwindow._parent;
	    d.etarget=this 
	    var e=FindMainForm_ParWin().event || e

	    d.initmousex=e.clientX 
	    d.initmousey=e.clientY
	    d.initx=parseInt(t.offsetLeft) 
	    d.inity=parseInt(t.offsetTop)
	    d.width=parseInt(t.offsetWidth) 
	    d.contentheight=parseInt(t.contentarea.offsetHeight) 

		t.style.backgroundColor="#F8F8F8" 
		t.contentarea.style.visibility="hidden"
		t.contentarea.style.display="block"

	    FindMainForm().doc.onmousemove=d.getdistance //FindMainForm().doc2
	    FindMainForm().doc.onmouseup=function()//FindMainForm().doc2
	    {
		    t.contentarea.style.backgroundColor="white";
		    t.contentarea.style.visibility="visible";
	        t.contentarea.style.display="block"
		    d.stop()
	    }
	    return false
    },

    getdistance:function(e)
    {
	    var d=dhtmlwindow
	    var etarget=d.etarget
	    if (etarget==null) etarget=this;
	    var e=FindMainForm_ParWin().event || e

	    d.distancex=e.clientX-d.initmousex 
	    d.distancey=e.clientY-d.initmousey
	    if (etarget.className=="drag-handle"||etarget!==null)
	    { 
		    d.move(etarget._parent, e)
		}
	    else if (etarget.className=="drag-resizearea2") 
	    {
		    d.resize(etarget._parent, e)
		}
	    return false 
    },

    getviewpoint:function()
    { 
	    var ie=FindMainForm().doc.all && !window.opera
	    var domclientWidth=FindMainForm().doc.documentElement && parseInt(FindMainForm().doc.documentElement.clientWidth) || 100000 
	    this.standardbody=(FindMainForm().doc.compatMode=="CSS1Compat")? document.documentElement : document.body 
	    this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	    this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	    this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	    this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
    },

    move:function(t, e)
    {
	    var l1=dhtmlwindow.distancex+dhtmlwindow.initx;
	    var h1=dhtmlwindow.distancey+dhtmlwindow.inity;
        //if(l1<-50)l1=0;
        if(h1<15)h1=15;
        t.style.left=l1+"px";
        t.style.top=h1+"px"; 
    },

    resize:function(t, e)
    {
	    t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
	    t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
    },

    enablecontrols:function(e)
    {
	    var sourceobj=FindMainForm_ParWin().event? FindMainForm_ParWin().event.srcElement : e.target 

	    if (sourceobj.getAttribute("title").indexOf('بستن پنجره')>=0) 
		    M_CallClose(this._parent);
		else if (sourceobj.getAttribute("title").indexOf('راهنمای پنجره')>=0)
		{
		    var p1=window.frames["_iframe-"+this._parent.id].location.pathname;
		    if(p1.indexOf('WebModalForm.aspx')>0)
		    {
		        var p3=window.frames["_iframe-"+this._parent.id].location.search;
		        if(p3.indexOf(',')>0)
		        {
		            var p2=p3.split(',')[0];
		            var p="";
		            if(p2.length>4)
		            {
		                p2=p2.replace('?Id=','');
		                p1=p1.replace('.aspx',p2+'.aspx');
		            }		            
		        }
		    }
		    ShowHelp(p1);
	    }
	    return false
    },

    close:function(t)
    {
        M_removeBackgroundDiv(document, t.id);
        
	    var closewinbol=true;
	    try
	    {
		    t.onclose1();
		    closewinbol=t.onclose()
	    }
	    catch(err)
	    { 
            alert(err.message)
		    closewinbol=true
        }
	    return closewinbol
    },

    setfocus:function(t)
    { 
	    this.zIndexvalue++;
	    t.style.zIndex=this.zIndexvalue;
    },

    stop:function()
    {
	    dhtmlwindow.etarget=null 
	    FindMainForm().doc.onmousemove=null
	    FindMainForm().doc.onmouseup=null
    },

    addEvent:function(target, functionref, tasktype)
    { 
	    var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	    if (target.addEventListener)
		    target.addEventListener(tasktype, functionref, false)
	    else if (target.attachEvent)
		    target.attachEvent(tasktype, functionref)
    },

    cleanup:function()
    {
	    for (var i=0; i<dhtmlwindow.tobjects.length; i++)
	    {
		    dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea2._parent=null;
		    if (dhtmlwindow.tobjects[i].controls!=null) dhtmlwindow.tobjects[i].controls._parent=null;		    
	    }
	    window.onload=null
    }

} 
window.onunload=dhtmlwindow.cleanup
//***********************************************************************************
//                                dhtmlwindow_Main.js
//***********************************************************************************
var dhtmlwindow_Main=
{
    zIndexvalue:100,
    tobjects: [], 
    temp1:"",
    w:0,
    h:0,
    init:function(t,close_show, help_show)
    {
        var styletpath1 = '../Themes/Skin' + GetSkinId() + '/image/';
        
    	var domwindow=document.createElement("div");
	    domwindow.id=t;
	    domwindow.style.zIndex=1;
	    domwindow.className="dhtmlwindowD";
	    //domwindow.title="Dynamic";
	    var domwindowdata='';
	    domwindowdata+='<div class="drag-handle" dir="ltr" align="right">';
	    domwindowdata+='<table cellpadding="0" cellspacing="0" border="0" width="100%" height="18px" style="padding:0px;spacing:0px;top:0px;background-image:url('+styletpath1+'middle1.bmp);"><tr><td class="drag_control_left"><div class="h_left1_bmp" /></td>';
	    
       	domwindowdata+='<td width=100%><input readonly="readonly" id="fns_title_box'+t+'" type="text" value="untitled" style="width:100%;background-color:Transparent; height:18px; clear:both;text-align:center;cursor:move;font-family:Tahoma_f;color:White;border-style:none;top:0px; "/></td>';

	    if (help_show) domwindowdata+='<td dir="rtl" style="padding:2px;top:0;background-image:url('+styletpath1+'middle1.bmp);"><div class="drag-controls1" id='+cid+'_help><div id="help_id" class="h_help_png" style="display:none" title="راهنمای پنجره" /></div></td>';

	    var cid= "close_div_id_fns"+t;
	    if(close_show) domwindowdata+='<td dir="rtl" style="padding-right:2px;top:0;background-image:url('+styletpath1+'middle1.bmp);"><div class="drag-controls" id='+cid+'><div id="close_id" class="h_close1_gif" title="بستن پنجره (Esc)" /></div></td>';

	    domwindowdata+='<td class="drag_control_right"><div class="h_right1_bmp" /></td></tr></table>';
	    domwindowdata+='</div>';
	    domwindowdata+='<div id="contentarea2" class="drag-contentarea"></div>';
	    domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea2" style="background: transparent top right no-repeat;">&nbsp;</div></div>';

	    domwindow.innerHTML=domwindowdata;
        
        domwindow.style.top = document.documentElement.scrollTop;

	    document.body.appendChild(domwindow);	    
    	
	    var t=document.getElementById(t);
	    var divs=t.getElementsByTagName("div");
	    for (var i=0; i<divs.length; i++)
	    { 
		    if (/drag-/.test(divs[i].className))
		    {
			    t[divs[i].className.replace(/drag-/, "")]=divs[i] ;
            }
	    }
   	
	    t.handle._parent=t;
	    t.resizearea2._parent=t;
	    if(help_show) t.controls1._parent=t; 
	    if(close_show) t.controls._parent=t; 
	    t.onclose1=function()
	    {
	       return true
	    } 
	    t.onclose=function()
	    {
	       return true
	    } 
	    t.onmousedown=function()
	    {
	        dhtmlwindow_Main.setfocus(this)
	    } 
	    
	    t.handle.onmousedown=dhtmlwindow_Main.setupdrag;
	    t.resizearea2.onmousedown=dhtmlwindow_Main.setupdrag;
	    if (t.controls1!=undefined) t.controls1.onclick=dhtmlwindow_Main.enablecontrols;
	    if (t.controls!=undefined) t.controls.onclick=dhtmlwindow_Main.enablecontrols;
	    t.close=function()
	    {
	        dhtmlwindow_Main.close(this);
	    } 
	    t.setSize=function(w, h)
	    {
	        dhtmlwindow_Main.setSize(this, w, h);
	    } 
	    t.moveTo=function(x, y)
	    {
	        dhtmlwindow_Main.moveTo(this, x, y);
	    } 
	    t.isResize=function(bol)
	    {
	        dhtmlwindow_Main.isResize(this, bol);
	    } 
	    t.isScrolling=function(bol)
	    {
	        dhtmlwindow_Main.isScrolling(this, bol);
	    } 
	    t.load=function(contentsource, title)
	    {
	        dhtmlwindow_Main.load(this, contentsource, title);
	    } 
	    this.tobjects[this.tobjects.length]=t;
	    return t; 
    },

    open:function(t, contentsource, title, attr, recalonload,close_show)
    {
	    function getValue(Name)
	    {
		    var config=new RegExp(Name+"=([^,]+)", "i") 
		    return (config.test(attr))? parseInt(RegExp.$1) : 0 
	    }
	    if (document.getElementById(t)==null) 
	    {
	        
		    t=this.init(t,close_show,contentsource.indexOf('WebModalFormMessage')<0) 
	    }
	    else
	    {
		    t=document.getElementById(t)
	    }
	    
	    this.setfocus(t)
	    t.setSize(getValue(("width")), (getValue("height"))) 

	    var xpos=getValue("center")? "middle" : getValue("left") 
	    var ypos=getValue("center")? "middle" : getValue("top") 
	    
    	var pf = parent.document.body.childNodes[parent.document.body.childNodes.length - 1];
    	if (pf.id)
    	{
            if ((pf.id.substring(0,9)=="googlebox") && (t.id != pf.id))
            {
                //parent.document.getElementById("close_div_id_fns"+pf.id).style.visibility = "hidden";
            }
        }        
	    if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0)
	    { 
		    if (window.attachEvent && !window.opera) 
		    {
			    this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		    }
		    else
		    {
			    this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	        }
	    }
	    
	    t.isResize(getValue("resize")) 
	    t.isScrolling(getValue("scrolling")) 
	    //t.style.visibility="visible"
	    t.style.display="none"
	    t.contentarea.style.display="block"
	    t.moveTo(xpos, ypos) 
	    t.load(contentsource, title)
	    return t
    },

    setSize:function(t, w, h)
    { 
	    t['_width'] = parseInt(w);
	    t['_height'] = parseInt(h + 18);
	    t.style.width=Math.max(parseInt(w), 150)+"px";
	    t.contentarea.style.height=Math.max(parseInt(h), 100)+"px";
    },

    moveTo:function(t, x, y)
    { 
	    this.getviewpoint();
	    t.style.left=(x=="middle")? ((this.docwidth-t._width) / 2) + "px" : this.scroll_left+parseInt(x)+"px";//+this.scroll_left
	    t.style.top=(y=="middle")? ((this.docheight-t._height) / 2) + "px" : this.scroll_top+parseInt(y)+"px";//+this.scroll_top
	    //t.style.left=(x=="middle")? ((this.docwidth-t._width) / 2 + this.scroll_left) + "px" : this.scroll_left+parseInt(x)+"px";
	    //t.style.top=(y=="middle")? ((this.docheight-t._height) / 2 + this.scroll_top) + "px" : this.scroll_top+parseInt(y)+"px";
    },

    isResize:function(t, bol)
    { 
	    t.statusarea.style.display=(bol)? "block" : "none"
	    t.resizeBool=(bol)? 1 : 0
    },

    isScrolling:function(t, bol)
    { 
	    t.contentarea.style.overflow=(bol)? "auto" : "hidden"
    },

    load:function(t,contentsource, title)
    { 
	    if (typeof title!="undefined")
	    {
		    t.handle.getElementsByTagName('*')[6].value=title
        }
	    t.contentarea.style.overflow="hidden" 
	    if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") 
	    {
		    t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
	    }
	    window.frames["_iframe-"+t.id].location.replace(contentsource) 
	    t.contentarea.datatype="iframe"
    },

    setupdrag:function(e)
    {
	    var d=dhtmlwindow_Main 
	    var t=this._parent 
	    d.etarget=this 
	    var e=window.event || e
	    d.initmousex=e.clientX 
	    d.initmousey=e.clientY
	    d.initx=parseInt(t.offsetLeft) 
	    d.inity=parseInt(t.offsetTop)
	    d.width=parseInt(t.offsetWidth) 
	    d.contentheight=parseInt(t.contentarea.offsetHeight) 

		t.style.backgroundColor="#F8F8F8" 
		t.contentarea.style.visibility="hidden"
		t.contentarea.style.display="block"

	    document.onmousemove=d.getdistance 
	    document.onmouseup=function()
	    {
		    t.contentarea.style.backgroundColor="white";
		    t.contentarea.style.visibility="visible";
	        t.contentarea.style.display="block"
		    d.stop()
	    }
	    return false
    },

    getdistance:function(e)
    {
	    var d=dhtmlwindow_Main
	    var etarget=d.etarget
	    var e=window.event || e
	    d.distancex=e.clientX-d.initmousex 
	    d.distancey=e.clientY-d.initmousey
	    if (etarget.className=="drag-handle")
	    { 
		    d.move(etarget._parent, e)
		}
	    else if (etarget.className=="drag-resizearea2") 
	    {
		    d.resize(etarget._parent, e)
		}
	    return false 
    },

    getviewpoint:function()
    { 
	    var ie=document.all && !window.opera
	    var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 
	    this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
	    this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	    this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	    this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	    this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
    },

    move:function(t, e)
    {
	    t.style.left=dhtmlwindow_Main.distancex+dhtmlwindow_Main.initx+"px"
	    t.style.top=dhtmlwindow_Main.distancey+dhtmlwindow_Main.inity+"px"
    },

    resize:function(t, e)
    {
	    t.style.width=Math.max(dhtmlwindow_Main.width+dhtmlwindow_Main.distancex, 150)+"px"
	    t.contentarea.style.height=Math.max(dhtmlwindow_Main.contentheight+dhtmlwindow_Main.distancey, 100)+"px"
    },

    enablecontrols:function(e)
    {
	    var sourceobj=window.event? window.event.srcElement : e.target 
	    if (sourceobj.getAttribute("title").indexOf('بستن پنجره')>=0) 
		    M_CallClose(this._parent);
		else if (sourceobj.getAttribute("title").indexOf('راهنمای پنجره')>=0)
		{
		    var p1=window.frames["_iframe-"+this._parent.id].location.pathname;
		    if(p1.indexOf('WebModalForm.aspx')>0)
		    {
		        var p3=window.frames["_iframe-"+this._parent.id].location.search;
		        if(p3.indexOf(',')>0)
		        {
		            var p2=p3.split(',')[0];
		            var p="";
		            if(p2.length>4)
		            {
		                p2=p2.replace('?Id=','');
		                p1=p1.replace('.aspx',p2+'.aspx');
		            }		            
		        }
		    }
		    ShowHelp(p1);
	    }
	    return false
    },

    close:function(t)
    {
    	var pf = parent.document.body.childNodes[parent.document.body.childNodes.length - 1];
    	if (pf.id)
    	{
            if ((pf.id.substring(0,9)=="googlebox") && t.id != pf.id)
            {
                var id=parent.document.getElementById("close_div_id_fns"+pf.id);
                if(id !=null)
                {
                    var id1=id.style;
                    if(id1!=null)
                    {
                        id1.visibility = "visible";
                    }
                }
            }
        }
        
        M_removeBackgroundDiv(document, t.id);
        
	    var closewinbol=true;
	    try
	    {
		    t.onclose1();
		    closewinbol=t.onclose()
	    }
	    catch(err)
	    { 
            alert(err.message)
		    closewinbol=true
        }
	    if (closewinbol)
	    { 
//		    if (window.frames["_iframe-"+t.id])
//			    window.frames["_iframe-"+t.id].location.replace("")
//		    else
//			    t.contentarea.innerHTML="";
//		    t.style.display="none";
	    }
//	    t=null;
	    return closewinbol
    },

    setfocus:function(t)
    { 
	    this.zIndexvalue++;
	    t.style.zIndex=this.zIndexvalue;
    },

    stop:function()
    {
	    dhtmlwindow_Main.etarget=null 
	    document.onmousemove=null
	    document.onmouseup=null
    },

    addEvent:function(target, functionref, tasktype)
    { 
	    var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	    if (target.addEventListener)
		    target.addEventListener(tasktype, functionref, false)
	    else if (target.attachEvent)
		    target.attachEvent(tasktype, functionref)
    },

    cleanup:function()
    {
	    for (var i=0; i<dhtmlwindow_Main.tobjects.length; i++)
	    {
		    dhtmlwindow_Main.tobjects[i].handle._parent=dhtmlwindow_Main.tobjects[i].resizearea2._parent=null;
		    if (dhtmlwindow_Main.tobjects[i].controls!=null) dhtmlwindow_Main.tobjects[i].controls._parent=null;		    
	    }
	    window.onload=null
    }

} 
window.onunload=dhtmlwindow_Main.cleanup
//***********************************************************************************
//                                PublicTasks.js
//***********************************************************************************

var nav=navigator.userAgent.toLowerCase();
var isOpera=(nav.indexOf("opera")!=-1)?true:false;
var isOpera5=(nav.indexOf("opera 5")!=-1 || nav.indexOf("opera/5")!=-1)?true:false;
var isOpera6=(isOpera && parseInt(navigator.appVersion)>=6)?true:false;
var isChrome=(nav.indexOf("applewebkit")!=-1);
var isN6=(nav.indexOf("gecko")!=-1) && (!isChrome);
var isN4=(document.layers)?true:false;
var isMac=(nav.indexOf("mac")!=-1);
var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;
var cur_index=1;
var isNotFast;
var interVal = 0;
var _MainForm = null;
var language = 'farsi';
var FarsiKeyArray=new Array(32,33,34,35,36,37,1548,1711,41,40,215,43,1608,45,46,47,48,49,50,51,52,53,54,55,56,57,58,1603,1608,61,46,1567,64,1588,1584,1586,1610,1579,1576,1604,1570,1607,1578,1548,1605,8217,1583,1582,1581,1590,1569,1587,1601,1593,1585,1589,1591,1594,1592,1580,1688,1670,94,95,1662,1588,1584,1586,1610,1579,1576,1604,1575,1607,1578,1606,1605,1574,1583,1582,1581,1590,1602,1587,1601,1593,1585,1589,1591,1594,1592,125,124,123,126);
var  Shift_FarsiKeyArray=new Array(32,33,34,35,36,37,1548,34,41,40,215,43,60,45,62,1567,48,49,50,51,52,53,54,55,56,57,58,58,1608,61,46,1567,64,1614,1573,1688,1616,1613,1617,1728,1570,93,1600,171,187,1569,1571,91,92,1611,1569,1615,1548,44,1572,1612,1610,1563,1577,125,124,124,94,95,1662,1588,1584,1586,1610,1579,1576,1604,1575,1607,1578,1606,1605,1574,1583,1582,1581,1590,1602,1587,1601,1593,1585,1589,1591,1594,1592,125,124,123,126);//1578//1601
var FarsiKeyArray2=new Array(32,33,34,35,36,37,1548,1711,41,40,215,43,1608,45,46,58,48,49,50,51,52,53,54,55,56,57,58,1603,1608,61,46,1567,64,1588,1584,1586,1610,1579,1576,1604,1570,1607,1578,1548,1605,8217,1583,1582,1581,1590,1569,1587,1601,1593,1585,1589,1591,1594,1592,1580,1688,1670,94,95,1662,1588,1584,1586,1610,1579,1576,1604,1575,1607,1578,1606,1605,1574,1583,1582,1581,1590,1602,1587,1601,1593,1585,1589,1591,1594,1592,125,124,123,126);

if(isIE) interVal = 10;
else interVal = 20;
var speedCommand = "slow";
//-----------------------------------------------------------------------------
function Go_UpdatePanel_No(eid)
{
    var el=eid;
    var ar= el.split('_');
    for(var i=0;i<ar.length;i++)
    {
        if(ar[i].indexOf('ContentPlaceHolder')>-1)
        {
            var ps=ar[i].indexOf('ContentPlaceHolder')+('ContentPlaceHolder').length;
          return  eval( ar[i].charAt(ps));          
        }
    }
    return -1;
}
//-----------------------------------------------------------------------------
function get_keyCtrl(eve)
{
    if (isIE) return eve.ctrlKey;
    else return eve.which;
}
function rest_keypressed(eve)
{
    if (isIE) return eve.keyCode=0;
    else return eve.which=0;
}
function Get_Sabt_Serial()
{
    return FindMainForm().id_tab_rand;    
}
//-----------------------------------------------------------------------------
function get_keypressed(eve)
{
    if (isIE) return eve.keyCode;
    else return eve.which;
}       
//-----------------------------------------------------------------------------
function Change_Zoom(a1,a2,a3)
{
    var siz=screen.availWidth;
    var z1='50%';
    if (isIE) 
    {
        if((siz >=320)&&(siz<=700))document.body.style.zoom=a1;
        if((siz >=701)&&(siz<=999))document.body.style.zoom=a2;
        if((siz >= 1000) && (siz<= 5000)) document.body.style.zoom = a3;
    }
}
//-----------------------------------------------------------------------------
function DbGrid_Sel(id_nam,rowindex,col)
{
    setTimeout('DbGrid_Sel2('+id_nam+','+rowindex+','+col+')',20);
}
//-----------------------------------------------------------------------------
function DbGrid_Sel2(id_nam,rowindex,col)
{
    try
    {
        var _GridView1=id_nam;//Get_Element_By_Id(document,id_nam);
        if(_GridView1!=null)
        {
            var lbly=_GridView1.childNodes;
            if(lbly.length>0)
            {
                var lblx1=lbly[0];
                if(lblx1.children.length>0)
                {
                    var lblx2=lblx1.children[0];
                    if(lblx2.children.length>0)
                    {
                        var lblx3=lblx2.children[0];
                        if(lblx3.children.length>0)
                        {
                            var lblx=lblx3.children;
                            if(rowindex<lblx.length)
                            {
                                if(rowindex==0)lblx[rowindex].children[col].children[0].focus();
                                else lblx[rowindex].children[col].children[0].children[0].focus();
                            }
                        }
                    }        
                }
            }
        }  
    }
    catch(exp)
    {
    }      
}

//-----------------------------------------------------------------------------
function key_press(obj,eve)
{
    var a=get_keypressed(eve);
    if(FindMainForm().language == 'farsi')
    {
        if(a>=32&&a<128)
        {
            var c1='';
            if(eve.shiftKey)
            {
                c1=Shift_FarsiKeyArray[a-32];
            }
            else
            {
                c1=FarsiKeyArray[a-32];
            }

            if(isIE)
            {
                eve.keyCode=c1;
            }
            else
            {
//                var si=getSelStart(obj);
//                var ei=getSelEnd(obj);

//                var g = obj.value.substr(0,si);
//                g += String.fromCharCode(c1);
//                g += obj.value.substr(ei,obj.value.length);
//                
//                obj.value=g;
//                setSelection(obj,si+1,si+1);
//                CancelEventHandeler(eve);
                eve.keyCode=c1;
                return c1;
            }
        }
    }
    return a;        
}
//YaZ{
function Shift_Key_Down(obj,eve)
{
    if(eve.shiftKey)
    {
      if (eve.keyCode!=16)
      {
        var ch;
        switch (eve.keyCode)
        {
//            case 48:
//            ch='~';
//            break;
//            case 49:
//            ch='!';
//            break;
//            case 50:
//            ch='@';
//            break;            
//            case 51:
//            ch='#';
//            break;
//            case  52:
//            ch='$';
//            break;
//            case 53:
//            ch='%';
//            break;
//            case 54:
//            ch='^';
//            break;
//            case 55:
//            ch='&';
//            break;
//            case 56:
//            ch='*';
//            break;
//            case 57:
//            ch='(';
//            break;
//            case 58:
//            ch=')';
//            break;
//            case 189:
//            ch='_';
//            break;
//            case 187:
//            ch='+';
//            break;
        }
        if (ch!=undefined)   obj.value+=ch;
      }
    }
}
//YAZ}

////
function Memo_ScrollDown(id1)
{ 
  if (document.getElementById(id1)) 
  {
    document.getElementById(id1).scrollTop = document.getElementById(id1).scrollHeight;   
  }
}
//-----------------------------------------------------------------------------
function Press_Enter2(Next_Item)
{
    var lbl=document.getElementById(Next_Item);
    if(lbl!=null)
    {
        lbl.focus();
    }
}
//-----------------------------------------------------------------------------
function Press_Enter2(Next_Item)
{
    var lbl=document.getElementById(Next_Item);
    if(lbl!=null)
    {
        try
        {
            lbl.focus();
        }
        catch(exp)
        {
        }
    }
}
//-----------------------------------------------------------------------------
function Set_Press_Enter(Next_Item)
{
    if(Next_Item !=undefined)
    {
        setTimeout('Press_Enter2("'+Next_Item.id+'")',300);

    }
    return true;
}

//-----------------------------------------------------------------------------
function Press_Enter_UD(Next_Item,Priv_Item,eve)
{
    if (eve == undefined)return false;
    key_cod=get_keypressed(eve);
    key_ctrl=get_keyCtrl(eve);
    if(key_ctrl)
    {
        if(key_cod==39)key_cod=38;
        if(key_cod==37)key_cod=40;
    }
    if(key_cod!=40 && key_cod!=38) return false;
    if((key_cod==40)&&(Next_Item!=''))setTimeout('Press_Enter2("'+Next_Item+'")',300);
    if((key_cod==38)&&(Priv_Item!=''))setTimeout('Press_Enter2("'+Priv_Item+'")',300);
    return true;
}
//-----------------------------------------------------------------------------
function Press_Enter_LR(Next_Item,Priv_Item,eve)
{
    if (eve == undefined)return false;
    key_cod=get_keypressed(eve);
    key_ctrl=get_keyCtrl(eve);
    if(key_ctrl)
    {
        if(key_cod==38)key_cod=39;
        if(key_cod==40)key_cod=37;
    }
    if (key_cod!=39 && key_cod!=37) return false;
    if((key_cod==37)&&(Next_Item!=''))setTimeout('Press_Enter2("'+Next_Item+'")',50);
    if((key_cod==39)&&(Priv_Item!=''))setTimeout('Press_Enter2("'+Priv_Item+'")',50);
    rest_keypressed(eve);
    return true;
}
//------------------------------------------------------------------------------
function Config_Fa_En(Element1,obj,eve)
{
var ch=key_press2(obj,eve);
// String.fromCharCode(ch);
//var va= Get_Element_By_Id(document,Element1).value;
//Get_Element_By_Id(document,Element1).value=va+ch;
}


//------------------------------------------------------------------------------
function key_press2(obj,eve)
{
    var a=get_keypressed(eve);
    if(FindMainForm().language == 'farsi')
    {
        if(a>=32&&a<128)
        {
            var c1='';
            if(eve.shiftKey)
            {
                c1=Shift_FarsiKeyArray[a-32];
            }
            else
            {
                c1=FarsiKeyArray2[a-32];
            }
            if(isIE)
            {
                eve.keyCode=c1;
            }
            else
            {
                var si=getSelStart(obj);
                var ei=getSelEnd(obj);
                var g = obj.value.substr(0,si);
                g += String.fromCharCode(c1);
                g += obj.value.substr(ei,obj.value.length);
                obj.value=g;
                setSelection(obj,si+1,si+1);
                CancelEventHandeler(eve);
                return c1;
            }
        }
    }
    return a;        
}
//-----------------------------------------------------------------------------
function Clear_Edit_Ent_1(lbl)
{
var lblx=Get_Element_By_Id(lbl.parentNode.parentNode.document,'StEdit1_Text_Box1');
if(lblx!=null)
{
    lblx.value='';
}
}
//-----------------------------------------------------------------------------
function getSelEnd(b)
{
    if (isIE)
    {
        var d=b.document.selection.createRange();
        return getSelStart(b)+d.text.length;
    }
    else return b.selectionEnd;    
}
//-----------------------------------------------------------------------------
function getSelStart(b)
{
    if (isIE)
    {
        var d=b.document.selection.createRange();
        if (d.text.length > 0)
            return b.value.indexOf(d.text);
        else
        {
            return -d.move('character',-65535);
        }
    }
    else return b.selectionStart;    
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function setSelection(b,s,e)
{
    if (isIE)
    {
        var f=b.createTextRange();
        f.collapse(true);
        f.moveStart('character',s);
        //f.moveEnd('character',e);
        f.select();
    }
    else b.setSelectionRange(s,e);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function GetElementById(wi_ch2)
{
    if (isIE)
    {
        var from=0;
        if (event!=null)
        {
            if (event.srcElement!=null)
            {
                from = (event)? event.srcElement.sourceIndex: 0;
            }
        }
                
        for(var i1=from;i1<document.all.length;i1++)
        {
            if(document.all[i1].id.indexOf(wi_ch2)>=0)
            {
                return document.all[i1];
            }
        }
    }    
    else
    {
        var d = document.getElementsByTagName('*');
        var i1;
        var item = document.activeElement;
        for(i1=0;i1<d.length;i1++)
        {
            if(d[i1].isEqualNode(item))
            {
                break;
            }
        }
        for (var i2 = i1 + 1; i2 < d.length;i2++)
        {
            if(d[i2].id.indexOf(wi_ch2)>=0)
            {
                return d[i2];
            }
        }
    }
    return null;
}
function show_mod()
{   
   if (FindMainForm().Form118==true)
   {          
        t_1=FindMainForm().googlewin_Form118.id;
        var doc1=FindMainForm().doc.frames["_iframe-"+t_1].document;
        F118_ListBox1=Get_Element_By_Id_2(doc1,'UC_118_ListBox1');
        var i=0;
        if(F118_ListBox1!=null)
        {
            while(i<F118_ListBox1.length)
            {
                F118_ListBox1.remove(0);
            }
        }
        //UFrame_118.Clear_Data(M_GetFormID(),Get_Sabt_Serial())
   }
   if (FindMainForm().Form1132==true)
   {     
        t_1=FindMainForm().googlewin_Form1132.id;
        var doc1=FindMainForm().doc.frames["_iframe-"+FindMainForm().googlewin_Form1132.id].document;
        F1132_text_box1=Get_Element_By_Id_2(doc1,'UC_1132_TextBox1_Text_Box1');
        F1132_text_box1.value='';
        var F1132_text_box2=Get_Element_By_Id_2(doc1,'UC_1132_TextBox1_ctl01_Text_Box1');
        F1132_text_box2.value='';

        var F1132_base1=doc1.getElementById('UC_1132_base1');
//        var Form1132_Searched_Val=null;
//        var Form1132_Searched_Val_Index=0;
//        var Form1132_Seach_Val_Pre='';
        for(var i=0;i<F1132_base1.childNodes[0].all.length;i++)
        {
            F1132_base1.childNodes[0].all[i].style.display='';
        }
   }
   else if (FindMainForm().Form97==true)
   {     
        t_1=FindMainForm().googlewin_Form97.id;
        var doc1=FindMainForm().doc.frames["_iframe-"+FindMainForm().googlewin_Form97.id].document;
        doc1.childNodes[0].children[1].childNodes[0][7].value='';
        doc1.childNodes[0].children[1].childNodes[0][8].value='';
   }
   else if (FindMainForm().Form1131==true)
   {     
       F1131_CheckBoxList_Clear_Selected1();
       if(FindMainForm().First_1131)
       {
            F1131_CheckBoxList_Clear_Selected2();
            F1131_Pre_Show();
            FindMainForm().First_1131=false;                                    
       }
       t_1=FindMainForm().googlewin_Form1131.id;    
   }
   var h=FindMainForm().doc.getElementById(t_1);
   if (h!=null)   
   {
     h.style.visibility=="visible";
       if (FindMainForm().Form1131)
       {
           dhtmlwindow=FindMainForm().dhtmlwindow1131;
           dhtmlwindow._parent=FindMainForm().googlewin_Form1131;      
           h.onmousedown=setupdrag;
           dhtmlwindow.etarget=h;
           dhtmlwindow.etarget._parent=FindMainForm().googlewin_Form1131;
        }
        else  if (FindMainForm().Form1132)  
        {
           dhtmlwindow=FindMainForm().dhtmlwindow1132;
           dhtmlwindow._parent=FindMainForm().googlewin_Form1132;      
           h.onmousedown=setupdrag;
           dhtmlwindow.etarget=h;
           dhtmlwindow.etarget._parent=FindMainForm().googlewin_Form1132;
        } 
        else  if (FindMainForm().Form97)  
        {
           dhtmlwindow=FindMainForm().dhtmlwindow97;
           dhtmlwindow._parent=FindMainForm().googlewin_Form97;      
           h.onmousedown=setupdrag;
           dhtmlwindow.etarget=h;
           dhtmlwindow.etarget._parent=FindMainForm().googlewin_Form97;
        } 
        else  if (FindMainForm().Form118) 
        {
          dhtmlwindow=FindMainForm().dhtmlwindow118;
           dhtmlwindow._parent=FindMainForm().googlewin_Form118;      
           h.onmousedown=setupdrag;
           dhtmlwindow.etarget=h;
           dhtmlwindow.etarget._parent=FindMainForm().googlewin_Form118;
        }
        var t=h;      	
	    h.handle._parent=t;
	    h.resizearea2._parent=t;
	    h.controls1._parent=t; 
	    h.controls._parent=t; 
	    if (t.controls1!=undefined) t.controls1.onclick=enablecontrols;
	    if (t.controls!=undefined) t.controls.onclick=enablecontrols;
        $(h).show();
   }
 }
function  enablecontrols()
    {  
    
	    var sourceobj=FindMainForm_ParWin().event? FindMainForm_ParWin().event.srcElement : e.target 
  
	    if (sourceobj.getAttribute("title").indexOf('بستن پنجره')>=0) 
		    M_CallClose(this._parent);
		else if (sourceobj.getAttribute("title").indexOf('راهنمای پنجره')>=0)
		{
		    var p1=window.frames["_iframe-"+this._parent.id].location.pathname;
		    if(p1.indexOf('WebModalForm.aspx')>0)
		    {
		        var p3=window.frames["_iframe-"+this._parent.id].location.search;
		        if(p3.indexOf(',')>0)
		        {
		            var p2=p3.split(',')[0];
		            var p="";
		            if(p2.length>4)
		            {
		                p2=p2.replace('?Id=','');
		                p1=p1.replace('.aspx',p2+'.aspx');
		            }		            
		        }
		    }
		    ShowHelp(p1);
	    }
	    return false
    }
 
 function setupdrag()
    {
        var d;
        if (FindMainForm().Form1131)d=FindMainForm().dhtmlwindow1131 
	    else if (FindMainForm().Form1132)d=FindMainForm().dhtmlwindow1132
	    else if (FindMainForm().Form97)d=FindMainForm().dhtmlwindow97
	    else if (FindMainForm().Form118)d=FindMainForm().dhtmlwindow118
	    else return false;
	    
	    var t=this._parent 
	    if (t==null) t=dhtmlwindow._parent;
	    //d.etarget=this 

	    var e=FindMainForm_ParWin().event || e
	    d.initmousex=e.clientX 
	    d.initmousey=e.clientY
	    d.initx=parseInt(t.offsetLeft) 
	    d.inity=parseInt(t.offsetTop)
	    d.width=parseInt(t.offsetWidth) 
	    d.contentheight=parseInt(t.contentarea.offsetHeight) 

		t.style.backgroundColor="#F8F8F8" 
		t.contentarea.style.visibility="hidden"
		t.contentarea.style.display="block"

	    FindMainForm().doc.onmousemove=function()	    
	    {
	       var d; 
	       if (FindMainForm().Form1131)d=FindMainForm().dhtmlwindow1131 
	        else if (FindMainForm().Form1132)d=FindMainForm().dhtmlwindow1132
	        else if (FindMainForm().Form97)d=FindMainForm().dhtmlwindow97
	        else if (FindMainForm().Form118)d=FindMainForm().dhtmlwindow118
	        else return false;
	        var etarget;
	        if(etarget==null)etarget=d.etarget;
	        //if (etarget==null) etarget=this;
	        if (FindMainForm_ParWin().event==null) return false;
	        var e=FindMainForm_ParWin().event || e
    	    
	        d.distancex=e.clientX-d.initmousex 
	        d.distancey=e.clientY-d.initmousey
	        if (etarget.className=="drag-handle"||FindMainForm_ParWin().event.type=="mousedown"||etarget!=null)
	        { 
		        move(etarget._parent, e)
		    }
	        else if (etarget.className=="drag-resizearea2") 
	        {
		        resize(etarget._parent, e)
		    }
		    
		    if (FindMainForm().Form1131)FindMainForm().dhtmlwindow1131=d 
	        else if (FindMainForm().Form1132)FindMainForm().dhtmlwindow1132=d
	        else if (FindMainForm().Form97)FindMainForm().dhtmlwindow97=d
	        else if (FindMainForm().Form118)FindMainForm().dhtmlwindow118=d
	        
	        return false 
	        
	    }	 
	    FindMainForm().doc.onmouseup=function()//FindMainForm().doc2
	    {
		    t.contentarea.style.backgroundColor="white";
		    t.contentarea.style.visibility="visible";
	        t.contentarea.style.display="block"
		    d.etarget=null 
	        FindMainForm().doc.onmousemove=null
	        FindMainForm().doc.onmouseup=null
	    }
	    
	    if (FindMainForm().Form1131)FindMainForm().dhtmlwindow1131=d 
	    else if (FindMainForm().Form1132)FindMainForm().dhtmlwindow1132=d
	    else if (FindMainForm().Form97)FindMainForm().dhtmlwindow97=d
	    else if (FindMainForm().Form118)FindMainForm().dhtmlwindow118=d
	    return false
    }
 
function   move(t, e)
{
    if (FindMainForm().Form1131)d=FindMainForm().dhtmlwindow1131 
    else if (FindMainForm().Form1132)d=FindMainForm().dhtmlwindow1132
    else if (FindMainForm().Form97)d=FindMainForm().dhtmlwindow97
    else if (FindMainForm().Form118)d=FindMainForm().dhtmlwindow118
    t.style.left=d.distancex+d.initx+"px"
    t.style.top=d.distancey+d.inity+"px"
}

function hide_mod()
{
try
{
    var t_1=null;
    if (FindMainForm().Form118==true) t_1=FindMainForm().googlewin_Form118.id;     
    if (FindMainForm().Form1132==true) t_1=FindMainForm().googlewin_Form1132.id;
    if (FindMainForm().Form97==true) t_1=FindMainForm().googlewin_Form97.id;
    if (FindMainForm().Form1131==true) t_1=FindMainForm().googlewin_Form1131.id;    
    if(t_1!=null)
    {
        var h=FindMainForm().doc.getElementById(t_1);
        if (h!=null)
        {
            h.style.visibility=="hidden";
            $(h).hide();       
            M_removeBackgroundDiv(FindMainForm().doc2, FindMainForm().t2);
        }
        if (FindMainForm().sub_after.indexOf("M_Call_Form")>-1)
        {
            eval(FindMainForm().sub_after);
        }
        else
        {
            FindMainForm_ParWin2().M_Sub_Server(FindMainForm().sub_after);
        }
    }
}
catch (ex)    
{
    FindMainForm().googlewin_Form118=null;
    FindMainForm().Form118=false;
    
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function CallModal(handle,t,caption,close_show)
{
    var disp=handle;
    while ((disp.Call_Modal == null)&&(disp !=null))
    {
        disp=disp.parent;
    }
    if(disp != null)
    {
        return disp.Call_Modal(t,caption,close_show);
    }         
    else null;       
}
//-----------------------------------------------------------------------------
function Call_Modal(tx,caption,close_show)// t,src,caption,param,close_show,coun)
{
    var t="googlebox"+(Math.random() * 100000).toFixed().toString();
    var src=tx[0];
    var param=tx[1];
    var bd = M_cretaeBackgroundDiv(document, t);
    var main_form=FindMainForm();
    if (FindMainForm().Form1132==true||FindMainForm().Form97==true||FindMainForm().Form1131==true||FindMainForm().Form118==true)
    {
        FindMainForm().t2=t; 
        FindMainForm().doc=parWin().parent.document;
        FindMainForm().doc2=this.document;      
        if ((FindMainForm().googlewin_Form1132!=null&&FindMainForm().Form1132)||(FindMainForm().googlewin_Form97!=null&&FindMainForm().Form97)||(FindMainForm().googlewin_Form1131!=null&&FindMainForm().Form1131)||(FindMainForm().googlewin_Form118!=null&&FindMainForm().Form118))
        {            
            show_mod();
            FindMainForm().doc3=this.document;
            FindMainForm().t3=t;
        }
        else
        {  
            if (FindMainForm().Form1132==true)
            {
                FindMainForm().googlewin_Form1132=dhtmlwindow.open(t, src, caption, param, "recal",close_show);        
                FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form1132);
                FindMainForm().dhtmlwindow1132=dhtmlwindow;
            }
            else if (FindMainForm().Form97==true)
            {
                FindMainForm().googlewin_Form97=dhtmlwindow.open(t, src, caption, param, "recal",close_show);        
                FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form97);
                FindMainForm().dhtmlwindow97=dhtmlwindow;
            }
            else if (FindMainForm().Form1131==true)
            {
               FindMainForm().googlewin_Form1131=dhtmlwindow.open(t, src, caption, param, "recal",close_show);
               FindMainForm().First_1131=false;             
               FindMainForm().dhtmlwindow1131=dhtmlwindow;
               FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form1131);           
            }
            else if (FindMainForm().Form118==true)
            {
                var l
                FindMainForm().googlewin_Form118=dhtmlwindow.open(t, src, caption, param, "recal",close_show);         
                FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form118);
                FindMainForm().dhtmlwindow118=dhtmlwindow;
            }
            FindMainForm().t=t;
            FindMainForm().doc3=this.document;
            FindMainForm().t3=t;
            FindMainForm().doc=parWin().parent.document;
        }
        M_showBackgroundDiv(bd);   
        if (FindMainForm().Form1132)return FindMainForm().googlewin_Form1132;  
        else if(FindMainForm().Form1131) return FindMainForm().googlewin_Form1131;   
        else if(FindMainForm().Form97) return FindMainForm().googlewin_Form97;   
        else if(FindMainForm().Form118) return FindMainForm().googlewin_Form118;
     
    }
    else
    {
        var googlewin=dhtmlwindow_Main.open(t, src, caption, param, "recal",close_show);       
        
        CallPassModal(googlewin);
        M_showBackgroundDiv(bd);
        M_animateShow(null, googlewin, false); 
        return googlewin;
    }
}
//-----------------------------------------------------------------------------
function GetFunctionKey(e,alt,ctrl,shift)
{
    ctrl = (ctrl != undefined);
    alt = (alt != undefined);
    shift = (shift != undefined);
    return (ctrl == e.ctrlKey && alt == e.altKey && shift == e.shiftKey);
}
//-----------------------------------------------------------------------------
function DbGrid_KeyPress(lbl,e)
{
    if(e.keyCode==40)
    {
        GridViewChange('SelectRel$','1$'+lbl,0);
    }
    else if(e.keyCode==38)
    {
    //up
        GridViewChange('SelectRel$','-1$'+lbl,0);
    }
    else if(e.keyCode==34)
    {
        GridViewChange('SelectRel$','10$'+lbl,0);
    //page down
    }
    else if(e.keyCode==33)
    {
        GridViewChange('SelectRel$','-10$'+lbl,0);
    //page up
    }
    
    var lbl=e;
    
}
//-----------------------------------------------------------------------------
function Click_Row_Grid(Grid_Id,SelectedIndex_Id,Row_Number)
{
   var sel=Get_Element_By_Id(document,SelectedIndex_Id);
    
    var Len_Act_Form=Get_Element_By_Id(document,Grid_Id+"_Len_Act_Form").value;
    Get_Element_By_Id(document,Grid_Id+"_"+Row_Number.toString()).className="GridSelectedRow";
    Get_Element_By_Id(document,Grid_Id+"_Grid_Info_Cur").innerHTML=Row_Number;
    
    if (eval( sel.value)!=Row_Number)
        Get_Element_By_Id(document,Grid_Id+"_"+sel.value).className="GridRow";
    for (var index=1;index<Len_Act_Form;index++)
    {
        if (index>1) {
             var lbl=Get_Element_By_Id_3(document, 'Row' + (index));
            //V4 var lbl = document.getElementById('ctl00_Row' + (index));
            lbl.removeAttribute('loaded');
            lbl.removeAttribute('isshowing');
       
            lbl.style.display='none';
           //lbl.hide();
        }
    }
    sel.value=Row_Number;
}
function Show_LinePanel2()
{
    b = Get_Element_By_Id(document, 'LinePanel1');
    b1 = Get_Element_By_Id(document, 'LinePanel2');           
         
   $(b).css({display:''}).hide();
   $(b1).css({display:''}).show();
}
//-----------------------------------------------------------------------------
function GridViewChange(ctype,val,ind)
{
    if((ctype=='Select$')||(ctype=='SelectRel$')||(ctype=='Pager$')||(ctype=='ChgPager$'))
    {
        var indx=val.indexOf('ctl00_ContentPlaceHolder');
        if(indx>=0)
        {
            var update_panel=parseInt(val.substr(indx+24,1));
        }
        else update_panel=0;
    }
    else var update_panel=1;
    if ((update_panel==1)&&(ind==undefined))
    {
        var lock = false;
        var lbl = Get_Element_By_Id_3(document, 'chkLock_1' );
       //V4 var lbl = Get_Element_By_Id_3(document, 'chkLock_1');
        if (lbl) lock = lbl.checked;    
        var ext = '';
        if (lock)
        {
            for (var i = 1; i < 8; i++) {
                ext += '$R' + i + '$' + (Get_Element_By_Id_3(document, 'Row' + i).getAttribute('isshowing') ? 'true' : 'false');
               //V4 ext += '$R' + i + '$' + (Get_Element_By_Id_3(document, 'Row'+i).getAttribute('isshowing')?'true':'false');
            }
        }
        M_Sub_Server('NeedLoad$'+ctype+val+ext,0/*, update_panel*/);
    }    
    else
    {
        M_Sub_Server('NeedLoad$'+ctype+val, update_panel);
    }
}
//-----------------------------------------------------------------------------
function GridViewChange2(ctype,val,ind,x)
{
    if((ctype=='Select$')||(ctype=='SelectRel$')||(ctype=='Pager$')||(ctype=='ChgPager$'))
    {
        var indx=val.indexOf('ctl00_ContentPlaceHolder');
        var update_panel=parseInt(val.substr(indx+24,1));
    }
    else var update_panel=1;
    if ((update_panel==1)&&(ind==undefined))
    {
        var lock = false;
        var lbl=Get_Element_By_Id_3(document, 'chkLock_1');
      //V4  var lbl = Get_Element_By_Id_3(document, 'chkLock_1');
        if (lbl) lock = lbl.checked;    
        var ext = '';
        if (lock)
        {
            for (var i = 1; i < 8; i++)
            {
                ext += '$R' + i + '$' + (Get_Element_By_Id_3(document, 'Row'+i).getAttribute('isshowing')?'true':'false');
            }
        }
        M_Sub_Server('NeedLoad$'+ctype+val+ext,0/*, update_panel*/);
    }    
    else
    {
        M_Sub_Server('NeedLoad$'+ctype+val, update_panel);
    }
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function TopButtonsClick(Dastor,Dastor_Client, eve, frameno)
{
//debugger;
try
{ 
    if (typeof eve == 'object')
    {
        var lbl = window.event? event.srcElement: eve.target;

        var trigger = 'UpdatePanel1';
        var Is_Trigerr = document.getElementById(trigger);
        if (Is_Trigerr == null) {
            trigger = 'ctl00_' + trigger;
        }
        if (frameno != undefined)
        {
            if (typeof frameno == 'number')
            {
                if (frameno == 0) frameno = 'UpdatePanel1';
                else frameno = '_UpdatePanel' + frameno;
                trigger = frameno;
                Is_Trigerr = document.getElementById(trigger);
                if (Is_Trigerr == null) {
                    trigger = 'ctl00_' + trigger;
                }
            }
            this['LastUpdatePanel'] = document.getElementById(trigger);
            this['LastlblFormId'] = Down_Get_lblFormId(this['LastUpdatePanel']);
        }
    }
    if(Dastor_Client!='')
    {
        eval(Dastor_Client);
    }
    eval(Dastor);
}
catch(ex)    
{
  //  document.URL='../Defualt.aspx'
}
}
//-----------------------------------------------------------------------------
function Img_Key_Down(event,ClientClick_)
{
    if((event.keyCode == 32)||(event.keyCode == 13))
    {
        this.disabled = 'true';
        ClientClick_;
        this.disabled = 'false';
    }
}
//-----------------------------------------------------------------------------

function clicking(Dastor,self, eve)
{
    if (eve == undefined) 
    {
        eve = window.event;
    }
    if (typeof eve == 'object')
    {
        var lbl = window.event? event.srcElement: eve.target;
        this['LastUpdatePanel'] = Up_Get_UpdatePanel(lbl);
        this['LastlblFormId'] = Down_Get_lblFormId(lbl);
    }
    try
    {
        eval(Dastor);
    }
    catch(exp)
    {
      FindMainForm().M_CallExit_Out();
    }
        
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Up_Get_UpdatePanel(lbl)
{
    while(lbl != null && lbl.nodeName != "BODY" && lbl.id.indexOf('UpdatePanel')<0)
    {
        lbl = lbl.parentNode;
    }
    return lbl;
}
//-----------------------------------------------------------------------------
function Get_Parent_By_Id(lbl,id_nam)
{
    while(lbl != null && lbl.nodeName != "BODY" && lbl.id.indexOf(id_nam)<0)
    {
        lbl = lbl.parentNode;
    }
    return lbl;
}
//-----------------------------------------------------------------------------
function Down_Get_lblFormId(lbl)
{
    if (FindMainForm().isIE)
    {
        var idx = lbl.sourceIndex;
        for(var i1=idx;i1<document.all.length;i1++)
        {
            if(document.all[i1].id.indexOf('lblFormId')>=0)
            {
                return document.all[i1];
            }
        }
    }
    else
    {
        var d = document.getElementsByTagName('*');
        var i1;
        for(i1=0;i1<d.length;i1++)
        {
            if(d[i1].isEqualNode(lbl))
            {
                break;
            }
        }
        for (var i2 = i1 + 1; i2 < d.length;i2++)
        {
            if(d[i2].id.indexOf('lblFormId')>=0)
            {
                return d[i2];
            }
        }
    }
    return null;
}
function M_Sub_Server_Pos(param,grid_eleman)
{
    var row=Get_Element_By_Id(document, grid_eleman).value;
    M_Sub_Server(param+'$0$0$0$'+row+'$false$0');
}
function M_Sub_ServerT(param, frameno)
{
    setTimeout("M_Sub_Server("+param+","+frameno+")",50);
}
//-----------------------------------------------------------------------------
function M_Sub_Server(param, frameno)
{
    this.focus();
    var trigger = 'UpdatePanel1';
    var Is_Trigerr = document.getElementById(trigger);
    if (Is_Trigerr == null) {
        trigger = 'ctl00_' + trigger;
    }
    if (frameno != undefined)
    {
        if (typeof frameno == 'number')
        {
            if(frameno==-1)
            {
                frameno='form1';
                trigger=frameno;
            }
            else
            {
                if (frameno == 0) frameno = 'UpdatePanel1';
                else frameno = '_UpdatePanel' + frameno;
                var Is_Trigerr = document.getElementById(frameno);
                if (Is_Trigerr != null) {
                    trigger = frameno;
                }
                else {
                    trigger = 'ctl00_' + frameno;
                }

            }
        }
    }
    else if (this['LastUpdatePanel']) trigger = this['LastUpdatePanel'].id;
    FindMainForm().LastChanged = new Date();
    __doPostBack(trigger,(Math.random()*10000000).toFixed().toString()+'$'+param);
}
//-----------------------------------------------------------------------------
function M_Sub_Server2(param, frameno)
{
    this.focus();
    FindMainForm().LastChanged = new Date();
    __doPostBack(frameno,(Math.random()*10000000).toFixed().toString()+'$'+param);
}
//-----------------------------------------------------------------------------
function  M_Sub_Server_Update_No(param,Element)
{
    M_Sub_Server(param,Go_UpdatePanel_No(Element.id));
}
//-----------------------------------------------------------------------------
function Sub_Server2(param, frameno)
{
    this.focus();
    var trigger='form1';
    if (frameno != undefined)
    {
        if (typeof frameno == 'number')
        {
            if (frameno == 0) frameno = 'UpdatePanel1';
            else frameno = '_UpdatePanel'+frameno;
            trigger = 'ctl00_' + frameno;
        }
    }
    else if (this['LastUpdatePanel']) trigger = this['LastUpdatePanel'].id;
    FindMainForm().LastChanged = new Date();
    __doPostBack(trigger,(Math.random()*10000000).toFixed().toString()+'$'+param);
}
//-----------------------------------------------------------------------------
function Call_Modal(tx,caption,close_show)// t,src,caption,param,close_show,coun)
{
    var t="googlebox"+(Math.random() * 100000).toFixed().toString();
    var src=tx[0];
    var param=tx[1];
    var bd = M_cretaeBackgroundDiv(document, t);
    var main_form=FindMainForm();
    if (FindMainForm().Form97==true||FindMainForm().Form1132==true||FindMainForm().Form1131==true||FindMainForm().Form118==true)
    {
        FindMainForm().t2=t;        
        FindMainForm().doc=parWin().parent.document;
        while (FindMainForm().doc.location.toString().indexOf('FormT')<0) 
        {
            FindMainForm().doc=FindMainForm_ParWin().parent.document;
        } 
        FindMainForm().doc2=this.document;      
        if ((FindMainForm().googlewin_Form1132!=null&&FindMainForm().Form1132)||(FindMainForm().googlewin_Form97!=null&&FindMainForm().Form97)||(FindMainForm().googlewin_Form1131!=null&&FindMainForm().Form1131)||(FindMainForm().googlewin_Form118!=null&&FindMainForm().Form118))
        {            
            show_mod();
            FindMainForm().doc3=this.document;
            FindMainForm().t3=t;
        }
        else
        {  
            if (FindMainForm().Form1132==true)
            {
                FindMainForm().googlewin_Form1132=dhtmlwindow.open(t, src, caption, param, "recal",close_show);        
                FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form1132);
                FindMainForm().dhtmlwindow1132=dhtmlwindow;
            }
            else if (FindMainForm().Form97==true)
            {
                FindMainForm().googlewin_Form97=dhtmlwindow.open(t, src, caption, param, "recal",close_show);        
                FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form97);
                FindMainForm().dhtmlwindow97=dhtmlwindow;
            }
            else if (FindMainForm().Form1131==true)
            {
                FindMainForm().First_1131 = false; 
                FindMainForm().googlewin_Form1131=dhtmlwindow.open(t, src, caption, param, "recal",close_show);             
                FindMainForm().dhtmlwindow1131=dhtmlwindow;
                if (isIE)
                {
                    FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form1131);           
                }
                else
                {
                    FindMainForm().doc.body.insertAdjacentHTML (FindMainForm().googlewin_Form1131);
                }
            }
            else if (FindMainForm().Form118==true)
            {
                FindMainForm().googlewin_Form118=dhtmlwindow.open(t, src, caption, param, "recal",close_show);         
                FindMainForm().doc.body.appendChild(FindMainForm().googlewin_Form118);
                FindMainForm().dhtmlwindow118=dhtmlwindow;
            }
            FindMainForm().t=t;
            FindMainForm().doc3=this.document;
            FindMainForm().t3=t;
        }
        M_showBackgroundDiv(bd);   
        if (FindMainForm().Form1132)return FindMainForm().googlewin_Form1132;  
        else if(FindMainForm().Form1131) return FindMainForm().googlewin_Form1131;   
        else if(FindMainForm().Form97) return FindMainForm().googlewin_Form97;   
        else if(FindMainForm().Form118) return FindMainForm().googlewin_Form118;
    }
    else
    {
        var googlewin=dhtmlwindow_Main.open(t, src, caption, param, "recal",close_show);       
        CallPassModal(googlewin);
        M_showBackgroundDiv(bd);
        M_animateShow(null, googlewin, false); 
        return googlewin;
    }
}

//-----------------------------------------------------------------------------
function print_Matn(id,wid,hei,zoom)
{
    var lbl=Get_Element_By_Id(document,id);
    var str=lbl.innerHTML;
    while(str.indexOf('\n')>=0)
    {
        str=str.replace('\n',"<br />");
    }
    
    str="<div align='right' dir='rtl' style='font-family: Tahoma_f'>"+str+"</div>";
    M_DoPrintableSections(str,wid,hei,zoom);
}

//-----------------------------------------------------------------------------
function CallPassModal(googlewin)
{
    if(googlewin)
    {
        var t2=this;
        var gum=0;
        var lbl=[];
        var bak=[];
        var w=0;
        var h=0;

        while(true)
        {
            if(t2!=null)
            {
                var x1=t2.name;
                var x3=x1.indexOf("_iframe-");
                if(x3>=0)
                {
                    var x2=x1.substring(x3+8,x1.length);
                    lbl[gum]=t2.parent.document.getElementById(x2);
                    var w1=lbl[gum]["_width"]; 
                    var h1=lbl[gum]["_height"];
                    if(w1>w)w=w1;
                    if(h1>h)h=h1;
                    gum++;
                    t2=t2.parent;
                }
                else
                {
                    break;
                }
            }
            else 
            {
                break;
            }    
        }        
        if(gum>0)
        {
            var wx1=[];
            var hx1=[];
            for(var i=0;i<gum;i++)
            {
                wx1[i]=lbl[i]["_width"]; 
                hx1[i]=lbl[i]["_height"];
            }
            bak[0]=googlewin.ownerDocument.getElementById("fns_background_div"+googlewin.id); 
            for(var i=0;i<gum-1;i++)
            {
                bak[i+1]=lbl[i].ownerDocument.getElementById("fns_background_div"+lbl[i].id); 
            }
            var w2=googlewin["_width"]; 
            var h2=googlewin["_height"];
            if(w2<w)w2=w;
            if(h2<h)h2=h;    
            for(var i=gum-1;i>=0;i--)
            {
                if(lbl[i].className=='dhtmlwindowD')
                {
                    lbl[i].setSize(w2+(35*(i+1)),h2+(90*(i+1)));
                    lbl[i].moveTo("middle", "middle");
                    bak[i].style.width = w2+(35*(i+1)) - 0;
                    bak[i].style.height = h2+(90*(i+1)) - 0;
                }
            }
            googlewin.moveTo("middle", "middle");
            googlewin.onclose1=function()
            { 
                for(var i=gum-1;i>=0;i--)
                {
                    if(lbl[i].className=='dhtmlwindowD')
                    {
                        lbl[i].setSize(wx1[i],hx1[i]);
                        lbl[i].moveTo("middle", "middle");
                        bak[i].style.width = wx1[i] - 0;
                        bak[i].style.height = hx1[i] - 0;
                    }
                }
                return true;
            }
            
//            for(var i=gum-1;i>=0;i--)
//            {
//                if(lbl[i].className=='dhtmlwindowD')
//                {
//                    lbl[i].setSize(w2+(10*(i)),h2+(20*(i)));
//                    lbl[i].style.left=2;
//                    lbl[i].style.top=2;
//                    
//                    bak[i].style.width = "100%";//w2+(20*(i+1));
//                    bak[i].style.height = "100%";//h2+(90*(i+1));
//                }
//            }
//                    googlewin.style.left=10;
//                    googlewin.style.top=2;
////            googlewin.moveTo("middle", "middle");
//            googlewin.onclose1=function()
//            { 
//                for(var i=gum-1;i>=0;i--)
//                {
//                    if(lbl[i].className=='dhtmlwindowD')
//                    {
//                        lbl[i].setSize(wx1[i],hx1[i]);
//                        lbl[i].style.left=2;
//                        lbl[i].style.top=2;
//                        bak[i].style.width = "100%";
//                        bak[i].style.height = "100%";//hx1[i] - 0;
//                    }
//                }
//                return true;
//            }
        }
    }
}
//-----------------------------------------------------------------------------
function FindMainForm_ParWin()
{
    var elem=FindMainForm().doc; 
    var w1=elem.defaultView || elem.parentWindow;
    return w1;
}
function FindMainForm_ParWin2()
{
    var elem=FindMainForm().doc2; 
    var w1=elem.defaultView || elem.parentWindow;
    return w1;
}
function parWin()
{
    var elem=this.document;
    var w1=elem.defaultView || elem.parentWindow;
    return w1;
}
function parWin2(par)
{
    var elem=par.document;
    var w1=elem.defaultView || elem.parentWindow;
    return w1;
}
//-----------------------------------------------------------------------------
function FindMainForm()
{
    if (_MainForm == null)
    {
        var lx=this;
        if (typeof(isMainForm) == 'undefined')
        {
            var gum=0;
            while((lx.isMainForm == null)&&(lx !=null))
            {
                lx=lx.parent;
                gum++;
                if(gum>10)break;
            }
        }
        _MainForm = lx;
    }
    return _MainForm;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ShowHelp(urlheader)
{
    var temp = urlheader;
    if ((urlheader == undefined) || (typeof urlheader == 'number'))
    {
        urlheader = window.location.pathname;
        if (temp != undefined)
            urlheader += "#" + temp;
    }    
    FindMainForm().retriveHelp(urlheader);
}
function M_Msg_Timer_Func(tim)
{
try
{
    tim=tim-1;
    if(tim>0)
    {
        if (document.readyState == "complete")
        {
            var lbl=Get_Element_By_Id_2(document,'UC_Message_IntEdit01');
            lbl.value=tim.toString();
        }
        setTimeout('M_Msg_Timer_Func('+ tim.toString()+');',1000);
    }
    else
    {
        Msg_CallOk();
    }
}
catch(exp)
{
}
}
//-----------------------------------------------------------------------------
function M_CallCloseMessage()
{
FindMainForm().Message_Box=true;
M_CallClose();
}
function M_CallClose(lbl)
{
    var w = this;
    if (lbl == undefined)
    {
        var lx=this.name;
        lx=lx.substring(8,lx.length);
        lbl=this.parent.document.getElementById(lx);
        w = this.parent;
    }        
    if (lbl)
    {
        FindMainForm().Modal_t_1131=lbl;
        var b1=false;
        var id1=lbl.id;
        if(FindMainForm().googlewin_Form1131!=null)
        {
            var id2=FindMainForm().googlewin_Form1131.id;
            if(id1==id2)
            {
                b1=true;
                FindMainForm().Form1131=true;
            }
        }
        if(FindMainForm().googlewin_Form118!=null)
        {
            var id2=FindMainForm().googlewin_Form118.id;
            if(id1==id2)
            {
                b1=true;
                FindMainForm().Form118=true;
            }
        }
        if(FindMainForm().googlewin_Form1132!=null)
        {
            var id2=FindMainForm().googlewin_Form1132.id;
            if(id1==id2)
            {
                b1=true;
                FindMainForm().Form1132=true;
            }
        }
        if(FindMainForm().googlewin_Form97!=null)
        {
            var id2=FindMainForm().googlewin_Form97.id;
            if(id1==id2)
            {
                b1=true;
                FindMainForm().Form97=true;
            }
        }
        if (b1)//(||||)
        {
            hide_mod();
            FindMainForm().Form1131=false;
            FindMainForm().Form1132=false;
            FindMainForm().Form97=false;
            FindMainForm().Form118=false;
        }
        else
        {   
            lbl.close();
            M_animateShow(lbl,null,true);	    
        }
    }   	    
}
//-----------------------------------------------------------------------------
function M_CallCloseT(lbl)
{
    setTimeout("M_CallClose("+lbl+")",50);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function _updateStyleSheets(links,d1,siz)
{
    if (links != null)
    {
        if(links.length==3)
        {
            if(siz==0)
            {
                links[0].href="../Themes/Skin"+d1+"/StyleSheet00003.css";
            }
            else if(siz==1)
            {
                links[0].href="../Themes/Skin"+d1+"/StyleSheet_xx_small00003.css";
            }
            else if(siz==2)
            {
                links[0].href="../Themes/Skin"+d1+"/StyleSheet_x_small00003.css";
            }
            else if(siz==3)
            {
                links[0].href="../Themes/Skin"+d1+"/StyleSheet_small00003.css";
            }
            
            links[1].href="../Themes/Skin"+d1+"/jquery-ui-1.8.2.css";
        }
    }
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function LoadStyles(siz)
{
    var d1=parseInt(GetSkinId());    
    
    _updateStyleSheets(document.getElementsByTagName("Link"),d1,siz);
    
    for (var i = 0; i < window.frames.length; i++)
    {
        _updateStyleSheets(window.frames[i].document.getElementsByTagName("Link"),d1,siz);
    }
    return d1-1;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function GetSkinId()
{
    var d2=FindMainForm();
    var i=0;
    var d1=d1=Get_Cookie(d2,'MyTheme');
    if( d1=="" || d1==null)
    {
        d1 = 9;
        M_Set_Cookie(d2,'MyTheme',d1);
    }
    else d1 = parseInt(d1); 
    return ++d1;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function CloseForms(src)
{
    Get_Sub_Place("CloseTab","", Get_Sabt_Serial(),src.split('?Id=')[1],Get_Sabt_Serial());
   // FindMainForm().SWebForm_Main.CloseTab(src.split('?Id=')[1],Get_Sabt_Serial()); 
}
//-----------------------------------------------------------------------------
function Set_Sabt_Serial(rand)
{
    FindMainForm().id_tab_rand=rand;    
}
//-----------------------------------------------------------------------------
function Get_Sabt_Serial()
{
    return FindMainForm().id_tab_rand;    
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Mirror_Func(str, Ch)
{
    var str2 = "";
    var str3 = "";    
    var tol = str.length;
    for (var i = 0; i < tol; i++)
    {
        if (str.charAt(i) != Ch)
        {
            str2 = str2 + str.charAt(i);
        }
        else
        {
            str3 = str.charAt(i) + str2 + str3;
            str2 = "";
        }
    }
    return str2 + str3;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function pasteFromClipBoard(sw)
{
    var ret = "";
    ret=FindMainForm().get_frm_Switcher(sw,1);
    return ret;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function pasteFromClipBoard1()
{
    var ret = "";
    if (window.clipboardData) 
    {
        ret = window.clipboardData.getData("Text");
    }
    else if (window.netscape) 
    { 
        try
        {
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
            var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
            if (!clip) return;

            var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
            if (!trans) return;

            trans.addDataFlavor('text/unicode');
            clip.getData(trans, clip.kGlobalClipboard);  

            var str       = new Object();  
            var strLength = new Object();  
            trans.getTransferData("text/unicode", str, strLength);  
            if (str) str       = str.value.QueryInterface(Components.interfaces.nsISupportsString);  
            if (str) ret = str.data.substring(0, strLength.value / 2);  
        }
        catch(exp)
        {
        }
    }
    if (ret == null) ret = "";
    return ret;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function copyToClipBoard(sw,meintext)
{
    FindMainForm().set_frm_Switcher(sw,1,meintext);
    return false;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function shellClientApp(filename)
{
try{
    if (isIE)
    {

        try
        {
            var shell = new ActiveXObject("WScript.shell");
            shell.Run(filename , 1);
            return true;
        }
        catch (e)
        {
            return false;
        }    
    }
    else if (window.netscape)
    {
        try
        {
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

            var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
            file.initWithPath(filename);
            if (file.exists())
            {
                file.launch();
                return true;
            }
        }
        catch (e)
        {
            return false;
        }        
    }
    return false;
    }
    catch (e)
        {
            return false;
        }
    
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Get_Cookie(c1, check_name ) 
{
	var a_all_cookies = c1.document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return null;
	}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function M_Set_Cookie(c1, name, value) 
{
    var expires = 365 * 1000 * 60 * 60 * 24;

	var today = new Date();
	today.setTime( today.getTime() );
	var expires_date = new Date( today.getTime() + (expires) );
	c1.document.cookie = name + "=" +escape( value ) +";expires=" + expires_date.toGMTString();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function M_Delete_Cookie(c1, name) 
{
	if ( Get_Cookie(c1, name ) ) document.cookie = name + "=" +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function M_DoPrintableSections(content,wdth,hght,zoom) 
{
    PreviewPage=window.open('','PreviewPage','left=0,top=0,width='+wdth+',height='+hght+'",menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1');    
    PreviewPage.document.open("text/html","replace");
    PreviewPage.document.writeln('<html><head><title></title>'//چاپ
    + '<style>@media print {.header, .hide { visibility: hidden }}</style></head><body align="center" dir="rtl" style="zoom:'+zoom+'%"><center id="center1">'
    + content
    +'</center></body></html>');
    PreviewPage.document.close();
    PreviewPage.print();
    PreviewPage.close();
}
/*********************************************************************************/
/*********************************************************************************/
function M_changeImage(item)
{
    var temp = item.src;
    item.src = item.getAttribute('srcover');
    item.setAttribute('srcover', temp);
}
/*********************************************************************************/
/*********************************************************************************/
function M_updateImages(eleman, oldskin, newskin)
{
    var imgs = eleman.getElementsByTagName('img');
    for (var i = 0; i < imgs.length; i++)
    {
        imgs[i].src = imgs[i].src.replace('Skin'+oldskin, 'Skin'+newskin);
        var src1 = imgs[i].getAttribute('srcover');
        if(src1!=null)
        {
            src1 = src1.replace('Skin'+oldskin, 'Skin'+newskin);        
            imgs[i].setAttribute('srcover', src1);
        }
        else
        {
            src1=null;
        }
    }
}
/*********************************************************************************/
/*********************************************************************************/
function M_wheel(event)
{
    var delta = 0;
    if (!event) 
        event = window.event;
    if (event.wheelDelta) 
    { 
        delta = event.wheelDelta/120;
        if (window.opera)
            delta = -delta;
    } else if (event.detail) 
    { 
        delta = -event.detail/3;
    }
    if (delta)
        mouseWheel(delta);
    if (event.preventDefault)
            event.preventDefault();
    event.returnValue = false;
}
/*********************************************************************************/
/*********************************************************************************/
function M_setImageButtonEnabled(eleman, value)
{
    var eleman_child=eleman.childNodes[0];
    var spn = eleman_child.getElementsByTagName('span')[0];
    if (value == true)
    {
        spn.style.color = '';
        eleman.removeAttribute('disabled');
        eleman_child.removeAttribute('disabled');
        if (eleman_child.attributes['class'].value!='Button_active1')
        {
            eleman_child.onmousedown=function(){eleman_child.className='Button_active1'};
            eleman_child.onmouseover=function(){eleman_child.className='Button_hover1'};
            eleman_child.onmouseout=function(){eleman_child.className='Button1'};
        }
    }    
    else
    {
        spn.style.color = 'graytext';
        eleman_child.setAttribute('disabled','disabled');
        eleman_child.onmousedown=null;
        eleman_child.onmouseover=null;
        eleman_child.onmouseout=null;
    }    
}
/*********************************************************************************/
/*********************************************************************************/
var _ElemanToHide1=null;
function M_CloseModal()
{
    try
    {
        if(document.readyState == 'complete') 
        {
            if (window.frames["_iframe-"+_ElemanToHide1.id])
            {        
                window.frames["_iframe-"+_ElemanToHide1.id].location.replace("");
            }
            else
            {
                _ElemanToHide1.contentarea.innerHTML="";
            }
            _ElemanToHide1 = null;
        }  
    }
    catch(exp)
    {
    }             
}
/*********************************************************************************/
/*********************************************************************************/
function M_animateShow(_ElemanToHide, _ElemanToShow, _removeHiddenEleman)
{
    _ElemanToHide1 = _ElemanToHide;
    var mf = FindMainForm();
    if (mf.isNotFast)
    {
        if (_ElemanToHide)
        {        
            $(_ElemanToHide).hide(mf.speedCommand, function(){
                            if (_removeHiddenEleman == true)
                                _ElemanToHide.ownerDocument.body.removeChild(_ElemanToHide);

                            if (_ElemanToShow) $(_ElemanToShow).show(mf.speedCommand);
                            
                            if (_ElemanToHide.id.indexOf("googlebox")==0)
                                setTimeout("M_CloseModal()",30);});
        }
        else if (_ElemanToShow) $(_ElemanToShow).show(mf.speedCommand);
    }
    else
    {
        if (_ElemanToHide)
        {
            $(_ElemanToHide).hide();

            if (_removeHiddenEleman == true)
                _ElemanToHide.ownerDocument.body.removeChild(_ElemanToHide);

            if (_ElemanToHide.id.indexOf("googlebox")==0)
                setTimeout("M_CloseModal()",0);
                
        }    
        if (_ElemanToShow) $(_ElemanToShow).show();
    }
}
/*********************************************************************************/
/*********************************************************************************/
function M_cretaeBackgroundDiv(doc,t)
{
    var d = doc.createElement("div"); 
    d.id = "fns_background_div"+t;
    d.className="popupMask1";
    //doc.body.scrollHeight=800;
    var db1=doc.body;
    var dd1=doc.documentElement;
    var h1=Math.max(Math.max(Math.max(dd1.scrollHeight,dd1.offsetHeight),db1.offsetHeight),db1.scrollHeight);
    var w1=Math.max(Math.max(Math.max(dd1.scrollWidth,dd1.offsetWidth),db1.offsetWidth),db1.scrollWidth);
    if(h1>4)d.style.height = h1 - 4;
    //if (doc.body.scrollHeight>1200)d.style.height="664px";
    if(w1>4)d.style.width = w1 - 4;
    d.style.display = 'none';
    doc.body.appendChild(d);
    return d;
}
/*********************************************************************************/
/*********************************************************************************/
function M_showBackgroundDiv(d)
{
    var mf = FindMainForm();
    if (mf.isNotFast)
        $(d).css({filter:'alpha(opacity=50)',opacity: 0.5}).show(mf.speedCommand);
    else    
        $(d).css({filter:'alpha(opacity=50)',opacity: 0.5}).show();
}
/*********************************************************************************/
/*********************************************************************************/
function M_cretaeAndShowBackground(doc, t)
{
    M_showBackgroundDiv(M_cretaeBackgroundDiv(doc, t));
}
/*********************************************************************************/
/*********************************************************************************/
function M_removeBackgroundDiv(doc,t)
{
    var lbl = doc.getElementById("fns_background_div"+t);
    var mf = FindMainForm();
    if (mf.isNotFast)
        $(lbl).hide(mf.speedCommand,function(){doc.body.removeChild(lbl)});
    else
    {
        $(lbl).hide();
        //doc.body.removeChild(lbl);
    }    
}
/*********************************************************************************/
/*********************************************************************************/
function M_toggleImage(lbl)
{
    /*var t = lbl.getAttribute('src');
    lbl.setAttribute('src', lbl.getAttribute('srctoggle'));
    lbl.setAttribute('srcover', lbl.getAttribute('srctoggle'));
    lbl.setAttribute('srctoggle', t);    
*/
}
/*********************************************************************************/
/*********************************************************************************/
function M_breakerToggle(base_id,lbl2,lbl)
{
    var s1=this.location.pathname;
    var i1=s1.indexOf('MWebForm');
    var id='';
    if(i1>=0)
    {
        for(var i2=i1+8;i2<i1+14;i2++)
        {
            if((s1.charAt(i2)=='.')||(s1.charAt(i2)=='_'))
            {
                break;
            }
            else id+=s1.charAt(i2);
        }
    }

    var lbl3=document.getElementById(base_id+'id1');
    var lbl4=document.getElementById(base_id+'id2');
    if(lbl3.className.indexOf('collapsed')>0)
    {
        lbl3.className="h_expand_gif";
        lbl4.className="h_expand_gif";
    }
    else
    {
        lbl3.className="h_collapsed_gif";
        lbl4.className="h_collapsed_gif";
    }
    if (typeof lbl == 'string') 
    {
        lbl = document.getElementById(lbl);
    }
    var mf = FindMainForm();
    var x = mf.isNotFast;
    var index = parseInt(lbl.id.substring(13,14));
    var img1 = lbl.getElementsByTagName('img')[0];
    var b = lbl.parentNode.parentNode.parentNode.rows[1];
    var b2 = b;
    var b1 = null;
    var state = b.getAttribute('isshowing');
    if ((index == 1) && (b.innerHTML.indexOf('LinePanel1')>=0))
    {
        b = Get_Element_By_Id(document, 'LinePanel1');
        b1 = Get_Element_By_Id(document, 'LinePanel2');
    }
    if (state)
    {
        b2.removeAttribute('isshowing');
        if (x)
        {
            $(b).css({display:''}).slideUp(mf.speedCommand, function(){M_toggleImage(img1);});
            $(b1).css({display:''}).slideDown(mf.speedCommand, function(){});                            
        }    
        else
        {
            $(b).css({display:''}).hide();
            $(b1).css({display:''}).show();
            //if (b1)
                //b1.scrollIntoView();
        }    
    }
    else
    {
        if (!b2.getAttribute('loaded'))
        {
            b2.setAttribute('loaded', 'true');
            M_Sub_Server(id+'_Page_'+index,index);

        }
        b2.setAttribute('isshowing', 'true');            
        if (x)
        {
            $(b1).css({display:''}).slideUp(mf.speedCommand, function(){});
            $(b).css({display:''}).slideDown(mf.speedCommand, function(){M_toggleImage(img1);/*b.scrollIntoView();*/});
        }    
        else
        {
            $(b1).css({display:''}).hide();
            $(b).css({display:''}).show();
            //if (b)
                //b.scrollIntoView();
        }    
    }
    if (!x)
        M_toggleImage(img1);
        
    var lbl = Get_Element_By_Id_3(document, 'chkLock_1');
    if (lbl && !lbl.checked && index > 1)
    {
        b2 = Get_Element_By_Id_3(document, 'Row1');
        if (b2.getAttribute('isshowing'))
        {
            b2.removeAttribute('isshowing');
            b = Get_Element_By_Id(document, 'LinePanel1');
            b1 = Get_Element_By_Id(document, 'LinePanel2');
            
            if (x)
            {
                $(b).css({display:''}).slideUp(mf.speedCommand, function(){M_toggleImage(img1);});
                $(b1).css({display:''}).slideDown(mf.speedCommand, function(){/*b1.scrollIntoView();*/});
            }    
            else
            {
                $(b).css({display:''}).hide();
                $(b1).css({display:''}).show();
                //if (b1)
                    //b1.scrollIntoView();
            }
        }    
    }
}
/*********************************************************************************/
function M_breakerToggle_Clear()
{
    var lbl1 = Get_Element_By_Id_3(document, 'B1_Vis');
//r1{
    if (lbl1 == null) {
        lbl1 = document.getElementById('B1_Vis');
    }
//r1}
    lbl1.style.display = '';
    for(var i=2;i<12;i++)
    {
        var lbl2 = Get_Element_By_Id_3(document, 'B' + i.toString() + '_Vis');
         //r1{
        if (lbl2 == null) {
            lbl2 = document.getElementById('B' + i.toString() + '_Vis');
        }
        //r1}
        var lbl1 = Get_Element_By_Id_3(document,'Row' + i.toString());
        if(lbl2!=null)
        {
            lbl2.style.display = 'none';
        }
        if(lbl1!=null)
        {
            lbl1.style.display = 'none';
        }
    }
    cur_index=1;
}
/*********************************************************************************/
function M_breakerToggle2(First_Frame,id,index,Show_Grid3)
{
    if((cur_index>0)&&(cur_index!=index))//&&(!ref))
    {
        var lbl1 = Get_Element_By_Id_3( document,'B' + (cur_index) + '_Vis');
         
        lbl1.style.display = 'none';
        var lbl2 = Get_Element_By_Id_3(document, 'chkLock_1');

        var lbl1 = Get_Element_By_Id_3( document,'Row' + (cur_index));
        
        if (!(lbl2 && lbl2.checked && cur_index == 1))
        {
            M_breakerToggle3(First_Frame,id,lbl1,cur_index,true,Show_Grid3);
            b1 = Get_Element_By_Id_4(document, 'LinePanel3',First_Frame);
            if(b1!=null)$(b1).css({display:''}).show();
        }
        else
        {
            b1 = Get_Element_By_Id_4(document, 'LinePanel3',First_Frame);
            $(b1).css({display:''}).hide();
        }
    }
    var lbl3 = Get_Element_By_Id_3( document,'B' + (index)+'_Vis');
    lbl3.style.display = '';
    var lbl = Get_Element_By_Id_3( document,'Row' + (index));
    M_breakerToggle3(First_Frame,id,lbl,index,false,Show_Grid3);
    cur_index=index;
}

function M_breakerToggle3(First_Frame,id,b,index,state,Show_Grid3)
{
    var b2 = b;
    var b1 = null;
    //var state = b.getAttribute('isshowing');
    var lbl = Get_Element_By_Id_3( document,'chkLock_1');
    var mf = FindMainForm();
    var x = mf.isNotFast;
    if ((index == 1) && (b.innerHTML.indexOf('LinePanel1')>=0))
    {
        b1 = Get_Element_By_Id_4 (document, 'LinePanel2',First_Frame);
        if (b1==null)
        {
          b1=document.getElementById('LinePanel2')   
        }
        b = Get_Element_By_Id_4(document, 'LinePanel1',First_Frame);
        //b4 = Get_Element_By_Id(b, 'Panel_GRid4');
        b4=document.getElementById('Panel_GRid4');
    }
    if (state)
    {
        b2.removeAttribute('isshowing');
        if (x)
        {
            $(b).css({display:''}).slideUp(mf.speedCommand, function(){/*M_toggleImage(img1);*/});
            $(b1).css({display:''}).slideDown(mf.speedCommand, function(){/*b1.scrollIntoView()*/});                            
        }    
        else
        {
            $(b).css({display:''}).hide();
            if (b1==null)
            {
                b1=document.getElementById('LinePanel2')   
            }
            if (Show_Grid3)
            {
                $(b4).css({display:''}).show();
                $(b1).css({display:''}).hide();
            }
            else
            {
                $(b1).css({display:''}).show();
                $(b4).css({display:''}).hide();
            }
        }    
    }
    else
    {
        if (!b2.getAttribute('loaded'))
        {
            b2.setAttribute('loaded', 'true');
            M_Sub_Server(id+'_Page_'+index,index);
        }
        b2.setAttribute('isshowing', 'true');            
        if (x)
        {
            $(b1).css({display:''}).slideUp(mf.speedCommand, function(){});
            $(b4).css({display:''}).slideUp(mf.speedCommand, function(){});
            $(b).css({display:''}).slideDown(mf.speedCommand, function(){/*M_toggleImage(img1);/*b.scrollIntoView();*/});
        }    
        else
        {
            $(b1).css({display:''}).hide();
            //$(b4).css({display:''}).hide();
            $(b).css({display:''}).show();
        }    
    }
    var lbl = Get_Element_By_Id_3( document,'chkLock_1');
    if (lbl && !lbl.checked && index > 1)
    {
        b2 = Get_Element_By_Id_3( document,'Row1');
        if (b2.getAttribute('isshowing'))
        {
            b2.removeAttribute('isshowing');
            b = Get_Element_By_Id_4(document, 'LinePanel1',First_Frame);
            b1 = Get_Element_By_Id_4(document, 'LinePanel2',First_Frame);
            //b4 = Get_Element_By_Id(b, 'Panel_GRid4');
            b4=document.getElementById('Panel_GRid4');
            
            if (x)
            {
                $(b).css({display:''}).slideUp(mf.speedCommand, function(){/*M_toggleImage(img1);*/});
                $(b4).css({display:''}).slideUp(mf.speedCommand, function(){/*M_toggleImage(img1);*/});
                $(b1).css({display:''}).slideDown(mf.speedCommand, function(){/*b1.scrollIntoView();*/});
            }    
            else
            {
            
                if (Show_Grid3)
                {
                    $(b4).css({display:''}).show();
                    $(b1).css({display:''}).hide();
                    $(b).css({display:''}).hide();
                }
                else
                {
                    $(b1).css({display:''}).show();
                    $(b4).css({display:''}).hide();
                    $(b).css({display:''}).hide();
                }
               
            }
        }    
    }
}

/*********************************************************************************/
/*********************************************************************************/
function M_ClearCommandText(eleman)
{
    if (eleman != '')
        Get_Element_By_Id(document,eleman).value="";
}
/*********************************************************************************/
/*********************************************************************************/
function M_SetCommandText(master,lbl, eleman)
{
    if (lbl)
    {
        if (typeof lbl == 'string')
            lbl = Get_Element_By_Id(document,lbl);
        var seri=lbl.value;
        if(seri=="")seri="-1";
       var ret=Get_Sub_Place("SelectCommand",M_GetFormID(),Get_Sabt_Serial(),seri);
        //eval('var ret = '+master+'.SelectCommand(M_GetFormID(),Get_Sabt_Serial(),'+seri+').value');
        
        if ( eleman.trim()!="")
        {
            Get_Element_By_Id(document,eleman).value+=ret;
        }
        else 
        {
           document.frames[0].document.body.innerHTML+= "<p align='right'>"+ret+"</p>";
        }
        
    }
}
/*********************************************************************************/
/*********************************************************************************/
function M_PressKey_Refer(master,lbl, eleman)
{
    if (window.event.keyCode==13 )
    {
      M_SetCommandText(master,lbl, eleman)  
    }
    
}
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
function Mask_KeyDown(lbl,eve)
{
    var mask = lbl.getAttribute('mask');
    if (mask)
    {
        if (!isMaskDigit(mask))
        {
            var b,d,f,g;
            var a=eve.keyCode;
            d=getSelStart(lbl);
            f=lbl.value;
            if((a==8||a==46)&&(d!=-1))
            {
                
                CancelEventHandeler(eve);
                
                b=f.length;
                g='';
                if(a==8)
                {
                    if (d>0)
                    {
                        while (d>1 && isNaN(parseInt(f.charAt(d-1)))) d--;
                       
                        g+=f.substring(0,d-1);
                        g+='0';
                        if(b>d)g+=f.substring(d,b);
                        d--;
                    }
                    else g=f;
                }
                else
                {
                    if (d<b)
                    {
                        while (d<b && isNaN(parseInt(f.charAt(d)))) d++;

                        g+=f.substring(0,d);
                        g+='0';
                        if(b-1>d)g+=f.substring(d+1,b);
                        d++;
                    }
                    else g=f;
                }
                lbl.value = g;
                setSelection(lbl,d,d);
            }
        }
    }
}
/*********************************************************************************/
/*********************************************************************************/
function Mask_KeyPressed(lbl,eve)
{
    var c,e,f;    
    var mask = lbl.getAttribute('mask');
    if (mask) 
    {
        var a=get_keypressed(eve);
        if(a==13) return a;
        if (a>=48&&a<=57)
        {
            if (!isMaskDigit(mask))
            {
                c=getSelStart(lbl);
                e=lbl.value;
                if (e=='')
                    e=getClearMask(mask);
                while (c < e.length && isNaN(parseInt(e.charAt(c)))) c++;

                if (c<e.length)
                {
                    var p = e.substring(0,c);
                    p += String.fromCharCode(a);
                    p += e.substring(c+1, e.length);
                    
                    f=Mask_Conv(p, mask);
                    
                    lbl.value = f;
                    c++;
                    while (c < f.length && isNaN(parseInt(f.charAt(c)))) c++;

                    setSelection(lbl,c,c);
                }
            }
            else if (lbl.value.length<mask.length) return;
        }
        CancelEventHandeler(eve);
        return false;
    }
}
/*********************************************************************************/
/*********************************************************************************/
function Int_KeyPressed(lbl,eve)
{
    var c,e,f;    
    var a=get_keypressed(eve);
    if(a==13) return a;
    if (a>=48&&a<=57)
    {
    }
    else
    {
        c=getSelStart(lbl);
        setSelection(lbl,c,c);
    }
    CancelEventHandeler(eve);
    return false;
}
/*********************************************************************************/
/*********************************************************************************/
function getClearMask(mask)
{
    var ret = '';
    for (var i=0; i<mask.length;i++)
        if (!isNaN(parseInt(mask.charAt(i))))
            ret+='0';
        else 
            ret+=mask.charAt(i);
    return ret;
}
/*********************************************************************************/
/*********************************************************************************/
function isMaskDigit(mask)
{
    for (var i=0; i<mask.length;i++)
        if (isNaN(parseInt(mask.charAt(i))))
            return false;
    return true;
}
/*********************************************************************************/
/*********************************************************************************/
function getMaskNumberCount(mask)
{
    var idx=0;
    for (var i=0; i<mask.length;i++)
        if (!isNaN(parseInt(mask.charAt(i))))
            idx++;
    return idx;
}
/*********************************************************************************/
/*********************************************************************************/
function Mask_Conv(g, mask)
{
    var a,b,c,d,e,f;

    d = g.length;
    for(f=d+1;f<=mask.length;f++)g+='0';

    var t='';
    var i=0;
    var idx=0;
    var ml = mask.length;
    var MConsts = '';
    var VTexts = '';
    var temp = '';
    while (i<ml)
    {
        if (isNaN(parseInt(mask.charAt(i))))
        {
            var x = i;
            while (i + 1 < ml && isNaN(parseInt(mask.charAt(i + 1)))) i++;
            if (MConsts == '')
                MConsts = mask.substring(x,i+1);
            else
                MConsts += String.fromCharCode(200)+mask.substring(x,i+1);

            temp = g.substring(idx, x);
            if (parseInt(t) > 0 && parseInt(temp)>parseInt(t))
                temp = t;
                
            if (VTexts == '')
                VTexts = temp;
            else
                VTexts += String.fromCharCode(200)+temp;
            
            t='';
            idx = i + 1;
        }
        else t += mask.charAt(i);
        i++;
    }       
    temp = g.substring(idx, ml);
    if (parseInt(t) > 0 && parseInt(temp)>parseInt(t))
        temp = t;
    if (VTexts == '')
        VTexts = temp;
    else
        VTexts += String.fromCharCode(200)+temp;
    MConsts = MConsts.split(String.fromCharCode(200)); 
    VTexts = VTexts.split(String.fromCharCode(200)); 

    var h=VTexts[0];
    for (i=1;i<VTexts.length;i++)
        h += MConsts[i-1]+ VTexts[i];
    
    return h;
}
/*********************************************************************************/
/*********************************************************************************/
function showKarbarName(d, eve)
{
    if (eve != undefined && get_keypressed(eve)!=13) return false;
    //eval('var res = '+Get_FromForm()+'.GetKarbarName("' + d.value + '",Get_Sabt_Serial()).value;');
   var res=Get_Sub_Place("GetKarbarName",'',Get_Sabt_Serial(),d.value);
    var lbl = d.parentNode.parentNode.getElementsByTagName('input')[0];
    lbl.value = res;
    lbl.defaultValue= res;
    return (res!="");
}
/*********************************************************************************/
function showClassMan(d, eve)
{
    if (eve != undefined && get_keypressed(eve)!=13) return;
   // eval('var res = '+Get_FromForm()+'.GetClassMan("' + d.value + '",Get_Sabt_Serial()).value;');
    var res=Get_Sub_Place("GetClassMan",'',Get_Sabt_Serial(),d.value);
    var lbl = d.parentNode.parentNode.getElementsByTagName('input')[0];
    lbl.value = res;
    lbl.defaultValue= res;
}/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
function changeGridViewPageSize(lbl2,lbl,ext)
{
    lbl = Get_Element_By_Id(document,lbl);
    M_Set_Cookie(this, lbl.id, lbl.selectedIndex.toString());
    GridViewChange('ChgPager$',lbl2, ext);
}
/*********************************************************************************/
/*********************************************************************************/
function setColor(r, g, b) 
{	
    if (r != null) rr = decToHexColor(r);
    else rr = '00';
    if (g != null) gg = decToHexColor(g);	
    else gg = '00';
    if (b != null) bb = decToHexColor(b);	
    else bb = '00';
    return "#" + rr + gg + bb;
}
function decToHexColor(dec) 
{	
    var hex = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']; 	
    dec = parseInt(dec); 	
    return hex[parseInt(dec / 16)] + hex[dec % 16]; 
}
/*********************************************************************************/
/*********************************************************************************/
function treeItemClick(item, dastor)
{
    if (item.getAttribute('active'))
    {
        item.removeAttribute('active');
        item.className = "S_Menu_Item_Over";
    }
    else
    {
        item.setAttribute('active','true');
        item.className = "S_Menu_Item";
    }
    if(dastor!="")eval(dastor);
}
/*********************************************************************************/
/*********************************************************************************/
function M_reverseSelectItems(lbl)
{
    lbl = Get_Element_By_Id(document, lbl);
    var d3 = lbl.getElementsByTagName("div");
    var s3 = lbl.getElementsByTagName("input");
    var i=0;
    if(d3.length>0)
    {
        while(i<s3.length)
        {
            if(d3[i].style.display=='')
            {
                s3[i].checked=! s3[i].checked;
            }
            i++;
        }
    }
    else
    {
        while(i<s3.length)
        {
            s3[i].checked=! s3[i].checked;
            i++;
        }
    }
}
/*********************************************************************************/
/*********************************************************************************/
function M_SelectItems(lbl, val)
{
    lbl = Get_Element_By_Id(document, lbl);
    var d3 = lbl.getElementsByTagName("div");
    var s3 = lbl.getElementsByTagName("input");
    var i=0;
    if(d3.length>0)
    {
        while(i<s3.length)
        {
            if(d3[i].style.display=='')
            {
                s3[i].checked = val;
            }
            i++;
        }
    }
    else
    {
        while(i<s3.length)
        {
            s3[i].checked = val;
            i++;
        }
    }
}
/*********************************************************************************/
/*********************************************************************************/
function getFlashClock()
{
    if (isIE) 
    {
//        if(navigator.appVersion.indexOf("MSIE 9.0")>=0)
        var codebase = document.location.protocol+'//'+document.location.host+'/dabirfiles/install_flash_player_ie.exe';
    }
    else var codebase = document.location.protocol+'//'+document.location.host+'/dabirfiles/install_flash_player.exe';
    return '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+codebase+'" WIDTH="128" HEIGHT="128" id="fnsclockx"><PARAM NAME=movie VALUE="../Theme_1/clock/clock0.swf"><PARAM NAME=quality VALUE=high><PARAM NAME=menu VALUE="false"><PARAM NAME=wmode VALUE="transparent"><EMBED href="../Theme_1/clock/clock0.swf" quality=high WIDTH="128" HEIGHT="128" NAME="fnsclockx" TYPE="application/x-shockwave-flash" PLUGINSPAGE="'+codebase+'"></EMBED></OBJECT>'
}
/*********************************************************************************/
/*********************************************************************************/
function CancelEventHandeler(eve)
{
    if (eve.stopPropagation)
    {
        eve.stopPropagation();
        eve.preventDefault();
    }
    else 
    {
        eve.cancelBubble = true;
        eve.returnValue = false;
    }
}
/*********************************************************************************/
function Get_Master_FKey(key,event)
{
    if (FindMainForm.Down_Shift_Key_Text)        return;
    var alt=GetFunctionKey(event, true, undefined, undefined);
    var shift=GetFunctionKey(event, undefined, undefined, true);
    if ((alt)||(shift))//Alt+Shift
    {
        var eleman='';
        var b1=false;
        var lbl1=null;
        if(alt)
        {
            switch(key)
            {
                case 49://1
                    eleman='ctl00_M_But1';
                    b1=true;
                    break;
                case 50://2
                    eleman='ctl00_M_But2';
                    b1=true;
                    break;
                case 51://3
                    eleman='ctl00_M_But3';
                    b1=true;
                    break;
                case 52://4
                    eleman='ctl00_M_But4';
                    b1=true;
                    break;
                case 53://5
                    eleman='ctl00_M_But5';
                    b1=true;
                    break;
                case 54://6
                    eleman='ctl00_M_But6';
                    b1=true;
                    break;
                case 55://7
                    eleman='ctl00_M_But7';
                    b1=true;
                    break;
            }
        }
        if(shift)
        {    
            
            switch(key)
            {
                case 49://1
                    eleman='ctl00_T_But1';
                    b1=true;
                    break;
                case 50://2
                    eleman='ctl00_T_But2';
                    b1=true;
                    break;
                case 51://3
                    eleman='ctl00_T_But3';
                    b1=true;
                    break;
                case 52://4
                    eleman='ctl00_T_But4';
                    b1=true;
                    break;
                case 53://5
                    eleman='ctl00_T_But5';
                    b1=true;
                    break;
                case 54://6
                    eleman='ctl00_T_But6';
                    b1=true;
                    break;
                case 55://7
                    eleman='ctl00_T_But7';
                    b1=true;
                    break;
            }
        }
        if(b1)
        {
            lbl1=document.getElementById(eleman);
            if(lbl1==null)lbl1=parent.document.getElementById(eleman);
            if(lbl1!=null)
            {
                lbl1=lbl1.childNodes[0];
                lbl1.click();
                var i1=0;
            }
            CancelEventHandeler(event);    
            FindMainForm().Event_KeyBoard(key);
            clear_event(event);
        }
    }    
}
/*********************************************************************************/
function DefaultFKey(obj,e)
{
    var key = get_keypressed(e);
    if(! Get_Master_FKey(key,e))
    {
        switch (key)
        {
            case 87://W
                if(GetFunctionKey(e,true,undefined,undefined))
                {
                    CancelEventHandeler(e);    
                    FindMainForm().deleteTab();
                    clear_event(event);
                    break;    
                }
            case 112://F1
            case 113://F2
            case 114://F3
            case 115://F4
            case 116://F5
            case 117://F6
            case 118://F7
            case 119://F8
            case 120://F9
            case 121://F10
            case 122://F11
            case 123://F12
                if (GetFunctionKey(e, undefined, undefined, true))//Shift
                {
                    CancelEventHandeler(e);    
                    FindMainForm().Event_KeyBoard(key);
                    clear_event(event);
            }    
                break;
            case 49://1
                if (GetFunctionKey(e, undefined, true, undefined))//Ctrl
                {
                    CancelEventHandeler(e);  
                    FindMainForm().language_change1();
                    clear_event(event);
                    return true;
                }    
                break;
            case 50://2
            case 51://3
            case 52://4
            case 53://5
            case 54://6
            case 55://7
            case 56://8
            case 57://9
                if (GetFunctionKey(e, undefined, true, true))//Ctrl + Shift
                {
                    CancelEventHandeler(e);    
                    FindMainForm().changeInfoPosition(key - 48);        
                }    
                break;
                case 8://BackSpace  
                    var s1=e.srcElement.tagName.toLowerCase();
                    if(!((s1=='input')||(s1=='textarea')))
                    {
                        CancelEventHandeler(e);  
                        clear_event(event);
                    }
                    return true;
                break;
                default:
                break;
        }
        return false;
    }
    else
    {
        CancelEventHandeler(e);  
        clear_event(event);
        return true;
    }
}
/*********************************************************************************/
/*********************************************************************************/
function GridViewSelectAll(lbl,pre)
{
    if (lbl.checked) M_Sub_Server(pre+"SelectAll"); else M_Sub_Server(pre+"SelectNone");        
}
/*********************************************************************************/
/*********************************************************************************/
function shellClientApp2(local_path,http_path,switch_nam,ip_server)
{
    if (isIE)
    {

        try
        {
            var shell = new ActiveXObject("WScript.shell");
            shell.Run(local_path+switch_nam+' '+ip_server , 1);
            return true;
        }
        catch (e)
        {
            //location.href='file://c:/dabir/'+switch_nam +'/'+ip_server;
        
            //location.href=http_path+switch_nam +'&'+ip_server;
            
            return false;
        }    
    }
    else if (window.netscape)
    {
        try
        {
           
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
            local_path = "C:\\dabir\\";
            var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
            file.initWithPath(local_path+switch_nam+' '+ip_server);
            if (file.exists())
            {
                file.launch();
                return true;
            }
            return true;
        }
        catch (e)
        {
            return false;
        }        
    }
    return false;
}
//-----------------------------------------------------------------------------
function ConvertToNumber(eve,ax,maxlen)
{
    if(maxlen==0)
    {
        var KeyID =eve.keyCode;
        if ( KeyID<48 || KeyID>57) eve.keyCode = 0 ;
    }
    else
    {
        var KeyID =eve.keyCode;
        if ( KeyID<48 || KeyID>57 || ax.value.length>=maxlen) eve.keyCode = 0 ;
    }
}
function showMacAddress2()
{
	var obj = new ActiveXObject("WbemScripting.SWbemLocator");
	var s = obj.ConnectServer(".");
	var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
	var e = new Enumerator (properties);
	var output='';
	var indx=0;
	while(!e.atEnd())
	{
		e.moveNext();
		var p = e.item ();
		if(!p) continue;
		if(p.MACAddress!=null)
		{
		    output+=p.Description+'>';
		    output+=p.MACAddress+'>';
		    output+=p.IpAddress(0);
		    output+='\r\n';
	    }
	}
	return output;
}
function users_onchange(ax1,ax2)
{
    var lbl1=Get_Element_By_Id(document,ax1);
    var lbl2=Get_Element_By_Id(document,ax2);
    lbl2.selectedIndex=lbl1.selectedIndex;
}
//***********************************************************************************
//                                Switch2.js
//***********************************************************************************

var S_index = -1;
var S_docs=[];
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
function S_Check_Switch_End_Timer(Check_End_Switch_Sub,key,t,d,sw)
{
var b1=0;
var str="";
var str1="";
try
{
    str = pasteFromClipBoard(sw);
}
catch (exp)
{
    str="";
}
if(str!=null && str!="")
{
    if(str.length>=key.length)
    {
        var str1=str.substring(0,key.length);
        if(str1==key)
        {
            if(t!=null)if(t!='null')S_Maximize(d,t);
            if(Check_End_Switch_Sub != undefined)
            {
                if(Check_End_Switch_Sub.trim()!="")
                {
                    FindMainForm().act_switch=false;
                    str = str.substring(key.length,str.length);
                    if(str.charAt(0)=='-')str=str.substr(1,str.length);
                    if(str.charAt(str.length-1)=='-')str=str.substr(0,str.length-1);
                    str=str.replace("-","\r\n");
                    //M_Sub_Server(Check_End_Switch_Sub+'$'+str);Add_Code
                    M_Sub_Server(Check_End_Switch_Sub+'$'+str,3);
                }
            }    
            b1=1;
        }
    }            
}
if(b1==0)
{
    setTimeout("S_Check_Switch_End_Timer('"+Check_End_Switch_Sub+"','"+key+"','"+t+"',"+d+","+sw+")", 300);
}            
}
function S_Check_Switch_End_Timer2(Check_End_Switch_Sub,key,t,d)
{
var b1=0;
var str="";
var str1="";
try
{        
    str=FindMainForm().Get_Cookie_FSN2_RecivedData_();      
}
catch (exp)
{
    str="";
}
if((str!=null && str!=""))
{
    if (str == "Active")
    {        
        if(Check_End_Switch_Sub != undefined)
        {
            if(Check_End_Switch_Sub.trim()!="")
            {
                FindMainForm().act_switch=false;
                str = str.substring(key.length,str.length);
                M_Sub_Server(Check_End_Switch_Sub+'$'+str);
            }
        }    
        b1=1;  
    }            
}
if(b1==0)
{
    setTimeout("S_Check_Switch_End_Timer2('"+Check_End_Switch_Sub+"','"+key+"','"+t+"',"+d+")", 300);
}            
}
//----------------------------------------------------------------------------------
function S_CallSwitch(frame,Check_End_Switch_Sub,OprandType,SubCode,dis_bak,sw) 
{
//emza mode | spmElsug |spmFax | spmPrint | spmPdf | spmGif | TSaveType(16) | TSaveType(8) | mail_merg_en | Visible | sadeh
// 2048        1024       512       256        64      32          16              8               4             2       1
//debugger;
    var lbl=M_GetFormID();
    if(SubCode=="")SubCode="0";
    var modal_details= Get_Sub_Place("Get_Switch_Str",M_GetFormID(),Get_Sabt_Serial(),OprandType,SubCode);
    //eval('var modal_details = '+frame+'.Get_Switch_Str("'+M_GetFormID()+'",Get_Sabt_Serial(),'+OprandType+','+SubCode+').value');
    if (modal_details!= null)
    {    
        FindMainForm().act_switch=true;
        var ret='';
        if(sw!=1)
        {
            for(var i=0;i<70;i++)
            {
                var date1=new Date();
                do
                {
                    var date2=new Date();
                }while(date2-date1<100); 
                ret=FindMainForm().get_frm_Switcher(sw,2);    
                if(ret!='Active_Switch_Request')break;
            }
        }
        if((ret!='Active_Switch_Response')&&(sw!=1))
        {
            var res=shellClientApp2(modal_details[4],modal_details[5],modal_details[6],modal_details[7]);
            setTimeout('S_Sub_CallSwitch("'+modal_details[1]+'","'+Check_End_Switch_Sub+'","'+modal_details[3]+'",'+dis_bak+','+sw+');',2000);
        }
        else 
        {
            copyToClipBoard(sw,modal_details[1]);
            var tt = null;
            if(dis_bak)
            {
                tt = (Math.random()*100000).toFixed().toString();
                S_Minimize(tt);
            }
            S_Check_Switch_End_Timer(Check_End_Switch_Sub,modal_details[3],tt,S_index,sw);
        }
    }
}
//--------------------------------------------------------------------------------------
function S_Sub_CallSwitch(s1,s2,s3,s5,sw)
{
    for(var i=0;i<70;i++)
    {
        var date1=new Date();
        do
        {
            var date2=new Date();
        }while(date2-date1<100); 
        ret=FindMainForm().get_frm_Switcher(sw,2);    
        if(ret!='Active_Switch_Request')break;
    }
    if(ret=='Active_Switch_Response')
    {    
        copyToClipBoard(sw,s1);
        var tt = null;
        if(s5)
        {
            tt = (Math.random()*100000).toFixed().toString();
            S_Minimize(tt);
        }
        S_Check_Switch_End_Timer(s2,s3,tt,S_index,sw);
    }
}

//-------------------------------------------------------------------------------------
function S_Minimize(t)
{
    M_cretaeAndShowBackground(window.document, t);
    S_index++;
    S_docs[S_index] = window.document;
}
//--------------------------------------------------------------------------------
function S_Maximize(idx,t)
{
    if(t!=null)
    {
        M_removeBackgroundDiv(S_docs[idx],t);
    }
}
//--------------------------------------------------------------------------------
function S_Check_Switch()
{
    M_Set_Cookie(this,'Switch_Start', 'Switch_End');
    window.open('blank','_blank','toolbar=no,location=no,directories=no, status=no,menubar=no,resizable=no,scrolling=yes,width=50,height=50,top=0,left=0 ');
    document.title="gggggggggggg";
    FindMainForm().Switch_Var="xxxxxxxxxxxxxxxxxxxxxxx";
    FindMainForm().CallSaveSwitch(FindMainForm().Switch_Var);
    if (document.title=='UnAct')
    {
       
        setTimeout("S_Check_Switch()", 300);
    }
}
//--------------------------------------------------------------------------------


