﻿$(document).ready(function() {
    var arrPhoto = ["jb", "mh", "jc", "ty", "gs", "sy", "ln", "sp", "sc", "to", "bs", ""]
    var arrName = ["Jeremy Birman", "Michael Hodgkins", "Jonathan Chong", "Tobias Young", "Gregory Stockton", "Scott Young", "Lucy Newson", "Sharminie Perera", "Sue Cox", "Tracy Ong", "Bradley Smith", "Mariana Prananto"];
    var arrTitle = ["B Juris, LLB", "B Comm, LLB, A. Mus A.", "LLB", "LLB (Distinction), BSc", "", "", "", "", "", "B Comm", "BSc, MCP", "MIS (Distinction)"];
    var arrPosition = ["Partner", "Partner", "Lawyer", "Articled Clerk", "Legal Executive", "Legal Executive", "Legal Executive", "Legal Executive", "Document Production", "Records and Administration Manager", "Software Development Manager", "Website Developer"];
    var arrPhone = ["9220 4480", "9220 4455", "9220 4467", "9220 4404", "9220 4408", "9220 4401", "9220 4408", "9220 4402", "9220 4491", "9220 4407", "9220 4425", "9220 4427"];
    var arrEmail = ["jb@birmanride.com.au", "mh@birmanride.com.au", "jc@birmanride.com.au", "ty@birmanride.com.au",
                    "gs@birmanride.com.au", "sy@birmanride.com.au", "lmn@birmanride.com.au", "sp@birmanride.com.au", "sc@birmanride.com.au", 
                    "to@birmanride.com.au", "bs@overtech.com.au", "mp@birmanride.com.au"];
    var arrPractice = ["General, civil and commercial litigation, criminal law, property and commercial law",
                    "Family law, wills, probate and deceased estates, estate planning, property and commercial law",
                    "Debt collection, family law, civil and commercial litigation, solicitor's certificate",
                    "General and civil litigation", "Commercial and civil litigation", "Commercial and civil litigation", 
                    "Real estate settlements", "Wills, enduring power of attorney, probate and deceased estates", "", "", "", ""];
    var arrBiography = ['Jeremy established the practice of Birman & Ride in 1979. He has been practising law as a barrister and solicitor since 1977 and has extensive experience in all areas of civil, commercial and criminal litigation and commercial law. He has appeared as counsel in nearly every court and tribunal in the state.',
                    'Michael graduated from Murdoch University Law School in 1996 and joined the firm as an articled clerk the same year. He was admitted to practice in 1997.',
                    'Jonathan is another graduate of our <a href="default.aspx">cadetship program</a>: he completed his law degree at the University of Western Australia whilst working part time at Birman & Ride.',
                    'Tobias joined our <a href="default.aspx">cadetship program</a> in 2007 and completed his degrees in law and environmental management at the University of Western Australia whilst working at Birman & Ride.',
                    'Gregory is completing bachelor degrees in Law and Arts at the University of Western Australia and is part of our <a href="default.aspx">cadetship program</a>. A keen sportsman, Gregory will give you a hand with your footy-tipping.',
                    'Scott joined our <a href="default.aspx">cadetship program</a> in 2010 and is studying Law and Science at the University of Western Australia. Scott is well suited to our high-tech environment, having skills and experience in computer technical support, repairs, network administration and web design.',                    
                    'Lucy is completing bachelor degrees in Law and Arts (Communication Studies) at the University of Western Australia and is part of our <a href="default.aspx">cadetship program</a>. Lucy has a honed her customer skills in the banking industry.',                        
                    'Sharminie joined our <a href="default.aspx">cadetship program</a> in 2010 and is studying Law and Arts (Political Science and International Relations) at the University of Western Australia. Sharminie has skills and experience working for retail and charitable organisations.',
                    'Sue has over 30 years experience in the preparation of legal documents and has been working at Birman & Ride since 1983. Apart from her skills with the keyboard Sue juggles the demands of our lawyers and legal executives.',
                    'Tracy has a Bachelor of Commerce degree from Curtin University of Technology with majors in Economics and Marketing. Tracy honed her customer service skills as a manager in the retail sector before joining our team. She speaks fluent Mandarin and Cantonese.',
                    'Bradley is a degree-qualified Software Engineer with 5 years of commercial software development experience. He works for Overtech Technologies on a range of projects, including their flagship product ContactsLaw – currently deployed at Birman & Ride. Bradley works closely with our legal professionals to ensure that the software is of the highest quality and meets our ongoing (and demanding) requirements.',
                    'Mariana has a Master degree in Information Systems (with Distinction) from the University of Wollongong. Her systems analysis and design skills started off in desktop applications before joining Birman & Ride.'];    
    var strHTML = '';


    
    for (i=0;i<arrName.length;i++) {        
        strHTML += '<a class="btnStaffNav" id="' + (i + 1) + '" href="#"><img src="images/web/' + arrPhoto[i] + 's.png" title="' + arrName[i] + '" /></a>&nbsp;&nbsp;';
    }
    
    $('#staffNav').html(strHTML);
    strHTML = '';
    
    
    for(x=0; x < arrName.length; x++) {
        strHTML += '<div class="hidden" id="divSN' + (x + 1) + '">';
        strHTML += '<span class="s_large wide"><table cellspacing="7" class="tblStaffH"><tr><td class="noborder">' + arrName[x] + '&nbsp;' + '<span class="s_medium">' + arrTitle[x] + '</span>' + '</td>';
        strHTML += '<td class="right posHeading">' + arrPosition[x] + '</td></tr></table></span>';
        
        strHTML += '<div class="staffphoto"><img src="images/web/' + arrPhoto[x] + '.png" /></div>';
        strHTML += '<div class="staffdesc">';
        //strHTML += '<span class="s_medium">' + arrTitle[x] + '</span>';
        strHTML += '<table class="tblStaff" cellspacing="0"><tr><th class="sborder">Direct line</th><td class="right bold sborder wide" colspan="2">' + arrPhone[x] + '</td></tr>';
        strHTML += '<tr><th class="sborder">Email</th><td class="right smaller sborder wide" colspan="2"><a href="mailto:' + arrEmail[x] + '">' + arrEmail[x] + '</a></td></tr>';
        
        if(arrPractice[x] != '') {
            strHTML += '<tr><th class="sborder">Practices</th><td class="sborder">&nbsp;&nbsp;&nbsp;&nbsp;</td><th class="sborder">Biography</th></tr>';
            strHTML += '<tr><td class="smaller">' + arrPractice[x] + '</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td class="noborder smaller">' 
        } else {
            strHTML += '<tr><th colspan="3">Biography</th></tr>';
            strHTML += '<tr><td class="smaller" colspan="3">' 
        };
        strHTML += arrBiography[x] + '</td></tr></table>';

        strHTML += '</div></div>';
        $('#staffHidden').html(strHTML);
    };

    
    $("#staffContainer").html($("#divSN1").html());
    $(".btnStaffNav").click(function(){
        var ref = this.id;      
        $("#staffContainer").hide();
        $("#staffContainer").html($("#divSN" + ref).html());   
        //$("#staff").fadeIn(1000); 
        $("#staffContainer").fadeIn('slow');
        /*$("#staffContainer").fadeIn(function(){
            this.style.removeAttribute("filter");                            
        });*/
    $("#staffContainer").show();              
    
    });
    $("#btnPrintPage").click(function() {
        window.print();
    });
    $("#btnEmailPage").click(function() {
        //$("#btnEmailPage").attr('href', 'mailto:?body=Visit http://www.birmanride.com.au&subject=You may be interested in');
        $("#btnEmailPage").attr('href', 'mailto:?body=Visit ' + $("#btnEmailPage").attr('title') + '&subject=You may be interested in');
    });
});



/*
        link-preview v1.4 by frequency-decoder.com

        Released under a creative commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/)

        Please credit frequency-decoder in any derivative work - thanks.

        You are free:

        * to copy, distribute, display, and perform the work
        * to make derivative works
        * to make commercial use of the work

        Under the following conditions:

                by Attribution.
                --------------
                You must attribute the work in the manner specified by the author or licensor.

                sa
                --
                Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.

        * For any reuse or distribution, you must make clear to others the license terms of this work.
        * Any of these conditions can be waived if you get permission from the copyright holder.

        References:
        
        Wesnapr: http://www.websnapr.com
        Dustan Diaz: http://www.dustindiaz.com/sweet-titles-finalized
        Arc90: http://lab.arc90.com/2006/07/link_thumbnail.php
*/
var webSnapr = {
        x:0,
        y:0,
        obj:{},
        img:null,
        lnk:null,
        timer:null,
        opacityTimer:null,
        errorTimer:null,
        hidden:true,
        linkPool: {},
        baseURI: "./",
        imageCache: [],
        init: function() {
                var lnks = document.getElementsByTagName('a');
                var i = lnks.length || 0;
                var cnt = 0;
                while(i--) {
                        if(lnks[i].className && lnks[i].className.search(/websnapr/) != -1) {
                                webSnapr.addEvent(lnks[i], ["focus", "mouseover"], webSnapr.initThumb);
                                webSnapr.addEvent(lnks[i], ["blur",  "mouseout"],  webSnapr.hideThumb);
                                webSnapr.linkPool[lnks[i].href] = cnt++;
                        }
                }
                if(cnt) {
                        webSnapr.preloadImages();
                        webSnapr.obj = document.createElement('div');

                        webSnapr.ind = document.createElement('div');
                        webSnapr.ind.className= "imageLoaded";
                        webSnapr.img = document.createElement('img');
                        webSnapr.img.alt = "preview";
                        webSnapr.img.id = "fdImage";
                        webSnapr.addEvent(webSnapr.img, ["load"], webSnapr.imageLoaded);
                        webSnapr.addEvent(webSnapr.img, ["error"], webSnapr.imageError);
                        webSnapr.obj.id = "fdImageThumb";
                        webSnapr.obj.style.visibility = "hidden";
                        webSnapr.obj.style.top = "0";
                        webSnapr.obj.style.left = "0";
                        webSnapr.addEvent(webSnapr.img, ["mouseout"],  webSnapr.hideThumb);
                        webSnapr.obj.appendChild(webSnapr.ind);
                        webSnapr.obj.appendChild(webSnapr.img);
                        webSnapr.addEvent(webSnapr.obj, ["mouseout"], webSnapr.hideThumb);
                        document.getElementsByTagName('body')[0].appendChild(webSnapr.obj);
                }
        },
        preloadImages: function() {
                var imgList = ["lt.png", "lb.png", "rt.png", "rb.png", "error.gif", "loading.gif"];
                var imgObj  = document.createElement('img');

                for(var i = 0, img; img = imgList[i]; i++) {
                        webSnapr.imageCache[i] = imgObj.cloneNode(false);
                        webSnapr.imageCache[i].src = webSnapr.baseURI + img;
                }
        },
        imageLoaded: function() {
                if(webSnapr.errorTimer) clearTimeout(webSnapr.errorTimer);
                if(!webSnapr.hidden) webSnapr.img.style.visibility = "visible";
                webSnapr.ind.className= "imageLoaded";
                webSnapr.ind.style.visibility = "hidden";
        },
        imageError: function(e) {
                if(webSnapr.errorTimer) clearTimeout(webSnapr.errorTimer);
                webSnapr.ind.className= "imageError";
                webSnapr.errorTimer = window.setTimeout("webSnapr.hideThumb()",2000);
        },
        initThumb: function(e) {
                e = e || event;

                webSnapr.lnk       = this;
                var positionClass  = "left";

                var heightIndent;
                var indentX = 0;
                var indentY = 0;
                var trueBody = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;

                if(String(e.type).toLowerCase().search(/mouseover/) != -1) {
                        if (document.captureEvents) {
                                webSnapr.x = e.pageX;
                                webSnapr.y = e.pageY;
                        } else if ( window.event.clientX ) {
                                webSnapr.x = window.event.clientX+trueBody.scrollLeft;
                                webSnapr.y = window.event.clientY+trueBody.scrollTop;
                        }
                        indentX = 10;
                        heightIndent = parseInt(webSnapr.y-(webSnapr.obj.offsetHeight))+'px';
                } else {
                        var obj = this;
                        var curleft = curtop = 0;
                        if (obj.offsetParent) {
                                curleft = obj.offsetLeft;
                                curtop = obj.offsetTop;
                                while (obj = obj.offsetParent) {
                                        curleft += obj.offsetLeft;
                                        curtop += obj.offsetTop;
                                }
                        }
                        curtop += this.offsetHeight;

                        webSnapr.x = curleft;
                        webSnapr.y = curtop;

                        heightIndent = parseInt(webSnapr.y-(webSnapr.obj.offsetHeight)-this.offsetHeight)+'px';
                }
                
                if ( parseInt(trueBody.clientWidth+trueBody.scrollLeft) < parseInt(webSnapr.obj.offsetWidth+webSnapr.x) + indentX) {
                        webSnapr.obj.style.left = parseInt(webSnapr.x-(webSnapr.obj.offsetWidth+indentX))+'px';
                        positionClass = "right";
                } else {
                        webSnapr.obj.style.left = (webSnapr.x+indentX)+'px';
                }
                if ( parseInt(trueBody.clientHeight+trueBody.scrollTop) < parseInt(webSnapr.obj.offsetHeight+webSnapr.y) + indentY ) {
                        webSnapr.obj.style.top = heightIndent;
                        positionClass += "Top";
                } else {
                        webSnapr.obj.style.top = (webSnapr.y + indentY)+'px';
                        positionClass += "Bottom";
                }

                webSnapr.obj.className = positionClass;
                webSnapr.timer = window.setTimeout("webSnapr.showThumb()",500);
        },
        showThumb: function(e) {
                webSnapr.hidden = false;
                webSnapr.obj.style.visibility = webSnapr.ind.style.visibility = 'visible';
                webSnapr.obj.style.opacity = webSnapr.ind.style.opacity = '0';
                webSnapr.img.style.visibility = "hidden";
                
                var addy = String(webSnapr.lnk.href);

                webSnapr.errorTimer = window.setTimeout("webSnapr.imageError()",15000);                
                webSnapr.img.src = 'http://images.websnapr.com/?url='+ encodeURIComponent(addy); // +'&rndm='+parseInt(webSnapr.linkPool[webSnapr.lnk.href]);                
                
                /*@cc_on@*/
                /*@if(@_win32)
                return;
                /*@end@*/
                
                webSnapr.fade(10);
        },
        hideThumb: function(e) {
                // Don't mouseout if over the bubble
                e = e || window.event;

                // Check if mouse(over|out) are still within the same parent element
                if(e.type == "mouseout") {
                        var elem = e.relatedTarget || e.toElement;
                        if(elem.id && elem.id.search("fdImage") != -1) return false;
                }

                webSnapr.hidden = true;
                if(webSnapr.timer) clearTimeout(webSnapr.timer);
                if(webSnapr.errorTimer) clearTimeout(webSnapr.errorTimer);
                if(webSnapr.opacityTimer) clearTimeout(webSnapr.opacityTimer);
                webSnapr.obj.style.visibility = 'hidden';
                webSnapr.ind.style.visibility = 'hidden';
                webSnapr.img.style.visibility = 'hidden';
                webSnapr.ind.className= "imageLoaded";
        },
        fade: function(opac) {
                var passed  = parseInt(opac);
                var newOpac = parseInt(passed+10);
                if ( newOpac < 90 ) {
                        webSnapr.obj.style.opacity = webSnapr.ind.style.opacity = '.'+newOpac;
                        webSnapr.opacityTimer = window.setTimeout("webSnapr.fade('"+newOpac+"')",20);
                } else {
                        webSnapr.obj.style.opacity = webSnapr.ind.style.opacity = '1';
                }
        },
        addEvent: function( obj, types, fn ) {
                var type;
                for(var i = 0; i < types.length; i++) {
                        type = types[i];
                        if ( obj.attachEvent ) {
                                obj['e'+type+fn] = fn;
                                obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
                                obj.attachEvent( 'on'+type, obj[type+fn] );
                        } else obj.addEventListener( type, fn, false );
                }
        }
}

webSnapr.addEvent(window, ['load'], webSnapr.init);
