
function ShowResults(b,s,o,q,p){
	//window.alert('1');
	//alert(b+'/Results/'+p+'/'+q+'|SR='+s+'|OR='+o+'/');
	window.location=b+'/Results/'+p+'/'+q+'|SR='+s+'|OR='+o+'/';
}

function swap(target, fname) {
	document[target].src = fname;
}

/// verify required fields
function CheckRequired(form) {
	var pass = true;
	for(i = 0; i < form.length; i++) {
		var tempobj = form.elements[i];
		if(tempobj.alt == "required") {
			if(tempobj.value == '') {
				pass = false;
				break;
			}
		}
	}
	if(!pass) {
		alert("Please enter all required information.");
		tempobj.focus(); // set focus to missing field
		return false;
	}
	else { return true; } 
}

/// confirm listing of account
function VerifyListingRemoval(BASE_URL,car_id) {
	msg = "Are you sure you want to remove this listing?\n\nNote: All photos and other information related to this listing will be deleted also.";
	if(confirm(msg)) {
		window.location=BASE_URL+'/Delete/'+car_id+'/';
	} else {
		return false;
	}
}



function verify_car_remove(BASE_URL,car_id) {
	msg = "Are you sure you want to remove this listing?\n\nNote: All photos and other information related to this listing will be deleted also.";
	if(confirm(msg)) {
		window.location=BASE_URL+'/cp/remove_car.php?sid='+car_id;
	} else {
		return false;
	}
}


/// confirm removal of account
function verify_user_remove(BASE_URL,Mid) {
	msg = "Are you sure you want to remove this acccount?\n\nNote: All listings and other information related to this account will be deleted too.";
	if(confirm(msg)) {
		window.location=BASE_URL+'/cp/remove_user.php?sid='+Mid;
	} else {
		return false;
	}
}



function verify_entry(ccode,table) {
	msg = "Are you sure you want to remove this entry?";
	if(confirm(msg)) {
		window.location='remove_entry.php?ccode='+ccode+'&table='+table;
	} else {
		return false;
	}
}



/// popup
function ShowPopup(Width,Height,Path,WinName){
	var xMax = screen.width, yMax = screen.height;
    Top = (yMax - Height)/2 - 40;
    Left = (xMax - Width)/2;        
    var windowName = WinName;    
    var features =
    'width='        + Width +
    ',height='      + Height +
    ',directories=' + 0 +
    ',location='    + 0 +
    ',menubar='     + 0 +
    ',scrollbars='  + 1 +
    ',status='      + 0 +
    ',toolbar='     + 0 +
    ',resizable='   + 0 +
    ',top='     + Top +
    ',left='     + Left;
    window.open(Path, windowName, features);
}


var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
  }

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
  return null;
  }

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    "; path=/" +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  }
