<!--
function e() {}

var disable_dblClick = false;

function disableDblClick(bDblClick){
	disable_dblClick = bDblClick;
}

function getDblClickStatus() {
	return disable_dblClick;
}

function page_open(sType,nID) {
	//alert('page.asp?h=' + sType + '&id=' + nID);
//	window.document.location.href='page.asp?h=' + sType + '&id=' + nID;
	window.document.location.replace('page.asp?h=' + sType + '&id=' + nID);

		//alert(window.document.location.href);
}

function confirmRedirection(msg, tab_index, handle, item_id){
	if (confirm(msg)){
		var retVal=new Object();
		
		retVal.Loc = 'page.asp?h=' + handle + '&id=' + item_id;
		retVal.TabId = tab_index;
		window.parent.returnValue = retVal;
		window.parent.close();
	}
}

function updateHeight() {
	var adjust = 30;
	if (window.navigator.userAgent.indexOf("SV1") != -1) //IE with SP2
	{ 
		adjust = 50;
	}
	
	if (window.navigator.userAgent.indexOf("MSIE 7.0") != -1) //IE 7.0
	{ 
		adjust = 0;
	}
	//alert(adjust);
	
	//alert (window.parent.dialogHeight + ' ' + window.document.body.scrollHeight + ' ' + adjust + ' ' + window.parent.document.all['include'].height);
		
	if (window.document.body.scrollHeight+parseInt(adjust)<screen.availHeight) {
		window.parent.dialogHeight= (window.document.body.scrollHeight+parseInt(adjust))+'px'; 
	} else {
		window.parent.dialogHeight=screen.availHeight+'px';
	}
	if (parseInt(window.parent.dialogTop)+window.document.body.scrollHeight+parseInt(adjust)>screen.availHeight) {

		window.parent.dialogTop=(screen.availHeight-window.document.body.scrollHeight-parseInt(adjust))+'px';
	}
	//alert (window.parent.dialogHeight + ' ' + window.document.body.scrollHeight + ' ' + adjust + ' ' + window.parent.document.all['include'].height);
	
}

function fixSize() {
	if (document.all) {
		window.parent.document.all['include'].height= window.document.body.scrollHeight-50;
		window.setTimeout('updateHeight();',1);
	} else if (document.getElementById) {
		window.parent.document.getElementById('include').height=document.height;
	}
}

function fixSizePopUp() {
	if (document.all) {
		window.parent.document.height= window.document.body.scrollHeight;
		window.setTimeout('updateHeight();',1);
	} else if (document.getElementById) {
		window.parent.document.height=document.height;
	}
}

function updateWidth() {
	if (window.document.body.scrollWidth<screen.availWidth) {
		if (parseInt(window.parent.dialogWidth)<(window.document.body.scrollWidth)) { 
			window.parent.dialogWidth=(window.document.body.scrollWidth+25)+'px'; 
		}
	} else 
		window.parent.dialogWidth=screen.availWidth+'px';
	if (parseInt(window.parent.dialogLeft)+window.document.body.scrollWidth+30>screen.availWidth) {
		
		window.parent.dialogLeft=(screen.availWidth-window.document.body.scrollWidth-30)+'px';
	}
	window.parent.document.all['include'].width= window.document.body.scrollWidth;
	
	
}

function fixWidth() {
	if (document.all) {
		
		window.setTimeout('updateWidth();',1);
	} else if (document.getElementById) {
		window.parent.document.getElementById('include').width=document.width;
	}
	
}

function lfixSize(mWidth,adWidth) {
	//used in letters
	var lHeight = screen.availHeight;
	if (document.all) {
		if (window.document.body.scrollHeight < lHeight){
			lHeight = window.document.body.scrollHeight+30;
		}
		window.resizeTo(mWidth+30+adWidth, lHeight);
		if (parseInt(window.screenTop)+lHeight+30>screen.availHeight)
			window.moveTo(window.screenLeft,screen.availHeight-lHeight);
	}	
}

function close_win(bRefresh){
	if (document.all){
		window.parent.returnValue=bRefresh;
	} else {
		if (bRefresh) 
			window.parent.opener.document.location.href = window.parent.opener.document.location.href;
	}
	window.parent.close(); 
}

// for referrals
function writeRefInDiv(nObj,bInPopup){
  if(nObj && nObj.Names != 0 ){
	with(document.all) {
	
		if(refNames.value != 0 ){
			refNames.value = refNames.value + ' || ';
			refIDs.value = refIDs.value + ',';
		}
		refNames.value = refNames.value + nObj.Names;
		refIDs.value = refIDs.value + nObj.IDs;
		drawRefTable(bInPopup);
	}
  }	
}
function detachRef(nID,bInPopup){
	var sCont, arrNames, arrIDs, sNames, sIDs;
	
	sNames = '';
	sIDs = '';
	arrNames = document.all.refNames.value.split(' || ');
	arrIDs = document.all.refIDs.value.split(',');
	for (i=0;i<arrIDs.length;i++) { 
		if (arrIDs[i] != nID) {
			sNames += arrNames[i];
			sNames += ' || ';
			sIDs += arrIDs[i];
			sIDs += ',';
		}
	}	
	sNames = sNames.substring(0, (sNames.length-4));
	sIDs = sIDs.substring(0, (sIDs.length-1));
	document.all.refNames.value = sNames;
	document.all.refIDs.value = sIDs;
	drawRefTable(bInPopup);
	
}
function drawRefTable(bInPopup) {
    var sCont, arrNames, arrIDs;
    if (document.all.refNames.value != 0) {
		arrNames = document.all.refNames.value.split(' || ');
  		arrIDs = document.all.refIDs.value.split(',');
		sCont = '<table border="0" cellspacing="0" cellpadding="0" bgcolor="#E5E5E5" width="100%">';
		for (i=0;i<arrNames.length;i++) { 
			sCont += '<tr><td>' + arrNames[i] + '</td><td align="right"><a href="#" onClick="detachRef(' + arrIDs[i]+ ','+bInPopup+');return false;">Detach</a></td>';
		}
		sCont += '</table>';
		
		document.all.divRefs.innerHTML = sCont;

	} else {
		document.all.divRefs.innerHTML = '';
	}
	if (bInPopup) fixSize();
}
// ---------------------------

// for attachments
function writeFileInDiv(nObj,bInPopup){
  if(nObj && nObj.Names != 0 ){
	with(document.all) {
	
		if(fileNames.value != 0 ){
			fileNames.value = fileNames.value + ' || ';
			fileExtens.value = fileExtens.value + ' || ';
			fileIDs.value = fileIDs.value + ',';
		}
		fileExtens.value = fileExtens.value + nObj.Extens;
		fileNames.value = fileNames.value + nObj.Names;
		fileIDs.value = fileIDs.value + nObj.IDs;
		drawFileTable(bInPopup);
	}
  }	
}
function detachFile(nID,bInPopup){
	var sCont, arrNames, arrIDs, arrExtens, sNames, sIDs, sExtens;
	
	sNames = '';
	sExtens = '';
	sIDs = '';
	
	arrNames = document.all.fileNames.value.split(' || ');
	arrExtens = document.all.fileExtens.value.split(' || ');
	arrIDs = document.all.fileIDs.value.split(',');
	
	for (i=0;i<arrIDs.length;i++) { 
		if (arrIDs[i] != nID) {
			sNames += arrNames[i];
			sNames += ' || ';
			
			sExtens += arrExtens[i];
			sExtens += ' || ';
			
			sIDs += arrIDs[i];
			sIDs += ',';
		}
	}	
	sNames = sNames.substring(0, (sNames.length-4));
	sExtens = sExtens.substring(0, (sExtens.length-4));
	sIDs = sIDs.substring(0, (sIDs.length-1));
	
	document.all.fileNames.value = sNames;
	document.all.fileExtens.value = sExtens;
	document.all.fileIDs.value = sIDs;
	drawFileTable(bInPopup);
}

function drawFileTable(bInPopup) {
	var sCont, arrNames, arrIDs, arrExtens;
	re = /\./g;
	
    if (document.all.fileNames.value != 0) {
		arrNames = document.all.fileNames.value.split(' || ');
  		arrIDs = document.all.fileIDs.value.split(',');
  		arrExtens = document.all.fileExtens.value.split(' || ');
		sCont = '<table border="0" cellspacing="0" cellpadding="0" bgcolor="#E5E5E5" width="100%">';
		for (i=0;i<arrNames.length;i++) {
			if (arrExtens[i] != ''){
				arrExtens[i] = arrExtens[i].replace(re,'');
			} else {
				arrExtens[i] = 'nil';
			}
			sCont += '<tr><td><span><img src="../img/icon/'+arrExtens[i]+'iconsmall.gif" border="0" width="16" vspace="2" align="absmiddle"></span> ' + arrNames[i] + '</td><td align="right"><a href="#" onClick="detachFile(' + arrIDs[i]+ ','+bInPopup+');return false;">Detach</a></td>';
		}
		sCont += '</table>';
		//alert(sCont);
		
		document.all.divFiles.innerHTML = sCont;

	} else {
		document.all.divFiles.innerHTML = '';
	}
	if (bInPopup) fixSizePopUp();
}
// ---------------------------

function testTime (date) {
	var s;
	var t;
	var MinMilli = 1000 *60;
	var HrMilli = MinMilli * 60;
	var DyMilli = HrMilli * 24
	t = Date.parse(date);
	s = Math.round(Math.abs(t/DyMilli));
	return(s);
}
function IsNumber(n) {
	var str=new String(n);
	return ( (str.search(/[^0-9.]/)==-1) && !isNaN(parseFloat(str)) );
}
function set_dealteam(newdtObj) {
	if (newdtObj && newdtObj.Names != 'Cancel') {
		document.forms[0].deal_team.value=newdtObj.Names;
		document.forms[0].deal_teamIDs.value=newdtObj.IDs;
		document.forms[0].responsibleID.value=newdtObj.Responsible;
		//	alert("Names:"+newdtObj.Names+"\nIDs:"+newdtObj.IDs+"\nResponsible:"+newdtObj.Responsible);				
	}
}
function blank(url){ // open links in new window from modal with iframe
	window.top.open(url);
}

//////////////// <a href="#" onclick="removeSelected('eventlist','objectID','event','delete');return false;">
function removeSelected(formname, elmname, objname, action) {
	var oForm=document.forms[formname];
	var oObjects;
	if (document.all) {
		oObjects=oForm.elements(elmname);
	}else {
		oObjects=oForm.elements[elmname];
	}
	var AllOK=false;
	var num=0;
	var i;
	if (oObjects) {
		if (oObjects.checked) {
			num=1;
			AllOK=true;
		} else {
			for (i=0;i<oObjects.length;i++) {
				if (oObjects[i].checked) {
					AllOK=true;
					num++;
				}
			}
		}
	} else {
		alert('There is no '+ objname + '(s) available to select.');
		return false;
	}
	if (AllOK) {
		var msgStr; // for request a hard copy in investor portal
		if(action=='request a hard copy')
			msgStr = 'The system will send email request for hard copies of '+num+' document(s). Would you like to proceed?';
		else
			msgStr = 'Are you sure you want to ' + action +' '+num+' '+objname+'(s)?';
		if (confirm(msgStr)) {
			if ((objname== "contact" || objname== "company") && action == "delete") {
				oForm.elements['a'].value='del';
			}		
			oForm.submit();
			return false;
		}
	} else
		if(action=='request a hard copy')
			alert('Please select at least one '+ objname + '.');
		else
			alert('Please select at least one '+ objname + ' to '+action+'.');
	return false;
}

function removeSelectedHidden(formname, elmname, objname, action) {
	var oForm=document.forms[formname];
	var oObjects;
	if (document.all) {
		oObjects=oForm.elements(elmname);
	}else {
		oObjects=oForm.elements[elmname];
	}
	var AllOK=false;
	var num=0;
	var i;
	if (oObjects) {
		if (oObjects.value!='') {
			num=1;
			AllOK=true;
		} /*else {
			for (i=0;i<oObjects.length;i++) {
				if (oObjects[i].value<>'') {
					AllOK=true;
					num++;
				}
			}
		}*/
	} else {
		alert('There is no '+ objname + '(s) available to select.');
		return false;
	}
	if (AllOK) {
		var msgStr; // for request a hard copy in investor portal
		if(action=='request a hard copy')
			msgStr = 'The system will send email request for hard copies of '+num+' document(s). Would you like to proceed?';
		else
			switch(objname) {
				case 'Capital Call':
					msgStr="Deleting this capital call(s) will induce automatic recalculation of total amounts called and remaining.\nRespective investor letters will not be automatically deleted.\n\nWould you like to proceed?";
					break;
				case 'Distribution':
					msgStr="You are trying to delete a fund distribution.\nPlease note respective investor letters will not be automatically deleted.\n\nWould you like to proceed?";
					break;
				default:
					msgStr = 'Are you sure you want to ' + action +' '+num+' '+objname+'(s)?';
					break;
				}
		if (confirm(msgStr)) {
			if ((objname== "contact" || objname== "company") && action == "delete") {
				oForm.elements['a'].value='del';
			}
			
			oForm.submit();
			return false;
		}
	} else
		if(action=='request a hard copy')
			alert('Please select at least one '+ objname + '.');
		else
			alert('Please select at least one '+ objname + ' to '+action+'.');
	return false;
}

//////////////// <a href="#" onclick="removeSelected('eventlist','objectID','event','delete');return false;">
function exportSelected(formname, elmname, objname, action) {
	var oForm=document.forms[formname];
	var oObjects;
	if (document.all) {
		oObjects=oForm.elements(elmname);
	}else {
		oObjects=oForm.elements[elmname];
	}
	var AllOK=false;
	var num=0;
	var i;
	if (oObjects) {
		if (oObjects.checked) {
			num=1;
			AllOK=true;
		} else {
			for (i=0;i<oObjects.length;i++) {
				if (oObjects[i].checked) {
					AllOK=true;
					num++;
				}
			}
		}
	} else {
		alert('There is no '+ objname + '(s) available to select.');
		return false;
	}
	if (AllOK) {
		var msgStr;
		msgStr = 'Are you sure you want to ' + action +' '+num+' '+objname+'(s)?';
		if (confirm(msgStr)) {
			oForm.action=oForm.action.replace(/h=[^&]+&?/,'h=do'+objname+'_export&');
			oForm.submit();
			return false;
		}
	} else
		alert('Please select at least one '+ objname + ' to '+action+'.');
	return false;
}



////////////////
function removeItem(loc,objname,action) {
	if (confirm('Are you sure you want to '+action+' this '+objname+'?')) {
		window.location = loc;
		return true;
	}
	return false;
}
function clearFrm() {
	if (confirm('Are you sure you want to clear all data in the form?'))
		window.location=window.location;
}

function checkValidDate(dt,msg) {
	var arrLastDay = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	if (msg == "") msg = "date";
	if (dt.value != 0) {
		var re=/^((0?\d)|(1[0-2]))\/(([0-2]?\d)|(3[0-1]))(\/(\d{1,4}))?$/;
		if (dt.value.search(re)==-1) {
			alert("Please enter a valid "+msg+".");
			dt.value="";
			dt.focus();
			return false;
		}else {
			var arrDates = dt.value.split("/");
			var iDay = arrDates[1];
			var iMonth = arrDates[0];
			var iYear;
			
			if (arrDates.length == 3) {
				 iYear = arrDates[2];
			} else {
				today = new Date();
				iYear = today.getYear();
			}
			
			var bRes = IsLeapYear(iYear);
			if (bRes == 1){
				arrLastDay[1]=29;
			} else {
				arrLastDay[1]=28;
			}
			
			if (iDay > arrLastDay[iMonth-1]){
				alert("The day you entered exceeds range of month. Please enter another one");
				dt.focus();
				return false;
			}
			
			if (parseInt(iYear) < 1900 && parseInt(iYear) > 99){
				alert("Please enter year greater than 1900");
				dt.focus();
				return false;
			}
		}
		return true;
	}
	return true;
}
function checkDate(dt,msg) {
	var arrLastDay = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	if (msg == "") msg = "date";
	if (dt.value == 0) {
		alert("Please enter "+msg+".")
	    dt.focus();
	    return false;
	} else {
		var re=/^((0?\d)|(1[0-2]))\/(([0-2]?\d)|(3[0-1]))(\/(\d{1,4}))?$/;
		if (dt.value.search(re)==-1) {
			alert("Please enter a valid "+msg+".");
			dt.value="";
			dt.focus();
			return false;
		} else {
			var arrDates = dt.value.split("/");
			var iDay = arrDates[1];
			var iMonth = arrDates[0];
			var iYear;
			
			if (arrDates.length == 3) {
				 iYear = arrDates[2];
			} else {
				today = new Date();
				iYear = today.getYear();
			}
			
			var bRes = IsLeapYear(iYear);
			if (bRes == 1){
				arrLastDay[1]=29;
			} else {
				arrLastDay[1]=28;
			}
			
			if (iDay > arrLastDay[iMonth-1]){
				alert("The day you entered exceeds range of month. Please enter another one");
				dt.focus();
				return false;
			}
			
			if (parseInt(iYear) < 1900 && parseInt(iYear) > 99){
				alert("Please enter year greater than 1900");
				dt.focus();
				return false;
			}
		}
		return true;
	}
	return false;
}

function checkDateE(dt,msg) {
	var arrLastDay = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	if (msg == "") msg = "date";
	if (dt.value == 0) {
		alert("Please enter "+msg+".")
	    dt.focus();
	    return false;
	} else {
		var re=/^((0?\d)|(1[0-2]))\/(([0-2]?\d)|(3[0-1]))(\/(\d{1,4}))?$/;
		if (dt.value.search(re)==-1) {
			alert("Please enter a valid "+msg+".");
			dt.value="";
			dt.focus();
			return false;
		} else {
			var arrDates = dt.value.split("/");
			var iDay = arrDates[1];
			var iMonth = arrDates[0];
			var iYear;
			
			if (arrDates.length == 3) {
				 iYear = arrDates[2];
			} else {
				today = new Date();
				iYear = today.getYear();
			}
			
			var bRes = IsLeapYear(iYear);
			if (bRes == 1){
				arrLastDay[1]=29;
			} else {
				arrLastDay[1]=28;
			}
			
			if (iDay > arrLastDay[iMonth-1]){
				alert("The day you entered exceeds range of month. Please enter another one");
				dt.focus();
				return false;
			}
			
			if (parseInt(iYear) < 1900 && parseInt(iYear) > 99){
				alert("Please enter year greater than 1900");
				dt.focus();
				return false;
			}
		}
		return true;
	}
	return false;
}

function IsLeapYear(p_year) {
        /*
        Check for leap year ..
        1.Years evenly divisible by four are normally leap years, except for...
        2.Years also evenly divisible by 100 are not leap years, except for...
        3.Years also evenly divisible by 400 are leap years.
        */
        if ((p_year % 4) == 0) {
                if ((p_year % 100) == 0 && (p_year % 400) != 0)
                        return 0;

                return 1;
        } else
                return 0;
}
function checkEmail(eml) {
	if (eml.value == 0) {
		alert("Please enter email address.")
	    eml.focus();
	    return false;
	} else {
		  var re=/^['%\w\.\+-]*@[\w\+-]+(\.[\w\+-]+)*\.[\w\+-]+$/;
		if (eml.value.search(re)==-1) {
			alert("Please enter a valid email address.");
			eml.focus();
			return false;
		}
		return true;
	}
	return false;
}

function close_win(bRefresh){
	if (document.all){
		window.parent.returnValue=bRefresh;
	} else {
		if (bRefresh) 
			window.parent.opener.document.location.href = window.parent.opener.document.location.href;
	}
	window.parent.close(); 
}

// from document_edit
function AttachReminder() {
	frm = document.forms[0];
	if (fCheck(frm)) {
		if (frm.elements['attachment'].value != 0){
			if (confirm('You have selected a file that hasn\'t been attached yet.\n\rDo you want to attach it?')) {
				return false;
			}
		}
		try {
			if (frm.elements['mergefile'].value != 0){
				if (confirm('You have created a merge letter that hasn\'t been attached yet.\n\rDo you want to attach it?')) {
					return false;
				}
			}
		} catch(e) {
		}
		if ((frm.elements['URL'].value != 'http://') && (frm.elements['URL'].value != 0)){
			if (confirm('You have entered a link that hasn\'t been attached yet.\n\rDo you want to attach it?')) {
				return false;
			}
		}
		return true;
    }
    return false;
}

function AttachLogo() {
	frm = document.forms[0];
	if (fCheck(frm)) {
		if (frm.elements['attachment'].value != 0){
			if (confirm('You have selected a file that hasn\'t been attached yet.\n\rDo you want to attach it?')) {
				return false;
			}
		}
		return true;
    }
    return false;
}

function AddAttachment(actstring) {
	document.all.upld.style.display='block';
	form = document.forms[0];
	if (form.elements['attachment'].value == 0) {
		alert('Please select file.');
		return false;
	}
	else {
		if (form.elements['attachment'].value.lastIndexOf('.')<form.elements['attachment'].value.lastIndexOf('\\') || form.elements['attachment'].value.lastIndexOf('.')==-1 || form.elements['attachment'].value.lastIndexOf('\\')==-1) {
			alert ('NetageVC does not allow uploading files without extension');
			return false;
		}
		if (fCheck(form)) {
			form.action = actstring;
			form.submit();
			return true;
		}
	}
	return false;
}
function DeleteAttachment(actstring) {
	if (confirm('Are you sure you want to delete this file?')) {
		form = document.forms[0];
		form.action = actstring;
		form.submit(actstring);
		//return true;
	}
	//return false;
}

function DelLetter(actstring) {
	if (confirm('Are you sure you want to delete this letter?')) {
		form = document.forms[0];
		form.action = actstring;
		form.submit();
	}
}
function AddLetter(actstring) {
	form = document.forms[0];
	if (form.elements['merge'].value == 0) {
		alert('Please create template.');
		return false;
	}
	else {
		if (fCheck(form)) {
			form.action = actstring;
			form.submit();
			return true;
		}
	}
	return false;
}		
function CreateLetter(url) {
	var strMsg="";
	try {
		var strResult=oMerge.CheckRequirements();
		switch(strResult) {
			case "NoWord":
				strMsg="Microsoft® Word is not installed on your computer." & vbNewLine & "Please install Microsoft Word version 2000 or 2002 and try again.";
				break;
			case "WrongWordVersion":
				strMsg="The necessary version of Microsoft® Word is not installed on your computer." & vbNewLine & "Please install Microsoft Word version 2000 or 2002 and try again.";
				break;
			case "NoXML":
				strMsg="The necessary XML Parser is not installed on your computer." & vbNewLine & "Please install Microsoft® XML Parser 2.5 or later and try again.";
				break;
			case "NoADO":
				strMsg="The necessary version of Microsoft ADO is not installed on your computer." & vbNewLine & "Please install Microsoft® ActiveX Data Objects version 2.0 or later and try again.";
			case "OK":
				strMsg=""
				break;
			default:
				strMesg="Unknown error";
		}
		if (strMsg!='') {
			alert("Sorry, NetageVC cannot proceed with your document merge request. " + strMsg);
			return;
							
		}
					
	}
	catch (e) {
		alert("You must enable running ActiveX controls to enable Mail Merge functionality.");
		return;
	}
	
	var newObj = modup('modal.asp?src=document_merge.asp&'+url,'',450,360,140,320);	
	if (newObj && newObj.Names!='Cancel') {
			document.forms[0].mergefile.value = newObj.Names;
			//document.forms[0].mergefile.value = newObj.IDs;
	}
	return;
}

function AddLink(actstring) {
	form = document.forms[0];
	if (form.elements['URL'].value == 0) {
		alert('Please enter link.');
		return false;
	}
	else {
		if (fCheck(form)) {
			form.action = actstring;
			form.submit();
			return true;
		}
	}
	return false;
}
function DeleteLink(actstring) {
	form = document.forms[0];
	if (confirm('Are you sure you want to delete this link?')) {
		if (fCheck(form)) {
			form.action = actstring;
			form.submit();
			return true;
		}
	}
	return false;
}
//------------------


function hideall() {
	MM_showHideLayers('general','','hide','companies','','hide','contacts','','hide','notes','','hide','documents','','hide','diligence','','hide','products','','hide','referrals','','hide','events','','hide','publish','','hide','pfrequests','','hide','irequests','','hide','requests','','hide','rating','','hide','funds','','hide','my','','hide','hpage','','hide','prefs','','hide','portfolio','','hide','investors','','hide');
}

function print_pager(){
	if (document.all) { 
		print();
	}
	else { 
		window.print();
	}
}

function modalwin(url, param, wid, hei, lft, tp) {
	return window.showModalDialog(url,param,"dialogWidth:"+wid+"px;dialogHeight:"+hei+"px;dialogLeft:"+lft+"px;dialogTop:"+tp+"px;status:no;resizable:yes;");
}
/*
function modup(url, param, wid, hei, lft, tp) {
	var bwinmod ; 
	if (bwinmod = window.showModalDialog(url,param,"dialogWidth:"+wid+"px;dialogHeight:"+hei+"px;dialogLeft:"+lft+"px;dialogTop:"+tp+"px;status:no;")
		if (bwinmod) {
			window.location.reload();
		}
	return bwinmod;
}*/
var newWindow = new Object();
function modup(url, param, wid, hei, lft, tp) {
	if (document.all) {
		var bwinmod ;
		bwinmod = window.showModalDialog(url,param,"dialogWidth:"+wid+"px;dialogHeight:"+hei+"px;dialogLeft:"+lft+"px;dialogTop:"+tp+"px;status:no;resizable:yes;");
		if (bwinmod) {
			var url=new String(window.location.href);
			var re=/changed=[^&?]*/;
			if (url.indexOf('changed=')>-1) {
				url=url.replace(re,'changed=1');
			} else {
				url=url + '&changed=1';
			}
			window.location=url;
		}
		return bwinmod;
	}
	else {
		if (!newWindow.win || (newWindow.win && newWindow.win.closed)) {
			id = Math.random();
			id = id.toString();
			re_d = /\.|,/g;
			id = id.replace(re_d,'');
			wname = 'NetageVC'+id;
			newWindow.returnedValue='';
			newWindow.name=wname;
			newWindow.url=url;
			newWindow.width = wid;
			newWindow.height = hei;
			var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4));
			var attr;
			if (Nav4) {
				newWindow.left = window.screenX + ((window.outerWidth - newWindow.width) / 2);
				dialogWin.top = window.screenY + ((window.outerHeight - newWindow.height) / 2);
				attr = "screenX=" + newWindow.left + ",screenY=" + newWindow.top + ",width=" + newWindow.width + ",height=" + newWindow.height;
			} else {
				newWindow.left = (screen.width - newWindow.width) / 2;
				newWindow.top = (screen.height - newWindow.height) / 2;
				attr = "left=" + newWindow.left + ",top=" + newWindow.top + ",width=" + newWindow.width + ",height=" + newWindow.height;
			}
			newWindow.win = window.open(url, wname, 'toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,location=no,'+attr);
			newWindow.win.focus();
	//		window.open(url, wname, "toolbar=no,menubar=no,scrollbars=yes,resizable=no,status=no,location=no,height="+hei+",width="+wid+",screenX="+lft+",screenY="+tp+",dependent=yes");
	//////////////////////////////// cyrilic :)
		//	if (document.layers) newWindow.document.open(charset=windows-1251);
	////////////////////////////////
			newWindow.focus();
		}
		else {
			newWindow.focus();
		}
	}
}

// Mozilla modal windows and return values
if (!document.all && top.opener) {
// Return 1 on form submit
	window.onsubmit=function(){
		newWindow.returnedValue=1;
	}
// If form is submitted, attach onunload event to refresh parent windows.
	window.onunload=function(){
		if(newWindow.returnedValue){
			if(top.opener)
				top.opener.location.reload();
			if(top.opener.top.opener)
				top.opener.top.opener.location.reload();
			if(top.opener.top.opener.top.opener)
				top.opener.top.opener.top.opener.location.reload();
		}
	}
}
// If Mozilla - check for existing modal windows on focus.
if (!document.all) {
	window.onfocus=function() {
		checkModal();
	}
}
// If Mozilla - check for existing modal windows on focus.
function checkModal() {
	setTimeout("finishChecking()", 50);
	return true;
}
// If Mozilla - check for existing modal windows on focus.
function finishChecking() {
	if (newWindow.win && !newWindow.win.closed) {
		newWindow.win.focus();
	}
}
/*
function popupFF(url, winname, wid, hei, lft, tp) {
//	if (winname == "") {
		id = Math.random();
		id = id.toString();
		re_d = /\.|,/g;
		id = id.replace(re_d,'');
		wname = winname+'NetageVC'+id;
//	}
	var newWindow;
	if (document.all) {
		newWindow = window.open(url, wname, "toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height="+hei+",width="+wid+",left="+lft+",top="+tp+",dependent=yes");
		//newWindow = window.open(url, wname, "height="+hei+",width="+wid+",left="+lft+",top="+tp+",dependent=yes");
	} else { //if (document.layers || document.getElementById) {
		//newWindow = window.open(url, wname, "toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height="+hei+",width="+wid+",screenX="+lft+",screenY="+tp+"");
		////newWindow = window.open(url, wname, "height="+hei+",width="+wid+",left="+lft+",top="+tp+);	
		
		newWindow = window.open(url, wname, 'toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height='+hei+',width='+wid+',screenX='+lft+',screenY='+tp);
		window.open(url, wname, "toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height="+hei+",width="+wid+",screenX="+lft+",screenY="+tp+",dependent=yes");
	}
	newWindow.focus();
}*/

function popupFF(url, winname, wid, hei, lft, tp) {
	id = Math.random();
	id = id.toString();
	re_d = /\.|,/g;
	id = id.replace(re_d,'');
	wname = winname + 'NetageVC'+id;
	var newWindow;	
	if (document.all) {
		newWindow = window.open(url, wname, 'toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height='+hei+',width='+wid+',left='+lft+',top='+tp+',dependent=yes');
	}
	else {
		newWindow = window.open(url, wname, 'toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height='+hei+',width='+wid+',screenX='+lft+',screenY='+tp);
		window.open(url, wname, 'toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,status=yes,location=yes,height='+hei+',width='+wid+',screenX='+lft+',screenY='+tp+',dependent=yes');
	}
	newWindow.focus();
}

function modup_tab(url, param, wid, hei, lft, tp, tab, pg, sort_by) {
	if (document.all) {
		var bwinmod ; 
		if (bwinmod = window.showModalDialog(url,param,"dialogWidth:"+wid+"px;dialogHeight:"+hei+"px;dialogLeft:"+lft+"px;dialogTop:"+tp+"px;status:no;resizable:yes;")){
			var url=new String(window.location.href);
			var re=/tab=[^&?]*/;
			if (url.indexOf('tab=')>-1) {
				url=url.replace(re,'tab='+tab);
			} else {
				url=url + '&tab='+ tab;
			}
			if (pg > 0) {
				re = /page=[^&?]*/;
				if (url.indexOf('page=')>-1) {
					url=url.replace(re,'page='+pg);
				} else {
					url=url + '&page='+ pg;
				}
			}
			re=/changed=[^&?]*/;
			if (url.indexOf('changed=')>-1) {
				url=url.replace(re,'changed=1');
			} else {
				url=url + '&changed=1';
			}
			
			
			re_sortby=/SortBy=[^&?]*/;
			if (!sort_by) sort_by = '';
			if (url.indexOf('SortBy=')>-1 && sort_by != '') {
				url=url.replace(re_sortby,'SortBy='+sort_by);
			}
			window.location=url;
		}
		return bwinmod;
	}
	else {
		id = Math.random();
		id = id.toString();
		re_d = /\.|,/g;
		id = id.replace(re_d,'');
		wname = 'NetageVC'+id;
		newWindow = window.open(url, wname, 'toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,location=no,height='+hei+',width='+wid+',screenX='+lft+',screenY='+tp);
//		window.open(url, wname, "toolbar=no,menubar=no,scrollbars=yes,resizable=no,status=no,location=no,height="+hei+",width="+wid+",screenX="+lft+",screenY="+tp+",dependent=yes");
//////////////////////////////// cyrilic :)
	//	if (document.layers) newWindow.document.open(charset=windows-1251);
////////////////////////////////
		newWindow.focus();
	}
}

function fileview(url) {
	if (window.showModalDialog(url,'',"dialogWidth:200px;dialogHeight:600px;status:no;resizable:yes;unadorned:yes")){
		window.location.reload();
	}
}

function popup(url, winname, wid, hei, lft, tp) {
//	if (winname == "") {
		id = Math.random();
		id = id.toString();
		re_d = /\.|,/g;
		id = id.replace(re_d,'');
		wname = winname+'NetageVC'+id;
//	}
	if (document.all) {
		newWindow = window.open(url, wname, "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,location=no,height="+hei+",width="+wid+",left="+lft+",top="+tp+",dependent=yes");
	} else if (document.layers || document.getElementById) {
		newWindow = window.open(url, wname, "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,location=no,height="+hei+",width="+wid+",screenX="+lft+",screenY="+tp+"");
	//////////////////////////////// cyrilic :)
		//	newWindow.document.open(charset=windows-1251);
	////////////////////////////////
		
	}
	newWindow.focus();
}

function getpopup_tab_url(url_src, tab)
{
	var re=/tab=[^&?]*/;
var url=new String(window.parent.opener.location);
	if (url.indexOf('tab=')>-1) {
		url=url.replace(re,'tab='+tab);
	} else {
		url=url + '&tab='+ tab;
	}
	return url;
}
/* used for demo only until now
function modupnn (url, param, wid, hei, lft, tp) {
	if (document.layers) {
		modup(url, param, wid, hei, lft, tp);
	}
}
*/
///////////////////////// checkbox selector
function SelectAll(fname) {
	for (var i=0;i<document.forms[fname].elements.length;i++) {
		var e = document.forms[fname].elements[i];
		if ((e.name != 'selector') && (e.type=='checkbox'))
			e.checked = document.forms[fname].selector.checked;
	}
}

function CheckSelected() {
	var chkID;
	var nIsPrimary;
	var fname=CheckSelected.arguments[0];
	if (CheckSelected.arguments.length>1) {
		chkID=CheckSelected.arguments[1]; 
		nIsPrimary=document.forms[fname].elements('isprimary'+chkID).value;
		
	} else {
		chkID=0;
		nIsPrimary=0;
	}
	if (nIsPrimary==1) {
		alert('Selected contact is primary for its company. It can not be deleted');
		
	}
	var TotalBoxes = 0;
	var TotalSelected = 0;
	for (var i=0;i<document.forms[fname].elements.length;i++) {
		var e = document.forms[fname].elements[i];
		if ((e.name != 'selector') && (e.type=='checkbox')) {
			TotalBoxes++;
			if (e.checked) {
				TotalSelected++;
			}
		}
	}
	if (TotalBoxes==TotalSelected) {
		document.forms[fname].selector.checked=true;
	}
	else {
		document.forms[fname].selector.checked=false;
	}
}
///////////////////////// checkbox selector

///////////////////////// paging
	function gotoPage(intNumber,strLink, iMaxPage){
		var minPage=1;
		var maxPage=iMaxPage;
		
		
		if ((intNumber<= maxPage) && (intNumber >= minPage)){
			//window.location.replace(strLink+ '&page='+intNumber);
			window.location = strLink+ '&page='+intNumber;
		}
	}
///////////////////////// paging

///////////////////////// alerts for PWS
function showPWSalert(oSel,sType){
	if (oSel.value == 3 || oSel.name == 'ShowInPWS' && oSel.value == 1){ // ShowInPWS in events , ShowIn otherwise
		return modup('../common/modal.asp?src=PWSalert.asp&fl='+sType,'',460,290,160,380);
	}
	return true;
}
/////////////////////////

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



//Acorn Campus Only
function helpwin(URL){	
	var sName,sWidth,sHeight,sXpos,sYpos,sScroll,sResize;
	sName = 'Help';
	sWidth = '330';
	sHeight = screen.availHeight - 250;
//	sXpos = '20';
//	sYpos = '40';
	sXpos = '3000';
	sYpos = '3000';
	sScroll = 'yes';
	sResize = 'yes';
	
	//handled agruments if they are left blank
	if (helpwin.arguments.length > 1){
		sName = helpwin.arguments[1];
		sWidth = helpwin.arguments[2];
		sHeight = helpwin.arguments[3];
		sXpos = helpwin.arguments[4];
		sYpos = helpwin.arguments[5];
		sScroll = helpwin.arguments[6];
		sResize = helpwin.arguments[7];
	}

	var winBars = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no';
	var winOptions = 'scrollbars='+ sScroll + ',resizable='+ sResize;
	var winSize = 'height=' + sHeight + ',width=' + sWidth;
	var winPosition = 'left=' + sXpos + ',top=' + sYpos;
	var winFeatures = winBars + ',' + winOptions + ',' + winSize + ',' + winPosition;
			
				
	newWindow = window.open(URL,sName,winFeatures);
	pixleft = screen.availWidth-340;
	pixtop = 140;
	newWindow.moveTo(pixleft, pixtop);
	newWindow.focus();
}

function trim_field_value(form_name, field){
	var re = /( )*/;
	var the_form = document.forms[form_name];
	var the_value =  eval('the_form.' + field + '.value');
	var trim_value = the_value.replace(re, "");

	return trim_value;
}

//Attach Existing Company/Contact - Check Search Criteria
function fCheckCriteria(frm, form_name, fld_name, lbl_field, min_lenngth){
	var trim_name;
	trim_name = trim_field_value(form_name, fld_name);
	
	if (trim_name == ''){
		alert('Please enter '+lbl_field+'.');
		frm.name.focus();
		return false;
	}
	
	if (trim_name.length < min_lenngth){
		alert('Please enter '+lbl_field+' longer than '+(min_lenngth-1)+' symbols.');
		frm.name.focus();
		return false;
	}
}

//Operate Documents (Merge/Notify)
function OperateDoc(formname, fieldname, pIDs, pAct, sTxt){
	var sMessage = sTxt;
	if (confirm(sMessage)){
		var oForm=document.forms[formname];
		oForm.elements[fieldname].value = 1;
		oForm.elements['change_status_to'].value = pAct;
		oForm.elements['change_status_of'].value = pIDs;
		oForm.submit();
	}
	return false;
}
// Adds value for notification after merge
function GetNotificationValue(pModUrl){
	var strNotify=modup(pModUrl,'',300,150,400,300);
	return strNotify;
}
// Disables Ctrl+N for IE

function keyDown(e) {
	if (document.all && (event.keyCode == 78) && (event.ctrlKey)){
		event.cancelBubble = true;
		event.returnValue = false;
		event.keyCode = false; 
		return false;
	}
}
if (document.all) document.onkeydown = keyDown;
//-->