function popup(href,width,height,scroll)
	{
	CMSPopup = window.open(href,'CMSPopup','resizable=no,toolbar=no,left=200,top=200,status=no,location=no,height=' + height + ',width=' + width + ',scrollbars=' + scroll);
	};
	
function isEmail(str)
	{
	// are regular expressions supported?
	var supported = 0;
	if (window.RegExp)
		{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr))
			{
			var supported = 1;
			}
		}
	if (supported == 1)
		{
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(str) && r2.test(str));
		}
	else
		{
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0) && (str.indexOf("@") < 2);
		}
	};

function checkRadio(formfield)
	{
	var i;
	for (i=0;i < formfield.length; ++i)
		{
		if (formfield[i].checked)
			{ 
			return formfield[i].value;
			}
		}
	return (false);
	};
	
function radioCheck(theField,theForm)
	{
	var i;
	formfield = eval(theForm.name + '.' + theField);
	for (i=0;i < formfield.length; ++i)
		{
		if (formfield[i].checked)
			{ 
			return formfield[i].value;
			}
		}
	return (false);
	};
	
function roundOff(value, precision)
	{
        value = "" + value //convert value to string
        precision = parseInt(precision);

        var whole = "" + Math.round(value * Math.pow(10, precision));

        var decPoint = whole.length - precision;

        if(decPoint != 0)
        {
                result = whole.substring(0, decPoint);
                result += ".";
                result += whole.substring(decPoint, whole.length);
        }
        else
        {
                result = whole;
        }
        return result;
	};

function SetCFCookie (name, value)
	{
	var name = name.toUpperCase();
	var path = "/";
	document.cookie = name + "=" + escape (value) +"; path=" + path + ";";
	};
	
function GetCFCookie(name)
	{ 
	var cname = name.toUpperCase() + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length; 
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			} 
		}
	return bl; 
	};
	
function GetCookie(name)
	{ 
	var cname = name + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length; 
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			} 
		}
	return bl; 
	}

// Find and replace characters within a string
function Switch(item,OldChar,NewChar)
	{
	var _ONE=0;
	var _ret="";
	var _flag=0;
	var _item=item.split("");
	for(var i=0;i<_item.length;i++)
		{
		if(!_flag&&_item[i]==OldChar)
			{
			_item[i]=NewChar;
			_flag=_ONE;
			}
		_ret+=_item[i];
		}
	return(_ret);
	}

function newwindow(href)
	{
	window.open(href,'newwindow','resizable=yes,toolbar=yes,left=200,top=200,status=yes,location=yes,scrollbars=yes');
	}

function getCookieVal (offset)
	{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	};


function SetCookie (name, value)
	{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var path = "/";
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value);
	//((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	//((path == null) ? "" : ("; path=" + path)) +
	//((domain == null) ? "" : ("; domain=" + domain)) +
	//((secure == true) ? "; secure" : "");
	};
function checkpop(myurl,width,height)
	{
	var pagelisting=GetCookie("poplist").split(",");
	var popwindow = true;
	for(var i=0;i < pagelisting.length;i++)
		{
		var mypage = pagelisting[i];
		if(myurl == mypage)
			{
			var popwindow = false;
			}
		}
	if(popwindow == true)
		{
		if(GetCookie("poplist").length == 0)
			{
			var setit = myurl;	
			}
		else
			{
			var setit = GetCookie("poplist") + "," + myurl;	
			}
		// set the cookie
		SetCookie("poplist",setit);
		// pop the window
		twin=window.open(myurl,'twin','resizable=no,toolbar=no,status=no,location=no,height='+height+',width='+width+',scrollbars=no');
		}
	}


var version4 = (navigator.appVersion.charAt(0) == "4");
var popupHandle;
function closePopup() {
if(popupHandle != null && !popupHandle.closed) popupHandle.close()
}
