//--- MacroMedia Standars Functions
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 MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];
    if(!x.oSrc) x.oSrc=x.title; x.title=a[i+4];
   }
}


//--- insainDevelopments Standard Functions
function openWin(url,wn,w,h,l,t,s,r,tb){
	//alert('url='+url+',wn='+wn+',width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+s+',resizable='+r+',toolbar='+tb)
	newWindow = window.open(url,wn,'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+s+',resizable='+r+',toolbar='+tb )
	newWindow.focus()
}

function changeClass(id,newClass){
	if (document.getElementById) eval("document.getElementById('" + id + "').className='" + newClass + "'");
}

function addToFavorites(){
	if (window.external){
		// if the browser is IE open the add favorite window
		external.AddFavorite(location.href,document.title)
	}
	else{
		alert("Sorry, your browser doesn't support this feature.\nPlease use the bookmark feature of your browser to save the location of this page.");
	}
}

function tellaFriend(){
	openWin('tellafriend.htm?url='+document.URL,'tella',450,340,300,200,'no','no','no');
}

function validEmail(emailField) {
	email = emailField.value
	if (email == "") {     //must contain something
		alert("Email address is empty")
		emailField.focus();
		return false
	}
	invalid = " /;,:"
	for (i=0; i<invalid.length; i++){   //cannot contain these characters
		bad = invalid.charAt(i)
		if (email.indexOf(bad,0) > -1){
			alert("Email address contains invalid characters")
			emailField.focus();
			return false
		}
	}
	atPos = email.indexOf("@",0)  //must have a @ character
	if (atPos == -1){
		alert("Email address is missing the @ character")
		emailField.focus();
		return false
	}
	if (atPos == 0){   //cannot start with @ character
		alert("Email address cannot start with the @ character")
		emailField.focus();
		return false
	}
	if (email.indexOf("@",atPos+1) != -1){  //can only have ONE @ character
		alert("Email address contains more than one @ character")
		emailField.focus();
		return false
	}
	dotPos = email.indexOf(".",atPos+1)  //must have a . character after the @
	if (dotPos == -1){
		alert("Email address must have a . character following the @ character")
		emailField.focus();
		return false
	}
	if (dotPos == 0){   //cannot start with . character
		alert("Email address cannot start with the . character")
		emailField.focus();
		return false
	}
	if ((dotPos-atPos) == 1){
		alert("Email address has no characters between the @ and . characters")
		emailField.focus();
		return false    
	}
	if (dotPos+3 > email.length){   //must have at least 2 characters after .
		alert("Email address must have at least two characters following the dot")
		emailField.focus();
		return false
	}        
}


function confirmLogout() {
  if (confirm("Are you sure you want to log out?")) {
    document.location = "logout.asp";
  }
}


//month array for use in date functions
var monthArray=new Array(12)
monthArray[0]="January"
monthArray[1]="February"
monthArray[2]="March"
monthArray[3]="April"
monthArray[4]="May"
monthArray[5]="June"
monthArray[6]="July"
monthArray[7]="August"
monthArray[8]="September"
monthArray[9]="October"
monthArray[10]="November"
monthArray[11]="December"



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);
}

