var enterPurch = false;
var menuTime = 500;
var menuTimeoutVar = null;


function loadPolikerImages() {
       var docu = document;
        var arraySz = 22;
        var firstarraySz = 7;
  if (docu.images)
    {
       if (!docu.PW_img) {
 	     docu.PW_img = new Array(arraySz);
 		 for(j=1; j<=arraySz; j++) {
            docu.PW_img[j] = new Image;
        } // for
		for (j=1; j<firstarraySz; j++)
		{
	        docu.PW_img[j].src = "Images/common/btn_" + (j) + "n.jpg";
     	}  // for loading
		for (j=11; j<=22; j++)
		{
	        docu.PW_img[j].src = "Images/common/btn_" + (j) + "n.jpg";
     	}  // for loading
	   }
	}
}


  function ImgOn (picNum)
{
//	alert(eval(this));
//	alert(theField.name)
   fImage = eval("document.btn_" + picNum);
//   fImage.src = theImg + "_o.jpg";
//   fImage = eval("Image" + picNum);
   fImage.src = "Images/common/btn_" + picNum + "n.jpg";

}

function ImgOff (picNum)
{
   fImage = eval("document.btn_" + picNum);
   fImage.src = "Images/common/btn_" + picNum  + ".jpg";
}

function frameImg (imgDir, imgNum)
{
	var theAlbum = $(imgDir + imgNum)
//		var attStr = "";
//	    for (var key in theAlbum) {
//		    attStr = attStr + key + " " + theAlbum[key] + "\n";
//	    }
//		alert(attStr);
	theAlbum.className="albumBoxN";
}

function unFrameImg (imgDir, imgNum)
{
	var theAlbum = $(imgDir + imgNum)
	theAlbum.className="albumBox";
}


function genImgOn(theFld) {
	theFld.className="imgSel";
}

function genImgOff(theFld) {
	theFld.className="imgBorderSpace";
}

function genImgSel (theFld, imgDir)
{
//	alert(theFld.id);
	bigImg = $("BigImage")
	bigImg.src = "Images/" + imgDir + "/image" + theFld.id + ".jpg";
}

function AlbumOn (albumNum)
{
	var theAlbum = $("alb" + albumNum)
//		var attStr = "";
//	    for (var key in theAlbum) {
//		    attStr = attStr + key + " " + theAlbum[key] + "\n";
//	    }
//		alert(attStr);
	theAlbum.className="albumBoxN";
}

function AlbumOff (albumNum)
{
	var theAlbum = $("alb" + albumNum)
	theAlbum.className ="albumBox";
}

function AlbumSel (theFld, imgDir, albumNum)
{
	alert(theFld.id);
}

function showText(sng)
{
     openTheWindow('songWords.asp?sng=' + sng,'polikerPlayer','width=234,height=405,resizable=no,status=no');
}

function showTextURL(sng)
{
     openTheWindow(sng,'polikerPlayer','width=234,height=405,resizable=no,status=no');
}

function playSong(alb,sng)
{
     openTheWindow('polikerPlayer.asp?alb=' + alb + '&sng=' + sng,'polikerSong','width=224,height=390,resizable=no,status=no');
}

function showVideo(sng)
{
     openTheWindow('videoPlayer.asp?sng=' + sng,'polikerPlayerVideo','width=350,height=380,resizable=no,status=no');
}

function showShow(showID)
{
     openTheWindow('showDetails.asp?show=' + showID,'polikerShow','width=400,height=415,resizable=no,status=no');
}

function showBigImg (theImg, w, h) {
	 theFeatuers = "width=" + w + ",height=" + h + ",resizable=no,status=no";
     openTheWindow('bigImage.asp?theImg='+theImg,'polikerImg',theFeatuers);

}

function openTheWindow (theURL,winName,features)
{
   theWindow = window.open(theURL,winName,features);
}

function smallWinInit()
{
	this.focus();
	scroller.init;
}

function showPurchase(theID) {
//		alert(theID);
		var obj = $(theID);
//		alert(obj);
		if (!obj) {
//			return false;
		}
		else if (obj.style) {
			if (obj.style.display == "none") {
				 obj.style.display="";
				 obj.visibility = "show";
				 btnHeight = Element.getDimensions($('btn_1')).height;
				 absButton = absPosLocal($('btn_1'));
                 obj.style.top = absButton.y + btnHeight-12;
                 obj.style.left = absButton.x + 67;
			} else {
				obj.style.display="none";
			}
		}
}

function showPurchase0(theID) {
}

function putHandCursor(theID) {
		var obj = $(theID);
		obj.style.cursor='hand';
}

function showPurchase1(theID) {
//		alert(theID);
		var obj = $(theID);
		clearTimeOut();
//		alert(obj);
		if (!obj) {
//			return false;
		}
		else if (obj.style) {
			if (obj.style.display == "none") {
				 obj.style.display="";
				 obj.visibility = "show";
				 btnHeight = Element.getDimensions($('btn_1')).height;
				 absButton = absPosLocal($('btn_1'));
                 obj.style.top = absButton.y + btnHeight-12;
                 obj.style.left = absButton.x + 67;
//				 obj.onMouseOut=timeout1(theID);
//				 obj.onMouseOver=clearTimeOut();
			} else {
//				obj.style.display="none";
			}
		}
}

function timeout1(theID)
{
		var obj = $(theID);
//		alert(theID);
		menuTimeoutVar = setTimeout(function() {hidePurchase1(theID)},menuTime);
//				obj.style.display="none";
}

function clearTimeOut() {
//	alert("clear");
   if (menuTimeoutVar) {
	   clearTimeout(menuTimeoutVar);
	   menuTimeoutVar = null;
   }
}

function hidePurchase1(theID) {
		var obj = $(theID);
		obj.style.display="none";
}


function hideLayer(theID) {
		var obj = $(theID);
		if (enterPurch) {
				obj.style.display="none";
				enterPurch = false;
		}
}

function markIn(theID) {
//	alert("enter");
		var obj = $(theID);
		enterPurch = true;
}

function absPosLocal(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}  // if
	return {x:curleft, y:curtop};
}


