/*
	JavaScript/DHTML API (JAPI) or (JBTJSAPILib.cfm) or (JSAPI)
	By: Jeffrey B. Turner of iDevMasters, Inc. (C) 2005-2009  jbt@idevmasters.com
	Owner:  Jeffrey B. Turner
	Commissoned by: iDevMasters, Inc.
	License:  This code comes without warrenty; written for IE5.5+ tested on IE7 and is not to be copied or distributed without license by iDevMasters, Inc.
	// This file is subject to the License see http://www.iDevMasters.com/JBTSourceLicense.text
	Subject: This program was written without the use of external code, tools or plugins.
	Place this script inside the head of your page. Follow the instructions below to implement.
*/
/* EXAMPLE CODE OF A CFML LOOP LIST
		function returnFormattedTimeFromMS(timeInMS)
		{
			// 1 Day, 3 Hours, 27 Minutes 14 Seconds and 80 ms
			// 86,400,000+10,800,000+1,620,000+14,000+80=98834080
			var MS=1;
			var S=1000;//<!--- value of a second in MS --->
			var M=60*1000;//<!--- value of an minute in MS --->
			var H=60*60*1000;//<!--- value of an hour in MS --->
			var D=24*60*60*1000;//<!--- value of a day in MS --->
			var Save=0;
			var RL="D,H,M,S";
			var timeInMSRemaining=timeInMS;
			var tmp="";
			var ListLength=JAPI.listLen(RL,",");
			for(x=1; x<=ListLength; x++)
			{
				tmp=JAPI.listGetAt(RL,x,",");//<!--- get next element in list --->
				Save=timeInMSRemaining % eval(tmp);//<!--- get remainder --->
				eval(tmp+"=Math.round(timeInMSRemaining/"+tmp+");");//<!--- set day, hour, minute or seconds --->
				timeInMSRemaining=Save;
				Save=0;
			}
			MS=timeInMSRemaining;//<!--- set ms --->
			//<!---alert(D+"/"+H+"/"+M+"/"+S+"/"+MS);--->
		}
*/
	JAPI.Blank=function()
	{
		return true;
	}

	JAPI.listGetAt=function(tstring,tpos,tseperator)
	{
		var OrgString=tstring;
		var StringLenght=tstring.lenght;
		var returnContent=null;
		if (OrgString.charAt(StringLenght)!=tseperator)
			OrgString=OrgString+tseperator;

		var start=0;
		var count=1;
		var k=0;
		for (j=0; j!='false';)
		{
			j=OrgString.indexOf(tseperator,k);
			if (count==tpos)
			{
				returnContent=OrgString.slice(start,j);
			}

			k=eval(j+1,'unsafe');			

			if (j==-1)
			{
				j='false';
			}

			start=k;
			if (k>StringLenght)
			{
				j='false';
			}

			count=eval(count+1,'unsafe');
		}
		return returnContent;
	}

	JAPI.listGetTo=function(tstring,tpos,tseperator)
	{
		var OrgString=tstring;
		var StringLenght=tstring.lenght;
		var start=0;
		var end=0;
		var j=0;
		var k=0;
		for (count=0; count<tpos; count++)
		{
			j=OrgString.indexOf(tseperator,k);
			if (j==-1)
			{
				count=tpos;
				end=StringLenght;
			}
			else
			{				
				end=j;
				k=j+1;				
			}
		}
		return OrgString.slice(start,end);
	}

	JAPI.listGetFrom=function(tstring,tpos,tseperator)
	{
		var OrgString=tstring;
		var StringLenght=tstring.lenght;
		var start=0;
		var laststart=0;
		var end=StringLenght;
		var j=0;
		var k=0;
		for (count=0; count<tpos; count++)
		{
			j=OrgString.indexOf(tseperator,k);
			if (j==-1)
			{
				count=tpos;
				start=laststart;
				laststart=StringLenght;
			}
			else
			{
				start=laststart;
				k=j+1;
				laststart=j;		
			}
			start++; //<!--- this get's past the seperator charachter --->
		}
		return OrgString.slice(start,end);
	}

	JAPI.listLen=function(tstring,tseperator)
	{
		var tstringleng=tstring.length++;
		var t;
		var Bean=1;
		if (!tseperator) tseperator=',';

		if(tstring.length==0 || tstring==null)
			Bean=0;
		else
		{
			for(i=1; i<tstringleng; i++)
			{
				t=tstring.indexOf(tseperator,i)
				if(t>0)
				{
					Bean++; 
					i=t++;
				}
			}
		}
		return Bean;
	}

	JAPI.listFind=function(str,srch,sep)
	{
		  if (! sep)  sep = ",";
		  var i = 0;
		  var found = false;
		  var result = 0;
		  while (!found && i < sep.length)
		  {
			result = JAPI.listFindSingleChar(str, srch, sep.charAt(i));
			found = result > 0;
			i++;
		  }
		  return result;
	}

	JAPI.listFindSingleChar=function(str, srch, sep)
	{
		  if (! sep)  sep = ",";
				
		  var istr = new String(str);
		  while (istr.indexOf(sep + sep) > -1)
				istr =      istr.substr(0, istr.indexOf(sep+sep)) + 
							istr.substr(istr.indexOf(sep+sep) + 1, istr.length);
		  var arr = new Array();
		  arr = istr.split(sep);
		  istr = srch;
		  
		  i = 0;
		  while (i < arr.length && arr[i] != istr) { i++; }
		  
		  if (i >= arr.length)
			return 0;
		  else
			return i + 1;
	}

	JAPI.listFindNoCase=function(str,srch,sep)
	{
		  if (! sep)  sep = ",";
		  return JAPI.listFind(str.toUpperCase(), srch.toUpperCase(), sep);
	}

	JAPI.listDeleteAtSingleChar=function(str, srch, sep)
	{
		if (! sep)
			sep = ",";

		var istr = new String(str);
		while (istr.indexOf(sep + sep) > -1)
			istr = istr.substr(0, istr.indexOf(sep+sep)) + istr.substr(istr.indexOf(sep+sep) + 1, istr.length);
		var arr = new Array();
		arr = istr.split(sep);
		istr = '';
		if (arr.length == 1 || eval(srch) > arr.length) 
			return "";
		else
		{
			for (var i = 0; i < eval(srch) - 1; i ++)
			{
				istr += arr[i];
				if (i < arr.length - 2) istr += sep;
			}
			for (var i = eval(srch); i < arr.length; i++)
			{
				istr += arr[i];
				if (i < arr.length - 1) istr += sep;
			}
			return istr;
		}
	}

	JAPI.listDeleteAt=function(str,srch,sep)
	{
		if (! sep)  sep = ",";
		var i = 0;
		var found = false;
		var result = 0;
		  
		while (!found && i < sep.length)
		{
			result = JAPI.listDeleteAtSingleChar(str, srch, sep.charAt(i));
			found = result.length > 0;
			i++;
		}
		if (result=="")
			return "";
		else
			return result;
	}
	
	JAPI.Left=function(str,count,startPosition)
	{
		var strLenght=str.length;
		var endpos=strLenght;
		if (!startPosition || startPosition<1)
		{
			startPosition=0;
		}
		
		if(strLenght>count)
		{
			endpos=count;
			str=str.slice(startPosition,endpos);//str=str.slice(0,endpos)+post;
		}
		return str;
	}
	
	JAPI.Right=function(str,count,pre)
	{
		var strLenght=str.length;
		var startpos=0;
		if(count<strLenght)
		{
			startpos=strLenght-count;
			str=pre+str.slice(startpos,strLenght);
		}
		return str;
	}
	
	JAPI.Mid=function(str,start,count)
	{
		var strLenght=str.length;
		var remaining=0;
		if(start>strLenght)
		{
			str='';
		}
		else
		{
			remaining=strLenght-start;
			if(count>remaining)
			{
				count=remaining;
			}
			str=str.slice(start,count);
		}
		return str;
	}

	JAPI.enableSelectControls=function(WIN,element)
	{	
		var Nextinline='';
		try
		{
			if(element==null)
				var LenghtofList=0;
			else
				var LenghtofList=JAPI.listLen(element,',');
									
			if(element=='' || LenghtofList==0)
				return false;
			else
			{
				LenghtofList++;						
				for(i=1; i<LenghtofList; i++)
				{
					Nextinline=JAPI.listGetAt(element,i,',');
					var ptr = eval("WIN.document.getElementById('" + Nextinline + "')");
					if(typeof(ptr.style)=='undefined')
					{
						// error, probebly duplicate ids
						ptr = eval("WIN.document.getElementById('" +Nextinline+ "')");
						ptr.style.visibility="hidden";
						ptr.style.display="none";
					}
					else
					{
						ptr.style.visibility="hidden";
						ptr.style.display="none";
					}
				}
				return true;
			}
		}
		catch (e){ }
	}

	JAPI.disableSelectControls=function(WIN,element)
	{
		try
		{
			var Nextinline='';
			if(element==null)
				var LenghtofList=0;
			else
				var LenghtofList=JAPI.listLen(element,',');
			
			if(element=='' || LenghtofList==0)
				return false;
			else
			{
				LenghtofList++;//<!---//alert(LenghtofList);--->
				for(i=1; i<LenghtofList; i++)
				{
					Nextinline=JAPI.listGetAt(element,i,',');
					var ptr = eval("WIN.document.getElementById('"+Nextinline+"')");
					if(typeof(ptr.style)=='undefined')
					{
						//<!---// error, probably duplicate ids--->
						ptr = eval("WIN.document.getElementById('"+Nextinline+"')");
						ptr.style.visibility="visible";
						ptr.style.display="inline";
					}
					else
					{
						ptr.style.visibility="visible";
						ptr.style.display="inline";
					}					
				}				
			}
		}
		catch (e){}
	}

	JAPI.getFFObjectsByName=function(WIN,TYPE,VALUE,CONDITION)
	{
		//<!---	//var coll=document.all.tags(TYPE); --->
		var coll=WIN.document.getElementsByTagName(TYPE);
		var Temp1='';
		var Temp2='';
		var Bean=0;
		var j=1;
		var my_array=new Array(1);

		if(CONDITION=='all')
			var CONDITION=1;
		else
			var CONDITION=0;
		if (coll!=null)
		{
			Bean=coll.length;
			for (i=0; i<coll.length; i++)
			{
				j++;
				my_array[j]=coll[i];
				Temp2="coll[i]."+VALUE;
				Temp2=eval(Temp2);						
				if(Temp2=="")
					if(CONDITION==1)
						if(Temp1=='')
							Temp1="*";
						else
							Temp1=Temp1+",*";
				else
					if(Temp1=='')
						Temp1=Temp2;
					else
						Temp1=Temp1+","+Temp2;
			}
			my_array[0]=Bean;
			my_array[1]=Temp1;
			return my_array;
		}
	}

	JAPI.toggleVisibility=function(WIN,element)
	{	
		if(!element)
		{
			return false;
		}
		else
		{
			var p=WIN.document.getElementById(element);
			if (p.className == "show1")
			{
				p.className = "show2";
			}
			else
			{
				p.className = "show1";
			}
			return true;
		}
	}

	JAPI.TextXMLparseResults=function(XML,parm) // Universal XML results parser
	{
		if(!parm)
		{
			var parm='error';
		}
		var startParm = new String("<" + parm + ">");
		var endParm = new String("</" + parm + ">");
				
		var istr = new String(XML);
		var i = istr.indexOf(startParm);
		var j = istr.indexOf(endParm);
	
		if (i== -1 || j == -1)
		{
			return "";
		}
		else
		{
			return istr.substring(i + startParm.length, j);
		}
	}
	
	JAPI.doXMLPage=function(method,page,formValues,returnparser) // Universal XML page caller
	{
		xhr= new ActiveXObject("Microsoft.XMLHTTP"); // init XML object
		xhr.open("POST", page, method); // open XML page
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set header def
		if(returnparser!=null)
		{
			eval("xhr.onreadystatechange="+returnparser+";"); // set results parser on return of XML doc
		}
		xhr.send(formValues); // submit document
		return true;
	}
<!--- This Javascript library is property of iDevMasters, Inc. as part of the SmackSiteKit. Copyright 2005-2009 --->
<!-- This Javascript library is property of iDevMasters, Inc. as part of the SmackSiteKit. Copyright 2005-2009 -->
