var rb = { } rb.dirs = { adverts : 'adverts/', pages : 'pages/' } rb.pages = { article : 'article.php', advert : 'advert.php' } rb.popup = function(url) { var win = window.open(url, 'name','height=400, width=600, resizable, scrollbars'); win.focus(); return false; } rb.pop_advert = function(url) { rb.popup(rb.pages.advert+"?image="+url); } rb.pop_article_show_page = function(page_no, article_id) { var url = rb.pages.article+'?page_no='+page_no+'&article_id='+article_id; rb.popup(url); var url = '?do=pages&page_no='+page_no; setTimeout("rb.redirect('"+url+"')", 500); } rb.pop_article_show_page_keep_articles = function(page_no, article_id) { var url = rb.pages.article+'?page_no='+page_no+'&article_id='+article_id; rb.popup(url); var url = '?do=articles&page_no='+page_no; setTimeout("rb.redirect('"+url+"')", 500); } rb.advert = function(url) { $('#site-advert').html(''); } rb.page = function(url) { $('#site-content').html(''); } rb.redirect = function(url) { location.href = url; } 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; } } $(document).ready(function(){ });