//BANNERSYSTEM JAVASCRIPT FIL
//DANIEL LINDSTEDT 2009-01-26

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.toGMTString());
}
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 "";
}

function checkCookie()
{
cookie=getCookie('fabasAd');
if (cookie==null || cookie=="")
{
cookie = ((new Date()).getTime() + "" + Math.floor(Math.random() * 1000000)).substr(0, 18);
setCookie('fabasAd',cookie,365);

}
}
checkCookie();

cookie=getCookie('fabasAd');

function sendRequest(url, poststr){
document.write('<iframe id="bannerFrame" width="'+iframeWidth+'" src="'+url+'?fabasAd='+cookie+'&'+poststr+'" frameborder="0" height="'+iframeHeight+'" marginwidth="0" marginheight="0" scrolling="no" style="border:'+borderSize+'px solid '+borderColor + '"  allowtransparency="true"></iframe>');
}			
	  var theText = '';
	  var bannerWords = bannerWords;
	  if(bannerWords != '0'){theText += ' '+bannerWords;}
	  var poststr = "p=" + encodeURI( bannerPlace ) +
	  				"&sI=" + encodeURI( sajtId ) +
					"&pS=" + encodeURI( placeSlots ) +
					"&oB=" + encodeURI( orderBanner ) +
					"&bS=" + encodeURI( bannerSpace ) +
					"&bW=" + encodeURI( theText );
	  sendRequest('http://ad.fabas.se/getBanner.php', poststr);
