<!--


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.0
  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 && document.getElementById) x=document.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];}
}

function form_finder() {
	if (document.forms[0]) {
	if ((document.forms[0].elements[0].type == "text") || (document.forms[0].elements[0].type == "textarea")){
		document.forms[0].elements[0].focus();
	}
	}
}

//Begin the check box logic
//function checkAll(field)
//{
//for (i = 0; i < field.length; i++)
//	field[i].checked = true ;
//}

function unchecktheAll(field)
{
for (i = field.length-1; i < field.length; i++)
	field[i].checked = false ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length-1; i++)
	field[i].checked = false ;
}


function unchecktheNone(field)
{
for (i = 0; i < 1; i++)
	field[i].checked = false ;
}

function uncheckN(field)
{
for (i = 1; i < field.length; i++)
	field[i].checked = false ;
}


function checkbox_checker(checkbox)
{


var checkbox_choices = 0;

for (counter = 0; counter < checkbox.length; counter++)
{

if (checkbox[counter].checked)
{ checkbox_choices = checkbox_choices + 1; }

}

if (checkbox_choices < 1 )
{

for (i = checkbox.length-1; i < checkbox.length; i++)
	checkbox[i].checked = true ;
}


}

function toggle(toggleId, e)
{
 if (!e) {
  e = window.event;
 }
 if (!document.getElementById) {
  return false;
 }
 var body = document.getElementById(toggleId);
 if (!body) {
  return false;
 } 
 var im = toggleId + "_toggle";
 if (body.style.display == 'none') {
  body.style.display = 'block';
  if (document.images[im]) {
   document.images[im].src = "/siteimages/close.png";
  }
 } else {
  body.style.display = 'none';
  if (document.images[im]) {
   document.images[im].src = "/siteimages/open.png";
  }
 }
 if (e) {
  // Stop the event from propagating, which
  // would cause the regular HREF link to
  // be followed, ruining our hard work.
  e.cancelBubble = true;
  if (e.stopPropagation) {
   e.stopPropagation();
  }
 }
}
function daysInMonth(month,year) {
	var m = [31,28,31,30,31,30,31,31,30,31,30,31];
	return m[1];
	if (month != 2){
		return m[month];
	}
	if (year%4 != 0){
		return m[1] + 1;
	}
	return m[1];
} 

function isNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function calculateDate(objForm, numMonths){

	objForm.beginDateOK.value = 'false';
	numMonths = new Number(numMonths);
	newDate = new Date(objForm.startdate.value);

	//Test Inputs
	if(newDate == 'Invalid Date'){
		alert('Not a valid Begin Date.');
		return false;
	}
	objForm.beginDateOK.value = 'true';
	newMonth = newDate.getMonth() + numMonths;
	newDate.setMonth(newMonth);
	newDate.setDate(newDate.getDate() - 1);
	month = newDate.getMonth() + 1;
	day = newDate.getDate();
	year = newDate.getFullYear();
	objForm.enddate.value = month+'/'+day+'/'+year;
	return true;
	
	/*
	else{
	}
	if(isNumeric(objForm.startdate.value.substring(0,2)) != true){
		alert('Not a valid Begin Date.');
		return false;
	}
	else{
		startMonth = objForm.startdate.value.substring(0,2);
	}
	if(isNumeric(objForm.startdate.value.substring(3,5)) != true){
		alert('Not a valid Begin Date.');
		return false;
	}
	else{
		startDay = objForm.startdate.value.substring(3,5);
		objForm.beginDateOK.value = 'true';
	}

	var addYears = 0;//default to same year 
	if ((startMonth * 1) + (numMonths * 1) >= 12){
		addYears = Math.floor(numMonths/12) + 1;
	}
	
	var endYear = (startYear * 1) + (addYears * 1);
	var addMonths = numMonths - (addYears * 12);
	var endMonth = startMonth * 1 + addMonths * 1;

	endMonth = endMonth - 1;//JS Months are 0 to 11
				
	if(startDay == 1){ //If starting on the first, end on the last
		endMonth = endMonth - 1;
		if(endMonth == -1){//December or the prior year
			endMonth = 11;
			endYear = endYear - 1;
		}
	}
	var daysInEndMonth = daysInMonth(endMonth,endYear);
						
	if(startDay == 1){ //If starting on the first, end on the last

		endDay = daysInEndMonth;
	}
	else{
		endDay = startDay -1;//Not the first so back off one day
		
	}
	if(endDay > daysInMonth(daysInEndMonth)){//If needed, reduce to number of days in month
		 endDay = daysInEndMonth;
	}
		
	var endDate = new Date(endYear, endMonth, endDay);//
	endMonth = endDate.getMonth() + 1;//JS months are 0 - 11
	objForm.enddate.value = endMonth +  '/' + endDay  + '/' + endDate.getYear();
	return true;
	*/
}

function calcAdjustedTotal(objForm){
	var signMultiplier = 1;
	if(objForm.AdjType.value.indexOf('Discount') > 0){
		var signMultiplier = -1;
	}
	if(objForm.isMonthly[0].checked == true){//monthly
		var subtotal = objForm.rate.value;
		if(objForm.numberofmonths.value != '0'){ //calculate end date for one-time if not 0 ; otherwise open ended
			calculateDate(objForm, objForm.numberofmonths.value);
		}
		else{
			objForm.enddate.value = '';//Open-ended
			objForm.beginDateOK.value = 'true';
		}
	}
	else{//one-time
		calculateDate(objForm, objForm.numberofmonths.value); //always calculate end date for one-time
		var subtotal = objForm.numberofmonths.value * objForm.rate.value;
	}
	objForm.subtotal.value = subtotal;
	
	var AdjPercent = objForm.AdjPercent.value * signMultiplier;
	var AdjPercentFactor = (1 + AdjPercent / 100);
	var AdjAmount = objForm.AdjAmount.value * signMultiplier;
	
	var AdjustedTotal = subtotal * AdjPercentFactor + AdjAmount;
	objForm.AdjustedTotal.value = AdjustedTotal.toFixed(2); 
	return true;
}
	
function calcAdjustedTotalShowcases(objForm){
	var signMultiplier = 1;
	if(objForm.AdjType.value.indexOf('Discount') > 0){
		var signMultiplier = -1;
	}
	if(objForm.isMonthly[0].checked == true){//monthly
		if(objForm.numberofmonths.value != '0' && objForm.manualEndDate.value != 'true'){ //calculate end date for one-time if not 0 or manual; otherwise open ended
			calculateDate(objForm, objForm.numberofmonths.value);
		}
		else{
			if(objForm.manualEndDate.value != 'true'){
				objForm.enddate.value = '';//Open-ended
				objForm.beginDateOK.value = 'true';
			}
		}
		var subtotal = objForm.NumOfListings.value  * objForm.rate.value;
	}	
	else{//one-time
		if(objForm.manualEndDate.value != 'true'){
			calculateDate(objForm, objForm.numberofmonths.value); //always calculate end date for one-time unless manual
		}
		var subtotal = objForm.numberofmonths.value * objForm.NumOfListings.value  * objForm.rate.value;
	}
		
	objForm.subtotal.value = subtotal;
	
	var AdjPercent = objForm.AdjPercent.value * signMultiplier;
	var AdjPercentFactor = (1 + AdjPercent / 100);
	var AdjAmount = objForm.AdjAmount.value * signMultiplier;
	
	var AdjustedTotal = subtotal * AdjPercentFactor + AdjAmount;
	objForm.AdjustedTotal.value = AdjustedTotal.toFixed(2);
	return true;
}

function addService(objForm){
	if(objForm.city.value == ''){
		alert('Please select a User City.');
		return true;
	}
	if(objForm.beginDateOK.value == 'true'){
		objForm.submit();
		return true;
	}
	else{
		return false;
	}
	
}

function deleteService(objForm){
	objForm.deleted.value = '1';
	objForm.submit();
	return true;
}

function endService(objForm){
	objForm.enddate.value = objForm.yesterday.value;
	return true;
}

//-->