var myimages=new Array()

function removeitem(sourceList)
{
	var maxCnt = sourceList.options.length; 
	for(var i = maxCnt - 1; i >= 0; i--) { 
		if ((sourceList.options[i]!= null) && (sourceList.options[i].selected == true)) 
			sourceList.options[i] = null; 
	} 
}

function loadjava(file){
  var head = parent.document.getElementsByTagName('head').item(0)
  var scriptTag = parent.document.getElementById('loadScript');
  if(scriptTag) head.removeChild(scriptTag);
  script = parent.document.createElement('script');
  script.src = file;
	script.type = 'text/javascript';
	script.id = 'loadScript';
	head.appendChild(script)
}

function CheckFDel(url)
{
 if (ConfirmDelete())
     location.href=url;
 }

// Mouse Over LIst Change Color
function changeBox(myInfo,myToggle)
{
 isItSelected=eval("document.all."+myInfo+".style.backgroundColor");
 if (myToggle=="1")
      {
          if (isItSelected=="#b8c9db")
                 {
                 } else {
                         eval("document.all."+myInfo+".style.backgroundColor=\"E0E0E0\";");
                         eval("document.all."+myInfo+".style.cursor=\"hand\";");
                        }
       }   else  {
                   if (isItSelected=="#b8c9db")
                   {
                   } else {
                           eval("document.all."+myInfo+".style.backgroundColor=\"#E9E9E9\";");
                           eval("document.all."+myInfo+".style.cursor=\"default\";");
                          }
                 }
}

function PagingMove(frm,mvpage)
{
       if (frm)
       {
        document.forms[frm].page.value=mvpage;
        document.forms[frm].submit();
       }
}


function preloadimages(){
         for (i=0;i<preloadimages.arguments.length;i++){
                  myimages[i]=new Image()
                           myimages[i].src=preloadimages.arguments[i]
                                    }
                                    }

//preloadimages("images/bullet.gif","images/divider.gif","images/minus.gif","images/plus.gif","images/remove.gif","images/top_bg_1.gif","images/update.gif")

// trim spaces function (client-side)...! //
function EliminateSpaces(_handler)
{
        while(''+_handler.value.charAt(_handler.value.length-1)==' ')
                _handler.value=_handler.value.substring(0,_handler.value.length-1);
}

function ConfirmDelete(path)
{
	//if (document.all&&window.print)
  var confirmWindow = window.showModalDialog(path+"/include/confirmdelete.php","","edge: Sunken; resizable: No; scroll: No; status: No; help: No; dialogWidth: 300px; dialogHeight: 120px; center: True");
	//else
	//{
	 //	var confirmWindow = 	window.open(path+"/include/confirmdelete.php","","width=300px,height=120px,resizable=0,scrollbars=0")
	//}

 window.event.returnValue = confirmWindow;
 //alert("sa="+confirmWindow);
 return confirmWindow;
}

function ConfirmAllDelete(path)
{
 var confirmWindow = window.showModalDialog(path+"/include/confirmdeleteall.php","","edge: Sunken; resizable: No; scroll: No; status: No; help: No; dialogWidth: 300px; dialogHeight: 120px; center: True");
 window.event.returnValue = confirmWindow;
 return confirmWindow;
}

function ConfirmClear(path)
{
 var confirmWindow = window.showModalDialog(path+"/include/confirmclear.asp","","edge: Sunken; resizable: No; scroll: No; status: No; help: No; dialogWidth: 300px; dialogHeight: 120px; center: True");
 window.event.returnValue = confirmWindow;
 return confirmWindow;
}

function ConfirmUpdate(path)
{
 var confirmWindow = window.showModalDialog(path+"/include/confirmupdate.php","","edge: Sunken; resizable: No; scroll: No; status: No; help: No; dialogWidth: 300px; dialogHeight: 120px; center: True");
 window.event.returnValue = confirmWindow;
 return confirmWindow;
}

function ConfirmInsert(path)
{
 var confirmWindow = window.showModalDialog(path+"/include/confirminsert.php?path="+path,"","edge: Sunken; resizable: No; scroll: No; status: No; help: No; dialogWidth: 300px; dialogHeight: 120px; center: True");
 window.event.returnValue = confirmWindow;
 return confirmWindow;
}


function IsYearLeap(theYear)
{
        var _retVal = false;
        if((theYear/4) == Math.round((theYear/4)))
        {
                _retVal = true;
                if((theYear/100) == Math.round((theYear/100)))
                {
                        _retVal = false;
                        if((theYear/400) == Math.round((theYear/400)))
                                _retVal = true;
                }
        }
        return _retVal;
}


function IsValidDate(_eDay, _eMonth, _eYear)
{
        var _retVal = true;

        //alert('Leap Year = ' + IsYearLeap(_eYear));

        if (IsYearLeap(_eYear) && _eMonth == 2 && _eDay > 29)
        {
                _retVal = false;
        }
        else if (!IsYearLeap(_eYear) && _eMonth == 2 && _eDay > 28)
        {
                _retVal = false;
        }
        else if ((_eMonth == 2 || _eMonth == 4 || _eMonth == 6 || _eMonth == 9 || _eMonth == 11) && _eDay > 30)
        {
                _retVal = false;
        }



        //alert('ValidDate = ' + _retVal);
        return _retVal;
}

function ShowTip()
{
        var eSrc = window.event.srcElement;
        var eHelpMenu = document.all["help"];
        OpenMenu(eSrc, eHelpMenu);
}


function DaysCompare(_v1,_v2) {
  var _delta = 0;
  var _a1 = _v1;
  var _a2 = _v2;
  var _err = "0";
  if (_v1.getTime() <= _v2.getTime()) {
    _a1 = _v2;
        _a2 = _v1;
     }
  else
  { return _err; }
  _delta = _a1.getTime() - _a2.getTime();
  _delta /= (1000 * 60 * 60 * 24);
  return _delta;
}

function formatAmount(_amount)
{
        /*ToDo*/
}

function formatCurrency(num)
{
	
        /***        Convert Number to recognizable number format for javascript        ***********************************/
        num = num.toString().replace(/\$|\./g,''); // Eliminate GR-fullstop
        num = num.toString().replace(/\$|\,/g,'.'); // Replace decimal separator from GR-comma 2 EN-fullstop
        /******************************************************************************************************/

        if(isNaN(num))
                num = "0";

        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();

        if(cents<10)
                cents = "0" + cents;

        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
                num = num.substring(0,num.length-(4*i+3)) + '.' + num.substring(num.length-(4*i+3)); //GR-fullstop thousand seperator

        return (((sign)?'':'-') + num + ',' + cents); //GR-comma decimal separator
}

function formatCurrencyForCalc(num)
{
        num = num.toString().replace(/\$|\./g,''); // Eliminate GR-fullstop
        num = num.toString().replace(/\$|\,/g,'.'); // Replace decimal separator from GR-comma 2 EN-fullstop

        if(isNaN(num))
                num = "0";

        return num;
}

function ConvertEnToGrFormat(num)
{
        num = num.toString().replace(/\$|\./g,','); //Perform reverse replacement before formatting... EN-fullstop 2 Gr-Comma
        return formatCurrency(num)
}

function ClearFields()
{
        var _flg = ConfirmClear();
        if(_flg == true)
        {
                var obj = document.all.item("cmdClear");
                for (i=0; i<obj.length; i++)
                {
                        document.forms[0].cmdClear[i].value="";
                }
        }
}

function ClearFieldPerID(id)
{
                var obj = document.all.item("cmdClear");
                for (i=id; i<obj.length; i++)
                {
                        document.forms[0].cmdClear[i].value="";
                }
}


// Check Phone  Format
function IsPhoneNumber(arg)
{
   var ValidChars = "0123456789.-)+( ";
   var IsPhone=false;
   var Char;
   for (i = 0; i < arg.length && IsPhone == false; i++)
      {
      Char = arg.charAt(i);
      if (ValidChars.indexOf(Char) == -1 || ValidChars.indexOf(Char) == null )
         {
         IsPhone = true;
         }
      }
   return IsPhone;

}

//Compare Dates
        function CompDate(vArg) {
                var date = new Date(vArg);
                var now = new Date();
                var diff = date.getTime() - now.getTime();
                var days = Math.floor(diff / (1000 * 60 * 60 * 24));
                return days
        }


// Check Email
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
        result = true;
  }
  return result;
}

function CheckAfm(afm)
{
        var tmpVal = 256;
        var Sum = 0;

        if (afm.length != 9 )
           { return false; }
        if (isNaN(afm.length))
           { return false; }

        for (cnt = 0;cnt < 8; cnt++)
        {
                Sum = Sum + tmpVal * afm.charAt(cnt);
                tmpVal = tmpVal / 2;
        }

        var Rem = Sum%11;
        if (Rem == 10 ) { Rem = 0; }
        if (Rem == afm.charAt(8))
        { return true; }
        else
        { return false; }
}

function showRemote(RemAdrdres)
        {
                self.name = "main"; // names current window as "main"
                var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
                "menubar=0,scrollbars=1,resizable=1,width=450,height=400";
                OpenWindow = window.open(RemAdrdres, "remote", windowprops);
        }

function showRemote2(RemAdrdres,Wid)
        {
                self.name = "main"; // names current window as "main"
                var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
                "menubar=0,scrollbars=1,resizable=1,width="+Wid+",height=400";
                OpenWindow = window.open(RemAdrdres, "remote", windowprops);
        }

function click()
        {
         //if (event.button==2) {
         //alert('Free ISP Project 2002 / 2003.')
         //}
        }

function showhideobj(id)
           {
            var obj = document.getElementById(id).style;
            if (obj.display=='none')
                obj.display = '';
            else
                obj.display = 'none';
            
           }
//document.onmousedown=click



