// DEFAULT LINK
// Link object (in case links script doesn't load
 if(!window.Link) function Link(cat,flg,url,src,ht,wd,ttl,alt,dsc,wgt){ this.cat=cat; this.flg=flg; this.url=url; this.src=src; this.ht=ht; this.wd=wd; this.ttl=ttl; this.alt=alt; this.dsc=dsc; this.wgt=wgt;}
// Note: categories fe=fetish, bd=bdsm, as=asian, sp=spanking, fd=femdom, ge=general etc.
// Note: weightings 3=top, 2=medium, 1=low, 0=off (in fact any weighting is possible)
// Note: flag 4=A1+! 3=hot!, 2=cool!, 1=new!, 0=blank

if(!window.cspLink) var cspLink=new Link('sp',4,'http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=924153-0000&PA=469062&BAN=0','470062csp.gif','62','470','Cutie Spankee','100% original cute Japanese girl spanking!','100% original cute Japanese skoolgirls, maids & secretaries spanked, caned paddled or whipped. 1,000s of original oriental punishment movies & pics, weekly updates.',4);

// FLAGS
flgA = new Array();
flgA[flgA.length]=''; // 0 = no flag
flgA[flgA.length]='New'; // 1
flgA[flgA.length]='Cool'; // 2
flgA[flgA.length]='Hot'; // 3
flgA[flgA.length]='A1'; // 4


var rndCsp = '000' + Math.floor(Math.random()*188);
var rndCspScr = 'csp/p'+rndCsp.substr(-3,3)+'.jpg';
var rndCspImg = new Image();
rndCspImg.src = rndCspScr; // Preloads image

// Toplists (editable)
if(window.tplA && tplA.length > 0){
 if(!window.noofTpl) var noofTpl = 3; // no of tpls
 var tplId='aspankee'; // id for toplists
 tplIds = new Array();
 for(i = 0; i < tplA.length; i++){
  tplA[i].href = tplA[i].href.toString().replace(/DefaultID/,tplId);
  tplIds[tplIds.length] = i;
 }
 tplA.sort(randOrd);
 tplStr = '<div class="tplDiv">';
 for(i = 0 ;i < noofTpl; i++){
  myTpl = tplA[i];
  tplStr += '<a class="tplLnk" href="'+myTpl.href+'" rel="external">'+myTpl.txt+'</a>';
  if(i < noofTpl-1) tplStr += ' ';
 }
 tplStr += '</div>';
}

// Sponsors (editable)
if(window.spoA && window.spoA.length > 0){
 if(!window.noofSpo) var noofSpo = 10;
 var weightedA = getWeightedIndices(spoA,'sp',2);// Generate weighted array
 for(var i = 0; i < noofSpo; i++){
  var selectedIndex = 0;
  var theLink = cspLink;
  if(window.weightedA){
   selectedIndex = Math.floor(Math.random()*weightedA.length);
   theLink = spoA[weightedA[selectedIndex]];
  }
  eval('var spo'+i+'Str = \''+makeSpoDiv(theLink)+'\';');// make spo ad
  if(window.weightedA){
   weightedA = filterArray(weightedA[selectedIndex],weightedA); // Remove all instances of selected
   if(weightedA.length < 1) weightedA = getWeightedIndices(spoA,'sp',2); // Regenerate weighted array
  }
 }
}else{
 for(var i = 0; i < 10; i++){
  eval('var spo'+i+'Str = \''+cspStr+'\';');// default to csp ad
 }
}

// NO EDITING REQUIRED BELOW THIS LINE
function randOrd(){
 return (Math.round(Math.random())-0.5);
}

function writeSlot(str){
 writeStr = eval(str+'Str');
 document.write(writeStr);
}

function makeSpoDiv(theLink){
 var flagTxt = (theLink.flg == 4 ? flgA[theLink.flg]+'+!' : flgA[theLink.flg]+'!');
 var theStr = '<div class="spoDiv">';
 theStr += '<a href="'+theLink.url+'" title="'+theLink.alt+'" rel="external"><b>'+theLink.ttl+'</b></a>';
 theStr += (theLink.flg>0 ? '&nbsp;<span class="flag '+flgA[theLink.flg]+'">'+flagTxt+'</span>' : '');
 theStr += '<br><a href="'+theLink.url+'" title="'+theLink.alt+'" rel="external nofollow">';
 theStr += '<img src="'+spoDir+theLink.src+'"';
 theStr += ' height="'+theLink.ht+'" width="'+theLink.wd+'" border="0" alt="'+theLink.alt+'">';
 theStr += '</a><br>'+theLink.dsc+'</div>'
 return theStr;
}

function randOrd(a, b){return (Math.round(Math.random())-0.5);}

function getWeightedIndices(unweightedA,cat,wgt){
// source array, category, minimum weight
 var re_cat = new RegExp('(^|\\s)' + cat + '($|\\s)', 'g');
 weightedA = new Array();
 for(a=0;a<unweightedA.length;a++){
  thisLink = unweightedA[a];
  if(cat.search(re_cat) != -1 && thisLink.wgt >= wgt){
   for(w=0;w<thisLink.wgt;w++){
    weightedA[weightedA.length] = a;
   }
  }
 }
 return weightedA;
}

function filterArray(theIndex,inA){
 outA = new Array();
 for(f=0;f<inA.length;f++){
  if(inA[f] != theIndex) outA[outA.length] = inA[f];
 }
 return outA;
}

// Add to favorites
var favStr = '<span class="bt">Bookmark this page (CTRL-D)</span>';
if(window.sidebar || window.external || (window.opera && window.print)){
 var favLinkTxt = (window.external)? 'Add site to favorites' : 'Bookmark this site';
 favStr = '<a class="bt" href="javascript:addBookmark(\''+site+'\',\''+homeUrl+'\')">'+favLinkTxt+'</a>';
}

function addBookmark(title,url){
 if(window.sidebar){
  window.sidebar.addPanel(title,url,'');
 }else if(window.external){
  window.external.AddFavorite(url,title);
 }else if(window.opera && window.print){
  var elem = document.createElement('a');
  elem.setAttribute('href',url);
  elem.setAttribute('title',title);
  elem.setAttribute('rel','sidebar');
  elem.click();
 }else{
  return true;
 }
}

var emailUrl = 'http://www.fetish-sm.org/acf_asianspankee/';

// Popups
function popEmail(){
 sndEml=window.open(emailUrl,"email_pop","width=440,height=230");
 return false;
}

