<!--

/*

	utility functions
		CheckBoxMax(maxNo,obj,curvalue)
		CheckBoxMin(minNo,obj,message,internalRef2Go)
		CheckSpecificValue(SpecValue,obj)
		GetResponseCount(obj,objType)
		GetObjectVal(obj,objType,objSep)
	is X functions
		isvalidemail(emailStr) 
		isCreditCard(st) 		
		isIntegerInRange (s, a, b)		
		isInteger (s)
		IsDate(mystring)
*/

//auto complete functions begin
function Format_Suggestions(row,rowData)
{
	retval = "";
	rowData = "-----" + rowData; 
	//so that we make room for the row[0] containing the id field. this field is always returned as the first field info by the back end ( server side page) and we never want to show it in the suggestions drop down. when we visually make our suggestions row using the Format_Suggestions function, we do not start with ------for convenienece reasin. and  that's the reason why we add it now!

	var retval;
	var curWidth;
	var array1 = rowData.split("-----")
	var array1,i,curitem
	
	for(var i = 0; i < array1.length; i++){
		if (i==0)
		{
			//id field is being iterated. row[0] always contains the id of the current record whose row is being formatted.
			//there is no point of showing that!
		}
		else
		{
			curitem = array1[i];
			curWidth = rightof(curitem,"width:")
			curitem = leftof(curitem,"width:")
			retval = retval +	"<div style='display:inline;width:" + curWidth + "px;float:left;'>" 
			retval = retval +  "<span style='" + curitem + "'>" + row[i]  + "</span>"
			retval = retval + "</div>" 
		}
	}
	return retval;
}


function Format_Return(row,rowData)
{
	var retval;
	if (contains(rowData,"[0]")) {rowData = replace(rowData,"[0]",row[0]);}
	if (contains(rowData,"[1]")) {rowData = replace(rowData,"[1]",row[1]);}
	if (contains(rowData,"[2]")) {rowData = replace(rowData,"[2]",row[2]);}
	if (contains(rowData,"[3]")) {rowData = replace(rowData,"[3]",row[3]);}
	if (contains(rowData,"[4]")) {rowData = replace(rowData,"[4]",row[4]);}
	if (contains(rowData,"[5]")) {rowData = replace(rowData,"[5]",row[5]);}
	if (contains(rowData,"[6]")) {rowData = replace(rowData,"[6]",row[6]);}
	return rowData;
}

//auto complete functions end


function confirmationframe(url,Msg_WhenActionIsSkippedDuetoAboveCondition) 
{
	//alert('confirmationframe is running.')
	var answer = confirm("Click the [OK] button if you are absolutely sure to continue with this operation.\n\nOr simply click the [CANCEL] button to abort. ")
	if (answer){
		actionframe.location.href=url
		return true;
	}
	else{
		alert('Action cancelled per your request.');
		return false;
	}
}

function confirmationself(url,Msg_WhenActionIsSkippedDuetoAboveCondition) 
{
	//alert('confirmationself is running.')
	var answer = confirm("Click the [OK] button if you are absolutely sure to continue with this operation.\n\nOr simply click the [CANCEL] button to abort. ")
	if (answer){
		window.location.href=url
		return true;
	}
	else{
		alert('Action cancelled per your request.');
		return false;
	}
}

function confirmationvisiblepop(url,Msg_WhenActionIsSkippedDuetoAboveCondition,ActionPopUpWindowProperties) 
{
	
	var answer = confirm("Click the [OK] button if you are absolutely sure to continue with this operation.\n\nOr simply click the [CANCEL] button to abort. ")
	if (answer){
		//window.location.href=url
		//var winpop=window.open(url,"winPop","width=500,height=500")
		var winpop=window.open(url,"winPop",ActionPopUpWindowProperties)
		return true;
	}
	else{
		alert('Action cancelled per your request.');
		return false;
	}
}



function IsDate(mystring)
{
var mystring, myresult ;
var mystring = new Date(mystring);
isNaN(mystring)? myresult=false : myresult=true ;
return myresult ;
}

function  CheckBoxMax(maxNo,obj,curvalue)
{
	var numChecked = 0
	var bolPop=false;
	for(var x = 0; x < obj.length; x++){
		if(obj[x].checked){
			numChecked++
			if (numChecked>maxNo) {
				bolPop=true
				Uncheck(obj,curvalue)
				break;
			}
		}
	}
	if (bolPop)
	{
		alert('You have already selected '+maxNo+' items. ')
		return false;
	}
	else
	{
		return true;
	}
}
function  CheckBoxMin(minNo,obj,message,internalRef2Go)
{
	var numChecked = 0
	var bolPop=false;
	for(var x = 0; x < obj.length; x++){
		if(obj[x].checked){
			numChecked++
		}
		else
		{
			//alert(obj[x].value + ' has a checked value of ' + obj[x].checked)
		}
	}
	if (numChecked<minNo)
	{
		alert(message)
		window.location.href=internalRef2Go
		return false;
	}
	else
	{
		return true;
	}
}
function  CheckSpecificValue(SpecValue,obj)
{
	//	use this function to turn on the Spec value when no other items are selected and vice versa
	//
	//
	//	<input onClick='CheckSpecificValue("Tell you later",document.forms[0].Languages)' type="checkbox" value="Arabic" name="Languages" checked>Arabic
	//	<input onClick='CheckSpecificValue("Tell you later",document.forms[0].Languages)' type="checkbox" value="English" name="Languages" checked>English
	//	<input onClick='CheckSpecificValue("Tell you later",document.forms[0].Languages)' type="checkbox" value="Other" name="Languages" checked>Other
	//	<input onClick='CheckSpecificValue("Tell you later",document.forms[0].Languages)' type="checkbox" value="Tell you later" name="Languages" >Tell you later
	//
	//
	//
	var at_least_one_item_Checked_other_than_spec_value = false;
	var spec_value_Checked = false;
	for(var x = 0; x < obj.length; x++){
		if (obj[x].checked)
		{
			if (obj[x].value == SpecValue)
			{
				spec_value_Checked=true;
			}
			else
			{
				at_least_one_item_Checked_other_than_spec_value = true;
			}
		}
	}
	if (spec_value_Checked && at_least_one_item_Checked_other_than_spec_value)
	{
		//make sure spec value is unchecked as another item is currently checked
		AssignCheckValue(false,obj,SpecValue)
	}

	if (!(spec_value_Checked) && !(at_least_one_item_Checked_other_than_spec_value))
	{
		//make sure spec value is checked as no other
		AssignCheckValue(true,obj,SpecValue)
	}
	return true;
}
function  GetResponseCount(obj,objType)
{
	//returns the number of characters in a text field or the number of options selected in a radio, checkbox , select or multiple select object types >>>  text(t),textarea(x),hidden(h), radio(r),checkbox(c), select(s)
	//in order this function to work default option on the select must be valued as "nada",
	//select boxes always report their first option whether it is selected or not, always as selected
	//if an empty string is an accepted value and should not be caught by the validation engine, then instead of leaving the value as "" leave it as "EMPTYSTRING"
	//in the posted page, do something for those that are submitted with with the value "EMPTYSTRING"

	var numChecked = 0;
	if ( (objType=="s") || (objType=="m") )
	{

		for (var x=0; x<obj.options.length; x++)
		{
			if ( obj.options[x].selected )
			{
				if ( obj.options[x].value != "nada" )
				{
					numChecked++;

				}
			}
		}
	}
	//if textbox or textarea or hidden
	if (objType=="t" || objType=="x" || objType=="h")
	{
		numChecked =  obj.value.length
	}
	//if radio or checkboxes  ( rc is a shortcut for radio or check )
	if ( (objType=="r") || (objType=="c") || (objType=="rc") )
	{
		for(var x = 0; x < obj.length; x++)
		{
			if(obj[x].checked)
			{
				numChecked++;
			}
		}
	}
	return numChecked;
}
function  GetObjectVal(obj,objType,objSep,ErrorCaption)
{
	//returns the value of the following object types >>>  text(t),textarea(x),hidden(h), radio(r),checkbox(c), select(s)
	//if empty it returns a value of EMPTY: followed by ErrorCaption
	
	//in order this function to work default option on the select must be valued as "nada",
	//select boxes always report their first option whether it is selected or not, always as selected
	//if an empty string is an accepted value and should not be caught by the validation engine, then instead of leaving the value as "" leave it as "EMPTYSTRING"
	//in the posted page, do something for those that are submitted with with the value "EMPTYSTRING"

	var returnVal = ""

	//if select or multiple select

	if ( (objType=="s") || (objType=="m") || (objType=="sm") )
	{
		for (var x=0; x<obj.options.length; x++)
		{
			if ( obj.options[x].selected )
			{
				if ( obj.options[x].value != "nada" )
				{
					returnVal = returnVal + obj.options[x].value + objSep

				}
			}
		}
	}
	//if textbox or textarea or hidden
	if (objType=="t" || objType=="x" || objType=="h" || objType=="htx" )
	{
		returnVal =  obj.value
	}
	
	//if radio or checkboxes  ( rc is a shortcut for radio or check )
	if ( (objType=="r") || (objType=="c") || (objType=="rc") )
	{
		for(var x = 0; x < obj.length; x++)
		{
			if(obj[x].checked)
			{
				returnVal = returnVal + obj[x].value + objSep
			}
		}
	}
	
	if ( returnVal.length == 0 ) 
	{
		returnVal = "EMPTY:" + ErrorCaption
	}
	

	return returnVal;
}


function IsEmpty2(input)

{
	//this is not a reqular isEmpty function, there is a slight variation . if a value is really empty, the caller of this function prepares it such that EMPTY:errorcaption is available
	var returnVal 
	
	if (input.indexOf("EMPTY:") >= 0 )
	{
		returnVal=true
	}
	else
	{
		returnVal=false
	}
	return returnVal
}

function GetCaption(input)
{
	//assumes a value of EMPTY: appears in the js

	return replacestring(input,"EMPTY:","")

}

//helpfer functions

function Uncheck(obj,curvalue)
{
	for(var x = 0; x < obj.length; x++){
		if (curvalue == obj[x].value) {
			obj[x].checked=false;
			break;
		}

	}

}
function AssignCheckValue(toBeSetValue,obj,objValue)
{
	for(var x = 0; x < obj.length; x++){
		if (obj[x].value == objValue)
		{
			obj[x].checked = toBeSetValue

		}
	}
}
function isvalidemail(emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address.
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
/* Finally, let's start trying to figure out if the supplied address is
   valid. */
/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	//alert("Invalid email address structure detected.")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid
if (user.match(userPat)==null) {
    // user is not valid
    //alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
			//alert("Destination IP address is invalid!")
			return false
	    }
    }
    return true
}
// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
	return false
}
/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding
   the domain or country. */
/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
	//	alert("The address must end in a three-letter domain, or two letter country.")
	return false
}
// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   return false
}
// If we've gotten this far, everything's valid!
return true;
}

function isCreditCard(st) {
  // Encoding only works on cards with less than 19 digits
  if (st.length > 19)
    return (false);

  sum = 0; mul = 1; l = st.length;
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }
// Uncomment the following line to help create credit card numbers
// 1. Create a dummy number with a 0 as the last digit
// 2. Examine the sum written out
// 3. Replace the last digit with the difference between the sum and
//    the next multiple of 10.

//  document.writeln("<BR>Sum      = ",sum,"<BR>");
//  alert("Sum      = " + sum);

  if ((sum % 10) == 0)
    return (true);
  else
    return (false);

} // END FUNCTION isCreditCard()

function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
}



function Zoom(obj,objstr)
//======================================================

{
	/*
	
	sample call 
	
	
	<input type="button" value="ZOOM" onClick="Zoom(window.document.FORMNAME.TEXTAREANAME,'FORMNAME.TEXTAREANAME')">
	

	*/
	
	var objval = obj.value
	var zoomwin = window.open("blank.htm","zoomwin","'width=500,height=800,scrollbars,resizable'")
	zoomwin.document.open()	
	zoomwin.document.write ("<body bgcolor='#ededed'><center><scr" + "ipt>var objstr='" + objstr + "'</scr" + "ipt>")
	zoomwin.document.write ("<form name='frm'><textarea rows='50' cols='170' name='zoombox'>"+ objval + "</textarea>")
	zoomwin.document.write ("<input type='button' value='update' onClick='window.opener." + objstr + ".value=window.document.frm.zoombox.value;self.close()'></form>")
	zoomwin.document.close()
	
	
	return true;

}



function ViewSource()

//======================================================
{

	/*
	
			  <INPUT TYPE="BUTTON" VALUE="VIEW SOURCE" onClick= 'ViewSource()'>
			  
			  or 
			  
			  <sc> ButtonViewSource() </sc>
			  
	*/		  
	window.location = "view-source:" + window.location.href
}

	 
function ViewSourceButton()
//======================================================
{

	/*
	
			ViewSourceButton() 
			
	*/
	
	window.document.write ("<INPUT TYPE=\"BUTTON\" VALUE=\"VIEW SOURCE\" onClick= 'ViewSource()'>")
}

function Refresh()
//======================================================
{

	/*
	
			  <INPUT TYPE="BUTTON" VALUE="REFRESH" onClick= 'Refresh()'>
			  
			  <sc> RefreshButton() </sc>
			  
	*/		  
	window.location.reload()
}

function RefreshButton()
//======================================================
{

	/*
	
			<sc> ButtonRefresh() </sc>
			
	*/
	
	window.document.write ("<INPUT TYPE=\"BUTTON\" VALUE=\"REFRESH\" onClick= 'Refresh()'>")

}


function RS (s)

{

	/*
	
		<sc> RS </sc>  or <sc> RS("<br>") </sc>
	
	*/
	
	if ( s.length > 0 )
	{
		document.write (s)
	}
	else
	{
		document.write ("&nbsp;")
	}
	
	return true;
	
}




function replacestring(sFull, sOld, sNew) {
  var sData = "";
  for (var i=0; i<sFull.length; i++) {
  if (sFull.substring(i,i+sOld.length) == sOld) {
      sData = sData + sNew;
      i = i + sOld.length - 1;
  } else { sData = sData + sFull.substring(i,i+1) }
  }
  return sData;
}

function trim(str)   {

	if (str.length==0) {return "";}

	while (str.charAt(0)==" ")
             {str=str.substring(1,str.length);}

	while (str.charAt(str.length-1)==" ")
             {str=str.substring(0,str.length-1);}

    return str;
}


function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;
	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}


function mid(str,start,n) {
	//returns a substring of str starting at 'start' that's n characters long.
	//alert('mid param n is passed as ' + n);
	if ( (n == null) || n == "undefined" ) {
	   n = str.length;
	}
	strlen = str.length
	var jj = str.substring(start-1,strlen)
	jj = jj.substring(0,n)
	return jj
}







function instr(iStartingFrom,lrgstring,smstring,bolNotCaseSensitive) {
	//returns a number indicating the spot where smstring appears in lrgstring.
    //behaves exactly like vb's instr function
    //this is how to use
    /*
	var sString;
	var sSearch;
	var iStartingFrom;
	var vbTextCompare;
	vbTextCompare=true;
	sString='hello World this is a simple string. ';
	sSearch='hello';
	iStartingFrom=1;

	alert(instr(iStartingFrom,sString,sSearch,vbTextCompare)) ;
    */

	lrgstring=lrgstring.substring(iStartingFrom-1,lrgstring.length)
	//alert('after the cut' + lrgstring)
	if ( bolNotCaseSensitive ) {
		lrgstring=lrgstring.toLowerCase();
		smstring=smstring.toLowerCase();
	}
    // this function has a bug, when the searched word is found at the beginning of the large word , it returns 0!..
    //following fix is just for that !...
   	if ( smstring == lrgstring.substring(0,smstring.length) ) {
   	   //set foundat to 1 and return immediately since smstring is found at the beginning of the lrgstring already !...
   	   foundat=1;
   	   return foundat;
   	}
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	foundat = 0
	for (i=0;i<=strlen2;i++) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)
		if (comp == smstring) {
			foundat = i
			break
		}
	}


	if ( iStartingFrom != 1 ) {
	    return foundat-(iStartingFrom-1);
	}
	else{
		return foundat;
	}
}




function getinbetween(sContents, sBeginningKey, sEndingKey) {
	var sText;
	var iBeginningKeyStartsAt;
	var sEndingKeyStartsAt;
	var vbTextCompare;
	var sCapturedResult;
	vbTextCompare=true;
	sText = sContents
	iBeginningKeyStartsAt = instr(1, sContents, sBeginningKey, vbTextCompare);
	sEndingKeyStartsAt = instr(1, sContents, sEndingKey, vbTextCompare);
	if (iBeginningKeyStartsAt > 0 && sEndingKeyStartsAt > 0) {
	   sText = right(sText, (len(sText) - (iBeginningKeyStartsAt + (len(sBeginningKey) - 1))));
	   sText = left(sText, (instr(1, sText, sEndingKey, vbTextCompare) - 1))
	   if ( sText == "" ) {
	      sCapturedResult = ""
	   }
	   else{
	      sCapturedResult = sText
	   }
	}
	else{
	  sCapturedResult = ""
	}
    return sCapturedResult;
}



function len(str) {
/***
        IN: str - the string whose length we are interested in

        RETVAL: The number of characters in the string
***/
  return String(str).length;
}


//-->

	function SetVal(obj, objtype , val)
	{

		// Author: Haluk Karamete 
		// URL   : www.developerlibrary.com | August 16,2005


		/*
		

		how to use

			(*) this function can set the value of any form object as the following calls demonstrates	

				SetVal(frm.text1,"t","XXX")
				SetVal(frm.textarea1,"x","XXX")
				SetVal(frm.textarea1,"h","XXX")
				SetVal(frm.checkbox1,"c","A,C")
				SetVal(frm.radio1,"r","B")
				SetVal(frm.select1,"s","B")
				SetVal(frm.multipleselect1,"m","A,D")

			(*)not case sensitive

			(*)multiple options must be seperated by comma

				What's that mean ? therefore may not work with if your multiple select options such as checkboxes or multiple select contains values that includes comma's in them, you are in deep trouble.

		

		*/
		
		var curval;
		if  ( (objtype == 'r') || (objtype == 'c') )  { objtype = 'rc'  }
		if  ( (objtype == 'm') || (objtype == 's') )  { objtype = 'ms'  }
		switch(objtype)
		{
		  case 'rc':
			val =  val.toLowerCase() + ","
			for(var x = 0; x < obj.length; x++)
			{
				curval = obj[x].value;
				curval = curval.toLowerCase();
				if ( curval != 'novalue' && curval != '' && curval != null )
				{
					curval = curval + ","
					if ( val.indexOf(curval) != -1)
					{
							obj[x].checked = true;
					}
				}
			}
			break;
		  case 'ms':
			val =  val.toLowerCase() + ","
			for (var x=0; x<obj.options.length; x++)
			{
				curval = obj[x].value;
				curval = curval.toLowerCase();
				if ( curval != 'novalue' && curval != '' && curval != null )
				{
					curval = curval + ","
					if ( val.indexOf(curval) != -1)
					{
							obj[x].selected = true;
					}
				}
			}
			break;
		  default:
			obj.value = val;
			break;
		}
	}


	function SaveAs(content2save)
	{
		//Author: Haluk Karamete 
		//URL   : www.developerlibrary.com | August 16,2005
		
		//how to use... 
		// <input type=button value='SAVE TEXT AREA' 
		//	onClick="SaveAs('<pre>' + window.document.frm.textareanamehere.value + '</pre>')">

		//whatever you send gets to be saved !... 

		//pop window and name it as tempwin dump obj.value onto it  and then use tempwin.document.execCommand
		if ( content2save.length>0 )
		{
			winTemp=window.open('blank.htm','winTemp','width=1,height=1')
			winTemp.document.open()
			winTemp.document.write(content2save)
			winTemp.document.close()
			winTemp.document.execCommand('SaveAs', false, '.txt')
			winTemp.close();
		return true;}
		else
		{
			alert('Nothing to save.')
			return false;
		}
	}
	//upload
	function popimageinfloat(uploadformname,path,resultmsg,autouploadafteryes)
	{
		//Author: Haluk Karamete 
		//URL   : www.developerlibrary.com | August 16,2005
		
		winT = window.open('blank.htm','winT','width=350,height=350')

		var msg1 = "<center>Verified successfully. <br>Image is eligible for upload.<p>"
		var msg2 = '<img width=150 height=150 src="'+path+'"><p>'
		if (autouploadafteryes== 1 )
		{
			var msg3 = "Do you wish to upload this image?<p><input type='button' value='YES' onClick='" + "window.opener.document."+uploadformname+".uploadstatus.value=\"1\"; window.opener.document."+uploadformname+".fileS.value=\"\";	window.opener.document."+uploadformname+".fileN.value=\"\";	alert(\"Thank you.\\nThe Upload procedure will take place immediately. Depending on the current bandwidth, this may take minutes.\");window.opener.document."+uploadformname+".submit();self.close();'>"
		}
		else
		{
			var msg3 = "Do you wish to upload this image?<p><input type='button' value='YES' onClick='" + "window.opener.document."+uploadformname+".uploadstatus.value=\"1\"; window.opener.document."+uploadformname+".fileS.value=\"\";	window.opener.document."+uploadformname+".fileN.value=\"\";	alert(\"Thank you.\\nThe Upload procedure will take at submission time.\");self.close();'>"
		}
		var msg4 = "&nbsp;&nbsp;&nbsp;"
		var msg5 = "<input type='button' value='NO' onClick='" + "window.opener.document."+uploadformname+".uploadstatus.value=\"\"; window.opener.document."+uploadformname+".fileS.value=\"\";	window.opener.document."+uploadformname+".fileN.value=\"\";	alert(\"Image upload is cancelled.\");self.close();'>"

		var html=msg1  + msg2 + msg3 + msg4 + msg5
		winT.document.open
		winT.document.write(html);
		winT.document.close
	}
	function Verify(thisform,uploadformname,browserboxname,allowedfiletypes,allowedfileS,ShowThumbnail,autouploadafteryes)
	{

		// Author: Haluk Karamete 
		// URL   : www.developerlibrary.com | August 16,2005

		var resultmsg;
		var evalstr = "thisform." + browserboxname + ".value"
		var currentlyselectedfilepath = eval(evalstr)
		if ( currentlyselectedfilepath != '')
		{
			var path = currentlyselectedfilepath;
			thisform.uploadfileref.src=currentlyselectedfilepath;
			thisform.fileN.value= checkfilename(currentlyselectedfilepath,allowedfiletypes)
			if (thisform.fileN.value=="0")
			{
				resultmsg='You have selected an invalid file type. \nAllowed file types are ' + allowedfiletypes
				thisform.uploadstatus.value=""
				reset(thisform)
				return false;
			}
			//=============================================================

			var filesizeinbytes = thisform.uploadfileref.fileSize;
			thisform.fileS.value = parseInt(filesizeinbytes/1024)

			alert('validating file... ok to continue ...')

			filesizeinbytes = thisform.uploadfileref.fileSize;
			thisform.fileS.value = parseInt(filesizeinbytes/1024)

			//=============================================================

			if (thisform.fileS.value>allowedfileS)
			{
				resultmsg='Allowed file size exceeds. \n\nPlease limit your images to less than '+allowedfileS+'K.' + 'This image is ' + thisform.fileS.value + 'K.'
				alert(resultmsg)
				thisform.uploadstatus.value=""
				reset(thisform)
				return false;
			}
			else
			{
				resultmsg = "";
				if ( ShowThumbnail == 1 )
				{

					//alert('This is right before popping the window... filesize calculated as ' + thisform.fileS.value + ' and the max allowed was ' + allowedfileS)
					//alert('I cannot afford to have this as 0 ..... >>>> thisform.uploadfileref.fileSize;=' + thisform.uploadfileref.fileSize)


					popimageinfloat(uploadformname,path,resultmsg,autouploadafteryes)
				}
				thisform.uploadstatus.value="1"
				return true
			}
		}
		else
		{
			alert('no image is selected.')
			thisform.uploadstatus.value=""
		}
	}
	function reset(thisform)
	{
		thisform.fileS.value= ""
		thisform.fileN.value= ""
		thisform.uploadstatus.value= ""
	}
	function checkfilename(i,allowedfiletypes)
	{
		i=i.toLowerCase();
		if (i.length > 5)
		{
			var thisstring= rightof(right(i,5),".")
			if (contains(allowedfiletypes,thisstring))
			{
				return "1"
			}
			else
			{
				return "0"
			}
		}
		else
		{
			return "0"
		}
	}
//LIBRARY GENERIC

/*

function  replacestring(sFull, sOld, sNew) {
function  trim(str)   {
function  allDigits(str)
function  inValidCharSet(str,charset)
function  mid(str,start,n) {
function  contains(lrgstring,smstring) {
function  instr(iStartingFrom,lrgstring,smstring,bolNotCaseSensitive) {
function  getinbetween(sContents, sBeginningKey, sEndingKey) {
function  len(str) {
function  leftof(lrgstringmsmstring) {
function  rightof(lrgstring,smstring) {
function  right(str,n) {
function  left(str,n)
function  autoComplete(field, select, property, forcematch)
*/



//LIBRARY VALIDATION

/*

function  CheckBoxMax(maxNo,obj,curvalue)
function  CheckBoxMin(minNo,obj,message,internalRef2Go)
function  CheckSpecificValue(SpecValue,obj)
function  GetResponseCount(obj,objType)
function  GetObjectVal(obj,objType,objSep,ErrorCaption)
function  isValidEmail(emailStr) {
function  isCreditCard(st) {
function  isWithinRange (s, a, b)
function  isInteger (s)
function  isMatch(a,b)
function  isDate(y,m,d)
*/

<!--

// REGULAR EXPRESSION DECLARATIONS
// Notes which apply to all the regexps below:
// (1) We want to only match strings exactly. In other words,
//     we only want to return true if the string being tested
//     matches the regular expression with no leading or trailing
//     unmatched characters. So, we begin each regexp with
//     the special character ^ (which matches beginning of input)
//     and end each regexp with the special character $ (which
//     matches end of input).
// (2) In the below comments we use these abbreviations:
//     BOI = Beginning Of Input
//     EOI = End Of Input
// (3) For explanations of the regexp special characters such as
//     ^ $ \s + [] \d * ! ? \ .
//     see http://developer.netscape.com/docs/manuals/communicator/jsguide/regexp.htm


// BOI, followed by one or more whitespace characters, followed by EOI.
var reWhitespace = /^\s+$/


// BOI, followed by one lower or uppercase English letter, followed by EOI.
var reLetter = /^[a-zA-Z]$/


// BOI, followed by one or more lower or uppercase English letters,
// followed by EOI.
var reAlphabetic = /^[a-zA-Z]+$/


// BOI, followed by one or more lower or uppercase English letters
// or digits, followed by EOI.
var reAlphanumeric = /^[a-zA-Z0-9]+$/


// BOI, followed by one digit, followed by EOI.
var reDigit = /^\d/


// BOI, followed by one lower or uppercase English letter
// or digit, followed by EOI.
var reLetterOrDigit = /^([a-zA-Z]|\d)$/


// BOI, followed by one or more digits, followed by EOI.
var reInteger = /^\d+$/



function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function replacestring(sFull, sOld, sNew) {

// Author: Haluk Karamete 
// URL   : www.developerlibrary.com | August 16,2005

  var sData = "";
  for (var i=0; i<sFull.length; i++) {
  if (sFull.substring(i,i+sOld.length) == sOld) {
      sData = sData + sNew;
      i = i + sOld.length - 1;
  } else { sData = sData + sFull.substring(i,i+1) }
  }
  return sData;
}

function replace(sFull, sOld, sNew) {
  var sData = "";
  for (var i=0; i<sFull.length; i++) {
  if (sFull.substring(i,i+sOld.length) == sOld) {
      sData = sData + sNew;
      i = i + sOld.length - 1;
  } else { sData = sData + sFull.substring(i,i+1) }
  }
  return sData;
}


function trim(str)   {

	if (str.length==0) {return "";}

	while (str.charAt(0)==" ")
             {str=str.substring(1,str.length);}

	while (str.charAt(str.length-1)==" ")
             {str=str.substring(0,str.length-1);}

    return str;
}



function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}

	return result;
}


function mid(str,start,n) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	if ( (n == null) || n == "undefined" ) {
	   n = str.length;
	}
	strlen = str.length
	var jj = str.substring(start-1,strlen)
	jj = jj.substring(0,n)
	return jj
}


function contains(lrgstring,smstring) {
	//alert('runs');
	//between two 2 identical js functions, second one ( the after defined one ) overwrites the first defined one. 
	smstring=smstring.toLowerCase();
	lrgstring=lrgstring.toLowerCase();
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	istrue = false
	for (i=0;i<=strlen2;i++) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)
		if (comp == smstring) {
			istrue = true
			break
		}
	}
	return istrue
}




function instr(iStartingFrom,lrgstring,smstring,bolNotCaseSensitive) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

    /*
	var sString;
	var sSearch;
	var iStartingFrom;
	var vbTextCompare;
	vbTextCompare=true;
	sString='hello World this is a simple string. ';
	sSearch='hello';
	iStartingFrom=1;

	alert(instr(iStartingFrom,sString,sSearch,vbTextCompare)) ;
    */

	lrgstring=lrgstring.substring(iStartingFrom-1,lrgstring.length)
	//alert('after the cut' + lrgstring)
	if ( bolNotCaseSensitive ) {
		lrgstring=lrgstring.toLowerCase();
		smstring=smstring.toLowerCase();
	}
    // this function has a bug, when the searched word is found at the beginning of the large word , it returns 0!..
    //following fix is just for that !...
   	if ( smstring == lrgstring.substring(0,smstring.length) ) {
   	   //set foundat to 1 and return immediately since smstring is found at the beginning of the lrgstring already !...
   	   foundat=1;
   	   return foundat;
   	}
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	foundat = 0
	for (i=0;i<=strlen2;i++) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)
		if (comp == smstring) {
			foundat = i
			break
		}
	}


	if ( iStartingFrom != 1 ) {
	    return foundat-(iStartingFrom-1);
	}
	else{
		return foundat;
	}
}


// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/

function autoComplete(field, select, property, forcematch){var found = false;for(var i = 0;i < select.options.length;i++){if(select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0){found=true;break;}}if(found){select.selectedIndex = i;}else{select.selectedIndex = -1;}if(field.createTextRange){if(forcematch && !found){field.value=field.value.substring(0,field.value.length-1);return;}var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";if(cursorKeys.indexOf(event.keyCode+";") == -1){var r1 = field.createTextRange();var oldValue = r1.text;var newValue = found ? select.options[i][property] : oldValue;if(newValue != field.value){field.value = newValue;var rNew = field.createTextRange();rNew.moveStart('character', oldValue.length) ;rNew.select();}}}}



function getinbetween(sContents, sBeginningKey, sEndingKey) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	var sText;
	var iBeginningKeyStartsAt;
	var sEndingKeyStartsAt;
	var vbTextCompare;
	var sCapturedResult;
	vbTextCompare=true;
	sText = sContents
	iBeginningKeyStartsAt = instr(1, sContents, sBeginningKey, vbTextCompare);
	sEndingKeyStartsAt = instr(1, sContents, sEndingKey, vbTextCompare);
	if (iBeginningKeyStartsAt > 0 && sEndingKeyStartsAt > 0) {
	   sText = right(sText, (len(sText) - (iBeginningKeyStartsAt + (len(sBeginningKey) - 1))));
	   sText = left(sText, (instr(1, sText, sEndingKey, vbTextCompare) - 1))
	   if ( sText == "" ) {
	      sCapturedResult = ""
	   }
	   else{
	      sCapturedResult = sText
	   }
	}
	else{
	  sCapturedResult = ""
	}
    return sCapturedResult;
}



function len(str) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

  return String(str).length;
}

function leftof(lrgstring,smstring) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005
	if (smstring == ""){smstring = " "}
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	foundat = 0
	for (i=0;i<=strlen2;i++) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)
		if (comp == smstring) {
			foundat = i
			break
		}
	}
	return lrgstring.substring(0,(foundat-1))
}


function rightof(lrgstring,smstring) {
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005
	return getinbetween(lrgstring + '^@`',smstring,'^@`')
	/*
	if (smstring == ""){smstring = " "}
	strlen1 = smstring.length
	strlen2 = lrgstring.length
	foundat = 0
	for (i=strlen2;i>=0;i--) {
		comp=lrgstring.substring(i-1,strlen2)
		comp = comp.substring(0,strlen1)
		if (comp == smstring) {
			foundat = i
			break
		}
	}
	return lrgstring.substring(foundat,255)
	*/
}


function right(str,n) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	strlen = str.length
	return str.substring(strlen-n,strlen)
}



function left(str,n) {

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	return str.substring(0,n)
}



//LIBRARY VALDAIOTN
/*

	utility functions
		CheckBoxMax(maxNo,obj,curvalue)
		CheckBoxMin(minNo,obj,message,internalRef2Go)
		CheckSpecificValue(SpecValue,obj)
		GetResponseCount(obj,objType)
		GetObjectVal(obj,objType,objSep)
	is X functions
		isValidEmail(emailStr)
		isCreditCard(st)
		isWithinRange (s, a, b)
		isInteger (s)
*/

function isMatch(a,b)
{

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	if ( a == b )
	{
		return true;
	}
	else
	{
		return false;
	}
}

function  CheckBoxMax(maxNo,obj,curvalue)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005
	var numChecked = 0
	var bolPop=false;
	for(var x = 0; x < obj.length; x++){
		if(obj[x].checked){
			numChecked++
			if (numChecked>maxNo) {
				bolPop=true
				Uncheck(obj,curvalue)
				break;
			}
		}
	}
	if (bolPop)
	{
		alert('You have already selected '+maxNo+' items. ')
		return false;
	}
	else
	{
		return true;
	}
}


function  CheckBoxMin(minNo,obj,message,internalRef2Go)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	var numChecked = 0
	var bolPop=false;
	for(var x = 0; x < obj.length; x++){
		if(obj[x].checked){
			numChecked++
		}
		else
		{
			//alert(obj[x].value + ' has a checked value of ' + obj[x].checked)
		}
	}
	if (numChecked<minNo)
	{
		alert(message)
		window.location.href=internalRef2Go
		return false;
	}
	else
	{
		return true;
	}
}

function  CheckSpecificValue(SpecValue,obj)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	//use this function to turn on the Spec value when no other items are selected and vice versa
	var at_least_one_item_Checked_other_than_spec_value = false;
	var spec_value_Checked = false;
	for(var x = 0; x < obj.length; x++){
		if (obj[x].checked)
		{
			if (obj[x].value == SpecValue)
			{
				spec_value_Checked=true;
			}
			else
			{
				at_least_one_item_Checked_other_than_spec_value = true;
			}
		}
	}
	if (spec_value_Checked && at_least_one_item_Checked_other_than_spec_value)
	{
		//make sure spec value is unchecked as another item is currently checked
		AssignCheckValue(false,obj,SpecValue)
	}

	if (!(spec_value_Checked) && !(at_least_one_item_Checked_other_than_spec_value))
	{
		//make sure spec value is checked as no other
		AssignCheckValue(true,obj,SpecValue)
	}
	return true;
}


function  GetResponseCount(obj,objType)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	//returns the number of characters in a text field or the number of options selected in a radio, checkbox , select or multiple select object types >>>  text(t),textarea(x),hidden(h), radio(r),checkbox(c), select(s)
	//in order this function to work default option on the select must be valued as "nada",
	//select boxes always report their first option whether it is selected or not, always as selected

	var numChecked = 0;
	if ( (objType=="s") || (objType=="m") )
	{

		for (var x=0; x<obj.options.length; x++)
		{
			if ( obj.options[x].selected )
			{
				if ( obj.options[x].value != "novalue" )
				{
					numChecked++;

				}
			}
		}
	}
	//if textbox or textarea or hidden
	if (objType=="t" || objType=="x" || objType=="h" || objType=="htx")
	{
		//alert('obj.value'+obj.value)
		//alert('obj.value.length'+obj.value.length)
		if ( obj.value == null )
		{
			numChecked = 0
		}
		else
		{

			numChecked =  obj.value.length
		}
	}
	//if radio or checkboxes  ( rc is a shortcut for radio or check )
	if ( (objType=="r") || (objType=="c") || (objType=="rc") )
	{
		for(var x = 0; x < obj.length; x++)
		{
			if(obj[x].checked)
			{
				numChecked++;
			}
		}
	}
	return numChecked;
}

function  GetObjectVal(obj,objType,objSep,ErrorCaption)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	//returns the value of the following object types >>>  text(t),textarea(x),hidden(h), radio(r),checkbox(c), select(s)
	//if empty it returns a value of EMPTY: followed by ErrorCaption

	//in order this function to work default option on the select must be valued as "novalue",
	//select boxes always report their first option whether it is selected or not, always as selected
	//if an empty string is an accepted value and should not be caught by the validation engine, then instead of leaving the value as "" leave it as "EMPTYSTRING"
	//in the posted page, do something for those that are submitted with with the value "EMPTYSTRING"

	var returnVal = ""

	//if select or multiple select

	if ( (objType=="s") || (objType=="m") || (objType=="sm") )
	{
		for (var x=0; x<obj.options.length; x++)
		{
			if ( obj.options[x].selected )
			{
				if ( obj.options[x].value != "novalue" )
				{
					returnVal = returnVal + obj.options[x].value + objSep

				}
			}
		}
	}
	//if textbox or textarea or hidden
	if (objType=="t" || objType=="x" || objType=="h" || objType=="htx" )
	{
		returnVal =  obj.value
	}

	//if radio or checkboxes  ( rc is a shortcut for radio or check )
	if ( (objType=="r") || (objType=="c") || (objType=="rc") )
	{
		for(var x = 0; x < obj.length; x++)
		{
			if(obj[x].checked)
			{
				returnVal = returnVal + obj[x].value + objSep
			}
		}
	}

	if ( returnVal.length == 0 )
	{
		returnVal = ""
	}


	return returnVal;
}


function TrackCount(fieldObj,countFieldName,maxChars)
{

  var countField = eval("fieldObj.form."+countFieldName);

  var diff = maxChars - fieldObj.value.length;

  // Need to check & enforce limit here also in case user pastes data
  if (diff < 0)
  {
    fieldObj.value = fieldObj.value.substring(0,maxChars);
    diff = maxChars - fieldObj.value.length;
  }
  countField.value = diff;
}

function LimitText(fieldObj,maxChars)
{

  var result = true;
  if (fieldObj.value.length >= maxChars)
    result = false;

  if (window.event)
    window.event.returnValue = result;
  return result;
}





//helpfer functions

function Uncheck(obj,curvalue)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	for(var x = 0; x < obj.length; x++){
		if (curvalue == obj[x].value) {
			obj[x].checked=false;
			break;
		}

	}

}
function AssignCheckValue(toBeSetValue,obj,objValue)
{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	for(var x = 0; x < obj.length; x++){
		if (obj[x].value == objValue)
		{
			obj[x].checked = toBeSetValue

		}
	}
}
function isValidEmail(emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address.
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
/* Finally, let's start trying to figure out if the supplied address is
   valid. */
/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	//alert("Invalid email address structure detected.")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid
if (user.match(userPat)==null) {
    // user is not valid
    //alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
			//alert("Destination IP address is invalid!")
			return false
	    }
    }
    return true
}
// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
	return false
}
/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding
   the domain or country. */
/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
	//	alert("The address must end in a three-letter domain, or two letter country.")
	return false
}
// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   return false
}
// If we've gotten this far, everything's valid!
return true;
}

function isCreditCard(st) {
  // Encoding only works on cards with less than 19 digits
  if (st.length > 19)
    return (false);

  sum = 0; mul = 1; l = st.length;
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }
// Uncomment the following line to help create credit card numbers
// 1. Create a dummy number with a 0 as the last digit
// 2. Examine the sum written out
// 3. Replace the last digit with the difference between the sum and
//    the next multiple of 10.

//  document.writeln("<BR>Sum      = ",sum,"<BR>");
//  alert("Sum      = " + sum);

  if ((sum % 10) == 0)
    return (true);
  else
    return (false);

} // END FUNCTION isCreditCard()

function isWithinRange (s, a, b)
{   if (isEmpty(s))
       if (isWithinRange.arguments.length == 1) return defaultEmptyOK;
       else return (isWithinRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}

function  isDate(y,m,d)

{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	alert('day'+d)
	return false;
}
function isInteger (s)

{   var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
}


function Zoom2(obj,objstr,caption,maxL)
//======================================================

{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

	sample call


	<input type="button" value="ZOOM" onClick="Zoom(window.document.FORMNAME.TEXTAREANAME,'FORMNAME.TEXTAREANAME')">


	*/

	var	cap ;
	var instruction ;
	var defaultinstruction ;
	var funstr;
	var textAreaStrInCaseOfMaxL;
	var boxCounterInCaseOfMaxL;

	defaultinstruction = "Instead of working in the small text area of the main form, you may temporarily work in this resizable text area. <p>When done simply click the Update button."

	//alert('org caption is ' + caption)
	if ( contains(caption,"|") )
	{
		cap = leftof(caption,"|")
		instruction = rightof(caption,"|")
	}
	else
	{
		//alert('does not contains |')
		cap = caption
		instruction = defaultinstruction
	}


	//alert('cap='+cap)
	//alert('instruction='+instruction)

	//alert('maxL='+maxL)
	var objval = obj.value
	var zoomwin = window.open("","zoomwin","Width='500',height='500'")
	zoomwin.document.open()
	zoomwin.document.write ("<scr" + "ipt>\n")
	zoomwin.document.write ("var objstr=" + "'" + objstr + "'" + ";\n")
	zoomwin.document.write ("var defaultinstruction=" + "'" + defaultinstruction + "'" + ";\n")
	zoomwin.document.write ("var cap=" + "'" + cap + "'" + ";\n")
	zoomwin.document.write ("var maxL="  + maxL  + ";\n")

	//text counter coming into the picture !...


	funstr = "function TrackCount(fieldObj,countFieldName,maxChars){var countField = eval(\"fieldObj.form.\"+countFieldName);var diff = maxChars - fieldObj.value.length;if (diff < 0){fieldObj.value = fieldObj.value.substring(0,maxChars);diff = maxChars - fieldObj.value.length;}countField.value = diff;}"
	zoomwin.document.write (funstr + "\n\n")

	funstr = "function LimitText(fieldObj,maxChars){ var result = true;  if (parseInt(fieldObj.value.length) >= parseInt(maxChars))   result = false;  if (window.event) window.event.returnValue = result;return result;}"
	zoomwin.document.write (funstr + "\n\n")

	textAreaStrInCaseOfMaxL = "onkeyup='TrackCount(this,\"formbuildersystem_textcount7549685E02\"," + maxL + ")' onkeypress='LimitText(this," + maxL + ")'"
	boxCounterInCaseOfMaxL = "<input type='text' name='formbuildersystem_textcount7549685E02' size='3' value='" + maxL + "'>"

	if (maxL == "" )
	{
		textAreaStrInCaseOfMaxL = ""
		boxCounterInCaseOfMaxL=""
	}
	else
	{
	}


	zoomwin.document.write ("</scr" + "ipt>\n\n")
	zoomwin.document.write ("<form name='frm'>\n\n<textarea rows='40' cols='100' name='zoombox' " + textAreaStrInCaseOfMaxL + ">"+ objval + "</textarea>\n" + boxCounterInCaseOfMaxL + "<p>")
	zoomwin.document.write ("<input type='button' value='Update" + "`" + cap + "`" + "' onClick='window.opener." + objstr + ".value=window.document.frm.zoombox.value;self.close()'>\n\n</form>\n")
	zoomwin.document.close()


	return true;

}


function ZoomButton2(Param1,Param2,Param3,Param4)
//======================================================

{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

	sample call


		<sc> ZoomButton2('window.document.frm.postedscript','frm.postedscript','Comments|Instead of typing into the small box, you may work with this bigger box and when done simply click Update.',3000) </sc>


	*/


	document.write ("<input type=\"button\" value=\"ZOOM\" onClick=\"Zoom2("              + Param1 + "," + "'" + Param2 + "'"  + "," + "'" + Param3 + "'"  + "," + "'" + Param4 + "'" +               ")\">")

	return true;
}


function ZoomButton(Param1,Param2)
//======================================================

{
	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

	sample call


		<sc> ZoomButton('window.document.frm.postedscript','frm.postedscript') </sc>


	*/

	
	document.write ("<input type=\"button\" value=\"ZOOM\" onClick=\"Zoom(" + Param1 + "," + "'" + Param2 + "')\">")

	return true;
}



function ViewSource()

//======================================================
{

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

			  <INPUT TYPE="BUTTON" VALUE="VIEW SOURCE" onClick= 'ViewSource()'>

			  or

			  <sc> ButtonViewSource() </sc>

	*/
	window.location = "view-source:" + window.location.href
}


function ViewSourceButton()
//======================================================
{

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

			ViewSourceButton()

	*/

	window.document.write ("<INPUT TYPE=\"BUTTON\" VALUE=\"VIEW SOURCE\" onClick= 'ViewSource()'>")
}

function Refresh()
//======================================================
{

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

			  <INPUT TYPE="BUTTON" VALUE="REFRESH" onClick= 'Refresh()'>

			  <sc> RefreshButton() </sc>

	*/
	window.location.reload()
}

function RefreshButton()
//======================================================
{

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

			<sc> ButtonRefresh() </sc>

	*/

	window.document.write ("<INPUT TYPE=\"BUTTON\" VALUE=\"REFRESH\" onClick= 'Refresh()'>")

}


function RS (s)

{

	// Author: Haluk Karamete 
	// URL   : www.developerlibrary.com | August 16,2005

	/*

		<sc> RS </sc>  or <sc> RS("<br>") </sc>

	*/

	if ( s.length > 0 )
	{
		document.write (s)
	}
	else
	{
		document.write ("&nbsp;")
	}

	return true;

}

-->