// SMCrunch2 Version 2.0.1, Copyright (C) Smart Media Ltd 2001-2005. All Rights Reserved.
//
// !!! Note: JScript by default
//
/// (c) Copyright Smart Media Limited, 2006-2011.
///
///This Software is provided under a license and may not be modified, copied or altered in any
///way by Licensee's own personnel or by any third party. This Software or parts of it,
///or its documentation may not be provided, copied, printed out or otherwise made available to
///any other person. Any attempt to copy, modify or reverse engineer the Software is strictly
///prohibited.
///
///This Software may only be used on the equipment it is licensed for.
///
///Title, copyright and all other proprietary rights in the Software and the Documentation and all
///parts and copies thereof shall remain vested with Smart Media Limited.
///
///This Software and information in it is subject to change without notice.
function ltrim(s)
{
if (s == "" || s==null) return "";
for (var i = 0;i < s.length;i++)
{
if (s.charAt(i) != ' ')
break;
}
if (i >= s.length)
return "";
return s.substring(i);
}
function rtrim(s)
{
if (s == "" || s ==null) return "";
for (var i = s.length-1;i >= 0;i--)
{
if (s.charAt(i) != ' ')
break;
}
if (i < 0)
return "";
return s.substring(0, i+1);
}
function trim(s)
{
if (s == "" || s == null) return "";
return ltrim(rtrim(s));
}
function isblank(s)
{
if( s != null )
{
for (var i = 0;i < s.length;i++)
{
var c = s.charAt(i);
if (c != ' ' && c != '\n' && c != '\t')
return false;
}
return true;
}
else
{
return false;
}
}
function isRadioSelected(field)
{
if (field != null)
{
if (field.length != null && field.length > 1)
{
for (var i = 0;i < field.length;i++)
{
if (field[i].checked)
return true;
}
}
else
{
if (field.checked)
return true;
}
}
return false;
}
function isPulldownSelected(field)
{
if (field != null)
{
if( field.selectedIndex != null && field.selectedIndex != 0 )
{

return true;
}
}
return false;
}
function isdigit(c)
{
return (c>='0' && c<='9');
}
function isnum(value)
{
tflag=true;
for(c=0;c<value.length;c++)
{
j=value.charAt(c);
if(!isdigit(j))
{
if ((j == '-' || j == '+') && c == 0)
continue;
tflag=false;
break;
}
}
return tflag;
}
function isfloat(value)
{
if(typeof value == 'object')
value = value.value;
tflag=true;
dpflag = false;
for(c=0;c<value.length;c++)
{
j=value.charAt(c);
if (j == '.' && !dpflag)
{
dpflag = true;
}
else if(!isdigit(j))
{
if ((j == '-' || j == '+') && c == 0)
continue;
tflag=false;
break;
}
}
return tflag;
}
function isemail(field)
{
if( field == null || field.value == null || field.value == '' )
return true;
if( field.value.match(/^[!#$%&'*\+\-\/\w\=\?\^`\{\|\}~]+([\.][!#$%&'*\+\-\/\w\=\?\^`\{\|\}~]+)*@([A-Za-z0-9]([\-]*[A-Za-z0-9])*)+(\.[A-Za-z]([\-]*[A-Za-z0-9])*)*$/) == null )
{
return false;
}
return true;
}
function OpenItemLookup(frm,descfield, idfield, search, u)
{
if (mywin != null) mywin.close();
var v_search = escape(search);
if( u != null && u != '' )
{
if( u.indexOf('?') > -1 )
u += '&';
else
u += '?';
u += 'x='+(new Date()).getTime();
if( frm != null )
{
var formname = frm.attributes.name.value;
if( typeof formname == 'undefined' )
formname = frm.attributes.name;
if( formname != null )
u += "&fieldform="+formname;
}
if( descfield != null ) u += "&fielddesc="+descfield;
if( idfield != null ) u += "&fieldid="+idfield;
if( search != null ) u += "&search="+v_search;
var mywin = window.open(u, "itemidsearch","toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=550,height=400");
}
}
function itemlookupchanged()
{
var e = document.getElementById('il_'+this.descfieldname);
var e2 = document.getElementById('ilc_'+this.descfieldname);
if( this.value == null || this.value == '' )
{
if( e2 != null ) e2.style.display = 'none';
if( e != null ) e.style.display = 'inline';
}
else
{
if( e != null ) e.style.display = 'none';
if( e2 != null )
{
e2.style.display = 'inline';
var htmlstr = '';
if( this.form[this.descfieldname].value != null )
{
htmlstr = this.form[this.descfieldname].value;
htmlstr = htmlstr.replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
}
e2.innerHTML='<span class="lookupval">'+htmlstr+
'</span> <a href="#" class="lookupremove" onclick="itemlookupunselect(\''+this.name+'\');return false;">Remove</a>';
}
}
}
function itemlookupunselect(fname)
{
var f = document.FORM1[fname];
if( f != null )
{
f.value = '';
if( f.descfieldname != null && f.form[f.descfieldname] != null )
f.form[f.descfieldname].value = '';
f.onchange();
}
}
function isLenLessThan(field, len)
{
if (field.length != null && field.length > len)
{
return false;
}
return true;
}

