function getRand()	{
	var maxCount = 10000;
	day = new Date();
	seed = day.getTime();
	return parseInt(((seed - (parseInt(seed/1000,10) *1000))/10)/100*maxCount + 1,10);
}
function getPopup(sUrl,iWidth,iHeight,sName,sText)	{
	sName = (sName) ? sName : "Edit";
	if(sName=="random")sName=getRand();
	oPopup=window.open(sUrl,sName,"scrollbars=yes,menubar=no,toolbar=no,status=no,directories=no,location=no,width="+iWidth+",height="+iHeight+",resizable=no,left=60,top=60");
	if(sText)oPopup.dialogArguments=sText;
	oPopup.opener = self;
}
function confirmLink(target,confirmText,elseStat)	{
	var conLength=confirmText.length;
	var RowCount=parseInt(conLength/40);
	var plusHeight=RowCount*16;
	var dialogHeight=145+plusHeight;
	var sUrl=jmRealPath+"jmuffin/html/confirmlink.cfm?i=1";
	getPopup(sUrl,290,dialogHeight,"Dialog",confirmText);
	oPopup.target=target;
	/*
	var bReturnValue = window.showModalDialog(sUrl,confirmText,"dialogHeight: "+dialogHeight+"px; dialogWidth:290px; dialogTop: 150px; dialogLeft: 150px; center: Yes; help: no; resizable: No; status: No;");
	var check=(bReturnValue)? bReturnValue:false ;
	if(target=="bool")return check;
	else if(check)window.location=target;
	else if(elseStat=="close")window.close();
	*/
}
oForm= new Array();
function ClassForm(code)	{
	this.code=code;
	this.setObject=setObject;
	this.check=check;
	this.aField= new Array();
	this.aType= new Array();
}
function setObject(field,sType)	{
	this.aField[this.aField.length]=field;
	this.aType[this.aType.length]=sType;
}
function check()	{
	var valueReturn=true;
	for(var i=0;i<this.aField.length;i++)	{
		oField=document.forms[this.code]["form_"+this.aField[i]];
		if(document.all)oLabel=document.all["label_"+this.aField[i]];
		else oLabel=document.getElementById("label_"+this.aField[i]);
		if(this.aType[i]=="text" || this.aType[i]=="textarea" )	{
			if(oField.value.length==0)	{
				oLabel.style.backgroundColor="red";
				valueReturn=false;
			}
			else
				oLabel.style.backgroundColor="";
		}
		if(this.aType[i]=="checkbox" || this.aType[i]=="radio" ){
			if(oField[0])	{
				iCount=0;
				for(var y=0;y<oField.length;y++)if(oField[y].checked)iCount++
					if(iCount==0){
						oLabel.style.backgroundColor="red";
						valueReturn=false;
					}else	{
					oLabel.style.backgroundColor="";
					}
				
			}
			else {	
				if(!oField.checked)	{
					oLabel.style.backgroundColor="red";
					valueReturn=false;
				}
				else
					oLabel.style.backgroundColor="";
			
			}
		}
	}
return valueReturn;
}
function newForm(sName)	{
	oForm[sName]= new ClassForm(sName);
}
function initPopup(width,height)	{
	window.resizeTo(width,height);
	if(document.body)	{
		if(document.all)document.body.style.overflow="auto";
		document.body.style.borderColor="white";
		document.body.style.borderStyle="solid";
		document.body.style.borderWidth="1px";
	}
}
function setCookie(name,value,days) {
	document.cookie = name+"="+value+"; path=/"
}
function getCookie(name) {
	var nameEQ = name + "="
	var ca = document.cookie.split(';')
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length)
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
	}
	return "";
}
function setVisibilityContext()	{
	visibility=(getCookie("JM_CONTEXT_VISIBILITY")=="visible")?"hidden":"visible";
	setCookie("JM_CONTEXT_VISIBILITY",visibility);
	oSite=parent.frames.jmContext;
	if(document.all) var oLogo=document.all["jmLogo"];
	else var oLogo=document.getElementById("jmLogo");
	if(visibility=="hidden")	{
		oLogo.width="120";
		oLogo.height="35";	
	}else	{
		oLogo.width="180";
		oLogo.height="45";	
	}
	oSite.window.location=oSite.self.location;//oSite.history.go(0);
	//setTimeout("window.loaction=history.go(0)",300);
}