/************************************************************************************************
 * Quartzy java script for the Quartzy.
 * @package    Quartzy  
 ***************************************************************************************************/
/****************** profile index page js************************/

	function validateAddMember(tmpform){
		var formName = $(tmpform);
		var checkFound = false;
		for (var counter=0; counter < formName.length; counter++){
			if ((formName.elements[counter].name == 'chkcontact[]' || formName.elements[counter].name == 'chklabmate[]') && (formName.elements[counter].checked == true)){
				checkFound = true;
			}
		}		
		if (checkFound != true){
			setValue('error','Please select atleast one member to invite.');											
			return false;							
		}
	}	
	function Validate( chkId ){  
    userid = (chkId.toString()).substr(10);       

	
      if (('chkcontact'+userid) == chkId){              
        document.getElementById('chklabmate'+userid).checked = false;        
        if ( document.getElementById(chkId).checked ){
            document.getElementById('chklabmate'+userid).disabled = true;
        }else{
            document.getElementById('chklabmate'+userid).disabled = false;
        }
      }else if(('chklabmate'+userid) == chkId){
        document.getElementById('chkcontact'+userid).checked = false;        
        if ( document.getElementById(chkId).checked ){
            document.getElementById('chkcontact'+userid).disabled = true;
        }else{
           document.getElementById('chkcontact'+userid).disabled = false;
        }
      }
  }  
  function activateIt( objId ){
    document.getElementById(objId).disabled = false;
    document.getElementById(objId).checked = true;    
    Validate( objId );
  }  
  function ValidateRef( chkId ){  
    userid = (chkId.toString()).substr(14); 
	
	
      if (('ref_chkcontact'+userid) == chkId){              
        document.getElementById('ref_chklabmate'+userid).checked = false;        
        if ( document.getElementById(chkId).checked ){
            document.getElementById('ref_chklabmate'+userid).disabled = true;
        }else{
            document.getElementById('ref_chklabmate'+userid).disabled = false;
        }
      }else if(('ref_chklabmate'+userid) == chkId){
        document.getElementById('ref_chkcontact'+userid).checked = false;        
        if ( document.getElementById(chkId).checked ){
            document.getElementById('ref_chkcontact'+userid).disabled = true;
        }else{
           document.getElementById('ref_chkcontact'+userid).disabled = false;
        }
      }
  }
  function activateItRef( objId ){
	    document.getElementById(objId).disabled = false;
	    document.getElementById(objId).checked = true;	        
	    ValidateRef( objId );
	  }
  function checkCommentInput(){
		var isReturnFalse = true;
		divArray = new Array('divComment');		
		fieldArray = new Array('txtComment');
		setArrCss(fieldArray,'txtField486'); // function to set the css of the fields		  			
		if( (trim($('txtComment').value)==0 || trim($('txtComment').value)=='') ){
			setValue('divComment','Comment cannot be empty');	
			setCss('txtComment','txtField486 invalidField');								
			isReturnFalse = false;		
		} else {			
			return true;		
		}	
	}
	function disableToFromYear(){				
		document.getElementById('selYearFromTo').value='';
		document.getElementById('selYearFromTo').disabled=true;
		document.getElementById('selYearTo').value='';
		document.getElementById('selYearTo').disabled=true;
		document.getElementById('selYearFromYear').value='Year';
		document.getElementById('selYearFromYear').disabled=false;
		document.getElementById('present').checked=false;
		document.getElementById('present').disabled=true;
	}
 	function disableYear(){
		document.getElementById('selYearFromYear').disabled=true;
		document.getElementById('selYearFromYear').value='';
		document.getElementById('selYearFromTo').disabled=false;
		document.getElementById('selYearFromTo').value='Year';
		document.getElementById('selYearTo').disabled=false;
		document.getElementById('selYearTo').value='Year';
		document.getElementById('present').disabled=false;
	}	
  	function selectPresent(){
		var curr = document.getElementById('present');
		var radioYear = document.getElementById('year_fromTo_fromTo');
		if(radioYear.checked==true){
			if(curr.checked==true){
				document.getElementById('selYearTo').readOnly=true;
				document.getElementById('selYearTo').value='present';
			}else{
				document.getElementById('selYearTo').value='Year';
				document.getElementById('selYearTo').disabled=false;
				document.getElementById('selYearTo').readOnly=false;				
			}		
		}
	}	
  	function funcdisable(){
		if(document.getElementById('present').checked==true){
			document.getElementById('selYearTo').readOnly=true;			
		}else{
			document.getElementById('selYearTo').readOnly=false;
			if(document.getElementById('selYearTo').value=='Year')
				document.getElementById('selYearTo').value ='';
		}
	}
	
	function showDeactPopup( ){	
	  DvLayerOpen('DvLayer','DvLayerAcc-deact','50')	  
	}	
	function searchLB(){	
	 if(trim($('searchTxtLb').value) == ''){
		alert('Please enter the term you want to search');
		$('searchTxtLb').focus();
		return(false);
	 }
	 return true;
	}
/****************** end profile index page js************************/
/******************current possition js *************/	
	function validateCurrentPositionsNext(){		
		var dateYear = trim($('txtYear').value);
		var dateYearFrom = trim($('txtYearFrom').value);
		var dateYearTo = trim($('txtYearTo').value);
		var valEntered = false;		
		if(dateYear=='Year'){
			dateYear='';
		}
		if(dateYearFrom=='Year'){
			dateYearFrom='';
		}
		if(dateYearTo=='Year'){
			dateYearTo='';
		}						
		if( ($('selPositionId').value==0 && trim($('txtPositionName').value)!='') || $('selPositionId').value!=0 ){	
			valEntered = true;			
		}
		if ( (trim($('txtUniversity').value)!=0 && trim($('txtUniversity').value)!='') || trim($('txtUniversityAuto').value)!=''){
			valEntered = true;		
		}		
		if($('oneYearDiv').checked && dateYear != ''){ valEntered = true; }		
		if($('twoYearDiv').checked && (dateYearFrom != '' || dateYearTo != '') ){ valEntered = true; }								
		if(valEntered){
			setElementValue('goNext',1);
			return validateCurrentPositions();
		} else {		
			new Ajax.Updater('mp-contentWrapper', siteURLEdu, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper');}, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');profileMenuActive('lnkEducation');}});;
		}		
		return false;		
	}  
  function showHideOther( selElement, otherDiv, inptElement ){  		
  	if($(selElement).value==0 && $(selElement).value!=''){
  		$(otherDiv).style.display='block';		
  	} else {
  		$(otherDiv).style.display='none';  		
  	}
  }   
   
  function nameForm(){    	
  	$('addAdvisorName').value='true';  	
  }  
  	function addAdvisorsP(){  				
		var container = $('ulAdvisor');
		var container1 = $('ulAnotherAdv');
		var clone = container.cloneNode(true);					
		var lastAdvId = parseInt($('totalAdvisor').value) +1;
		$('totalAdvisor').value = lastAdvId;		
		clone.id ='ulAdvisor'+lastAdvId;
		clone.style.display ='block';
		container1.insertBefore(clone, container1.lastChild);			
		var newDiv = '<div  class=\'Remove\'> <a href=\'javascript:remAdvisorsP("ulAdvisor'+lastAdvId+'")\'>Remove</a></div>';		
		var tempString = clone.innerHTML;		
		if(navigator.userAgent.indexOf('MSIE') != -1 ){
			var newTempString = tempString.replace('<DIV class=Add><A href="javascript:addAdvisorsP()">Add another</A></DIV>', newDiv);
		} else {
			var newTempString = tempString.replace('<div class="Add"><a href="javascript:addAdvisorsP()">Add another</a></div>', newDiv);
		}				
		clone.innerHTML = newTempString;			  		
	}
	
	function remAdvisorsP(id){		
		$(id).remove();
	}	
	function valAdvisorsP(){				
		var totalFields = parseInt($('totalAuthor').value);		
		for(i=0; i < document.currentPositionForm.elements.length; i++){ 		
			if(document.currentPositionForm.elements[i].name=='txtAdvisorFname[]' || document.currentPositionForm.elements[i].name=='txtAdvisorLname[]'){
				if(document.currentPositionForm.elements[i].value==''){				
					return false;
				}						
			}		
		}
		return true;				
	} 
	function valAdvisorsCheckP(){				
		var totalFields = parseInt($('totalAuthor').value);		
		var formName = 	document.currentPositionForm;
		for(i=0; i < formName.elements.length; i++){ 			
			if(formName.elements[i].name=='txtAdvisorFname[]'){
				var fId = formName.elements[i].id;
				var actId = getIdFromString(fId);
				var lId = 'lname_'+actId;				
				if( (trim($(fId).value)=='' && trim($(lId).value)!='') || (trim($(lId).value)=='' && trim($(fId).value)!='') ){
					return false;
				} 		
			}						
		
		}
		return true;				
	}	
	function valSpecialAdvisorsP(){	
		var regex=/^[A-Za-z\-\']+$/;
		var totalFields = parseInt($('totalAuthor').value);
		var formName = document.currentPositionForm;		
		for(i=0; i < document.currentPositionForm.elements.length; i++){ 		
			if(formName.elements[i].name=='txtAdvisorFname[]' || formName.elements[i].name=='txtAdvisorMname[]' || formName.elements[i].name=='txtAdvisorLname[]'){			
				if( trim(formName.elements[i].value) !='' &&  !regex.test(trim(formName.elements[i].value))){					
					return false;
				}
			}						
		}
		return true;
	}
	function disableToYear(){
		if($('chkCurrentPosition').checked){							
			$('txtYearTo').value = 'present';	
			$('txtYearTo').disabled = true;						
		} else {
			$('txtYearTo').value = 'Year';
			$('txtYearTo').disabled = false;
		}
	}	
	function disableCurrentFromYear(){				
		document.getElementById('txtYearFrom').value='';
		document.getElementById('txtYearFrom').disabled=true;
		document.getElementById('txtYearTo').value='';
		document.getElementById('txtYearTo').disabled=true;
		document.getElementById('txtYear').value='Year';
		document.getElementById('txtYear').disabled=false;				
		$('chkCurrentPosition').disabled = true;
		$('chkCurrentPosition').checked = false;
	}
	function disableCurrentYear(){
		document.getElementById('txtYear').disabled=true;
		document.getElementById('txtYear').value='';
		document.getElementById('txtYearFrom').disabled=false;
		document.getElementById('txtYearFrom').value='Year';
		document.getElementById('txtYearTo').disabled=false;
		document.getElementById('txtYearTo').value='Year';
		$('chkCurrentPosition').disabled = false;
		if($('chkCurrentPosition').checked){
			$('txtYearTo').value = 'present';
		}		
	}
	function validateLenPosition(objCountName){
		$('textareaCount').style.display = '';
		var charCount=500;
		obj=$(objCountName);
		msgnowLen=parseInt(find_new_lines(obj.value))+parseInt(obj.value.length);
		if(msgnowLen <=charCount){
			rem=charCount-msgnowLen;
			$('textareaCount').innerHTML=rem+ ' letters remaining';
		} else {
			rem=Math.abs(charCount-msgnowLen);
			$('textareaCount').innerHTML='<font color=red>Exceeded Maximum by '+rem+' letters</font>';
		}
	}
	function checkMoveCond(){
		if(confirm('You can come back again at any time and complete/edit your profile. Would you like to add members to your Contact/LabMate Network?')){			
			callCommonLeftPanelPage('Labmates');
		} else {
			return true;
		}
	}
	function checkMoveCondFinal(){
		if(confirm('Thanks for entering your profile. You can come back again at any time and complete/edit your profile. Would you like to add members to your Contact/LabMate Network?')){			
			callCommonLeftPanelPage('Labmates');
		} else {
			return true;
		}
	}
	function initialDisable( ){
	   if($('oneYearDiv').checked){
	       document.getElementById('txtYearFrom').value='';
           document.getElementById('txtYearFrom').disabled=true;
	       document.getElementById('txtYearTo').value='';
		   document.getElementById('txtYearTo').disabled=true;
	   }else{
	      $('chkCurrentPosition').disabled = false;
	      document.getElementById('txtYear').disabled=true;
		  document.getElementById('txtYear').value='';
	   }
	}
	function showTxtUniversity(val){
		if($('divUniversity')){ $('divUniversity').style.display = 'none'; }
		if($('divUniversityid')){ $('divUniversityid').style.display = 'none'; }
		if(val=='-1'){	$('uniTextDiv').style.display = '';	}
		else{ $('uniTextDiv').style.display = 'none';	}
	}
	function submitFirst(){ document.regFormFirst.submit; }

	function txtCountryDivShow(dvId,field)  {
		if($(field).value == '1' || $(field).value == '01')
	  		$(dvId).style.display='block';
	  	else
	  		$(dvId).style.display='none';
	  }
/******************current possition js *************/
/*********Hounor Award js************/
	function validateHonoursAwards(){		
		var isReturnFalse = true;	
		divArray = new Array('divtxtHonoursAwardsName','divtxtHonoursAwardsDesc','divYear');		
		fieldArray = new Array('txtHonoursAwardsName','txtHonoursAwardsDesc','selYearFromTo','selYearTo');				
		unSetVal(divArray); 	// function for unset the div error				
		var regex=/^[0-9A-Za-z\s-.,]+$/; 		
		var date = new Date();
		var curryear = date.getYear();				
		var browserName=navigator.appName;		
		if(browserName=='Netscape'){
			if(curryear > 100)
				curryear = 2000 - 100 + curryear;	
		}		
		var honourName = $('txtHonoursAwardsName').value;
		honourName = honourName.replace(/(<([^>]+)>)/ig,''); 		
		var honourDesc = $('txtHonoursAwardsDesc').value;
		honourDesc = honourDesc.replace(/(<([^>]+)>)/ig,''); 	
		if (trim(honourName) == 0 || trim(honourName)==''){		
				setValue('divtxtHonoursAwardsName','Please enter the honors/awards name.');									
				$('divtxtHonoursAwardsName').style.display = 'block';	
				isReturnFalse = false;		
		} 		
		if (honourDesc.length > 500){					
				setValue('divtxtHonoursAwardsDesc','Description should not be more than 500 letters.');	
				isReturnFalse = false;	
		}				
		if (honourDesc.length > 500){					
				setValue('divtxtHonoursAwardsDesc','Description should not be more than 500 letters.');									
				isReturnFalse = false;						
		} 		
		if (document.getElementById('year_fromTo_fromTo').checked){							
			var fromyear=trim(document.getElementById('selYearFromTo').value);			
			var toyear=trim(document.getElementById('selYearTo').value);			
			var regex = /^(1|2)/;					
			if ((trim($('selYearFromTo').value))=='' || (trim($('selYearFromTo').value)=='Year'))			{				
				setValue('divYear','Please enter valid year(s).');					
				isReturnFalse = false;
			}else if ((trim($('selYearTo').value))=='' || (trim($('selYearTo').value)=='Year')){				
				setValue('divYear','Please enter the year.');					
				isReturnFalse = false;
			}else if (fromyear.length != 4 || !regex.test(fromyear)){
				setValue('divYear','Year entered should be a valid year.(i.e. 2005)');				
					isReturnFalse = false;
			}else if(document.getElementById('selYearTo').value != 'present'){ 
				if ((trim($('selYearFromTo').value)) >= (trim($('selYearTo').value))){				
					setValue('divYear','Year from cannot be greater than Year to.');				
					isReturnFalse = false;
				}else if (trim($('selYearTo').value) > curryear){				
					setValue('divYear','Year entered cannot be greater than current year ');				
					isReturnFalse = false;
				}else if(fromyear.length != 4 || toyear.length != 4 ){				
					setValue('divYear','Year entered should be a valid year.(i.e. 2005)');				
					isReturnFalse = false;
				}else if(!regex.test(fromyear) || !regex.test(toyear)){				
					setValue('divYear','Year entered should be a valid year.(i.e. 2005)');				
					isReturnFalse = false;
				}
			}
			if (trim($('selYearFromTo').value) > curryear){				
				setValue('divYear','Year entered cannot be greater than current year ');			
				isReturnFalse = false;
			}		
		}
		if (document.getElementById('year_year_year').checked){
			var year=trim(document.getElementById('selYearFromYear').value);
			var regex = /^(1|2)/;
			if ((trim($('selYearFromYear').value))=='' || (trim($('selYearFromYear').value)=='Year')){				
				setValue('divYear','Please enter the year.');					
				isReturnFalse = false;
			}else if(year > curryear){				
				setValue('divYear','Year entered cannot be greater than current year.');				
				isReturnFalse = false;
			}else if(year.length != 4 || !regex.test(year)){				
				setValue('divYear','Year entered should be a valid year.(i.e. 2005)');				
				isReturnFalse = false;
			}	 
		} 	
		if(!isReturnFalse){
			$('alert_messages').style.display = 'none';			
		}
		return isReturnFalse;
   }   
	function validateHonoursAwardsNext(){	
		var dateYear = trim($('selYearFromYear').value);
		var dateYearFrom = trim($('selYearFromTo').value);
		var dateYearTo = trim($('selYearTo').value);
		var honourName = $('txtHonoursAwardsName').value;
		honourName = honourName.replace(/(<([^>]+)>)/ig,'');
		valEntered = false;		
		if(dateYear=='Year'){ dateYear='';	}
		if(dateYearFrom=='Year'){ dateYearFrom='';	}
		if(dateYearTo=='Year'){	dateYearTo='';	}				
		if (trim(honourName)!=0 || trim(honourName)!=''){ valEntered = true; }		
		if($('year_year_year').checked && dateYear != ''){ valEntered = true;}		
		if($('year_fromTo_fromTo').checked && (dateYearFrom != '' || dateYearTo != '') ){ valEntered = true; }								
		if(valEntered){
			setElementValue('goNext',1);
			return validateHonoursAwards();
		} else {			
			new Ajax.Updater('mp-contentWrapper', siteURLPubl, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper');}, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');profileMenuActive('lnkPublications');}});;
		}		
		return false;
	}
/*********Hounor Award js************/
/***********************profile  Education js ***************************************/
	function validateEducationNext(){		
		var valEntered = false;
		var awardedYr = trim($('txtYearAwarded').value);		
		if(awardedYr=='Year'){
			awardedYr='';
		}				
		if( (trim($('txtDegreesAwarded').value)!=0 && trim($('txtDegreesAwarded').value)!='') || trim($('txtDegreeName').value)!='' ){			
			valEntered = true;			
		}		
		if ( (trim($('txtUniversity').value)!=0 && trim($('txtUniversity').value)!='') || trim($('txtUniversityAuto').value)!=''){
			valEntered = true;			
		}
		if ( trim(awardedYr)!=0 || trim(awardedYr)!='' ){
			valEntered = true;			
		}			
		if($('uploadThesisId').checked == true){			
			if (trim($('txtThesisTitle').value)!=0 && trim($('txtThesisTitle').value)!=''){
				valEntered = true;				
			}		
		}		
		if(valEntered){
			setElementValue('goNext',1);			
			return validateEducation();			
		} else {			
			new Ajax.Updater('mp-contentWrapper', siteURLReas, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper');}, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');profileMenuActive('lnkResearch');}});;
		}		
		
		return false;
  }
	function getIdFromString(str){
		temp =  str.split('_');
		temp = temp[temp.length-1];
		return temp;
	}	
	function valAdvisorsCheckE(){
		var totalFields = parseInt($('totalAuthor').value);
		var formName = 	document.educationForm;
		for(i=0; i < formName.elements.length; i++){
			if(formName.elements[i].name=='txtAdvisorFname[]'){
				var fId = formName.elements[i].id
				var actId = getIdFromString(fId);
				var lId = 'lname_'+actId;								
				if( (trim($(fId).value)=='' && trim($(lId).value)!='') || (trim($(lId).value)=='' && trim($(fId).value)!='') ){
					return false;
				}				
			}
		}
		return true;
	}	
	function addAdvisorsE(){
  				
		var container = $('ulAdvisor');
		var container1 = $('ulAnotherAdv');
		var clone = container.cloneNode(true);			
		
		var lastAdvId = parseInt($('totalAuthor').value) +1;
		$('totalAdvisor').value = lastAdvId;
		
		clone.id ='ulAdvisor'+lastAdvId;
		clone.style.display ='block';		
		var newDiv = '<div  class=\'Remove\'> <a href=\'javascript:remAdvisorsE("ulAdvisor'+lastAdvId+'")\'>Remove</a></div>';
		
		var tempString = clone.innerHTML;
		
		if(navigator.userAgent.indexOf('MSIE') != -1 ){
			var newTempString = tempString.replace('<DIV class=Add><A href="javascript:addAdvisorsE()">Add another</A></DIV>', newDiv);
		} else {
			var newTempString = tempString.replace('<div class="Add"><a href="javascript:addAdvisorsE()">Add another</a></div>', newDiv);
		}
		clone.innerHTML = newTempString;
		
		container1.insertBefore(clone, container1.lastChild);		
	}	
	function remAdvisorsE(id){	$(id).remove();	}	
	function valAdvisorsE(){				
		var totalFields = parseInt($('totalAdvisor').value);
		var formName = 	document.educationForm;		
		for(i=0; i < formName.elements.length; i++){ 		
			if(formName.elements[i].name=='txtAdvisorFname[]' || formName.elements[i].name=='txtAdvisorLname[]'){
				if(formName.elements[i].value==''){				
					return false;
				}						
			}		
		}
		return true;				
	} 	
	function valSpecialAdvisorsE(){	
		var regex=/^[A-Za-z\-\']+$/;
		var totalFields = parseInt($('totalAuthor').value);
		var formName = 	document.educationForm;
		for(i=0; i < formName.elements.length; i++){ 		
			if(formName.elements[i].name=='txtAdvisorFname[]' || formName.elements[i].name=='txtAdvisorMname[]' || formName.elements[i].name=='txtAdvisorLname[]'){			
				if( trim(formName.elements[i].value)!='' && !regex.test(trim(formName.elements[i].value))){					
					return false;
				}
			}						
		}
		return true;
	}
	function getSelectionIdEN(text, li){  $('txtUniversity').value=li.id;  }
    
    function getSelectionIdDEP(text, li){ $('txtDepartment').value=li.id;    }	
	function getLICount(autoID){	
		var autoID = 'txtUniversityAuto';				
		var allULs = document.getElementsByTagName('ul');
		var ulElementID = 'university_auto_complete_ul';
		var focusElemnt = $(autoID+'_auto_complete');				
		for(i=0; i<allULs.length; i++){			
			if(allULs[i].id == ulElementID){			
				var ulElem = $('university_auto_complete_ul');
				lis=$('university_auto_complete_ul').getElementsByTagName('li');
				n=lis.length-1;
				if (null != focusElemnt) {					
					if(ulElem.lastChild && ulElem.lastChild.value>9){				
						focusElemnt.className = 'auto_complete_height auto_complete';			
					} else {
						focusElemnt.className = 'auto_complete';			
					}
				}				
				
			}
		}						
	}				
	function getLICountRepeat(autoID){	setInterval('getLICount(\''+autoID+'\')', 500);	}		
	function getLICountDept(autoID){	
		var autoID = 'txtDepartmentAuto';		
		var allULs = document.getElementsByTagName('ul');
		var ulElementID = 'department_auto_complete_ul';
		var focusElemnt = $(autoID+'_auto_complete');						
		for(i=0; i<allULs.length; i++){			
			if(allULs[i].id == ulElementID){
				var ulElem = $('department_auto_complete_ul');
				lis=$('department_auto_complete_ul').getElementsByTagName('li');
				n=lis.length-1;						
				if(ulElem.lastChild && ulElem.lastChild.value>9){				
					focusElemnt.className = 'auto_complete_height auto_complete';			
				} else {
					focusElemnt.className = 'auto_complete';			
				}				
			}
		}	
	}			
	
	function getLICountRepeatDept(autoID){	setInterval('getLICountDept(\''+autoID+'\')', 1);}		
	function errorsuppressor(){	return true;}		
	function getResearchLICount(autoID){	
		var autoID = 'txtFriends';										
		var allULs = document.getElementsByTagName('ul');
		var ulElementID = 'university_auto_complete_ul';
		var focusElemnt = $(autoID+'_auto_complete');						
		focusElemnt.style.width = '200px';		
		for(i=0; i<allULs.length; i++){	
			if(allULs[i].id == ulElementID){			
				var ulElem = $('university_auto_complete_ul');
				lis=$('university_auto_complete_ul').getElementsByTagName('li');
				n=lis.length-1;								
				if(ulElem.lastChild && ulElem.lastChild.value>9){				
					focusElemnt.className = 'auto_complete_height auto_complete';			
				} else {
					focusElemnt.className = 'auto_complete';			
				}				
			}
		}				
		
	}		
	
	function getProtocolLICount(autoID){
		var focusElemnt;
		var autoID = 'txt_ProtocolTags';										
		var allULs = document.getElementsByTagName('ul');
		var ulElementID = 'university_auto_complete_ul';
		focusElemnt = $(autoID+'_auto_complete');	
		if(focusElemnt) {
		focusElemnt.style.width = '200px';		
		for(i=0; i<allULs.length; i++) {	
			if(allULs[i].id == ulElementID){			
				var ulElem = $('university_auto_complete_ul');
				lis=$('university_auto_complete_ul').getElementsByTagName('li');
				n=lis.length-1;								
				if(ulElem.lastChild && ulElem.lastChild.value>9){				
					focusElemnt.className = 'auto_complete_height auto_complete';			
				} else {
					focusElemnt.className = 'auto_complete';			
				}				
			}
		}				
		}
	}	

	function getResearchLICountRepeat(autoID){	setInterval('getResearchLICount(\''+autoID+'\')', 500);	}
	function getProtocolLICountRepeat(autoID){	setInterval('getProtocolLICount(\''+autoID+'\')', 500);	}
	function getSelectionIdCPos(text, li){ $('txtUniversity').value=li.id; }	    
    function getDegreeSelectionId(text, li){    $('txtDegreesAwarded').value=li.id;  }  
	function validateLenAbstract(objCountName){		
		var charCount=2500;
		obj=$(objCountName);
		msgnowLen=parseInt(find_new_lines(obj.value))+parseInt(obj.value.length);
		if(msgnowLen <=charCount){
			rem=charCount-msgnowLen;
			$('textareaAbsCount').innerHTML=rem+ ' letters remaining';
		} else {
			rem=Math.abs(charCount-msgnowLen);
			$('textareaAbsCount').innerHTML='<font color=red>Exceeded Maximum by '+rem+' letters</font>';
		}
	}   	
/***********************profile  Education js ***************************************/
/*********************** Reasearch Js ******************************/
	function validateLenResearch(objCountName){
		var charCount=1500;
		obj=$(objCountName);		
		msgnowLen=parseInt(find_new_lines(obj.value))+parseInt(obj.value.length);		
		if(msgnowLen <=charCount){
			rem=charCount-msgnowLen;
			$('textareaCount').innerHTML=rem+ ' letters remaining';
		} else {
			rem=Math.abs(charCount-msgnowLen);
			$('textareaCount').innerHTML='<font color=red>Exceeded Maximum by '+rem+' letters</font>';
		}
	}	
	function valResearch(){	
		var isReturnFalse = true;		
		divArray = new Array('divDesc');
		unSetVal(divArray); // function for unset the div error		
		fieldArray = new Array('txtDesc');
		msgnowLen=parseInt(find_new_lines($('txtDesc').value))+parseInt($('txtDesc').value.length);		
		if (msgnowLen > 1500){
			setValue('divDesc','Description should not be more than 1500 letters.');					
				isReturnFalse = false;
		}		
		return isReturnFalse;
	}	
	function valResearchNext(){		
		var valEntered = true;		
		if(valEntered){
			setElementValue('goNext',1);
			return valResearch();
		} else {			
			new Ajax.Updater('mp-contentWrapper', siteURLHonAw, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper');}, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');profileMenuActive('lnkHonor');}});;
		}		
		return false;		
	}
/*********************** Reasearch Js ******************************/
/*********************** presentation Js ******************************/
	var posterAbstractMaxChar = 2500;
	var allPosterFileCountArray = new Array();	 
	function validatePresentation(){		
		var isReturnFalse = true;
		var re = new RegExp(/^[1/2]/);		
		var browserName=navigator.appName;		
		var dateYear = trim($('txtYear').value);
		divArray = new Array('divTitle','divMonth','divYear','divErrAuthor');
		unSetVal(divArray); // function for unset the div error		
		fieldArray = new Array('txtTitle','txtMonth','txtYear');
		var regex=/^[0-9A-Za-z\s\.\(\/\)\-\%\=\[\]\:\&\,\;\!]+$/;
		var date = new Date();
		var curryear = date.getYear();
		if(browserName=='Netscape'){
			if(curryear > 100)
				curryear = 2000 - 100 + curryear;	
		}		
		if( (trim($('txtTitle').value)==0 || trim($('txtTitle').value)=='') ){
			setValue('divTitle','Please enter the title.');			
			isReturnFalse = false;		
		}		
		if (trim($('txtMonth').value) == 0 || trim($('txtMonth').value)==''){				
				setValue('divMonth','Please select a month.');				
				isReturnFalse = false;				
		}	
		if (trim($('txtYear').value) == 0 || trim($('txtYear').value)==''){		
				setValue('divYear','Please enter the year.');				
				isReturnFalse = false;
		}else if(trim($('txtYear').value)=='Year') {				
				setValue('divYear','Please enter the year.');				
				isReturnFalse = false;
		}else if(dateYear>curryear){
			setValue('divYear','Entered Year cannot be greater than current Year.');	
			isReturnFalse = false;
		}else if( dateYear.length != 4 || !dateYear.match(re) ){
			setValue('divYear','Please enter a valid Year. (i.e. 2005)');	
			
			isReturnFalse = false;
		}							
		if (!valAuthorsPP()){			
			setValue('divErrAuthor','Please enter first and last name for author(s)');
			isReturnFalse = false;
		} else if (!valSpecialAuthorsPP()){				
			setValue('divErrAuthor','Special characters & middle spaces are not allowed in Author');
			isReturnFalse = false;			
		}		
		if(!isReturnFalse){	$('alert_messages').style.display = 'none'; 	}		
		if(!valPosterAbstract()){ isReturnFalse = false;}		
		
		return isReturnFalse;
  }  
	function validatePresentationNext(){		
		var valEntered = false;		
		if( trim($('txtTitle').value)!='' ){ valEntered = true;	 }		
		if ( trim($('txtMonth').value)!=0 ){ valEntered = true;	}		
		if ( trim($('txtYear').value)!='' && trim($('txtYear').value)!='Year' ){ valEntered = true;	}		
		if (valAuthorsPP()){ valEntered = true; }		
		if(valEntered){
			setElementValue('goNext',1);
			return validatePresentation();
		} else {		
			new Ajax.Updater('mp-contentWrapper', siteURLPerso, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper');}, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');profileMenuActive('lnkPersonal');}});;
		}		
		return false;	
	}   
  function addAuthorsP(){  	
		 var container = $('ulAuthor1'); //document.getElementById('ulAdvisor1');
		 var container1 = $('ulAnotherAuth'); //document.getElementById('ulAnotherAuth');		 		 
		 var lastAdvId = parseInt($('totalAuthor').value) +1;
		 $('totalAuthor').value = lastAdvId;		 
		 var clone = container.cloneNode(true);
		 clone.id ='ulAuthor'+lastAdvId;		 		 
		 var newDiv = '<div id="add_remove_'+lastAdvId+'" class=\'Remove\'> <a href=\'#\' onclick=\'remAuthorsP("ulAuthor'+lastAdvId+'")\' style=\'cursor:pointer\'>Remove</a></div>';			
		var tempString = clone.innerHTML;
		var newTempString = tempString.replace('<div class="Add"><a href="#" onclick="addAuthorsP()">Add another</a></div>', newDiv);
		clone.innerHTML = newTempString;		 
		 clone.style.display ='block';
		 container1.insertBefore(clone, container1.lastChild);			
		 var newListelement = document.createElement('li');
		 newListelement.innerHTML = '<div class=\'label-field\'>&nbsp;</div><div class=\'input-field\' ><a href=\'#\' onclick=\'remAuthorsP("ulAuthor'+lastAdvId+'")\'>Remove</a></div>';		
	}
	function valAuthorsP(){
		var totalFields = parseInt($('totalAuthor').value);	
		var formName = 	document.presentationForm;
		for(i=0; i < formName.elements.length; i++){ 
			if(formName.elements[i].name=='txtAuthorFname[]' || formName.elements[i].name=='txtAuthorLname[]'){
				if(trim(formName.elements[i].value=='')){	return false; }			
			}			
		}
		return true;
	}  
	function valSpecialAuthorsPP(){
		var regex=/^[A-Za-z\-\']+$/;
		var totalFields = parseInt($('totalAuthor').value);
		var formName = document.presentationForm;		
		for(i=0; i < document.presentationForm.elements.length; i++){ 		
			if(formName.elements[i].name=='txtAuthorFname[]' || formName.elements[i].name=='txtAuthorMname[]' || formName.elements[i].name=='txtAuthorLname[]'){			
				if( (trim(formName.elements[i].value)) !='' && !regex.test(trim(formName.elements[i].value))){					
					return false;
				}
			}						
		}
		return true;		
	}     
  	function addAuthorsPP(){  				
		var container = $('ulAuthor');
		var container1 = $('ulAnotherAuth');
		var clone = container.cloneNode(true);		
		var lastAdvId = parseInt($('totalAuthor').value) +1;
		$('totalAuthor').value = lastAdvId;		
		clone.id ='ulAuthor'+lastAdvId;
		clone.style.display ='block';
		container1.insertBefore(clone, container1.lastChild);			
		var newDiv = '<div  class=\'Remove\'> <a href=\'javascript:remAuthorsPP("ulAuthor'+lastAdvId+'")\'>Remove</a></div>';		
		var tempString = clone.innerHTML;		
		if(navigator.userAgent.indexOf('MSIE') != -1 ){
			var newTempString = tempString.replace('<DIV class=Add><A href="javascript:addAuthorsPP()">Add another</A></DIV>', newDiv);
		} else {
			var newTempString = tempString.replace('<div class="Add"><a href="javascript:addAuthorsPP()">Add another</a></div>', newDiv);
		}
		clone.innerHTML = newTempString;
	}	
	function remAuthorsPP(id){	$(id).remove(); }	
	function valAuthorsPP(){					
		var totalFields = parseInt($('totalAuthor').value);
		var formName = 	document.presentationForm;
		var contForms = 0;
		for(i=0; i < formName.elements.length; i++){
			if(formName.elements[i].name=='txtAuthorFname[]' || formName.elements[i].name=='txtAuthorLname[]'){				
				contForms++;
				if(formName.elements[i].value==''){				
					return false;
				}						
			}		
		}		
		if(contForms==0) return false;			
		return true;				
	} 
		
  	var Count = 1;   // count is used for count to number of file to be upload	
	function setMyFilenamePoster(filename,newfilename, fileCnt,fileForm){	
		var fCnt = parseInt(fileCnt);		
		var ni = document.getElementById(fileForm);
		var divCnt = 1;		
		if($('filecount').value){
			$('filecount').value = parseInt($('filecount').value) + 1;			
			divCnt = $('filecount').value;		
		} else {
			$('filecount').value = 1;
		}		
		if( allPosterFileCountArray != ''){
			var maxVl =  parseInt(maxArrayValuePost(allPosterFileCountArray))+1;
			divCnt = maxVl;
		}		
		var newdiv = document.createElement('div');		
		newdiv.setAttribute('id','myDiv'+divCnt);		
		allPosterFileCountArray.push(divCnt);			
		var newDivHTML = divCnt+'- '+filename+'&nbsp;&nbsp;<input name=\'oldfilename[]\' type=\'hidden\' value=\''+filename+'\'><input name=\'newfilename[]\' type=\'hidden\' value=\''+newfilename+'\'><a href=\'javascript:delMyfilePoster("myDiv'+divCnt+'", "'+fCnt+'", "'+fileForm+'", "'+divCnt+'");\' title=\'Remove\' alt=\'Remove\'>X</a>';		
		newdiv.innerHTML = newDivHTML;
	  	ni.appendChild(newdiv);		
		Count++;	  
	}	
	// function to delete the uploaded file 
	function delMyfilePoster(id, fileCnt, fileForm, divCnt){	
		document.getElementById(id).innerHTML='';		
		allPosterFileCountArray.splice(allPosterFileCountArray.indexOf(divCnt).value,1);
		if($('filecount').value && $('filecount').value > 0)
	 		$('filecount').value = parseInt($('filecount').value) - 1;			
	 	if($('filecount').value < fileCnt){	 		
	 	 	var childElement = window.frames['iframeContainer'].document.getElementById('txtFile');
	 	 	childElement.disabled=false;
	 	}		
		var d = document.getElementById(fileForm);
		var olddiv = document.getElementById(id);
		d.removeChild(olddiv);		
	}	
	function reduceCount(fileCnt){
		if($('filecount').value && $('filecount').value > 0){
	 		$('filecount').value = parseInt($('filecount').value) - 1;
		}
		allPosterFileCountArray.splice(allPosterFileCountArray.indexOf(fileCnt).value,1);		
	}			
	function maxArrayValuePost(listSalery){	
		var j=0;
		for(i=0;i<listSalery.length;i++){
			if(listSalery[i]>listSalery[j])
				j=i;
		}
		return listSalery[j]
	}	
	function reloadFramePoster(frameId, elmentId) {
		var f = document.getElementById(frameId);
		f.src = f.src;		
	}	
	function validateLenPoster(objCountName){
		var charCount=2500;
		obj=$(objCountName);
		msgnowLen=parseInt(find_new_lines(obj.value))+parseInt(obj.value.length);
		if(msgnowLen <=charCount){
			rem=charCount-msgnowLen;
			$('textareaCount').innerHTML=rem+ ' letters remaining';
		} else {
			rem=Math.abs(charCount-msgnowLen);
			$('textareaCount').innerHTML='<font color=red>Exceeded Maximum by '+rem+' letters</font>';
		}
	}	
	function valPosterAbstract(){	
		var isReturnFalse = true;		
		msgnowLen=parseInt(find_new_lines($('txtAbstract').value))+parseInt($('txtAbstract').value.length);	
		if (msgnowLen > posterAbstractMaxChar){
			setValue('divAbstract','Posters/Talks Abstract should not be more than '+posterAbstractMaxChar+' letters.');					
				isReturnFalse = false;					
		}
		return isReturnFalse;	
	}
/*********************** presentation Js ******************************/
/*********************** Publication Js ******************************/
	function valPublication(){
			var isReturnFalse = true;		
				divArray = new Array('divPubType','divTitle','divPublisher','divErrAuthor','divYear','divJournal','divBooktitle','divUrl','divErrEditor','divMonth');
				unSetVal(divArray); // function for unset the div error		
				fieldArray = new Array('txtTitle','txtPublisher','txtJournal','txtBooktitle');
				var regex=/^[0-9A-Za-z\s\.\(\/\)\-\%\=\[\]\:\&\,]+$/;				
				if (trim($('selPubType').value) == 0 || trim($('selPubType').value)==''){				
						setValue('divPubType','Please select a publication type.');						
						isReturnFalse = false;			
				} else {		
				var pulicTitle = $('txtTitle').value;
				pulicTitle = pulicTitle.replace(/(<([^>]+)>)/ig,''); 		
				if (trim(pulicTitle) == 0 || trim(pulicTitle)==''){				
						setValue('divTitle','Please enter the title.');				
						isReturnFalse = false;			
				} 					
				if(trim($('selPubType').value)=='book') {					
					var pulicTxtPubli = $('txtPublisher').value;
					pulicTxtPubli = pulicTxtPubli.replace(/(<([^>]+)>)/ig,''); 					
					if (trim(pulicTxtPubli) == 0 || trim(pulicTxtPubli)==''){				
						setValue('divPublisher','Please enter the name of the Publisher.');		
						isReturnFalse = false;			
					} else if(!regex.test(pulicTxtPubli)) {
						setValue('divPublisher','Special characters are not allowed.');				
						isReturnFalse = false;	
					}
				} else if(trim($('selPubType').value)=='journal') {					
					var pulicJournal = $('txtJournal').value;
					var month = $('txtMonth').value;
					pulicJournal = pulicJournal.replace(/(<([^>]+)>)/ig,''); 					
					if (trim(pulicJournal) == 0 || trim(pulicJournal)==''){				
						setValue('divJournal','Please enter the name of the Journal.');				
						isReturnFalse = false;			
					} else if(!regex.test(pulicJournal)) {
						setValue('divJournal','Special characters are not allowed.');				
						isReturnFalse = false;	
					}
					if (trim(month) == 0 || trim(month)==''){				
						setValue('divMonth','Please select a month.');				
						isReturnFalse = false;			
					}					
					msgnowLen=parseInt(find_new_lines($('txtAbstract').value))+parseInt($('txtAbstract').value.length);			
					if (msgnowLen > 2000){				
						setValue('divAbstract','Abstract should not be more than 2000 letters.');					
							isReturnFalse = false;
					}						
				} else if(trim($('selPubType').value)=='conference'){					
					var pulicBookTitle = $('txtBooktitle').value;
					pulicBookTitle = pulicBookTitle.replace(/(<([^>]+)>)/ig,'');					
					if (trim(pulicBookTitle) == 0 || trim(pulicBookTitle)==''){				
						setValue('divBooktitle','Please enter the name of the Conference.');				
						isReturnFalse = false;			
					} else if(!regex.test(pulicBookTitle)) {
						setValue('divBooktitle','Special characters are not allowed.');				
						isReturnFalse = false;	
					}
					msgnowLen=parseInt(find_new_lines($('txtAbstract').value))+parseInt($('txtAbstract').value.length);			
					if (msgnowLen > 2000){				
						setValue('divAbstract','Abstract should not be more than 2000 letters.');					
							isReturnFalse = false;
					}		
				}				
				var regex1 = /^(1|2)/;
			    var year=trim($('myYear').value);			    
			    var date=new Date();
				var curyear=date.getYear();				
				var browserName=navigator.appName;				
				if(browserName=='Netscape'){
					if(curyear>100)	curyear = 2000 - 100 + curyear;
				}								
				if ((year.length==0) || (year=='') || (year=='Year')){				
						setValue('divYear','Please enter year.');				
						isReturnFalse = false;			
				}else if(year.length != 4){
						setValue('divYear','Year entered should be a valid Year.(i.e. 2005)');							
						isReturnFalse = false;		
				}else if(year > curyear){
					setValue('divYear','Year entered cannot be greater than current Year.');			
					isReturnFalse = false;	
				}else if(!regex1.test(year)){
					setValue('divYear','Year entered should be a valid Year.(i.e. 2005)');			
					isReturnFalse = false;	
				}				
				if($('txtURL').value !='http://' && $('txtURL').value !='http://' && trim($('txtURL').value) !=''){
					if(!urlValidate($('txtURL').value)){
						setValue('divUrl','Invalid url.');
						isReturnFalse = false;		
					}
				}
				if (!valAuthors()){				
					setValue('divErrAuthor','Please enter first name and last name of author(s).');				
					isReturnFalse = false;			
				}else if (!valSpecialAuthors()){				
						setValue('divErrAuthor','Special characters & middle spaces are not allowed in Advisor.');
						isReturnFalse = false;			
				}				
				if(!valEditorsCheckE()){		
					setValue('divErrEditor','Please enter first name and last name of editor(s)');				
					isReturnFalse = false;
				}else if (!valSpecialEditors()){				
						setValue('divErrEditor','Special characters & middle spaces are not allowed in Editor.');
						isReturnFalse = false;			
				}				
			}				
				return isReturnFalse;
		}

	function valPublicationNext(){	
		valEntered = false;
		var year3=trim($('myYear').value);	
		var pulicTitle = $('txtTitle').value;
		pulicTitle = pulicTitle.replace(/(<([^>]+)>)/ig,''); 		
		if (trim(pulicTitle)!=0 || trim(pulicTitle)!=''){	valEntered = true; }	
		if ( year3!='' && year3!='Year' ){ valEntered = true; }
		if(trim($('selPubType').value)=='book') {
			var pulicTxtPubli = $('txtPublisher').value;
			pulicTxtPubli = pulicTxtPubli.replace(/(<([^>]+)>)/ig,''); 		
			if (trim(pulicTxtPubli)!=0 || trim(pulicTxtPubli)!=''){				
				valEntered = true;			
			}			
		} else if(trim($('selPubType').value)=='journal') {		
			var pulicJournal = $('txtJournal').value;
			pulicJournal = pulicJournal.replace(/(<([^>]+)>)/ig,''); 		
			if (trim(pulicJournal)!=0 || trim(pulicJournal)!=''){				
				valEntered = true;			
			}					
		} else if(trim($('selPubType').value)=='conference'){		
			var pulicBookTitle = $('txtBooktitle').value;
			pulicBookTitle = pulicBookTitle.replace(/(<([^>]+)>)/ig,'');		
			if (trim(pulicBookTitle)!=0 || trim(pulicBookTitle)!=''){				
				valEntered = true;			
			}		
		}
		if (valAuthors()){	valEntered = true; } 	
		if(valEntered){
			setElementValue('goNext',1);
			return valPublication();
		} else {		
			new Ajax.Updater('mp-contentWrapper', siteURLPost, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper');}, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');profileMenuActive('lnkPresentation');}});;
		}
		return false;	
	}

function addAuthors(){
	 var container = document.getElementById('ulAuthor');
	 var container1 = document.getElementById('ulAnotherAuth');
	 var clone = container.cloneNode(true);				 
	 var lastAuthId = parseInt($('totalAuthor').value) +1;
	 $('totalAuthor').value = lastAuthId;	 
	 clone.id ='ulAuthor'+lastAuthId;
	 clone.style.display ='block';
	 container1.insertBefore(clone, container1.lastChild);		
	 var newDiv = '<div  class=\'Rmv\'> <a href=\'javascript:remAuthors("ulAuthor'+lastAuthId+'")\'><img src="../images/icnRemove.gif" alt="Remove" title="Remove"></a></div>';	 
	var fDiv = 'id="fname_'+lastAuthId+'"';
	var lDiv = 'id="lname_'+lastAuthId+'"';	 
	var tempString = clone.innerHTML;
	if(navigator.userAgent.indexOf('MSIE') != -1 ){					
			var newTempString = tempString.replace('<DIV class=Rmv><A href="javascript:remAuthors(\'ulAuthor\')">Remove</A></DIV>', newDiv);		   	
			var newTempString = newTempString.replace('id=txtAdvisorFname', fDiv);
			var newTempString = newTempString.replace('id=txtAdvisorLname', lDiv); 			
		} else {			
			var newTempString = tempString.replace('<div class="Rmv"><a href="javascript:remAuthors(\'ulAuthor\')">Remove</a></div>', newDiv);			
			var newTempString = newTempString.replace('id="txtAdvisorFname"', fDiv);
			var newTempString = newTempString.replace('id="txtAdvisorLname"', lDiv);												
		}	
	clone.innerHTML = newTempString;
}

	function remAuthors(id){ $(id).remove();}
	
	function valAuthors(){
		var totalFields = parseInt($('totalAuthor').value);	
		var contForms = 0;	
		var tempVal = '';
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].name=='txtAuthorFname[]' || document.frmPulication.elements[i].name=='txtAuthorLname[]'){
				contForms++;
				tempVal = trim(document.frmPulication.elements[i].value);
				tempVal = tempVal.replace(/(<([^>]+)>)/ig,'');
				if(tempVal=='') {				
					return false;
				}
			}
		}
		if(contForms==0)
				return false;
		return true;
	} 
	function valSpecialAuthors(){
		var regex=/^[A-Za-z\-\']+$/;
		var totalFields = parseInt($('totalAuthor').value);		
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].name=='txtAuthorFname[]' || document.frmPulication.elements[i].name=='txtAuthorLname[]'){
				if(!regex.test(trim(document.frmPulication.elements[i].value))){				
					return false;
				}
			}
		}
		return true;
	}

	function valSpecialEditors(){
		var regex=/^[A-Za-z\-\']+$/;
		var totalFields = parseInt($('totalEditor').value);		
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].name=='txtEditorFname[]' || document.frmPulication.elements[i].name=='txtEditorLname[]'){			
				if(trim(document.frmPulication.elements[i].value) != ''){
					if(!regex.test(trim(document.frmPulication.elements[i].value)))	{					
						return false;
					}
				}
			}
		}
		return true;
	}  	
	function addAdvisors(){  	
			 var container = $('ulAdvisor1'); //document.getElementById('ulAdvisor1');
			 var container1 = $('ulAnotherAdv'); //document.getElementById('ulAnotherAuth');
			 var clone = container.cloneNode(true);	
			 var lastAdvId = parseInt($('totalAdvisor').value) +1;
			 $('totalAdvisor').value = lastAdvId;		 
			 clone.id ='ulAdvisor'+lastAdvId;
			 clone.style.display ='block';
			 container1.insertBefore(clone, container1.lastChild);			
			 var newListelement = document.createElement('li');
			newListelement.innerHTML = '<div class=\'label-field\'>&nbsp;</div><div class=\'input-field\' ><a href=\'javascript:void(0);\' onclick=\'remAdvisors("ulAdvisor'+lastAdvId+'")\'>Remove</a></div>';
			 clone.insertBefore(newListelement, clone.lastChild);	 
			
		}
	
	function remAdvisors(id){ $(id).remove(); }	
	function valAdvisors(){
		var totalFields = parseInt($('totalAdvisor').value);		
		for(i=0; i < document.currentPositionForm.elements.length; i++){ 
			if(document.currentPositionForm.elements[i].name=='txtAdvisorFname[]' || document.currentPositionForm.elements[i].name=='txtAdvisorLname[]'){				
				if(trim(document.currentPositionForm.elements[i].value=='')){					
					return false;
				}				
			}
		}
		return true;
	} 
  // FUNCTION FOR ADD THE FILE NAMES
  	var Count = 1;   // count is used for count to number of file to be upload
	function setMyFilename(filename,newfilename,fileCnt,fileForm){		
		if($('filecount').value){	 		
			$('filecount').value = parseInt($('filecount').value) + 1;	 		
			var Count = $('filecount').value;
		}
	 	else{
	 		$('filecount').value = 1;
	 		var Count = $('filecount').value;
	 	}	 		
	 	$('fileForm').innerHTML += '<div style=\'position: relative; left: 0px; top: -15px;\' id=\'myDiv'+Count+'\'>'+$('filecount').value+'- '+filename+'&nbsp;&nbsp;<input name=\'oldfilename[]\' type=\'hidden\' value=\''+filename+'\'><input name=\'newfilename[]\' type=\'hidden\' value=\''+newfilename+'\'><a href=\'javascript:delMyfile("myDiv'+Count+'","'+fileCnt+'","'+fileForm+'");\' title=\'Remove\' alt=\'Remove\'>X</a><\div>';	 	
	  Count++;
	}
	
	// function to delete the uploaded file 
	function delMyfile(id, fileCnt, fileForm){
		document.getElementById(id).innerHTML='';
		subsFileCount(fileCnt);		
		var d = document.getElementById(fileForm);
		var olddiv = document.getElementById(id);
		d.removeChild(olddiv);		
	}	
	// function for substract the file count
	function subsFileCount(fileCnt){
		if($('filecount').value && $('filecount').value > 0)
	 		$('filecount').value = parseInt($('filecount').value) - 1;	 	
	 	if($('filecount').value < fileCnt){ 
			if( null !== window.frames['iframeContainer'].document ){
				var childElement = window.frames['iframeContainer'].document.getElementById('txtFile');
				if(null !== childElement){
					childElement.disabled=false;
				}	 	 	
			}				
	 	 	//document.getElementById('maxmsg').style.display='none';
	 	}
	}	
	function changePublication(id){
		var arrAllFiels = new Array('liPublisher','liJournal','liBooktitle','liEditor','liSeries','liPage','liMonth','liAbstract','numberLabelPages','numberLabelIssueNumber','numberLabelNumber','liNumberField','liEditorBox','liEditorEdition','liURL','pageLabelPages','pageLabelJourPages','spanExampleText');		
		var arrBookFields = new Array('liPublisher','numberLabelPages','liNumberField','liEditorBox','liEditorEdition','liURL');
		var arrJournalFields = new Array('liJournal','liPage','liMonth','liAbstract','numberLabelIssueNumber','liNumberField','liSeries','pageLabelJourPages');
		var arrConferenceFields = new Array('liBooktitle','liEditor','liPage','liAbstract','liSeries','pageLabelPages','spanExampleText','numberLabelNumber');
		divArray = new Array('divPubType','divTitle','divPublisher','divErrAuthor','divYear','divJournal','divBooktitle','divMonth');
		unSetVal(divArray); // function for unset the div error				
		if(id.value=='0'){
			$('dvAllFeilds').style.display='none';
		}else{
			$('dvAllFeilds').style.display='block';			
		}		
		if(id.value=='book'){
			for(i=0; i < arrAllFiels.length; i++){				
				var tmpVal = false;
				for(j=0; j < arrBookFields.length; j++)	{ 
					if(arrAllFiels[i] == arrBookFields[j]){ 
						tmpVal = true;						
					}
				}				
				if(tmpVal){
					$(arrAllFiels[i]).style.display='block';
				}else{
					$(arrAllFiels[i]).style.display='none';
				}				
			}
		}else if(id.value=='journal'){
			for(i=0; i < arrAllFiels.length; i++){
					var tmpVal = false;					
					for(j=0; j < arrJournalFields.length; j++){
						if(arrAllFiels[i] == arrJournalFields[j]){ 
							 tmpVal = true;						
						}
					}					
					if(tmpVal){
						$(arrAllFiels[i]).style.display='block';
					}else{
						$(arrAllFiels[i]).style.display='none';
					}
				}
		}else if(id.value=='conference'){
			for(i=0; i < arrAllFiels.length; i++){
				var tmpVal = false;			
				for(j=0; j < arrConferenceFields.length; j++){
					if(arrAllFiels[i] == arrConferenceFields[j]){ 					
						tmpVal = true;		
					}
				}			
				if(tmpVal){
					$(arrAllFiels[i]).style.display='block';
				}else{
					$(arrAllFiels[i]).style.display='none';
				}
			}
		}
	}
	
	function chkAllPublication(){		
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].name=='pubid[]'){
				if(document.frmPulication.chkAll.checked==true)	{
					document.frmPulication.elements[i].checked=true;
				}else {
					document.frmPulication.elements[i].checked=false;
				}				
			}			
		}
		return true;
	} 
	
	function frmValPublication(){		
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].checked==true && document.frmPulication.elements[i].name=='pubid[]'){
			 return true;	
			}
		}
		setValue('divSelectErr','Please select at least one Publication.');
		return false;
	} 	
	function setChkAllBox()	{		
		var flag = true;		
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].name=='pubid[]'){
				if(document.frmPulication.elements[i].checked==false){
					flag = false;
				}
			}
		}		
		document.frmPulication.chkAll.checked= flag;
	} 		
	function setMyFilenamePub(filename,newfilename,fileform,filecnt,uploadfile,frameid,remDivid){		
		var oldfilen = '';
		var newfilen = '';		
		if($(filecnt).value){	 		
			$(filecnt).value = parseInt($(filecnt).value) + 1;	 		
			var Count = $(filecnt).value;
		}else{
	 		$('filecount').value = 1;
	 		var Count = $(filecnt).value;
	 	}	
		if(remDivid=='myDivPubS'){
			oldfilen='oldfilenamePubS';
			newfilen='newfilenamePubS';
		} else if (remDivid=='myDivPubA'){
			oldfilen='oldfilenamePubA';
			newfilen='newfilenamePubA';
		} else {
			oldfilen='oldfilenamePub';
			newfilen='newfilenamePub';
		}
	 	$(fileform).innerHTML += '<div id=\''+remDivid+Count+'\'>'+$(filecnt).value+'- '+filename+'&nbsp;&nbsp;<input name=\''+oldfilen+'\' type=\'hidden\' value=\''+filename+'\'><input name=\''+newfilen+'\' type=\'hidden\' value=\''+newfilename+'\'><a href=\'javascript:delMyfilePub("'+remDivid+Count+'","'+filecnt+'","'+uploadfile+'","'+frameid+'","'+fileform+'");\' title=\'Remove\' alt=\'Remove\'>X</a><\div>';	 	
	  Count++;
	}
	
	// function to delete the uploaded file 
	function delMyfilePub(id,filecnt,uploadfile,frameid,fileform){
		document.getElementById(id).innerHTML='';
		subsFileCountPub(filecnt,uploadfile,frameid);
		var d = document.getElementById(fileform);
		var olddiv = document.getElementById(id);
		d.removeChild(olddiv);				
	}	
	function addEditors(){		
		 var container = document.getElementById('ulEditor');
		 var container1 = document.getElementById('ulAnotherEdit');
		 var clone = container.cloneNode(true);					 
		 var lastAuthId = parseInt($('totalEditor').value) +1;
		 $('totalEditor').value = lastAuthId;		 
		 clone.id ='ulEditor'+lastAuthId;
		 clone.style.display ='block';
		 container1.insertBefore(clone, container1.lastChild);			
		 var newDiv = '<div  class=\'Rmv\'> <a href=\'javascript:remEditors("ulEditor'+lastAuthId+'")\'><img src="../images/icnRemove.gif" alt="Remove" title="Remove"></a></div>';		 
		 var fDiv = 'id="fname_'+lastAuthId+'"';
		 var lDiv = 'id="lname_'+lastAuthId+'"';	 				 
		var tempString = clone.innerHTML;		
		if(navigator.userAgent.indexOf('MSIE') != -1 ){									                                         
			var newTempString = tempString.replace('<DIV class=Rmv><A href="javascript:remEditors(\'ulEditor\')">Remove</A></DIV>', newDiv);
			var newTempString = newTempString.replace('id="txtEditorFname"', fDiv);
			var newTempString = newTempString.replace('id="txtEditorLname"', lDiv);				
		} else {			
			var newTempString = tempString.replace('<div class="Rmv"><a href="javascript:remEditors(\'ulEditor\')">Remove</a></div>', newDiv);			
			var newTempString = newTempString.replace('id="txtEditorFname"', fDiv);
			var newTempString = newTempString.replace('id="txtEditorLname"', lDiv);				
		}
		clone.innerHTML = newTempString;				
	}	
	function valEditorsCheckE(){	
		var totalFields = parseInt($('totalEditor').value);
		var formName = 	document.frmPulication;
		var tempValF = '';
		var tempValL = '';
		for(i=0; i < formName.elements.length; i++){
			if(formName.elements[i].name=='txtEditorFname[]'){
				var fId = formName.elements[i].id
				var actId = getIdFromString(fId);
				var lId = 'lname_'+actId;								
				tempValF = $(fId).value;
				tempValF = tempValF.replace(/(<([^>]+)>)/ig,'');				
				tempValL = $(lId).value;
				tempValL = tempValL.replace(/(<([^>]+)>)/ig,'');				
				if( (trim(tempValF)=='' && trim(tempValL)!='') || (trim($(lId).value)=='' && trim(tempValF)!='') ){
					return false;
				}				
			}
		}
		return true;
	}
		
	function remEditors(id){ $(id).remove(); }
	
	function valEditors(){
		var totalFields = parseInt($('totalEditor').value);		
		for(i=0; i < document.frmPulication.elements.length; i++){ 
			if(document.frmPulication.elements[i].name=='txtEditorFname[]' || document.frmPulication.elements[i].name=='txtEditorLname[]'){
				if(trim(document.frmPulication.elements[i].value=='')){					
					return false;
				}
			}
		}
		return true;
	} 
	function validateLenAbs(objCountName){
	   var charCount=2000;
	   obj=$(objCountName);
	   msgnowLen=parseInt(find_new_lines(obj.value))+parseInt(obj.value.length);
	   if(msgnowLen <=charCount){
        rem=charCount-msgnowLen;
		$('textareaCount').innerHTML=rem+ ' letters remaining';
	   } else {
		rem=Math.abs(charCount-msgnowLen);
		$('textareaCount').innerHTML='<font color=red>Exceeded Maximum by '+rem+' letters</font>';
	   }
    }
    function find_new_lines(str) {
	   count=0;
	   modstr=escape(str);
	   for(s=0;s<modstr.length;s++) {
	      if(modstr.indexOf('%0D%0A') > -1) {
			count++;
			modstr=modstr.replace('%0D%0A','');
		  } else if(modstr.indexOf('%0A') > -1) {
			count++;
			modstr=modstr.replace('%0A','');
		  } else if(modstr.indexOf('%0D') > -1) {
			count++;
			modstr=modstr.replace('%0D','');
		  }
	   }	   
	   return count;
	}
/*********************** Publication Js ******************************/
/*********************** Personal Js ******************************/	
	var personalInterestMaxChar = 1500;
	function valPersonal(){	
		var isReturnFalse = true;		
			divArray = new Array('divPubType','divTitle','divPublisher','divAuthor');
			unSetVal(divArray); // function for unset the div error		
			fieldArray = new Array('txtTitle','txtPublisher','txtAuthor');
			setArrCss(fieldArray,'txtField150'); // function to set the css of the fileds	
			if (trim($('selPubType').value) == 0 || trim($('selPubType').value)==''){				
					setValue('divPubType','Please select publication type.');					
					isReturnFalse = false;			
			}else{
			setCss('selPubType','txtField155');
			}				
			if (trim($('txtTitle').value) == 0 || trim($('txtTitle').value)==''){				
					setValue('divTitle','Please enter title.');					
					isReturnFalse = false;			
			}			
			if (trim($('txtPublisher').value) == 0 || trim($('txtPublisher').value)==''){				
					setValue('divPublisher','Please enter publisher.');									
					isReturnFalse = false;			
			}
			if (trim($('txtAuthor').value) == 0 || trim($('txtAuthor').value)==''){				
					setValue('divAuthor','Please enter author.');								
					isReturnFalse = false;			
			}	
			return isReturnFalse;
	}	
	function valPersonalInterest(){
		var isReturnFalse = true;
		divArray = new Array('divURL','divLabUrl');
		unSetVal(divArray); // function for unset the div error
		fieldArray = new Array('txtPersonalUrl','txtLabUrl');	
		
		var perURL =  trim(document.getElementById('txtPersonalUrl').value);  
		var labURL =  trim(document.getElementById('txtLabUrl').value);
		if(perURL=='http://' || perURL=='https://') { perURL=''; }
		if(labURL=='http://' || labURL=='https://') { labURL=''; }
		
		if (trim($('txtProfileUrl').value) == 0 || trim($('txtProfileUrl').value)==''){				
					setValue('divProfileUrl','Please enter Public Profile URL.');				
					isReturnFalse = false;			
			}
			msgnowLen=parseInt(find_new_lines($('txtPersonalDesc').value))+parseInt($('txtPersonalDesc').value.length);		
				if (msgnowLen > personalInterestMaxChar){					
					setValue('divPersonalDesc','Personal Interests/Info should not be more than '+personalInterestMaxChar+' letters.');					
						isReturnFalse = false;					
				}
		if(trim($('txtPersonalUrl').value)!='' && (trim($('txtPersonalUrl').value)).length > 200 ){		
			setValue('divURL','Personal URL cannot have more than 200 characters.');
			isReturnFalse = false;
		}
		if(($('txtPersonalUrl').value !='http://' && $('txtPersonalUrl').value !='https://') && (($('txtPersonalUrl').value !='http://' && $('txtPersonalUrl').value !='https://') && trim($('txtPersonalUrl').value) !='')){			
			if(!urlValidateF($('txtPersonalUrl').value)){
				setValue('divURL','Invalid Personal link/URL.');
				isReturnFalse = false;
			}			
		}
		if(trim($('txtLabUrl').value)!='' && (trim($('txtLabUrl').value)).length > 200 ){		
			setValue('divLabUrl','Personal URL cannot have more than 200 characters.');
			isReturnFalse = false;
		}
		if(($('txtLabUrl').value !='http://' && $('txtLabUrl').value !='https://') && (($('txtLabUrl').value !='http://' && $('txtLabUrl').value !='https://') && trim($('txtLabUrl').value) !='')){			
			if(!urlValidateF($('txtLabUrl').value)){
				setValue('divLabUrl','Invalid Lab link/URL.');
				isReturnFalse = false;
			}			
		}
				
				return isReturnFalse;
	}	
	function validateLen(objCountName){
		var charCount=personalInterestMaxChar;
		obj=$(objCountName);
		msgnowLen=parseInt(find_new_lines(obj.value))+parseInt(obj.value.length);
		if(msgnowLen <=charCount){
			rem=charCount-msgnowLen;
			$('textareaCount').innerHTML=rem+ ' letters remaining';
		} else {
			rem=Math.abs(charCount-msgnowLen);
			$('textareaCount').innerHTML='<font color=red>Exceeded Maximum by '+rem+' letters</font>';
		}
	}	
	function find_new_lines(str){
		count=0;
		modstr=escape(str);
		for(s=0;s<modstr.length;s++){
			if(modstr.indexOf('%0D%0A') > -1){
				count++;
				modstr=modstr.replace('%0D%0A','');
			} else if(modstr.indexOf('%0A') > -1) {
				count++;
				modstr=modstr.replace('%0A','');
			} else if(modstr.indexOf('%0D') > -1){
				count++;
				modstr=modstr.replace('%0D','');
			}
		}
		return count;
	}	
	function enableGivenElement(childElement){	childElement.disabled=false;	}			
	function emptyElemt(fileFormP){		$(fileFormP).innerHTML='';	}		
	function unableUploadP(){	var childElement = window.frames['iframeContainerP'].document.getElementById('txtFile');			
		setTimeout('enableGivenElement(childElement)',500); 	
	}		
	function reloadFrame(frameId, elmentId) {		
		$(elmentId).value=0;		
		var f = document.getElementById(frameId);
		f.src = f.src;
	}			
	function fillProfileURL(fillValue, fillElement, hideDiv, showDiv){
		$(fillElement).value = fillValue;
		$(hideDiv).style.display='none';
		$(showDiv).style.display='block';
		$(showDiv).innerHTML = '<a href=\'javascript:void(0);\' onclick=\'javascript:showDiv("suggetionDiv", "suggetionDivMore");\'>Show Others</a>';
		
	}		
	function showDiv(showDiv, HideDiv){
		$(HideDiv).style.display='none';
		$(showDiv).style.display='block';
	}	
// function to delete the uploaded file 
	function delMyfileCV(id){	
		document.getElementById(id).innerHTML='';				
		if($('filecountPicture').value && $('filecountPicture').value > 0)
	 		$('filecountPicture').value = parseInt($('filecountPicture').value) - 1;
	 	if($('filecountPicture').value < 1){
	 	 	var childElement = window.frames['iframeContainerP'].document.getElementById('txtFile');			
	 	 	childElement.disabled=false;
	 	 	$('showMsg').style.display='none';	 	 	
	 	}
	}		
/*********************** Personal Js ******************************/
/*********************** Invite Js ******************************/
	function chkSelected(){	
		var formName = document.inviteExtContacts;		
		var maindisable = false;		
		var totalEmails = $('totalEmails').value;
		var tempCName = '';					
		var allInputs = formName.getElementsByTagName('input');		
		for(var k=0; k<allInputs.length; k++){			
			if(allInputs[k].type == 'checkbox' && allInputs[k].name.indexOf('chkExtContact')!=-1 && allInputs[k].checked==false){
				maindisable = true;
				break;
			}		
		}		
		if(maindisable){ formName.chkSelectAll.checked = false; } else { formName.chkSelectAll.checked = true;	}								
	}	
	function valInvite(){
		var returnValue = true;
		divArray = new Array('divToAddresses');
		fieldArray = new Array('txtToAddresses');
		setArrCss(fieldArray, 'txtField185');
		unSetVal(divArray);		
		if (trim($('txtToAddresses').value) == ''){	
			setValue('divToAddresses', 'Please enter at least one email address.');
			setCss('txtToAddresses', 'txtField185 invalidField');
			$('txtToAddresses').value = '';
			$('success').style.display='none';
			returnValue = false;
		}		
		return returnValue;
	}	
	function validChkDelete(){
	    var chkdel = document.deleteInvHistory.chkdel;
	    var chkflag = false;	    
	    if( chkdel.length ){
    	    for(i=0;i<chkdel.length;i++){
                if(document.deleteInvHistory.chkdel[i].checked){
                    $('hdDeleteChk').value +=document.deleteInvHistory.chkdel[i].value+',';            
                    chkflag = true;
                }
            }            
            $('hdDeleteChk').value = $('hdDeleteChk').value.substring(0, $('hdDeleteChk').value.lastIndexOf(','));
        }else{
            if(chkdel.checked ){
                $('hdDeleteChk').value = chkdel.value;
                chkflag = true;
            }
        }        
        if( chkflag == false){
           alert('Please Select Atleast 1 Entry For Deletion.');
		   return false;			
	    }
	    return true;
	}	
	function checkAllHistorySelected(){
		var formName = document.deleteInvHistory;
		var allInputs = formName.getElementsByTagName('input');
		var maindisable = false;	
		for(var k = 0; k < allInputs.length; k++){			
			if(allInputs[k].type == 'checkbox' && allInputs[k].name.indexOf('chk')!=-1 && allInputs[k].checked==false){				
				maindisable = true;
				break;
			}
		}
		if(maindisable){
			formName.cehkAllHistory.checked = false;			
		} else {
			formName.cehkAllHistory.checked = true;			
		}
	}	
	function checkAllHistory(count){
		var formName = document.deleteInvHistory;
		var allInputs = formName.getElementsByTagName('input');		
		if ($('cehkAllHistory').checked == true){
			for(var k = 0; k < allInputs.length; k++){			
				if(allInputs[k].type == 'checkbox'){
					allInputs[k].checked = true;
				}				
			}
		}else{
			for(var k = 0; k < allInputs.length; k++){			
				if(allInputs[k].type == 'checkbox'){
					allInputs[k].checked = false;
				}				
			}
		}
	}
	function checkLabInvites(){
		//alert("hiiiiiiiiii");
		var returnValue = true;
		divArray = new Array('divtxtEmails');
		fieldArray = new Array('txtEmails');
		setArrCss(fieldArray, 'txtField185');
		unSetVal(divArray);		
		if (trim($('txtEmails').value) == ''){	
			setValue('divtxtEmails', 'Please enter at least one email address.');
			setCss('txtEmails', 'txtField185 invalidField');
			$('txtEmails').value = '';
			$('success').style.display='none';
			returnValue = false;
		}else if(isValidEmail(trim($('txtEmails').value)) == 'self'){
			
			setValue('divtxtEmails', 'You can not invite yourself.');
			setCss('txtEmails', 'txtField185 invalidField');
			$('success').style.display='none';
			returnValue = false;
		}else if(!isValidEmail(trim($('txtEmails').value))){
		
			setValue('divtxtEmails', 'One or more of the email addresses are invalid.');
			setCss('txtEmails', 'txtField185 invalidField');
			$('success').style.display='none';
			returnValue = false;
		}
		//setWinSize();
		return returnValue;
	}

	function checkLabInvitesBox(){
		
		//alert('Hello');return false;
		var returnValue = true;
		divArray = new Array('divtxtEmails');
		fieldArray = new Array('txtEmails');
		setArrCss(fieldArray, 'tArea');
		unSetVal(divArray);	
		var txtEmails = document.getElementById('txtEmails');
		if(txtEmails.value == 'Please enter emails separated by commas. Thanks!'){
			txtEmails = '';
		}
			
		if(($('txtEmails').value == 'Please enter emails separated by commas. Thanks!') || ($('txtEmails').value == ''))	{
			setValue('divtxtEmails', 'Please enter at least one email address.');
			setCss('txtEmails', 'tArea invalidField');
			$('txtEmails').value = '';
			returnValue = false;
		}else if(isValidEmail(trim($('txtEmails').value)) == 'self'){
			
			setValue('divtxtEmails', 'You can not invite yourself.');
			setCss('txtEmails', 'tArea invalidField');
			returnValue = false;
		}else if(!isValidEmail(trim($('txtEmails').value))){
		
			setValue('divtxtEmails', 'One or more of the email addresses are invalid.');
			setCss('txtEmails', 'tArea invalidField');
			returnValue = false;
		}
		//setWinSize();
		return returnValue;
	}
	function checkInvitesUserBox(){
		
		var returnValue = true;
		divArray = new Array('divtxtEmails');
		fieldArray = new Array('txtInviteEmails');
		setArrCss(fieldArray, 'tArea');
		unSetVal(divArray);	
		var txtEmails = document.getElementById('txtInviteEmails');
		if(txtEmails.value == 'Please enter emails separated by commas. Thanks!'){
			txtEmails = '';
		}
			
		if(($('txtInviteEmails').value == 'Please enter emails separated by commas. Thanks!') || ($('txtInviteEmails').value == ''))	{
			setValue('divtxtEmails', 'Please enter at least one email address.');
			setCss('txtInviteEmails', 'tArea invalidField');
			$('txtInviteEmails').value = '';
			returnValue = false;
		}else if(isValidEmail(trim($('txtInviteEmails').value)) == 'self'){
			
			setValue('divtxtEmails', 'You can not invite yourself.');
			setCss('txtInviteEmails', 'tArea invalidField');
			returnValue = false;
		}else if(!isValidEmail(trim($('txtInviteEmails').value))){
		
			setValue('divtxtEmails', 'One or more of the email addresses are invalid.');
			setCss('txtInviteEmails', 'tArea invalidField');
			returnValue = false;
		}
		//setWinSize();
		return returnValue;
		
	}
	function checkLabInvites2(divtxtEmails,txtEmails,txtField185,success){
		var returnValue = true;
		divArray = new Array(divtxtEmails);
		fieldArray = new Array(txtEmails);
		setArrCss(fieldArray, txtField185);
		unSetVal(divArray);		
		if (trim($( txtEmails ).value) == ''){	
			setValue( divtxtEmails , 'Please enter at least one email address.');
			setCss( txtEmails , 'txtField185 invalidField');
			$( txtEmails ).value = '';
			$(success).style.display='none';
			returnValue = false;
		}else if(isValidEmail(trim($( txtEmails ).value)) == 'self'){
			setValue( divtxtEmails , 'You can not invite yourself.');
			setCss( txtEmails , 'txtField185 invalidField');
			$(success).style.display='none';
			returnValue = false;
		}else if(!isValidEmail(trim($( txtEmails ).value))){
			setValue( divtxtEmails , 'You can not invite yourself.');
			setCss( txtEmails , 'txtField185 invalidField');
			$(success).style.display='none';
			returnValue = false;
		}
		//setWinSize();
		return returnValue;
	}
	function isProperEmail(strObj){
		var regExPattern= /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i;
	    if(!strObj.match(regExPattern))
	      return false;
	    else
	      return true;
	}
/*********************** Invite Js ******************************/
/*********************** Invite contact grabber Js ******************************/	
	function inviteLabEmails(){
		if(document.getElementById('txtEmails') && document.getElementById('txtEmailsInvited')){
			document.getElementById('txtEmailsInvited').value = document.getElementById('txtEmails').value;
		}
		var val = valContactsGrabber();
		//setWinSize();
		return val;
	}
	
	function inviteLabEmails2(txtEmails,txtEmailsInvited){
		if(document.getElementById(txtEmails) && document.getElementById(txtEmailsInvited)){
			document.getElementById(txtEmailsInvited).value = document.getElementById(txtEmails).value;
		}
		var val = valContactsGrabber2();
		//setWinSize();
		return val;
	}
	function valContactsGrabber(){
		var returnValue = true;
		divArray = new Array('divEmail', 'divPass');
		fieldArray = new Array('txtEmail', 'pwdPass');
		setArrCss(fieldArray, '');
		unSetVal(divArray);		
		if($('errorId'))
			$('errorId').style.display = 'none';
		if (trim($('txtEmail').value) == ''){
			setValue('divEmail', 'Please enter email address.');			
			$('txtEmail').value = '';
			returnValue = false;
		}else if(!isProperEmailAddress(trim($('txtEmail').value))){
			setValue('divEmail', 'Please enter valid Email address');
			returnValue = false;
		}
		if (trim($('pwdPass').value) == ''){
			setValue('divPass', 'Please enter the password.');			
			$('pwdPass').value = '';
			returnValue = false;
		}       
		if(returnValue){
		  $('txtEmail').value = trim($('txtEmail').value);
		}		
		return returnValue;
	}
	
	function valContactsGrabber2(){
		var returnValue = true;
		divArray = new Array('divEmail2', 'divPass2');
		fieldArray = new Array('txtEmail2', 'pwdPass2');
		setArrCss(fieldArray, '');
		unSetVal(divArray);		
		if($('errorId2'))
			$('errorId2').style.display = 'none';
		if (trim($('txtEmail2').value) == ''){
			setValue('divEmail2', 'Please enter email address.');			
			$('txtEmail2').value = '';
			returnValue = false;
		}else if(!isProperEmailAddress(trim($('txtEmail2').value))){
			setValue('divEmail2', 'Please enter valid Email address');
			returnValue = false;
		}
		if (trim($('pwdPass2').value) == ''){
			setValue('divPass2', 'Please enter the password.');			
			$('pwdPass2').value = '';
			returnValue = false;
		}       
		if(returnValue){
		  $('txtEmail2').value = trim($('txtEmail2').value);
		}		
		return returnValue;
	}
	
	function isProperEmailAddress(strObj){
		var regExPattern= /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i;
	    if(!strObj.match(regExPattern))
	      return false;
	    else
	      return true;
	}
	function disableOther(id, flag){
		if (flag == 1){
			if ($('chkContact'+id).checked == true){
				$('chkLabmate'+id).checked = false;
				$('chkLabmate'+id).disabled = true;
			}else{
				$('chkLabmate'+id).disabled = false;
			}
		}else{
			if ($('chkLabmate'+id).checked == true){
				$('chkContact'+id).checked = false;
				$('chkContact'+id).disabled = true;
			}else{
				$('chkContact'+id).disabled = false;
			}
		}
	}
	function activateCheckbox(id, flag){
		if (flag == 1){
			if ($('chkContact'+id).disabled == true){
				$('chkContact'+id).disabled = false;
				$('chkContact'+id).checked = true;
				$('chkLabmate'+id).checked = false;
				$('chkLabmate'+id).disabled = true;
			}
		}else{
			if ($('chkLabmate'+id).disabled == true){
				$('chkLabmate'+id).disabled = false;
				$('chkLabmate'+id).checked = true;
				$('chkContact'+id).checked = false;
				$('chkContact'+id).disabled = true;
			}
		}
	}
	function valAddContactLabmate(count){
		var contactFlg = 0;
		var labmateFlg = 0;
		for (i=1; i<=count; i++){
		    if($('chkContact'+i) ){
    			if ($('chkContact'+i).checked == true){
    				$('hdContact').value = $('hdContact').value + $('chkContact'+i).value + ',';
    				contactFlg = 1;
    			}
    	    }    	    
    	    if($('chkLabmate'+i) ){
    			if ($('chkLabmate'+i).checked == true){
    				$('hdLabmate').value = $('hdLabmate').value + $('chkLabmate'+i).value + ',';
    				labmateFlg = 1;
    			}
    		}
		}
		$('hdContact').value = $('hdContact').value.substring(0, $('hdContact').value.lastIndexOf(','));
		$('hdLabmate').value = $('hdLabmate').value.substring(0, $('hdLabmate').value.lastIndexOf(','));
		if (contactFlg == 0 && labmateFlg == 0){			
			alert('Please Select a Member To Invite.');
			return false;
		}else{			
			return true;
		}
	}	
	function valInviteExtContacts(count){
		var flg = 0;
		var returnValue = true;
		for (i=1; i<=count; i++){
			if ($('chkExtContact'+i).checked == true){
				$('hdExtContacts').value = $('hdExtContacts').value + $('chkExtContact'+i).value + ',';
				flg = 1;
			}
		}
		$('hdExtContacts').value = $('hdExtContacts').value.substring(0, $('hdExtContacts').value.lastIndexOf(','));
		if (flg == 0){
			alert('Please Select Atleast 1 Contact To Invite.');
			returnValue = false;
		}
		return returnValue;
	}
	function checkAllExtContacts(count){
		if ($('chkSelectAll').checked == true){
			for (i=1; i<=count; i++){
				$('chkExtContact'+i).checked = true;
			}
		}else{
			for (i=1; i<=count; i++){
				$('chkExtContact'+i).checked =false;
			}
		}
	}
	function checkAllExtContactsInvite(count){
		var txtEmails = $('txtEmails').value;
		if ($('chkSelectAll').checked == true){
			for (i=1; i<=count; i++){
				$('chkExtContact'+i).checked = true;
				txtEmails = txtEmails.replace($('chkExtContact'+i).value+', ','');
				txtEmails += $('chkExtContact'+i).value+', ';
			}
		}else{
			for (i=1; i<=count; i++){
				$('chkExtContact'+i).checked =false;
				txtEmails = txtEmails.replace($('chkExtContact'+i).value+', ','');
			}			
		}
		$('txtEmails').value = txtEmails;		
	}
	function chkSelectedInvite(id){
		var txtEmails = $('txtEmails').value;		
		if($(id).checked){
			txtEmails = txtEmails.replace($(id).value+', ','');
			txtEmails += $(id).value+', ';		
		}else{
			txtEmails = txtEmails.replace($(id).value+', ','');			
		}
		$('txtEmails').value = txtEmails;
	}
	function updateInvitedMemeberList(cntList, labList){		   
	   var total=0;	   
        if(trim(cntList) != ''){
    	   cntArrList = cntList.split(',');    	   
           if(cntArrList){
                for(i=0;i<cntArrList.length;i++){                    
                    childEle = $('dv'+parseInt(cntArrList[i]));
                    document.forms['addContactLabmate'].removeChild(childEle);
                    total++;
                }
           }    	  
        }        
        if(trim(labList) != ''){
           labArrList = labList.split(',');	   
           if(labArrList){
                for(i=0;i<labArrList.length;i++){                    
                    childEle = $('dv'+parseInt(labArrList[i]));
                    document.forms['addContactLabmate'].removeChild(childEle);
                    total++;
                }
            }
        }	        
        var countAll = parseInt($('cntAll').value);        
        $('cntAll').value = countAll - total;        
        if($('cntAll').value < 1){
            $('dvButton').style.display = 'none';
        }
	}	
	function resetExtInv(count){
	   for (i=1; i<=count; i++){
	       $('chkSelectAll').checked = false;
	       if( $('chkExtContact'+i).checked){
	       		$('chkExtContact'+i).disabled = true;
	       }
	       $('chkExtContact'+i).checked = false;	       	       
	       $('hdExtContacts').value = '';
	   }	   
	   window.scroll(0,0);
	   $('updateInviteDv').focus();
	}	
	function showHideDiv(flag){
		if (flag == 1){
			$('alreadyMembers').style.display = '';
			$('nonSiteMembers').style.display = 'none';
		}else{
			$('nonSiteMembers').style.display = '';
			$('alreadyMembers').style.display = 'none';
		}
	}
/*********************** Invite contact grabber Js ******************************/
/*********************** Tool tip Js ******************************/
var Tooltip = Class.create();
Tooltip.prototype = {
  initialize: function(element, tool_tip) {
    var options = Object.extend({
      default_css: false,
      margin: "0px",
	    padding: "5px",
	    backgroundColor: "#d6d6fc",
	    min_distance_x:0,
      min_distance_y:0,
      delta_x: 10,
      delta_y: -200,
      zindex: 1000
    }, arguments[2] || {});

    this.element      = $(element);
    this.options      = options;    
    // use the supplied tooltip element or create our own div
    if($(tool_tip)) {
      this.tool_tip = $(tool_tip);
    } else {
      this.tool_tip = $(document.createElement("div")); 
      document.body.appendChild(this.tool_tip);
      this.tool_tip.addClassName("tooltip");
      this.tool_tip.appendChild(document.createTextNode(tool_tip));
    }

    // hide the tool-tip by default
    this.tool_tip.hide();
    this.eventMouseOver = this.showTooltip.bindAsEventListener(this);
    this.eventMouseOut   = this.hideTooltip.bindAsEventListener(this);
    this.eventMouseMove  = this.moveTooltip.bindAsEventListener(this);
    this.registerEvents();
  },
  destroy: function() {
    Event.stopObserving(this.element, "mouseover", this.eventMouseOver);
    Event.stopObserving(this.element, "mouseout", this.eventMouseOut);
    Event.stopObserving(this.element, "mousemove", this.eventMouseMove);
  },
  registerEvents: function() {
    Event.observe(this.element, "mouseover", this.eventMouseOver);
    Event.observe(this.element, "mouseout", this.eventMouseOut);
    Event.observe(this.element, "mousemove", this.eventMouseMove);
  },
  moveTooltip: function(event){
	  Event.stop(event);
	  // get Mouse position
    var mouse_x = Event.pointerX(event);
	  var mouse_y = Event.pointerY(event);	
	  // decide if wee need to switch sides for the tooltip
	  var dimensions = Element.getDimensions( this.tool_tip );
	  var element_width = dimensions.width;
	  var element_height = dimensions.height;	
	  if ( (element_width + mouse_x) >= ( this.getWindowWidth() - this.options.min_distance_x) ){ // too big for X
		  mouse_x = mouse_x - element_width;
		  // apply min_distance to make sure that the mouse is not on the tool-tip
		  mouse_x = mouse_x - this.options.min_distance_x;
	  } else {
		  mouse_x = mouse_x + this.options.min_distance_x;
	  }	
	  if ( (element_height + mouse_y) >= ( this.getWindowHeight() - this.options.min_distance_y) ){ // too big for Y
		  mouse_y = mouse_y - element_height;
	    // apply min_distance to make sure that the mouse is not on the tool-tip
		  mouse_y = mouse_y - this.options.min_distance_y;
	  } else {
		  mouse_y = mouse_y + this.options.min_distance_y;
	  }	
	  // now set the right styles
	  this.setStyles(mouse_x, mouse_y);
  },	
  showTooltip: function(event) {
    Event.stop(event);
    this.moveTooltip(event);
	  new Element.show(this.tool_tip);
  },  
  setStyles: function(x, y){
    // set the right styles to position the tool tip
	  Element.setStyle(this.tool_tip, { position:'absolute',
	 								    top:y + this.options.delta_y + "px",
	 								    left:"0px",
									    zindex:this.options.zindex
	 								  });	
	  // apply default theme if wanted
	  if (this.options.default_css){
	  	  Element.setStyle(this.tool_tip, { margin:this.options.margin,
		 		  						                    padding:this.options.padding,
		                                      backgroundColor:this.options.backgroundColor,
										                      zindex:this.options.zindex
		 								    });	
	  }	
  },

  hideTooltip: function(event){
	  new Element.hide(this.tool_tip);
  },
  getWindowHeight: function(){
    var innerHeight;
	  if (navigator.appVersion.indexOf('MSIE')>0) {
		  innerHeight = document.body.clientHeight;
    } else {
		  innerHeight = window.innerHeight;
    }
    return innerHeight;	
  },
 
  getWindowWidth: function(){
    var innerWidth;
	  if (navigator.appVersion.indexOf('MSIE')>0) {
		  innerWidth = document.body.clientWidth;
    } else {
		  innerWidth = window.innerWidth;
    }
    return innerWidth;	
  }
}
/*********************** Tool tip Js ******************************/
/*********************** Tool tip NEW DV Js ******************************/
	var offsetfromcursorX=-12 //Customize x offset of tooltip
	var offsetfromcursorY=10 //Customize y offset of tooltip
	var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
	var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image
	
	//New code added on 19th January 2011 to set image path start
	var docURL = window.location.host;
	var imgPath = '';
	
	if(docURL == 'quartzy.com' || docURL == 'admin.quartzy.com'){
		imgPath = docURL; 
	}else{
		imgPath = docURL+'/quartzy/web';
	}

	document.write('<div id="dhtmltooltipQ"></div>');
	document.write('<img id="dhtmlpointerQ" src="https://'+imgPath+'/images/arrow2_002.gif" style="display:none;">');
	//New code added on 19th January 2011 to set image path end
	
	//document.write('<div id="dhtmltooltipQ"></div>') //write out tooltip DIV
	//document.write('<img id="dhtmlpointerQ" src="images/arrow2_002.gif" style="display:none;">') //write out pointer image
	
	var ie=document.all
	var ns6=document.getElementById && !document.all
	var enabletip=false
	if (ie||ns6)
	var tipobj=document.all? document.all["dhtmltooltipQ"] : document.getElementById? document.getElementById("dhtmltooltipQ") : ""	
	var pointerobj=document.all? document.all["dhtmlpointerQ"] : document.getElementById? document.getElementById("dhtmlpointerQ") : ""	
	function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}	
	function ddrivetip(thetext, thewidth, thecolor){
	if (ns6||ie){
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
	tipobj.innerHTML=thetext
	enabletip=true
	return false
	}
	}	
	function positiontip(e){
	if (enabletip){
	var nondefaultpos=false
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
	var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20	
	var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
	var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY	
	var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000	
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<tipobj.offsetWidth){
	//move the horizontal position of the menu to the left by it's width
	tipobj.style.left=curX-tipobj.offsetWidth+"px"
	nondefaultpos=true
	}else if (curX<leftedge)
	tipobj.style.left="5px"
	else{
	//position the horizontal position of the menu where the mouse is positioned
	tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
	pointerobj.style.left=curX+offsetfromcursorX+"px"
	}	
	//same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight){
	tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
	nondefaultpos=true
	}else{
	tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
	pointerobj.style.top=curY+offsetfromcursorY+"px"
	}
	tipobj.style.visibility="visible"
	if (!nondefaultpos)
	pointerobj.style.visibility="visible"
	else
	pointerobj.style.visibility="hidden"
	}
	}	
	function hideddrivetip(){
	if (ns6||ie){
	enabletip=false
	tipobj.style.visibility="hidden"
	pointerobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
	}
	}
	document.onmousemove=positiontip
/*********************** Tool tip NEW DV Js ******************************/	

	function fnSaveFacNote(actUrl) {
		//alert(actUrl);return false;
		jQuery.ajax({
						url	 	: actUrl,
						type	: 'POST',
						cache	: false,
						success	: function(data) {
									alert(data);return false;
									//window.location = '#';
								}
			});
	}
	
	function changeFacilityState(requestUrl) {
	
		new Ajax.Updater('mp-contentWrapper', requestUrl, {asynchronous:true, evalScripts:true, method:'get', onComplete:function(request, json){Element.hide('indicator2');Element.show('mp-contentWrapper'); window.location='#';  }, onLoading:function(request, json){Element.hide('mp-contentWrapper');Element.show('indicator2');}});; return false;

	}
	
	/* START Function for tracking vendor product click from vendor inventory */
		function vendorProductTracking(targetUrl) {
			jQuery.ajax({
							url	 	: targetUrl,
							type	: 'POST',
							cache	: false,
							success	: function(data) {
										//alert(data);return false;
									}
				});
		}
	/* END Function for tracking vendor product click from vendor inventory */
	function emailNotificationCheckbox( chkId ){
		if(chkId=="email_notification_YES"){
			document.getElementById('email_notification_YES').checked = true;
			document.getElementById('email_notification_NO').checked = false;
		}else{
			document.getElementById('email_notification_NO').checked = true;
			document.getElementById('email_notification_YES').checked = false;
		}		    
	}


function validateUserInvites(){
		var returnValue = true;
		divArray = new Array('divtxtinputEmails');
		fieldArray = new Array('txtEmails');
		setArrCss(fieldArray, 'txtField185');
		unSetVal(divArray);		
		if (trim($('txtEmails').value) == ''){	
			setValue('divtxtinputEmails', 'Please enter at least one email address.');
			setCss('txtEmails', 'txtField185 invalidField');
			$('txtEmails').value = '';
			$('success').style.display='none';
			returnValue = false;
		}else if(isValidEmail(trim($('txtEmails').value)) == 'self'){
			
			setValue('divtxtinputEmails', 'You can not invite yourself.');
			setCss('txtEmails', 'txtField185 invalidField');
			$('success').style.display='none';
			returnValue = false;
		}else if(!isValidEmail(trim($('txtEmails').value))){
		
			setValue('divtxtinputEmails', 'One or more of the email addresses are invalid.');
			setCss('txtEmails', 'txtField185 invalidField');
			$('success').style.display='none';
			returnValue = false;
		}
		
		return returnValue;
	}	
