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];}
}


function MM_LoadMenuImages() {
  MM_preloadImages('images/menu_1_b.jpg','images/menu_2_b.jpg','images/menu_3_b.jpg','images/menu_4_b.jpg',
  'images/menu_5_b.jpg','menu_6_b.jpg','menu_7_b.jpg','menu_8_b.jpg','menu_9_b.jpg')
}



function NonSpace(field) {

	var xpos =0;
	var xlen =field.length;
	var xpos1 =0;
	var xpos2 =xlen;

	for (var i=0; i < xlen; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == " ") {xpos++;}
		else {var xpos1=xpos;break;  }
	}
	field = field.substring(xpos1, xlen)
	var xlen1 = field.length;

	for (var i=0; i < xlen1; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp != " ") {xpos1++;}
		else {xpos2=i;break;  }
	}
	field = field.substring(0, xpos2)
	return field;
}
function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
function IsPhone(str)          // is phone str valid
    {
    if (str.length != 12) 
              // nope - wrong str length
		{
		alert('Invalid PhoneNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
    {
    if (i == 3 || i == 7)
    {
      if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . PhoneNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
    {
      if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. PhoneNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}
function validateZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;
	if (field.value.length!=5 && field.value.length!=10) {
		alert("Please enter your 5 digit digit  ZIP  code.");
		return false;
	}
	for (var i=0; i < field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (temp == "-") hyphencount++;
		if (valid.indexOf(temp) == "-1") {
			alert("Invalid characters in your ZIP code.  Please try again.");
			return false;
		}
		if ((hyphencount > 1) || ((field.value.length==10) && ""+field.value.charAt(5)!="-")) {
			alert("The hyphen character should be used with a properly formatted 5 digit+four  ZIP  code, like '12345-6789'.   Please try again.");
			return false;
		}
	}
	return true;
}
function isNum(chr)
{
	if (chr < "0" || chr > "9")
		return false;
	else
		return true;
}
function isNumber09(InString)  {
        RefString="0123456789";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 0 - 9 ");
				return false;
			}
		}
        return true;
}
function isNumberZip(InString)  {
        RefString="0123456789-";

        for (Count=0; Count < InString.length; Count++)  {
            TempChar= InString.substring (Count, Count+1);
            if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter a valid Zip Code! ");
				return false;
			}
		}
        return true;
}
var reWhitespace = /^\s+$/
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{   return (isEmpty(s) || reWhitespace.test(s));}
function Start(page) {
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=550,height=250,top=50,left=50");
}
var digits = "0123456789";
var whitespace = " \t\n\r";
var decimalPointDelimiter = "."
var phoneNumberDelimiters = "()-./ ";
var validUSPhoneChars = digits + phoneNumberDelimiters;
var digitsInUSPhoneNumber = 10;
var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."
var sPhone = "Phone Number"
var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415-555-1212). Please reenter it now."
var pEntryPrompt = "Please enter a "
var pUSPhone = "10 digit U.S. phone number (like 415-555-1212)."
var defaultEmptyOK = false
function isEmpty(s)
{   return ((s == null) || (s.length == 0))}function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }
    return true;
}
function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}
function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}
function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "", 3, "-", 3, "-", 4))}
function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, iUSPhone);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}
function isInt(chr)           
{
	if (isNaN(chr))
	{return false; }
	else
	  {
		if (chr>0)
		{ return true;	}
		else
		  { return false; }	  
	   }
}
function validZIP(field) {	var valid = "0123456789-";	var hyphencount = 0;	if (field.length!=5 && field.length!=10) {		alert("Please enter your 5 digit or 5 digit+4 zip code.");		return false;	}	for (var i=0; i < field.length; i++) {		temp = "" + field.substring(i, i+1);		if (temp == "-") hyphencount++;			if (valid.indexOf(temp) == "-1") {				alert("Invalid characters in your zip code.  Please try again.");		return false;	}	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {		alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");		return false;	}}return true;}  function changeBox(obj) {
//	obj.checked = !obj.checked;
	obj.checked = true;
}
var iYear = "This field must be a 2 or 4 digit year number.  Please reenter it now."
var pYear = "2 or 4 digit year number."
var cYear = "The year must be lesser than current year.  Please reenter it now."

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];
    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}
function isPhone(str) //format: NNN-NNN-NNNN
{
	if (str.length != 12)     
	{		
		return false;
	}		
	for (var i=0; i<12; i++)
	{
		if ((i == 3 || i == 7) && str.charAt(i) != "-")
		{
			return false;
		}
		if (i!=3 && i!=7 && parseInt(str.charAt(i)) != str.charAt(i))
		{				
			return false;
		}		
	}
	return true;                     
}
function isPhone2Format(str) //format: (NNN) NNN-NNNN
{
	return /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/.test(str);                   
}
function validateUSPhone( strValue ) {
	if((isPhone(strValue)) || (isPhone2Format(strValue))){
		return true;
	}
	else{
		return false;
	}
}
function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}

function checkYear (theField, emptyOK)
{   if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isYear(theField.value, false)) 
       return warnInvalid (theField, iYear);         var chkDate=new Date(Date())
     var sYear=chkDate.getFullYear()
        if (theField.value>sYear)
           return warnInvalid (theField, cYear);       
    else return true;
}
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\');\"></span>"
                  
                  //alert()
	   myImage.outerHTML = strNewHTML	  
    }
}
function changeClass(Elem, myClass) 
{
	if(document.getElementById(Elem)){
		document.getElementById(Elem).className = myClass;
	}
}
function changeClassElem(Elem, myClass) 
{
	Elem.className = myClass;
}
var tmpdgOverEdit = 'images/dg_edit_hover.gif';
var tmpdgEdit = 'images/dg_edit.gif';
var tmpdgOverUpdate = 'images/dg_update_hover.gif';
var tmpdgUpdate = 'images/dg_update.gif';
var tmpdgOverCancel = 'images/dg_cancel_hover.gif';
var tmpdgCancel = 'images/dg_cancel.gif';
function changePicture(objPic, newPicture) 
{
	if(objPic){
		objPic.src = newPicture;
	}
}
function showPremiereDetails( carID )
{
	checkIfOpenDetails( 2 );
	changeClass( carID,'elemShow' );
}
function checkIfOpenDetails( maxCars )
{
	for( i=0; i<maxCars; i++ )
	{
		var elemID = "ucPremiereCarList_rptCarsList__ctl" + i + "_ucPremiereCar_divCarDetails";
		if( document.getElementById(elemID) )
		{
			changeClass( elemID,'elemHide' );
		}
	}
}
function manageLoginCtrl(Elem, normalClass, invalidClass) {
	if(document.getElementById(Elem)){
		if(document.getElementById(Elem).value.length == 0){
			document.getElementById(Elem).className = invalidClass;
		}
		else{
			document.getElementById(Elem).className = normalClass;
		}
	}
}
function checkIFIsSuggested( oUsername )
{
	if( document.forms.frmMain.rbSuggest )
	{
		var sugestions = document.forms.frmMain.rbSuggest;
		
		for( index=0; index < sugestions.length; index++ )
		{
			if( sugestions[index].value == oUsername.value )
			{
				sugestions[index].checked = true;
			}
			else
			{
				sugestions[index].checked = false;
			}
		}
	}
}
function validSignUP( oCollection ) {

	var err = document.getElementById('pnlResult');
	if(err.innerHTML != "")
		err.innerHTML = "";
	
	if ( ( oCollection=="" ) || ( oCollection=="txtFirstName" ) ) {
		if (isWhitespace(document.frmMain.txtFirstName.value)) 
		{
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please enter First Name</li></div>";
			document.frmMain.txtFirstName.focus();
			return false;
		}  
	}
	
	if ( ( oCollection=="" ) || ( oCollection=="txtLastName" ) ) {
		if (isWhitespace(document.frmMain.txtLastName.value)) 
		{
			// alert("Please enter Last Name");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please enter Last Name</li></div>";
			document.frmMain.txtLastName.focus();
			return false;
		}
	} 

	if ( ( oCollection=="" ) || ( oCollection=="txtEmail" ) ) {
		if (isWhitespace(document.frmMain.txtEmail.value)) 
		{
			//alert("Please enter email ");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please enter Email</li></div>";
			document.frmMain.txtEmail.focus();
			return false;
		}  
		if (document.frmMain.txtEmail.value.length>0){ 
			var myEmail = NonSpace(document.frmMain.txtEmail.value);
			if (isEmail(myEmail)==false) {
					//alert("Please enter a valid E-Mail address, like: name@companyname.com ");
					var err = document.getElementById('pnlResult');
					err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please enter a valid <br/>Email address, like: name@companyname.com </li></div>";
					document.frmMain.txtEmail.focus();
					return false;
			}  
		}
		checkEmailAvailability("txtEmail");	
	}
	
	if ( ( oCollection=="" ) || ( oCollection=="txtPhone" ) ) {
		if(!check3Phone( 'txtPhone1', 'txtPhone2', 'txtPhone3', false, false )){
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please, enter a <br/>valid phone number, <br/>like: 555-555-5555</li></div>";
			return false;
		}
	}
	
	if ( ( oCollection=="" ) || ( oCollection=="txtUserName" ) ) {
		if (isWhitespace(document.frmMain.txtUserName.value)) 
		{
			//alert("Please enter UserName");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please enter Username</li></div>";
			document.frmMain.txtUserName.focus();
			return false;
		}  
	}
	
	if ( ( oCollection=="" ) || ( oCollection=="txtPassword" ) ) {
		if (isWhitespace(document.frmMain.txtPassword.value)) 
		{
			//alert("Please enter Password");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please enter Password</li></div>";
			document.frmMain.txtPassword.focus();
			return false;
		}  
		if ( document.frmMain.txtPassword.value.length < 6 ) 
		{
			// alert("Password minimum lenght must be 6 characters");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Password minimum lenght must be 6 characters</li></div>";
			document.frmMain.txtPassword.focus();
			return false;
		}  
	}
	
	if ( ( oCollection=="" ) || ( oCollection=="txtPasswordConfirmation" ) ) {
		if (isWhitespace(document.frmMain.txtPasswordConfirmation.value)) 
		{
			//alert("Please confirm Password");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Please confirm Password</li></div>";
			document.frmMain.txtPasswordConfirmation.focus();
			return false;
		} 
	}
	
	if ( oCollection=="" ) {
		if ( document.frmMain.txtPassword.value != document.frmMain.txtPasswordConfirmation.value ) 
		{
			// alert("Passwords don't match! Re-enter!");
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>Passwords don't match! Re-enter!</li></div>";
			document.frmMain.txtPassword.focus();
			return false;
		} 
	} 
	
	if ( oCollection=="" ) {
		if( !document.frmMain.chkAgreement.checked )
		{
			var err = document.getElementById('pnlResult');
			err.innerHTML = "<div class=\"divErr\" ><ul class=\"ulErr\"><li>You have to agree with Texas Cars For Kids policies in order register!</li></div>";
			document.frmMain.chkAgreement.focus();
			return false;
		}
	}
	return true;
}

function checkingEmail() {

	var err = document.getElementById('pnlResult');
	if(err.innerHTML != "")
		err.innerHTML = "";
	if (document.frmMain.txtEmail.value.length>0){ 
		var myEmail = NonSpace(document.frmMain.txtEmail.value);
		if (isEmail(myEmail)==true) {
			checkEmailAvailability("txtEmail");	
		}	
	} 
	document.getElementById('txtEmail').select();
	return false;
}
function clearErrMessage()
{
	var err = document.getElementById('pnlResult');
	err.innerHTML = "";
}
function changeImage(Elem, newSrc) 
{
	var tmp = new Image();
	tmp.src = newSrc;

	if(document.getElementById(Elem))
	{
		document.getElementById(Elem).src = tmp.src;
	}
}

var timer;
function doShowPrintOptions(){
	if (document.getElementById('divPhotoPrint')){
		killTimer();
		changeClass('divPhotoPrint','elemShow');
	}
}
function doHidePrintOptions(){
	if (document.getElementById('divPhotoPrint')){
		killTimer();
		timer = window.setTimeout("changeClass('divPhotoPrint','elemHide');", 500);
	}
	if(document.getElementById('rbPrintWP')){
		document.getElementById('rbPrintWP').checked = false;
	}
	if(document.getElementById('rbPrintWOP')){
		document.getElementById('rbPrintWOP').checked = false;
	}
}
function killTimer(){
	window.clearTimeout(timer);
}

function printList( bPhotos, iLocation, iType ) {
	var wSpace = 650;
	var hSpace = 400;
	var width = (screen.availWidth - wSpace)/2;
	var height = (screen.availHeight - hSpace)/2;
	
	loc = "printlist.aspx?bp=" + bPhotos + "&il=" + iLocation + "&it=" + iType;
	windowprops = 'left=' + width + ',top=' + height + ',width=' + wSpace + ',height=' + hSpace + ',menubar=0,toolbar=0,status=0,location=0,scrollbars=1,resizable=1';
	popupWindow = open(loc, 'printLIST', windowprops);
	if (popupWindow.opener == null) 
			popupWindow.opener = self;
}

function printBoatList( bPhotos, iLocation, iType ) {
	var wSpace = 750;
	var hSpace = 400;
	var width = (screen.availWidth - wSpace)/2;
	var height = (screen.availHeight - hSpace)/2;
	
	loc = "printboatlist.aspx?bp=" + bPhotos + "&il=" + iLocation + "&it=" + iType;
	windowprops = 'left=' + width + ',top=' + height + ',width=' + wSpace + ',height=' + hSpace + ',menubar=0,toolbar=0,status=0,location=0,scrollbars=1,resizable=1';
	popupWindow = open(loc, 'printLIST', windowprops);
	if (popupWindow.opener == null) 
			popupWindow.opener = self;
}

function getLocation(){
	if( document.frmMain.rblAuctionLocation_0 )
		if( document.frmMain.rblAuctionLocation_0.checked )
			return document.frmMain.rblAuctionLocation_0.value;
		else if( document.frmMain.rblAuctionLocation_1.checked )
				return document.frmMain.rblAuctionLocation_1.value;
			else
				return 0;
	else
		return 0;
}
var timerSearch;
function doShowSearch(bShow){
	if (document.getElementById('divPhotoPrint')){
		window.clearTimeout(timerSearch);
		
		if(bShow == true)
		{
			changeClass('divSearchOptions','elemShow');
		}
		else
		{
			timerSearch = window.setTimeout("changeClass('divSearchOptions','elemHide');", 500);
		}
	}
}

function ViewHolder(HolderID){
	if (document.getElementById(HolderID)){
		var Holder = document.getElementById(HolderID);
		
		if(Holder.className == "elemShow"){
			Holder.className = "elemHide";
		}
		else{
			if(Holder.className == "elemHide"){
				Holder.className = "elemShow";
			}
		}
	}
}
function formatNumber(oCtrl) 
{			
	if(oCtrl){
		if(!isMoney(oCtrl.value)){
			oCtrl.value=0;
		}
		
		var Number = oCtrl.value;
		Number = 50*(Math.ceil(Number/50));
		
		var num = new NumberFormat();
		num.setInputDecimal('.');
		num.setNumber(Number); 
		num.setPlaces('2', false);
		num.setCurrencyValue('$');
		num.setCurrency(true);
		num.setCurrencyPosition(num.LEFT_OUTSIDE);
		num.setNegativeFormat(num.LEFT_DASH);
		num.setNegativeRed(false);
		num.setSeparators(true, ',', ',');
		
		oCtrl.value = num.toFormatted();//new NumberFormat(Number).toFormatted();
	}
}
function formatNumber(oCtrl) 
{			
	if(oCtrl){
		
		if(oCtrl.value.length > 0){
			oCtrl.value = oCtrl.value.replace(/-/g,'');
			oCtrl.value = oCtrl.value.replace(/\$/g,'');
			oCtrl.value = oCtrl.value.replace(/,/g,'');
		}
		
		if(!isMoney(oCtrl.value))
			oCtrl.value=0;
		
		var Number = oCtrl.value;
		Number = 50*(Math.ceil(Number/50));
		
		var num = new NumberFormat();
		num.setInputDecimal('.');
		num.setNumber(Number); 
		num.setPlaces('2', false);
		num.setCurrencyValue('$');
		num.setCurrency(true);
		num.setCurrencyPosition(num.LEFT_OUTSIDE);
		num.setNegativeFormat(num.LEFT_DASH);
		num.setNegativeRed(false);
		num.setSeparators(true, ',', ',');
		
		oCtrl.value = num.toFormatted();//new NumberFormat(Number).toFormatted();
	}
}
function isMoney(strVal)
{			
	var validStr='0123456789.,';
	var temp;
	for (var i=0; i<strVal.length; i++) {
	temp =  strVal.substring(i,i+1);
	if (validStr.indexOf(temp) == -1)  return false ;}
	return true;
}

function checkBid()
{
	var YourBid=0;
	var YourMaxBid=0;
	
	if (document.getElementById('txtBid')){
		var vTmp = document.getElementById('txtBid').value;
		if(vTmp.length > 0){
			vTmp = vTmp.replace(/-/g,'');
			vTmp = vTmp.replace(/\$/g,'');
			vTmp = vTmp.replace(/,/g,'');
		}
		if(!isMoney(vTmp))
			vTmp = 0;
		YourBid = vTmp;
	}
	if (document.getElementById('txtMaxBid')){
		var vTmp = document.getElementById('txtMaxBid').value;
		
		if(vTmp.length > 0){
			vTmp = vTmp.replace(/-/g,'');
			vTmp = vTmp.replace(/\$/g,'');
			vTmp = vTmp.replace(/,/g,'');
		}
		if(!isMoney(vTmp))
			vTmp = 0;
		YourMaxBid = vTmp;
	}
	
	if( parseFloat(YourMaxBid) == parseFloat(0) ){
		document.getElementById('txtMaxBid').value = document.getElementById('txtBid').value;
		YourMaxBid = document.getElementById('txtBid').value;
	}
	
	if( parseFloat(YourBid) == parseFloat(0) ){
		alert('"YourBid" cannot be $0.00!');
		return false;
	}
	
	if( parseFloat(YourMaxBid) < parseFloat(YourBid) ){
		alert('"Your Maximum Bid" cannot be smaller than "Your Bid"!');
		return false;
	}
	
	var numB = new NumberFormat();
		numB.setInputDecimal('.');
		numB.setNumber(YourBid); 
		numB.setPlaces('2', false);
		numB.setCurrencyValue('$');
		numB.setCurrency(true);
		numB.setCurrencyPosition(numB.LEFT_OUTSIDE);
		numB.setNegativeFormat(numB.LEFT_DASH);
		numB.setNegativeRed(false);
		numB.setSeparators(true, ',', ',');
		document.getElementById('txtBid').value = numB.toFormatted();
	
	var numMB = new NumberFormat();
		numMB.setInputDecimal('.');
		numMB.setNumber(YourMaxBid); 
		numMB.setPlaces('2', false);
		numMB.setCurrencyValue('$');
		numMB.setCurrency(true);
		numMB.setCurrencyPosition(numMB.LEFT_OUTSIDE);
		numMB.setNegativeFormat(numMB.LEFT_DASH);
		numMB.setNegativeRed(false);
		numMB.setSeparators(true, ',', ',');
		document.getElementById('txtMaxBid').value = numMB.toFormatted();
		
	return true;
}
function confirmOwnBid(vType)
{
	var bIsValid = true;
	
	if(checkBid())
	{
		if(!confirm('You are already the high bidder for this ' + ((vType==1)?'Car':((vType==2)?'Boat':'Vehicle')) + '! \nContinue?'))
		{
			bIsValid = false;
		}
	}
		
	return bIsValid;
}
function checkConfirmation()
{
	if (document.getElementById('chkConfirm')){
		var vTmp = document.getElementById('chkConfirm');
		if(!vTmp.checked){
			alert('Please check the agreement checkbox!');
			return false;
		}
		
	}
	
	return true;
}

var timerSend;
function doShowSendEmail(bShow){
	if (document.getElementById('divSendEmail')){
		window.clearTimeout(timerSend);
		
		if(bShow == true)
		{
			changeClass('divSendEmail','elemShow');
		}
		else
		{
			timerSend = window.setTimeout("changeClass('divSendEmail','elemHide');changeClass('divSend2Friend','elemShow');", 500);
		}
	}
}
// validate online deposit
function validStep1() {

	if (isWhitespace(document.frmMain.txtFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.frmMain.txtFirstName.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmMain.txtLastName.focus();
	     return false;
	}  

	if (isWhitespace(document.frmMain.txtAddress1.value)) 
	{
	     alert("Please enter Address ");
	     document.frmMain.txtAddress1.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtCity.value)) 
	{
	     alert("Please enter City");
	     document.frmMain.txtCity.focus();
	     return false;
	}  
	if ( (document.frmMain.ddlStates.options[document.frmMain.ddlStates.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmMain.ddlStates.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtZip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmMain.txtZip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmMain.txtZip)==false) {
				document.frmMain.txtZip.focus();
				return false;
	} 
	if ( (document.frmMain.ddlCountries.options[document.frmMain.ddlCountries.options.selectedIndex].value)=="0")
	{
	     alert("Please enter Country");
	     document.frmMain.ddlCountries.focus();
	     return false;
	}  
	/*
	if (isWhitespace(document.frmMain.txtPhone.value)) 
	{
	     alert("Please enter Phone ");
	     document.frmMain.txtPhone.focus();
	     return false;
	} 
	
	if (document.frmMain.txtPhone.value !="" && !checkUSPhone(document.frmMain.txtPhone)) {
		document.frmMain.txtPhone.focus();
		return false;
	}
	*/
	if(!check3Phone( 'txtPhone1', 'txtPhone2', 'txtPhone3', true, true ))
		return false;
	
	if (isWhitespace(document.frmMain.txtEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmMain.txtEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtEmail.value.length>0){ 
	var myEmail = NonSpace(document.frmMain.txtEmail.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmMain.txtEmail.focus();
			return false;
	}  
	}			

	return true;
}
function validStep2() {
	if(confirm("This will start Secure Payment process. Please make sure that the billing information is accurate.\n\rContinue?")){
		return true;
	}
	return false;
}

function validMyAccount() {

	if (isWhitespace(document.frmMain.txtAccFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.frmMain.txtAccFirstName.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtAccLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmMain.txtAccLastName.focus();
	     return false;
	} 
	if (document.frmMain.txtAccPhone.value !="" && !checkUSPhone(document.frmMain.txtAccPhone)) {
		document.frmMain.txtAccPhone.focus();
		return false;
	}
	if (isWhitespace(document.frmMain.txtAccEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmMain.txtAccEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtAccEmail.value.length>0){ 
		var myEmail = NonSpace(document.frmMain.txtAccEmail.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.frmMain.txtAccEmail.focus();
				return false;
		}  
	}	
	
	if (isWhitespace(document.frmMain.txtFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.frmMain.txtFirstName.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmMain.txtLastName.focus();
	     return false;
	}  

	if (isWhitespace(document.frmMain.txtAddress1.value)) 
	{
	     alert("Please enter Address ");
	     document.frmMain.txtAddress1.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtCity.value)) 
	{
	     alert("Please enter City");
	     document.frmMain.txtCity.focus();
	     return false;
	}  
	if ( (document.frmMain.ddlStates.options[document.frmMain.ddlStates.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmMain.ddlStates.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtZip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmMain.txtZip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmMain.txtZip)==false) {
				document.frmMain.txtZip.focus();
				return false;
	} 
	if ( (document.frmMain.ddlCountries.options[document.frmMain.ddlCountries.options.selectedIndex].value)=="0")
	{
	     alert("Please enter Country");
	     document.frmMain.ddlCountries.focus();
	     return false;
	}  
	
	if (isWhitespace(document.frmMain.txtPhone.value)) 
	{
	     alert("Please enter Phone ");
	     document.frmMain.txtPhone.focus();
	     return false;
	}  
	if (document.frmMain.txtPhone.value !="" && !checkUSPhone(document.frmMain.txtPhone)) {
		document.frmMain.txtPhone.focus();
		return false;
	}
	
	
	if (isWhitespace(document.frmMain.txtEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmMain.txtEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtEmail.value.length>0){ 
	var myEmail = NonSpace(document.frmMain.txtEmail.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmMain.txtEmail.focus();
			return false;
	}  
	}			

	return true;
}
function validContactUs() {

	if (isWhitespace(document.frmContactUs.txtFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.frmContactUs.txtFirstName.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.txtLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmContactUs.txtLastName.focus();
	     return false;
	}  

	if (isWhitespace(document.frmContactUs.txtAddress.value)) 
	{
	     alert("Please enter Address ");
	     document.frmContactUs.txtAddress.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.txtCity.value)) 
	{
	     alert("Please enter City");
	     document.frmContactUs.txtCity.focus();
	     return false;
	}  
	if ( (document.frmContactUs.ddlStates.options[document.frmContactUs.ddlStates.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmContactUs.ddlStates.focus();
	     return false;
	}  
	if (isWhitespace(document.frmContactUs.txtZip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmContactUs.txtZip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmContactUs.txtZip)==false) {
				document.frmContactUs.txtZip.focus();
				return false;
	} 
	/*
	if (isWhitespace(document.frmContactUs.txtPhone.value)) 
	{
	     alert("Please enter Phone ");
	     document.frmContactUs.txtPhone.focus();
	     return false;
	}  
	if (document.frmContactUs.txtPhone.value !="" && !checkUSPhone(document.frmContactUs.txtPhone)) {
		document.frmContactUs.txtPhone.focus();
		return false;
	}
	*/
	if(!check3Phone( 'txtPhone1', 'txtPhone2', 'txtPhone3', true, true ))
		return false;
	
	/*	
	if (document.frmContactUs.txtFax.value !="" && !checkUSPhone(document.frmContactUs.txtFax)) {
		document.frmContactUs.txtFax.focus();
		return false;
	}*/
	if(!check3Phone( 'txtFax1', 'txtFax2', 'txtFax3', false, true ))
		return false;
	
	if (isWhitespace(document.frmContactUs.txtEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.txtEmail.focus();
	     return false;
	}  
	if (document.frmContactUs.txtEmail.value.length>0){ 
	var myEmail = NonSpace(document.frmContactUs.txtEmail.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmContactUs.txtEmail.focus();
			return false;
	}  
	}			

	if (isWhitespace(document.frmContactUs.txtMessage.value)) 
	{
	     alert("Please enter Message ");
	     document.frmContactUs.txtMessage.focus();
	     return false;
	}  
	 return true;
}

function validSendToFriend() {

	if (isWhitespace(document.frmMain.txtYourName.value)) 
	{
	     alert("Please enter Your Name");
	     document.frmMain.txtYourName.focus();
	     return false;
	}  
	
	if (isWhitespace(document.frmMain.txtYourEmail.value)) 
	{
	     alert("Please enter Your Email ");
	     document.frmMain.txtYourEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtYourEmail.value.length>0){ 
		var myEmail = NonSpace(document.frmMain.txtYourEmail.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.frmMain.txtYourEmail.focus();
				return false;
		}  
	}			

	if (isWhitespace(document.frmMain.txtFriendName.value)) 
	{
	     alert("Please enter Recipient's Name");
	     document.frmMain.txtFriendName.focus();
	     return false;
	}  
	
	if (isWhitespace(document.frmMain.txtFriendEmail.value)) 
	{
	     alert("Please enter Recipient's Email ");
	     document.frmMain.txtFriendEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtFriendEmail.value.length>0){ 
		var myEmail = NonSpace(document.frmMain.txtFriendEmail.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.frmMain.txtFriendEmail.focus();
				return false;
		}  
	}	
	 return true;
}

function printCarDetails( iCarID ) {
	var wSpace = 760;
	var hSpace = 420;
	var width = (screen.availWidth - wSpace)/2;
	var height = (screen.availHeight - hSpace)/2;
	
	loc = "printcardetail.aspx?vid=" + iCarID;
	windowprops = 'left=' + width + ',top=' + height + ',width=' + wSpace + ',height=' + hSpace + ',menubar=0,toolbar=0,status=0,location=0,scrollbars=1,resizable=1';
	popupWindow = open(loc, 'printCARDETAILS', windowprops);
	if (popupWindow.opener == null) 
			popupWindow.opener = self;
}

function printBoatDetails( iCarID ) {
	var wSpace = 760;
	var hSpace = 420;
	var width = (screen.availWidth - wSpace)/2;
	var height = (screen.availHeight - hSpace)/2;
	
	loc = "printboatdetail.aspx?vid=" + iCarID;
	windowprops = 'left=' + width + ',top=' + height + ',width=' + wSpace + ',height=' + hSpace + ',menubar=0,toolbar=0,status=0,location=0,scrollbars=1,resizable=1';
	popupWindow = open(loc, 'printBOATDETAILS', windowprops);
	if (popupWindow.opener == null) 
			popupWindow.opener = self;
}


function printPremiereCarDetails( iCarID ) {
	var wSpace = 760;
	var hSpace = 420;
	var width = (screen.availWidth - wSpace)/2;
	var height = (screen.availHeight - hSpace)/2;
	
	loc = "printpremierecardetail.aspx?vid=" + iCarID;
	windowprops = 'left=' + width + ',top=' + height + ',width=' + wSpace + ',height=' + hSpace + ',menubar=0,toolbar=0,status=0,location=0,scrollbars=1,resizable=1';
	popupWindow = open(loc, 'printCARDETAILS', windowprops);
	if (popupWindow.opener == null) 
			popupWindow.opener = self;
}

function validLoginProblems() {
	
	if(!check3Phone( 'txtPhone1', 'txtPhone2', 'txtPhone3', true, true ))
		return false;
	
	if (isWhitespace(document.frmContactUs.txtEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.txtEmail.focus();
	     return false;
	}  
	if (document.frmContactUs.txtEmail.value.length>0){ 
	var myEmail = NonSpace(document.frmContactUs.txtEmail.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmContactUs.txtEmail.focus();
			return false;
	}  
	}			

	if (isWhitespace(document.frmContactUs.txtMessage.value)) 
	{
	     alert("Please enter Message ");
	     document.frmContactUs.txtMessage.focus();
	     return false;
	}  
	 return true;
}
function validForgotPass()
{
	/*if ( (isWhitespace(document.frmContactUs.txtUsername.value)) && (isWhitespace(document.frmContactUs.txtFPEmail.value)) )
	{
	     alert("Please Enter your Username or your Email Address");
	     document.frmContactUs.txtUsername.focus();
	     return false;
	}*/  
	
	if (document.frmContactUs.txtFPEmail.value.length>0){ 
		var myEmail = NonSpace(document.frmContactUs.txtFPEmail.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.frmContactUs.txtFPEmail.focus();
				return false;
		}  
	}			

	return true;
}
function validLoginHome()
{
	if (isWhitespace(document.frmMain.txtUserName.value)) 
	{
	     alert("Please enter Username! ");
	     document.frmMain.txtUserName.focus();
	     return false;
	}  
	
	
	if (isWhitespace(document.frmMain.txtPassword.value)) 
	{
	     alert("Please enter Password! ");
	     document.frmMain.txtPassword.focus();
	     return false;
	}  
	
	return true;
}
function validLoginHomeUsername()
{
	if(document.getElementById('txtUserName'))
	{
		//alert('Username \"' + document.getElementById('txtUserName').value + '\" does not exist!');
		alert('Invalid ID or password.\nPlease try again.');
		document.getElementById('txtUserName').focus();
	}
}
function validLoginHomePassword()
{
	if(document.getElementById('txtPassword')){
		//alert('Password is invalid!');
		alert('Invalid ID or password.\nPlease try again.');
		document.getElementById('txtPassword').focus();
	}
}
function validEmptyField( FieldID, FieldCaption )
{
	if(document.getElementById(FieldID))
	{
		alert(FieldCaption + ' cannot be empty.');
		document.getElementById(FieldID).focus();
	}
}
function validLogin()
{
	if (isWhitespace(document.frmContactUs.txtUsername.value)) 
	{
	     alert("Please enter Username ");
	     document.frmContactUs.txtUsername.focus();
	     return false;
	}  
	
	
	if (isWhitespace(document.frmContactUs.txtEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmContactUs.txtEmail.focus();
	     return false;
	}  
	
	return true;
}

/*usermenu dropdowns*/
var timerMyBids;
function doShowMyBids(){
	doHideAll();
	if (document.getElementById('div_UM_MyBids')){
		window.clearTimeout(timerMyBids);
		changeClass('div_UM_MyBids','elemShow');
		changeClass('spn_UM_MyBids','lnkHover');
	}
}
function doHideMyBids(){
	if (document.getElementById('div_UM_MyBids')){
		window.clearTimeout(timerMyBids);
		timerMyBids = window.setTimeout("changeClass('div_UM_MyBids','elemHide');changeClass('spn_UM_MyBids','lnkNormal');", 500);
	}
}

var timerMySearch;
function doShowMySearch(){
	doHideAll();
	if (document.getElementById('div_UM_MySearch')){
		window.clearTimeout(timerMySearch);
		changeClass('div_UM_MySearch','elemShow');
		changeClass('spn_UM_MySearch','lnkHover');
	}
}
function doHideMySearch(){
	if (document.getElementById('div_UM_MySearch')){
		window.clearTimeout(timerMySearch);
		timerMySearch = window.setTimeout("changeClass('div_UM_MySearch','elemHide');changeClass('spn_UM_MySearch','lnkNormal');", 500);
	}
}


var timerMyAccount;
function doShowMyAccount(){
	doHideAll();
	if (document.getElementById('div_UM_MyAccount')){
		window.clearTimeout(timerMyAccount);
		changeClass('div_UM_MyAccount','elemShow');
		changeClass('spn_UM_MyAccount','lnkHover');
	}
}
function doHideMyAccount(){
	if (document.getElementById('div_UM_MyAccount')){
		window.clearTimeout(timerMyAccount);
		timerMyAccount = window.setTimeout("changeClass('div_UM_MyAccount','elemHide');changeClass('spn_UM_MyAccount','lnkNormal');", 500);
	}
}

var timerListCars;
function doShowListCars(){
	doHideAll();
	if (document.getElementById('div_UM_ListCars')){
		window.clearTimeout(timerListCars);
		changeClass('div_UM_ListCars','elemShow');
		changeClass('spn_UM_ListCars','lnkHover');
	}
}
function doHideListCars(){
	if (document.getElementById('div_UM_ListCars')){
		window.clearTimeout(timerListCars);
		timerListCars = window.setTimeout("changeClass('div_UM_ListCars','elemHide');changeClass('spn_UM_ListCars','lnkNormal');", 500);
	}
}

var timerListBoats;
function doShowListBoats(){
	doHideAll();
	if (document.getElementById('div_UM_ListBoats')){
		window.clearTimeout(timerListBoats);
		changeClass('div_UM_ListBoats','elemShow');
		changeClass('spn_UM_ListBoats','lnkHover');
	}
}
function doHideListBoats(){
	if (document.getElementById('div_UM_ListBoats')){
		window.clearTimeout(timerListBoats);
		timerListBoats = window.setTimeout("changeClass('div_UM_ListBoats','elemHide');changeClass('spn_UM_ListBoats','lnkNormal');", 500);
	}
}
function doHideAll()
{
	try
	{
		changeClass('div_UM_ListBoats','elemHide');
		changeClass('div_UM_ListCars','elemHide');
		changeClass('div_UM_MyAccount','elemHide');
		changeClass('div_UM_MySearch','elemHide');
		changeClass('div_UM_MyBids','elemHide');
		changeClass('spn_UM_MyBids','lnkNormal');
		changeClass('spn_UM_MySearch','lnkNormal');
		changeClass('spn_UM_MyAccount','lnkNormal');
		changeClass('spn_UM_ListCars','lnkNormal');
		changeClass('spn_UM_ListBoats','lnkNormal');
	}
	catch(e){}
}
function validMyAccount_User() {

	if (isWhitespace(document.frmMain.txtAccFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.frmMain.txtAccFirstName.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtAccLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmMain.txtAccLastName.focus();
	     return false;
	} 
	
	if(!check3Phone( 'txtAccPhone1', 'txtAccPhone2', 'txtAccPhone3', false, true ))
		return false;
	
	
	if (isWhitespace(document.frmMain.txtAccEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmMain.txtAccEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtAccEmail.value.length>0){ 
		var myEmail = NonSpace(document.frmMain.txtAccEmail.value);
		if (isEmail(myEmail)==false) {
				alert("Please enter a valid E-Mail address, like: name@companyname.com ");
				document.frmMain.txtAccEmail.focus();
				return false;
		}  
	}	
	
	

	return true;
}

function validMyAccount_Billing()
{

	if (isWhitespace(document.frmMain.txtFirstName.value)) 
	{
	     alert("Please enter First Name");
	     document.frmMain.txtFirstName.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtLastName.value)) 
	{
	     alert("Please enter Last Name");
	     document.frmMain.txtLastName.focus();
	     return false;
	}  

	if (isWhitespace(document.frmMain.txtAddress1.value)) 
	{
	     alert("Please enter Address ");
	     document.frmMain.txtAddress1.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtCity.value)) 
	{
	     alert("Please enter City");
	     document.frmMain.txtCity.focus();
	     return false;
	}  
	if ( (document.frmMain.ddlStates.options[document.frmMain.ddlStates.options.selectedIndex].value)=="0")
	{
	     alert("Please enter State");
	     document.frmMain.ddlStates.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtZip.value)) 
	{
	     alert("Please enter Zip");
	     document.frmMain.txtZip.focus();
	     return false;
	}  
	 if (validateZIP(document.frmMain.txtZip)==false) {
				document.frmMain.txtZip.focus();
				return false;
	} 
	if ( (document.frmMain.ddlCountries.options[document.frmMain.ddlCountries.options.selectedIndex].value)=="0")
	{
	     alert("Please enter Country");
	     document.frmMain.ddlCountries.focus();
	     return false;
	}  
	
	if(!check3Phone( 'txtPhone1', 'txtPhone2', 'txtPhone3', true, true ))
		return false;
	
	if (isWhitespace(document.frmMain.txtEmail.value)) 
	{
	     alert("Please enter email ");
	     document.frmMain.txtEmail.focus();
	     return false;
	}  
	if (document.frmMain.txtEmail.value.length>0){ 
	var myEmail = NonSpace(document.frmMain.txtEmail.value);
	if (isEmail(myEmail)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmMain.txtEmail.focus();
			return false;
	}  
	}
	
	return true;			
}

function validMyAccount_Password() {

	if (isWhitespace(document.frmMain.txtOldPassword.value))  
	{
	     alert("Please enter Current Password");
	     document.frmMain.txtOldPassword.focus();
	     return false;
	}  
	if (isWhitespace(document.frmMain.txtNewPassword.value))
	{
	     alert("Please enter New Password");
	     document.frmMain.txtNewPassword.focus();
	     return false;
	} 
	if (document.frmMain.txtOldPassword.value==document.frmMain.txtNewPassword.value)  
	{
	    alert("The new password should be different from old password");
	    document.frmMain.txtNewPassword.focus();
	    return false;
	}  
	
	if (isWhitespace(document.frmMain.txtNewPasswordConfirm.value))
	{
	     alert("Please confirm New Password");
	     document.frmMain.txtNewPasswordConfirm.focus();
	     return false;
	} 
	return true;
}


/* phone utilities */

//phone validations
function isPhoneUS2(str) //format: (NNN) NNN-NNNN
{
	//str = removeSpaces(str);
	return /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/.test(str);                   
}
function isPhoneUS1(str) //format: NNN-NNN-NNNN
{
	//str = removeSpaces(str);
	return /^\d{3}\-?\d{2}\-?\d{4}$/.test(str);                   
}


function clearCharacters( oCtrl ) {
	oCtrl.value = oCtrl.value.replace(/\D/g,'');
}
function focusNext( oCtrl, NextCtrlID ) {
	if(oCtrl.value.length==3)
	{
		if (document.getElementById(NextCtrlID))
			document.getElementById(NextCtrlID).focus();
	}
}
function removeSpaces( strValue ) 
{
	 return strValue.replace(/\s/g, '');
}

function check3Phone( PhoneField1ID, PhoneField2ID, PhoneField3ID, isRequired, showAlert )
{
	
	if( (document.getElementById(PhoneField1ID)) && (document.getElementById(PhoneField2ID)) && (document.getElementById(PhoneField3ID)) )
	{
		var PhoneField1 = document.getElementById(PhoneField1ID);
		var PhoneField2 = document.getElementById(PhoneField2ID);
		var PhoneField3 = document.getElementById(PhoneField3ID);
		
		if ((PhoneField1.value.length > 0 ) || (PhoneField2.value.length > 0) || (PhoneField3.value.length > 0)) {
			
			if (PhoneField1.value.length < 3 ) {
				if(showAlert)
					alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField1.focus();
				return false;
			}
			if (PhoneField2.value.length < 3) {
				if(showAlert)
					alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField2.focus();
				return false;
			}
			if (PhoneField3.value.length < 4) {
				if(showAlert)
					alert('This field must be a 4 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField3.focus();
				return false;
			}
		}
		else
		{
			if ( isRequired ) 
			{
				if(showAlert)
					alert("Please enter Phone ");
				PhoneField1.focus();
				return false;
			}
		}
	}
	else
	{
		alert("No Phone field present on this form");
	    return false;
	}
	
	return true;
}

function grayOut(vis, options) {
  
	var g_UA = navigator.userAgent.toLowerCase();
	var g_MAC = (g_UA.indexOf("mac")!=-1);
  
	var options = options || {}; 
	var zindex = options.zindex || 50;
	var opacity = options.opacity || 0.1;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || ((g_MAC)?'Transparent':'#ffffff');
	var dark=document.getElementById('darkenScreenObject');
	if (!dark) {
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');          
			tnode.style.position='absolute';                
			tnode.style.top='0px';                          
			tnode.style.left='0px';                         
			tnode.style.overflow='hidden';                        
			tnode.style.display='none';                     
			tnode.id='darkenScreenObject';                   
		tbody.appendChild(tnode);                           
		dark=document.getElementById('darkenScreenObject'); 
	}
	if (vis) {
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} else {
			var pageWidth='100%';
			var pageHeight='100%';
		}   
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';                          
	} else {
		dark.style.display='none';
	}
}
function showPreviewTitle()
{
	if(document.getElementById('divPreview'))
		changeClass('divPreview','divPreview elemShow');
}


/* preload menu images */		
MM_preloadImages('menu_vehicles_sale_hover.gif', 'menu_auction_info_hover.gif', 'menu_bidding_info_hover.gif', 'menu_about_us_hover.gif');
