var newwindow;

function poptastic(url, Width, Height) {
	//var Width = 850;
	//var Height = 470;
	var posX=(screen.availWidth-Width)/2;
	var posY=(screen.availHeight-Height)/2;
	// scrollbar-fix for user with low res.
	var bars = (screen.width <= 800) ? 'yes' : 'no';
	var now = new Date();
	newwindow = window.open(url,'thething'+ now.getTime(),'toolbar=no,scrollbars=' + bars +',vscrolling=no,directories=no,resizable=no,menubar=no,width=' +Width+',height='+Height+',screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY+ "');
	if (newwindow && newwindow.open && !newwindow.closed) {
		jump = true;
		var center = screen.width/2;
		var center2 = screen.height/2;
		var middle = center - (Width/2);
		var middle2 = center2 - (Height/2);
		newwindow.moveTo(middle-5,middle2-5);
		newwindow.focus();
	} else {
		jump = false;
	}
	//if (jump) { self.location.href="/"; }
	return false;
}

var xmlhttpFlash;
function sendFlashDataHttp(flashDataUrl)
{
xmlhttpFlash=null;
if (window.XMLHttpRequest)
  {// code for all new browsers
  xmlhttpFlash=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5 and IE6
  xmlhttpFlash=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttpFlash!=null)
  {
  xmlhttpFlash.open("GET",flashDataUrl,true);
  xmlhttpFlash.send(null);
  return true;
  }
else
  {
  return false;
  }
}

function sendFlashData(flashDataUrl)
{
	FlImage1= new Image(1,1);
	FlImage1.src = flashDataUrl;
}

// BEGIN Xtractor client tracker script ------------------------------------------------------

var _pxId = "";
var _pxRegUrl = "http://pxreg.prospectxtractor.se/";

function _pxReg() {
	var img=new Image(1,1);
	img.src=_pxRegUrl+"?"+_pxPar();
	img.onload=function() { _pxVoid(); }
}
function _pxVoid() { return; }
function _pxPar(){
	var p="";
	if (_pxId != "") { p+="&id="+_pxId; }
	p+="&ref="+escape(_pxRef());
	p+="&dt="+escape(document.title);
	p+="&sr="+screen.width+"x"+screen.height;
	p+="&sd="+screen.colorDepth;
	p+="&fv="+_pxFV();
	p+="&pageUrl="+escape(document.location.href);
	p+="&osas_id="+readID();	
	return p;
}
function _pxRef(){
	if (top.document.referrer){
		return top.document.referrer;
	} else{
		return document.referrer;
	}
}
function _pxFV(){
	var f=0,n=navigator;
	if (n.plugins && n.mimeTypes.length) {
		var x=n.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y=x.description;
			f=y.charAt(y.indexOf('.')-1);
		}
	}
	else {
		r=false;
		for(var i=15;i>=3&&r!=true;i-=1){
			execScript('on error resume next: r=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
			f=i;
		}
	}
	return f;
}



// ** ** START Handle OSAS ID ** **

function readID() {
	var expDays = 365; // number of days the cookie should last
	var expDate = new Date();
	expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays));
	var id = GetCookie('osas_id');
	
	if (id == null || id == "no id" || id == "") {
		
		var generated_id = generateId();
		
		id = generated_id;
		
		if (id != GetCookie('osas_id')){
			SetCookie('osas_id', generated_id, expDate);
		}
	}
	
	return id;
}


function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}


function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}


function generateId(){

	var timestamp = new Date().getTime();
	timestamp = timestamp.toString() + "";


	if(timestamp.charAt(0) == '0'){
		timestamp = timestamp.substring(1, timestamp.length);
		timestamp = "1" + timestamp;
	}

	var randomnumber = Math.floor(Math.random()*10);
	var random_temp;
	var return_id = 1;

	for(var i=0;i<4;i++){
		random_temp = Math.floor(Math.random()*10);
		randomnumber = randomnumber + "" + random_temp;
	}

	return_id = timestamp + "" + randomnumber;

	return return_id;
	
}

// ** ** END Handle OSAS ID ** **

_pxId = "52EF2062-6E6B-49A9-AC7D-FC2662D86397"; 
_pxReg(); 

// END Xtractor client tracker script ------------------------------------------------------
