
/*function createoverlayBack()
{
	if(!document.getElementById('overlayBack'))
	{
		var objBody = document.getElementsByTagName("body").item(0);

		var objoverlayBack = document.createElement("div");
		objoverlayBack.setAttribute('id','overlayBack');
		objoverlayBack.style.display = 'none';
		objoverlayBack.onclick = function() { displayContact(); return false; }
		objBody.appendChild(objoverlayBack);
	}
}


function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}*/
var contact = "";
var path="http://shared.remax.com.au/images/contact_agent/loader.gif";
function loadForm (propid,webref,userid, url, address)
{
	contact = new MaJiG_BOX("<center><img src='"+path+"'></center>");
	//displayContact();
	//var arrayPageSize = getPageSize();
//	alert('loading.... '+url);

	new Ajax.Request("/",
    	{
		onSuccess : function(response, json)
		{
//			alert('success');
		    contact._set_Content(response.responseText);
		    $('title').style.display = 'block';
			//$('contactForm').innerHTML  = response.responseText;
		},
		onFailure : function(response)
		{
		    alert('Error loading contact page');
		},
		parameters : "userID="+userid+"&webref="+webref+"&propid="+propid+"&loadForm=yes&content=main&page=contact_agent&address="+address
	}
    );
}


function  submitForm(propid,webref,userid,url,sendSMS)
{
	var params = Form.serialize($('contact_agent_form'));
	new Ajax.Request('/',
	{
		onSuccess:function(response, json)
		{
			//$('contactForm').innerHTML = response.responseText;
			contact._set_Content( response.responseText);
			$('title').style.display = 'block';
		},
		onFailure : function(response)
		{
			alert('failed. URL = '+url);
		},
		method: 'post',
		parameters : "page=contact_agent&userID="+userid+"&webref="+webref+"&propid="+propid+"&sendSMS="+sendSMS+"&loadForm=yes&content=main&send_msg=yes&"+params

	}
	);
}


/*function displayContact()
{
	var arrayPageSize   = getPageSize();
	var arrayPageScroll = getPageScroll();
	if($('contactForm').visible())
	{
		Effect.Fade($('contactForm'),{duration:1})
		$('overlayBack').style.display = 'none';
		showSelectBoxes();
	}
	else
	{
		createoverlayBack();
		hideSelectBoxes();
		//determine position of window
		$('contactForm').style.top = (arrayPageScroll[1] + (arrayPageSize[3] / 15)) + "px";
		$('contactForm').style.left = (arrayPageSize[2] / 4) + "px";
		Effect.Appear($('contactForm'),{queue: 'end', scope: 'togglebar', duration:1})
		$('overlayBack').style.height = (arrayPageSize[1]) + "px";
		$('overlayBack').style.display = 'block';
	}
}*/

