
jQuery(function($){
	
  var url = window.location.href;
  if(url.search("beta=1") != -1) { // BETA MODE  ONLY
	
		// LINK BETA MAKER ****
		$('a').each(function(){
			var link = $(this).attr('href');
			
			if(link.search("lplonline") != -1) {
				if(link.search("=") != -1)
					link += '&beta=1';
				else
					link += '?beta=1';
			
				$(this).attr('href',link);
			}
		});
	
		// CATALOG LINKS TO SPECIAL FRAME (like google image search)  *********
		$('a').each(function() {
			var link = $(this).attr('href');
			if(link.search("minerva") != -1) {
				link = link.replace(/&/g, '$$$');
				link = link.replace('http://','');
				var backurl = url.replace(/&/g, '$$$');
				backurl = backurl.replace('http://','');

				
				$(this).attr('href','http://lplonline.org/apps/item_viewer.php?to=' + link + '&from=' + backurl);
			}
		});

		
  } // END IF BETA;

	var helpForm = '<form id="quickhelp" method="get" action="" style="font-weight:900;font-size:.8em;font-style:italic;background:#F0EFFF;padding:8px;margin:6px 0px;">   How Can We Help You?<br /><textarea name="helptext" style="font-size:1em;height:13px;width:105px;" ></textarea>  <input type="submit" value="ask..." /></form>';
	
	$('div#sidebar').prepend(helpForm);
	
	$('form#quickhelp').bind('submit',function(){
		//var helptext = $(this).find('input[type="text"]').val();
		var helptext = $(this).find('textarea').val();
		window.open('wp-content/themes/lpl/popup_form.php?helptext='+helptext,'form','width=600,height=510,top=100,left=100,location=0,menubar=0,scrollbar=0,status=0,resize=1');
		return false;
	});
  
  $('form#quickhelp textarea').bind('focus',function(){
  
	$(this).animate({height: 140,width:150},400);
  
  });
  $('form#quickhelp textarea').bind('blur',function(){
  
	$(this).animate({height: 13,width:105},400);
  
  }); 
  
  
  
  function changeBanners() {
			$.ajax({
				type: 'get',
				url: 'wp-content/themes/lpl/bannersort.php',
				//data: 'bannersort=1',
				success: function(txt) {
					$('div#banners ul').fadeOut(1000,function(){
						$('div#banners ul').html(txt);
					});
					
					$('div#banners ul').fadeIn(1000);
				}
			});
		}
		
	setInterval(changeBanners,30000); //	30 SECONDS
	
	
	// to use: action link gets [ class="clickOpen" open="foo" ] and target gets [ id="foo" style="display:none;" ] 
	$('.clickOpen').css({'cursor':'pointer','color':'blue','text-decoration':'underline'});
	$('.clickOpen').click(function(){
		var get = '#' + $(this).attr('open');
		var target = $(get);
		if(target.is(':visible'))
			target.slideUp();
		else
			target.slideDown();
			
	});
	
	
// jquery end;
});