var menu0=new Array()
menu0[0]='<a href="/iw/EWills">Express Islamic Wills</a>'
menu0[1]='<a href="/iw/Wills">Bespoke Islamic Wills</a>'
//menu0[2]='<a href="/iw/TaxPlanning">Inheritance Tax Planning</a>'
//menu0[3]='<a href="/iw/Probate">Probate</a>'
menu0[2]='<a href="/iw/Inheritance">Inheritance Distribution</a>'


var menu1=new Array()
menu1[0]='<a href="/iw/IslamicWill">What is an Islamic Will</a>'
menu1[1]='<a href="/iw/WhyIslamicWill">Why Make an Islamic Will</a>'
menu1[2]='<a href="/iw/Sources">Quran and Hadith Sources</a>'
menu1[3]='<a target=_blank href="/guide.pdf">Our Islamic Wills Guide</a>'
menu1[4]='<a href="/iw/Glossary">Islamic Will Glossary</a>'
menu1[5]='<a href="/iw/Articles?command=">Articles</a>'
menu1[6]='<a href="/iw/FAQ">FAQ</a>'

var menu2=new Array()
menu2[0]='<a href="/iw/Founders">Company Information</a>'
menu2[1]='<a href="/iw/Partners">Our Partners</a>'
menu2[3]='<a href="/iw/TermsAndConditions">Terms and Conditions</a>'

var menu3=new Array()
menu3[0]='<a href="/iw/InheritanceCalculator">Inheritance Tax Calculator</a>'
menu3[1]='<a href="https://www.islamwills.com/iw/MakeWill?express=true&start=emenu">Start an Express Islamic Will</a>'
//menu3[2]='<a href="https://www.islamwills.com/iw/MakeWill?start=bmenu">Start a Bespoke Islamic Will</a>'
menu3[2]='<a href="https://www.islamwills.com/iw/MakeSpouseWill">Make An Islamic Will For My Spouse</a>'
//menu3[4]='<a href="https://www.islamwills.com/iw/TelephoneInterview">Request a Telephone Interview</a>'
menu3[3]='<a href="https://www.islamwills.com/iw/AmendWill">Amend My Islamic Will</a>'
//menu3[6]='<a href="https://www.islamwills.com/iw/InvoiceSummary">View/Pay Invoices</a>'
menu3[4]='<a href="/sample.pdf">Sample Will</a>'


var menuwidth='165px' //default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

var hideshow = true;
var showHelpTag = "<img class=\"logo\" src=\"/img/question_mark.png\"/>&nbsp;Help";
var hideHelpTag = "Hide Help";

/////No further editting needed


var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
    document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype)
{
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null)
    {
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth)
{
    if (ie4||ns6)
        dropmenuobj.style.left=dropmenuobj.style.top="-500px"
    if (menuwidth!="")
    {
        dropmenuobj.widthobj=dropmenuobj.style
        dropmenuobj.widthobj.width=menuwidth
    }
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
        obj.visibility=visible
    else if (e.type=="click")
        obj.visibility=hidden
}

function changeLinkColour(obj, changeColor) {

}

function iecompattest()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge")
    {
        var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
        if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
            edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
    }
    else
    {
        var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
        var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
        if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        { //move up?
            edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
            if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
                edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
        }
    }
    return edgeoffset
}

function populatemenu(what)
{
    if (ie4||ns6)
        dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth)
{
    if (window.event) 
        event.cancelBubble=true
    else if (e.stopPropagation) 
        e.stopPropagation()
    clearhidemenu()
    dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
    populatemenu(menucontents)

    if (ie4||ns6)
    {
        showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
    }
    return clickreturnvalue();
}

function clickreturnvalue()
{
    if (ie4||ns6) 
        return false;
    else 
        return true;
}

function contains_ns6(a, b) 
{
    while (b.parentNode)
    {
        if ((b = b.parentNode) == a)
            return true;
    }
    return false;
}

function dynamichide(e)
{
    if (ie4&&!dropmenuobj.contains(e.toElement))
        delayhidemenu()
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
        delayhidemenu()
}

function hidemenu(e)
{
    if (typeof dropmenuobj!="undefined")
    {
        if (ie4||ns6)
            dropmenuobj.style.visibility="hidden"
    }
}

function delayhidemenu()
{
    if (ie4||ns6)
        delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu()
{
    if (typeof delayhide!="undefined")
        clearTimeout(delayhide)
    if (hidemenu_onclick=="yes") 
    {
        document.onclick=hidemenu
    }
}

function changeLinkHref(id,newHref) 
{
    if (document.links.length > 0) 
    {
        if (document.getElementById) 
        {
            document.getElementById(id).href = newHref;
        }
    }
}

function loadPage()
{
    changeLinkHref("menu0","/iw/Main");
    changeLinkHref("menu1","/iw/Main");
    changeLinkHref("menu2","/iw/Main");
    changeLinkHref("menu3","/iw/Main");
    if (document.getElementById("leftmenubar")) {
        document.getElementById("leftmenubar").style.visibility  = 'hidden';
        document.getElementById("leftmenubar").style.height='0px';
    }
}

function loadAddress(radio,id) {  
    if (radio.checked) {
        document.all("contactaddress.address").value=address[id];
        document.all("contactaddress.city").value=city[id];
        document.all("contactaddress.postcode").value=postcode[id];
        document.all("contactaddress.country").value=country[id];
    } 
}

function loadContact(radio,id) {
    if (radio.checked) {
        if (document.all("memberDetail.gender")!=null) {
        if (allinfo[id][9]=="Male") {
            document.all("memberDetail.gender")[0].checked=true;
        }
        else {
            document.all("memberDetail.gender")[1].checked=true;
        }
        }
        document.all("memberDetail.forename").value=allinfo[id][0];
        document.all("memberDetail.surname").value=allinfo[id][1];
        if (document.all("contactaddress.address")!=null) {
            document.all("contactaddress.address").value=allinfo[id][2];
            document.all("contactaddress.city").value=allinfo[id][3];
            document.all("contactaddress.postcode").value=allinfo[id][4];
            document.all("contactaddress.country").value=allinfo[id][5];
        }
        document.all("memberDetail.type").value=allinfo[id][10];
        document.all("memberDetail.relationship").value=allinfo[id][6];
        if (allinfo[id][7]=="true") {
            document.all("memberDetail.adult")[0].checked=true;
        }
        else {
            document.all("memberDetail.adult")[1].checked=true;
        }
        if (allinfo[id][8]=="true") {
            document.all("memberDetail.religion")[0].checked=true;
        }
        else {
            document.all("memberDetail.religion")[1].checked=true;
        }
        if (allinfo[id][10]=="other") {
            disableFields(false);
        }
        else {
            disableFields(true);         
        }
    } 
}


function disableFields(field) {
    document.all("memberDetail.gender")[0].disabled=field;
    document.all("memberDetail.gender")[1].disabled=field;
    document.all("memberDetail.forename").disabled=field;
    document.all("memberDetail.surname").disabled=field;
    document.all("memberDetail.gender").disabled=field;
    /*if (document.all("contactaddress.address")!=null) {
        document.all("contactaddress.address").disabled=field;
        document.all("contactaddress.city").disabled=field;
        document.all("contactaddress.postcode").disabled=field;
        document.all("contactaddress.country").disabled=field;
            
    }*/
    document.all("memberDetail.relationship").disabled=field;
    document.all("memberDetail.adult")[0].disabled=field;
    document.all("memberDetail.adult")[1].disabled=field;
    document.all("memberDetail.religion")[0].disabled=field; 
    document.all("memberDetail.religion")[1].disabled=field; 
    return true;
}

function loadSurname(radio,surname) {  
    if (radio.checked) {
        document.all("memberDetail.surname").value=surname;
    } 
}

function checkOther(list) {
    if (list.value=="Other") 
    {
        document.getElementById("specifyname").style.display="inline";
        document.getElementById("specifyfield").style.display="inline";
    }
    else {
        document.getElementById("specifyname").style.display="none";
        document.getElementById("specifyfield").style.display="none";
    }
}

$(document).ready(function() {
    /*if ($("#updatehelp")!=null && $("#lastPage")!=null && $("#lastPage").val()=="") {
        showHelp('updatehelp');
    }*/
});


function showMainHelp() {
    showHelp("help");  
}



function showHelp(div) {
    $("#"+div).dialog({
        maxwidth: 400 , 
        modal: false, 
        maxheight: 400
    });
}

function disable(button) {
    button.disabled=disable;
    document.forms["paytakeform"].submit();
    return true;
}

function updateTitle(gender) {
    $('#titlelist').find('option').remove().end();
    if (gender=="Male") {
        $('#titlelist').append("<option value='Mr'>Mr</option>").append("<option value='Dr'>Dr</option>");
    }
    else {
        $('#titlelist').append("<option value='Mrs'>Mrs</option>").append("<option value='Miss'>Miss</option>").append("<option value='Ms'>Ms</option>").append("<option value='Dr'>Dr</option>");
    }
}

function newContact() {
    document.all("memberDetail.gender")[0].checked=false;
    document.all("memberDetail.gender")[1].checked=false;
    document.all("memberDetail.forename").value="";
    document.all("memberDetail.surname").value="";
    if (document.all("contactaddress.address")!=null) {
        document.all("contactaddress.address").value="";
        document.all("contactaddress.city").value="";
        document.all("contactaddress.postcode").value="";
        document.all("contactaddress.country").value="";
    }
    document.all("memberDetail.relationship").value="";
    document.all("memberDetail.adult")[0].checked=false;
    document.all("memberDetail.adult")[1].checked=false;
    document.all("memberDetail.religion")[0].checked=false;
    document.all("memberDetail.religion")[1].checked=false;        
    disableFields(false);
}

function clearSelect(field) {
    document.all(field).value=0;
}
