		function MoveTo() {
			dml=document.messageList
			dbox=dml.destBox
			if(dbox.options[dbox.selectedIndex].value == "@NEW") {
				nn=window.prompt("Please enter a name for your new folder.","");
				if (nn==null || nn=="null" || nn=="") {
					dbox.selectedIndex=0;
					dml.destBox2.selectedIndex=0;
					return;
				}
				dml.new_folder_name.value=nn;
				dml.MOV.value=1;
				dml.submit();
			}
			else {
				dml.folder_id.value=dml.destBox.value
				dml.MOV.value=1
				dml.submit()
			}
			return false
		}
		function Goto(id) {
			dml=document.messageList;
			dbox=dml.destBox2;
			window.location='/nest?s=images&folderID='+id;
			//if(dbox.options[dbox.selectedIndex].value == thisItem) {
			//}
			return false;
		}
		function Delete() {
			if (!confirm('Really delete these images?\n\nBe careful!\n\nDelete images only when you no longer need them.\nOtherwise, they may disappear from your auctions!')) {
				return false;
			}
			dml=document.messageList;
			dml.folder_id.value=dml.destBox.value // 5/20/02: needed to jump back to right folder!
			dml.deleteIt.value='images';
			dml.submit();
			return false;
		}
		function DeleteFolder() {
			dml=document.messageList;
			if (dml.destBox.value == '') {
				alert('This is the DELETE FOLDER button.  Select a folder, or use DELETE CHECKED.');
				return false;
			}
			if (!confirm('WAIT!  Do you really want to delete this FOLDER and ALL of the images in it?')) {
				return false;
			}
			dml.deleteIt.value='folder'
			dml.submit();
			return false;
		}
		//	function SynchMoves(primary) {
		//	dml=document.messageList;
		//	if(primary==2) dml.destBox.selectedIndex=dml.destBox2.selectedIndex;
		//	else dml.destBox2.selectedIndex=dml.destBox.selectedIndex;
		//	}
		function SetChecked(val) {
			dml=document.messageList;
			len = dml.elements.length;
			var i=0;
			for( i=0 ; i<len ; i++) {
				if (dml.elements[i].name.indexOf('k', 0) > -1) {
					dml.elements[i].checked=val;
				}
			}
		}
		function itemWindow(myUrl) {
			if (screen) {
				leftPos = screen.width-660
		 		itemWin = window.open(myUrl, 'itemWin', 'width=650,height=600,left='+leftPos+',top=0,resizable=yes,scrollbars=yes')
		 		itemWin = window.open(myUrl, 'itemWin', 'width=650,height=600,left='+leftPos+',top=0,resizable=yes,scrollbars=yes')
			}
			return false
		}
		function topLeftWindow(thisUrl) {
			if (screen) {
				//scr_width = screen.width/2
				scr_width = 800
				scr_height = screen.height*2/3
		 		itemWin = window.open(thisUrl, 'itemWin', 'width='+scr_width+',height='+scr_height+',left=50,top=0,resizable=yes,scrollbars=yes')
			}
			itemWin.focus()
		}
		function topRightWindow(thisUrl) {
			if (screen) {
				scr_width = screen.width/2
				scr_height = screen.height/2
		 		itemWin = window.open(thisUrl, 'itemWin', 'width='+scr_width+',height='+scr_height+',left='+scr_width+',top=0,resizable=yes,scrollbars=yes')
			}
			itemWin.focus()
		}
		function picWindow(thisUrl) {
			if (screen) {
				leftPos = screen.width/10
				topPos = screen.height/10
				width = screen.width/4
				height = screen.height/3
		 		itemWin2 = window.open(thisUrl, 'itemWin', 'width='+width+',height='+height+',left='+leftPos+',top='+topPos+',resizable=yes,scrollbars=yes')
			}
			itemWin2.focus()
		}
		function termsWindow(name)
		{
			myWindow = window.open(name, 'smallwin', 'width=330,height=400,scrollbars=yes,resizable=yes')
			myWindow.focus()
		}
		function newChartWindow(name)
		{
			chartWindow = window.open(name, 'chartwin', 'width=600,height=250,left=0,top=0,scrollbars=no,location=no,locationbar=no,navigationbar=no,historybar=no,menubar=no,resize=no')
			chartWindow.focus()
		}
		function submitUser(n, errform) {

			if (n == 0 && errform.userid.value == '') {
					alert('You didn\'t specify a userid!')
					errform.userid.focus()
					errform.userid.select()
					return false
			}
			if (n == 0 && hasMetaChars(errform.userid)) {
					alert('Your userid cannot contain spaces or funny characters.')
					errform.userid.focus()
					errform.userid.select()
					return false
			}
			if (n <= 1 && errform.firstname.value == '') {
					alert('Please specify your first name.')
					errform.firstname.focus()
					errform.firstname.select()
					return false
			}
			if (n <= 1 && errform.lastname.value == '') {
					alert('Please specify your last name.')
					errform.lastname.focus()
					errform.lastname.select()
					return false
			}
			if (n <= 1 && !validEmail(errform.email.value)) {
					alert('Invalid email address.')
					errform.email.focus()
					errform.email.select()
					return false
			}
			if (n == 0 && errform.email.value != errform.email2.value) {
					alert('The e-mail addresses do not match!')
					errform.email.focus()
					errform.email.select()
					return false
			}
			if ( n == 0 && errform.password.value == '' ) {
					alert('Please enter a password!')
					errform.password.focus()
					errform.password.select()
					return false
			}
			if ( n == 5 && errform.password.value == '' ) {
					alert('Please enter a password!')
					errform.password.focus()
					errform.password.select()
					return false
			}
			if ( n == 5 && errform.password2.value == '' ) {
					alert('Please enter your password to verify!')
					errform.password2.focus()
					errform.password2.select()
					return false
			}
			if ( (n == 0 || n == 1) && errform.password.value != errform.password2.value ) {
					alert('The passwords do not match!')
					errform.password.focus()
					errform.password.select()
					return false
			}
			if ( (n == 0 || n == 1) && errform.password.value != errform.password2.value) {
					alert('The passwords do not match.')
					errform.password2.focus()
					errform.password2.select()
					return false
			}

			// credit card stuff
			// if ( /* n == 0 || n == 6) {
			if (n == 6) {

				cc_selected	= errform.billing_opt[1].checked;
				cc_type_str	= errform.cc_type.value
				cc		= errform.cc_number.value
				cclen	= errform.cc_number.value.length
				cc_num	= errform.cc_number.value
				zip		= errform.zip_code.value

				if (cc_selected==1)
				{
					if (cc_type_str=='default') {
						alert('Please specify a card type!')
						return false
					}

					if ( (!isNumber(cc) || cclen < 15) ) {
						alert('Please specify a valid card number!')
						return false
					}

					if ( !validCC(cc_type_str, cc_num) ) {
						// hack for capitalization
						if (cc_type_str == 'mc') {
							alert('Invalid MasterCard number.')
						}
						else if (cc_type_str == 'amex') {
							alert('Invalid American Express number.')
						}
						else {
							alert('Invalid '+cc_type_str.toUpperCase().substring(0,1)+cc_type_str.substring(1,20)+' number.')
						}
						return false
					}
					if ( (( cclen > 0 && (cclen <= 14 || !isNumber(cc)) || hasSpace(errform.cc_number) )
					||
					( errform.cc_type.selectedIndex > 0 && cclen <= 14)) ) {
						alert('Invalid card number.  Please use 15 or 16 digits, or choose PayPal.')
						errform.cc_number.focus()
						errform.cc_number.select()
						return false
					}
					if ( cc_type_str !='paypal' && (zip.length < 4 ) ) {
						alert('Invalid zip code.')
						errform.zip_code.focus()
						errform.zip_code.select()
						return false
					}
					if ( zip.length>0 && zip.length<4 && cclen >= 15 ) {
						zip=errform.zip_code.value;
						alert('Please give a valid ZIP code.')
						return false
					}
				}
			}
			return true
		}
		function submitFile(errform) {
			//if (errform.userfile[0].value.indexOf('.htm') > -1) {
				//alert('Yo!  No .htm files allowed.');
				//return false;
			//}
			return true
		}
		function checkNumber(num) {
			if (isNumber(num)) {
				alert('You must specify a number (click BROWSE for a pop-up menu).')
				return false
			}
			return true
		}
		function submitSnipe(errform) {

			free_snipes = 3;

			bid	= errform.bid.value
			entered_item_no	= trimAllSpaces(errform.item_no.value);
			snipes	= errform.snipes.value
			snipesRemaining = errform.snipesRemaining.value
			last4 = errform.last4_card_no.value
			isSubscriber = errform.isSubscriber.value

			if ( snipes == '3' && snipesRemaining == '0' )
			{
				if (confirm("You have completed your free trial.\n\nClick OK to extend your membership!")) {
					document.location = '/addfunds/';
					return false;
				}
				return false;
			}

			if ( (snipes > free_snipes) && snipesRemaining == '0' && isSubscriber == '0' )
			{
				if (confirm("You are out of snipes, or your membership expired.\n\nClick OK to extend your membership!")) {
					document.location = '/addfunds/';
					return false;
				}
				return false;
			}

			// enough bid?
			if ( bid > 50000 )
			{
				alert("Please contact customer support to enable your account for bids over $50,000.");
				return false;
			}

			if ( errform.ebay_info_ok.value == 0 ) {
					alert('CANNOT ENTER SNIPE.\n\nOne of three problems exist:\n1. You are not logged in.\n2. You have not yet given us your ebay info.\nClick OK to login.')
					// errform.item_no.focus()
					// errform.item_no.select()
					document.location = '/user';
					return false
			}
			if (entered_item_no < 100000000 || !isNumber(entered_item_no) || entered_item_no == '') {
					alert('The item number is incorrect.  Make sure there are no leading or trailing spaces.')
					errform.item_no.focus()
					errform.item_no.select()
					return false
			}
			if ( (!isNumber(bid) || bid == '') && errform.checkbid.value==1 ) {
					alert('No bid entered.  If you wish to track this item, just enter a "0".')
					errform.bid.focus()
					errform.bid.select()
					return false
			};
			return true;
		}
		function isNumber(thisValue) {
			thisValue=trimTrailingSpace(thisValue);
			if (thisValue == '') {
				return false
			}
			thisValueStr = ''+thisValue;
			for (i=0; i<thisValueStr.length; i++) {
				ch = thisValueStr.charAt(i)
				if ( (ch < '0' || ch > '9') && ch != '.' ) {
						return false
				}
			}
			return true
		}
		function trimTrailingSpace(str) {
			var str2='';
			for (i=0; i<str.length; i++) {
				ch = str.charAt(i);
				if (ch == ' ') {
					break;
				}
				str2=str2+ch;
			}
			return str2;
		}
		function trimAllSpaces(str) {
			var str2='';
			for (i=0; i<str.length; i++) {
				ch = str.charAt(i);
				if (ch != ' ') {
					str2=str2+ch;
				}
			}
			return str2;
		}
		function hasPlus(thisform) {
			if (thisform.query.value.indexOf('+', 0) > -1) {
					alert('Plus signs are unecessary (see search tips).')
					return false
			}
			if (thisform.query.value.indexOf(' AND ', 0) > -1 || thisform.query.value.indexOf(' and ', 0) > -1 ) {
					alert('The word AND may not be necessary (see search tips).')
					return true
			}
			//if (itemWin && !itemWin.closed) {
				//itemWin.close()
			//}
			return true
		}
		function hasSpace(thisItem) {
			if (thisItem.value.indexOf(' ', 0) > -1) {
					return true
			}
			return false
		}
		function hasMetaChars(thisItem) {
			//  _@- are ok
			invalidChars = ' !#$%^&*()=+{}[]\|;:\'"<>.,/?`~'
			if (thisItem.value == '') {
					return false
			}
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i)
				if (thisItem.value.indexOf(badChar, 0) > -1) {
						return true
				}
			}
			return false
		}
		function isBlank(item) {
			if (item.value == '') {
				return true
			}
			for (i=0; i<item.value.length; i++) {
				if (item.value.charAt(i) != ' ') {
					return false
				}
			}
			return true
		}
		function validCC(cardType, cc_number)
		{
			// var strCC = document.admoney.cardnumber.value;
			// var originalCCValue = document.admoney.hiddencardnumber.value;

			// var strCC = this.cc_number.value;
			// var cardType = this.cardtype[cardTypeIndex].value;

			// var cardTypeIndex = -1;
			// for (i = 0; i < document.admoney.cardtype.length; i++)
			// {
				// if (document.admoney.cardtype[i].checked)
				// {
					// cardTypeIndex = i;
				// }
			// }

			if (cc_number != '') {

				var cardLength = (cc_number + '~|').indexOf('~|', 0);

				if (cardLength > 0) {
					// var valid = isValidCC(cc_number);
					var valid = true;

					if (cardType == 'visa') {
						if (cc_number.substr(0, 1) != 4) {
							valid = false;
						}
						else if (cardLength != 13 && cardLength != 16) {
							valid = false;
						}
					}
					else if (cardType == 'mc') {
						var twoCCDigits = cc_number.substr(0, 2)

						if (twoCCDigits < 51 || twoCCDigits > 55)
						{
							valid = false;
						}
						else if (cardLength != 16)
						{
							valid = false;
						}
					}
					else if (cardType == 'amex') {
						var twoCCDigits = cc_number.substr(0, 2)

						if (twoCCDigits != 34 && twoCCDigits != 37) {
							valid = false;
						}
						else if (cardLength != 15) {
							valid = false;
						}
					}
				}
			}

			if (valid)
			{
				return true;
			}
			return false;
		}
			
		function validEmail(email) {
			invalidChars = ' /:,;'
			if (email == '') {
					return false
			}
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar, 0) > -1) {
						return false
				}
			}
			atPos = email.indexOf('@',1)
			if (atPos == -1) {
				return false
			}
			if (email.indexOf('@',atPos+1) > -1) {
				return false
			}
			periodPos = email.indexOf('.', atPos+1)
			if (periodPos == -1) {
				return false
			}
			if (periodPos+3 > email.length) {
				return false
			}
			return true
		}

	// this function gets the cookie, if it exists
	function Get_Cookie( name ) {
		var start = document.cookie.indexOf( name + "=" );
		var len = start + name.length + 1;
		if ( ( !start ) &&
		( name != document.cookie.substring( 0, name.length ) ) )
		{
		return null;
		}
		if ( start == -1 ) return null;
		var end = document.cookie.indexOf( ";", len );
		if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
	}

  // from http://www.safalra.com/programming/javascript/get-data/
  // e.g. GET_DATA['language'] 
  function initialiseGetData(){
    GET_DATA=new Array();
    var getDataString=new String(window.location);
    var questionMarkLocation=getDataString.search(/\?/);
    if (questionMarkLocation!=-1){
      getDataString=getDataString.substr(questionMarkLocation+1);
      var getDataArray=getDataString.split(/&/g);
      for (var i=0;i<getDataArray.length;i++){
        var nameValuePair=getDataArray[i].split(/=/);
        GET_DATA[unescape(nameValuePair[0])]=unescape(nameValuePair[1]);
      }
    }
  }

  function storeClick()
  {
    // personal click tracking pixel
  	v = GET_DATA['source'];
  	if (!v) { v = GET_DATA['src']; }

  	if (v) {
  		x = "<img width=1 height=1 src=/exec/pixel.php?source="+v;
 		if (GET_DATA['rr']) { x=x+'&rr='+GET_DATA['rr']; }
  		if (GET_DATA['b']) { x=x+"&b="+GET_DATA['b']; }
  		if (GET_DATA['k']) { x=x+"&k="+GET_DATA['k']; }
  		x = x+">";
  		// alert(x);
  		document.write(x);
  	}
  }

// end hide script from old browsers -->
