function decideIfScroll()  {
	if (document.layers) {
		var boxScroll= parseInt(document.contentLayer.clip.height);
	}else {

		if (document.getElementById) {
			if(document.getElementById('contentLayer')!=null){
				var boxScroll= parseInt(document.getElementById('contentLayer').offsetHeight);
			}
		}else {

			if (document.all) {
				var boxScroll = parseInt(document.all.contentLayer.clientHeight);
			}
		}
	}
	if (parseInt(boxScroll) < 300)  {
		if (document.layers) {
			document.scrollarea.style.overflow="hidden";
		}else {
			if (document.getElementById) {
				document.getElementById('scrollarea').style.overflow="hidden";
			}else {
				if (document.all) {
					document.all.scrollarea.style.overflow="hidden";
				}
			}
		}
	}
}

function demoPopUp(url){
	demoWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=741,height=520');
	self.name = "mainWin";
}

function deselect_all(catName){
	if(eval("document.roles."+catName+".length")>1){
		for(i=0; i<eval("document.roles."+catName+".length"); i++){
			eval("document.roles."+catName+"[i].checked = false");
		}
	}else{
		eval("document.roles."+catName+".checked = false");
	}
	eval("document.roles.parent_"+catName+".checked = false");
}

function disableSubmit( formName, buttonName ){
	var submitted = false;
	if ( !submitted ) {
		eval("document." + formName + "." + buttonName + ".disabled = true;");	
		eval("document." + formName + ".submit();");
		submitted = true;
	}
}

function disableSubmitAndCancel( formName, buttonName, cancelButton ){
	var submitted = false;
	if ( !submitted ) {
		eval("document." + formName + "." + buttonName + ".disabled = true;");
		
		eval("document." + formName + "." + cancelButton + ".disabled = true;");

		eval("document." + formName + ".submit();");
		submitted = true;
	}
}

function disableThreeButtons(formName, button1, button2, button3){
	var submitted = false;
	if (!submitted) {
		eval("document." + formName + "." + button1 + ".disabled = true;");
		
		eval("document." + formName + "." + button2 + ".disabled = true;");

		eval("document." + formName + "." + button3 + ".disabled = true;");

		eval("document." + formName + ".submit();");
		submitted = true;
	}
}

function mClk(src){ 
	if(event.srcElement.tagName=='TD')
		src.children.tags('A')[0].click();
}

function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)){ 
		src.style.cursor = 'hand'; 
		src.bgColor = clrOver; 
	} 
}

function mOut(src,clrIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} 
} 

function opencal(month_el,date_el,year_el,x,e,way,language,formName){
	ctop = 0;
	cleft = 0;
	if(document.all){
		ctop = event.screenY+20;
		cleft = event.screenX+20;
	}else{
		ctop = e.screenY+20;
		cleft = e.screenX+20;
	}
	params = "location=no, resizable=0, width=144,height=165,left=" + cleft + ",top=" + ctop;
	init(month_el,date_el,year_el,formName, ctop, cleft);
}

function opencalendar(month_el,date_el,year_el,x,e,way,language,formName){
	ctop = 0;
	cleft = 0;
	if(document.all){
		ctop = event.screenY+20;
		cleft = event.screenX+20;
	}else{
		ctop = e.screenY+20;
		cleft = e.screenX+20;
	}
	url = "/calendar.jsp?month_el='" + month_el + "'&date_el='" + date_el + "'&year_el='" + year_el + "'&way='" + way + "'&language='"+language+"'&formName='"+formName+"'";
	params = "location=no, resizable=0, width=144,height=165,left=" + cleft + ",top=" + ctop;
	calendar = window.open(url,"cal",params);
	delay = setTimeout("calendar.focus()",400);
}

function popUp(url){
	newWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=400');
}

function popup(url, name, windowSpec) {
	newWindow = window.open(url, name, windowSpec);
	newWindow.focus;
}

function popup(url, name, w, h) {
	winspec = "scrollbars=0,resizable=0,toolbar=0,status=0,left=50,top=50, width=" +w+ ", height="+h+"";
	newWindow = window.open( url, name, winspec );
	newWindow.focus;
}

function select_all(catName){
	if(eval("document.roles."+catName+".length")>1){
		for(i=0; i<eval("document.roles."+catName+".length"); i++){
			eval("document.roles."+catName+"[i].checked = true");
		}
	}else{
		eval("document.roles."+catName+".checked = true");
	}
	eval("document.roles.parent_"+catName+".checked = true");
}

function selectParent(catName){
	var v = eval("document.roles.parent_"+catName+".checked");
	if(v == false){
		eval("document.roles.parent_"+catName+".checked = true");
	}
}

function show(aId, htmlCode){
	var isVisible = eval("document.all."+aId+".style.display");

	if(isVisible == 'none'){
		eval("document.all."+aId+".style.display = \"block\"");
	}else{
		eval("document.all."+aId+".style.display = \"none\"");
	}
}

function toggle(catName){
	var v = eval("document.roles.parent_"+catName+".checked");
	if(v == false){
		deselect_all(catName);
	}else{
		select_all(catName);
	}
}

function writeDiv(id) {
    if (document.all!=null) {
        document.write("<div id=" + id +" style=\"display: none\">")
    } else {
        
        if (navigator.appName == 'Netscape'){
            document.write("<div id=" + id +" style=\"visibility:visible\">")
        }
    }
}

function writeScrollArea() {
    if (document.all!=null) {
        document.write("<DIV id=scrollarea><DIV id=contentLayer>");
    } else {
        
        if (navigator.appName == 'Netscape'){
            document.write("")
        }
    }
}

function writeToggle(id) {
    if (document.all!=null) {
        document.write("[ <a href=\"javascript:show('"+id+"')\">+/--</a> ]");
    } else {
        
        if (navigator.appName == 'Netscape'){
            document.write("")
        }
    }
}

function dynamicTextareaResize(textarea) {
	a = textarea.value.split('\n');
	b=1;
	for (x=0;x < a.length; x++) {
	    if (a[x].length >= textarea.cols) b+= Math.floor(a[x].length/textarea.cols);
	}
	b+= a.length;
	if (b > textarea.rows) textarea.rows = b;
}
