var state = 'none'; 
function showhide(layer_ref)
{ 
    alert(layer_ref);
    if (state == 'block') 
    { 
        alert("Set as none");
        state = 'none'; 
    }
    else
    { 
        alert("Set as block");
        state = 'block'; 
    }
    
    if (document.all)
    { //IS IE 4 or 5 (or 6 beta) 
        eval( "document.all." + layer_ref + ".style.display = state"); 
    }
    
    if (document.layers)
    { //IS NETSCAPE 4 or below 
        document.layers[layer_ref].display = state; 
    }
    
    if (document.getElementById &&!document.all) 
    { 
        hza = document.getElementById(layer_ref); 
        hza.style.display = state; 
    }
}

function SmartJack(DivtoHide, DivtoShow)
{
    showhide(DivtoHide);
    showhide(DivtoShow);
}

function ShowDiv(id)
{
   var e = document.getElementById(id);
   if(e.style.display == 'block')
   {
       e.style.display = 'none';
   }
   else
   {
       e.style.display = 'block';
   }
}

function SendToPage(val)
{
    document.nanakshahi.action=val;
    document.nanakshahi.submit();
    return true;
}

function SortList(SortReq, DivToCloseID)
{
    var e = document.getElementById(SortReq);
    alert(e.options.value);
    ShowDiv(DivToCloseID);
}

function ValidateEmail(EmailValue)
{
    var strMail = EmailValue;
    strMail = trim(strMail);
    if(strMail.length>6)
    {
        var regMail =  /^\w+([-.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;        
        if (regMail.test(strMail))        
        { 
            return true;
        }
        else
        {
            document.nanakshahi.email.focus();
            alert("Invalid email format.\nPlease enter a valid email in the format user@host.domain.");            
            return false;
        }
    }
    else
    {
        alert("Email address seems to be short or incomplete");
        document.nanakshahi.email.focus();
        return false;
    }
}
    
function ValidateAdopter()
{
    var Fname = document.nanakshahi.first_name.value;
    var Aemail = document.nanakshahi.email.value;
    Fname = trim(Fname);
    Aemail = trim(Aemail);
    
    if(Fname!=null)
    {
        if(Fname.length>=3)
        {
            return ValidateEmail(Aemail);
        }
        else
        {
            alert("Please fill in your valid first name");
            document.nanakshahi.first_name.focus();
            return false;
        }
    }
    else
    {
        if(Fname=="" || Fname=="null" || Fname==null)
        {
            alert("Your have not mentioned your first name");
            document.nanakshahi.first_name.focus();
            return false;
        }
    }
}
