


var mac = false;  //var mac = (navigator.userAgent.indexOf("Mac")!=-1);


window.focus();

function supportsIFrame()
	{
	if(document.all || document.getElementById && !document.all)
		{
		// ie and ns6+
		return true;
		}
	else
		{
		return false;
		}
	}

function CFC_init(scrollValue,templaters_js)
	{
	if (document.all)
		{
		document.stylePre="";
		document.stylePost="style.";
		document.app="ie";
		}
	else
		{
		document.stylePre="document.";
		document.stylePost="";
		document.app="ns";
		}

	if (scrollValue) document.body.scrollTop=scrollValue;

	CFC_preloadButtons();
	
	if (typeof(templaters_js)!="undefined") eval(templaters_js);
	}

function CFC_openAdWin(src,w,h,winName,resAbl)
	{
	if ((typeof w) == "undefined" || !w) w=700;
	if ((typeof h) == "undefined" || !h) h=560;
	if ((typeof winName) == "undefined" || winName == "") winName="CFC_AdWin";
	
	var cK=CFC_cacheKiller();
	var technique="iFrame";
	
	if (!supportsIFrame() || mac) 
		technique="frame"; 
	else
		resAbl=1;
	
	var adWin=window.open(src+"&CFC_technique="+technique+"&"+cK,winName,"location=0,toolbar=0,status=1,resizable="+resAbl+",scrollbars=1,width="+w+",height="+h);
	adWin.focus();
	}

function CFC_openActWin(src,w,h)
	{
	if ((typeof w) == "undefined" || !w) w=400;
	if ((typeof h) == "undefined" || !h) h=100;
	var actWin=window.open(src,"CFC_actWin","menubar=0,copyhistory=0,directories=0,toolbar=0,status=1,resizable=0,scrollbars=0,width="+w+",height="+h);
	actWin.focus();
	}

function CFC_cacheKiller()
	{
	var cK=new Date();
	cK=cK.valueOf();
	return "CFC_cK="+cK;
	}


function CFC_getFormLocator(name,locator)
	{
	var returnValue;
	for (var div in locator.layers)
		{
		if (locator[div])
			{
			if (locator.layers[div].document.forms[name])
				{
				return(locator[div].document);
				}
			var tmp=CFC_getFormLocator(name,locator[div].document);
			if (tmp) return(tmp);
			}
		}
	return(0);
	}



function CFC_checkMandatories(form)
	{
	return 1; 
	if (!form)
		{
		for (var f in document.forms)
			{
			form=document.forms[f];
			}
		}
	
	flag=1;

	if (form.Mandatory)
		{
		flag=0;
		if (!(form.Mandatory[0]))
			{
			flag=CFC_checkMandatoriesObj(form.elements[form.Mandatory.value]);
			toCheck=form.Mandatory.value;
			}
		else
			{
			ii=0;
			while (form.Mandatory[ii])
				{
				flag=CFC_checkMandatoriesObj(form.elements[form.Mandatory[ii].value]);
				if (!flag) 
					{
					toCheck=form.Mandatory[ii].value;
					break;
					}
				ii++;
				}
			}
		}
	if (flag)
		return true;
	else
		{
		var toCheckObj=form[toCheck];
		if (toCheckObj.type!="hidden") 
			{
			if (toCheckObj[0] && toCheckObj.type!="select-one") toCheckObj[0].focus(); else toCheckObj.focus();
			}
		alert("");	
		return false;
		}
	}


function CFC_checkMandatoriesObj(toCheckObj)			
	{
	if (toCheckObj.type=="select-one")
			{
			if (toCheckObj.selectedIndex==0) return 0;
			else return 1;
			}

	if (toCheckObj.type=="text" || toCheckObj.type=="textarea" || toCheckObj.type=="hidden")
		{	
		if (toCheckObj.value!="") return 1;
		else return 0;	
		}

	if (toCheckObj[0].type=="radio" || toCheckObj[0].type=="checkbox")
		{
		i=0;
		while (toCheckObj[i])
			{
			if (toCheckObj[i].checked) return 1; 
			i++;
			}
		return 0;
		}
	}

var labelCharMap = new Array(
"_","_","_","_","_","_","_","_","_","_","_","_","_","_","_","_",
"_","_","_","_","_","_","_","_","_","_","_","_","_","_","_","_",
"_","_","_","_","_","_","_","_","_","_","_","_","_","_","_","_",
"0","1","2","3","4","5","6","7","8","9","_","_","_","_","_","_",
"_","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W","X","Y","Z","_","_","_","_","_",
"_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","_","_","_","_","_",
"_","f","_","_","_","fi","fi","_","_","_","_","_","_","_","_","_",
"_","_","_","_","_","_","_","_","_","_","_","_","y","_","_","_",
"_","i","c","p","o","v","_","s","_","_","_","_","_","_","_","_",
"_","_","_","_","_","_","_","_","_","_","_","_","_","_","_","_",
"A","A","A","A","AE","A","AE","C","E","E","E","E","I","I","I","I",
"D","N","O","O","O","O","OE","X","O","U","U","U","UE","Y","B","ss",
"a","a","a","a","ae","a","ae","c","e","e","e","e","i","i","i","i",
"o","n","o","o","o","o","oe","_","o","u","u","u","ue","y","b","y"
);

function CFC_checkLabel(str)
	{
	var res = "";
	for (var i = 0; i < str.length; i++)
		{
		var c = str.charCodeAt(i);
		c = (c >= 0 && c <= labelCharMap.length) ? labelCharMap[c] : "_";
		res += c;
		}
	if (res != str) alert(str+" contains invalid characters.\n\nSuggestion: "+res);
	return res;
	}

