function xyzPanel(pid, bid, domain, cat, weight, html){ this.pid=pid; this.bid=bid; this.domain=domain; this.cat=cat; this.weight=weight; this.html=html;}
function xyzSite(sid, domain, cat){ this.sid=sid; this.domain=domain; this.cat=cat;}

function externalLinks(){
// Adapted from: http://perishablepress.com/press/2007/11/20/open-external-links-as-blank-targets-via-unobtrusive-javascript/
 if(!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for(var i=0; i<anchors.length; i++){
  var anchor = anchors[i];
  if(anchor.getAttribute('href') && anchor.getAttribute('rel')){
   var relTxt = anchor.getAttribute('rel');
   if(relTxt.indexOf('external') >= 0) anchor.target = '_blank';
  }
 }
}

var alreadyrunflag = 0;
if(document.addEventListener){
 document.addEventListener('DOMContentLoaded', function(){alreadyrunflag=1; externalLinks();}, false);
}else if(document.all && !window.opera){
 document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>');
 var contentloadtag = document.getElementById('contentloadtag');
 contentloadtag.onreadystatechange = function(){
  if(this.readyState=="complete"){
   alreadyrunflag=1;
   externalLinks();
  }
 };
}

window.onload=function(){
 setTimeout("if (!alreadyrunflag){externalLinks();}", 0);
}

function getWeightedKeys(inputA, cat, cookie, domain){
 var wA = new Array();
 for(var k in inputA){
  var theInput = inputA[k];
  if((cat == '' || cat == 'all' || theInput.cat == cat) && (cookie == '' || cookie.indexOf(theInput.pid) < 0) && theInput.weight > 0 && theInput.domain != domain){
   for( var w = 0; w < theInput.weight; w++){
    wA.push(k);
   }
  }
 }
 return jsShuffle(wA);
}

function jsShuffle(a){
 var tmp, current, top = a.length;
 if(top) while(--top){
  current = Math.floor(Math.random() * (top + 1));
  var tmp = a[current];
  a[current] = a[top];
  a[top] = tmp;
 }
 return a;
}

function cleanDomain(domain){
// won't work with e.g. co.uk domains
 var parts = domain.toString().split('.'.toString());
 return parts.slice(-2).join('.');
}

function setCookie(c_name, value, expiredays){
 var exdate = new Date();
 exdate.setDate(exdate.getDate() + expiredays);
 document.cookie = c_name+ '=' +escape(value)+ ((expiredays==null) ? '' : ';expires=' + exdate.toUTCString());
}

function getCookie(c_name){
 if(document.cookie.length > 0){
  c_start = document.cookie.indexOf(c_name + '=');
  if(c_start != -1){
   c_start = c_start + c_name.length+1;
   c_end=document.cookie.indexOf(';', c_start);
   if(c_end == -1) c_end = document.cookie.length;
   return unescape(document.cookie.substring(c_start, c_end));
  }
 }
 return '';
}

var xyzPos = -245;
// var jsPanelCat = 'all';
var cookiesOn = true;

$(document).ready(function() {
 if(cookiesOn == true){
  var rawCookie = getCookie('xyzpanel');
  var xyzCookie = rawCookie.split(',');
 }else{
  var rawCookie = '';
  var xyzCookie = new Array();
 }
 var href = location.href.toLowerCase();
 var protocol = location.protocol.toLowerCase();
 var host = location.host.toLowerCase();
 var pathname = location.pathname.toLowerCase();
 var xyzPanelSite = new xyzSite('', '', 'SPD');
 var xyzPanelCat = '';
 var xyzPanelShow = false;

 var xyzSites = new Array();
// xyzSite(sid, domain, cat)
xyzSites.push(new xyzSite('6ob', '6-of-the-best.net', 'all'));
xyzSites.push(new xyzSite('ads', 'adult-spanking.com', 'all'));
xyzSites.push(new xyzSite('bas', 'bare-ass-spanking.com', 'all'));
xyzSites.push(new xyzSite('bbs', 'bare-bottom-spankings.com', 'all'));
xyzSites.push(new xyzSite('bar', 'barebottom-spanking.com', 'all'));
xyzSites.push(new xyzSite('msp', 'fetish-files.net', 'all'));
xyzSites.push(new xyzSite('fsm', 'fetish-sm.org', 'all'));
xyzSites.push(new xyzSite('fbf', 'free-bdsm-fetish.com', 'all'));
xyzSites.push(new xyzSite('fsg', 'free-spanking-galleries.com', 'all'));
xyzSites.push(new xyzSite('gsp', 'girl-spanking.com', 'all'));
xyzSites.push(new xyzSite('asn', 'kinghost.com', 'all'));
xyzSites.push(new xyzSite('pbk', 'punishment-book.com', 'all'));
xyzSites.push(new xyzSite('sgi', 'spankers-guide.com', 'all'));
xyzSites.push(new xyzSite('snc', 'spanking-caning.com', 'SPD'));
xyzSites.push(new xyzSite('spg', 'spanking-galleries.net', 'all'));
xyzSites.push(new xyzSite('spl', 'spanking-links.net', 'all'));



 var xyzDomain = cleanDomain(host);
 for(var i in xyzSites){
  if(xyzSites[i].domain == xyzDomain){
   xyzPanelSite = xyzSites[i];
   xyzPanelCat = (typeof(wwwPanelCat) == 'undefined')? xyzPanelSite.cat : wwwPanelCat;
   xyzPanelShow = (typeof(wwwPanelShow) == 'undefined')? true : wwwPanelShow;
   break;
  }
 }
// if(typeof(jsPanelCat) != undefined) xyzPanelCat = jsPanelCat;
 if(href.indexOf('showpanel=0') > -1) xyzPanelShow = false;

 var xyzPanels = new Array();
// xyzPanel(pid, domain, cat, weight, html)
xyzPanels.push(new xyzPanel('cfp0', 'cfp0', 'clarefondapass.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=cfp0&bid=cfp0" title="Value for money access to 3, 4 or 5 Clare Fonda spanking sites!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360cfp0.jpg" border="0" alt="Value for money access to 3, 4 or 5 Clare Fonda spanking sites!" /></a>'));
xyzPanels.push(new xyzPanel('csp0', 'csp0', 'cutiespankee.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=csp0&bid=csp0" title="100% original cute Japanese girl spanking!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360csp0.jpg" border="0" alt="100% original cute Japanese girl spanking!" /></a>'));
xyzPanels.push(new xyzPanel('fhv0', 'fhv1', 'firmhandspanking.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=fhv0&bid=fhv1" title="Gorgeous girls, beautiful bottoms, sound spankings!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360fhv1.jpg" border="0" alt="Gorgeous girls, beautiful bottoms, sound spankings!" /></a>'));
xyzPanels.push(new xyzPanel('lup0', 'lup0', 'lupus-spanking.com', 'SPD', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=lup0&bid=lup0" title="The best spanking movies in the world - from Lupus and Rig-East!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360lup0.jpg" border="0" alt="The best spanking movies in the world - from Lupus and Rig-East!" /></a>'));
xyzPanels.push(new xyzPanel('pun0', 'pun0', 'punished-girls.com', 'SPD', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=pun0&bid=pun0" title="High quality on-cam bare bottom spanking & caning!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360pun0.jpg" border="0" alt="High quality on-cam bare bottom spanking & caning!" /></a>'));
xyzPanels.push(new xyzPanel('rlp0', 'rlp0', 'realspankingspass.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=rlp0&bid=rlp0" title="8 sites - unlimited access for around $2.33 daily!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360rlp0.jpg" border="0" alt="8 sites - unlimited access for around $2.33 daily!" /></a>'));
xyzPanels.push(new xyzPanel('sas0', 'sas0', 'spankingshame.com', 'SPD', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=sas0&bid=sas0" title="Spanking & Shame (reloaded) - a world of spanking, shame, humiliation & pain!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360sas0.jpg" border="0" alt="Spanking & Shame (reloaded) - a world of spanking, shame, humiliation & pain!" /></a>'));
xyzPanels.push(new xyzPanel('rus0', 'rus0', 'russian-discipline.com', 'SPD', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=rus0&bid=rus0" title="Download high res 60 min. corporal punishment movies!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360rus0.jpg" border="0" alt="Download high res 60 min. corporal punishment movies!" /></a>'));
xyzPanels.push(new xyzPanel('pun1', 'pun1', 'punished-girls.com', 'SPD', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=pun1&bid=pun1" title="High quality on-cam bare bottom spanking & caning!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360pun1.jpg" border="0" alt="High quality on-cam bare bottom spanking & caning!" /></a>'));
xyzPanels.push(new xyzPanel('gsg0', 'gsg0', 'girlspanksgirl.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=gsg0&bid=gsg0" title="Girl Spanks Girl - Daily updated all F/f spanking movies!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360gsg0.jpg" border="0" alt="Girl Spanks Girl - Daily updated all F/f spanking movies!" /></a>'));
xyzPanels.push(new xyzPanel('aaa0', 'aaa0', 'aaaspanking.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=aaa0&bid=aaa0" title="Triple rated spankings for triple rated girls!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360aaa0.jpg" border="0" alt="Triple rated spankings for triple rated girls!" /></a>'));
xyzPanels.push(new xyzPanel('ppp0', 'ppp0', 'spanking-pass.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=ppp0&bid=ppp0" title="Access 3 exclusive spanking sites with 1 Pass!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360ppp0.jpg" border="0" alt="Access 3 exclusive spanking sites with 1 Pass!" /></a>'));
xyzPanels.push(new xyzPanel('hfp1', 'hfp1', 'herfirstpunishment.com', 'SPD', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=hfp1&bid=hfp1" title="Severe spanking punishments directly from Russia!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/240360hfp1.jpg" border="0" alt="Severe spanking punishments directly from Russia!" /></a>'));
xyzPanels.push(new xyzPanel('1st0', '1st0', '1stchoicespanking.com', 'all', '1', '<a class="panelLink" rel="external" href="http://www.bare-ass-spanking.com/xyzpanel/c.php?sid='+xyzPanelSite.sid+'&pid=1st0&bid=1st0" title="1st Choice Spanking - Welted bare buttocks, thrashed bottoms, hard caning and more!"><img class="panelImg" src="http://www.bare-ass-spanking.com/xyzpanel/pimages/2403601st0.jpg" border="0" alt="1st Choice Spanking - Welted bare buttocks, thrashed bottoms, hard caning and more!" /></a>'));



 if(xyzPanels.length < 1) xyzPanelShow = false;
 if(xyzPanelShow){
  weighted = getWeightedKeys(xyzPanels, xyzPanelCat, rawCookie, xyzPanelSite.domain);
  if(weighted.length == 0){
   xyzCookie = (cookiesOn == true)? xyzCookie.slice(-1) : new Array();
   rawCookie = xyzCookie.join(',');
   weighted = getWeightedKeys(xyzPanels, xyzPanelCat, rawCookie, xyzPanelSite.domain);
  }
  var theXyzPanel = xyzPanels[weighted[0]];
  var timeNow = new Date;
  var blankGifSrc = 'http://www.bare-ass-spanking.com/xyzpanel' + '/v.php?sid=' + xyzPanelSite.sid + '&pid=' + theXyzPanel.pid + '&bid=' + theXyzPanel.bid + '&t=' + timeNow.getTime();
  var blankGif = '<img id="xyzBlank" alt="" src="'+blankGifSrc+'" border="0">';
  if(cookiesOn == true){
   xyzCookie.push(theXyzPanel.pid);
   var xyzCookieStr = xyzCookie.join(',');
   setCookie('xyzpanel', xyzCookieStr, 1);
  }else{
   setCookie('xyzpanel', '');
  }
  $('<style>*:focus{ outline: none;} *::-moz-focus-inner { border: none;} #xyzPanelWrap{ width:265px; height:386px; position:fixed; left:-245px; top:15px; z-index: 9999;} #xyzPanel1{ padding: 0; height:10px; background:transparent url(http://www.bare-ass-spanking.com/xyzpanel/images//panel1.png) no-repeat top right;} #xyzPanel2{ padding: 0 10px; height:360px; background:transparent url(http://www.bare-ass-spanking.com/xyzpanel/images//panel2.png) repeat-y top right;} #xyzPanel3{ padding: 0; height:16px; background:transparent url(http://www.bare-ass-spanking.com/xyzpanel/images//panel3.png) no-repeat top right;} #xyzPanel{ width:240px; height:360px; margin:0; padding:0; color:#000; background:#fff;} #xyzPanelTab{ position:absolute; top:-10px; right:-10px; display:block; width:30px; height:30px; background:transparent url(http://www.bare-ass-spanking.com/xyzpanel/images//paneltab.png) no-repeat -30px -30px; text-decoration:none; outline: none;} #xyzPanelTab.open{ background-position:-26px -30px;} #xyzPanelTab.closed{ background-position:0 0;} a.xyzPanelLink, img.xyzPanelImg{display: block; width: 240; height: 360;}#xyzBlank{ display: block; height: 30px; width: 30px; border: 0; visibility: hidden; outline: none;}</style><div id="xyzPanelWrap" style="left: 0;"><a id="xyzPanelTab" class="open" href="#">'+blankGif+'</a><div id="xyzPanel1"></div><div id="xyzPanel2"><div id="xyzPanel">' + theXyzPanel.html + '</div></div><div id="xyzPanel3"></div></div>').appendTo('body');
  $('#xyzPanelTab').click(function(e) {
   e.preventDefault();
   $('#xyzPanelWrap').animate({ left: xyzPos }, 600, 'linear', function() {
    xyzPos = (xyzPos == 0)? -245 : 0;
   });
   $(this).toggleClass('closed');
  });
// }else{
 }
});

