﻿// JScript File
var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}
if (window.navigator.userAgent.toLowerCase().match("opera")) {
   browserType= "opera"
}


function hide() {
  if (browserType == "gecko" )
  {
     document.poppedLayer = 
         eval('document.getElementById("divError")');
     document.poppedLayer.style.visibility = "hidden";
  }
  else if (browserType == "ie")
  {
     document.poppedLayer = 
        eval('document.getElementById("divError")');
     document.poppedLayer.style.visibility = "hidden";
  }
  else if (browserType == "opera")
  {
     document.poppedLayer = 
        eval('document.getElementById("divError")');
     document.poppedLayer.style.display = "none";
  }
  else
  {
     document.poppedLayer =   
        eval('document.layers["divError"]');  
     document.poppedLayer.style.visibility = "hidden";
  }
}

function validate_adaos(e)
	{
		var keynum
		if(window.event) // IE
		{
			keynum = e.keyCode
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which
		}

		if(((keynum>=48)&&(keynum<=57))||(keynum==8))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function validate_adaos(e)
	{
		var keynum
		if(window.event) // IE
		{
			keynum = e.keyCode
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which
		}

		if(((keynum>=48)&&(keynum<=57))||(keynum==8))
		{
			return true;
		}
		else
		{
			return false;
		}
	}


function press_enter(e, ctlText)
    {

	    if (!e) var e = window.event
	    if(e.keyCode==13)
		    {
		    if(ctlText=='COD')
			    {
			    var myButton=document.getElementById("ctl00_MainContentPlaceHolder_btnSearchCod");
			    myButton.focus();
			    //myButton.click();
			    }
    			
		    if(ctlText=='DEN')
			    {
			    var myButton=document.getElementById("ctl00_MainContentPlaceHolder_btnSearchDen");
			    myButton.focus();
			    //myButton.click();
			    }
			if(ctlText=='LOG')
			    {
			    var myButton=document.getElementById("ctl00_btnSignIn");
			    myButton.focus();
			    //myButton.click();
			    }
			if(ctlText=='UPD_ORDER')
			    {
			    if ($Selected+1 >9)
			        var Sel = $Selected+1
			    else
			        var Sel= '0' + $Selected+1
			        
			    var myButton=document.getElementById("ctl00_MainContentPlaceHolder_dgOrders_ctl"+Sel+"_btnUpdate");
			    myButton.focus();
			    //myButton.click();
			    }
		    if(ctlText=='ART')
			    {
			    //var myButton1=document.getElementById("ctl00_MainContentPlaceHolder_btnSearch");
			    //myButton1.focus();
			    //myButton1.click();
			    }
			if(ctlText=='Login')
			    {
			    var myButton=document.getElementById("lnkLogin");
			    //alert(myButton.Text);
			    myButton.focus();
			    //myButton.click();
			    }
			}
	    }

function press_Update(e, ctlText,RowID)
    {
    
	    if (!e) var e = window.event
	    if(e.keyCode==13)
		    {
		    if(ctlText=='UPD_ORDER')
			    {
			    var Sel = RowID.replace("tbxCerut","btnUpdate")
			    var myButton=document.getElementById(Sel);
			    myButton.focus();
			    myButton.click();
    		    }
			if(ctlText=='UPD_ORDER1')
			    {
			    var Sel = RowID.replace("tbxObservatii","btnUpdate")
			    var myButton=document.getElementById(Sel);
			    myButton.focus();
			    myButton.click();
    		    }
			}
	    }

function btnParameterInfo_Click(url){
			//window.showModalDialog(url,'','dialogWidth:640px;dialogHeight:480px;scroll:yes;resizable:yes;status:no;help:no;center:yes;');
			window.open(url,'','Width=640,Height=480,scroll=no,resizable=no,status=no,help=no,center=yes');
			//alert(url);
		}
function wopen(url, name, w, h){
				wleft = (screen.width - w) / 2;
				wtop = (screen.height - h) / 2;
				var win = window.open(url, 
									name,
									'width=' + w + ', height=' + h + ', ' +
									'left=' + wleft + ', top=' + wtop + ', ' +
									'location=no, menubar=no, ' +
									'status=no, toolbar=no, scrollbars=yes, resizable=no, titlebar=no, menubar=no');
									win.resizeTo(w, h);
									win.moveTo(wleft, wtop);
									win.focus();
			    return win;
				}

function wopen3(url, name, w, h){
				wleft = (screen.width - w) / 2;
				wtop = (screen.height - h) / 2;
				var win = window.open(url, 
									name,
									'width=' + w + ', height=' + h + ', ' +
									'left=' + wleft + ', top=' + wtop + ', ' +
									'location=no, menubar=no, ' +
									'status=no, toolbar=no, scrollbars=yes, resizable=no, titlebar=no, menubar=no');
									win.resizeTo(w, h);
									win.moveTo(wleft, wtop);
									win.focus();
				}
function SaveScroll1(val)
            {
                document.getElementById('hiddenScroll1').value = val;
            }
function SaveScroll2(val)
            {
                document.getElementById('hiddenScroll2').value = val;
            }
function RestoreScroll()
            {
                if (document.getElementById('scrollDiv1') != null)
                {
                    document.getElementById('scrollDiv1').scrollTop = document.getElementById('hiddenScroll1').value;
                    
                }
                if (document.getElementById('scrollDiv2') != null)
                {
                    document.getElementById('scrollDiv2').scrollTop = document.getElementById('hiddenScroll2').value;
                }
            }

function ResizeDivs()
            {
                if (document.getElementById('scrollDiv1') != null)
                {
                    document.getElementById('scrollDiv1').style.height= window.screen.availHeight*(27/100);
                }
                if (document.getElementById('scrollDiv2') != null)
                {
                    document.getElementById('scrollDiv2').style.height= window.screen.availHeight*(25/100);
                }
                else
                {
                    if (document.getElementById('scrollDiv1') != null)
                    {
                        document.getElementById('scrollDiv1').style.height= window.screen.availHeight*(55/100);
                    }
                }
            }
function ResizeDiv2(percent)
            {
                document.getElementById('scrollDiv2').style.height= window.screen.availHeight*(percent/100);
            }
            
function GridSelectRow(id){
			var CellClicked = document.activeElement;
			var RowClicked = CellClicked.parentNode;
			var FirstCell = RowClicked.children[0];
			var InputField = FirstCell.children[0];
				
			if (InputField != null){
					__doPostBack(InputField.name,'');
			}
		}
		
function myInitPage()
		{
			var objErrorLabel = document.getElementById("lblUrlModalWindowHidden");
    		if(objErrorLabel!=null){
    		    window.open('MsgBox.aspx','name','height=100,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, modal=yes');
    		    }
    		//if (window.showModalDialog) {
            //    var oRet = window.showModalDialog("MsgBox.aspx","name","dialogWidth:255px;dialogHeight:250px");
            //} else {
            //    var oRet = window.open('MsgBox.aspx','name','height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
            //    }

    		
    		
    		    //if (confirm('Vrei sa procesezi comanda?')==true)
    		    //    __doPostBack('btnAddManual','');
                //var oRet = window.showModalDialog(objErrorLabel.value,'','dialogWidth:300px;dialogHeight:200px;center:yes;scroll:no;resizable:no;status:no;');    		        
			    //var oRet = window.open(objErrorLabel.value,'','dialogWidth:300px;dialogHeight:200px;center:yes;scroll:no;resizable:no;status:no;');
			    
			    //if (oRet) __doPostBack('btnAddManual','');
			    
				//var res = modalDialog(objErrorLabel.value, 400, 200);
				//if(res)
				//{
			//		__doPostBack('btnAddManual','');
				//}
			//}
			
		}

//Anthem function to show/hide Loading text

function Anthem_PreCallBack() { 

        var loading = document.createElement("div"); 
        loading.id = "loading"; 
        loading.className = "anthemLoading";
        loading.innerHTML = "<img src='images/loading.gif' />"; 
        document.body.appendChild(loading); 
} 

function Anthem_PostCallBack() { 
        var loading = document.getElementById("loading"); 
        document.body.removeChild(loading); 
}

function ScrollToTop()
{
    window.scrollTo(0,0);
}

