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];}
}

//forms

function collapseElem(obj) {
	var el = document.getElementById(obj);
	el.style.display = 'none';
}

function expandElem(obj) {
	var el = document.getElementById(obj);
	el.style.display = '';
}

function collapseAll() {
  var numFormPages = 1;

  for(i=2; i <= numFormPages; i++) {
  	currPageId = ('mainForm_' + i);
  	collapseElem(currPageId);
  }
}

function copyAddress() {
	document.rentspot.cust_address.value=document.rentspot.spot_address.value;	
	document.rentspot.cust_unit.value=document.rentspot.spot_unit.value;	
	document.rentspot.cust_city.value=document.rentspot.spot_city.value;	
	document.rentspot.cust_postal.value=document.rentspot.spot_postal.value;
	document.rentspot.cust_prov.selectedIndex=document.rentspot.spot_province.selectedIndex;
    document.rentspot.cust_country.selectedIndex=document.rentspot.spot_country.selectedIndex;
}

function mergeAddressRedirect(address,city,postcode, prov, country)
{

  var query = "";
  var data = "";

  if (address=='e.g., 1700 Yonge Street') address='';
  if (city=='e.g., Toronto') city='';
  if (postcode=='e.g., M6M 1M7') postcode='';
  
  data = address + "," + city + "," + postcode;
  
  if (address == "")
  {
	  if(city == "")	 
	  {
			if(postcode == "") alert('Please enter your search terms.');
  			else query = postcode + "," + country;	
	   }
	  else
	  {
			if(postcode == "") query = city + "," + prov + "," + country;	  
  			else query = postcode +  "," + country;	  
	  }
  }
  else
  {
	  if(city == "")	 
	  {
			if(postcode == "") alert('Please enter city and/or postal/zip code.');
  			else query = postcode + ","  + country;	
	   }
	  else
	  {
			if(postcode == "") query = address + "," + city + "," + prov + "," + country;	  
  			else query = postcode + "," + country;	  
	  }  
  }

   if(query != "") window.location='find_spot1.php?i='+query+'&d='+data;
}

function popDetails(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=400,left = 395,top = 250');");
}
function checkTerms(fldname) 
{
	var start = document.getElementById("spot_avail_from").value;	
	var end = document.getElementById("spot_avail_end").value;	
	if (start=="") 
	{
        alert ("Sorry, please specify Available From Date.");
        return false;
    }
	if (end=="") 
	{
        alert ("Sorry, if you don not specify Available Until Date, please click on 'Click here to specify no end date'");
        return false;
    }
    var elem = document.getElementById(fldname);
    if (elem.checked==false) 
	{
        alert ("Sorry, please review and agree to the parkingspots.com\nPrivacy Policy and Terms and Conditions.");
        return false;
    }
	
	return true;
}
function typeChange(ind, country)
{
	if(ind == 2)
	{
		var answer = confirm("Commercial Spot Owners will be charged the equivalent of\none months rent upon completion of a match\n             please click OK to continue ");	
		if(!answer)	window.location.href = "find_spot1.php?c="+country;
		else	return false; 
	}
	else if(ind == 4)
	{
		var answer = confirm("Business Lot Owners will be charged the equivalent of\none months rent upon completion of a match\n             please click OK to continue ");	
		if(!answer)	window.location.href = "find_spot1.php?c="+country;
		else	return false; 
	}
	else return false;
}
function numChange(ind, country)
{
	if(ind >= 1)
	{
		var answer = confirm("Spot Owners that have more then one spot will be charged the\nequivalent of one months rent upon completion of a match\n             please click OK to continue ");	
		if(!answer)	window.location.href = "find_spot1.php?c="+country;
		else	
		{
			var typeSel = document.getElementById("spot_type");
			typeSel.selectedIndex = 2;
			return false; 
		}
	}
	else return false;
}

