var _fan = new Object({

	version: "1.0",

	pixpath: ((/^https/i.test(window.location.protocol) ? 'https' : 'http') + '://' + 'trgc.opt.fimserve.com/fp.gif' + '?'),

	w: window,

    d: document,

    n: navigator,

	profile: function() {

		d = f.n;

		c = f.w;

		var s = [d.appName, d.version, d.language ? d.language: d.browserLanguage, d.platform, d.userAgent, d.javaEnabled() ? 1: 0];

		if (c.screen) {

			s.push(c.screen.width + "x" + c.screen.height);

			s.push(c.screen.colorDepth);

        } else if (c.java) {

            l = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

            s.push(l.screen.width + "x" + l.screen.height);

        }

		s.push(d.referrer ? d.referrer: "");

		return s;

	}

});

_fan.pixel = function(pid) {

	var a = this;

	f = _fan;

	var fields = {};

	fields.pixelid = pid;

	//fields.browser_profile = f.profile();

	a.setKW = function(s) {

		if (typeof s != "string") return false;

		fields.sdrowyek = s;

		return true;

	};

	a.setUID = function(s) {

		if ((typeof s != "number")&&(typeof s != "string")) return false;

		fields.diresu = s;

		return true;

	};

	a.setUA = function(s) {

		if (typeof s != "number") return false;

		fields.egaresu = s;

		return true;

	};

	a.setUG = function(s) {

		if (typeof s != "number") return false;

		fields.rednegresu = s;

		return true;

	}

	a.setD = function(s) {

		fields.atad = s;

		return true;

	}

	a.init = function() {

		// attach to onload event

		if (window['attachEvent']) {

			window.attachEvent('onload', a.persistEvent);

		} else {

			window.addEventListener('load', a.persistEvent, false);

		}

	};

	a.persistEvent = function() {

		var query = [];

		fields.rnd = Math.round(Math.random()*(new Date()).valueOf())

		for (var i in fields) if (fields.hasOwnProperty(i)) {

			query.push(i + '=' + encodeURIComponent(fields[i]));

		}

		(new Image(1,1)).src = f.pixpath + query.join('&');

	}

	a.trackPageView = function() {

		a.init();

	};

	a.trackEvent = function(category, action) {

		if(!category && !action) return false;

		fields.category = category;

		fields.action = action;

		a.persistEvent();

		return true;

	}

	a.getVersion = function() {

        return _fan.version;

    };

	return a;

};



_fan.getPixel = function(pid) {

	var a = new _fan.pixel(pid);

    return a

}



// decide if we should instaciate pixel using globals

try{

if("undefined" != typeof _fanpid) {

var p = _fan.getPixel(_fanpid);

if("undefined" != typeof _fankw)

p.setKW(_fankw);

if("undefined" != typeof _fanuid)

p.setUID(_fanuid);

if("undefined" != typeof _fanua)

p.setUA(_fanua);

if("undefined" != typeof _fanug)

p.setUG(_fanug);

if("undefined" != typeof _fand)

p.setD(_fand);

p.persistEvent();

}

}catch(err){}