// JavaScript Document
<!--
// inlined jquery.color plugin
(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);
//end of jquery.color
// jquery.mousewheel
var bgimgurl, bgimgtxt, scrolling;
var picturearray = [], textarray = [];
var img = new Image();

// Dreamweaver autofunctions
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function IW_preloadImage(imgsrc) {
	img = new Image()
	img.src = imgsrc;
}

// Preload images
	MM_preloadImages('/images/footermenu-background.png', '/images/footermenu-01s.png','/images/footermenu-02s.png','/images/footermenu-03s.png','/images/footermenu-04s.png','/images/footermenu-05s.png', '/images/artist-background.gif', '/images/submenu_background.png', '/images/content-backgroundfade.png', '/images/colorbox/close-button.png');
	if (window.location.pathname == "/artist.htm") {
		$(".artistcontent a").each( function() {
			MM_preloadImages($(this).attr("href"));		//IW_preloadImage($(this).attr("href"));
		});
		for (x=0;x<4;x++) {
			imgtoload = '/images/timeline-quote'+x+'.png';			
			//IW_preloadImage(imgtoload);
			imgtoload2 = '/images/timeline-button-'+x+'o.gif';
			//IW_preloadImage(imgtoload2);
			MM_preloadImages(imgtoload, imgtoload2);
		}
	}
	if ((window.location.pathname.indexOf("event") > -1) || (window.location.pathname.indexOf("faq") > -1)) {
		MM_preloadImages('/images/paper-background.png', '/images/paper-header.png');
	}
// Infiniweb custom functions
function IW_querystring_value(keyname) {
	completestring = window.location.search.substring(1);
	variables = completestring.split("&");
	for (x=0;x<variables.length;x++) {
		variable = variables[x].split("=");
		if (variable[0] == keyname) {
			return variable[1];
		}
	}
}
function IW_changebuttonicons(newimage) {
	$(".news_expander img").each(function() {
		$(this).attr("src", newimage);
	});
}

if(window.location.pathname.indexOf("event") > -1)	{
	function eventsindex() {
		if ($("#events-pagetitle").attr("src") != "/images/events-title.gif") {
			if (!$.browser.msie) {
			$("#events-pagetitle").animate({opacity:0}).load('/images/events-title.gif', '' , function() { $(this).attr("src", "/images/events-title.gif").animate({opacity:1}); } ); //.css("margin-left", "124px")
			} else {
				//new code to test - from http://www.witheringtree.com/index.php/2009/05/image-load-event-binding-with-ie-using-jquery/
				newurl = "/images/events-title.gif";
				//$("#events-pagetitle").load(newurl, '' , function() { $(this).attr("src", newurl).css("margin-left", "141px"); } );
				$("#events-pagetitle").attr("src", newurl);		//	.css("margin-left", "124px")	
			}
		}
		IW_changebuttonicons("/images/events-e-icon.png");
	} 
	function eventsnews() {
		if ($("#events-pagetitle").attr("src") != "/images/news-title.gif") {
			if (!$.browser.msie) {
				$("#events-pagetitle").animate({opacity:0}).load('/images/news-title.gif', '' , function() { $(this).attr("src", "/images/news-title.gif").animate({opacity:1}); } ); //.css("margin-left", "141px")
			} else {
				//new code to test - from http://www.witheringtree.com/index.php/2009/05/image-load-event-binding-with-ie-using-jquery/
				newurl = "/images/news-title.gif";//?random=" + (new Date()).getTime();
				//$("#events-pagetitle").load(newurl, '' , function() { $(this).attr("src", newurl).css("margin-left", "141px"); } );
				$("#events-pagetitle").attr("src", newurl); //.css("margin-left", "141px")
			}
		}
		IW_changebuttonicons("/images/news-n-icon.png");
	} 
	function eventscollections() {
		if ($("#events-pagetitle").attr("src") != "/images/special-collections.gif") {
			if (!$.browser.msie) {
				$("#events-pagetitle").animate({opacity:0}).load('/images/special-collections.gif', '' , function() { $(this).attr("src", "/images/special-collections.gif").animate({opacity:1}); } ); //.css("margin-left", "141px")
			} else {
				//new code to test - from http://www.witheringtree.com/index.php/2009/05/image-load-event-binding-with-ie-using-jquery/
				newurl = "/images/special-collections.gif";//?random=" + (new Date()).getTime();
				//$("#events-pagetitle").load(newurl, '' , function() { $(this).attr("src", newurl).css("margin-left", "141px"); } );
				$("#events-pagetitle").attr("src", newurl); //.css("margin-left", "141px")
			}
		}
		
		IW_changebuttonicons("/images/events-c-icon.png");
	} 
}

function IW_enlargebutton(status) {
	if (status == "on") {
		document.getElementById("enlarge").style.display='block';
	} else {
		document.getElementById("enlarge").style.display='none';
	}
}

function IW_makelinksactive() {
	if ($.browser.msie) {
		$(".list_header").css("font-size", "14px");		 
	}
        $(".list_header").hover(function() {
				$(this).css("cursor", "pointer");
				if(!$.browser.msie){
					$(this).animate({ fontSize:"20px", backgroundColor:"#eee", left:'-=2px', marginTop: '-=6px', backgroundPosition:'0px +=6px'}, 'fast'); //.children(".news_expander").animate({ marginTop: '-=1px' }, 'fast')
					$(this).child(".list_date").css("color", "#f00");
				} else {
					$(this).animate({ fontSize:"16px", backgroundColor:"rgb(238,238,238)", left:'-=2px', marginTop: '-=6px'}, 'fast');
					$(this).child(".news_expander").animate({ marginTop: '-=8px' }, 'fast');	
				}
		}, function() {	
				$(this).css("cursor", "default");
				if(!$.browser.msie){
					$(this).animate({ fontSize:"18px", backgroundColor:"#fff", marginTop: '+=6px', backgroundPosition: '0px -=6px'}, 'fast'); //.children(".news_expander").animate({ marginTop: '+=1px' }, 'fast')
					$(this).child("a").css("padding-top", "0px");
					$(this).child(".list_date").css("color", "#0f0");
				} else {
					$(this).animate({ fontSize:"14px", backgroundColor:"rgb(255,255,255)", marginTop: '+=6px'}, 'fast');
					$(this).child(".news_expander").animate({ marginTop: '+=8px' }, 'fast');
				}
		}).click(function() {
			$("#item_detail_panel").remove();
			if ($(this).children(".header_title").length) {
				h3text = $(this).children(".list_date").html() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " + $(this).children(".header_title").html();
			} else {
				h3text = $(this).children(".list_title").html();
			}

			$("#content-white").append("<div id='item_detail_panel'><div id='panel_closer'><a href='javascript:close_panel();'><img src='/images/paper-closebutton.png' /></a></div><div id='panel_content'><h3>" + h3text + "</h3><br />"+ $(this).next().html() +"</div></div>");
			$("#timelinedata").animate({top: '-=600px'}, 'fast');
			$("#item_detail_panel").css("z-index", "300").animate({top: '40px'}, 600);
        });

		$("#panel_closer").click( function() {
			close_panel();
		});

        $(".faqitem a").mouseover( function() { $(this).css("cursor", "pointer") }).mouseout( function() { $(this).css("cursor", "default") }).click( function(ev) {
				ev.preventDefault();
              $(".faqitem a").each( function() { 
                    $(this).children('img').attr('src', $(this).children('img').attr('src').replace('-s', '-n'));
              });
              $(this).children('img').attr('src', $(this).children('img').attr('src').replace('-n', '-s'));
        });	
}

function IW_load_faqindex() {
	$('#timelinedata').load("faq-faqs.htm", '', function() {
		if ($.browser.msie) {
			$(".list_header").css("font-size", "14px");			 
		}
		$("#timelinedata div.list_header span").css("padding", "0px").css("margin", "0px");
		$(".contentscrollpane").css("padding", "0").css("margin-top", "0");
		IW_makelinksactive();
		IW_changebuttonicons('/images/faq-q-icon.png');
		$('div.list_header').css("width", "643px");
		$('#timelinedata').css("display", "block");
	});	
}

function IW_changeeventscontent(eventspage) {
	close_panel();
	$('#timelinedata').load(eventspage, '', function(){ 
		if(eventspage == "/events-events.htm") {
			eventsindex();	
			IW_makelinksactive();
			$('#events-pagetitle').animate({opacity:1});
		}
		if (eventspage == "/events-news.htm") {
			eventsnews();	
			IW_makelinksactive();
			$('#events-pagetitle').animate({opacity:1});
		}
		if(eventspage == "/events-public.htm") {
			$(".list_date").each( function() {
				somevars = $(this).next(".header_title").html().split(";");	
				$(this).html(somevars[0]);
				$(this).next(".header_title").html(somevars[1]);
			});
			//$('#events-pagetitle').animate({opacity:0});
			eventscollections();
			IW_makelinksactive();
			//$("#publictitle").css("font-size", "45px").css("padding-bottom", "10px");	
			$('#events-pagetitle').animate({opacity:1});

		}
		$('#timelinedata').css("display", "block");
		$('.contentscrollpane').jScrollPane({scrollbarWidth:12});

	});
}

function IW_changefaqcontent(faqpage) {
	close_panel();	
	if (faqpage == "index") {
		$('#timelinedata').css("display", "none");
		$("#content-white").css("padding-top", "0px");
		IW_load_faqindex();
		IW_scrollpanel();//IW_submenu();
		$('.contentscrollpane').jScrollPane({scrollbarWidth:12});
	} else {
		$('#timelinedata').css("display", "none");
		$(".contentscrollpane").css("padding", "15px 85px").css("margin-top", "0px");
		$("#content-white").css("padding-top", "10px");
		$('#timelinedata').load(faqpage, '', function(){ 
            $('#timelinedata').css("display", "block");
			$('.contentscrollpane').jScrollPane({scrollbarWidth:12});
		});
	}
}

function IW_load_eventsindex() {
	$('#timelinedata').load("events-events.htm", '', function() {
		$(".contentscrollpane").css("padding", "0px 0px").css("margin-top", "0px");
		IW_makelinksactive();
		IW_changebuttonicons('/images/events-e-icon.png');
		$('#timelinedata').css("display", "block");
	});	
}

function IW_clicksubmenu(itemclicked) {
	newclicked = "#"+itemclicked+" a";
	$(newclicked).triggerHandler('click');

}

function IW_button() {
	if (bgimgurl) {
		leftpanelmiddlehorizontal = parseInt((document.width - 660 - 25 - 80)/2);
		leftpanelmiddlevertical = parseInt(((document.height * 0.86) - 67)/2);
		replacement = "-orig.jpg";
		toreplace = ".jpg";
		enlargeurl = "enlarge/"+bgimgurl.replace(toreplace,replacement);
		bgpos = leftpanelmiddlevertical+"px "+leftpanelmiddlehorizontal+"px";
		//$("#enlarge").css({ backgroundPosition: bgpos});
        document.getElementById("enlarge").innerHTML = '<a href="/images/backgrounds/'+enlargeurl+'" title="'+bgimgtxt+'"><img src="/images/basquiat_enlarge.gif" title="'+bgimgtxt+'" alt="'+bgimgtxt+'" /></a>';
        $('#enlarge a').colorbox({ maxWidth: '100%', maxHeight: '100%', scalePhotos: true});
	} else {
		setTimeout(IW_button, 1000);
	}
}

if((window.location.pathname == "/index-new.htm") || (window.location.pathname == "/")) {
	$(".hpimg").css("height", "80%").css("width", "80%");
	function animatenews(idx) {				
		$("#news li").each( function(index) {
			$(this).fadeOut(500);
			if (index == idx) {
				$(this).fadeIn(500);
			}
		});
		if (idx == $("#news li").length - 1) {
			nextidx = 0;	
		} else {
			nextidx = idx + 1;
		}
		setTimeout("animatenews(nextidx)", 4000);
	}
	
	function animateevents(eidx) {				
		$("#events li").each( function(eindex) {
			$(this).fadeOut(500);
			if (eindex == eidx) {
				$(this).fadeIn(500);
			}
		});
		if (eidx == $("#events li").length - 1) {
			nexteidx = 0;	
		} else {
			nexteidx = eidx + 1;
		}
		setTimeout("animateevents(nexteidx)", 4000);
	}
}

function close_panel() {
	$("#item_detail_panel").animate({top:'2000px'}, 300);
	setTimeout(delete_panel, 300);
}

function delete_panel() {
	$("#item_detail_panel").css("z-index", "-300").remove();
	$("#timelinedata").animate({top: '+=600'}, 'fast');
}

function IW_loadbgimage() {
        $("#loader div.image").fadeOut(500);
        setTimeout(IW_loadbgimage2, 1000);
}

function IW_loadbgimage2() {                                
	rannum = Math.round(Math.random() * (picturearray.length - 1));
	bgimgurl = picturearray[rannum];
	bgimgtxt = textarray[rannum];
	if (bgimgurl) {
		bgimgurl2 = bgimgurl;
		bgy = parseInt(((screen.height *0.87)/2))-400;
		if(window.screen.width > 1279) {
			replacement = "-large.jpg";
			toreplace = ".jpg";
			bgimgurl2 = "large/"+bgimgurl.replace(toreplace, replacement);
			bgy = parseInt(((screen.height *0.87)/2))-700;
		}
		fullurl = '/images/backgrounds/'+bgimgurl2;
		fullcss = "url(/images/backgrounds/"+bgimgurl2+") 0px "+bgy+"px no-repeat"; //
		if(!$.browser.msie){
				$(img).load(fullurl, '', function() {
				$('#loader').removeClass('loading');
				$("#loader div.image").css("max-height","800px");
				$("#loader div.image").css("height","100%");
				$("#loader div.image").css("width","1050px");
				$("#loader div.image").css("background", fullcss);
				$("#loader div.image").fadeIn(500);
				IW_button();
				}).attr('src', fullurl);
		   } else {
				$('#loader').removeClass('loading');
				$("#loader div.image").css("max-height","800px");
				$("#loader div.image").css("height","100%");
				$("#loader div.image").css("width","1050px");
				$("#loader div.image").css("background", "url(/images/backgrounds/"+bgimgurl2+")"); //"+bgy+"px
				$("#loader div.image").fadeIn(500);
				IW_button();
		   }
			setTimeout(IW_loadbgimage, 7000);
	} else {/**/
		setTimeout(IW_loadbgimage2, 1000);
	}
}

// JQuery custom functions
function getBGimages() {
	if ($.browser.msie){
		if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		} else {// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.open("GET","/images/backgrounds/PhotoGallery.xml",false);
		xmlhttp.send();
		xmlDoc=xmlhttp.responseXML;
		imgarr = xmlDoc.getElementsByTagName("img");
		for (x = 0 ;x < imgarr.length; x++) {
			picturearray.push(imgarr.item(x).attributes[0].value);
			textarray.push(imgarr.item(x).attributes[1].value);
		}
	} else {	
		$.ajax({
			type: "GET",
			url: "/images/backgrounds/PhotoGallery.xml",
			dataType: "xml",
			success: function(xml){
				$(xml).find("img").each(function(){
					picturearray.push($(this).attr("src"));
					textarray.push($(this).attr("alt"));
				});
			}
		});
	}
}

function show_artisttimeline_data_complete() {
	$('.contentscrollpane').jScrollPane({scrollbarWidth:12});
	$(".contentscrollpane").css("padding-bottom", "0px");
	$("#timelinedata").css("visibility", "visible");
	$("#timelinedata p").css("color", "#fff").css("width", "70%");
	$('.contentscrollpane').jScrollPane({scrollbarWidth:12});
	$('.contentscrollpane').animate({top: '0px'});

		var colorcounter = 0;
		var colors = ["#996600", "#669933", "#cc3300", "#0099cc"];
		$(".timelineyears").mouseover( function() {
			 $(this).attr("src", $(this).attr("src").replace(".gif", "o.gif"));
			 $(this).css("cursor", "pointer");
			 // dh = $(document).height() * 0.85;
			 dh = $(".jScrollPaneContainer").height() + 30;//30 = padding offset at top
			 $("#yeardata").empty().remove();
			 for (x = 0; x < 4; x++) {
				var rgbString = $(this).next().css("color"); // get this in whatever way.
				if ($.browser.msie){
					var hexString = rgbString.replace("#", "");
				} else {
					var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
					for (var i = 1; i <= 3; ++i) {
						parts[i] = parseInt(parts[i]).toString(16);
						if (parts[i].length == 1) parts[i] = '0' + parts[i];
					}
					var hexString = parts.join(''); // "0070ff"
					hexString = hexString.substr(-6, 6);
				}
				if (hexString == colors[x].replace("#", "")) {
					colorcounter = x;
				}
			 }
			 
			 $(this).parent().prepend("<div id='yeardata' style='position:absolute; background:url(/images/timeline-quote"+colorcounter+".png) right 8px no-repeat;'><div id='yeardata_inner' style='background-color: "+$(this).next().css("color")+"; '>"+$(this).next().html()+"</div></div>");
			if ($.browser.msie) {
				$("#yeardata").css("font-size", "14px");
			}
			 topofpanel = $(this).offset().top;
			 bottomofpanel = $("#yeardata").height() + topofpanel; 
			 if (bottomofpanel > dh) {
				displacement = dh - bottomofpanel;
				$("#yeardata").css("margin-top", displacement).css("background-position", "right "+(0-displacement+8)+"px");
			 } else {
				bottom = $("#yeardata").height() + topofpanel;
			 }
			 $("#yeardata").fadeIn(1000);
		}).mouseout( function() { 
			$(this).attr("src", $(this).attr("src").replace("o.gif", ".gif"));
			$(this).css("cursor", "default");
			$("#yeardata").fadeOut(1000, function() {$(this).empty().remove()});
		});
}

function show_artisttimeline_data() {
	$("#content-white").css("background-image", "url(/images/artist-background.gif)");
	$("#content-white").css("background-repeat", "repeat");
	$("#timelinedata").css("visibility", "hidden");	
	$("#timelinedata").load("/artist-timeline.htm", '', show_artisttimeline_data_complete);
}

function show_foot_data_complete() {
	$(".contentscrollpane").css("padding-bottom", "170px");
	$("#timelinedata").css("visibility", "visible");
	$('.contentscrollpane').jScrollPane({scrollbarWidth:12});
	$('.contentscrollpane').animate({top: '0px'});
	$("#timelinedata p").css("color", "#000").css("width", "100%");
}

function show_artistessay_data_complete() {
	$(".contentscrollpane").css("padding-bottom", "170px");
	$("#timelinedata").css("visibility", "visible");
	$("#timelinedata p").css("color", "#000").css("width", "100%");
	$("#timelinedata a").hover(function(ev) {
			if (($("#artistpopup").css("display") == "none") || ($("#artistpopup").css("visibility") == "hidden")) {
				$("#artistpopup a").attr("href", $(".artistscroll a").attr("alt"));
				var popupsrc = $(".artistscroll a").attr("href");
				$('<img />')
					.attr('src', popupsrc)
					.load(popupsrc, '', function(){
						if ($('#artistpopup a img').length == 0) {
							$('#artistpopup a').prepend( $(this) );
						}
						// Your other custom code
						$("#artistpopup").show();
						popupwidth = $(this).width()+8;
						popupheight = $(this).height() + 24;
						$("#artistpopup").css("width", popupwidth);
						if ((ev.pageX + (popupwidth/2)) < $(document).width()) {
							if ((ev.pageX - (popupwidth/2)) < 0) {
								$("#artistpopup").css("left", 0);
							} else {
								$("#artistpopup").css("left", ev.pageX - (popupwidth/2));
							}
						} else {
							$("#artistpopup").css("left", ev.pageX - popupwidth + 30);
						}
						if ((ev.pageY + (popupheight/2)) < $(document).height()) {
							if ((ev.pageY - (popupwidth/2)) < 0) {
								$("#artistpopup").css("top", 0);
							} else {
								$("#artistpopup").css("top", ev.pageY - (popupheight/2));
							}
						} else {
							$("#artistpopup").css("top", ev.pageY - popupheight + 30);
						}
						$("#artistpopup").delay(200).css("visibility", "visible");
						$("#artistpopup a").colorbox({ maxWidth: '100%', maxHeight: '100%', scalePhotos: true});
				});
			}
		}
	);
	$("#artistpopup").mouseout(function() {
		$(this).hide();
		$("#artistpopup").css("visibility", "hidden");
		$("#artistpopup a img").remove();
	});
	$('.contentscrollpane').jScrollPane({scrollbarWidth:12});
	$('.contentscrollpane').animate({top: '0px'});
}

function show_artistessay_data() {
	$('#content-white').css("background", "#fff");
	$("#timelinedata").css("visibility", "hidden");
	$("#timelinedata").load("/artist-essay.htm", '', show_artistessay_data_complete);
}

function changemenu(x) {
	switch (x) {
		case 1:
			$("#img-chr").attr("src", "/images/chronology-s.png");
			$("#img-ess").attr("src", "/images/essay-n.png");
			$("#img-chrf").attr("src", "/images/chronfoot-n.png");
			$("#img-essf").attr("src", "/images/essayfoot-n.png");
			show_artisttimeline_data();
			break;
		case 2:
			$("#img-chr").attr("src", "/images/chronology-n.png");
			$("#img-ess").attr("src", "/images/essay-s.png");
			$("#img-chrf").attr("src", "/images/chronfoot-n.png");
			$("#img-essf").attr("src", "/images/essayfoot-n.png");
			show_artistessay_data();
			break;
		case 3:
			$("#img-chr").attr("src", "/images/chronology-n.png");
			$("#img-ess").attr("src", "/images/essay-n.png");
			$("#img-chrf").attr("src", "/images/chronfoot-s.png");
			$("#img-essf").attr("src", "/images/essayfoot-n.png");
			$('#content-white').css("background", "#fff");
			$("#timelinedata").css("visibility", "hidden");
			$("#timelinedata").load("/artist-chronfoot.htm", '', show_foot_data_complete);
			break;
		case 4:
			$("#img-chr").attr("src", "/images/chronology-n.png");
			$("#img-ess").attr("src", "/images/essay-n.png");
			$("#img-chrf").attr("src", "/images/chronfoot-n.png");
			$("#img-essf").attr("src", "/images/essayfoot-s.png");
			$('#content-white').css("background", "#fff");
			$("#timelinedata").css("visibility", "hidden");
			$("#timelinedata").load("/artist-essayfoot.htm", '', show_foot_data_complete);
			break;
	}
}

	
	function hidefirstdot() {
			$("#firstdot").attr("src", $("#firstdot").attr("src").replace("o.gif", ".gif"));
			$("#firstdot").css("cursor", "default");
			$("#yeardata").fadeOut(1000, function() {$(this).empty().remove()});		
	}
	
	function showfirstdot() {
		var colorcounter = 0;
		var colors = ["#996600", "#669933", "#cc3300", "#0099cc"];
		if($("#firstdot").attr("src")) {
			toreplace = ".gif";
			replacement = "o.gif";

			srcfile = $("#firstdot").attr("src").replace(toreplace, replacement);
			 $("#firstdot").attr("src", srcfile);
			 $("#firstdot").css("cursor", "pointer");
			 // dh = $(document).height() * 0.85;
			 dh = $(".jScrollPaneContainer").height() + 30;//30 = padding offset at top
			 $("#yeardata").empty().remove();
			 for (x = 0; x < 4; x++) {
				var rgbString = $("#firstdot").next().css("color"); // get this in whatever way.
				if ($.browser.msie){
					var hexString = rgbString.replace("#", "");
				} else {
					var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
					for (var i = 1; i <= 3; ++i) {
						parts[i] = parseInt(parts[i]).toString(16);
						if (parts[i].length == 1) parts[i] = '0' + parts[i];
					}
					var hexString = parts.join(''); // "0070ff"
					hexString = hexString.substr(-6, 6);
				}
				if (hexString == colors[x].replace("#", "")) {
					colorcounter = x;
				}
			 }
			 
			 $("#firstdot").parent().prepend("<div id='yeardata' style='position:absolute; background:url(/images/timeline-quote"+colorcounter+".png) right 8px no-repeat;'><div id='yeardata_inner' style='background-color: "+$("#firstdot").next().css("color")+"; '>"+$("#firstdot").next().html()+"</div></div>");
			if ($.browser.msie) {
				$("#yeardata").css("font-size", "14px");
			}
			 topofpanel = $("#firstdot").offset().top;
			 bottomofpanel = $("#yeardata").height() + topofpanel; 
			 if (bottomofpanel > dh) {
				displacement = dh - bottomofpanel;
				$("#yeardata").css("margin-top", displacement).css("background-position", "right "+(0-displacement+8)+"px");
			 } else {
				bottom = $("#yeardata").height() + topofpanel;
			 }
			 $("#yeardata").fadeIn(1000);
		setTimeout(hidefirstdot, 5000);
		} else {
			setTimeout(showfirstdot, 1000);
		}
	}
	
function IW_scrollpanel() {
	$(".submenu").css("display", "block");
	$(".submenu").animate({right:680}, 300);
}

function IW_contentappear() {
	if(window.location.pathname == "/artist.htm") {
		show_artisttimeline_data();
	}
	if(window.location.pathname == "/faq.htm") {
		IW_load_faqindex();
	}
	if(window.location.pathname == "/events.htm") {
		IW_load_eventsindex();
		if (IW_querystring_value("pg") == "news") {
			IW_changeeventscontent('/events-news.htm');
		}
	}
	
	$("div.content").css("z-index", "1");
	//$("div.content").delay(500).fadeIn(500);
    //setTimeout(IW_loadbgimage, 3000);
	IW_loadbgimage();
	if((window.location.pathname.indexOf("artist") > -1) || (window.location.pathname.indexOf("event") > -1) || (window.location.pathname.indexOf("faq") > -1)) {
		if(window.location.pathname.indexOf("faq") > -1) {
			IW_changebuttonicons("/images/faq-q-icon.png");
		}
    	setTimeout(IW_scrollpanel, 5000);
	} 
	if((window.location.pathname == "/index-new.htm") || (window.location.pathname == "/")) {
		setTimeout(IW_slidenews, 3000);
	}
	setTimeout(showfirstdot, 5000);
}

// homepage functions
if((window.location.pathname == "/index-new.htm") || (window.location.pathname == "/")) {
	function IW_slidenews() {
		$("#sections").trigger('next');
		$("#sections2").trigger('next');
		setTimeout(IW_slidenews, 3000);
	}
}

if((window.location.pathname.indexOf("artist") > -1) || (window.location.pathname.indexOf("event") > -1) || (window.location.pathname.indexOf("faq") > -1) || (window.location.pathname.indexOf("catalog") > -1)) {
	$(".news_expander").css("display", "inline-block");
}

$(document).ready(function() {
	IW_contentappear();
	//setTimeout(IW_contentappear, 60000);
	if(window.location.pathname.indexOf("event") > -1) {
		$(".list_date").each( function() {
			 var newdate = $(this).html().split("-");
			 var shortArray = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
			 var longArray = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
			 for (var x=0; x < shortArray.length; x++) {
					if (newdate[1] == shortArray[x]) {
						   var newmonth = longArray[x];
					}
			 }
			 $(this).html(newmonth + " " + newdate[0] + ", " + newdate[2]);
		});
	}

	if((window.location.pathname.indexOf("artist") > -1) || (window.location.pathname.indexOf("event") > -1) || (window.location.pathname.indexOf("faq") > -1)) {
		$("#submenu a").each( function() {
			if($(this).attr("href") == window.location.pathname) {
				var submenuimage = $(this).children("img").attr("src").replace("-n", "-s");
				$(this).children("img").attr("src", submenuimage);
			}
		});
	}

	if((window.location.pathname == "/index-new.htm") || (window.location.pathname == "/")) {
		$("#news li .list_more a").each( function() { 
			$(this).attr("href", "javascript:document.location = '/events.htm?pg=news';");
		}); 
	} 

	if((window.location.pathname.indexOf("event") > -1) || (window.location.pathname.indexOf("faq") > -1)) {
		$(".contentscrollpane").css("padding", "0px").css("margin-top", "0px");
		$("#content-white").css("padding-top", "0px");
		IW_makelinksactive();
	}
	
	if((window.location.pathname == "/index-new.htm") || (window.location.pathname == "/")) {
		animatenews(0);
		animateevents(0);
	}
	$(window).resize(function() {
		if ($(window).height() < 487) {
		  $('#footer').css("bottom", $(window).height()-488);
		}
		var footerheight = $(document).height() * .14;
		$('#footer').css("height", footerheight);
	});
	
	getBGimages();
	if (window.location.pathname.indexOf("artist") > -1) {
		$('.artistcontent').jScrollPane({scrollbarWidth:12});
	} 
});
//-->
