//  SHINS.js

// site specific stuff for theshinsmusic.com

// ** Global variables ** //
// Final left position of gliding element
var leftPoint = 100;
var rightPoint = 600;
// Interval ID
var intervalID;
// 'Corrector' positioning factor for IE/Mac et al., but doesn't hurt others
var fudgeFactor = {top:-1, left:-1};
var xShift = -1;

// Set initial position offscreen and show object and
// start timer by calling glideToCenter()
function startGlide(layerName, y, xOffset) {
    // 'obj' is the positionable object
    var obj = getRawObject(layerName);
    // set fudgeFactor values only first time
    if (fudgeFactor.top == -1) {
        if ((typeof obj.offsetTop == "number") && obj.offsetTop > 0) {
            fudgeFactor.top = obj.offsetTop;
            fudgeFactor.left = obj.offsetLeft;
        } else {
            fudgeFactor.top = 0;
            fudgeFactor.left = 0;
        }
        if (obj.offsetWidth && obj.scrollWidth) {
            if (obj.offsetWidth != obj.scrollWidth) {
                obj.style.width = obj.scrollWidth;    
            }
        }
    }
    shiftTo(obj, (2*getInsideWindowWidth())/3 + xOffset, y - fudgeFactor.top);
    show(obj);
    intervalID = setInterval("glideToCenter('" + layerName + "')", 1);
}
// Move the object to the left by 5 pixels until it's centered
function glideToCenter(layerName) {
    var obj = getRawObject(layerName);
	var yShift = (Math.round(Math.random()*8-4.1));
    shiftBy(obj,xShift,yShift);
	if ((getObjectTop(obj) - 30) < 0) {
	    hide(obj);
    } 
    if ((getObjectLeft(obj) < leftPoint)) {
        xShift = 1;
    } else if ((getObjectLeft(obj) > rightPoint)) {
	    xShift = -1;
	}
}

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;
    }
  }
}






