<!--

var facultyID 

function addSymbol(id,symbol){
	var textElement = document.getElementById(id);
	textElement.value += symbol;
	textElement.focus();
}
function textCounter(fieldid,SID,maxlimit) {
	var field = document.getElementById(fieldid);
	var cntfield = document.getElementById("count_"+SID);
	var CountMSG = document.getElementById("counterMSG"+SID);
	
	// if too long...trim it!
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
		
	}
	// otherwise, update 'characters left' counter
	else{
		cntfield.value = maxlimit - field.value.length ;
		if (field.value.length > 2005){
			cntfield.style.color = "red";
			CountMSG.innerHTML = "You have less than 320 characters left to use in your abstract body. If you include a figure, text will automatically be deleted.";
		}
		if (field.value.length < 2005){
		cntfield.style.color = "black";
		CountMSG.innerHTML = "";
		}
	}
}

function wordCounter(id,FTID, maxlimit,minlimit){
	var field = document.getElementById(id);
	var cntfield = document.getElementById("count_"+FTID);
	var CountMSG = document.getElementById("counterMSG"+FTID);
	var words = field.value.split(" ");
	var r = 0;
	var z;
	
	for ( z = 0 ; z < words.length  ; z++) {
		if (words[z].length > 0 || ( words[z].length == 0 && words[z].charCodeAt(1) == 13 ) )
			r++;
	}
	
	cntfield.value=r;
	if (r >  maxlimit){
		CountMSG.innerHTML = "You have exceeded the maximum word limit.";
		window.alert("You have exceeded the maximum word limit.");
		document.getElementById("valid_"+id).value = "false"
	}
	else{
		CountMSG.innerHTML = "";
		if (minlimit > 0) {
			if (r < minlimit){
			    CountMSG.innerHTML = "You have not reached the minimum word requirement.";
			    document.getElementById("valid_"+id).value = "false"
			}
			else{
			    CountMSG.innerHTML = "";
			    document.getElementById("valid_"+id).value = "true"
			}
		}
	}

}
var RequiredElements;

function validate(sid,type){
	var i,tmpArr,e,v,vid,SID,SIDS,FID,fsubReqFields,s,valid, subReqFields,FTID ;
	var j,e1,v1,vid1;
	if (sid.length > 0){
		fsubReqFields = 0;//faculty
		subReqFields = 0;//session and faculty
		var elements = RequiredElements.split(";");
		alert (elements)
		for (i in elements){
			tmpArr = elements[i].split("_");
			FTID = tmpArr[1];
			SID = tmpArr[2];
			FID = tmpArr[3];
			//checkboxes
			if (FTID == 243 || FTID == 246 ||  FTID == 73|| FTID == 242){
				var f,chked, ccount;
				vid = elements[i].substring(2);
					vid = "V"+vid;
					v = document.getElementById(vid);
					valid = false;
				
				if (FTID == 242 ){
					var e = document.getElementById(elements[i]+"0");
					if (e.checked )
							valid =true;
				}
				else{
					if (FTID == 243)
						ccount = 6;
					if (FTID == 246 )
						ccount = 3;
					if (FTID == 73 )
						ccount = 9;
					
							
					
					for (f=0;f<ccount; f++){
						//alert(elements[i]+f);
						var e = document.getElementById(elements[i]+f);
						if (e.checked )
							valid =true;		
					}
				}
				if (!valid){
					subReqFields++;
				}
				v.className = (valid)?"valid": "invalid" ;
			}	
			else{
				e = document.getElementById(elements[i]);
				
				if ((SID == "0" || SID == sid) ){
					//window.alert(elements[i]);
					if(e.type == "text"){
						vid = elements[i].substring(2);
						vid = "V"+vid;
						v = document.getElementById(vid);
						valid = (e.value.replace(/^\s*|\s*$/g,"") == ""  )?false : true ;
						v.className = (valid)?"valid": "invalid" ;
						if (FID != 0 && !valid)
							fsubReqFields++ ;
						if (!valid)
							subReqFields++;
					}
					if (e.type == "textarea"  ){
						vid = elements[i].substring(2);
						vid = "V"+vid;
						v = document.getElementById(vid);
						valid = (e.value.replace(/^\s*|\s*$/g,"") == ""  )?false : true ;
						//v.className = (valid)?"valid": "invalid" ;
						if (valid){
							if (FTID == 10 || FTID == 238 || FTID ==239 || FTID == 240 || FTID ==  241){
								var maxlimit = 100;
								if (FTID == 238){
									maxlimit = 50;
								}
								var cntfield = parseInt(document.getElementById("count_"+FTID).value);
								if (cntfield > maxlimit){
									valid= false;
								}
								else {
									if (FTID == 10 && cntfield < 30)
										valid= false;
								}						
							}
						}
						v.className = (valid)?"valid": "invalid" ;
						if (FID != 0 && !valid)
							fsubReqFields++ ;
						if (!valid){
							subReqFields++;
						}
					}
					if (e.type== "radio" ){
						var ename = elements[i].substr(0,elements[i].length -1 );
						vid = ename;
						vid = vid.substr(2,(vid.length -2));
						vid = "V"+vid;
						v = document.getElementById(vid);						
						valid =radioval(document.submain,ename);
						v.className = (valid)? "valid": "invalid" ;
						if (FID != 0 && !valid)
							fsubReqFields++ ;
						if (!valid)
							subReqFields++;
					}
				}
			}
		}	
	}
	if (type =="save"){
		if (fsubReqFields + subReqFields  > 0)
			window.alert( "Some required fields are not filled.");
		else
			document.submain.submit();
	}
	if (type == "Pass"){
		if (fsubReqFields + subReqFields  > 0){
			window.alert( "Some required fields are not filled.")
			createNew = false;
		}
		else
			createNew = true;
	}
}

var createNew = false;

function CheckPInfo(){
	validate("0","Pass");
	if(createNew){
		var newName = document.getElementById('NewSessionName');
		//if (newName.value.length > 0  )
	}
	
}			
function getElement(form,name){
		for(var x=0; x<form.elements.length; x++){
			var ee = form[x];
			if(ee.name == name)
				 return ee;
		}
		return null;
	} 
	function radioval(form,name) {
		var flag = false;
		for(var x=0; x<document.submain.elements.length; x++){
			var ee = document.submain.elements[x];
			if(ee.name == name){
				if (document.submain.elements[x].checked || document.submain.elements[x+1].checked ) 
					flag = true;
			}
		}
		return flag;
	}	

	function enableSubmitBtn(e){
		//var radio = getElement("submain","NewSessionTrackID");
		var btn = document.getElementById("CreateNewS");
		//var name = document.getElementById("NewSessionName");
		//window.alert("radio: "+ radio.value +" , Name: " + name.value); 
		btn.disabled =  false;
	}
	function SubmitNewSession(){
		var name = document.getElementById("NewSessionName");
		if (name.value.replace(/^\s*|\s*$/g,"") == ""){
			window.alert("Please enter a title for the new Abstract");
			return ;
		}
		document.submain.checkOut.value = "";
		document.submain.submit();
	}
	function validateFac(sid){
		var email = document.getElementById("email"+sid);
		var ln = document.getElementById("LN"+sid);
		var fn = document.getElementById("FN"+sid);
		var notVcount = 0;
		//email
		var vemail = document.getElementById("Vemail"+sid);
		if (!isEmail(email)){
			notVcount++;
			vemail.style.color = "red";
		}
		else
			vemail.style.color = "black";
		//last name
		var vln = document.getElementById("VLN"+sid);
		if ((ln.value.replace(/^\s*|\s*$/g,"") == "") ){
			notVcount++;
			vln.style.color = "red";
		}
		else
			vln.style.color = "black";
		//first name
		var vfn = document.getElementById("VFN"+sid);
		if ((fn.value.replace(/^\s*|\s*$/g,"") == "") ){
			notVcount++;
			vfn.style.color = "red";
		}
		else
			vfn.style.color = "black";
		if (notVcount > 0){
			window.alert("Please make sure you filled all the fields and that the email is correct before adding this contributing Author.")
			return;
		}
		else {
			document.submain.submit();
		}
			
	}
function deleteSession(sid){
	if (window.confirm("Are you sure you want to delete this abstract?")){
		document.sessionList.DSession.value = sid;
		document.sessionList.submit();
	}
}
function facultyUp(sid,fid){
	var fu = document.getElementById("FU_"+sid);
	fu.value = fid;
	document.submain.checkOut.value = "";
	document.submain.submit();
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=380,height=700');");
}
var ethansims = "ethansims.htm";
var format = "format.htm";
var authors = "authors.htm";
var disclosure = "disclosure.htm";
function HelpPopUp(URL) {
//day = new Date();
//id = day.getTime();
eval("pagehelp = window.open(URL, 'help', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=380,height=400');");
}
 function isEmail(theElement) {
   // This function checks if the text entered in a field has the
   // format x...@yyyy.zzzz. or x...@aaa.bbb.ccc.ddd

        var email_regex = /^[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+(\.[\w\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~])*\@(((\w+[\w\d\-]*[\w\d]\.)+(\w+[\w\d\-]*[\w\d]))|((\d{1,3}\.){3}\d{1,3}))$/;

        if (email_regex.test(theElement.value)) {
                tmp = theElement.value.split(/\@/);
                var dot_num_regex = /^(\d{1,3}\.){3}\d{1,3}$/;
                if (dot_num_regex.test(tmp[1])) return (isLegalIP(tmp[1]));
                return true;
        } else {
                return false;
        }
   } 
  function ShowHideDisclosures(radioID){
	var radio = document.getElementById(radioID);
	var radioIDParts = radioID.split("_");
	var sid = radioIDParts[2];
	var fieldtypes = new Array(217,76,222,223,226,227,228,229,230,231 );
	var tr,display, trid; 
	var value = radio.value ;
	var testValue = "<b>I do not have financial interest in, or receive support from, any commercial entity in connection with this proposed presentation.</b>";
	//window.alert(value.length);
	if (value.length == testValue.length){
		display = "none";
	}
	else
		display = "block";
		
	for (var i=0;i<fieldtypes.length ;i++){
		trid = "tr_"+sid+"_"+fieldtypes[i] ;
		tr= document.getElementById(trid);
		tr.style.display = display;
	}
  }
function test(msg){
	window.alert(msg);
}

//-->