﻿document.write("<script src='http://mlsr.realtylink.org/mlsrcommon/scripts.js' type='text/javascript'></script>");
document.write("<script src='http://mlsr.realtylink.org/mlsrcommon/comscripts.js' type='text/javascript'></script>");

window.addEvent('domready', function(){
	//-vertical

	var mySlide = new Fx.Slide('relocationMiniForm').hide();
	
	$('toggle').addEvent('click', function(e){
		e = new Event(e);
		mySlide.toggle();
		e.stop();
	});
	
	$('slideout').addEvent('click', function(e){
		e = new Event(e);
		mySlide.slideOut();
		e.stop();
	});
	
});


var xmlhttp


function reloFormSubmit()
{
    xmlhttp=GetXmlHttpObject();
    
      
      
   
      
      var serviceType=getCheckedValue(document.relocationMiniForm.serviceType);
      var name=document.relocationMiniForm.fullname.value;
      var area=document.relocationMiniForm.cityOrArea.value;
      var neighbourhood=document.relocationMiniForm.neighbourhood.value;
      var phone=document.relocationMiniForm.phone.value;
      var email=document.relocationMiniForm.email.value;
      
      
      var url="aspscript/relocationMiniForm.aspx";
      url=url+"?name="+name+"&area="+area+neighbourhood+"&neighbourhood="+neighbourhood+"&phone="+phone+"&email="+email+"&serviceType="+serviceType;
    
    if (xmlhttp==null)
      {
         //alert ("Your browser does not support AJAX!");
         window.location=url;
         return;
      }  
      
    
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function stateChanged()
{
    if (xmlhttp.readyState==0)
    {
        document.getElementById("relocationMiniForm").innerHTML="<h2>Your Request is sending, please wait....</h2>";
    }
    
     if (xmlhttp.readyState==2)
    {
        document.getElementById("relocationMiniForm").innerHTML="<h2>Your Request is loading, please wait....</h2>";
    }
    
     if (xmlhttp.readyState==3)
    {
        document.getElementById("relocationMiniForm").innerHTML="<h2>Your Request is being processed, please wait....</h2>";
    } 
    
    if (xmlhttp.readyState==2)
    {
        document.getElementById("relocationMiniForm").innerHTML="<h2>Your Request is being completed, please wait....</h2>";
    }
    
    
    if (xmlhttp.readyState==4)
    {
        document.getElementById("relocationMiniForm").innerHTML="<h2>"+xmlhttp.responseText+"</h2>";
    }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}



function CheckRegion()
{
var n = document.propSearch.Region.options[document.propSearch.Region.selectedIndex].value;
var newWindow;
var Rurl="";
	switch (n)
		{
			case 'Kelowna':
				newWindow=window.open('http://www.macrealtykelowna.com');
				Rurl='http://www.macrealtykelowna.com';
				break;
			case 'Vernon':
				newWindow=window.open('http://www.macrealtyvernon.com/index.asp');
				Rurl='http://www.macrealtyvernon.com/index.asp';
				break;
			case 'Osoyoos':
				newWindow=window.open('http://www.osoyoosrealestate.com/listings.php')
				Rurl='http://www.osoyoosrealestate.com/listings.php';
				break;
			case 'Nanaimo':
				newWindow=window.open('http://www.macrealtynanaimo.com/Listings.htm')
				Rurl='http://www.macrealtynanaimo.com/Listings.htm';
				break;
			case 'Edmonton':
				newWindow=window.open('http://www.macrealtyedmonton.com/listing/search')
				Rurl='http://www.macrealtyedmonton.com/listing/search';
				break;
			case 'Edmonton East':
				newWindow=window.open('http://www.macdonaldrealtyedmonton.com/listings?pathway=5')
				Rurl='http://www.macdonaldrealtyedmonton.com/listings?pathway=5';
				break;
			case 'Victoria':
				window.open('http://www.macrealty.com/properties/victoriaListings.htm')
				Rurl='http://www.macrealty.com/properties/victoriaListings.htm';
				break;
				
				
		}
		
		if (!newWindow || !newWindow.top)
		{
			//document.write("windows has been blocked");
			if (Rurl!="")
			{
				window.location = Rurl;
			}
		}

}

function resubmit()
{
	var n = document.propSearch.Region.options[document.propSearch.Region.selectedIndex].value;
	/*check the region to redirect the page*/
	if (isNaN(n))
		CheckRegion();
	else
		document.propSearch.submit();	// submit the form
}

function newspopup(url) 
{

  var oWin = window.open(url,'popwin','height=140px,width=190px,toolbar=no,resizable=yes,scrollbars=yes');
   if (oWin==null || typeof(oWin)=="undefined")
       window.location=url;
   else
       oWin;
 }
 
 function submissionform_popup(url) 
{

  var oWin = window.open(url,'popwin','height=680px,width=900px,toolbar=no,resizable=yes,scrollbars=yes');
   if (oWin==null || typeof(oWin)=="undefined")
       window.location=url;
   else
       oWin;
 }
 

	 	

 

 