//
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;
}
//
//
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 getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return 'maroon';
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
    temp = unescape(dc.substring(begin + prefix.length, end));
    if (temp=="" | temp == null) { temp = 'maroon'};

  return temp;
}
 
function setCookie(name, value) {

	var curCookie = name + "=" + escape(value);
	document.cookie = curCookie;
}

function setColorPalette() {
	var colorPalette = new Array ("blue","maroon","green");
	var theColor = colorPalette[Math.round(Math.random() * 2)];
	createCookie('color',theColor,0);
}

function getColorPalette() {
	var myColor = readCookie('color');
	if ((myColor == null) ||(myColor='')) {
		setColorPalette();
	} else {
		var color = readCookie('color');
		if (color==null) { color = 'blue';}
	}
}

/* basics */
 
var isIE=navigator.appName.indexOf("Explorer")>=0 ? true: false;
var isMac=navigator.platform.indexOf("Mac")>=0 ? true: false;
var NS6=(parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var base = 'toolbar=0,location=0,directories=0,status=0,menubar=0,';
var none = base+'resizable=0,scrolling=0,scrollbars=0,';
var withScroll =  base+'resizable=0,scrolling=1,scrollbars=1,';
var footerHeight = 33;
var tourWindowHeight = 300 + 200;
var tourWindowWidth = 300 + 445;
var buttonPath=(location.href.indexOf("tours")>0 ||location.href.indexOf("keywords")>0)? '../../../../': '../../';
if (location.href.indexOf("zooms")>0){
	buttonPath=buttonPath+"../";
}


function buttonOnTour(which){
	if (pngAlpha){
	theButton=eval(which);
	theButton.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = buttonPath+'images/design/buttons/on/'+which+'.png';
	} else {
		document.images[which].src = Buttons[which]['on'].src;}
	}
 
function buttonOffTour(which){
	if (pngAlpha) {
	theButton=eval(which);
	theButton.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = buttonPath+'images/design/buttons/off/'+which+'.png';
	} else {
		document.images[which].src = Buttons[which]['off'].src;
  }
}

function setMinTourSize(){
	return true;
	}

function Button(imgName,path){
	this['on'] = new Image();
	this['off'] = new Image();
	 if (pngNormal){
		this['on'].src = path+'images/design/buttons/on/'+imgName+'.png';
		this['off'].src = path+'images/design/buttons/off/'+imgName+'.png';}
	else{
		this['on'].src = path+'images/design/buttons/on/'+imgName+'.gif';
		this['off'].src = path+'images/design/buttons/off/'+imgName+'.gif';}
	}

function buttonOn(which){
	if (pngAlpha){
	theButton=eval(which);
	theButton.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = buttonPath+'images/design/buttons/on/'+which+'.png';
	} else {
		document.images[which].src = Buttons[which]['on'].src;}
	}
 
function buttonOff(which){
	if (pngAlpha) {
	theButton=eval(which);
	theButton.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = buttonPath+'images/design/buttons/off/'+which+'.png';
	} else {
		document.images[which].src = Buttons[which]['off'].src;}
	}

function dropBy(theURL){
	width = 765;
	height = 485;
	var options = none+'width='+width+',height='+height;
	var livingRoomPath=(location.href.indexOf("tours")>0 ||location.href.indexOf("keywords")>0)? '../.': '';

	var text = '<FRAMESET cols="72%,18%" frameborder=0 border=0 framespacing=0 bordercolor=#cccccc>';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=room scrolling=no src="(from josh) common.js">';
    text = text + '<FRAMESET border=false rows="23,*,23,*" frameBorder=0 frameSpacing=0>';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=one scrolling=no src="(from josh) common.js">';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=colors scrolling=auto src="(from josh) common.js">';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=three scrolling=no src="(from josh) common.js">';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=frames scrolling=auto src="(from josh) common.js">';
    text = text +  '</FRAMESET></FRAMESET><noframes></noframes>';
	var theRoom = window.open("","virtual",options);
	theRoom.document.open();
	theRoom.document.write(text);
	theRoom.document.close();
	theRoom.focus();}

function dropByOS(theURL){
	width = 765;
	height = 485;
	var options = none+'width='+width+',height='+height;
	var livingRoomPath=(location.href.indexOf("tours")>0 ||location.href.indexOf("keywords")>0)? '../.': '';

	var text = '<FRAMESET cols="72%,18%" frameborder=0 border=0 framespacing=0 bordercolor=#cccccc>';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=room scrolling=no src="(from josh) common.js">';
    text = text + '<FRAMESET border=false rows="23,*,23,*" frameBorder=0 frameSpacing=0>';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=one scrolling=no src="(from josh) common.js">';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=colors scrolling=auto src="(from josh) common.js">';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=three scrolling=no src="(from josh) common.js">';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=frames scrolling=auto src="(from josh) common.js">';
    text = text +  '</FRAMESET></FRAMESET>';
	var theRoom = window.open("","virtual",options);
	theRoom.document.open();
	theRoom.document.write(text);
	theRoom.document.close();
	theRoom.focus();}

function frameIt(theSelector){
	theChoice = theSelector;
	theStub = "../../../images/design/frame"+theChoice;
	parent.room.document.images['upperleft'].src = theStub+"_top_left.gif";
	parent.room.document.images['uppermiddle'].src = theStub+"_top_middle.gif";
	parent.room.document.images['upperright'].src = theStub+"_top_right.gif";
	parent.room.document.images['middleleft'].src = theStub+"_middle_left.gif";
	parent.room.document.images['middleright'].src = theStub+"_middle_right.gif";
	parent.room.document.images['bottomleft'].src = theStub+"_bottom_left.gif";
	parent.room.document.images['bottommiddle'].src = theStub+"_bottom_middle.gif";
	parent.room.document.images['bottomright'].src = theStub+"_bottom_right.gif";}

function navigate(theSelector){
	selectedItem = theSelector.selectedIndex;
	theChoice = "./"+theSelector.options[selectedItem].value+".htm";
	location.href=theChoice;}

function openArtistTour(theSelector){
	selectedItem = theSelector.selectedIndex;
	theChoice = theSelector.options[selectedItem].value;
	openKeyTour(theChoice);
	}

function openKeyTour(theURL){
  var options = none+'width='+tourWindowWidth+', height='+tourWindowHeight+', toolbar=0';
  var winname = "Keyword";
  var win = window.open(theURL,winname,options); 	win.focus();

}

function openKeyWithinTour(theURL){location.href=theURL;}
  
function paintIt(theSelector){
	theColor = theSelector;
	parent.room.document.getElementById('theWall').style.backgroundColor = theColor ;
	parent.room.document.bgColor = theColor ;}

function setImage(imgName, imgPath, imgWidth, imgHeight, divID, imgClass, altText) {	
	var strPath = imgPath+imgName;
	if (pngAlpha) {
		sourceCode = '<div style="height:'+imgHeight+'px;width:'+imgWidth+'px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strPath+'.png\', sizingMethod=\'scale\')" id="'+divID+'" class="'+imgClass+'" title=\''+altText+'\'></div>';
	} else if (pngNormal) {
		sourceCode = '<img src="(from josh) common.js" width="'+imgWidth+'" height="'+imgHeight+'" name="'+divID+'" border="0" class="'+imgClass+'" alt="'+altText+'" />';
	} else {
		sourceCode = '<img src="(from josh) common.js" width="'+imgWidth+'" height="'+imgHeight+'" name="'+divID+'" border="0" class="'+imgClass+'" alt="'+altText+'" />';
	}
	return sourceCode;
	}

function setWindowWidth(){
  if (document.body.clientWidth < 790) {
   /* window.resizeTo(790,560);*/}}
  
function slideShow(){
	var options = none+'width=720,height=560';
	winname = "player";
	var player = window.open('./slideshow.htm',winname,options);
	player.focus();}

function viewBio(theURL){
	width = 765;
	height = 508;
	var options = withScroll+'width='+width+',height='+height;
	winname = "Biography";
	var bio = window.open(theURL,winname,options);
	bio.focus();}
	
function oldzoomIn(theURL){
  	var options = base+'resizable=1,scrolling=0,scrollbars=0,width=780,height=550';
  	winname = "image_zoom";
  	var bio = window.open(theURL,winname,options);
	bio.focus();}
  	
 function zoomIn(theURL){
	screenWidth = screen.width;
	screenHeight = screen.height;
	desired = 500+80;
	 if (screenHeight>desired){
		width = desired;
		height = desired;
	 }else{
		width = 780;
		height = screenHeight-120;
	 }

  	var options = base+'resizable=1,scrolling=0,scrollbars=0,width='+width+',height='+height;
	var text = '<FRAMESET rows="*,33" frameborder=0 border=0 framespacing=0 bordercolor=#cccccc>';
    text = text + '<FRAME marginHeight=0 marginWidth=0 name=zoom scrolling=no>';
     text = text + '<FRAME marginHeight=0 marginWidth=0 name=toolbar scrolling=no src="(from josh) common.js">';
    text = text +  '</FRAMESET>';
	var theZoom = window.open("","zoom",options);
	theZoom.document.open();
	theZoom.document.write(text);
	theZoom.document.close();
	theZoom.focus();
}




/* set browser and operating system environment */

function getBrowser() {
	var ua = navigator.userAgent.toLowerCase(); 
	this.ua = ua;
	var oPos = ua.indexOf('opera');
	// browser name
	this.isGecko     = (ua.indexOf('gecko') != -1);
	this.isMozilla   = (this.isGecko && ua.indexOf("gecko/") + 14 == ua.length);
	this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (oPos == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
	this.isIE        = ( (ua.indexOf("msie") != -1) && (oPos == -1) && (ua.indexOf("webtv") == -1) ); 
	this.isOpera     = (oPos != -1); 
	this.isIcab      = (ua.indexOf("icab") != -1); 
	this.isWebtv     = (ua.indexOf("webtv") != -1); 
	this.isOmniweb   = (ua.indexOf("omniweb") != -1);
	this.isDreamcast   = (ua.indexOf("dreamcast") != -1);
	
	// spoofing and compatible browsers
	this.isIECompatible = ( (ua.indexOf("msie") != -1) && !this.isIE);
	this.isNSCompatible = ( (ua.indexOf("mozilla") != -1) && !this.isNS && !this.isMozilla);
	
	this.versionMinor = parseFloat(navigator.appVersion); 	// browser version
	
	if (this.isNS && this.isGecko) {
		this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
	} 	// correct version number for NS6+
	
	else if (this.isIE && this.versionMinor >= 4) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
	} 	// correct version number for IE4+ 
	
	else if (this.isOpera) {
		if (ua.indexOf('opera/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
		}	else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
		}
	}	// correct version number for Opera 
	
	else if (this.isIcab) {
		if (ua.indexOf('icab/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
		} else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
		}
	}	// correct version number for iCab 
	
	else if (this.isWebtv) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('webtv/') + 6 ) );
	}	// correct version number for WebTV
	
	this.versionMajor = parseInt(this.versionMinor); 
	
	// platform
	this.isWin   = (ua.indexOf('win') != -1);
	this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1) );
	this.isMac   = (ua.indexOf('mac') != -1);
	this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('linux') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
	
	// specific browser shortcuts
	this.isIE5x = (this.isIE && this.versionMajor == 5);
	this.isIE55 = (this.isIE && this.versionMinor == 5.5);
	this.isIE5up = (this.isIE && this.versionMajor >= 5);
	this.isIE6x = (this.isIE && this.versionMajor == 6);
	this.isIE6up = (this.isIE && this.versionMajor >= 6);
	
	this.isIE4xMac = (this.isIE4x && this.isMac);
}

var browser = new getBrowser();

// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) {
	var pngAlpha = true;
// else, if the browser can display PNGs normally, then do that. 
} else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) {
	var pngNormal = true;
} 


/* style variants */

function resizePreview(){
	var windowHeight = (NS6)? window.innerHeight : document.body.offsetHeight;
	/* if (windowHeight>430){ */
	document.getElementById('footer').style.top = windowHeight - footerHeight+"px" ;}

/* button package */

if (document.styleSheets.length>0){

if (isIE && (!isMac)){
var offset = document.styleSheets[0].rules.length-1;
var offObj = document.styleSheets[0].rules[offset-2].style;
var onObj = document.styleSheets[0].rules[offset-1].style;
var downObj = document.styleSheets[0].rules[offset].style;
} else {
var offset = document.styleSheets[0].cssRules.length-1;
var offObj = document.styleSheets[0].cssRules[offset-2].style;
var onObj = document.styleSheets[0].cssRules[offset-1].style;
var downObj = document.styleSheets[0].cssRules[offset].style;
}

var onText = onObj.color;
var onHighlight = onObj.borderTopColor;
var onLowlight = onObj.borderBottomColor;
var onBackground = onObj.backgroundColor;

var downText = downObj.color;
var downHighlight = downObj.borderTopColor;
var downLowlight = downObj.borderBottomColor;
var downBackground = downObj.backgroundColor;

var offText = offObj.color;
var offHighlight = offObj.borderTopColor;
var offLowlight = offObj.borderBottomColor;
var offBackground = offObj.backgroundColor;
} 

function buttonOver(which){
	var nodeObj = document.getElementById(which);
	var copyObj = document.getElementById('over');
	nodeObj.style.backgroundImage =  'url('+buttonPath+'images/design/'+which+'_on.gif)';
	nodeObj.style.backgroundPositionY='4px';
	nodeObj.style.margin='0px';
	nodeObj.style.padding='0px';
	nodeObj.style.lineHeight='13px';
	nodeObj.style.backgroundPosition = 'left center';
	nodeObj.style.backgroundPositionX='3px';
	nodeObj.style.backgroundPositionX='3px';
	nodeObj.style.borderColor = onLowlight;
	nodeObj.style.backgroundColor =onBackground;
	nodeObj.style.borderLeftColor = onHighlight;
	nodeObj.style.borderTopColor = onHighlight;
	nodeObj.style.color = onText;}

function buttonOut(which){
	var nodeObj = document.getElementById(which);
	nodeObj.style.backgroundImage =   'url('+buttonPath+'images/design/'+which+'_off.gif)';
	nodeObj.style.lineHeight='13px';
	nodeObj.style.backgroundPositionY='4px';
	nodeObj.style.margin='0px';
	nodeObj.style.padding='0px';
	nodeObj.style.backgroundPosition = 'left center';
	nodeObj.style.backgroundPositionX='3px';
	nodeObj.style.fontWeight = 'normal';
	nodeObj.style.fontStyle = 'normal';
	nodeObj.style.borderColor = offLowlight;
	nodeObj.style.borderLeftColor = offHighlight;
	nodeObj.style.borderTopColor = offHighlight;
	nodeObj.style.backgroundColor = offBackground;
	nodeObj.style.color = offText;}

function buttonClick(which){
	var nodeObj = document.getElementById(which);
	nodeObj.style.backgroundImage =   'url('+buttonPath+'images/design/'+which+'_down.gif)';
	nodeObj.style.backgroundColor = downBackground;
	nodeObj.style.borderColor = downHighlight;
	nodeObj.style.color = downText;
	nodeObj.style.borderBottomColor = downLowlight;
	nodeObj.style.borderRightColor = downLowlight;
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
//
function changePages(theOldID,theNewID){
		opacity(theOldID, 100, 0, 2250);
	opacity(theNewID, 0, 100, 2250)
	document.getElementById(theOldID).style.display = 'none';
}

function navigateOpps(theForm){
theTarget = theForm.navigator.options[theForm.navigator.selectedIndex].value;
location.href = theTarget;
}

	function openGuide(){
	if (screen.width<=800){
	var options = 'toolbar=1,location=0,directories=0,status=0,menubar=1,resizable=1,scrolling=1,scrollbars=1';} 
	else {
	var options = 'toolbar=1,location=0,directories=0,status=0,menubar=1,resizable=1,scrolling=1,scrollbars=1';}
	winname = "OpenStudios";
	var openStudio = window.open("http://www.marinarts.org/html/openstudios.htm",winname,options);
	openStudio.focus();}


function openStudiosHome(){
	var options = base+'width=810,height=560,resizable=1,scrolling=1,scrollbars=1';
	winname = "OpenStudios";
	var openStudio = window.open("http://www.marinarts.org/html/openstudios.htm",winname,options);
	/* window.name="easel"; */
	openStudio.focus();}
 
function openStudios(){
	var options = base+'width=810,height=560,resizable=1,scrolling=1,scrollbars=1';
	winname = "OpenStudios";
	var openStudio = window.open('http://www.marinarts.org/html/openstudios.htm',winname,options);
	openStudio.focus();}

function openStudiosKeys(){
	var options = base+'width=810,height=560,resizable=1,scrolling=1,scrollbars=1';
	winname = "OpenStudios";
	var openStudio = window.open("http://www.marinarts.org/html/openstudios.htm",winname,options);
	/* window.name="easel"; */
	openStudio.focus();}

