// ----------------- Style Switcher -----------------//
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;
}
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



// --------------------- Striper --------------------//

function striper(parentElementTag, parentElementClass, childElementTag, styleClasses)
{
    var i=0,currentParent,currentChild;
    // capability and sanity check
    if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {
        // turn the comma separate list of classes into an array
        var styles = styleClasses.split(',');
        // get an array of all parent tags
        var parentItems = document.getElementsByTagName(parentElementTag);
        // loop through all parent elements
        while (currentParent = parentItems[i++]) {
            // if parentElementClass was null, or if the current parent's class matches the specified class
            if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {
                var j=0,k=0;
                // get all child elements in the current parent element
                var childItems = currentParent.getElementsByTagName(childElementTag);
                // loop through all child elements
                while (currentChild = childItems[j++]) {
                    // based on the current element and the number of styles in the array, work out which class to apply
                    k = (j+(styles.length-1)) % styles.length;
                    // add the class to the child element - if any other classes were already present, they're kept intact
                    currentChild.className = currentChild.className+" "+styles[k];
                }
            }
        }
    }
}



// ---------------------- PopUp ---------------------//
function popup(url) {
      var Popped = 
window.open(url,"popup","status=no,width=400,height=400,scrollbars=yes,resizable=yes");
   }
 


// ---------------------- Image Cross Fade ---------------------//
/*
    Image Cross Fade Redux
    Version 1.0
    Last revision: 02.15.2006
    steve@slayeroffice.com
*/
window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
function so_init()
{
    if(!d.getElementById || !d.createElement)return;
    css = d.createElement('link');
    css.setAttribute('href','slideshow2.css');
    css.setAttribute('rel','stylesheet');
    css.setAttribute('type','text/css');
    d.getElementsByTagName('head')[0].appendChild(css);
    imgs = d.getElementById('rotator').getElementsByTagName('img');
    for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
    imgs[0].style.display = 'block';
    imgs[0].xOpacity = .99;
    setTimeout(so_xfade,9000);
}
function so_xfade()
{
    cOpacity = imgs[current].xOpacity;
    nIndex = imgs[current+1]?current+1:0;
    nOpacity = imgs[nIndex].xOpacity;
    cOpacity-=.05;
    nOpacity+=.05;
    imgs[nIndex].style.display = 'block';
    imgs[current].xOpacity = cOpacity;
    imgs[nIndex].xOpacity = nOpacity;
    setOpacity(imgs[current]);
    setOpacity(imgs[nIndex]);
    if(cOpacity<=0)
    {
        imgs[current].style.display = 'none';
        current = nIndex;
        setTimeout(so_xfade,9000);
    }
    else
    {
        setTimeout(so_xfade,50);
    }
    function setOpacity(obj)
    {
        if(obj.xOpacity>.99)
        {
            obj.xOpacity = .99;
            return;
        }
        obj.style.opacity = obj.xOpacity;
        obj.style.MozOpacity = obj.xOpacity;
        obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
    }
}