// JavaScript Document


$(function() {

	// IMAGES WITH ROLLOVERS
	$('.rollover').each(function() {
		var src = $(this).attr('src');
		if (src) {
			var over = src.replace(/(\.){1}(.{3,4})$/, "-over.$2");
			if ($(this).hasClass('active')) $(this).attr('src', over);
			else {
				var pic = new Image();
				pic.src = over; 
				$(this).hover( function() {
					$(this).attr('src', over);
				}, function() {
					$(this).stop(true, false).attr('src', src);
				});
			}
		}
	});
	
	// IF NOT IE, AND NOT 'class="rollover"'
	// ALL OTHER IMAGES NESTED INSIDE AN '<a>' TAG WILL FADE ON ROLLOVER
	if (navigator.appName != 'Microsoft Internet Explorer') {
		$("a img").each( function() {
			var img = $(this);
			if (!img.hasClass('rollover')) {
				img.parents('a').hover( function() {
					img.css({ opacity: 0.5 });
				}, function() {
					img.stop(true, false).css({ opacity: 1.0 });
				});
			}
		});
	}
	
	
	// INPUT TEXT WITH PLACEHOLDERS
	$('.placeholder').each( function() {
		var ph = $(this).addClass('faded').val();
		$(this).bind('focus', function() { if ($(this).val() == ph) $(this).val('').removeClass('faded'); });
		$(this).bind('blur', function() { if ($(this).val() == '') $(this).val(ph).addClass('faded'); });
	});
	
});


$(window).load(function() {

	// ADD FRAME TO IMAGE
	$('img.frame').each( function() {
		var i = $(this);
		if (i.width() > 0) {
			var img = $('<div>').append(i.clone()).remove().html();
			img = img.replace(/class="([^"])*"/, ''); // remove class
			var html =
			'<div class="' + i.attr('class') + '">'+
				'<div class="image">' + img + '</div>'+
				'<div class="shadow">'+
					'<img src="/images/dropshadow.png" width="' + (i.width() + 10) + '" height="10" />'+
				'</div>'+
			'</div>';
			i.replaceWith(html);
		}
	});
	
});

