/* PACKAGE FUNCTIONS */

// popup windows of classic.tpl ( zooms + interactives )
// <a href="#" onClick="return allZooms('url.html','ZoomWindow');"> - link - </a>
// width=500 + scroll=0 -OR- width=516 + scroll=1 -AND- height=550 or height=500
function allZooms (url,name,width,height,scroll) {
	var options = "width=" + width + ",height=" + height + ",status=0,toolbar=0,menubar=0,location=0,scrollbars=" + scroll + ",resizable=0";
	window.open(url,name,options);
	return false;
}

// popups
function winPop(url,w,h,s) {
	if (s == "") { s = "0"; }
	var winleft = (screen.width - w) / 2;
	var wintop = (screen.height - h) / 2;
   var agent,windowName,params,win
		agent = navigator.userAgent;
		windowName = "popup";
		params  = "'";
		params += "toolbar=0,";
		params += "location=0,";
		params += "directories=0,";
		params += "status=0,";
		params += "menubar=0,";
		params += "scrollbars=" + s + ",";
		params += "resizable=0,";
		params += "left=" + winleft + ",top=" + wintop + ",";
		params += "width=" + w + ",";
		params += "height=" + h + "'";

     win = window.open(url,windowName,params);

    if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) win = window.open(url, windowName , params)
    if (!win.opener) win.opener = window
	 win.focus();
	return false;
}

function openNewWindow(url,name,options) {
    window.open(url,name,options);
}


/* ----------------------------------------------------------------------------------------------------------------------- */


// image rollovers ( prev / next )
// <a . onMouseOver="switchOn('n_')" onMouseOut="switchOff('n_')"> <img src="/sgallery/_off.gif" ... name="n_"> </a>
// _ = number refering to image associated
if (document.images) {   
		n1On = new Image(50,10);
		n1On.src = "/sgallery/prevon.gif";
		n1Off = new Image(50,10);
		n1Off.src = "/sgallery/prevoff.gif";

		n2On = new Image(50,10);
		n2On.src = "/sgallery/nexton.gif";
		n2Off = new Image(50,10);
		n2Off.src = "/sgallery/nextoff.gif";
		
		n3On = new Image(50,10);
		n3On.src = "/sgallery/prevon.gif";
		n3Off = new Image(50,10);
		n3Off.src = "/sgallery/prevoff.gif";

		n4On = new Image(50,10);
		n4On.src = "/sgallery/nexton.gif";
		n4Off = new Image(50,10);
		n4Off.src = "/sgallery/nextoff.gif";

}

function switchOn(imgName) {
    if (document.images) { 
        imgOn = eval(imgName + "On.src");
        document [imgName].src = imgOn;
        }
}

function switchOff(imgName) {
   if (document.images) { 
        imgOff = eval(imgName + "Off.src");
        document [imgName].src = imgOff;
        }
}


/* ----------------------------------------------------------------------------------------------------------------------- */


// auto goto url via pulldown
// <form name="linkForm"> <select onChange="navigateTo(this);"> <option value="relative|absolute url"> - link - </select> </form>
function navigateTo(s) { 
	var url = s.options[s.selectedIndex].value;
	if (url) window.top.location.href = url;
	return false;
}

function navDie(s) {
	var url = s.options[s.selectedIndex].value;
	if (url) { 
		opener.location.href = url; 
		window.close();
	}
	return false;
}

// links from popup to parent browser
// <a href="#" onClick="quickLink('url.html');"> - link - </a>
function popLink(url) {
    opener.location.href = url; 
    window.close();
}

// pulls values from url
function getParam(paramName) {
    var url,paramBegin,paramEnd,parseCharPos,valueBegin,paramValue
    url = window.location.search;
    paramBegin = url.indexOf(paramName)
    if (paramBegin == -1) return false
    paramEnd = paramBegin + paramName.length

    if (url.indexOf('&',paramEnd) == -1) {
        parseCharPos = url.length
    } else {
        parseCharPos = url.indexOf('&',paramEnd)
    }

    valueBegin = paramEnd + 1
    paramValue = url.substring(valueBegin, parseCharPos)

//    alert("paramName="+paramName+"\nparamValue=" + paramValue)

    for (i = 0; i < paramValue.length; i++) {
    paramValue = paramValue.replace("+", " ");
    paramValue = paramValue.replace("%26", "&");
    paramValue = paramValue.replace("%27", "'");
    paramValue = paramValue.replace("%28", "(");
    paramValue = paramValue.replace("%29", ")");
    }

    return paramValue
}

/* END PACKAGE FUNCTIONS */
