$(function(){
	$('#nav > ul > li > a').textShadow({
	color:   "#000",
	xoffset: "24px",
	yoffset: "3px",
	radius:  "0",
	opacity: "30"
});
 	
	
 
 	$('.question').append('<a href="#" class="questionPlus" >click for answer</a>');

 
 $(".questionPlus").click(function() { 
 	if ($(this).parent().next('.answer').is(":hidden")) {
      $(this).text('click to close').parent().next('.answer').slideDown();
	  return false;
	} else {
		$(this).text('click for answer').parent().next('.answer').slideUp();
		return false;
	}
    });



});



//AJAX art details load
function getArt(str,w,h) { 
if (str != ""){
 // {
 // $("#displayart").html("");
  		//return;
  //} else {
	  
	 
	  
	 var ajax_string = "ajax-art.php?id=" + str;
	 if(w != '0' && w != undefined){
		ajax_string += "&w=" + w;
	 }
	  if(h != '0' && w != undefined){
		ajax_string += "&h=" + h;
	 }
	  
	$('#displayart').load(ajax_string, function() {
		//$("#displayart").fadeOut(30).fadeIn(220); 

		
	
	});
  }
}//end getArt function




$(function() {
		
		$('body').append("<div id='zoom'><div id='zoomContainer'></div></div>");
		
		//used for blowing up small image - blurry
		$("#getzoomsm").live('click', function(){
			//$(this).fancybox();
			var img = $(this).children('img');
			var imgWidth = img.width();
			var imgHeight = img.height();
			var container = $('#zoomContainer');
			img.clone().appendTo(container);
			
				if (imgWidth > imgHeight){
					//container.css({'width':'100%', 'height':'100%'});
					container.children('img').css({'width':'100%', 'height':'auto'});
				} else if (imgWidth < imgHeight) {
				
					//container.css({'width':'100%', 'height':'100%'});
					container.children('img').css({'width':'auto', 'height':'100%'});
					
				} else {
				 
					//container.css({'width':'100%', 'height':'100%'});
					container.children('img').css({'width':'auto', 'height':'100%'});
					
				}
			container.append('<br /><span>CLOSE WINDOW</span>');	
			$('#zoom').fadeIn();
			
			return false;	
    	});
    	
		
		
		//used if a large image is detected
		$("#getzoom").live('click', function(){
			//$(this).fancybox();
			var img = $(this).find('a').attr('href');
			var container = $('#zoomContainer');
			container.html('<img src="' + img + '" />');
			
			container.append('<br /><span>CLOSE WINDOW</span>');	
			$('#zoom').fadeIn();
			
			return false;	
    	});
    	
    	$('#zoom').click(function(){
    		$(this).fadeOut().children('div').empty();
    	});
		
		
		

//check if it exists otherwise it will error with an offset message
if ($("#displayart").length > 0){
	
    var $sidebar   = $("#displayart"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 15;

    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });
 } //  #displayart	actuall exists
 
 
 //check if it exists otherwise it will error with an offset message
if ($("#scrollingDiv").length > 0){
	
    var $sidebar   = $("#scrollingDiv"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 0;

    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });
 } //  #displayart	actuall exists
 
	
	
	
	
	
	
 
});



//submit form by hitting enter for all browsers
$(function(){
    $('input').keydown(function(e){
        if (e.keyCode == 13) {
            $(this).parents('form').submit();
            return false;
        }
    });
});


//clear search fields on click
function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}


//pop up window
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//validation
function tmt_lenValidator(f,sp,ep,ks,eMsg){
	var str;var myErr="";var re=/^(\s*)$/;fv=MM_findObj(f).value;
	if(ks){if(re.test(fv)){fv=fv.replace(re,"");}}
	if(fv.length<sp||fv.length>ep){alert(unescape(eMsg));myErr += 'eMsg';}
	document.MM_returnValue=(myErr=="");
}

