var rb = {  }

$(document).ready(function(){

	$('hr').each(function(){
		$(this).replaceWith('<p style="border:0px; border-bottom:1px dotted #007cc6; " >&nbsp;</p>');
	});
	
	$('img[src$=.png]').ifixpng(); 
	
});

rb.check = function(elem)
{
	var elem_id = $(elem).attr('id');
	
	var errors = "";
	
	$("form[id='"+$(elem).attr('id')+"'] input[accept='true'], form[id='"+$(elem).attr('id')+"'] textarea[accept='true']").each(function(){
		$(this).removeClass('error');
		var mask = $(this).attr('mask');
		
		switch(mask)
		{
		case "email":
			if(!rb.is_email($(this).val())) 
			{
				errors += $(this).attr('alt')+"\n";
				$(this).addClass('error');
				$(this).focus(function(){$(this).removeClass('error');});
			}	
		break; 
		default:
			if($(this).val().length < 1) 
			{
				errors += $(this).attr('alt')+"\n";
				$(this).addClass('error');
				$(this).focus(function(){$(this).removeClass('error');});
			}	
		break;
		}
		
	});
	
	
	if(errors.length < 1) return true;
	alert("Please amend the following before continuing:\n"+errors);
	
	return false;
}

rb.is_email = function(email)
{
	//var email = email.value;
	//var email = document.forms[target].elements[field].value;
	var atSym = email.indexOf('@');
	var dot = email.lastIndexOf('.');
	var space = email.indexOf(' ');
	var len = email.length;
	if (atSym < 1 || dot < atSym || len - dot <= 2 || space != -1) {
		return false;
	}
	else { 
		return true; 
	}
}

rb.encode = function(str) {
		var result = "";
		for (i = 0; i < str.length; i++) {
			if (str.charAt(i) == " ") {
				result += "+";
			}
			else {
				result += str.charAt(i);
			}
		}
		return escape(result);
}

rb.decode = function(str) {
		var result = str.replace(/\+/g, " ");
		return unescape(result);
}

$(document).ready(function(){
	$('div#content img').each(function(){
		var float = $(this).css('float');	
		if(float == 'left') $(this).addClass('image-left');
		if(float == 'right') $(this).addClass('image-right');
	});	
});

