function forINCheck(obj)
{
var prop; var txt="";
for(prop in obj)
{if(typeof(obj[prop])=="string") txt+=prop+'\n';}
alert(txt);
}

function OraFormatDate(str)
  {
   if(!isOraFmt(str))
   {
   if((str=="")||(str==" ")||(str==null))str=initDate();
   var months = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
    var dateArr=new Array(); dateArr= str.split("/");
   if(dateArr[0]<1)dateArr[0]=1;
   var mon = months[(parseInt(dateArr[0]))-1].toUpperCase();
  
   if(dateArr[1].length==1)
     dateArr[1]="0"+dateArr[1];
   
  if(dateArr[2].length==2)
     dateArr[2]='20'+dateArr[2];

 
 return (dateArr[1]+"-"+mon+"-"+dateArr[2]);
   }
   else return str;
  }
//correct format for mySQL is yyyy-mm-dd
function mySQLDate(str)
 {
  //regex should be ##/##/####
  var pattern = /^([01]{0,1}\d)\/?([0123]{0,1}\d)\/?((19|20)\d{2})$/;

	if(pattern.test(str))
	{
   if((str=="")||(str==" ")||(str==null))str=initDate();
   var dateArr=new Array(); dateArr= str.split("/");
   //split from mm/dd/yyyy
   
    if(dateArr[1].length==1) dateArr[1]="0"+dateArr[1];
     if(dateArr[2].length==2) dateArr[2]='20'+dateArr[2];
   
   return (dateArr[2]+"-"+dateArr[0]+"-"+dateArr[1]);
   }
   else return str;
 }//end mySQLDate  
   
  function changeToOra(formField)
  {var date = (typeof formField == "object")?formField:find_obj(formField);
   date.value = OraFormatDate(date.value);
  }
  
   function makeDateFromOra(str)
  {
   var months = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
    str=str.substring(0,11); //##-lll-####
   var dateArr=new Array(); 
   dateArr= str.split("-");
   
    for(var i=0; i<months.length; i++)
       if(dateArr[1].toLowerCase()==months[i])
	      {dateArr[1]=i; break;}
   
   return (dateArr[1]+"/"+dateArr[0]+"/"+dateArr[2]);
   
  }
  
  function isOraFmt(str)
   {flag =false;
    var months = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"); 
  for(var i=0; i<months.length; i++)
     if((str.indexOf(months[i].toUpperCase())!=-1))
	      {flag=true; break;}
  return flag;
  }    
  
  function initDateff(formField)
    {
	var date = (typeof formField == "object")?formField:find_obj(formField);
	var currDate = new Date();
var mon =currDate.getMonth(); mon++; var day = currDate.getDate();
var yr = currDate.getFullYear();

if(mon>12){mon=1; yr++}
	date.value = (mon+"/"+day+"/"+yr);
	
    }

  function initDate()
    {
	var currDate = new Date(); var mon =currDate.getMonth(); 
	mon++; var day = currDate.getDate();
var yr = currDate.getFullYear();

if(mon>12){mon=1; yr++}
	return (mon+"/"+day+"/"+yr);
	
    }
	
	
	 function initDateRange(formField_from, formField_to)
    {  var date_from = (typeof formField_from == "object")?formField_from:find_obj(formField_from);
	var date_to = (typeof formField_to == "object")?formField_to:find_obj(formField_to);
	var currDate = new Date(); var mon =currDate.getMonth(); mon++; 
	var day = currDate.getDate(); var yr = currDate.getFullYear();
    if(mon>12){mon=1; yr++}
	
	if((mon-1)==0){mon=12; yr--;}
		date_from.value = (mon-1+"/"+day+"/"+yr);
	   	date_to.value = (mon+"/"+day+"/"+yr);
    
	}
	
	
 function initDateRangeStr()
    {
	var currDate = new Date(); var mon =currDate.getMonth(); mon++; 
	var day = currDate.getDate(); var yr = currDate.getFullYear();
    if(mon>12){mon=1; yr++}
	
	if((mon-1)==0){mon=12; yr--;}
		
		return ((mon-1+"/"+day+"/"+yr)+"#"+(mon+"/"+day+"/"+yr));
    
	}
	
	function initDateRangeArr()
    {
	 var dateRngstr = initDateRangeStr();
	 var datearr = dateRngstr.split("#");
	 
	 return datearr;
	}
	
	function getUiStr()
	{
	   var dt = new Date();
	  var dtstr = dt.getMonth().toString()+dt.getDate().toString()+dt.getFullYear().toString()+dt.getHours().toString()+dt.getMilliseconds().toString(); // in format MMDDYYYYHH24MISS 
	return dtstr;
	}
	
	function getOptList(fld)
	{
	var txt=""; var grp = (typeof fld == "object")?fld:find_obj(fld); 
	
 for(var i=0; i<grp.length; i++)
     { if(grp.options[i].selected)
	       if(grp.options[i].value=="none") continue;
		   else
		     txt+=grp.options[i].value+"#";
	 }
	return txt;
	}
	//assgns a multiple option list to a hidden field and separates the values with a # 
	function getOptListAssgn(fld,hfld)
	{	var grp = (typeof fld == "object")?fld:find_obj(fld); 
	var hidfld = (typeof hfld == "object")?hfld:find_obj(hfld);
	var txt=""
   for(var i=0; i<grp.length; i++)
      if((grp.options[i].selected)&&(grp.options[i].value!="none"))
	     txt+=grp.options[i].value+"#";
	hidfld.value = txt;
	}
	
   function getDoctype(fld)
	{
	//"application/msword","application/vnd.ms-powerpoint","application/x-zip-compressed",
	//"text/plain","application/vnd.ms-excel","application/pdf","application/vnd.visio"
	var regex_word = /.doc/i;	var regex_word1 = /.html/i; 	var regex_word2 = /.htm/i;
	 var regex_powerpt = /.ppt/i; var regex_powerpt1 = /.pp2/i; var regex_powerpt2 = /.pot/i;
	 var regex_zip = /.zip/i; var regex_txt = /.rtf/i; var regex_txt1 = /.txt/i;
    var regex_exel = /.xl/i;   var regex_exel1 = /.xls/i;  var regex_exel2 = /.xlt/i;  
    var regex_pdf = /.pdf/i;
	var regex_vsio = /.vs/i; var regex_vsio1 = /.vsd/i; var regex_vsio2 = /.vss/i; var regex_vsio3 = /.vsd/i;
	
	var doc = find_obj(fld).value;
	
	if((doc.search(regex_word)!=-1)||(doc.search(regex_word1)!=-1)||(doc.search(regex_word2)!=-1))
	       return 0; 
		   
     if((doc.search(regex_powerpt)!=-1)||(doc.search(regex_powerpt1)!=-1)||(doc.search(regex_powerpt2)!=-1))
	       return 1;

	if((doc.search(regex_zip)!=-1))
        	return 2;
			
	if((doc.search(regex_txt)!=-1)||(doc.search(regex_txt1)!=-1))
        	return 3;
	
	   if((doc.search(regex_exel)!=-1)||(doc.search(regex_exel1)!=-1)||(doc.search(regex_exel2)!=-1))
	       return 4;

	if((doc.search(regex_pdf)!=-1))
        	return 5;

if((doc.search(regex_vsio)!=-1)||(doc.search(regex_vsio1)!=-1)||(doc.search(regex_vsio2)!=-1)||(doc.search(regex_vsio3)!=-1))
	       return 6;

else {alert("The document format type you are trying to upload in not accepted, please try another type."); return -1;}
			
	}
	
	
function timeConverter(stime,stimeAmPm,etime,etimeAmPm)
{
var timeFld = find_obj(stime); var amPm = find_obj(stimeAmPm);
var timeFld2 = find_obj(etime); var amPm2 = find_obj(etimeAmPm);

var pattern = /^(\d{1,2}):(\d{2})/;
var result = pattern.test(timeFld.value);
var tarr =  timeFld.value.split(":");
var tarr2 =  timeFld2.value.split(":");
var t1hr = parseInt(tarr[0]); var t1min = parseFloat(tarr[1]);
var t2hr = parseInt(tarr2[0]); var t2min = parseFloat(tarr2[1]);

//if(t1min==0)t1min="00"; if(t2min==0){t2min="00";} 

 if(result)
 {
if((amPm.selectedIndex==1)&&(t1hr<=12))
       {t1hr+=12; timeFld.value=t1hr+":"+t1min;  }
	if((amPm2.selectedIndex==1)&&(t2hr<=12))
       { t2hr+=12; timeFld2.value=t2hr+":"+t2min;}
	   
var hrdiff=0;
var mindiff=0;

if(((amPm.selectedIndex==1)&&(amPm2.selectedIndex==1))||((amPm.selectedIndex==0)&&(amPm2.selectedIndex==0))||((amPm.selectedIndex==0)&&(amPm2.selectedIndex==1)))
   hrdiff=t2hr-t1hr;
   
if((amPm.selectedIndex==1)&&(amPm2.selectedIndex==0))
	   hrdiff=(24-t1hr)+t2hr;

    	   
  if((t1min+t2min!=0)||((t1min!="00")&&(t2min!="00")))
    {    if(t2min>=t1min)
		     mindiff=t2min-t1min;
		  else
		   {mindiff=(60-t1min)+t2min; hrdiff--;}
	}
	
  }//end result

  return (hrdiff+":"+mindiff);
}//end function
	
function slice(arr,beginngIndex,endingIndex)
{
 var temp = new Array(); var count=0;
 
 if(arr && endingIndex<=arr.length)
   while(beginngIndex<endingIndex)
       {temp[count]=arr[beginngIndex]; beginngIndex++; count++;}
	    
	return temp;	
}


function GetParam(name)
{
  var start=location.search.indexOf("?"+name+"=");
  if (start<0) start=location.search.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=location.search.indexOf("&",start)-1;
  if (end<0) end=location.search.length;
  var result=location.search.substring(start,end);
  var result='';
  for(var i=start;i<=end;i++) {
    var c=location.search.charAt(i);
    result=result+(c=='+'?' ':c);
  }
  return unescape(result);
}

//This function is dependent on GetParam(). It is passed the paramName and the elseValue
//the paramname is the name of the string that is to be extracted from the query stirng and
//the elsevalue is what you want that value to be if a blank is returned. example url?someString=blah
//getParamValue("someString","blahblah") would return blah but if url?someSting= &..& it would return blahblah

function getParamValue(paramName,elseValue)
{
var header ="";
 header = GetParam(paramName);
 return ((header=="")||(header==" "))?elseValue:header;
}

//formatTeleNum accepts a 10 digit telephone number and a fommat choice returns a string with a specified format.
//the format string "dashes" return a number in the format ###-###-#### dashes_wp returns (###) ###-####
//"dashes_sp" return a number in the format ### ###-#### 
//the format string "dots" return a number in the format ###.###.#### dots_wp returns (###) ###.####
//"dots_sp" return a number in the format ### ###.#### 
function formatTeleNum(num,format)
{
 if(num.length==10)
   {
   if(format=="dashes") return (num.substring(0,3)+"-"+num.substring(3,6)+"-"+num.substring(6,num.length));
   if(format=="dashes_wp") return ("("+num.substring(0,3)+") "+num.substring(3,6)+"-"+num.substring(6,num.length));
   if(format=="dashes_sp") return (num.substring(0,3)+" "+num.substring(3,6)+"-"+num.substring(6,num.length));
   //dots 
   if(format=="dots") return (num.substring(0,3)+"."+num.substring(3,6)+"."+num.substring(6,num.length));
   if(format=="dots_wp") return ("("+num.substring(0,3)+") "+num.substring(3,6)+"."+num.substring(6,num.length));
   if(format=="dots_sp") return (num.substring(0,3)+" "+num.substring(3,6)+"."+num.substring(6,num.length));
   }

else return num;
}

//function takes in a 10 digit telephone number and retruns an array
//with the array[0] being the npa, array[1] being the nxx, and array[2]
//being the line. if the input parameter is not 10 digits long it will return the string "N/A"
function breakTeleNum(num)
{
 var tnArray = new Array();

  if(num.length==10)
   {
    tnArray[tnArray.length]=num.substring(0,3); 
    tnArray[tnArray.length]=num.substring(3,6);
    tnArray[tnArray.length]=num.substring(6,num.length);
   return tnArray;
   }
  else return "N/A";
}


//function adds decimal places to number strings
function deciamlPlace(num)
{
//test cases "n", n.n, .n, .nn 
var retNum=""; var flag=false;
var pattern1 = /^\d{1}$/;
var pattern2 = /^(\d{1,})[.]?(\d{1})$/;
var pattern3 = /^(.\d{1})$/;
var pattern4 = /^(.\d{2})$/;

if(pattern1.test(num)){retNum=num+".00"; flag=true;} //add 2 dec places to the end of the string
if(pattern2.test(num)){retNum=num+"0"; flag=true;} //add 1 dec places to the end of the string
if(pattern3.test(num)){retNum="0"+num+"0"; flag=true;} //add 2 dec places to the end of the string and 1 at the beginning
if(pattern4.test(num)){retNum="0"+num; flag=true;} //add adecimal place at the beginning

return(flag)?retNum:num;
}

function checkForAllTrue()
{var flg=true;

	for(var i=0; i<arguments.length; i++)
		if(!arguments[i]){flg=false; break;}
	
return flg;
}

//makeNewOptItem takes in the option Item field, the option text, option value, & the option index positon 
//this funciton will change your dom object and is dependent on find_obj.js
function makeNewOptItem(optFldname,optTxt,optVal,optIndexPos)
{var optFld = (typeof optFldname == "object")?optFldname:find_obj(optFldname);
  var tOptItem=new Option(optTxt,optVal);
  if((isNaN(optIndexPos))||(optIndexPos=="")||(optIndexPos==null))optIndexPos=optFld.length;
    optFld.options[optIndexPos]=tOptItem;
}

//removeOptions removes option indexes from an option list. it takes in the option field name and how many options
//that are to be removed from the list. stopIndex is the stopping point that you wnat the options to stop being removed
//for ex. assume opt length =10 & stopIndex=5 you can remove from options 10 to 5. if stopIndex is not defined it defaluts
// to 0. this funciton will change your dom object and is dependent on find_obj.js
function removeOptions(optFldname,removeIndex,stopIndex)
{ var optFld = (typeof optFldname == "object")?optFldname:find_obj(optFldname);
   if((isNaN(stopIndex))||(stopIndex=="")||(stopIndex==null))stopIndex=0;
   if((isNaN(removeIndex))||(removeIndex=="")||(removeIndex==null))removeIndex=0;
   
   for(var i=removeIndex; i>stopIndex; i--)optFld.remove(i);
}

//removeAllOptions clears an entire option list
//this function is dependent on removeOptions & find_obj
function removeAllOptions(optFldname)
{var optFld = (typeof optFldname == "object")?optFldname:find_obj(optFldname);
removeOptions(optFld,optFld.length,0);
}

//getFirstAttrMatch finds the 1st match of attribute of a tagset & returns the node
//takes in tagset, the name of the attribute you want to match, the name of the attribute Value and
// the tagset loop start index
function getFirstMatchNode(tagset,attr,attrVal,startIndex)
{
 var n=null;
  if((isNaN(startIndex))||(startIndex=="")||(startIndex==null))startIndex=0;
 for(var i=startIndex; i<tagset.length; i++)
    {if(tagset[i].getAttribute(attr)==attrVal)
     { n = tagset[i]; break;}
    }
	return n;
}





