﻿//Misc. JavaScript Functions
function confirm_delete(strMsg) {
  if (confirm(strMsg)==true)
    return true;
  else
    return false;
}
        
function PopupWindow(sLocation,sWinName) {
  window.open(sLocation,"report_" + sWinName,"status=yes,menubar=yes,scrollbars=yes,resizable=yes");
}

function WaitBtn(sBtnId) {
    if (Page_ClientValidate()) {
        ToggleBtn(document.getElementById(sBtnId),'Please Wait...',false);
    }
}

function ToggleBtn(oBtn,sText,bEnabled) {
    oBtn.disabled=!bEnabled;
    oBtn.value=sText;
}

/* Random String */
function RandomString(iLen) {
	var sStr = "";
	
	for(i=0; i<iLen; i++) {
		iRndNum = RandomNumber();
		sStr = sStr + String.fromCharCode(iRndNum)	
	}
	return sStr;
}

/* Random Number */
function RandomNumber() {
	var RndNum = Math.random()
	RndNum = parseInt(RndNum*1000);
	RndNum = (RndNum % 25) + 97;
	return RndNum;
}

/* Report Window */
function ReportWindow(sReport,sQueryString) {
	var _WinName = "rptWin_" + RandomString(4);
	var _WinUrl = sReport + "?" + sQueryString;
	//var _WinUrl = "/reports/rpt_load.aspx?rpt=" + sReport + sQueryString;
	
	oRptWin = window.open(_WinUrl,_WinName,"status=yes,menubar=yes,scrollbars=yes,resizable=yes");
	return oRptWin;
}

function ResetScrollPosition()
{
    setTimeout("self.scrollTo(0,0)",1000);
}

function ScrollToPosition()
{
    var pnlErrorMessage = document.getElementById('error');
    var x = pnlErrorMessage.offsetLeft;
    var y = pnlErrorMessage.offsetTop;

     alert("Script from master page");


    window.scrollTo(x, y);
}

function waittofade(strId) {
	if (document.getElementById(strId)) {
		setTimeout("fadeIn(7,'" + strId + "')", 3000);
	}
}

function fadeIn(where,strId) {
    if (where >= 1) {
        document.getElementById(strId).style.backgroundColor = "#FFFF" + Color[where];
		  if (where > 1) {
			  where -= 1;
			  setTimeout("fadeIn("+where+",'"+strId+"')", 500);
			} else {
			  where -= 1;
			  setTimeout("fadeIn("+where+",'"+strId+"')", 500);
			  //document.getElementById(strId).style.backgroundColor = "transparent";
			  document.getElementById(strId).style.display = "none";
			}
    }
}

function fadeInit(strId) {
	document.getElementById(strId).style.backgroundColor = "#FFFF99";
}