<!--
///////////////////////////
// browser detect functions
///////////////////////////

// get browser type
var isNS4;
var isNS6;
var isIE4;
var isIE5;
var strPlatform;
scrOfX = 0, scrOfY = 0;

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

Browser = navigator.appName
Net = Browser.indexOf("Netscape")
Micro = Browser.indexOf("Microsoft")
Netscape = false
IE = false

if(Net >= 0)
{
	Netscape = true
}

if(Micro >= 0)
{
	IE = true
}

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

strPlatform = navigator.platform;

function ValidObject(Object) 
{
	if(Object == null)
	{
		return false;
	}
	
	if(typeof(Object) == "undefined") 
	{
		return false;
	}
	
	return true;
}

// function to return handle to form element
function GetObject(name, this_form)
{
	strHandle = '';

	strHandle = eval("document." + this_form + "." + name);
	return strHandle;

	if(ValidObject(eval("document." + this_form + ".elements['" + name + "']")))
	{
		//alert(\'name = \' + name + \'\n form name = \' + this_form);
		strHandle = eval("document." + this_form + ".elements['" + name + "']");
		//alert(\'handle = \' + strHandle);		
	}

	return strHandle;
}

// popup window function
function Popup(url, width, height, options)
{
	if(!width) width = 400;
	if(!height) heigth = 600;
	if(!options) options = 'scrollbars=yes,status=no';

	myFloater = window.open('', 'Information', options + ',width=' + width + ',height=' + height);
    myFloater.location.href = url;
}

// function to write to a div or layer tag as appropriate to browser
function DoLayer(id, text)
{
// refer to field by method appropriate to the browser
	if (isIE4)
	{
		document.all[id].innerHTML = text;
	}
	else if (isNS4) 
	{
		id = id + '_layer';
		document.layers[id].document.open();
		document.layers[id].document.write(text);
		document.layers[id].document.close();
	}
	else if (isNS6 || isIE5)
	{
		document.getElementById(id).innerHTML = text;
	}
}

function Disable(name, form_name)
{
	handle = GetObject(name, form_name);
	handle.disabled = true;
}

function Enable(name, form_name)
{
	handle = GetObject(name, form_name);
	handle.disabled = false;
}

function Clear(name, form_name)
{
	handle = GetObject(name, form_name);
	handle.value = '';
}

iRefreshLimit = 0;
if(ValidObject(document.SmsConsole) == true)
{
	iRefreshLimit = (document.SmsConsole.iRefresh.value * 10);
}

t = null;
refreshtime = 100 *  iRefreshLimit;
function RefreshMe()
{
	t = setTimeout("SmsConsole.submit()", refreshtime);
}

var xPos;
var yPos;

function XYpos(e) {

	if (IE == true) {
		xPos = event.screenX
		yPos = event.screenY
	}
	else{
		xPos = e.clientX;
		yPos = e.clientY;
	}
}

function getMouseXY(e) {
  e = e || window.event

  if (IE) { // grab the x-y pos.s if browser is IE
	//xPos = event.clientX + document.body.scrollLeft
	//yPos = event.clientY + document.body.scrollTop
  
    xPos = event.clientX + document.documentElement.scrollLeft;
    yPos = event.clientY + document.documentElement.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    xPos = e.pageX
    yPos = e.pageY
  }  
  // catch possible negative values in NS4
  if (xPos < 0){xPos = 0}
  if (yPos < 0){yPos = 0}  
  return true
}


function changeActionDiv(content, visibleStatus, leftPos, topPos, visible)
{
	handle = document.getElementById("actionDiv");
	handle.innerHTML = content;
	handle.style.visibility = visibleStatus;
	handle.style.top = topPos;
	handle.style.left = leftPos;

	if(visible)
	{
		handle = document.getElementById(visible);
		
		if(handle)
		{
			handle.style.visibility = "visible";
		}
	}
}


function hideActionDiv()
{
	handle = document.getElementById("actionDiv");
	handle.style.visibility = "hidden";
}

function createRequest()
{
	try
	{
		request = new XMLHttpRequest();
	}
	catch (trymicrosoft)
	{
		try
		{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (othermicrosoft)
		{
			try
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (failed)
			{
				request = null;
			}
		}
	}

	if(request == null)
	{
		alert("Error creating request object");
	}

	return request;
}

function createMultiRequest()
{
	try
	{
		request = new XMLHttpRequest();
	}
	catch (trymicrosoft)
	{
		try
		{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (othermicrosoft)
		{
			try
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (failed)
			{
				request = null;
			}
		}
	}

	if(request == null)
	{
		alert("Error creating request object");
	}

	return request;
}

function replaceText(el, text) {
  if (el != null) {
    clearText(el);
    var newNode = document.createTextNode(text);
    el.appendChild(newNode);
  }
}

function clearText(el) {
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        el.removeChild(childNode);
      }
    }
  }
}

function getText(el)
{
	var text = "";
	if(el != null)
	{
		if(el.childNodes) 
		{
			for(var i = 0; i < el.childNodes.length; i++)
			{
				var childNode = el.childNodes[i];
				if(childNode.nodeValue != null) 
				{
					text = text + childNode.nodeValue;
				}
			}
        }
      
    }

	return text;
}

fadeLayer_Show = function() {

	handle = document.getElementById("fadeLayer");

	scrollXY();

	var iWidth	= document.body.clientWidth + scrOfX;
	var iHeight = document.body.clientHeight + scrOfY;

	handle.style.visibility			= 'visible';
	handle.style.position			= 'absolute';
	handle.style.left				= 0 + 'px'; 
	handle.style.top				= 0 + 'px'; 
	handle.style.width				= iWidth + 'px';
	handle.style.height				= iHeight + 'px';
	handle.style.backgroundColor	= '#000000';
	handle.style.zIndex				= '9';
}

fadeLayer_Hide = function() {
	
	handle = document.getElementById("fadeLayer");
	
	handle.style.visibility			= 'hidden';
	handle.style.position			= 'absolute';
	handle.style.left				= 0 + 'px'; 
	handle.style.top				= 0 + 'px'; 
	handle.style.width				= 0 + 'px'; 
	handle.style.height				= 0 + 'px';
	handle.style.backgroundColor	= '';
	handle.style.zIndex				= '';
}

scrollXY = function() {
	
	scrOfY = 0;
	scrOfX = 0;
	// Firefox.
	if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {

		scrOfY = document.body.scrollTop;
	    scrOfX = document.body.scrollLeft;
	}

	// IE6.
	else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {

		scrOfY = document.documentElement.scrollTop;
	    scrOfX = document.documentElement.scrollLeft;
	}
}

function Loading()
{
	var strContent = '<div align="center"><br /><br /><br /><br /><img src="images/hourglass_large.jpg" alt=""><br /><br /><span class="crmBlunt">Loading...</span></div>';

	return strContent;
}

function number_format( number, decimals, dec_point, thousands_sep )
{                                      
 	var n = number, prec = decimals;
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
    var dec = (typeof dec_point == "undefined") ? '.' : dec_point;
                                                                                                 
    var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
                                                                                                                         
    var abs = Math.abs(n).toFixed(prec);
    var _, i;
                                                                                                                    
    if (abs >= 1000) {
		 _ = abs.split(/\D/);
		i = _[0].length % 3 || 3;
																																							  
		 _[0] = s.slice(0,i + (n < 0)) +
		 _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
		
		s = _.join(dec);
    } else {
    	s = s.replace('.', dec);
    }
                                                                                                                                                                                      
    return s;
}

function showMsg(sMsg, Title, xPos, yPos, iWidth)
{
	if(!ValidObject(xPos))
	{
		xPos = '200';
	}

	if(!ValidObject(yPos))
	{
		yPos = '200';
	}

	if (!ValidObject(Title))
	{
		Title = 'Confirmation';
	}

	strContent	= '<span class="frontText">' + (sMsg != '' ? sMsg : 'Account successfully updated') + '</span>'

	strText = '<table cellpadding="4" cellspacing="0" width="' + (iWidth || '200') + '" border="0" class="blackBorder" bgcolor="white"><tr><td width="35" valign="top" align="left" class="dataHeader"><span class="frontBold">' + Title + '</span></td></tr><tr><td>' + strContent + '</td></tr><tr><td align="left"><a href="javascript:changeActionDiv(\'\', \'hidden\', (xPos - 188), (yPos - 60))" onMouseover="window.status=\'Done\'; return true;"><img src="images/buttons/close_layer_white.gif" border="0"></a></td></tr></table>';

	return changeActionDiv(strText, 'visible', xPos + 'px', yPos + 'px');
}


function SetCampaign(mode)
{
    handle = GetObject('iCampaign', 'create');
    handle.value = mode;
}

SetCampaignType = function(type)
{
    handle = GetObject('strCampaignType', 'create');
    handle.value = type;
}

RedirectToEditor = function()
{
    document.create.action = 'create.x?iTask_ID=43';
    document.create.submit();
}

function addWindowOnload(func)
{
	if(typeof(window.onload) === 'function')
	{
		var prevOnload = window.onload;
		window.onload = function(){ prevOnload(); func(); }
	}
	else
	{
		window.onload = func;
	}
}
-->

