


function isAllowedCharForInput(c) {
   return (((c>= "0") && (c <= "9")) || ((c >= "A") && (c <= "z")) || (c == ".") || (c =="-") || (c =="_"));
}
function isValidAlpha(inputVal){
   for (var i=0;i<inputVal.length;i++)
	 if (!isAllowedCharForInput(inputVal.charAt(i))) {
	            alert('Search name cannot include '+inputVal.charAt(i));
		    	return false;
		}
   return true;
}
	function isAllowedCharForDouble(c) {
	    return (((c>= "0") && (c <= "9")) || (c == ".") || (c =="-") || (c =="+"));
    	}
	function isAllowedCharForInt(c){
  	    return ((c>= "0") && (c <= "9"));
	}
	
	function isAPosNumber(inputVal){
		for (var i=0;i<inputVal.length;i++){
		    if (!isAllowedCharForInt(inputVal.charAt(i))) 
		    	return false;
		}
 	   	return true;
	}
	function isADouble(val){
	    if (val.length == 0) return true;
	    var first = val.charAt(0);
	    var gotDot = false;
	    var gotDigit = false;
	    if (!isAllowedCharForDouble(first)) return false;
	    if (first == ".") gotDot = true;
	    if (isAllowedCharForInt(first)) gotDigit = true;
	    if (val.length == 1) {
	    	if (gotDigit) return true;
	    	else return false;
	    }
	    for (var i=1;i<val.length;i++){
	        if (val.charAt(i) == ".") {
	        	if (gotDot) return false;
	        	else gotDot = true;
	        }
	        else {
	        	if (isAllowedCharForInt(val.charAt(i))) gotDigit = true;
		        else return false;
		}
	    }
	    if (!gotDigit) return false;
	    else return true;
	}
	
	function isADate(s) {
		var month;
		var day;
		var year;
		var mIndex, dIndex, yIndex;
		var currentDate, enteredDate;
		if (s.length == 0) return true;
		mIndex = s.indexOf("/");
		if (mIndex == -1)
		    return false;
		month = s.substring(0,mIndex);
		if (!isAPosNumber(month)) return false;
		dIndex = s.indexOf("/", mIndex+1);
		if (dIndex == -1)
		    return false;
		day = s.substring(mIndex+1,dIndex);
		if (!isAPosNumber(day)) return false;
		year = s.substring(dIndex+1,s.length);
		if (!isAPosNumber(year)) return false;

		if ((month < 1) || (month > 12))
		    return false;
		if ((day < 1) || (day > 31))
		    return false;
		if ((year < 1900) || (year > 3000))
		    return false;

		currentDate = new Date();
		enteredDate = new Date(year, (month-1), day, currentDate.getHours(),
				   currentDate.getMinutes(), currentDate.getSeconds());
		if ((currentDate - enteredDate) <= 0)
			return false;

		return true;    
	}
	
var newwin, newpop;
// default values
var popWinName="popWin";
var newWinName="newWin";
var popWidth=625;
var popHeight=470;
var newWinWidth=640;
var newWinHeight=600;
var expDays=1;
var validated=true;
var reSize = "no";
// -----------------------
// DESCRIPTION: pop-up window
// ARGUMENTS: filename, &name, &width, &height, &scroll
// RETURN: --
// -----------------------
function popUp(filename){
	var argv=popUp.arguments;  
	var argc=argv.length;  
	var name=(argc>1) ? argv[1] : popWinName;  
	var w=(argc>2) ? argv[2]:popWidth;
	var h=(argc>3) ? argv[3]:popHeight;
	var s=(argc>4) ? argv[4]:reSize;
	var scroll=(argc>5) ? argv[5]:"yes";
	var left=(argc>6) ? argv[6]:200;
	var top=(argc>7) ? argv[7]:100;
	window.name="ToolboxWin";
	if(!newpop||newpop.closed) {
		newpop=window.open(filename, name, "toolbar=no,width="+w+",height="+h+",menubar=no,resizable=yes,status=no,scrollbars="+scroll+",left="+left+",top="+top);
	} else {
		newpop.focus();
		newpop.location = filename;
	}
}

    function showGlossaryTerm(term,code,parmString) {
         var s = "/SP/editorial/Glossary.do?term="+term+"&code="+code+"&"+parmString;

        if( this.window.location.search.indexOf("sp_popup=YES")>0 )  s = s +"&sp_popup=YES";
        if( this.window.location.search.indexOf("sp_glossary=YES")>0 )  s = s +"&sp_glossary=YES";          
    
         if( this.window.location.search.indexOf("sp_popup=YES")>0  ||  this.window.location.search.indexOf("sp_glossary=YES")>0 )  {
         		this.window.location = s;     
         	}     else  {
       	remote = window.open(s,"glossaryWindow","width=510,height=410,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes");        
  	   	if (browserName != "Microsoft Internet Explorer") 
 			remote.focus();            	
        }		
     }

 	function showGlossaryTermPopup(term,code, parmString) {
     		browserName = navigator.appName;
	     	browserVer = navigator.appVersion;
    	 	browserVer = browserVer.substring(0,1);
    	 	if (browserVer == '.') browserVer = 2;
    	 	else browserVer = browserVer;
    	 	//old Netscape alert
     		if (browserName == "Netscape" && browserVer < 3) 
 			alert('This feature is unreliable with your version of Netscape.');
 
       	remote = window.open("/SP/editorial/Glossary.do?term=" + term + "&code=" + code +  "&sp_popup=YES&"+parmString,"glossaryWindow","width=490,height=410,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=yes,resizable=yes");        
  	   	if (browserName != "Microsoft Internet Explorer") 
 			remote.focus();   
 }
 
 
function openFeature() 
{
    	var argv=openFeature.arguments;  
	var argc=argv.length;  
	var w=(argc>1) ? argv[1]:popWidth;
	var h=(argc>2) ? argv[2]:popHeight;
	var s=(argc>3) ? argv[3]:reSize;
	var scroll=(argc>4) ? argv[4]:"yes";
	var winParam = "toolbar=no,width="+w+",height="+h+",directories=no,location=no,menubar=no,status=no,personalbar=no,scrollbars="+scroll+",resizable="+s;
	
	if( document.theForm.pagename.selectedIndex == 0 )
        {
            alert('You must select a Portfolio.');
            return false;
        }
	
     window.open('/WS/none.html', 'FeatureWindow', 'toolbar=no,width=600,height=440,directories=no,location=no,menubar=no,status=no,personalbar=no,scrollbars=yes,resizable=yes');	
      
     return true;
}

function showGlossaryTermPopupLetter(letter,typestring, parmString) {
     		browserName = navigator.appName;
	     	browserVer = navigator.appVersion;
    	 	browserVer = browserVer.substring(0,1);
    	 	if (browserVer == '.') browserVer = 2;
    	 	else browserVer = browserVer;
    	 	//old Netscape alert
     		if (browserName == "Netscape" && browserVer < 3) 
 			alert('This feature is unreliable with your version of Netscape.');
 
       	remote = window.open("/SP/editorial/Glossary.do?letter=" + letter + "&type=" + typestring +  "&sp_popup=YES&sp_glossary=YES&"+parmString,"glossaryWindow","width=490,height=410,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=yes,resizable=yes");        
  	   	if (browserName != "Microsoft Internet Explorer") 
 			remote.focus();   
 }

