

function doChangeCard(formName) {
  if(1 == formName.cardTypeId.value) {
    showRow("cvmRow");
    hideRow("validFromDateRow");
    hideRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_Visa.gif";
  } else if(2 == formName.cardTypeId.value) {
    showRow("cvmRow");
    hideRow("validFromDateRow");
    hideRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_MasterCard.gif";
  } else if(8 == formName.cardTypeId.value) {
    showRow("cvmRow");
    hideRow("validFromDateRow");
    hideRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_Amex.gif";
  } else if(10 == formName.cardTypeId.value) {
    hideRow("cvmRow");
    showRow("validFromDateRow");
    showRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_Maestro.gif";
  } else if(9 == formName.cardTypeId.value) {
    hideRow("cvmRow");
    showRow("validFromDateRow");
    showRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_Solo.gif";
  } else if(6 == formName.cardTypeId.value) {
    hideRow("cvmRow");
    hideRow("validFromDateRow");
    hideRow("issueNumberRow");
    formName.f_cardTypeImage.src = "/images/payment/yacCC_Jcb.gif";
  } else if(97 == formName.cardTypeId.value) {
    showRow("cvmRow");
    hideRow("validFromDateRow");
    hideRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_Delta.gif";
  } else if(11 == formName.cardTypeId.value) {
    showRow("cvmRow");
    hideRow("validFromDateRow");
    hideRow("issueNumberRow");
    formName.cardTypeImage.src = "/images/payment/yacCC_Electron.gif";
  }
} // doChangeCard()




/*	The following Methods Format Prices */
function formatDecimal(argvalue, addzero, decimaln) {
  var numOfDecimal = (decimaln == null) ? 2 : decimaln;
  var number = 1;

  number = Math.pow(10, numOfDecimal);

  argvalue = Math.round(parseFloat(argvalue) * number) / number;
  // If you're using IE3.x, you will get error with the following line.
  // argvalue = argvalue.toString();
  // It works fine in IE4.
  argvalue = "" + argvalue;

  if (argvalue.indexOf(".") == 0)
    argvalue = "0" + argvalue;

  if (addzero == true) {
    if (argvalue.indexOf(".") == -1)
      argvalue = argvalue + ".";

    while ((argvalue.indexOf(".") + 1) > (argvalue.length - numOfDecimal))
      argvalue = argvalue + "0";
  }

  return argvalue;
}

/*
formatValue(1223.434, "$##,###.##")		will return "$1,223.43"
formatValue(1223.43, "$##,###.##")		will return "$1,223.43"
formatValue(1223., "$##,###.##")		will return "$1,223.00"
formatValue(1223, "$##,###.##")		will return "$1,223.00"
formatValue(23., "$##,###.##")			will return "$23.00"
formatValue(23.3, "$##,###.##")		will return "$23.30"
formatValue(124343423.3, "$###,###,###.##")	will return "$124,343,423.30"
*/

function formatValue(argvalue, format) {
  var numOfDecimal = 0;
  if (format.indexOf(".") != -1) {
    numOfDecimal = format.substring(format.indexOf(".") + 1, format.length).length;
  }
  argvalue = formatDecimal(argvalue, true, numOfDecimal);

  argvalueBeforeDot = argvalue.substring(0, argvalue.indexOf("."));
  retValue = argvalue.substring(argvalue.indexOf("."), argvalue.length);

  strBeforeDot = format.substring(0, format.indexOf("."));

  for (var n = strBeforeDot.length - 1; n >= 0; n--) {
    oneformatchar = strBeforeDot.substring(n, n + 1);
    if (oneformatchar == "#") {
      if (argvalueBeforeDot.length > 0) {
        argvalueonechar = argvalueBeforeDot.substring(argvalueBeforeDot.length - 1, argvalueBeforeDot.length);
        retValue = argvalueonechar + retValue;
        argvalueBeforeDot = argvalueBeforeDot.substring(0, argvalueBeforeDot.length - 1);
      }
    }
    else {
      if (argvalueBeforeDot.length > 0 || n == 0)
        retValue = oneformatchar + retValue;
    }
  }

  return retValue;

}

var popupWindow = null;
function MM_openBrWindow(theURL,winName,features) { //v2.0
  if((popupWindow == null ) || popupWindow.closed) {
   popupWindow = open(theURL,winName,features);
   popupWindow.focus();
  } else {
   // popupWindow is open somewhere
   popupWindow.location = theURL;
   popupWindow.focus();   
  }
}

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) { //v3.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); 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 hide(elementId) {
  hideRow(elementId);
}

function hideRow (rowId) {
	if (document.getElementById) {
		// ie5+ netscape6+, opera+
	    document.getElementById(rowId).style.display ='none';
	} 
}

function show(elementId) {
 showRow(elementId);
}

function showRow (rowId) {
	if((navigator.appName=="Microsoft Internet Explorer") && 
		(navigator.userAgent.indexOf("Opera")==-1)  && 
		 (navigator.userAgent.indexOf("Opera")==-1)) {
		// opera pretends to be internet explorer!
		if (document.getElementById) {
	    	document.getElementById(rowId).style.display = 'block';
		}
	} else {
		if (document.getElementById) {
	    	document.getElementById(rowId).style.display = 'block';
		} 
	}
}

function toggleShowRow(rowId,imageId) {
	if (document.getElementById) {
    	if('none' == document.getElementById(rowId).style.display) {
			showRow(rowId);
			document.getElementById(imageId).src = "/images/expanded.gif";
		} else {
			hideRow(rowId);
			document.getElementById(imageId).src = "/images/collapsed.gif";
		}
	} 
}

function toggleShow(elementId) {
  if (document.getElementById) {
    if('none' == document.getElementById(elementId).style.display) {
      showRow(elementId);
    } else {
      hideRow(elementId);
    }
  } 
}

function yacButtonPressed() {
  /* style.cursor='wait';this.disable=true; */
}


function highlight(area) {
 area.style.borderColor='#999';
 /*area.style.backgroundColor='#f5f5f5';*/
 area.style.cursor='pointer';
}

function clearHighlights(area) {
  area.style.borderColor='';
  /*area.style.backgroundColor='#fff';*/
  area.style.cursor='auto';
}

function startDayChanged(formName) {
  if(formName.startDay.selectedIndex > formName.endDay.selectedIndex) {
     formName.endDay.selectedIndex = formName.startDay.selectedIndex;
  }  
  doChangeEndTime(formName);
}

function startMonthChanged(formName) {
  formName.endMonth.selectedIndex = formName.startMonth.selectedIndex;
  doChangeEndTime(formName);    
}

function startYearChanged(formName) {
  formName.endYear.selectedIndex = formName.startYear.selectedIndex;
  doChangeEndTime(formName);
}

function doChangeEndTime(formName) {
  formName.endHour.selectedIndex = 23;
  formName.endMinute.selectedIndex = 59;
  formName.endSecond.selectedIndex = 59;
}
  
function doChangeCallsPerPage(formName) {
  formName.endRowNum.value = parseInt(formName.startRowNum.value) + parseInt(formName.callsPerPage.value) -1;
}

var startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("vNavlist");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}

var width=0;
var height=0;
function getDimensions(numA,numB)
{
   if(numA>101||numA<0)
   {
       numA=100;
   }
   if(numB>101||numB<0)
   {
       numB=100;
   }
   width=(screen.width/100)*numA;
   height=(screen.height/100)*numB;
}

//function createPopUp(theurl,w,h)//default for terms and conditions 41,38
//{
//       getDimensions(w,h);
//      var popup=open(theurl,'FaxTermsAndConditions','width='+width+',height='+height+'');
//       popup.moveTo((screen.width-width)/2,(screen.height-height)/2);
//       popup.focus();
//} 

//function showPopup(theURL) {
// showPopup(theURL,450,350);
//}
var popup;
function showPopup(theURL,width,height) 
{
	if((width==0)||(height==0))
	{
		showPopup(theURL,450,350);
	}
	else
	{
		if ( ( popup == null ) || popup.closed ) 
		{
				popup = open( theURL, 'popupWindow', 'scrollbars=yes,width='+width+',height='+height+'' );
				popup.moveTo((screen.width-width)/2,(screen.height-height)/2);
				popup.focus();
		}
		else  
		{
				// popup is open somewhere
				popup.location = theURL;
				popup.resizeTo(width,height);
				popup.moveTo((screen.width-width)/2,(screen.height-height)/2);
				popup.focus();
		}
	}
}
function hlight(event)
{
  // Internet Explorer
  if (event.srcElement)
  {
    if(event.srcElement.nodeName=="TD")
		{
			event.target.parentNode.style.backgroundColor='white';
		}
  }
  // Netscape and Firefox
  else if (event.target)
  {
    if(event.target.nodeName=="TD")
		{
			event.target.parentNode.style.backgroundColor='white';
		} 		
  }
}
function llight(event)
{
  // Internet Explorer
  if (event.srcElement)
  {
    if(event.srcElement.nodeName=="TD")
		{
			event.target.parentNode.style.backgroundColor=null;
		}
  }
  // Netscape and Firefox
  else if (event.target)
  {
    if(event.target.nodeName=="TD")
		{
			event.target.parentNode.style.backgroundColor=null;
		} 		
  }
}


var helpWindow = null;
function openHelpWindow(parentWindow, theURL) { 
  var screenWidth = screen.availWidth;
  var height = 500;
  var width = 300;
  var left = screen.availWidth - width - 15;
  var top = 0;
  var features = 'height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',location=no,resizable=yes,status=no';
  helpWindow = open(theURL, 'Help', features);
  helpWindow.focus();
  
/*  if(helpWindow != null)
  {
   helpWindow = open(theURL,winName,features);
   helpWindow.focus();
  } else {
  
   popupWindow.location = theURL;
   popupWindow.focus();   
  }*/
}


function posLeft() {
  return typeof window.pageXOffset != 'undefined' ? 
  	window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? 
  		document.documentElement.scrollLeft : document.body.scrollLeft ? 
  			document.body.scrollLeft : 0;
}
