// Some globals
var atsign = "&#64;";
var address = "contact"+atsign+"jamesburns"+"design.com";

// make an array of imagenames in Illustration

var illoPre="images/illustrative/";
var illo = new Array(
"airport.jpg","lois.jpg","carseat.jpg","shrink.jpg","JPBhead.jpg","angryGirl.jpg","volleyball.jpg","girlRobot.jpg","group.jpg","ludacris.jpg","rpb.jpg","carseat.jpg","bush.jpg","Shirley.jpg","ti.jpg","rpb2005.jpg","shoes.jpg","toro.jpg","train.jpg","BRB.jpg","tennis.jpg","car.jpg","heads.jpg","pssst.jpg","figure.jpg","barrett.jpg","crimeComic.jpg","PhoenixFollies.jpg","cab.jpg","atlas.jpg","yoga.jpg","barGirl.jpg","towelGirl.jpg","polkaDotGirl.jpg","Babuska.jpg","stripper.jpg","Kirby.jpg","BRBolder.jpg","ashen.jpg","nightmare.jpg","zaftig.jpg","chainsaw-guy.jpg","billHeads.jpg","icons.jpg","Bill.jpg","JeepEbay.jpg","ladyAtlas.jpg","toughGirls.jpg"
);

// make new array from names of image files
var bigPics=new Array;
for (x=0; x<illo.length;x++){
bigPics[x]=illoPre + illo[x];
}

function mailLink(type,subject){
document.write ("<a href=mailto:"+ address + ">" + type + "<\/a>");
}

//picks one of an array
function pickOne (which){
return which[Math.floor(Math.random()*which.length)];
}

// The following 2 functions are from http://clagnut.com/sandbox/imagefades/

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity((obj), opacity);
      opacity += 10;
      fade = setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
    }
  }
}


// function to preload images
function preLoad(stuff){
for (i=0; i< stuff.length; i++){
loaded= new Image();
loaded.src=stuff[i]; 
	}
}

function makeString(huh){
return "\"" + huh + "\"" ;

}

function findPath(what){
what= makeString(what);
var lastSlash; // the position of the last slash in the path
var fileName;  // the name of the file
var directory; // The directory
lastSlash = what.lastIndexOf("/");
fileName = what.substring(lastSlash+1,what.length);
directory = what.substring(0,lastSlash);
alert(fileName);
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

// flash detection stuff

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
        var pluginsArrayLength = navigator.plugins.length;
        // for each plugin...
        for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
            // loop through all desired names and check each against the current plugin name
            var numFound = 0;
            for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
                // if desired plugin name is found in either plugin name or description
                if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
                    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
                    // this name was found
                    numFound++;
                }   
            }
            // now that we have checked all the required names against this one plugin,
            // if the number we found matches the total number provided then we were successful
            if(numFound == daPlugins.length) {
                pluginFound = true;
                // if we've found the plugin, we can stop looking through at the rest of the plugins
                break;
            }
        }
    }
    return pluginFound;
} // detectPlugin
