var d = new Date();
var sliverHeight = new Array("10","70");
var sliverWidth = new Array("100","140");
var animationSpeed = new Array(500,0,200);
var memberId = "";

// set up a listener to handle mousing over/out of the menu items as well as clicking on the links
$(document).ready(function(){	
	$(".floatingnavitem").hover(function(){
	  	$(this).addClass("floatingnavitemhover");
	},function(){
	  	$(this).removeClass("floatingnavitemhover");
	});
						   
	$(".mainnavitem").hover(function(){
	  	$(this).addClass("mainnavhover");
	},function(){
	  	$(this).removeClass("mainnavhover");
	});	
	
	$(".subnavitem").hover(function(){
	  	$(this).addClass("subnavhover");
	},function(){
	  	$(this).removeClass("subnavhover");
	});
	
	$(".memberthumb").hover(function(){
	  	$(this).addClass("memberthumbhover");
	},function(){
	  	$(this).removeClass("memberthumbhover");
	});
	
	$("#allmembers").hover(function(){
	  	$(this).addClass("allmembershover");
	},function(){
	  	$(this).removeClass("allmembershover");
	});
	
	$(".eventsitem").hover(function(){
	  	$(this).addClass("eventsitemhover");
	},function(){
	  	$(this).removeClass("eventsitemhover");
	});
	
	//$(".blog").click(function(){location.href='http://blog.nysr.com'});
	$(".blog").click(function(){window.open('http://blog.nysr.com')});
	$(".login").click(function(){location.href='http://nysr.com/sitecontrol'});
	$(".join").click(function(){location.href='join.php'});
	
	$(".home").click(function(){location.href='home.php'});
	$(".about").click(function(){location.href='about.php'});	
	$(".members").click(function(){location.href='members.php'});	
	$(".news").click(function(){location.href='news.php'});	
	$(".contact").click(function(){location.href='contact.php'});	
	
	$(".mission").click(function(){location.href='about.php'});
	$(".initiatives").click(function(){location.href='initiatives.php'});
	$(".advocacy").click(function(){location.href='advocacy.php'});
	$(".portfolios").click(function(){location.href='members.php'});	
	$(".become").click(function(){location.href='join.php'});	
	$(".newsitems").click(function(){location.href='news.php'});	
	$(".events").click(function(){location.href='events.php'});	
	
	$(".memberthumb").click(function(){location.href='members_detail.php?a='+this.id+''});
	$(".membername").click(function(){location.href='members_detail.php?a='+this.id+''});
	$("#allmembers").click(function(){history.go(-1)});
	
	//$(".artistsliverworkexpanded").click(function(){location.href='members_detail.php?a='+this.id+''});
	
	$("#slivers li").click(function(){splitslivermemberid = $(this).attr("id").split('-'); location.href='members_detail.php?a='+splitslivermemberid[1]+''});
	
	
	
	
		
	// If we don't have enough slivers to scroll, remove the white fades
	if(hazedisplay == "off"){
		//alert("off");
		$(".scrollercontroltop").hide();
		$(".scrollercontrolbottom").hide();
	}
	
	
	$(".showthumb").click(function(){location.href='members.php?show=thumbnail'});
	$(".showname").click(function(){location.href='members.php?show=name'});
	
	// these are for the news
	$(".cyear").click(function(){location.href='news.php?y='+d.getFullYear()+''});
	$(".year1").click(function(){location.href='news.php?y='+(d.getFullYear()-1)+''});
	$(".year2").click(function(){location.href='news.php?y='+(d.getFullYear()-2)+''});
	$(".archive").click(function(){location.href='news.php?y=a'});	// special case for the archive
	// these are for the events calendar
	$(".cyeare").click(function(){location.href='events.php?y='+d.getFullYear()+''});
	$(".year1e").click(function(){location.href='events.php?y='+(d.getFullYear()-1)+''});
	$(".year2e").click(function(){location.href='events.php?y='+(d.getFullYear()-2)+''});
	$(".archivee").click(function(){location.href='events.php?y=a'});	// special case for the archive
	
	$(".eventsitem").click(function(){showEvent(this.id);});
	
	// get prettyphoto running to open lightboxed images
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// set up the sliver scrolling on the left
	$('#slivers').carouFredSel({
		autoPlay:false,
		direction:'down',
		visibleItems:35,
		scroll:{
			items:1,
			speed:100,
			onBefore : function(oldItems, newItems) {
				oldItems.children(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]});
				//newItems.filter(":first").css("opacity", 1);
        	}
		},
		auto:{
			items:1,
			speed:250
		},
		next:{
			button:$('#slivers_down'),
			key:'up'
		},
		prev:{
			button:$('#slivers_up'),
			key:'down'
		}
	});
	
	

	
	/*$("#slivers li").click(function(){
		
		//If its expanded, go to that members page
		if($(this).height()=="70"){
				var slivermemberid = $(this).attr("id");
				var splitslivermemberid = slivermemberid.split('-');
				//alert(splitslivermemberid[1]);
				location.href='members_detail.php?a='+splitslivermemberid[1]+''
			};
		
		//Resize the slivers
		$('#slivers li .artistsliverwork').each(function(index){
			
			if($(this).height()=="70"){
				$(this).animate({height:sliverHeight[0],width:sliverWidth[0]});
				
			}});
		$(this).children(".artistsliverwork").animate({height:sliverHeight[1],width:sliverWidth[1]});

	});*/


//Hovering



/*$("#slivers li").hover(
  function () {
	  
	  //alert($(this).attr("id"));
	  //var slivermemberid = $(this).attr("id");
		//var splitslivermemberid = slivermemberid.split('-');
		//memberid = splitslivermemberid[1];
	  
	  
	  //if still small, expand
    //if($(this).height()=="10"){alert("expannding")}
	if($(this).height()=="10"){ //Shrink Others
		//$(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]},70);
								//Enlarge THIS
		//$(this).children(".artistsliverwork").animate({height:sliverHeight[1],width:sliverWidth[1]},70);
		$(".artistslivername").css({"color":"#d54828"});
	}
  }, 
  function () {
	  //if still expanded, make small
    //if($(this).height()=="70"){alert("Contracting")}
	if($(this).height()=="70"){//Shrink Others
								//$(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]},70);
								//Shrink THIS
								//$(this).children(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]},70);
								$(".artistslivername").css({"color":"#000000"});
								}
});*/




/*$("#slivers li").hover(
  function () {
	  
	  //alert($(this).attr("id"));
	  //var slivermemberid = $(this).attr("id");
		//var splitslivermemberid = slivermemberid.split('-');
		//memberid = splitslivermemberid[1];
	  
	  
	  //if still small, expand
    //if($(this).height()=="10"){alert("expannding")}
	if($(this).height()=="10"){ //Shrink Others
		$(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0],"margin-top":"0px"},0);
								//Enlarge THIS
		$(this).children(".artistsliverwork").animate({height:sliverHeight[1],width:sliverWidth[1],"margin-top":"-60px"},0);
	}
  }, 
  function () {
	  //if still expanded, make small
    //if($(this).height()=="70"){alert("Contracting")}
	if($(this).height()=="70"){//Shrink Others
								$(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0],"margin-top":"0px"},0);
								//Shrink THIS
								$(this).children(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0],"margin-top":"0px"},0);
								}
});*/
	




//hovering w/ hit zone


$(".sliverhoverhitzone").hover(
  function () {
	  
	  //alert($(this).parent().attr("id"));

	  	//$(".artistsliverwork").stop(true,true);
	  //if still small, expand
    //if($(this).height()=="10"){alert("expannding")}
	if($(this).parent().height()=="10"){ //Shrink Others
								$(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]},70);
								$(".artistslivername").css({color:"#000000"});
								//Enlarge THIS
								$(this).parent().children(".artistsliverwork").animate({height:sliverHeight[1],width:sliverWidth[1]},70);
								$(this).parent().children(".artistslivername").css({color:"#d54828"});
								}
  }, 
  function () {
	  	 // alert($(this).parent().attr("id"));
	  	$(".artistsliverwork").stop(true,true);
	  //if still expanded, make small
    //if($(this).height()=="70"){alert("Contracting")}
	if($(this).parent().height()=="70"){//Shrink Others
	
								$(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]},40);
								$(".artistslivername").css({color:"#000000"});
								//Shrink THIS
								$(this).parent().children(".artistsliverwork").animate({height:sliverHeight[0],width:sliverWidth[0]},40);
								$(this).parent().children(".artistslivername").css({color:"#000000"});
								}
});




});




//Previous and next links
	function memPrev(a){
		//var memberpage = parseInt(memberid);
		//if(memberpage == 1){
			//location.href='members_detail.php?a='+(membersdetailarraylength)+''
		//}else{
			location.href='members_detail.php?a='+a;
		//}
	}
		
	function memNext(a){
		//var memberpage = parseInt(memberid);
		//if(memberpage == membersdetailarraylength){
			//location.href='members_detail.php?a=1'
		//}else{
		location.href='members_detail.php?a='+a;
		//}
	}
	




// this function will handle when events are clicked on in the calendar
// a = the id of the event the user clicked on
function showEvent(a){
	$(".eventsitemactive").each(function(){$(this).removeClass("eventsitemactive");});
	$("#"+a).removeClass("eventsitemhover");
	$("#"+a).addClass("eventsitemactive");
	var posA = $("#"+a).position();
	var posB = $("#eventsdetails").position();
	var eid = a.split("_");
	$('#eventsdetails').fadeOut(animationSpeed[2],function(){
		$('#eventsdetails').load("_libraries/php/eventdetails.php?id="+eid[1],function(){
			$('#eventsdetails').css({'marginTop':(posA.top-posB.top)});
			$('#eventsdetails').fadeIn(animationSpeed[2]);
		});
	});
}

// this function will obscure email addresses from spam bots
function jemail(user, domain, suffix, linkText, cssClass){
	var cssText = "";
	if(cssClass){
		cssText = ' class="'+cssClass+'"';
	}
	if(linkText){
		document.write('<a href="'+'mailto:'+user+'@'+domain+'.'+suffix+'"'+cssText+' title="click here to send an email">'+linkText+'</a>');
	}
	else{
		document.write('<a href="'+'mailto:'+user+'@'+domain+'.'+suffix+'"'+cssText+' title="click here to send an email">'+user+'@'+domain+'.'+suffix+'</a>');
	}
}
