var collectionon=1;
var collectionnames = new Array("zero","one","two","three");

$().ready(function() {
	$('textarea.rte').each(function(j) {
		if (j==0) {
      $.getScript("/includes/js/fckeditor/fckeditor.js",function() {
        $("textarea.rte").each(function(i) {
          var rte_name = $(this).attr('name');
          var oFCKeditor = new FCKeditor(rte_name);
          oFCKeditor.BasePath='/includes/js/fckeditor/';
          //oFCKeditor.ToolbarSet='GUD';
          oFCKeditor.ToolbarSet='Partial';
          oFCKeditor.Config['ToolbarCanCollapse']=false;
          oFCKeditor.Config['CustomConfigurationsPath']='/includes/js/fckconfig_my.js';
          oFCKeditor.ReplaceTextarea();
        });
			});
		}
	});
  $('.sub_links .face a').click(function() {
		$('.sub_links .face a').removeClass("active");
		$('#splash').attr("class","left flL " + $(this).attr("class"));
		$(this).addClass("active");
		switch ($(this).attr("id")) {
			case "one": collectionon=1; break;
			case "two": collectionon=2; break;
			case "three": collectionon=3; break;
			default: alert("unknown collection: "+$(this).attr("id"));
		}
		return false;
	});
	$('#larrow').click(function() {
		if (collectionon > 1) collectionon--;
		else collectionon = 3;
		fnord(collectionon);
		return false;
	});

	$('#rarrow').click(function() {
		if (collectionon < 3) collectionon++;
		else collectionon = 1;
		fnord(collectionon);
		return false;
	});

	
	narg('#enteremail','EMAIL SIGN UP');
	narg('#enterzip','ENTER ZIPCODE');

	// apply to all png images 
	$('#larrow,#rarrow,#main,#header h1 a').ifixpng('/images/pixel.gif'); 

	//IF IE6 rules
  if (window.attachEvent) {
    //:hover only works on anchor tags in IE 6 and earlier
    //do your best to make the ui work with a:hover before resorting to this
    $('ul.iehover li').each(function() {
      $(this).hover(function(){
        $(this).addClass("hover");
      },function() {
        $(this).removeClass("hover");
      });
    });

  }//end if IE6 rules
	
	$('#fig1hover').hover(function() { $('#fig1data').show(); } ,function() { $('#fig1data').hide(); });
	$('#fig2hover').hover(function() { $('#fig2data').show(); } ,function() { $('#fig2data').hide(); });
	$('#fig3hover').hover(function() { $('#fig3data').show(); } ,function() { $('#fig3data').hide(); });
	$('#fig4hover').hover(function() { $('#fig4data').show(); } ,function() { $('#fig4data').hide(); });

	
});

function fnord(i) {
	$('#'+collectionnames[i]).click();
}

function narg(pattern,text) {
	var tmp = text;
	var foo = $(pattern);
	foo.focus(function() {
		if (foo.val() == tmp) { foo.val(''); }
	});
	foo.blur(function() {
		if (foo.val().match(/^ *$/)) { foo.val(tmp); }
	});
	foo.val(tmp);
}
