﻿
if (document.cookie.indexOf("Kirjattu")==-1) {	
	var customerid;
	var ref;
	var ip;	
    var xmlHttp; 
    if(document.URL.indexOf("/")==-1){
		customerid = document.URL; 
    }else{
		customerid = document.URL.substring(0,document.URL.indexOf("/",7)); 
    }        
    ref = document.referrer;
    ip = "123456";
    document.cookie = "Kirjattu";    
    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        xmlHttp = new XMLHttpRequest();
    }
    url = "http://www.kursori.fi/kseuranta/remotehost.asp";
    //document.write(url)
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange = readData; //Vastauksen käsittely

    function readData() {
        if (xmlHttp.readyState == 4) {			//4=valmis
            ip = xmlHttp.responseText;
            url = "http://www.kursori.fi/kseuranta/kirjaa.asp?customerid=" + customerid + "&ref=" + ref + "&ip=" + ip;
            //document.write(url)
            xmlHttp.open("GET", url, true);
            xmlHttp.send(null);
        }
    }
    
    
    
}

