$(function() {
	
	$("input.watermark").each(function(idx) {
		
		var me = $(this);
		
		if (me.attr("type") == "password") {
			me.after("<input type='text' value='" + me.attr("title") + "' class='watermark input passholder' />");
			me.hide();
			me = me.next();
		}
		
		me.val($(this).attr("title"));
		
		me.focus(ClearWatermark);
		$(this).blur(RemoveWatermark);
		
	});
	
});

var h1 = { src: 'http://biz.zipinstallation.com/fonts/h1.swf' };
var h2 = { src: 'http://biz.zipinstallation.com/fonts/h2.swf' };
var phoneseg = { src: 'http://biz.zipinstallation.com/fonts/h1.swf' };

sIFR.activate(h1);
sIFR.activate(h2);
sIFR.activate(phoneseg);

sIFR.replace(h1, {
	selector: '#content h1',
	wmode: 'transparent',
	css: '.sIFR-root { color: #1f78b4; }',
	tuneHeight: 0,
	selectable: true,
	offsetTop: 0
});

sIFR.replace(h2, {
	selector: '#content h2',
	wmode: 'transparent',
	css: '.sIFR-root { color: #000000; }',
	tuneHeight: -5,
	selectable: true,
	offsetTop: 0
});

sIFR.replace(h2, {
	selector: '#content h3',
	wmode: 'transparent',
	css: '.sIFR-root { color: #000000; }',
	tuneHeight: -5,
	selectable: true,
	offsetTop: 0
});

sIFR.replace(phoneseg, {
	selector: '.phoneseg',
	wmode: 'transparent',
	css: '.sIFR-root { color: #BCD7E9; }',
	tuneHeight: -5,
	selectable: true,
	offsetTop: 0
});


function ClearWatermark() {
	var me = $(this);
	
	if (me.hasClass("passholder")) {
		me = $(this).prev();
		$(this).hide();
		me.addClass("selected");
		me.show();
		me.focus();
	}
	
	if (me.val() == me.attr("title")) {				
		me.val("");
		me.addClass("selected");
	}
}

function RemoveWatermark() {
	var me = $(this);
				
	if (me.val() == "") {
		me.val(me.attr("title"));
		
		if (me.attr("type") == "password")
			me.hide().next().show();
		else
			me.toggleClass("selected");
	}
	
}
