function PopupReport(url) {
	window.open(url, "Report", "scrollbars=yes,status=yes,resizable=yes,width=770,height=580");
}

function PopupMap(url) {
	var wnd = window.open("", "Map", "scrollbars=yes,status=yes,resizable=yes,width=550,height=450");
	if (wnd != null) {
		var strHtml = "<html><head><title>TOT Service Office Map...</title>"
			+ "<link href=\"/Include/Styles/Backend.css\" type=\"text/css\" rel=\"stylesheet\"></head>"
			+ "<body><center><img src='"+   url + "'><br>"
			+ "<form><input type=\"button\" value=\"  Print  \" onClick=\"window.print();\">&nbsp;<input type=\"button\" value=\"  Close  \" onClick=\"window.close();\"></form></center></body></html>";
		wnd.document.open();
		wnd.document.write(strHtml);
		wnd.document.close();
		wnd.focus();
	}
}

function ViewPicServer(strPic)
{
	var wnd = window.open("","picwin","resizable=yes,scrollbars=yes,status=yes,width=450,height=400");
	if (wnd != null) {
		var strHtml = "<html><head><title>View Picture...</title>"
			+ "<link href=\"/Include/Styles/Backend.css\" type=\"text/css\" rel=\"stylesheet\"></head>"
			+ "<body><center><img src='"+   strPic + "'>"
			+ "<form><input type=\"button\" value=\"  Close  \" onClick=\"window.close();\"></form></center></body></html>";
		wnd.document.open();
		wnd.document.write(strHtml);
		wnd.document.close();
		wnd.focus();
    }
}

function ViewPicLocal(strPic)
{
	//alert(strPic);
	if ( strPic == "" ) {
		alert("Please select the picture file first!");
		return ;
	}
	var strtmp = '';
	for (var i=0; i<strPic.length; i++) {
		if(strPic.substring(i, i+1)  == "\\")
			strtmp += "/" ;
		else
			strtmp += strPic.charAt(i);
	}
	var wnd = window.open("","picwin","resizable=yes,scrollbars=yes,status=yes,width=400,height=400");
	if (wnd != null) {
		var strHtml = "<html><head><title>View Picture...</title>"
			+ "<link href=\"/include/css/totwebfront.css\" type=\"text/css\" rel=\"stylesheet\"></head>"
			+ "<body><center><img src='file://"+   strtmp + "'>"
			+ "<form><input type=\"button\" value=\"  Close  \" onClick=\"window.close();\"></form></center></body></html>";
		wnd.document.open();
		wnd.document.write(strHtml);
		wnd.document.close();
		wnd.focus();
	}
}	

/*****************************************************
* Check & Uncheck All checkbox in DataGrid 
******************************************************/
    function CheckAllDataGridCheckBoxes(checkVal) 
    {
        for(i = 0; i < document.forms[0].elements.length; i++) 
        {
          elm = document.forms[0].elements[i]
            if (elm.type == 'checkbox') 
            {
                    elm.checked = checkVal;
                
            }
        }

  }

  function CheckSelectGridCheckBoxes(checkVal, checkStatus) 
   {
            if(!checkStatus.checked)
            {
               checkVal.checked = checkStatus.checked;
            }
            else
            {
                  var isSelectAll = false;
                    for(i = 0; i < document.forms[0].elements.length; i++) 
                    {
                      elm = document.forms[0].elements[i]
                      
                        if (elm.type == 'checkbox' && elm.name != checkVal.name) 
                        {
                           if(!elm.checked)
                           {
                              
                              isSelectAll = false;
                               break;
                           }
                           else
                           {
                               isSelectAll = true;
                           }
                        }
                    }
                    checkVal.checked = isSelectAll;
             }
     
  }
  function FormatCurrency(num) 
  {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}
 
