// vc_id = "$Id: CommonFunctions.js 12312 2009-01-05 23:42:20Z robert $"
// JavaScript Document
// General Library of Scripts
var ie = (document.all != null);

function doNothing() { 
	var get=0; 
}

function checkSub(){
	return(confirm("Are you sure? Click OK to continue or CANCEL to go back."))
}

function checkSubCustom(msg){
	return(confirm(msg))
}

// These are for the favorites multiple delete...not so common.
// Because of a nested form for this page to save comments...the loop is abnormal.
function favcheckAll(nof,noomf) {
	var curObj = '';
	for (i = 1; i <= nof; i++) {
		curObj = document.getElementById('fav' + i);
		curObj.checked = 1;
	}
	for (i = 1; i <= noomf; i++) {
		curObj = document.getElementById('favOffMarket' + i);
		curObj.checked = 1;
	}
}

function favunCheckAll(nof,noomf) {
	var curObj = '';
	for (i = 1; i <= nof; i++) {
		curObj = document.getElementById('fav' + i);
		curObj.checked = 0;
	}
	for (i = 1; i <= noomf; i++) {
		curObj = document.getElementById('favOffMarket' + i);
		curObj.checked = 0;
	}
}

function favsendToDelete(nof,noomf) {
	
	if (checkSubCustom('You are about to delete a batch of your favorites.')) {
	
		var curObj = '';
		var qString = '';
		
		if (nof > 100) {
			noomf = 100;
		}
		
		for (i = 1; i <= nof; i++) {
			curObj = document.getElementById('fav' + i);
			if (curObj.checked) {
				qString += curObj.value + ',';	
			}
		}
		
		if (noomf > 100) {
			noomf = 100;
		}
		
		for (i = 1; i <= noomf; i++) {
			curObj = document.getElementById('favOffMarket' + i);
			if (curObj.checked) {
				qString += curObj.value + ',';	
			}
		}
		//strip last comma off of qString
		qString = qString.substr(0, qString.length - 1);
		
		if (qString != '') {
			window.location = 'index.cfm?fuseaction=account.actDeleteFavorite&listingID=' + qString;
		} else {
			alert ('Sorry, you have not checked any listings to delete.  Please select 1 or more listings.');	
		}
	
	}
	
}
// END favorites