function get_username() {

    if (document.cookie.length > 0) {
        begin = document.cookie.indexOf("bcom_registered_username=");
        if (begin != -1) {
            begin += "bcom_registered_username=".length;
            end = document.cookie.indexOf(";", begin);
            
            if (end == -1) {
                end = document.cookie.length;
            }
    
            return unescape(document.cookie.substring(begin, end));
        }
    }
    
    return null;
}

function has_username() {

    if (get_username() == null) {
        return false;
    }
    
    return true;
}


/* OAS Adspot list, will use the most exact match based off the current url.
 * Set new items by adding new lines using following the describe format:
 *
 *      adspots["/relative/location"] = "Adspot1,Adspot2,AdspotN";
 */
    var adspots = new Object();
    adspots["/"]                      ="Top,TopRight,Position1,Position2,x30";
    adspots["/viewclassifieds"]       = "Top,TopRight";
    adspots["/"]                      = "Top,TopRight,Position1";
    adspots["/viewclassifieds"]       = "Top,TopRight,Position1";
    adspots["/business/"]             = "Top,BottomLeft";
    adspots["/blog/"]                 = "Top";
    adspots["/searchbusinesses/"]     = "Top,BottomLeft";

//Determines what adspot list to use 
var loc = (document.location + "").toLowerCase();
var lastposition = -1;
var listpos = '';

// let's see if 'home/' is already in the URL

 
// makes the location consistent
if (-1 == loc.indexOf('home')){
  loc = loc + 'home/';
}

if( '/home' == loc.substr(((loc.length) - 5)) ){
  loc = loc + '/';
}

for( var i in adspots ) {

    var position = loc.indexOf( linkurl + i );

    if( position != -1 && i.length > lastposition ) {

        lastposition = i.length;
        listpos = adspots[i];
    }
}
OAS_listpos = listpos;
// Configuration Variables
OAS_url = 'http://oascentral.bakersfield.com/RealMedia/ads/';
OAS_query = ''; 

OAS_target = '_top';

// end of configuration

OAS_rn = new String (Math.random()); OAS_RNS = OAS_rn.substring (2, 11);

function OAS_NORMAL(pos) {
  document.write('<A HREF="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_RNS + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" TARGET=' + OAS_target + '>'); 
} 
  
if (navigator.userAgent.indexOf('Mozilla/3') != -1 || navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1){
  OAS_version = 10; 
} else {
  OAS_version = 11;
}
 
if (OAS_version >= 11){
  document.write('<SCRIPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_RNS + '@' + OAS_listpos + '?' + OAS_query +'"><\/SCRIPT>'); 
}
 
function OAS_AD(pos) {
if (OAS_version >= 11)
  OAS_RICH(pos); 
else 
  OAS_NORMAL(pos);
} 
