function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}



// version: beta
// created: 2005-08-30
// updated: 2005-08-31
// mredkj.com
function extractNumber(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}

function hideStatusLinks()
{
var doc = document.body.getElementByTag("a");
for (var x=0;x<doc.length;x++)
{
doc[x].setAttribute("onmouseover",hideLink);
}
}

function hideLink()
{
window.status = "Frogs like teacups";
}


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_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 SetDate(ddlDateType, txtBeginDate, txtEndDate, f_trigger_c1, f_trigger_c2)
{
	var todaysDate = new Date();
	var today = new String();
	var month;
	var today = ((todaysDate.getMonth() + 1) + '/' + todaysDate.getDate() + '/' + todaysDate.getFullYear()).toString();
	
	if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'YEARTODATE')
	{
		txtBeginDate.value = ('1/1/' + (todaysDate.getFullYear())).toString();
		txtEndDate.value = today;
	}				
	else if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'PREVIOUS12MONTH')
	{
		txtBeginDate.value = ((todaysDate.getMonth()+1) + '/' + todaysDate.getDate() + '/' + (todaysDate.getFullYear()-1)).toString();
		txtEndDate.value = today;
	}
	else if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'PREVIOUSYEAR')
	{
		txtBeginDate.value = ('1/1/' + (todaysDate.getFullYear()-1)).toString();	
		txtEndDate.value = ('12/31/' + (todaysDate.getFullYear()-1)).toString();
	}
	else if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'THISQUARTER' || ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'LASTQUARTER')
	{
		var intMonth;
		var intYear;
		intMonth = todaysDate.getMonth()+1;
		intYear = todaysDate.getFullYear();
				
			if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'LASTQUARTER')
			{				
				if (intMonth >= 1 && intMonth <= 3)
				{
					intMonth = 12;
					intYear = intYear - 1;
				}
				else
				{
					intMonth = intMonth - 3;
				}
			}
					
			if (intMonth >= 1 && intMonth <= 3)
			{
				txtBeginDate.value = ('1/1/' + intYear).toString();
				txtEndDate.value = ('3/31/' +	intYear).toString();
			}
			else if (intMonth >= 4 && intMonth <= 6)
			{
				txtBeginDate.value = ('4/1/' + intYear).toString();
				txtEndDate.value = ('6/30/' +	intYear).toString();
			}
			else if (intMonth >= 7 && intMonth <= 9)
			{
				txtBeginDate.value = ('7/1/' + intYear).toString();
				txtEndDate.value = ('9/30/' +	intYear).toString();
			}
			else if (intMonth >= 10 && intMonth <= 12)
			{
				txtBeginDate.value = ('10/1/' + intYear).toString();
				txtEndDate.value = ('12/31/' + intYear).toString();
			}		
		}
		else if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) == 'CUSTOM')
		{
			txtBeginDate.value = ((todaysDate.getMonth()+1) + '/01/' + (todaysDate.getFullYear())).toString();
			txtEndDate.value = today;
		}
		if (ucase(ddlDateType.options[ddlDateType.selectedIndex].value) != 'CUSTOM')
		{
			f_trigger_c1.disabled = true;
			f_trigger_c2.disabled = true;
		}
		else
		{
			f_trigger_c1.disabled = false;
			f_trigger_c2.disabled = false;	
		}
}

function areScrolls(){
var is = {
    ie:      navigator.appName == 'Microsoft Internet Explorer',
    java:    navigator.javaEnabled(),
    ns:      navigator.appName == 'Netscape',
    ua:      navigator.userAgent.toLowerCase(),
    version: parseFloat(navigator.appVersion.substr(21)) ||
             parseFloat(navigator.appVersion),
    win:     navigator.platform == 'Win32'
	}
	if(is.ie)
	{
		if(document.body.scrollHeight>document.body.clientHeight)return "yes"
		if(document.body.scrollHeight<=document.body.clientHeight)return "no"
	}
}

function hidden()
{
	if (areScrolls() == 'no')
	{
		document.body.style.overflow='hidden';
	}
	
}
function unhidden()
{document.body.style.overflow='';}

function GetSelectValues(CONTROL){
var strTemp = "";
var TotalLength;
var RecordSelected;
RecordSelected = false;
strTemp += "(";
for(var i = 0;i < CONTROL.length;i++)
{
	if(CONTROL.options[i].selected == true)
	{
		strTemp += "'" + CONTROL.options[i].value + "',";
		RecordSelected = true;
	}

}
if (RecordSelected == true)
{
	TotalLength = strTemp.length - 1;
	strTemp = left(strTemp, TotalLength);
}
strTemp += ")";
return strTemp;
}
function test(Quantity)
{
    alert(Quantity);
}

function FlagChanged(txt, rowID, grid)
{
    
    var count;
    var Quantity = txt.value;
    
    grid.Edit(grid.GetRowFromClientId(rowID)); 
    var gridItem = grid.GetRowFromClientId(rowID);
    if(gridItem.Cells[3].Value != '')
    {
        txtValue = Quantity;
    }
    //gridItem.SetValue(5, true);
    //grid.EditingDirty=true;
    grid.EditComplete();
    
    grid.Render(); 
    //count = grid.Table.GetRowCount();
    //var gridItem = grid.Table.GetRow(count - 1);
    
    
    
    
}
function AddRow(grid)
{
    /*alert('test');
    var count;
    var gridItem;     
    grid.EditingDirty=true;
    grid.EditComplete(); */        
    grid.Table.AddRow();
    /*count = grid.Table.GetRowCount();
    var gridItem = grid.Table.GetRow(count - 1); 
    

    if(gridItem.Cells[3].Value == null || gridItem.Cells[3].Value == 0) 
    {
        gridItem.SetValue(3, 1);            
    } 
    grid.Render();                 */
 }
 function onSelect(item)
 {
    grid.EditingDirty=true;
    grid.EditComplete();        
 }
function CheckAllItems(grid, columnNumber)
    {
      var gridItem;
      var f = document.forms[0];
      var itemIndex = 0;
      while(gridItem = grid.Table.GetRow(itemIndex))
      {
        gridItem.SetValue(columnNumber, true);
        itemIndex++;
      }
   
      grid.Render();
    }
function GetItemIfChecked(grid, columnToCheck, columnToGet)
    {
      var gridItem;
      var TotalLength;
      f = window.opener.document.forms[0];
      var itemIndex = 0;
      var retVal = '';
      while(gridItem = grid.Table.GetRow(itemIndex))
      {
        if(gridItem.Cells[columnToCheck].Value == true)
        {
			retVal += gridItem.Cells[columnToGet].Value + ','; 
        }
        itemIndex++;
      }
      //alert(retVal);
      grid.Render();
      TotalLength = retVal.length - 1;
	  retVal = left(retVal, TotalLength);
      f.sendeleadto.value = retVal;
     alert('The email address have been added to the send to box on lead form.');
     //return retVal;
    }
function getRemoveUrlContent(item, grid)
{    
    if(item.Cells[0].Value == null)
    {               
        var urlContent = "<a href=\"javascript:deleteRow('ClientID', grid);\">Delete</a>";
        var clientID = item.ClientId;
        urlContent = urlContent.replace(/ClientID/, clientID);        
        urlContent = urlContent.replace(/grid/, grid);        
        return urlContent;               
    }
    else
    {
        return "";
    }        
}


function GetItemIfChecked2(grid, columnToCheck, columnToGet, txt)
    {
      var gridItem;
      var TotalLength;
      var itemIndex = 0;
      var retVal = '';
      //var f = document.forms[0];
      while(gridItem = grid.Table.GetRow(itemIndex))
      {
        if(gridItem.Cells[columnToCheck].Value == true)
        {
			retVal += gridItem.Cells[columnToGet].Value + ','; 
        }
        itemIndex++;
      }
      //alert(retVal);
      grid.Render();
      TotalLength = retVal.length - 1;
	  retVal = left(retVal, TotalLength);
      //f.txtIsChecked.value = retVal;
      txt.value = retVal;
     //return retVal;
    }
function DeleteSelectedRows(grid, columnToCheck)
{
    var i;    
    var gridItem;
    var itemIndex = 0;
    var checkedItems = new Array();
 
    
    while(gridItem = grid.Table.GetRow(itemIndex))
    {
        if(gridItem.Cells[columnToCheck].Value == true)
		checkedItems[checkedItems.length] = gridItem;
        itemIndex++;    
    }
    
/*
    ajax call back does something funky
    need to pause execution of current 
    function until callback returns
    adjust pause time as needed
*/
    for (i = 0; i < checkedItems.length; i++)
    {
        grid.Delete(checkedItems[i]);
        DoPause(300);
    }        
    grid.Render();
}


function clearDate(txtboxObj)
	{
		txtboxObj.value = '';			
	}
function UnCheckAllItems(grid, columnNumber)
    {
      var gridItem;
      var f = document.forms[0];
      var itemIndex = 0;
      while(gridItem = grid.Table.GetRow(itemIndex))
      {
        gridItem.SetValue(columnNumber, false);
        itemIndex++;
      }      
      grid.Render();
    }



function hidify_showify(e_table, e_img, alt_less, alt_more) {
   if(document.getElementById) {
      var id_table = document.getElementById(e_table).style;
      var id_img = document.getElementById(e_img);

      //Set the object to table-cell if the browser is
      //Firefox and block if it's anything else.
      if(navigator.userAgent.indexOf("Firefox") != -1){
         if(id_table.display == "table-cell") {
            id_table.display = "none";
            id_img.src = "images/arrow_down.gif";
            id_img.alt = alt_more;
         }
         else {
            id_table.display = "table-cell";
            id_img.src = "images/arrow_up.gif";
            id_img.alt = alt_less;
         }
      }
      else {
         if(id_table.display == "block") {
            id_table.display = "none";
            id_img.src = "images/arrow_down.gif";
            id_img.alt = alt_more;
         }
         else {
            id_table.display = "block";
            id_img.src = "images/arrow_up.gif";
            id_img.alt = alt_less;
         }
      }
      return false;
   }
   else {
      return true;
   }
}


var newWin = '';
var newWindow = '';

function DelCookie (name,path,domain) 
{ if (getCookie(name)) 
  { document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function SetCookie(name, value, expires, path, domain) 
{ document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null)    ? "" : "; path=" + path) +
  ((domain == null)  ? "" : "; domain=" + domain);
}

function GetCookie(name)
{ var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) 
  { begin = dc.indexOf(cname);       
    if (begin != -1) 
    { begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function clickButton(e){ 
          
           if(navigator.appName.indexOf("Netscape")>(-1)){ 
                 if (e.keyCode == 13){ 
                       bt.click(); 
                       return false; 
                 } 
           } 
           if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
				  if (event.keyCode == 46)
                 { 
                       //bt.click(); 
                       return true;
                 }
                 if (event.keyCode < 48 || event.keyCode > 57){ 
                       //bt.click(); 
                       //alert("Enter Numbers Only");
                       return false; 
                 }
                
                 if(event.Length>3)
                 {
					//alert("Number Should be between 1 and 999")
                 }
           } 
           
     }

function exp2(ID){
	if (document.getElementById(ID).innerHTML=="+")
    		document.getElementById(ID).innerHTML="-"
	else
		document.getElementById(ID).innerHTML="+"
}

function exp(strTag ,strAttribute){ 
var elem = document.getElementsByTagName(strTag); 
var elem1 =window.event.srcElement; 
for (var i=0;i<elem1.children.length-1;i++){ 
  elem1.children[i].innerText=="-"?elem1.children[i].innerText="+":elem1.children[i].innerText="-"; 
} 
for (var i =0;i<elem.length;i++) 
{ 
if(elem[i].getAttribute(strAttribute)=="yes") 
{ 
elem[i].style.display=='none'? elem[i].style.display='block':elem[i].style.display='none'; 
} 
} 

} 

function copySelected(fromObject,toObject) {
for (var i=0, l=fromObject.options.length;i<l;i++) {
if (fromObject.options[i].selected)
addOption(toObject,fromObject.options[i].text,fromObject.options[i].value);
}

for (var i=fromObject.options.length-1;i>-1;i--) {
if (fromObject.options[i].selected)
deleteOption(fromObject,i);
}
}

function deleteOption(object,index) {
object.options[index] = null;
}

function addOption(object,text,value) {
var defaultSelected = true;
var selected = true;
var optionName = new Option(text, value, defaultSelected, selected)
object.options[object.length] = optionName;
}
function dosubmit() {}

function CheckDate(CONTROL){ 
var strFormat = 'mm/dd/yyyy';
CONTROL.value = FormatDate(CONTROL.value,strFormat); 
} 

function isDate(DateToCheck){
if(DateToCheck==""){return true;}
var m_strDate = FormatDate(DateToCheck);
if(m_strDate==""){
return false;
}
var m_arrDate = m_strDate.split("/");
var m_DAY = m_arrDate[0];
var m_MONTH = m_arrDate[1];
var m_YEAR = m_arrDate[2];
if(m_YEAR.length > 4){return false;}
m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;
var testDate=new Date(m_strDate);
if(testDate.getMonth()+1==m_MONTH){
return true;
} 
else{
return false;
}
}//end function




function FormatDate(s,FormatAs){

var strReturnDate;
var arrDate
var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//var arrMonthName = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

var strMONTH;
var Separator;
var DateToFormat = new String(s);
if(DateToFormat==""){return"";}
if(!FormatAs){FormatAs="mm/dd/yyyy";}

FormatAs = FormatAs.toLowerCase();
DateToFormat = DateToFormat.toLowerCase();

while(DateToFormat.indexOf("st")>-1){
DateToFormat = DateToFormat.replace("st","");
}

while(DateToFormat.indexOf("nd")>-1){
DateToFormat = DateToFormat.replace("nd","");
}

while(DateToFormat.indexOf("rd")>-1){
DateToFormat = DateToFormat.replace("rd","");
}

while(DateToFormat.indexOf("th")>-1){
DateToFormat = DateToFormat.replace("th","");
}
if(DateToFormat.indexOf(".")>-1){
Separator = ".";
}

if(DateToFormat.indexOf("-")>-1){
Separator = "-";
}


if(DateToFormat.indexOf("/")>-1){
Separator = "/";
}

if(DateToFormat.indexOf(" ")>-1){
Separator = " ";
}

arrDate = DateToFormat.split(Separator);
DateToFormat = "";
	for(var iSD = 0;iSD < arrDate.length;iSD++){
		if(arrDate[iSD]!=""){
		DateToFormat += arrDate[iSD] + Separator;
		}
	}
DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
arrDate = DateToFormat.split(Separator);

if(arrDate.length < 3){
return "";
}

var DAY = arrDate[0];
var MONTH = arrDate[1];
var YEAR = arrDate[2];




if(parseFloat(arrDate[1]) > 12){
DAY = arrDate[1];
MONTH = arrDate[0];
}

if(parseFloat(DAY) && DAY.toString().length==4){
YEAR = arrDate[0];
DAY = arrDate[2];
MONTH = arrDate[1];
}


for(var iSD = 0;iSD < arrMonths.length;iSD++){
var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
var MonthPosition = DateToFormat.indexOf(ShortMonth);
	if(MonthPosition > -1){
	MONTH = iSD + 1;
		if(MonthPosition == 0){
		DAY = arrDate[1];
		YEAR = arrDate[2];
		}
	break;
	}
}

var strTemp = YEAR.toString();
if(strTemp.length==2){

	if(parseFloat(YEAR)>40){
	YEAR = "19" + YEAR;
	}
	else{
	YEAR = "20" + YEAR;
	}

}


	if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){
	MONTH = "" + MONTH;
	}
	if(parseInt(DAY)< 10 && DAY.toString().length < 2){
	DAY = "" + DAY;
	}
	
switch (FormatAs){
	case "mm/dd/yyyy":
	return MONTH + "/" + DAY + "/" + YEAR;
	//case "mm/dd/yyyy":
	//return MONTH + "/" + DAY + "/" + YEAR;
	case "dd/mmm/yyyy":
	return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
	case "mmm/dd/yyyy":
	return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
	case "dd/mmmm/yyyy":
	return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
	case "mmmm/dd/yyyy":
	return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
	}
return strMonth + "/" + DAY + "/" + YEAR;

} //End Function



function CloseWindow()
{                                    
    self.close();
}               

function submitHandler(formName) {
	var f = document.forms[formName];
	f.submit();
}
function clearHandler() {
	var f = document.forms[0];
		f.reset();	
}
function resetform() {
	var f = document.forms[0];
	var baseurl;
	baseurl = '<%=Request.ServerVariables("SCRIPT_NAME")%>';
	self.location.href = baseurl + '?PageTitle=<%= Request.QueryString("PageTitle") %>&ApplicationType=<%= Request.QueryString("ApplicationType") %>';
}

function openWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 230;
			strHeight = screen.availHeight - 160;
	tools = "resizable,status=yes,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'newWindow1',tools); 

}

function openCampaignWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 230;
			strHeight = screen.availHeight - 160;
	tools = "resizable,status=yes,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'Campaign',tools); 
  NewWindow1.resizeTo(strWidth, strHeight);

}

function popitup(url) {
	var newwindow = '';
	
		newwindow=window.open(url,'name');
		newwindow.location.href = url;
	
	if (window.focus) {newwindow.focus()}
	return false;
}
function openFullWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable=no,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth;
			strHeight = screen.availHeight;
	tools = "resizable,status=yes,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'FullWindow',tools); 
  NewWindow1.resizeTo(strWidth, strHeight);

}

function openQueryWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 260;
			strHeight = screen.availHeight - 160;
	tools = "resizable,status=yes,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'Query',tools); 

}
function openLeadWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 150;
			strHeight = screen.availHeight - 100;
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'Lead',tools); 

}
function openPrintLeadWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 150;
			strHeight = screen.availHeight - 100;
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'PrintLead',tools); 

}
function openMaintenanceWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 200;
			strHeight = screen.availHeight - 80;
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'Maintenance',tools); 
   NewWindow1.resizeTo(strWidth, strHeight);
}
function openOpportunityWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 150;
			strHeight = screen.availHeight - 100;
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'Opportunity',tools); 

}
function showDetail3(url, Width, Height)
{
		
		var tools="";
		if (Width == 0 && Height == 0)
		{
			Width = screen.availWidth - 10;
			Height = screen.availHeight - 160;
			tools = "resizable=yes,toolbar=yes,status=yes,location=yes,scrollbars=yes,menubar=yes,width="+Width+",height="+Height+",top=20" + ",left=" + (screen.availWidth-Width) / 2;
		}	
		else
		{
			tools = "resizable=yes,status=yes,toolbar=no,location=no,scrollbars=yes,width="+Width+",height="+Height+",left=" + (screen.availWidth-Width) / 2 + ",top=5";
		}
		newWindow = window.open(url, 'newWindow3', tools);
		newWindow.resizeTo(Width, Height);
}
function openUserWindow(url, strWidth, strHeight) 
{ 
  var tools;
  var NewWindow1;
   if (strHeight > 0 && strWidth > 0) 
   {
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
   }
  if (strHeight == 0 && strWidth == 0) 
  {
	strWidth = screen.availWidth - 280;
			strHeight = screen.availHeight - 100;
	tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
	}
 
		
  NewWindow1 = window.open(url, 'Opportunity',tools); 

}
function popUpWin(ID, url, pagetitle, type, strWidth, strHeight, GridName)
	{
		var NewWindow2;

		if (type == "fullScreen")
		{
			strWidth = screen.availWidth - 180;
			strHeight = screen.availHeight - 160;
		}

		var tools="";
		if (type == "standard" || type == "fullScreen") tools = "resizable,status=yes,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0" + ",left="+(screen.availWidth-strWidth) / 2;
		if (type == "console") tools = "resizable,status=yes,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=" + (screen.availWidth-strWidth) / 2 + ",top=5";
		
		if (ID != 0)
		{
			NewWindow2 = window.open(url+'?ID=' + ID + '&GridName=' + GridName + '&PageTitle='+pagetitle, 'newWindow2', tools);
		}
		else
		{
			NewWindow2 = window.open(url+'?GridName=' + GridName + '&PageTitle='+pagetitle, 'newWindow2', tools);
		}


}

function maketheBalloon(id, width, message)
{
   var theString = '&lt;STYLE TYPE="text/css"&gt;#'+id+'{width:'+width+';}&lt;/STYLE&gt;';
   theString+='&lt;DIV CLASS="balloon" id="'+id+'"&gt;'+message+'&lt;/DIV&gt;';
   document.write(theString);
}

function makeItVisible(id, event)
{
             document.layers[id].left = event.pageX + 10;
             document.layers[id].top = event.pageY + 10;;
             document.layers[id].visibility="show";
}
function setUpHelp()
{
   maketheBalloon("sal",200,"test");
}

function hideHelp(id)
{
  is.nav4up ? document.layers[id].visibility="hide" : document.all[id].style.visibility="hidden";
}


function showDetail(ID, AlternateID, URL, PageTitle, Width, Height, ToolBar, LocationBar, GridName) 
{
		
		var tools="";
		if (Width == 0 && Height == 0)
		{
			Width = screen.availWidth - 200;
			Height = screen.availHeight - 20;
			//tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+Width+",height="+Height+",top=20" + ",left=" + (screen.availWidth-Width) / 2;
		}
		if (Width == 0 && Height == 0)
		{
			if (ID != 0)
			{
				newWindow = window.open(URL + '?ID='+ID + '&GridName=' + GridName + '&PageTitle=' + PageTitle + '&AlternateID=' + AlternateID, 'newWindow2', 'directories=no,toolbar=' + ToolBar + ',resizable=yes,status=yes,menubar=no,location=' + LocationBar + ',scrollbars=yes,titlebar=yes,width=' + Width + ',height=' + Height + ',left=65,top=0,left=' + (screen.availWidth-Width) / 2 + ',screenX=' + (((screen.availWidth-10) - 300) / 2) + ',screenY=25');		
			}
			else
			{			
				newWindow = window.open(URL + '?GridName=' + GridName + '&PageTitle=' + PageTitle + '&AlternateID=' + AlternateID, 'newWindow2', 'directories=no,toolbar=' + ToolBar + ',resizable=yes,status=yes,menubar=no,location=' + LocationBar + ',scrollbars=yes,titlebar=yes,width=' + Width + ',height=' + Height + ',left=65,top=5');
			}
			
		}
		else
		{
			if (ID != 0)
			{
				newWindow = window.open(URL + '?ID='+ID + '&GridName=' + GridName + '&PageTitle=' + PageTitle + '&AlternateID=' + AlternateID, 'newWindow2', 'directories=no,toolbar=' + ToolBar + ',resizable=yes,status=yes,menubar=no,location=' + LocationBar + ',scrollbars=yes,titlebar=yes,width=' + Width + ',height=' + Height + ',left=65,top=0,left=' + (screen.availWidth-Width) / 2 + ',screenX=' + (((screen.availWidth-10) - 300) / 2) + ',screenY=25');		
			}
			else
			{			
				newWindow = window.open(URL + '?GridName=' + GridName + '&PageTitle=' + PageTitle + '&AlternateID=' + AlternateID, 'newWindow2', 'directories=no,toolbar=' + ToolBar + ',resizable=yes,status=yes,menubar=no,location=' + LocationBar + ',scrollbars=yes,titlebar=yes,width=' + Width + ',height=' + Height + ',left=65,top=5');
			}
			
		}
		newWindow.resizeTo(Width, Height);
	
}

function showDetail2(ID, AlternateID, URL, PageTitle, Width, Height, ToolBar, LocationBar, GridName) 
{
		
		var tools="";
		if (Width == 0 && Height == 0)
		{
			Width = screen.availWidth - 10;
			Height = screen.availHeight - 160;
			//tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+Width+",height="+Height+",top=20" + ",left=" + (screen.availWidth-Width) / 2;
		}
		if (ID != 0)
		{
			newWindow = window.open(URL + '?ID='+ID + '&GridName=' + GridName + '&PageTitle=' + PageTitle + '&AlternateID=' + AlternateID, 'newWindow3', 'directories=no,toolbar=' + ToolBar + ',resizable=yes,status=yes,menubar=no,location=' + LocationBar + ',scrollbars=yes,titlebar=yes,width=' + Width + ',height=' + Height + ',left=65,top=25,screenX=' + (((screen.availWidth-10) - 300) / 2) + ',screenY=25');		
		}
		else
		{			
			newWindow = window.open(URL + '?GridName=' + GridName + '&PageTitle=' + PageTitle + '&AlternateID=' + AlternateID, 'newWindow3', 'directories=no,toolbar=' + ToolBar + ',resizable=yes,status=yes,menubar=no,location=' + LocationBar + ',scrollbars=yes,titlebar=yes,width=' + Width + ',height=' + Height + ',left=65,top=5');
		}
		newWindow.resizeTo(Width, Height);
	
}


function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}


function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}



function filterNum(str) {
re = /^\$|,/g;
// remove "$" and ","
return str.replace(re, "");
}






 function onInsert(item)
  {
        return true; 
  }
  
  function onUpdate(item)
  {
      return true; 
  }

  function onCallbackError(excString)
  {  
    alert(excString); 
    Grid1.Callback();    
  }

  function onDelete(item)
  {
      if (confirm("Delete record?"))
        return true; 
      else
        return false; 
  }
  
  function editGrid(rowId, g)
  {    
    g.Edit(g.GetRowFromClientId(rowId)); 
    
  }
    
  function editRow(g)
  {
    g.EditComplete();     
  }

  function insertRow(g)
  {
    g.EditComplete(); 
   
  }
  function deleteRow(rowId, g)
  {
    g.Delete(g.GetRowFromClientId(rowId)); 
  }

function changeColor(currentColor, ID, otherColor, otherID)
	{
		var elem;
		elem = document.getElementById(ID);
		if(currentColor == '#000000')
		{
			elem.style.color = '#cccccc';
			elem.style.fontWeight = '';
		}
		else if(currentColor == '#cccccc')
		{
			elem.style.color = '#000000';
			elem.style.fontWeight = 'bold';
		}
			
		
		elem = document.getElementById(otherID);
		if(otherColor == '#000000')
		{
			elem.style.color = '#cccccc';
			elem.style.fontWeight = '';
		}
		else if(otherColor == '#cccccc')
		{
			elem.style.color = '#000000';
			elem.style.fontWeight = 'bold';
		}
	}