/* 
script.js
MarylynVarriale.com
Copyright (c) 2008 - All rights reserved
*/

// ****************************************************************
// GLOBALS
// ****************************************************************

var vComps = new Array
(
	"wholewall",
	"dagostino",
	"longisland-30",
	"turnoff",
	"sticksnstones",
	"letter-a",
	"wisingup",
	"giftoflove",
	"hp",
	"lamamedia",
	"mmantra",
	"bwaymall"
);

var vNames = new Array
(
	"Whole in the Wall",
	"D'Agostino",
	"Long Island Jingle",
	"Turn Off!",
	"Sticks and Stones",
	"Letterville",
	"Wising Up",
	"The Gift of Love",
	"H. P.",
	"LaMa Media",
	"Millennium Mantra",
	"Broadway Mall"
);

var vNumComps = vComps.length,
	vCompNum = 0,
	vDelta = 28;

// ****************************************************************
// SITE FUNCTIONS
// ****************************************************************

function fComp(rComp) 
{
	vCompNum = rComp;
	fShowComp();
}

function fShowComp() 
{
	var tDOM = fDOM("compon" , 1);
	tDOM.top = (vCompNum * vDelta) + 'px';
	tDOM = fDOM("compositions");
	tDOM.src="comps/" + vComps[vCompNum] + ".html";
	fSetCookie("comp", vCompNum);
}

function fOver(rWhich) 
{
	var tDOM = fDOM(("comp" + rWhich), 1);
	tDOM.background = '#fff';
}

function fOut(rWhich) 
{
	var tDOM = fDOM(("comp" + rWhich), 1);
	tDOM.background = 'none';
}

function fInit() 
{
	vCompNum = parseInt(fGetCookie("comp"));
	if (isNaN(vCompNum)) vCompNum = 0;
	setTimeout('fShowComp()', 10);
}


// ****************************************************************
// DOM
// ****************************************************************

var vIsID = 0, vIsAll = 0, vIsLayers = 0;
if (document.getElementById) { vIsID = 1; }
else if (document.all) { vIsAll = 1; }
else if ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) == 4)) { vIsLayers = 1; }

function fDOM(rID, rStyle) 
{
	if (rStyle) 
	{
		if (vIsID) { return document.getElementById(rID).style; } 
		else if (vIsAll) { return document.all[rID].style; } 
		else if (vIsLayers) { return document.layers[rID]; }
	} else {
		if (vIsID) { return document.getElementById(rID); } 
		else if (vIsAll) { return document.all[rID]; } 
		else if (vIsLayers) { return document.layers[rID]; }
	}
}

// ****************************************************************
// COOKIES
// ****************************************************************

function fSetCookie(rName, rValue, rDays) {
	if (typeof(rDays) == 'undefined') rDays = 1;
	var tDate = new Date();
	tDate.setDate(tDate.getDate() + rDays);
	var tCookie = (rName + '=' + escape(rValue) + '; expires=' + tDate.toGMTString() + '; path=/');
	document.cookie = tCookie;
}

function fGetCookie(rName) {
	var tOffset, tEnd;
	var tSearch = (rName + "=");
	var tValue = "";
	if (document.cookie.length > 0) {
		tOffset = document.cookie.indexOf(tSearch);
		if (tOffset != -1) {
			tOffset += tSearch.length;
			tEnd = document.cookie.indexOf(";", tOffset);
			if (tEnd == -1) tEnd = document.cookie.length;
			tValue = unescape(document.cookie.substring(tOffset, tEnd));
      }
   }
  return(tValue);
}

