//////////////////////////////     ==== COPYWRITE NOTICE ====
//////////////////////////////     All coding, text, and graphics contained in this web site
//////////////////////////////     is copyright (c) 2002 by Jeff Rouyer - All Rights Reserved.
//////////////////////////////     No duplication, gleaning, or other forms of copying is allowed
//////////////////////////////     without the expressed written permission from Jeff Rouyer
//////////////////////////////        web:   www.rouyerdesign.com
//////////////////////////////        email: jrouyer@rouyerdesign.com
//////////////////////////////                                                 (Thank You!)

//////////////////////////////
//////////////////////////////    1. BROWSER SNIFFER
//////////////////////////////

function Is() {
  agent       = navigator.userAgent.toLowerCase();
  this.major  = parseInt(navigator.appVersion);
  this.minor  = parseFloat(navigator.appVersion);

  this.ns     = ((agent.indexOf('mozilla')   != -1) &&
                (agent.indexOf('spoofer')    == -1) &&
                (agent.indexOf('compatible') == -1) &&
                (agent.indexOf('opera')      == -1) &&
                (agent.indexOf('webtv')      == -1) &&
                (agent.indexOf('hotjava')    == -1));

  this.ns2    = (this.ns && (this.major      ==  2));
  this.ns3    = (this.ns && (this.major      ==  3));
  this.ns4    = (this.ns && (this.major      ==  4));
  this.ns6    = (this.ns && (this.major      >=  5));

  this.ie     = ((agent.indexOf("msie")      != -1) &&
                (agent.indexOf("opera")      == -1));

  this.ie3    = (this.ie && (this.major      <   4));

  this.ie4    = (this.ie && (this.major      ==  4) &&
                (agent.indexOf("msie 4")     != -1));

  this.ie5    = (this.ie && (this.major      ==  4) &&
                (agent.indexOf("msie 5.")    != -1) &&
                (agent.indexOf("msie 5.5")   == -1) &&
                (agent.indexOf("mac")        == -1));

  this.iem5   = (this.ie && (this.major      ==  4) &&
                (agent.indexOf("msie 5.")    != -1) &&
                (agent.indexOf("mac")        != -1));

  this.ie55   = (this.ie && (this.major      ==  4) &&
                (agent.indexOf("msie 5.5")   != -1));

  this.ie6    = (this.ie && (this.major      ==  4) &&
                (agent.indexOf("msie 6.")    != -1) ||
                (agent.indexOf("msie 7.")    != -1));
                              
  this.nsdom  = (this.ns4 || this.ns6);
  this.ie5dom = (this.ie5 || this.iem5   || this.ie55);
  this.iedom  = (this.ie4 || this.ie5dom || this.ie6);
  this.w3dom  = (this.ns6 || this.ie6);
  this.flash6 = (this.ns6 && getPlugin("r65"));
  this.plugin = (this.flash6 || this.ns4 || this.ie5 || this.ie55 || this.ie6)
}

var is = new Is();

//////////////////////////////
//////////////////////////////    2. OBJECT DEFINITIONS
//////////////////////////////

function objectSetup() {
  if(is.iedom || is.nsdom) {
    page               = new Object();
    page.width         = (is.nsdom) ? innerWidth  : document.body.clientWidth;
    page.height        = (is.nsdom) ? innerHeight : document.body.clientHeight;

    menuArray          = new Array();
    menuArray[0]       = {top: 0, right: 80, bottom:21, left:  0, posx:0 -   0, posy:null};
    menuArray[1]       = {top: 0, right:208, bottom:21, left: 80, posx:0 -  80, posy:null};
    menuArray[2]       = {top: 0, right:288, bottom:21, left:208, posx:0 - 208, posy:null};
    menuArray[3]       = {top: 0, right:416, bottom:21, left:288, posx:0 - 288, posy:null};
    menuArray[4]       = {top: 0, right:496, bottom:21, left:416, posx:0 - 416, posy:null};
    menuArray[5]       = {top: 0, right:624, bottom:21, left:496, posx:0 - 496, posy:null};
    menuArray[6]       = {top: 0, right:704, bottom:21, left:624, posx:0 - 624, posy:null};
    menuArray[7]       = {top: 0, right:832, bottom:21, left:704, posx:0 - 704, posy:null};

    cdarmArray         = new Array();
    cdarmArray[0]      = {top:0, right:139, bottom:105, left:  0, posx:-   0, posy:null};
    cdarmArray[1]      = {top:0, right:317, bottom:139, left:139, posx:- 139, posy:null};
    cdarmArray[2]      = {top:0, right:510, bottom:317, left:317, posx:- 317, posy:null};
    cdarmArray[3]      = {top:0, right:732, bottom:510, left:510, posx:- 510, posy:null};
    cdarmArray[4]      = {top:0, right:954, bottom:732, left:732, posx:- 732, posy:null};

    titleArray         = new Array();
    titleArray[0]      = {top:284, right:454, bottom:379, left:0, posx:null, posy: 20};
    titleArray[1]      = {top:189, right:454, bottom:284, left:0, posx:null, posy:115};
    titleArray[2]      = {top: 94, right:454, bottom:189, left:0, posx:null, posy:210};
    titleArray[3]      = {top:  0, right:454, bottom: 94, left:0, posx:null, posy:305};

    handArray          = new Array();
    handArray[0]       = {top: 60, left:31};
    handArray[1]       = {top: 86, left:36};
    handArray[2]       = {top:118, left:32};
    handArray[3]       = {top:146, left:26};

    fingerArray        = new Array();
    fingerArray[0]     = {top:0, right: 67, bottom:56, left:  0, posx:28 -   0, posy:0};
    fingerArray[1]     = {top:0, right:134, bottom:56, left: 67, posx:28 -  67, posy:0};
    fingerArray[2]     = {top:0, right:201, bottom:56, left:134, posx:28 - 134, posy:0};
    fingerArray[3]     = {top:0, right:268, bottom:56, left:201, posx:28 - 201, posy:0};

    arrowArray         = new Array();
    arrowArray[0]      = {top: 0, right: 75, bottom: 60, left:  0, posx:564 -   0, posy:null};
    arrowArray[1]      = {top: 0, right:150, bottom: 60, left: 75, posx:564 -  75, posy:null};
    arrowArray[2]      = {top: 0, right:225, bottom: 60, left:150, posx:564 - 150, posy:null};
    arrowArray[3]      = {top:60, right: 75, bottom:120, left:  0, posx:564 -   0, posy:null};
    arrowArray[4]      = {top:60, right:150, bottom:120, left: 75, posx:564 -  75, posy:null};
    arrowArray[5]      = {top:60, right:225, bottom:120, left:150, posx:564 - 150, posy:null};

    root               = new layerSetup(null,"rootLYR",0,0,page.width,page.height,1,"visible");

    audioPLYR          = new layerSetup(null,"audioLYR",20,20,100,100,2,"hidden");
    audioPLYR.plugin   = new pluginSetup(audioPLYR,"audio");

    viewport           = new layerSetup(null,"viewportLYR",(page.width-693)/2,(page.height-399)/2,693,399,6,"visible");

    topedge            = new layerSetup(null,"topLYR",0,0,page.width,parseInt(viewport.top)+19,2,"visible");

    corner             = new layerSetup(topedge,"cornerLYR",0,0,264,120,3,"visible");

    bottomedge         = new layerSetup(null,"bottomLYR",0,parseInt(viewport.top)+354,page.width,page.height-(parseInt(viewport.top)+354),4,"visible");

    background         = new layerSetup(null,"backgroundLYR",0,((page.height-399)/2)+18,page.width,336,5,"visible");

    base               = new layerSetup(viewport,"baseLYR",0,314,693,85,7,"visible");

    submenu            = new layerSetup(viewport,"submenuLYR",-380,-2,420,18,8,"hidden");
    submenu.dataArray1 = new arraySetup("linear",-380,500,0,0,20);
    submenu.dataArray2 = new arraySetup("linear",20,100,0,0,35);
    submenu.animation  = new animationSetup(submenu.dataArray1,"left",null,"submenu.animator()",null,null,"submenu.zIndex=24",40,0);
    submenu.animator   = arrayAnimator;

    webpages           = new layerSetup(submenu,"webpagesLYR",0,0,90,18,9,"hidden");
    multimedia         = new layerSetup(submenu,"multimediaLYR",100,0,85,18,10,"hidden");
    printmedia         = new layerSetup(submenu,"printmediaLYR",195,0,85,18,11,"hidden");
    publications       = new layerSetup(submenu,"publicationsLYR",290,0,120,18,12,"hidden");
    pdf                = new layerSetup(submenu,"pdfLYR",0,0,160,18,13,"hidden");
    acrobat            = new layerSetup(submenu,"acrobatLYR",165,0,90,18,14,"hidden");

    spinner            = new layerSetup(viewport,"spinnerLYR",450,236,245,77,15,"visible");
    spinner.dataArray  = new arraySetup("linear",236,-146,0,0,20);
    spinner.animation  = new animationSetup(spinner.dataArray,"top",null,"spinner.animator()",null,null,null,40,2);
    spinner.animator   = arrayAnimator;

    mask               = new layerSetup(viewport,"maskLYR",448,86,245,228,16,"visible");

    info1              = new layerSetup(viewport,"info1LYR",100,20,null,null,17,"visible");
    info1.dataArray    = new arraySetup("linear",-100,200,0,0,20);
    info1.animation    = new animationSetup(info1.dataArray,"left",null,"info1.animator()",null,null,null,40,0);
    info1.animator     = arrayAnimator;

    hand               = new layerSetup(viewport,"handLYR",4,62,100,184,18,"hidden");

    handbase           = new layerSetup(hand,"handbaseLYR",0,0,100,184,19,"hidden");

    finger             = new layerSetup(hand,"fingerLYR",28,0,67,56,20,"hidden");
    finger.dataArray   = fingerArray;
    finger.animation   = new animationSetup(finger.dataArray,"clip",null,"finger.animator()",null,null,null,60,1);
    finger.animator    = arrayAnimator;
                         clipAnimator(finger,fingerArray[0]);

    shade              = new layerSetup(viewport,"shadeLYR",0,0,182,399,21,"visible");

    info2              = new layerSetup(viewport,"info2LYR",345,140,210,170,22,"hidden");

    display            = new layerSetup(viewport,"displayLYR",130,20,440,340,23,"visible");

    content            = new layerSetup(display,"contentLYR",0,340,440,null,24,"visible");
    content.dataArray1 = new arraySetup("linear",340,-340,0,0,20);
    content.animation1 = new animationSetup(content.dataArray1,"top",null,"content.animator1(1);content.animator2(2)",null,null,null,40,0);
    content.animator1  = arrayAnimator;
    content.dataArray2 = new arraySetup("clip",0,0,0,440,4000,4000,0,0,20);
    content.animation2 = new animationSetup(content.dataArray2,"clip",null,"content.animator2(2)",null,null,null,40,0);
    content.animator2  = arrayAnimator;

    mainmenu           = new layerSetup(viewport,"mainmenuLYR",0,62,128,105,25,"hidden");

    welcome            = new layerSetup(mainmenu,"welcomeLYR",0,0,128,21,26,"hidden");
                         clipAnimator(welcome,menuArray[0]);

    portfolio          = new layerSetup(mainmenu,"portfolioLYR",0,28,128,21,27,"hidden");
                         clipAnimator(portfolio,menuArray[2]);

    resume             = new layerSetup(mainmenu,"resumeLYR",0,56,128,21,28,"hidden");
                         clipAnimator(resume,menuArray[4]);

    contact            = new layerSetup(mainmenu,"contactLYR",0,84,128,21,29,"hidden");
                         clipAnimator(contact,menuArray[6]);

    title              = new layerSetup(viewport,"titleLYR",183,20,454,379,30,"hidden");
                         clipAnimator(title,titleArray[0]);

    cdArray            = new Array();
    cdArray[0]         = {top:0, right:218, bottom:55, left: 90, posx:(parseInt(viewport.left)-11) -  90, posy:null};
    cdArray[1]         = {top:0, right:346, bottom:55, left:218, posx:(parseInt(viewport.left)-11) - 218, posy:null};

    cdposArray         = new Array();
    cdposArray[0]      = {attribute_1:((page.width-695)/2-11)   - 230, attribute_2:parseInt(viewport.top)+309};
    cdposArray[1]      = {attribute_1:((page.width-695)/2-11)   - 164, attribute_2:parseInt(viewport.top)+282};
    cdposArray[2]      = {attribute_1:((page.width-695)/2-11)   - 120, attribute_2:parseInt(viewport.top)+278};
    cdposArray[3]      = {attribute_1:(((page.width-695)/2)-11) -  90, attribute_2:parseInt(viewport.top)+284};
    cdposArray[4]      = {attribute_1:(((page.width-695)/2)-11) -  90, attribute_2:parseInt(viewport.top)+290};

    cd                 = new layerSetup(null,"cdLYR",(parseInt(viewport.left)-241),parseInt(viewport.top)+308,218,95,31,"hidden");
    cd.dataArray1      = cdposArray;
    cd.animation1      = new animationSetup(cd.dataArray1,"left","top","cd.animator1(1)",null,null,null,140,0);
    cd.animator1       = arrayAnimator;
    cd.dataArray2      = cdArray;
    cd.animation2      = new animationSetup(cd.dataArray2,"clip",null,"cd.animator2(2)",null,null,null,50,20);
    cd.animator2       = arrayAnimator;

    cdviewport         = new layerSetup(null,"cdviewportLYR",((page.width-695)/2-161),parseInt(viewport.top)+296,222,105,32,"visible");

    cdarm              = new layerSetup(cdviewport,"cdarmLYR",0,0,954,105,33,"hidden");
    cdarm.dataArray    = cdarmArray;
    cdarm.animation    = new animationSetup(cdarm.dataArray,"clip",null,"cdarm.animator()",null,null,null,140,0);
    cdarm.animator     = arrayAnimator;
                         clipAnimator(cdarm,cdarmArray[0]);

    scroller           = new layerSetup(viewport,"scrollerLYR",529,0,117,399,34,"visible");

    uparrow            = new layerSetup(viewport,"uparrowLYR",564,18,75,60,35,"visible");

    dnarrow            = new layerSetup(viewport,"dnarrowLYR",564,153,75,120,36,"visible");

    base.image         = new imageSetup(base,"baseIMG","images/base.jpg");
    mask.image         = new imageSetup(mask,"maskIMG","images/mask_8rgb.gif");
    spinner.image      = new imageSetup(spinner,"spinnerIMG","images/spinner_8rgb.gif");
    handbase.image     = new imageSetup(handbase,"handbaseIMG","images/hand_8rgb.gif");
    finger.image       = new imageSetup(finger,"fingerIMG","images/finger_8rgb.gif");
    shade.image        = new imageSetup(shade,"shadeIMG","images/shade_");
    welcome.image      = new imageSetup(welcome,"welcomeIMG","images/menu_8rgb.gif");
    portfolio.image    = new imageSetup(portfolio,"portfolioIMG","images/menu_8rgb.gif");
    resume.image       = new imageSetup(resume,"resumeIMG","images/menu_8rgb.gif");
    contact.image      = new imageSetup(contact,"contactIMG","images/menu_8rgb.gif");
    title.image        = new imageSetup(title,"titleIMG","images/title_8rgb.gif");
    cd.image           = new imageSetup(cd,"cdIMG","images/spindle_8rgb.gif");
    cdarm.image        = new imageSetup(cdarm,"cdarmIMG","images/cdarm_8rgb.gif");
    scroller.image     = new imageSetup(scroller,"scrollerIMG","images/scroller_");
    uparrow.image      = new imageSetup(uparrow,"uparrowIMG","images/arrows_");
    dnarrow.image      = new imageSetup(dnarrow,"dnarrowIMG","images/arrows_");

    image_count        = (!is.ns4) ? 16 : 13;

  } else {
    document.write('<html><body background="images/background.jpg"><center><br><br><br><table width="320"><tr><td><font size="4" face="arial,helvetica,sans-serif">Web Browser Support</font></td></tr><tr><td><img src="images/home_screen.jpg" width="320" height="208"></td></tr><tr><td><font size="1" face="arial,helvetica,sans-serif">Sorry but this page cannot be displayed in your browser. This site uses the full feature set of Dynamic HTML as supported and tested in the following browsers and operating systems:<br><br>Windows 9x/NT/ME/2K/XP and Macintosh OS 9.x/10.x<ul><li><a href="www.netscape.com">Netscape</a> 4.x ~ 6.x and <a href="www.mozilla.org">Mozilla</a> 0.9x<li><a href="www.microsoft.com/ie">Internet Explorer</a> 4.x ~ 5.x ~ 6.x</ul>RE: Opera - Although Opera is applauded for supporting standards based initiatives, it however doesn\'t yet support important core Dynamic HTML methods. Full Support for this browser will occur automatically when a broader set of DHTML methods are implemented. </font></td></tr></table></center></body></html>')
  }
}

//////////////////////////////
//////////////////////////////    3. SETUP FUNCTIONS
//////////////////////////////

function getPlugin(version) {
	if(navigator.plugins) {
  	navigator.plugins.refresh();
    for(var i = 0; i < navigator.plugins.length; i++) {
			if(navigator.plugins[i].description.indexOf(version) != -1) {
      	return true;
	    }
    }
  }
}

function getObject(type,parent,id) {
  if(type == "layer") {
    if(is.ns4) {
      if(id != "rootLYR") {
        this.obj     = (parent == null) ? document["rootLYR"].document[id] : parent.document[id];
        this.obj.htm = (parent == null) ? document["rootLYR"].document[id].document : parent.document[id].document;
      } else {
        this.obj     = document[id];
      }
    } else if(is.iedom && !is.ie6) {
      this.obj       = document.all[id].style;
      this.obj.htm   = document.all[id];
    } else if(is.iem5 || is.ns6 || is.ie6) {
      this.obj       = document.getElementById(id).style;
      this.obj.htm   = document.getElementById(id);
    }
  } else if(type == "image") {
    if(is.ns4) {
      this.obj       = parent.document[id];
    } else if(is.ie4 || is.ie5 || is.ie55) {
      this.obj       = document[id];
    } else if(is.iem5 || is.ns6 || is.ie6) {
      this.obj       = document.getElementById(id);
    }
    this.obj.parent  = parent;
  }
  return this.obj;
}

function layerSetup(parent,id,left,top,width,height,zindex,visibility) {
  this.obj                 = new getObject("layer",parent,id);
  this.obj.left            = left;
  this.obj.top             = top;
  if(width != null) {
   if(is.ns4) {
      this.obj.clip.right  = width;
    } else {
      this.obj.width       = Math.abs(width);
    }
  }
  if(height != null) {
   if(is.ns4) {
      this.obj.clip.bottom = height;
    } else {
      this.obj.height      = Math.abs(height);
    }
  }
  this.obj.zIndex          = zindex;
  this.obj.visibility      = visibility;
  return this.obj;
}

var image_count = 0;

function imageSetup(parent,id,url) {
  this.obj           = new Image();
  this.obj.onload    = loadManager;
  if(url) {
    if(url.indexOf('.jpg') != -1 || url.indexOf('.gif') != -1) {
      this.obj.src   = url;
    } else {
      this.obj.src   = (is.ns6 || is.iem5) ? url + "8rgba.png" :  url + "8rgb.gif";
    }
    var imageObj     = new getObject("image",parent,id);
        imageObj.src = this.obj.src;
  }
   // this.obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + '32rgba.png' + "',sizing='image')";

  return this.obj;
}

function pluginSetup(parent,id) {
  var pluginObj = false;
  if(!is.iem5) {
    if(is.ie5 || is.ie55 || is.ie6) {
      pluginObj = document.getElementById(id);
    } else if(is.ie4) {
      pluginObj = document.all[id];
    } else if(is.ns4 || is.ns6) {
      pluginObj = (is.ns4) ? parent.document.embeds[id] : document.embeds[id];
    }
    return pluginObj;
  }
}

function animationSetup(data,attribute_1,attribute_2,animator,command_1,command_2,command_3,delay,cycle) {
  this.index       = 0;
  this.interval    = null;
  this.dataArray   = data;
  this.property_1  = attribute_1;
  this.property_2  = attribute_2;
  this.animator    = animator;
  this.command_1   = command_1;
  this.command_2   = command_2;
  this.command_3   = command_3;
  this.delay       = delay;
  this.cycle       = cycle;
  this.loop        = cycle;
  this.start       = startAnimation;
  this.stop        = stopAnimation;
  this.state       = true;
  this.status      = null;
  function startAnimation() {
    clearInterval(this.interval);
    this.interval = setInterval(this.animator,this.delay);
  }
  function stopAnimation() {
    clearInterval(this.interval);
  }
  return this;
}

function arraySetup() {
  var args = arraySetup.arguments;
  var dataArray = new Array();
  switch(args[0]) {
    case "clip" :
      var value_1 = args[1];
      var value_2 = args[3];
      var value_3 = args[5];
      var value_4 = args[7];
      for(var i = 0; i <= args[9]-1; i++) {
        value_1 += Math.round(args[2]/args[9]);
        value_2 += Math.round(args[4]/args[9]);
        value_3 += Math.round(args[6]/args[9]);
        value_4 += Math.round(args[8]/args[9]);
        dataArray[i] = {top:value_1,right:value_2,bottom:value_3,left:value_4};
      }
    break;
    case "linear" :
      var value_1 = args[1];
      var value_2 = args[3];
      for(var i = 0; i <= args[5]-1; i++) {
        value_1 += Math.round(args[2]/args[5]);
        value_2 += Math.round(args[4]/args[5]);
        dataArray[i] = {attribute_1:value_1,attribute_2:value_2};
      }
    break;
    case "circular" :
      var increment = (args[2] - args[1])/args[7];
      for(var i = 0; i <= args[7]-1; i++) {
        args[1] += increment;
        var value_1 = Math.round(args[3] + args[5] * Math.cos(args[1]*(Math.PI/180)));
        var value_2 = Math.round(args[4] + args[6] * Math.sin(args[1]*(Math.PI/180)));
        dataArray[i] = {attribute_1:value_1,attribute_2:value_2};
      }
    break;
  }
  return dataArray;
}

function eventSetup() {
  var args     = eventSetup.arguments;
  var eventObj = args[args.length-1];
  for(i = 0; i <= args.length-2; i++) {
    if(is.ns4) {
      eventObj.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT | Event.MOUSEUP | Event.MOUSEDOWN | Event.MOUSEMOVE)
      eventObj["on" + args[i]] = eventManager;
    }
    if(is.ie4 || is.ie5 || is.iem5) {
      eventObj.htm["on" + args[i]] = eventManager;
    }
    if(is.ie55 || is.ie6) {
      eventObj.htm.attachEvent("on" + args[i],eventManager);
    }
    if(is.ns6) {
      eventObj.htm.addEventListener(args[i],eventManager,false);
    }
  }
}

//////////////////////////////
//////////////////////////////    4. ANIMATOR FUNCTIONS
//////////////////////////////

function arrayAnimator(sequence) {
  var animation = (sequence) ? eval("this.animation" + sequence) : this.animation;
  if(animation.index <= animation.dataArray.length-1) {
    if(animation.property_1 == "clip") {
      clipAnimator(this,animation.dataArray[animation.index]);
    } else if(animation.property_1 == "opacity") {
      opacityAnimator(this,animation.dataArray[animation.index].attribute_1);
    } else {
      this[animation.property_1] = animation.dataArray[animation.index].attribute_1;
    }
    if(animation.property_2) {
      this[animation.property_2] = animation.dataArray[animation.index].attribute_2;
    }
    if(animation.command_1) {
      eval(animation.command_1);
    }
    animation.index++;
  } else {
    if(animation.loop == -1) {
      if(animation.command_2) {
        eval(animation.command_2);
      }
      animation.index = 0;
    } else if(animation.loop > 0) {
      if(animation.command_2) {
        eval(animation.command_2);
      }
      animation.index = 0;
      animation.loop--;
    } else {
      clearInterval(animation.interval);
      if(animation.command_3) {
        eval(animation.command_3);
      }
      animation.index = 0;
      animation.loop  = animation.cycle;
    }
  }
}

function clipAnimator(obj,cliparray) {
  if(cliparray.posx != null) {
    obj.left           = cliparray.posx;
  }
  if(cliparray.posy != null) {
    obj.top            = cliparray.posy;
  }
  if(is.ns4) {
    obj.clip.top       = cliparray.top;
    obj.clip.right     = cliparray.right;
    obj.clip.bottom    = cliparray.bottom;
    obj.clip.left      = cliparray.left;
  } else if(is.ns6 || is.iedom) {
    obj.clip = "rect(" + cliparray.top    + "px "
                       + cliparray.right  + "px "
                       + cliparray.bottom + "px "
                       + cliparray.left   + "px)";
  }
}

function opacityAnimator(obj,opacity) {
  if(is.ie5dom || is.ie6) {
    obj.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ",style=0)";
  } else if(is.ns6) {
    obj.MozOpacity = opacity/100;
  }
}

function textAnimator(obj,value,size,color,weight) {
  this.obj               = obj;
  this.obj.fontSize      = size;
  this.obj.color         = color;
  this.obj.fontWeight    = weight;
}

//////////////////////////////
//////////////////////////////    5. IMAGE PRELOAD MANAGER
//////////////////////////////

var onload_count  = 0;
var toggle        = true;
var startup_timer = null;

function loadManager() {
  onload_count++;
  var percent  = (onload_count/image_count)*100;
  var status   = "Loading...";
  if(onload_count >= image_count) {
    status = "All Done!";
  }
  var msg = '<font class="header1">' + status + '</font><br><table border="0" cellpadding="0" cellspacing="0" width="200" height="10"><tr><td bgcolor="#74d5fc" width=' + Math.round(percent) + '%  align="right"><font class="loadmsg">' + Math.round(percent) + '% </font></td><td><font class="info">&nbsp;</font></td></tr></table>';
  if(is.plugin) {
    if(audioPLYR.plugin.PercentLoaded() >= 50) {
      if(toggle) {
        audioManager("loop");
      }
      toggle = false;
    }
  }
  if(onload_count <= image_count) {
    pageManager("display_info",info1,msg);
  }
  if(onload_count >= image_count) {
    startup_timer = setTimeout("actionManager('start_up')",2000);
  }
}

//////////////////////////////
//////////////////////////////    6. ACTION MANAGER
//////////////////////////////

var menu_timer      = null;
var page_timer      = null;
var cd_state        = false;
var selected_menu = "welcomeLYR";

function actionManager(action) {
  var args = actionManager.arguments;
  switch(args[0]) {
    case "start_up" :
      eventSetup("mouseover","mouseout","mousedown","mousemove",welcome);
      eventSetup("mouseover","mouseout","mousedown","mousemove",portfolio);
      eventSetup("mouseover","mouseout","mousedown","mousemove",resume);
      eventSetup("mouseover","mouseout","mousedown","mousemove",contact);
      eventSetup("mouseover","mouseout",webpages);
      eventSetup("mouseover","mouseout",multimedia);
      eventSetup("mouseover","mouseout",printmedia);
      eventSetup("mouseover","mouseout",publications);
      eventSetup("mouseover","mouseout",pdf);
      eventSetup("mouseover","mouseout",acrobat);
      eventSetup("mouseover","mouseout","mousedown","mouseup",uparrow);
      eventSetup("mouseover","mouseout","mousedown","mouseup",dnarrow);
      submenu.visibility   = "visible";
      hand.visibility      = "visible";
      handbase.visibility  = "visible";
      finger.visibility    = "visible";
      mainmenu.visibility  = "visible";
      welcome.visibility   = "visible";
      portfolio.visibility = "visible";
      resume.visibility    = "visible";
      contact.visibility   = "visible";
      title.visibility     = "visible";
      dnarrow.visibility   = "visible";
      uparrow.visibility   = "visible";
      setTimeout("audioManager('allstop');actionManager('menu_select','welcomeLYR')",1000);
    break;

    case "view_menu" :
      clipAnimator(finger,fingerArray[0]);
      audioManager('over');
      switch(args[1]) {
        case "welcomeLYR" :
          window.status='HELLO';
          clearTimeout(menu_timer);
          clipAnimator(welcome,menuArray[1]);
          actionManager('point_to',0);
        break;
        case "portfolioLYR" :
          clearTimeout(menu_timer);
          clipAnimator(portfolio,menuArray[3]);
          actionManager('point_to',1)
        break;
        case "resumeLYR" :
          clearTimeout(menu_timer);
          clipAnimator(resume,menuArray[5]);
          actionManager('point_to',2)
        break;
        case "contactLYR" :
          clearTimeout(menu_timer);
          clipAnimator(contact,menuArray[7]);
          actionManager('point_to',3)
        break;
      }
    break;

    case "reset_menu" :
      switch(args[1]) {
        case "welcomeLYR" :
          clearTimeout(menu_timer);
          if(selected_menu != args[1]) {clipAnimator(welcome,menuArray[0])};
          menu_timer = setTimeout("actionManager('view_menu',selected_menu)",1200);
        break;
        case "portfolioLYR" :
          clearTimeout(menu_timer);
          if(selected_menu != args[1]) {clipAnimator(portfolio,menuArray[2])};
          menu_timer = setTimeout("actionManager('view_menu',selected_menu)",1200);
        break;
        case "resumeLYR" :
          clearTimeout(menu_timer);
          if(selected_menu != args[1]) {clipAnimator(resume,menuArray[4])};
          menu_timer = setTimeout("actionManager('view_menu',selected_menu)",1200);
        break;
        case "contactLYR" :
          clearTimeout(menu_timer);
          if(selected_menu != args[1]) {clipAnimator(contact,menuArray[6])};
          menu_timer = setTimeout("actionManager('view_menu',selected_menu)",1200);
        break;
      }
    break;

    case "menu_select" :
      clipAnimator(welcome,menuArray[0]);
      clipAnimator(portfolio,menuArray[2]);
      clipAnimator(resume,menuArray[4]);
      clipAnimator(contact,menuArray[6]);
      finger.animation.start();
      audioManager('down');
      switch(args[1]) {
        case "welcomeLYR" :
          submenu.left            = -400;
          clipAnimator(title,titleArray[0]);
          selected_menu = args[1];
          actionManager('point_to',0);
          actionManager('view_menu',args[1]);
          actionManager('animate_cdrom','grab');
          pageManager("display_info",info1,"<font class='header1'>Welcome</font>");
          info1.animation.start();
          clearTimeout(page_timer);
          page_timer = setTimeout("pageManager('load_page','content/welcome.html')",500);
        break;
        case "portfolioLYR" :
          submenu.zIndex          = 7;
          submenu.left            = -400;
          webpages.visibility     = "visible";
          multimedia.visibility   = "visible";
          printmedia.visibility   = "visible";
          publications.visibility = "visible";
          pdf.visibility          = "hidden";
          acrobat.visibility      = "hidden";
          submenu.animation.start();
          clipAnimator(title,titleArray[1]);
          selected_menu       = args[1];
          actionManager('point_to',1);
          actionManager("animate_cdrom","load");
          actionManager('view_menu',args[1]);
          pageManager("display_info",info1,"<font class='header1'>Web Pages</font>");
          info1.animation.start();
          clearTimeout(page_timer);
          page_timer = setTimeout("pageManager('load_page','content/webpages.html')",500);
        break;
        case "resumeLYR" :
          submenu.zIndex          = 7;
          submenu.left            = -400;
          webpages.visibility     = "hidden";
          multimedia.visibility   = "hidden";
          printmedia.visibility   = "hidden";
          publications.visibility = "hidden";
          pdf.visibility          = "visible";
          acrobat.visibility      = "visible";
          submenu.animation.start();
          clipAnimator(title,titleArray[0]);
          selected_menu      = args[1];
          actionManager('point_to',2);
          actionManager('view_menu',args[1]);
          actionManager('animate_cdrom','grab');
          pageManager("display_info",info1,"<font class='header1'>Resume</font>");
          info1.animation.start();
          clearTimeout(page_timer);
          page_timer = setTimeout("pageManager('load_page','content/resume.html')",500);
        break;
        case "contactLYR" :
          submenu.left            = -400;
          clipAnimator(title,titleArray[0]);
          selected_menu       = args[1];
          actionManager('point_to',3);
          actionManager('animate_cdrom','grab');
          actionManager('view_menu',args[1]);
          pageManager("display_info",info1,"<font class='header1'>Contact</font>");
          info1.animation.start();
          clearTimeout(page_timer);
          page_timer = setTimeout("pageManager('load_page','content/contact.html')",500);
        break;
        case "webpagesLYR" :
          clipAnimator(title,titleArray[1]);
          actionManager("view_menu","portfolioLYR");
          pageManager("display_info",info1,"<font class='header1'>Web Pages</font>");
          info1.animation.start();
          clearTimeout(page_timer);
          page_timer = setTimeout("pageManager('load_page','content/webpages.html')",500);
        break;
        case "multimediaLYR" :
          clipAnimator(title,titleArray[2]);
          actionManager("view_menu","portfolioLYR");
          pageManager("display_info",info1,"<font class='header1'>Multimedia</font>");
          info1.animation.start();
          page_timer = setTimeout("pageManager('load_page','content/multimedia.html')",500);
        break;
        case "printmediaLYR" :
          clipAnimator(title,titleArray[3]);
          actionManager("view_menu","portfolioLYR");
          pageManager("display_info",info1,"<font class='header1'>Print Media</font>");
          info1.animation.start();
          page_timer = setTimeout("pageManager('load_page','content/printmedia.html')",500);
        break;
        case "publicationsLYR" :
          clipAnimator(title,titleArray[3]);
          actionManager("view_menu","portfolioLYR");
          pageManager("display_info",info1,"<font class='header1'>Publications</font>");
          info1.animation.start();
          page_timer = setTimeout("pageManager('load_page','content/publications.html')",500);
        break;
        case "pdfLYR" :
          actionManager("view_menu","resumeLYR");
        break;
        case "acrobatLYR" :
          actionManager("view_menu","resumeLYR");
        break;
      }
    break;

    case "point_to" :
      hand.left = handArray[args[1]].left;
      hand.top  = handArray[args[1]].top;
    break;

    case "animate_cdrom" :
      switch(args[1]) {
        case "load" :
          if(!cd_state) {
            audioManager("cdarm");
            cd.visibility             = "visible";
            cdarm.visibility          = "visible";
            cd.animation1.dataArray1  = cd.dataArray1;
            cdarm.animation.dataArray = cdarm.dataArray;
            cdarm.animation.animator  = "cdarm.animator();cd.animator1(1)";
            cdarm.animation.command_3 = "audioManager('cdspin');actionManager('animate_cdrom','retract')";
            cdarm.animation.start();
          }
        break;
        case "retract" :
          audioManager("cdarm");
          cdarm.dataArray.reverse();
          cdarm.animation.animator  = "cdarm.animator()";
          cdarm.animation.command_3 = "cdarm.visibility='hidden';cdarm.dataArray.reverse();cd.animation2.start()";
          cdarm.animation.start();
          cd_state = true;
        break;
        case "grab" :
          if(cd_state) {
            audioManager("cdarm");
            cd.animation2.stop();
            clipAnimator(cd,cdArray[0]);
            cdarm.visibility          = "visible";
            cdarm.animation.animator  = "cdarm.animator()";
            cdarm.animation.command_3 = "actionManager('animate_cdrom','unload')";
            cdarm.animation.start();
          }
        break;
        case "unload" :
          audioManager("cdarm");
          cd.dataArray1.reverse();
          cdarm.dataArray.reverse();
          cdarm.animation.animator  = "cdarm.animator();cd.animator1(1)";
          cdarm.animation.command_3 = "cdarm.visibility='hidden';cd.visibility='hidden';cd.dataArray1.reverse();cdarm.dataArray.reverse()";
          cd_state = false;
          cdarm.animation.start();
        break;
      }
    break;

  }
}

//////////////////////////////
//////////////////////////////    7. PAGE MANAGER
//////////////////////////////

var scroll_timer    = null;
var content_height  = 1000;

function pageManager(action) {
  var args = pageManager.arguments;
  switch(args[0]) {
    case "load_page" :
      content.top        = 340;
      spinner.animation.start();
      if(is.ie4) {
        document.frames["frameData"].document.location = args[1];
      }
      if(is.ie5dom || is.ie6 || is.ns6) {
        document.getElementById("frameData").src = args[1];
      }
      if(is.ns4) {
        content.load(args[1],450);
      }
    break;

    case "page_is_loaded" :
      clearTimeout(page_timer);
      secondary_command  = args[1] || null;
      secondary_variable = args[2] || null;
      page_timer = setTimeout("pageManager('display_page',secondary_command,secondary_variable)",2000);
    break;

    case "display_page" :
      if(is.ie4) {
        content.htm.innerHTML = document.frames['frameData'].document.body.innerHTML;
      } else if(is.ie5dom || is.ie6 || is.ns6) {
        content.htm.innerHTML = window.frames.frameData.document.getElementById('body').innerHTML;
      }
      content.animation1.start();
      if(args[1]) {
        pageManager(args[1],args[2]);
      }
    break;

    case "display_info" :
      if(is.iedom || is.ns6) {
        args[1].htm.innerHTML = args[2];
      } else {
        args[1].document.write(args[2]);
        args[1].document.close();
      }
    break;

    case "display_popup" :
    	if(args[2]) {
	      var window_width  = args[2];
	      var window_height = args[3];
	    } else {
	      var window_width  = screen.width-100;
	      var window_height = screen.height-100;
	    }
      var window_top    = 10;
      var window_left   = (screen.width-window_width)/2;
      window.open(''+ args[1] + '','display','resizable=yes,menubar=yes,scrollbars=auto,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
    break;

    case "portfolio_setup" :
      imageArray = new Array();
      for(i = 1; i <= args[1]; i++) {
        imageArray[i]            = new getObject("image",content,"portfolio" + i + "IMG");
        imageArray[i].width      = 90;
        imageArray[i].height     = 90;

        imageArray[i].dataArray1 = new arraySetup("linear",90,90,90,90,45);
        imageArray[i].animation1 = new animationSetup(imageArray[i].dataArray1,"width","height","imageArray["+ i + "].animator1(1)",null,null,"imageArray["+ i + "].animation1.state=true",10,0);
        imageArray[i].animator1  = arrayAnimator;

        imageArray[i].dataArray2 = new arraySetup("linear",180,-90,180,-90,45);
        imageArray[i].animation2 = new animationSetup(imageArray[i].dataArray2,"width","height","imageArray["+ i + "].animator2(2)",null,null,"imageArray["+ i + "].animation1.state=true",10,0);
        imageArray[i].animator2  = arrayAnimator;
      }
      portfolio0    = new Object();
      portfolio0.id = "blah";
    break;

    case "zoom" :
     if(portfolio0.id != "blah") {
       if(portfolio0.id != imageArray[args[1]].id) {
         portfolio0.animation1.state = false;
         portfolio0.animation2.start();
       }
     }
     if(portfolio0.id != imageArray[args[1]].id) {
       imageArray[args[1]].animation1.state = false;
       imageArray[args[1]].animation1.start();
       portfolio0 = imageArray[args[1]];
     }
    break;

    case "scroll_page" :
      if(is.ns4) {
        content_height = content.htm.height;
      } else {
        content_height = content.htm.offsetHeight;
      }
      switch(args[1]) {
        case "up_slow" :
          clearInterval(scroll_timer);
          scroll_timer = setInterval("if(parseInt(content.top)>-(content_height-300)){content.top=(parseInt(content.top)-1);spinner.animator();}else{clearInterval(scroll_timer);}",40);
        break;
        case "up_fast" :
          clearInterval(scroll_timer);
          scroll_timer = setInterval("if(parseInt(content.top)>-(content_height-300)){content.top=(parseInt(content.top)-10);spinner.animator();}else{clearInterval(scroll_timer);}",20);
        break;
        case "dn_slow" :
          clearInterval(scroll_timer);
          scroll_timer = setInterval("if(parseInt(content.top)<0){content.top=(parseInt(content.top)+1);spinner.animator();}else{clearInterval(scroll_timer);}",40);
        break;
        case "dn_fast" :
          clearInterval(scroll_timer);
          scroll_timer = setInterval("if(parseInt(content.top)<0){content.top=(parseInt(content.top)+10);spinner.animator();}else{clearInterval(scroll_timer);}",20);
        break;
        case "return_top" :
          content.top = 0;
        break;
        case "all_stop" :
          clearInterval(scroll_timer);
        break;
      }
    break;
  }
}

//////////////////////////////
//////////////////////////////    8. EVENT MANAGER
//////////////////////////////

var elementID         = "";

function eventManager(e) {
  var evt     = (is.nsdom) ? e.type   : window.event.type;
  var target  = (is.nsdom) ? e.target : window.event.srcElement;
  var mouse_x = (is.nsdom) ? e.pageX  : window.event.clientX;
  var mouse_y = (is.nsdom) ? e.pageY  : window.event.clientY;
  switch(evt) {
    case "mousemove" :
      switch(elementID) {
        case "welcomeLYR" :
          hand.top  = mouse_y - parseInt(viewport.top) - 8;
          hand.left = handArray[0].left;
        break;
        case "portfolioLYR" :
          hand.top  = mouse_y - parseInt(viewport.top) - 8;
          hand.left = handArray[1].left;
        break;
        case "resumeLYR" :
          hand.top  = mouse_y - parseInt(viewport.top) - 8;
          hand.left = handArray[2].left;
        break;
        case "contactLYR" :
          hand.top  = mouse_y - parseInt(viewport.top) - 8;
          hand.left = handArray[3].left;
        break;
      }
    break;
    case "mouseover" :
      elementID  = (target.parent) ? target.parent.id || target.parent.htm.id : target.id;
      switch(elementID) {
        case "welcomeLYR" :
          actionManager("view_menu",elementID);
        break;
        case "portfolioLYR" :
          actionManager("view_menu",elementID);
        break;
        case "resumeLYR" :
          actionManager("view_menu",elementID);
        break;
        case "contactLYR" :
          actionManager("view_menu",elementID);
        break;
        case "uparrowLYR" :
          clipAnimator(uparrow,arrowArray[1]);
          pageManager("scroll_page","dn_slow");
        break;
        case "dnarrowLYR" :
          clipAnimator(dnarrow,arrowArray[4]);
          pageManager("scroll_page","up_slow");
        break;
      }
    break;
    case "mouseout" :
      switch(elementID) {
        case "welcomeLYR" :
          actionManager("reset_menu",elementID);
        break;
        case "portfolioLYR" :
          actionManager("reset_menu",elementID);
        break;
        case "resumeLYR" :
          actionManager("reset_menu",elementID);
        break;
        case "contactLYR" :
          actionManager("reset_menu",elementID);
        break;
        case "uparrowLYR" :
          clipAnimator(uparrow,arrowArray[0]);
          pageManager("scroll_page","all_stop");
        break;
        case "dnarrowLYR" :
          clipAnimator(dnarrow,arrowArray[3]);
          pageManager("scroll_page","all_stop");
        break;
      }
    break;
    case "mousedown" :
      switch(elementID) {
        case "welcomeLYR" :
          actionManager("menu_select",elementID);
        break;
        case "portfolioLYR" :
          actionManager('menu_select',elementID);
        break;
        case "resumeLYR" :
          actionManager("menu_select",elementID);
        break;
        case "contactLYR" :
          actionManager("menu_select",elementID);
        break;
        case "uparrowLYR" :
          clipAnimator(uparrow,arrowArray[2]);
          pageManager("scroll_page","dn_fast");
          return false;
        break;
        case "dnarrowLYR" :
          clipAnimator(dnarrow,arrowArray[5]);
          pageManager("scroll_page","up_fast");
          return false;
        break;
      }
    break;
    case "mouseup" :
      switch(elementID) {
        case "uparrowLYR" :
          clipAnimator(uparrow,arrowArray[1]);
          pageManager("scroll_page","dn_slow");
          return false;
        break;
        case "dnarrowLYR" :
          clipAnimator(dnarrow,arrowArray[4]);
          pageManager("scroll_page","up_slow");
          return false;
        break;
      }
    break;
  }
}

//////////////////////////////
//////////////////////////////    9. AUDIO MANAGER
//////////////////////////////

function audioManager(command) {
  if(is.plugin) {
    switch(command) {
      case "loop" :
        audioPLYR.plugin.GotoFrame(1);
        audioPLYR.plugin.Play();
        audioPLYR.plugin.GotoFrame(0);
      break;
      case "over" :
        audioPLYR.plugin.GotoFrame(2);
        audioPLYR.plugin.Play();
        audioPLYR.plugin.GotoFrame(0);
      break;
      case "down" :
        audioPLYR.plugin.GotoFrame(3);
        audioPLYR.plugin.Play();
        audioPLYR.plugin.GotoFrame(0);
      break;
      case "cdspin" :
        audioPLYR.plugin.GotoFrame(4);
        audioPLYR.plugin.Play();
        audioPLYR.plugin.GotoFrame(0);
      break;
      case "cdarm" :
        audioPLYR.plugin.GotoFrame(5);
        audioPLYR.plugin.Play();
        audioPLYR.plugin.GotoFrame(0);
      break;
      case "allstop" :
        audioPLYR.plugin.GotoFrame(6);
        audioPLYR.plugin.Play();
        audioPLYR.plugin.GotoFrame(0);
      break;
    }
  }
}

