function moveView()
{
	catIdx = document.view.categoryName.selectedIndex;
	cat = document.view.categoryName.options[catIdx].value;
	document.location = 'viewClients.php?categoryName='+cat;
}

function formatCurrency(num)
{
   num = num.toString().replace(/\$|\,/g,'');

   if(isNaN(num)) num = "0";

   cents = Math.floor((num*100+0.5)%100);
   num   = Math.floor(num).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 ( num + '.' + cents);

}

function formatCurrency1(num)
{
   num = num.toString().replace(/\$|\,/g,'');

   if(isNaN(num)) num = "0";

   cents = Math.floor((num*100+0.5)%100);
   num   = Math.floor(num).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 ( num + '.' + cents);

}


function highlight(field) 
{
  field.focus();
  field.select();
}

function loadSelect(f_name,select_name,val)
{

        var the_one = eval('document.'+f_name+'.'+select_name);

        for(x=0;x < the_one.length;x++)
        {

           if (the_one.options[x].value == val)
            {
                 the_one.options.selectedIndex = x
                 the_one.options[x].selected = true;
                 break;
            }

        }

        the_one = "";


}

function popWin( url, name, width, height, scroller )
{
        var outStr = 'height=' + height + ',width=' + width;
        if (!scroller)
        {
                outStr = outStr + ',menubar=no,toolbar=yes,location=no,directories=no,status=no,scrollbars=no,resizable=no';
        }
        else
        {
                outStr = outStr + ',menubar=no,toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=no';
        }
                window.open(url, name, outStr);
}

function popWinCalc( url, name, width, height, scroller )
{
        var outStr = 'height=' + height + ',width=' + width;
        if (!scroller)
        {
                outStr = outStr + ',menubar=no,toolbar=yes,location=no,directories=no,status=no,scrollbars=no,resizable=no';
        }
        else
        {
                outStr = outStr + ',menubar=no,toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=no';
        }


        window.open(url, name, outStr);
}

function getPdf(mls)
{
	f = document.sort;
	document.location = "preListing.php?mls="+mls;

}

function go(url)
{
	document.location = url;
}

function selectAll()
{

   f = document.pSheet;

   for(var i = 0; i < f.length; i++)
   {
                var e = f.elements[i];
                if(e.type == "checkbox")
                        e.checked = true;
   }

}

function deSelectAll()
{

   f = document.pSheet;

   for(var i = 0; i < f.length; i++)
   {
                var e = f.elements[i];
                if(e.type == "checkbox")
                        e.checked = false;
   }

}

function generatePdf()
{

	if(confirm("Is the page formatted and sorted as you wish?"))
	{
		document.sort.method="GET";
		document.sort.action="generatePdf0.php";
		document.sort.submit();
	}
}

function newSearch(s)
{
        document.searchForm.skipRows.value = s;
        document.searchForm.submit();
}

function newSearch1(s)
{
        document.searchForm.skipRows.value = s;
        document.searchForm.submit();
}


function newSearchPrint(s)
{
        document.searchForm.skipRows.value = s;
        document.searchForm.submit();
}


function popUp(page)
{
        window.open(page, "popup",
                        "width=600,height=500, \
                         toolbar=0,directories=0, \
                         menubar=0,status=0, \
                         scrollbars=1,resizable=0, \
                         location=0,copyhistory=0");
}

function popUp1(page,w,h)
{
        var windowString = "width="+w+",height="+h+", \
                         toolbar=1,directories=0, \
                         menubar=0,status=0, \
                         scrollbars=1,resizable=0, \
                         location=0,copyhistory=0";
        pageOut = "displayImage.php?image="+page+"&width="+w+"&height="+h;
        window.open(pageOut, "popup",windowString);

}

function popUp2(page,w,h)
{
        var windowString = "width="+w+",height="+h+", \
                         toolbar=0,directories=0, \
                         menubar=0,status=0, \
                         scrollbars=1,resizable=0, \
                         location=0,copyhistory=0";
	pageOut = page;
        window.open(pageOut, "popup",windowString);

}

