// *************************************************************
// *************************************************************
// commonly used js functions
// --------------------------
// findPosX
// findPosY
// GetHtmlElementByID
// OpenDialerWindow
// *************************************************************
// *************************************************************

/* 

	Comments to fool ISA Server.

	fooling you
	
	
	fooling you
	
	
	fooling you


*/


// *************************************************************
// http://blog.firetree.net/2005/07/04/javascript-find-position/
// helper methods for getting x and y coordinates
function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	{
		while(1) 
		{
			curleft += obj.offsetLeft;
			if(!obj.offsetParent)
			{
				break;
			}
			obj = obj.offsetParent;
		}
	}
	else if(obj.x)
	{
		curleft += obj.x;
	}
	
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	{
		while(1)
		{
			curtop += obj.offsetTop;
			if(!obj.offsetParent)
			{
				break;
			}
			obj = obj.offsetParent;
		}
	}
	else if(obj.y)
	{
		curtop += obj.y;
	}
	
	return curtop;
}

// *******************************************************
// *******************************************************
// originally getElement from http://tech.hostforadollar.com/index.php?op=articulos&task=verart&aid=12	
function GetHtmlElementByID( psID ) 
{ 
	if(document.all) 
	{ 
		return document.all[psID]; 
	} 
	else if(document.getElementById) 
	{ 
		return document.getElementById(psID); 
	} 
	else 
	{ 
		for (iLayer = 1; iLayer < document.layers.length; iLayer++) 
		{ 
			if(document.layers[iLayer].id == psID) 
			{
				return document.layers[iLayer]; 
			}
		}
	}        

	return null; // was return Null?
} 

// *******************************************************
// *******************************************************
// open the dialer window
// global var, strange naming avoids any possible conflicts
var talkeeVar___is800x600 = true;
var conf_window;
function OpenDialerWindow()
{
	InitializeScreenResolution();
	var width = GetDialerWindowWidth();
	var height = GetDialerWindowHeight();
	
	var settings = "width=" + width + 
					",height=" + height + 
					",status=yes," +
					"resizable=yes," +
					"scrollbars=yes";
	
 conf_window = window.open("DialerWindow.aspx", "MASipPhone", settings);
	conf_window.opener = top;
	conf_window.focus();	
}

function GetDialerWindowWidth()
{
	if(talkeeVar___is800x600)
	{
		return 780;
	}
	else
	{
		//return 940; // we can go this big if we want
		return 895;
	}
}

function GetDialerWindowHeight()
{
	if(talkeeVar___is800x600)
	{
		return 480;
	}
	else
	{
		return 690;
	}
}

function InitializeScreenResolution()
{
	//http://www.pageresource.com/jscript/jscreen.htm	
	if((screen.width >= 1024) && (screen.height >= 768))
	{
		talkeeVar___is800x600 = false;
	}
	else
	{
		talkeeVar___is800x600 = true;
	}
	
}