function open_dialogbox(path,width,height,resize,scroll,status,samewindow)
{	
	var w = 480, h = 340;
	if(!width)
		width="700";
	if(!height)
		height="500";
	if(!resize)
		resize="no";
	if(!scroll)
		scroll="no";
	if(!samewindow)
		samewindow="objwnd";
	if(!status)
		status="no";
	
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	objwnd=window.open(path,samewindow,"munubar=no,titlebar=no,status="+status+",resizable="+resize+",scrollbars="+scroll+",width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd.focus();
}
function SelectAllCheckBox(objChkAll, objCBL)
{    
    if (objCBL.length)
    {
        for (i = 0; i < objCBL.length; i++)
        {
            if (objChkAll.checked == true) { objCBL[i].checked = true; }
            else { objCBL[i].checked = false; }
        }
    }
    else
    {
        if (objChkAll.checked == true) { objCBL.checked = true; }
        else { objCBL.checked = false; }
    }
}
function Check_CheckBoxSelection(objCBL)
{
    if (objCBL.length)
    {
        for (i = 0; i < objCBL.length; i++)
        {
            if (objCBL[i].checked == true) { return true; }
        }
    }
    else
    {
        if (objCBL.checked == true) { return true; }
    }
    return false;
}
function PerformAction(ActDrpDwnId, objCBL, jsFncName)
{
    var objDD = $get(ActDrpDwnId);
    var selectedrecords = "";
    
    if (objDD.selectedIndex == 0)
    {
        alert("Please select an action to perform...");
        objDD.focus();
        return false;
    }
    if (Check_CheckBoxSelection(objCBL) == false)
    {
        alert("Please select atleast one record to perform action...");
        return false;
    }
    if (objCBL.length)
    {
        for (i = 0; i < objCBL.length; i++)
        {
            if (objCBL[i].checked == true)
            {
                if (selectedrecords != "") { selectedrecords += ","; }
                selectedrecords += objCBL[i].value;
            }
        }
    }
    else
    {
        if (objCBL.checked == true) { selectedrecords = objCBL.value; }
    }
    
    if (objDD.value.toLowerCase().indexOf("delete") >= 0)
    {
        if (confirm("Are you sure you want to delete selected records?"))
        {
            var func = jsFncName + "('Remove$" + selectedrecords + "');";
            eval(func);
        }
        else return false;
    }
    else
    {
        var func = jsFncName + "('" + objDD.value + "$" + selectedrecords + "');";
        eval(func);
    }
}
function ShowFilterPanel(objDD, objPnl, PnlType, objFromDate, objToDate)
{
    if (PnlType == "Date")
    {
        $get(objFromDate).value = "";
        $get(objToDate).value = "";
    }
    if ($get(objDD).selectedIndex != 0)
        ShowByID_Inline(objPnl);
    else
        HideByID(objPnl);
}
function ShowByID_Inline(id)
{
    $get(id).style.display = "inline";
}
function ShowByID(id)
{
    $get(id).style.display = "block";
}
function HideByID(id)
{
    $get(id).style.display = "none";
}
function DisplayCustomTag(param,objname)
{
	if(param!="")
	{
		paramarr=param.split(",");
		var paramstr="";
		for(i=0;i<paramarr.length;i++)
		{
			paramstr+=",[\""+paramarr[i]+"\",\"[["+paramarr[i].toUpperCase()+"\]]\"]";
		}
		objname.arrCustomTag=eval("["+paramstr.substr(1)+"]");
	}
}
function ResetPaging(PagingCtl)
{
    __doPostBack(PagingCtl);
}

function deleteinvoice()
{
    if(confirm('You are about to delete order. Please note that any associated information related to this particular order will also be permanently removed and not retrievable.\n\nDo you wish to delete this order ?'))
    {
       return true;
    }
     return false;
}

function FireOnSubmit(event)
{
    if (event.which) // mozilla
        var keycode = event.which;
    else // ie
        var keycode = event.keyCode;
        //alert(keycode);
    if (keycode == 13)
    {
        return true;
    }
    return false;      
}

function showModalPopupViaClient(BehaviorID) 
{
    var modalPopupBehavior = $find(BehaviorID);
    //alert(BehaviorID + " - " + modalPopupBehavior);
    modalPopupBehavior.show();
}
function hideModalPopupViaClient(BehaviorID) 
{
    var modalPopupBehavior = $find(BehaviorID);
    modalPopupBehavior.hide();
    return false;
}
function replaceAll(str,from,to)
{
    var idx = str.indexOf(from);
    while (idx > -1) 
	{
        str = str.replace(from,to); 
        idx = str.indexOf(from);
    }
    return str;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}