function getViewportSize()
{
    var viewport = new Array();

 	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
 	{
      	viewport[0] = window.innerWidth,
      	viewport[1] = window.innerHeight
 	}

	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 	else if (typeof document.documentElement != 'undefined'
    	&& typeof document.documentElement.clientWidth !=
    	'undefined' && document.documentElement.clientWidth != 0)
 	{
    	viewport[0] = document.documentElement.clientWidth,
    	viewport[1] = document.documentElement.clientHeight
 	}

 	// older versions of IE
 	else
 	{
    	viewport[0] = document.getElementsByTagName('body')[0].clientWidth,
    	viewport[1] = document.getElementsByTagName('body')[0].clientHeight
 	}
 	return viewport;
}

/**
	* Map dragging stuff
	*/
	var objDrag = new Object();
	objDrag.zIndex = 0;

	function Browser()
	{
		var ua, s, i;

		this.isIE = false;
		this.isNS = false;
		this.version = null;

		ua = navigator.userAgent;

		s = "MSIE";
		if((i = ua.indexOf(s)) >= 0){
			this.isIE = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}

		s = "Netscape6/";
		if((i = ua.indexOf(s)) >= 0){
			this.isNS = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}

		s = "Gecko";
		if((i = ua.indexOf(s)) >= 0){
			this.isNS = true;
			this.version = 6.1;
			return;
		}
	}

	var browser = new Browser();

	function dragStart(event, id)
	{
		var el;
		var x, y;

		if(id){
			objDrag.elNode = document.getElementById(id);
		} else {
            if (browser.isIE)
      			objDrag.elNode = window.event.srcElement;
    		if (browser.isNS)
      			objDrag.elNode = event.target;

    		// If this is a text node, use its parent element.

    		if (objDrag.elNode.nodeType == 3)
      			objDrag.elNode = objDrag.elNode.parentNode;
		}

		// Get cursor position
        if (browser.isIE) {
    		x = window.event.clientX + document.documentElement.scrollLeft
      			+ document.body.scrollLeft;
    		y = window.event.clientY + document.documentElement.scrollTop
      			+ document.body.scrollTop;
  		}
  		if (browser.isNS) {
    		x = event.clientX + window.scrollX;
    		y = event.clientY + window.scrollY;
  		}


		objDrag.cursorStartX = x;
		objDrag.cursorStartY = y;
		objDrag.elStartLeft = parseInt(objDrag.elNode.style.left, 10);
		objDrag.elStartTop = parseInt(objDrag.elNode.style.top, 10);

		if(isNaN(objDrag.elStartLeft)) objDrag.elStartLeft = 0;
		if(isNaN(objDrag.elStartTop)) objDrag.elStartTop = 0;

		objDrag.elNode.style.zIndex = ++objDrag.zIndex;

        if (browser.isIE) {
    		document.attachEvent("onmousemove", dragGo);
    		document.attachEvent("onmouseup",   dragStop);
    		window.event.cancelBubble = true;
    		window.event.returnValue = false;
  		}
  		if (browser.isNS) {
    		document.addEventListener("mousemove", dragGo,   true);
    		document.addEventListener("mouseup",   dragStop, true);
    		event.preventDefault();
  		}
	}

	function dragGo(event)
	{
		var x, y;

        if (browser.isIE) {
    		x = window.event.clientX + document.documentElement.scrollLeft
      			+ document.body.scrollLeft;
    		y = window.event.clientY + document.documentElement.scrollTop
      			+ document.body.scrollTop;
  		}
  		if (browser.isNS) {
    		x = event.clientX + window.scrollX;
    		y = event.clientY + window.scrollY;
  		}

		objDrag.elNode.style.left =
			(objDrag.elStartLeft + x - objDrag.cursorStartX) + "px";
		objDrag.elNode.style.top =
			(objDrag.elStartTop + y - objDrag.cursorStartY) + "px";

        if (browser.isIE) {
    		window.event.cancelBubble = true;
    		window.event.returnValue = false;
  		}
  		if (browser.isNS){
    		event.preventDefault();
		}
	}

	function dragStop(event)
	{
        if (browser.isIE) {
    		document.detachEvent("onmousemove", dragGo);
    		document.detachEvent("onmouseup",   dragStop);
  		}
  		if (browser.isNS) {
    		document.removeEventListener("mousemove", dragGo,   true);
    		document.removeEventListener("mouseup",   dragStop, true);
  		}
	}

function showDiv(id)
{
	var div = document.getElementById(id);
	div.style.display = "block";
}

function hideDiv(id)
{
	var div = document.getElementById(id);
	div.style.display = 'none';
}

function swapMainImage($path)
	{
		var main = document.getElementById('property_main');
		main.src = $path;
	}

function showFull(id)
{
	var div = document.getElementById(id);
	div.style.display = "block";
}

function hideFull(id)
{
    var div = document.getElementById(id);
	div.style.display = "none";
}

function submitForm(id)
{
	var form = document.getElementById(id);
	form.submit();
}

function confirmCancel()
{
	if(confirm("If you cancel now you will lose the data that you have input so far. \r\n\r\nAre you sure you want to Cancel? \r\nClick OK to confirm."))
		return true;
	else
		return false;
}

function confirmPropertyDelete()
{
	if(confirm("Are you sure you want to delete the selected properties? \r\n This action is not reversible. \r\n\r\nClick OK to confirm."))
		return true;
	else
		return false;
}

function confirmSectionDelete()
{
	if(confirm("Are you sure you want to delete the selected section? \r\n This action is not reversible. \r\n\r\nClick OK to confirm."))
		return true;
	else
		return false;
}

function confirmImageDelete()
{
	if(confirm("Are you sure you want to delete the selected images? \r\n This action is not reversible. \r\n\r\nClick OK to confirm."))
		return true;
	else
		return false;
}