﻿function MM_swapImgRestore() 
{ 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// for buttons mouseover and mouseout events
function MouseIn(event)
{
    var Objevt;
    if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
	    Objevt = event.srcElement
	}
	else
	{
        Objevt = event.target
    }    
    
	Objevt.className='CommandButton_hover';

    /*
    Objevt.style.cursor = "hand"; 
    Objevt.style.textDecorationUnderline = true;
    Objevt.style.textDecorationBlink = true;
    Objevt.style.fontWeight = 'Bold';
    */
}
		
function MouseOut(event)
{
    var Objevt;
    if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
	    Objevt = event.srcElement
	}
	else
	{
        Objevt = event.target
    }
    Objevt.className='CommandButton';
}

function ExitFunction(event) {
    if (event != undefined) {
        if (navigator.appVersion.indexOf("MSIE") != -1) {
            event.returnValue = false;
            return false;
        }
        else {
            event.preventDefault();
            return false;
        }
    }
    else {
        return false;
    }
}
function CheckEmail(mailobject, event) {
   
    var email = mailobject.value;
    if (mailobject.value != "") {
        var AtSign, DotSign, pos, DotAfter, DotPos, charAftDot;
        AtSign = mailobject.value.search("\\@");
        pos = mailobject.value.search("\\@");
        DotAfter = mailobject.value.substring(pos + 1, mailobject.value.length);
        DotPos = DotAfter.search("\\.");
        DotSign = mailobject.value.search("\\.");
        charAftDot = mailobject.value.substring(DotSign + 1, mailobject.value.length);


        if (AtSign == -1) {
            mailobject.value = "";
            mailobject.focus();
            ShowAlertPopup("Enter Correct EmailID");
            return ExitFunction(event);
        }
        else if (DotSign == -1) {
            mailobject.value = "";
            mailobject.focus();
            ShowAlertPopup("Enter Correct EmailID");
            return ExitFunction(event);
        }
        else if (DotPos == -1) {
            mailobject.value = "";
            mailobject.focus();
            ShowAlertPopup("Enter Correct EmailID");
            return ExitFunction(event);
        }
        else {
            if (charAftDot.length == 0) {
                mailobject.value = "";
                mailobject.focus();
                ShowAlertPopup("Enter Correct EmailID");
                return ExitFunction(event);
            }
            return true;
        }
    }
}
function ValidateNumber(Current, CompulsoryField, NegativeAllowed, AlliesName, ZeroAllowed, event) {
    var IsAlliesName = true;

    if ((typeof (CompulsoryField) == 'undefined') || (CompulsoryField == null)) {
        CompulsoryField = 'No';
    }

    if ((typeof (NegativeAllowed) == 'undefined') || (NegativeAllowed == null)) {
        NegativeAllowed = 'No';
    }

    if ((typeof (AlliesName) == 'undefined') || (AlliesName == null)) {
        IsAlliesName = false;
    }

    if ((typeof (ZeroAllowed) == 'undefined') || (ZeroAllowed == null)) {
        ZeroAllowed = 'No';
    }

    if ((CompulsoryField != 'No') && (Current.value == 0) && (ZeroAllowed == 'No')) {
        Current.focus();

        if (IsAlliesName) {
            ShowAlertPopup("Enter " + AlliesName + "");
        }
        else {
            ShowAlertPopup("Enter the value");
        }

        return ExitFunction(event);
    }

    if (Current.value == "") {
        //Current.value = 0;
        return true;
    }
    else {
        if (isNaN(Number(Current.value))) {
            Current.value = "";
            Current.focus();
            ShowAlertPopup("Enter numbers only");

            return ExitFunction(event);
        }

        if (NegativeAllowed == 'No') {
            if ((eval(Number(Current.value))) < 0) {
                Current.value = "";
                Current.focus();
                ShowAlertPopup("Negative values are not allowed");
                return ExitFunction(event);
            }
        }
        Current.value = Current.value;
        return true;
    }
}
function Confirmation(event, Action) {

    var ConfirmMsg;

    if (typeof (Action) == 'undefined') {
        ConfirmMsg = confirm("Are you sure you want to delete the selected record?")
    }

    if (ConfirmMsg == false) {
        return ExitFunction(event);
    }
    else {
        return true;
    }

}