﻿/**************************\
*                          *
*  Core Script Functions   *
* Choice Homes Public Site *
*                          *
*       Version 1.0        *
*                          *
\**************************/

var popWindow = null;
var strPopChrome = "channelmode=0, height=600, left=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0, top=0, width=800"

function DisplayPublicImage(strDisplayObjID, strNewSrc)
{
	document.getElementById(strDisplayObjID).src = "/UploadPublic/" + strNewSrc;
}

function JumpBack()
{
	window.history.go(-1);
}

function SetHeightToAvailable(reduceByThis)
{
	var myHeight = 0;

	if( typeof( window.innerHeight ) == 'number' )
	{
    	//Non-IE
		myHeight = window.innerHeight;
  	}
	else if( document.documentElement && document.documentElement.scrollHeight )
	{
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.scrollHeight;
	}
	else if( document.body && document.body.clientHeight )
	{
 		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}

	myHeight = myHeight - reduceByThis;
	
	if( myHeight < 0 )
	{
		myHeight = 0;
	}

	return myHeight;
}

function SetWidthToAvailable(reduceByThis)
{
	var myWidth = 0;

	if( typeof( window.innerWidth ) == 'number' )
	{
    	//Non-IE
		myWidth = window.innerWidth;
  	}
	else if( document.documentElement && document.documentElement.scrollWidth )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.scrollWidth;
	}
	else if( document.body && document.body.clientWidth )
	{
 		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}

	myWidth = myWidth - reduceByThis;
	
	if( myWidth < 0 )
	{
		myWidth = 0;
	}

	return myWidth;
}

function ShowAllotments(GIDFile, PDFFile)
{
	var popURL;

	if( popWindow != null )
	{
		
		if( popWindow.open )
		{
			popWindow.close();
		}
		popWindow = null;
	}
	
	popURL = "EstateLots.aspx?GID=" + String(GIDFile) + "&OUT=" + PDFFile;

	popWindow = window.open(popURL, "_blank", strPopChrome, true);
}

function StartDownload(URLFileName)
{
	var popURL;

	if( popWindow != null )
	{
		
		if( popWindow.open )
		{
			popWindow.close();
		}
		popWindow = null;
	}
	
	popURL = "/UploadPublic/" + String(URLFileName);
	popWindow = window.open(popURL, "_blank", strPopChrome, true);
}

function OpenOffSite(a) {
  window.open(a.href, "OffSite", "directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes").focus();
  return false;
}
