var SysreqManager = SysreqManager || {};

SysreqManager.PluginVersion='0.52.0001';
SysreqManager.IsPluginInit=false;
SysreqManager.IsOldPlugin=false;
SysreqManager.DataUrl='http://st.playfast.ru/all_requirements.xml';
SysreqManager.CurrentGameReq=null;
SysreqManager.CurrentGameReqTemplate='<tr><td><a href="{url}">{name}</a></td><td><img src="{cur_page}/skins/img/glob_img/{src}.png" width="16" height="16" alt="" /></td></tr>';

SysreqManager.PluginInit = function(){
    if(drm.initialize()){
    	SysreqManager.IsPluginInit = true;
    	if(ProdownFrame.getVersion()<SysreqManager.PluginVersion){
    		SysreqManager.IsPluginInit = false;
    		SysreqManager.IsOldPlugin = true;
    	}else{
    		if(String.IsNullOrEmpty(drm.getHardwareId())){
    			SysreqManager.IsPluginInit = false;
                SysreqManager.IsOldPlugin = true;
    		}
    	}
    }
    else $('#retest_but').hide();
};
SysreqManager.GetData = function(){
    var result = drm.testRequirements(SysreqManager.DataUrl, null);
    var data;
    if(window.ActiveXObject){
        data = new ActiveXObject('Microsoft.XMLDOM');
        data.async = false;
        data.loadXML('<?xml version="1.0" encoding="utf-8"?>\n'+result);
    } else data = result;
    return data;
};
SysreqManager.Check = function(){
    var data = SysreqManager.GetData();
    var result = new Array();
    $('Requirements > File', data).each(function(i, _item){
        var item = $(_item);
        var name = item.attr('name');
        var status = item.attr('ok')=='true';
        var url = item.attr('cure');
        if(SysreqManager.CurrentGameReq.contains(name)){result.push({name: name, status: status, url: url});}
    });
    var name = '';
    var status = '';
    var url = '';
    $('Or > File', data).each(function(i, _item){
        var item = $(_item);
        name = item.attr('name');
        var status_temp = item.attr('ok')=='true';
        url = item.attr('cure');
        if(status_temp) status = 'true';
    });
    if(SysreqManager.CurrentGameReq.contains(name)){result.push({name: name, status: status, url: url});}
    return result;
};
SysreqManager.FillGameReq = function(){
    if($('#sw_check').length>0){
        var showRetestBut = false;
        var result = String.Empty;
        var data = SysreqManager.Check();
        for(var i=0;i<data.length;i++){
            if(!data[i].status)showRetestBut = true;
            result += SysreqManager.CurrentGameReqTemplate.template({
                cur_page: cur_page,
                url:data[i].url,
                name: data[i].name,
                src: data[i].status ? 'accept' : 'cancel'
            });
        }
        if(!result.IsEmpty()){
            $('#sw_check').html(result);
            if(!showRetestBut)$('#retest_but').hide();
        }
        else $('#retest_but').hide();
    }
};
$(document).ready(function(){
    SysreqManager.PluginInit();
    var sysreqContainer=$('#sw_curent_game');
    if(sysreqContainer.length>0)SysreqManager.CurrentGameReq=sysreqContainer.val().split(',');
    SysreqManager.FillGameReq();
});
;Array.prototype.contains=function(element){for(var i=0;i<this.length;i++){if(this[i]==element){return true;}}return false;};

;Number.prototype.Numeral = function(string1, string2, string3)
{
    var ost10 = this % 10;
    var ost100 = this % 100;
    if (ost10 == 1 && ost100 != 11) { return string1; }
    if (ost100 > 11 && ost100 < 15) { return string3; }
    if (ost10 > 1 && ost10 < 5) { return string2; }
    return string3;
};
Number.prototype.Pixels=function(){return '{value}px'.template({value: parseInt(this)});};
;String.Empty='';
String.prototype.template=function(obj){return this.replace(/{([^{}]+)}/g,function(full,word){return((typeof obj[word]==='string'||typeof obj[word]==='number')?obj[word]:full);});};
String.IsNullOrEmpty=function(s){if(s == null) return true;return $.trim(s)==String.Empty;};
String.prototype.IsEmpty=function(){return String.IsNullOrEmpty(this);};
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,String.Empty);};
String.prototype.isEmailAddress=function(){return this.IsEmpty()||(/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(this);};
String.RandomString = function(string_length){
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var randomstring = String.Empty;
    for (var i=0;i<string_length;i++)
    {
        var rnum = Math.floor(Math.random()*chars.length);
        randomstring += chars.substring(rnum, rnum + 1);
    }
    return randomstring;
};
;Boolean.parse=function(b){var a=b.trim().toLowerCase();if(a==="false")return false;if(a==="true")return true};
;var Effects = Effects || {};
Effects.Shake = function(container) {
    if ($(container).css("left").indexOf('%') != "-1" ) {
        var maringLeft = $(container).css("margin-left");
        maringLeft = maringLeft.substring(0, (maringLeft.length - 2));
        $(container).css("left", ($(container).offset().left - maringLeft) * 1 + "px");
    }
    $(container).animate({ left: "+=10px" }, 50, 'linear')
                .animate({ left: "-=20px" }, 50, 'linear')
                .animate({ left: "+=10px" }, 50, 'linear');
};
;var Cookie = Cookie || {};
Cookie.BaseName = 'account';
Cookie.Get = function(name) {
	try{return $.parseJSON($.cookie(name));}
	catch(err){$.cookie(name, null);return null;};
};
Cookie.Set=function(name, value, params){$.cookie(name, $.toJSON(value), params);};
Cookie.Delete=function(name, params){$.cookie(name, null, params);};
;/* please do not use this function for Cookie, use Cookie.fn instead */
Function.createDelegate=function(a,b){return function(){return b.apply(a,arguments)}};
Function.createCallback=function(b,a){return function(){var e=arguments.length;if(e>0){var d=[];for(var c=0;c<e;c++)d[c]=arguments[c];d[e]=a;return b.apply(this,d)}return b.call(this,a)}};
Function.emptyFunction=Function.emptyMethod=function(){};
function ReloadWindow(url,pluginReload){
    if(pluginReload && navigator.plugins.refresh)navigator.plugins.refresh(false);
    if(String.IsNullOrEmpty(url))window.location.reload();
    else window.location=url;
};
function isEnterKey(e){return(e.keyCode?e.keyCode:e.which)==13;};

;var Events = Events || {};
Events.Download = {Plugin: 'Download.Plugin'};
Events.Game = {Play: 'Game.Play', Tracker: 'Game.GameTracker', Buy: 'Game.Buy', Rent: 'Game.Rent', ShortPlay: 'Game.ShortPlay', LongPlay: 'Game.LongPlay', Details: 'Game.Details', DetailsDemo: 'Game.DetailsDemo', PluginTrue: 'Game.PluginTrue', PluginFalse: 'Game.PluginFalse', SysReqTrue: 'Game.SysReqTrue', SysReqFalse: 'Game.SysReqFalse', SysReqFalseOverride: 'Game.SysReqFalseOverride'};
Events.Login = {PageSubmit: 'Login.PageSubmit', PageSuccess: 'Login.PageSuccess', PageFail: 'Login.PageFail', WizardOpen: 'Login.WizardOpen', WizardSubmit: 'Login.WizardSubmit', WizardSuccess: 'Login.WizardSuccess', WizardFail: 'Login.WizardFail', WizardCancel: 'Login.WizardCancel'};
Events.Register = {PageOpen: 'Register.PageOpen', PageSubmit: 'Register.PageSubmit', PageSuccess: 'Register.PageSuccess', PageFail: 'Register.PageFail', WizardOpen: 'Register.WizardOpen', WizardSubmit: 'Register.WizardSubmit', WizardSuccess: 'Register.WizardSuccess', WizardFail: 'Register.WizardFail', WizardCancel: 'Register.WizardCancel'};
Events.Buy = {Open: 'Buy.Open', Close: 'Buy.Close', WebMoney: 'Buy.WebMoney', YandexMoney: 'Buy.YandexMoney', Qiwi: 'Buy.Qiwi', MoneyMail: 'Buy.MoneyMail', RbkMoney: 'Buy.RbkMoney', W1: 'Buy.W1', PromoCode: 'Buy.PromoCode', Sms: 'Buy.Sms', Success: 'Buy.Success', Fail: 'Buy.Fail'};
Events.Consultant = {Click: 'Consultant.Click'};
;function UserManager(){this.init();};
UserManager.prototype = {
    init: function(){
        this.onLoginSuccess = Function.createDelegate(this, this.OnLoginSuccess);
        this.onRegSuccess   = Function.createDelegate(this, this.OnRegSuccess);
    },
    OnLoginSuccess: function(response, type, onSuccess, onFail){
        if(response=='OK'){
            $.ajax({
    			type: "GET",
    			url: '{cur_page}/classes/auth.php?a=login&lang={lang}'.template({
    				cur_page: cur_page,
                    lang: language
    			}),
    			success: function(data){onSuccess(data);},
                error: WindowManager.ShowErrorWindow
    		});
    	}
        else {
            $(document).trigger({type: eval("Events.Login.{type}Fail".template({type: type}))});
            onFail();
        }
    },
	Login: function(login, password, type, onSuccess, onFail){
	    var me = this;
	    $.ajax({
			type: "GET",
			url: '{cur_page}/classes/auth.php?email={email}&passw={passw}&lang={lang}'.template({
				cur_page: cur_page,
                lang: language,
				email: login,
				passw: escape(password)
			}),
			success: function(response){me.onLoginSuccess(response, type, onSuccess, onFail);},
            error: WindowManager.ShowErrorWindow
		});
	},
	Logout: function(){},
    OnRegSuccess: function(response, type, onSuccess, onFail){
        if(response=='OK'){
            $(document).trigger({type: eval("Events.Register.{type}Success".template({type: type}))});
            this.OnLoginSuccess(response, type, onSuccess, onFail);
        }
        else{
            $(document).trigger({type: eval("Events.Register.{type}Fail".template({type: type}))});
            onFail(response);
        }
    },
	Register: function(email, password, password_c, nick, rm, type, onSuccess, onFail){
	    var me = this;
	    $.ajax({
  			type: "GET",
  			url: '{cur_page}/classes/reg.php?email={email}&passw={passw}&passwc={passwc}&nick={nick}&rm={rm}&lang={lang}'.template({
  				cur_page: cur_page,
                lang: language,
  				email: email,
  				passw: password,
  				passwc: password_c,
  				nick: nick,
  				rm: rm
  			}),
  			success: function(response){me.onRegSuccess(response, type, onSuccess, onFail);},
            error: WindowManager.ShowErrorWindow
  		});
	},
	IsAnonym: function(){return String.IsNullOrEmpty((Cookie.Get(Cookie.BaseName)!=null)?Cookie.Get(Cookie.BaseName).userlogin:null);},
	GetUser: function(){}
};
$(document).ready(function(){userManager = new UserManager();});

;var API = API || {};
API.GetLicense = function(obj){
    drm.acquireLicense(
        alQuery.template({
            api_url: api_url,
            license:obj.license,
            uuid: obj.uuid,
            userid: (Cookie.Get(Cookie.BaseName)) ? Cookie.Get(Cookie.BaseName).userid : String.Empty
        })
    );
    if(obj.type=='play')GameManager.Play(obj);
    else if(obj.type=='load')GameManager.Load(obj);
	RatingManager.Rate({cur_page: cur_page, uuid: uuid});
};
;var GameManager = GameManager || {};

GameManager.URL = "{cur_page}/classes/get_game_attributes.php?id={id}";

GameManager.Attributes = {};

GameManager.Attributes.uuid = 'uuid';
GameManager.Attributes.license = 'license';

GameManager.OnPlayClick = function(){
    $.ajax({
    	type: "GET",
    	url: GameManager.URL.template({cur_page: cur_page, id: Cookie.Get('runGame')}),
    	success: function(data){
    	    var data = $.parseJSON(data);
            if(data!=null) GameManager.Play(data);
            else WindowManager.ShowErrorWindow(null, 'Answer from server', 'Data is null');
    	},
        error: WindowManager.ShowErrorWindow
    });
}
GameManager.OnLoadClick = function(obj, callback){
    var me = obj;
    $.ajax({
    	type: "GET",
    	url: GameManager.URL.template({cur_page: cur_page, id: ($(obj).attr(GameManager.Attributes.uuid))}),
    	success: function(data){
    	    var data = $.parseJSON(data);
            data.license = $(me).attr(GameManager.Attributes.license);
            GameManager.Load(data);
            if(callback)callback();
    	},
        error: WindowManager.ShowErrorWindow
    });
}
GameManager.OnDeleteClick = function(obj){
    var me = obj;
    $.ajax({
    	type: "GET",
    	url: GameManager.URL.template({cur_page: cur_page, id: ($(obj).attr(GameManager.Attributes.uuid))}),
    	success: function(data){
    	    var data = $.parseJSON(data);
            GameManager.Delete(data);
    	},
        error: WindowManager.ShowErrorWindow
    });
}
GameManager.Play = function(data){
    ProdownFrame.player.downloadUrl=data.DownloadURL;
    ProdownFrame.player.image=data.FileImg;
    ProdownFrame.player.commandLine=data.CommandLine;
    ProdownFrame.player.hintUpload=data.HintUpload;
    ProdownFrame.player.name=data.ImgName;
    ProdownFrame.player.minHintTime="1";
    ProdownFrame.player.autoStop="true";
    ProdownFrame.player.throttle=true;
    ProdownFrame.player.autoLaunch=36000;
    ProdownFrame.Launch();
};
GameManager.Load = function(data){
    $(document).trigger({type:Events.Game.Play, license:data.license});
    GameManager.GetLicense(data);
    Cookie.Set("gameTitle",data.FullName,{path: "/"});
    Cookie.Set("gameType",data.license,{path: "/"});
    Cookie.Set("runGame", data.UUID, {path: "/"});
    ProdownFrame.player.downloadUrl=data.DownloadURL;
    ProdownFrame.player.image=data.FileImg;
    ProdownFrame.player.commandLine=data.CommandLine;
    ProdownFrame.player.hintUpload=data.HintUpload;
    ProdownFrame.player.name=data.ImgName;
    ProdownFrame.player.minHintTime="1";
    ProdownFrame.player.autoStop="false";
    ProdownFrame.player.throttle=false;
    ProdownFrame.player.autoLaunch=0;
    ProdownFrame.Load();
};
GameManager.Delete = function(data){
    jConfirm(gameDeleteConfirmMsg, gameDeleteConfirmHeader, function(r){
        if(r==true){
            ProdownFrame.player.image=data.fileImage;
            ProdownFrame.Delete();
            drm.deleteCatalog(data.UUID);
            UpdateCatalog();
        }
    });
};
GameManager.GetLicense = function(data){
    drm.acquireLicense(
        alQuery.template({
            api_url: api_url,
            license:data.license,
            uuid: data.UUID,
            userid: (Cookie.Get(Cookie.BaseName))?Cookie.Get(Cookie.BaseName).userid:String.Empty
        })
    );
    data.rate = 'play';
    RatingManager.Rate(data);
};
;var RatingManager=RatingManager||{};
RatingManager.SetRatingURL='{cur_page}/classes/setrating.php?i={rate}&id={id}';
RatingManager.Rate=function(data){$.ajax({url:RatingManager.SetRatingURL.template({cur_page:cur_page,id:data.UUID,rate:data.rate})});};

;var WindowManager = WindowManager || {};

WindowManager.ShowErrorWindow = function(XMLHttpRequest, textStatus, errorThrown){
    (new InfoForm()).ShowForm(
        Function.emptyFunction,
        Function.emptyFunction,
        {header: 'Error', message: textStatus+" - "+errorThrown}
    );
};
;var StatManager = StatManager || {};
StatManager.IsActive = false;
StatManager.TrackName = String.Empty;
StatManager.CookieName = {LoadTracker: 'LoadTracker', PlayTracker: 'PlayTracker', TestCookie: '__utmc'};
StatManager.GameAttrURL = '{cur_page}/classes/get_game_attributes.php?id={id}';

StatManager.PluginEvent= {
    Idle: 'STATUS_IDLE',
    Loading: 'STATUS_LOADING',
    Launched: 'STATUS_LAUNCHED',
    Stopping: 'STATUS_STOPPING',
    Ready: 'STATUS_READY'
};
StatManager.TrackEvent = {
	PageView: '_trackPageview',
	Event: '_trackEvent',
	SetAccount: '_setAccount',
    CookiesAllowed: 'Cookies allowed'
};
StatManager.Action = {
	Register: {
		Category: 'register',
		Actions: {
			PageOpen: {Name: 'page.register.open', Label: 'page_register_open '},
			PageSubmit: {Name: 'page.register.submit', Label: 'page_register_submit'},
			PageOk: {Name: 'page.register.ok', Label: 'page_register_ok'},
			PageFailure: {Name: 'page.register.failure', Label: 'page_register_failure'},
			WizardOpen: {Name: 'wizard.register.open', Label: 'wizard_register_open '},
			WizardSubmit: {Name: 'wizard.register.submit', Label: 'wizard_register_submit'},
			WizardOk: {Name: 'wizard.register.ok', Label: 'wizard_register_ok'},
			WizardFailure: {Name: 'wizard.register.failure', Label: 'wizard_register_failure'},
			WizardClose: {Name: 'wizard.register.close', Label: 'wizard_register_close'}
		}
	},
	Login: {
		Category: 'login',
		Actions: {
			PageSubmit: {Name: 'page.login.submit', Label: 'page_login_submit'},
			PageOk: {Name: 'page.login.ok', Label: 'page_login_ok'},
			PageFailure: {Name: 'page.login.failure', Label: 'page_login_failure'},
			WizardOpen: {Name: 'wizard.login.open', Label: 'wizard_login_open'},
			WizardSubmit: {Name: 'wizard.login.submit', Label: 'wizard_login_submit'},
			WizardOk: {Name: 'wizard.login.ok', Label: 'wizard_login_ok'},
			WizardFailure: {Name: 'wizard.login.failure', Label: 'wizard_login_failure'},
			WizardClose: {Name: 'wizard.login.close', Label: 'wizard_login_close'}
		}
	},
	Download: {
		Category: 'download',
		Actions: {
			Plugin: {Name: 'download.plugin ', Label: 'download_plugin'}
		}
	},
    Consultant: {
		Category: 'consultant',
		Actions: {
			Click: {Name: 'consultant.click', Label: 'consultant_click'}
		}
	},
	Game: {
		Category: 'game',
		Actions: {
			Demo: {Name: 'game.demo.game_demo', Label: 'game_demo'},
			DemoPluginTrue: {Name: 'game.demo.plugin_true', Label: 'game_demo_plugin_true'},
			DemoPluginFalse: {Name: 'game.demo.plugin_false', Label: 'game_demo_plugin_false'},
			DemoSysTrue: {Name: 'game.demo.sys_true', Label: 'game_demo_sys_true'},
			DemoSysFalse: {Name: 'game.demo.sys_false', Label: 'game_demo_sys_false'},
			DemoSysFalseOverride: {Name: 'game.demo.sys_false_override', Label: 'game_demo_sys_false_override'},
			Full: {Name: 'game.full', Label: 'game_full'},
			LoadTime: {Name: 'game.loadtime', Label: 'game_loadtime'},
			PlayTime: {Name: 'game.playtime', Label: 'game_playtime'},
			Buy: {Name: 'game.buy', Label: 'game_buy'},
			Rent: {Name: 'game.rent', Label: 'game_rent'},
			ShortPlay: {Name: 'game.shortplay'},
			LongPlay: {Name: 'game.longplay'},
			Details: {Name: 'game.details'},
			DetailsDemo: {Name: 'game.details.demo'}
		}
	},
    Buy: {
		Category: 'buy',
		Actions: {
			WebMoney: {Name: 'buy.webmoney', Label: 'buy_webmoney'},
			YandexMoney: {Name: 'buy.yandex.money', Label: 'buy_yandex.money'},
			Qiwi: {Name: 'buy.qiwi', Label: 'buy_qiwi'},
			MoneyMail: {Name: 'buy.moneymail', Label: 'buy_moneymail'},
			RbkMoney: {Name: 'buy.rbkmoney', Label: 'buy_rbkmoney'},
			W1: {Name: 'buy.w1', Label: 'buy_w1'},
			PromoCode: {Name: 'buy.promocode', Label: 'buy_promocode'},
			Sms: {Name: 'buy.sms', Label: 'buy_sms'},
			Open: {Name: 'buy.open', Label: 'buy_open'},
			Close: {Name: 'buy.close', Label: 'buy_close'},
			Ok: {Name: 'buy.ok', Label: 'buy_ok'},
			Failure: {Name: 'buy.failure', Label: 'buy_failure'}
		}
	}
};
// Download Plugin
StatManager.OnDownloadPlugin = function(){
	StatManager.PushEvent([
        StatManager.Action.Download.Category,
        StatManager.Action.Download.Actions.Plugin.Name,
        StatManager.Action.Download.Actions.Plugin.Label
    ]);
};
// Consultant Click
StatManager.OnConsultantClick = function(){
	StatManager.PushEvent([
        StatManager.Action.Consultant.Category,
        StatManager.Action.Consultant.Actions.Click.Name,
        StatManager.Action.Consultant.Actions.Click.Label
    ]);
};
// Register
StatManager.OnPageRegisterOpen = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.PageOpen.Name,
        StatManager.Action.Register.Actions.PageOpen.Label
    ]);
};
StatManager.OnPageRegisterSubmit = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.PageSubmit.Name,
        StatManager.Action.Register.Actions.PageSubmit.Label
    ]);
};
StatManager.OnPageRegisterSuccess = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.PageOk.Name,
        StatManager.Action.Register.Actions.PageOk.Label
    ]);
};
StatManager.OnPageRegisterFail = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.PageFailure.Name,
        StatManager.Action.Register.Actions.PageFailure.Label
    ]);
};
StatManager.OnWizardRegisterOpen = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.WizardOpen.Name,
        StatManager.Action.Register.Actions.WizardOpen.Label
    ]);
};
StatManager.OnWizardRegisterSubmit = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.WizardSubmit.Name,
        StatManager.Action.Register.Actions.WizardSubmit.Label
    ]);
};
StatManager.OnWizardRegisterSuccess = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.WizardOk.Name,
        StatManager.Action.Register.Actions.WizardOk.Label
    ]);
};
StatManager.OnWizardRegisterFail = function(){
	StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.WizardFailure.Name,
        StatManager.Action.Register.Actions.WizardFailure.Label
    ]);
};
StatManager.OnWizardRegisterCancel = function(){
    StatManager.PushEvent([
        StatManager.Action.Register.Category,
        StatManager.Action.Register.Actions.WizardClose.Name,
        StatManager.Action.Register.Actions.WizardClose.Label
    ]);
};
// Login
StatManager.OnPageLoginSubmit = function(){
    StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.PageSubmit.Name,
        StatManager.Action.Login.Actions.PageSubmit.Label
    ]);
};
StatManager.OnPageLoginSuccess = function(){
	StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.PageOk.Name,
        StatManager.Action.Login.Actions.PageOk.Label
    ]);
};
StatManager.OnPageLoginFail = function(){
	StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.PageFailure.Name,
        StatManager.Action.Login.Actions.PageFailure.Label
    ]);
};
StatManager.OnWizardLoginOpen = function(){
    StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.WizardOpen.Name,
        StatManager.Action.Login.Actions.WizardOpen.Label
    ]);
};
StatManager.OnWizardLoginSubmit = function(){
    StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.WizardSubmit.Name,
        StatManager.Action.Login.Actions.WizardSubmit.Label
    ]);
};
StatManager.OnWizardLoginSuccess = function(){
	StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.WizardOk.Name,
        StatManager.Action.Login.Actions.WizardOk.Label
    ]);
};
StatManager.OnWizardLoginFail = function(){
	StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.WizardFailure.Name,
        StatManager.Action.Login.Actions.WizardFailure.Label
    ]);
};
StatManager.OnWizardLoginCancel = function(){
    StatManager.PushEvent([
        StatManager.Action.Login.Category,
        StatManager.Action.Login.Actions.WizardClose.Name,
        StatManager.Action.Login.Actions.WizardClose.Label
    ]);
};
// Game
StatManager.OnPlayClick = function(data){
    if(data.license=='buy'){
        StatManager.PushEvent([
            StatManager.Action.Game.Category,
            StatManager.Action.Game.Actions.Full.Name,
            StatManager.Action.Game.Actions.Full.Label
        ]);
    }
    else{
        StatManager.PushEvent([
            StatManager.Action.Game.Category,
            StatManager.Action.Game.Actions.Demo.Name,
            StatManager.Action.Game.Actions.Demo.Label
        ]);
    }
};
StatManager.OnBuyClick = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.Buy.Name,
        StatManager.Action.Game.Actions.Buy.Label
    ]);
};
StatManager.OnRentClick = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.Rent.Name,
        StatManager.Action.Game.Actions.Rent.Label
    ]);
};
StatManager.OnPluginTrue = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.DemoPluginTrue.Name,
        StatManager.Action.Game.Actions.DemoPluginTrue.Label
    ]);
};
StatManager.OnPluginFalse = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.DemoPluginFalse.Name,
        StatManager.Action.Game.Actions.DemoPluginFalse.Label
    ]);
};
StatManager.OnSysReqTrue = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.DemoSysTrue.Name,
        StatManager.Action.Game.Actions.DemoSysTrue.Label
    ]);
};
StatManager.OnSysReqFalse = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.DemoSysFalse.Name,
        StatManager.Action.Game.Actions.DemoSysFalse.Label
    ]);
};
StatManager.OnSysReqFalseOverride = function(){
	StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.DemoSysFalseOverride.Name,
        StatManager.Action.Game.Actions.DemoSysFalseOverride.Label
    ]);
};
StatManager.GameTracker = function(data){
    switch(data.status){
        case StatManager.PluginEvent.Loading:
        case StatManager.PluginEvent.Ready:
            if(!StatManager.IsStartTime(loadTracker)){
                StatManager.StartTrackAndSet(loadTracker, StatManager.CookieName.LoadTracker);
          	}
        	break;
        case StatManager.PluginEvent.Stopping:
        case StatManager.PluginEvent.Idle:
        	if(StatManager.IsStartTime(playTracker)){
        	    StatManager.StopTrackAndDelete(playTracker, StatManager.CookieName.PlayTracker);
        	}
            else if(StatManager.IsStartTime(loadTracker)){
                StatManager.StopTrackAndDelete(loadTracker, StatManager.CookieName.LoadTracker);
            }
        	break;
        case StatManager.PluginEvent.Launched:
            if(!StatManager.IsStartTime(playTracker)){
                if(StatManager.IsStartTime(loadTracker)){
              	    StatManager.StopTrackAndDelete(loadTracker, StatManager.CookieName.LoadTracker);
             	}
                StatManager.StartTrackAndSet(playTracker, StatManager.CookieName.PlayTracker);
            }
            break;
    }
};
StatManager.GameLoadtime = function(){
    StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.LoadTime.Name,
        StatManager.Action.Game.Actions.LoadTime.Label
    ]);
};
StatManager.GamePlaytime = function(){
    StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.PlayTime.Name,
        StatManager.Action.Game.Actions.PlayTime.Label
    ]);
};
StatManager.OnShortPlay = function(){
    var runGame = Cookie.Get('runGame');
    $.ajax({
    	type: "GET",
    	url: StatManager.GameAttrURL.template({
    		cur_page: cur_page,
            id: runGame
    	}),
    	success: function(response){
    	    var response = $.parseJSON(response);
    	    StatManager.PushEvent([
                StatManager.Action.Game.Category,
                StatManager.Action.Game.Actions.ShortPlay.Name,
                response.FullName
            ]);
        }
    });
};
StatManager.OnLongPlay = function(){
    var runGame = Cookie.Get('runGame');
    $.ajax({
    	type: "GET",
    	url: StatManager.GameAttrURL.template({
    		cur_page: cur_page,
            id: runGame
    	}),
    	success: function(response){
    	    var response = $.parseJSON(response);
    	    StatManager.PushEvent([
                StatManager.Action.Game.Category,
                StatManager.Action.Game.Actions.LongPlay.Name,
                response.FullName
            ]);
        }
    });
};
StatManager.OnDetailPageLoad = function(){
    StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.Details.Name,
        $("#page_header").html()
    ]);
};
StatManager.OnDetailDemoPageLoad = function(){
    StatManager.PushEvent([
        StatManager.Action.Game.Category,
        StatManager.Action.Game.Actions.DetailsDemo.Name,
        $("#page_header").html()
    ]);
};
// Buy
StatManager.OnWebMoneyClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.WebMoney.Name,
        StatManager.Action.Buy.Actions.WebMoney.Label
    ]);
};
StatManager.OnYandexMoneyClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.YandexMoney.Name,
        StatManager.Action.Buy.Actions.YandexMoney.Label
    ]);
};
StatManager.OnQiwiClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.Qiwi.Name,
        StatManager.Action.Buy.Actions.Qiwi.Label
    ]);
};
StatManager.OnMoneyMailClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.MoneyMail.Name,
        StatManager.Action.Buy.Actions.MoneyMail.Label
    ]);
};
StatManager.OnRbkMoneyClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.RbkMoney.Name,
        StatManager.Action.Buy.Actions.RbkMoney.Label
    ]);
};
StatManager.OnW1Click = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.W1.Name,
        StatManager.Action.Buy.Actions.W1.Label
    ]);
};
StatManager.OnPromoCodeClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.PromoCode.Name,
        StatManager.Action.Buy.Actions.PromoCode.Label
    ]);
};
StatManager.OnSmsClick = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.Sms.Name,
        StatManager.Action.Buy.Actions.Sms.Label
    ]);
};
StatManager.OnBuyOpen = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.Open.Name,
        StatManager.Action.Buy.Actions.Open.Label
    ]);
};
StatManager.OnBuyClose = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.Close.Name,
        StatManager.Action.Buy.Actions.Close.Label
    ]);
};
StatManager.OnBuySuccess = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.Ok.Name,
        StatManager.Action.Buy.Actions.Ok.Label
    ]);
};
StatManager.OnBuyFail = function(){
    StatManager.PushEvent([
        StatManager.Action.Buy.Category,
        StatManager.Action.Buy.Actions.Failure.Name,
        StatManager.Action.Buy.Actions.Failure.Label
    ]);
};
// Track Event
StatManager.PushEvent = function(data){
    _gaq.push([StatManager.TrackEvent.PageView, data[0]]);
    data.unshift(StatManager.TrackEvent.Event);
	_gaq.push(data);
};

StatManager.IsStartTime = function(obj){return typeof(obj.startTime_)!='undefined'&&obj.startTime_!=null;};
StatManager.StopTrackAndDelete = function(obj, cookieName){
    obj._recordEndTime();
    obj._track();
    Cookie.Delete(cookieName, {path:'/'});
    obj.startTime_=null;
};
StatManager.StartTrackAndSet = function(obj, cookieName){
    obj._recordStartTime();
    Cookie.Set(cookieName, obj.startTime_, {path:'/'});
};

$(document).ready(function(){
    if(ga_active=='1'){
        _gaq=_gaq||[];
        _gaq.push([StatManager.TrackEvent.SetAccount,ga]);
        _gaq.push([StatManager.TrackEvent.PageView]);
        playTracker = new TimeTracker(
            null,
            StatManager.Action.Game.Category,
            StatManager.Action.Game.Actions.PlayTime.Name,
            StatManager.Action.Game.Actions.PlayTime.Label
        );
        var playTrackerTime = Cookie.Get(StatManager.CookieName.PlayTracker);
        if(playTrackerTime)playTracker.startTime_=playTrackerTime;

        loadTracker = new TimeTracker(
            null,
            StatManager.Action.Game.Category,
            StatManager.Action.Game.Actions.LoadTime.Name,
            StatManager.Action.Game.Actions.LoadTime.Label
        );
        var loadTrackerTime = Cookie.Get(StatManager.CookieName.LoadTracker);
        if(loadTrackerTime)loadTracker.startTime_=loadTrackerTime;

        pageTracker = _gaq._getAsyncTracker();

        var availableCookiesCheck = Cookie.Get(StatManager.CookieName.TestCookie);
        var availableCookies = (availableCookiesCheck)?'Yes':'No';
        pageTracker._setCustomVar(1, StatManager.TrackEvent.CookiesAllowed, availableCookies, 1);

    	$(document).bind(Events.Download.Plugin, StatManager.OnDownloadPlugin);
    	$(document).bind(Events.Consultant.Click, StatManager.OnConsultantClick);

        $(document).bind(Events.Register.PageOpen, StatManager.OnPageRegisterOpen);
        $(document).bind(Events.Register.PageSubmit, StatManager.OnPageRegisterSubmit);
    	$(document).bind(Events.Register.PageSuccess, StatManager.OnPageRegisterSuccess);
    	$(document).bind(Events.Register.PageFail, StatManager.OnPageRegisterFail);
        $(document).bind(Events.Register.WizardOpen, StatManager.OnWizardRegisterOpen);
        $(document).bind(Events.Register.WizardSubmit, StatManager.OnWizardRegisterSubmit);
    	$(document).bind(Events.Register.WizardSuccess, StatManager.OnWizardRegisterSuccess);
    	$(document).bind(Events.Register.WizardFail, StatManager.OnWizardRegisterFail);
    	$(document).bind(Events.Register.WizardCancel, StatManager.OnWizardRegisterCancel);
		
        $(document).bind(Events.Login.PageSubmit, StatManager.OnPageLoginSubmit);
    	$(document).bind(Events.Login.PageSuccess, StatManager.OnPageLoginSuccess);
    	$(document).bind(Events.Login.PageFail, StatManager.OnPageLoginFail);
        $(document).bind(Events.Login.WizardOpen, StatManager.OnWizardLoginOpen);
        $(document).bind(Events.Login.WizardSubmit, StatManager.OnWizardLoginSubmit);
    	$(document).bind(Events.Login.WizardSuccess, StatManager.OnWizardLoginSuccess);
    	$(document).bind(Events.Login.WizardFail, StatManager.OnWizardLoginFail);
    	$(document).bind(Events.Login.WizardCancel, StatManager.OnWizardLoginCancel);

        $(document).bind(Events.Game.Play, StatManager.OnPlayClick);
        $(document).bind(Events.Game.PluginTrue, StatManager.OnPluginTrue);
        $(document).bind(Events.Game.PluginFalse, StatManager.OnPluginFalse);
        $(document).bind(Events.Game.SysReqTrue, StatManager.OnSysReqTrue);
        $(document).bind(Events.Game.SysReqFalse, StatManager.OnSysReqFalse);
        $(document).bind(Events.Game.SysReqFalseOverride, StatManager.OnSysReqFalseOverride);
        $(document).bind(Events.Game.Buy, StatManager.OnBuyClick);
        $(document).bind(Events.Game.Rent, StatManager.OnRentClick);
    	$(document).bind(Events.Game.Tracker, StatManager.GameTracker);
    	$(document).bind(Events.Game.ShortPlay, StatManager.OnShortPlay);
    	$(document).bind(Events.Game.LongPlay, StatManager.OnLongPlay);
    	$(document).bind(Events.Game.Details, StatManager.OnDetailPageLoad);
    	$(document).bind(Events.Game.DetailsDemo, StatManager.OnDetailDemoPageLoad);

        $(document).bind(Events.Buy.WebMoney, StatManager.OnWebMoneyClick);
        $(document).bind(Events.Buy.YandexMoney, StatManager.OnYandexMoneyClick);
    	$(document).bind(Events.Buy.Qiwi, StatManager.OnQiwiClick);
    	$(document).bind(Events.Buy.MoneyMail, StatManager.OnMoneyMailClick);
    	$(document).bind(Events.Buy.RbkMoney, StatManager.OnRbkMoneyClick);
    	$(document).bind(Events.Buy.W1, StatManager.OnW1Click);
    	$(document).bind(Events.Buy.PromoCode, StatManager.OnPromoCodeClick);
    	$(document).bind(Events.Buy.Sms, StatManager.OnSmsClick);
    	$(document).bind(Events.Buy.Open, StatManager.OnBuyOpen);
    	$(document).bind(Events.Buy.Close, StatManager.OnBuyClose);
    	$(document).bind(Events.Buy.Success, StatManager.OnBuySuccess);
    	$(document).bind(Events.Buy.Fail, StatManager.OnBuyFail);
    }
});
;function TextRotator(){
    this.fadingTime = 700;
    this.pauseTime = 2000;
    this.init();
};
TextRotator.prototype = {
    init: function(){},
    Start: function(container, data){
        this.ProccessImgLoad(data);
        this.FadeInOutString(container, data, null);
    },
    FadeInOutString: function(container, data, index){
    	var me = this;
    	index=index==null?-1:index;
    	container.hide().html(data[this.GetNextIndex(data, index)]).fadeIn(this.fadingTime , function(){
    	    window.setTimeout(function(){
    		    container.fadeOut(me.fadingTime , function(){me.FadeInOutString(container, data, me.GetNextIndex(data, index));});
    		}, me.pauseTime);
    	});
    },
    GetNextIndex: function(data,index){return(index+1<data.length)?index+1:0;},
    ProccessImgLoad: function(data){
        for(var i=0;i<data.length-1;i++){
            var imgSrc = ($('img', data[0]).prevObject[0]) ? $('img', data[0]).prevObject[0].src : null;
            if(imgSrc)$('<img>').attr('src', imgSrc);
        }
    }
};
$(document).ready(function(){textRotator=new TextRotator();});

;function Player(){
	this.container = null;
	this.previewContainer = null;
	this.middleContainer = null;
	this.url = cur_page + '/player.xml';
	this.data = null;
	this.timer = null;
    this.init();
};
Player.prototype = {
    init: function(){
        this.onGetData = Function.createDelegate(this, this.OnGetData);
	    this.goToNextSlide = Function.createDelegate(this, this.GoToNextSlide);
	},
	Start: function(container){
		this.container = $(container);
		this.previewContainer = $('div.preview', this.container);
		this.middleContainer = $('div.view', this.container);
		this.GetData();
	},
	Refresh: function(){
		if(!userManager.IsAnonym())
			$('li[showRegistered=false]', this.previewContainer).hide();
		else
			$('li[showRegistered=false]', this.previewContainer).show();
		$('ul li:visible:first', this.previewContainer).click();
	},
	GetData: function(){
		var me = this;
		$.ajax({
			url: this.url,
			success: function(data){me.onGetData($(data));},
            error: WindowManager.ShowErrorWindow
		});
	},
	OnGetData: function(data){
		this.LoadPreviewImages(data);
		$('ul li:visible:first', this.previewContainer).click();
	},
	ChangeMiddle: function(node){
		var me = this;
		var middleNode = this.GetImageNode(node, 'middle');
		var largeNode = this.GetImageNode(node, 'large');
		var middleImageLinkNode = this.GetLinkNode(node, 'middleImage');
        var image = $(new Image());
		image.attr('src', cur_page + middleNode.attr('src'))
			.attr('width', middleNode.attr('width'))
			.attr('height', middleNode.attr('height'))
			.attr('alt', middleNode.attr('alt'))
			.attr('class', 'gray')
			.css('width', middleNode.attr('width'))
			.css('height', middleNode.attr('height'));
        this.middleContainer.fadeOut('fast', function(){
			var temp = middleImageLinkNode.length > 0 ? $('<a href="{cur_page}{language}{link}"></a>'.template({cur_page: cur_page, language: language, link: middleImageLinkNode.attr('href')})).append(image):image;
			temp.mouseenter(function(){window.clearTimeout(me.timer)})
				.mouseleave(function(){me.timer = window.setTimeout(me.goToNextSlide, node.attr('delay'));});
			me.middleContainer.children().remove();
			me.middleContainer.append(temp);
			var viewMenuHtml=me.GetViewMenuHtml(node);
			if(viewMenuHtml!=null){me.middleContainer.append(viewMenuHtml);}
			var viewTitleHtml=me.GetViewTitleHtml(node);
			if(viewTitleHtml!=null) me.middleContainer.append(viewTitleHtml);
			me.middleContainer.fadeIn('fast');
		});
	},
	LoadPreviewImages: function(data){
        var head = $('<ul>');
        this.previewContainer.append(head);
		var nodes = data.find('item');
		for(var i=0;i<nodes.length;i++){
			var itemNode = $(nodes[i]);
			var showRegisteredAttr = itemNode.attr('showRegistered');
			var showRegistered = Boolean.parse(showRegisteredAttr == undefined ? 'true' : showRegisteredAttr);
			var smallNode = this.GetImageNode(itemNode, 'small');
			var listItem = $('<li></li>').attr('showRegistered', showRegistered)
				.click(Function.createCallback(this.OnPreviewClick, {context: this, itemNode: itemNode}));
			if( (!userManager.IsAnonym() && !showRegistered)) listItem.hide();
			var image = $(new Image())
				.attr('src', cur_page + smallNode.attr('src'))
				.attr('width', smallNode.attr('width'))
				.attr('height', smallNode.attr('height'));
			head.append(listItem.append(image));
		};
	},
	OnPreviewClick: function(obj, context){
		window.clearTimeout(context.context.timer);
		$('ul,li', context.previewContainer).removeClass('selected');
		$(obj.currentTarget).addClass('selected');
		with(context){
			context.ChangeMiddle(itemNode);
			context.timer = window.setTimeout(context.goToNextSlide, itemNode.attr('delay'));
		};
	},
	GoToNextSlide: function(){
		var nextElement = $('li.selected ~ li:visible:first', this.previewContainer);
		(nextElement.length > 0 ? nextElement : $('ul li:visible:first', this.previewContainer)).click();
	},
    GetImageNode: function(node, size){
        return $('images,image', node).children('[size={size}]'.template({size: size}));
    },
    GetLinkNode: function(node, type){
        return $('links,link', node).children('[type={type}]'.template({type: type}));
    },
    GetMenuNode: function(node, type){
        var menuNode = $('menus,menu', node);
        return (menuNode)?menuNode.children('[type={type}]'.template({type: type})):null;
    },
    GetViewMenuHtml: function(node){
        var menuNode = this.GetMenuNode(node, 'view');
        var result = String.Empty;
        if(menuNode.length>0){
            var menuItems = menuNode.attr('content').split(',');
			var temp = new Array();
            for(var i=0;i<menuItems.length;i++){
				var linkNode = this.GetLinkNode(node, menuItems[i]);
				temp.push('<a href="{cur_page}{language}{link}">{title}</a>'.template({
				    cur_page: cur_page,
					language: language,
                    link: linkNode.attr('href'),
                    title: linkNode.attr('title')
                }));
            };
            result = '<div class="menu">{items}</div>'.template({items: temp.join('<span>|</span>')});
        };
        return result == String.Empty ? null : result;
    },
	GetViewTitleHtml: function(node){
		var title = node.attr('title');
		return title == String.Empty ? null : '<div class="title"><span>{title}</span></div>'.template({title: title});
	}
};
$(document).ready(function(){player=new Player();});
;/* ===================================================================================================
 * script: main
 * Description: функции js необходимые для работы на сайте
 * Created by Grinevich Dmitry 11.01.2010
 * ==================================================================================================*/
/////////////////////////////////////////////////////////////////
//  Определяет браузер клиента
/////////////////////////////////////////////////////////////////
var uagent    = navigator.userAgent.toLowerCase();

var is_safari = ( ( uagent.indexOf( 'safari' ) != -1 ) || ( navigator.vendor == "Apple Computer, Inc." ) );
var is_opera  = ( uagent.indexOf( 'opera' ) != -1 );
var is_webtv  = ( uagent.indexOf( 'webtv' ) != -1 );
var is_ie     = ( ( uagent.indexOf( 'msie' ) != -1 ) && ( !is_opera ) && ( !is_safari ) && ( !is_webtv ) );
var is_ie4    = ( ( is_ie ) && ( uagent.indexOf( "msie 4." ) != -1 ) );
var is_moz    = ( ( navigator.product == 'Gecko' ) && ( !is_opera ) && ( !is_webtv ) && ( !is_safari ) );
var is_ns     = ( ( uagent.indexOf( 'compatible' ) == -1 ) && ( uagent.indexOf( 'mozilla' ) != -1 ) && ( !is_opera ) && ( !is_webtv ) && ( !is_safari ) );
var is_ns4    = ( ( is_ns ) && ( parseInt( navigator.appVersion ) == 4 ) );
var is_kon    = ( uagent.indexOf( 'konqueror' ) != -1 );
var is_win    = ( ( uagent.indexOf( "win" ) != -1 ) || ( uagent.indexOf( "16bit" ) !=- 1 ) );
var is_mac    = ( ( uagent.indexOf( "mac" ) != -1 ) || ( navigator.vendor == "Apple Computer, Inc." ) );

var alQuery = "{api_url}?api=lcr&lic_type={license}&game_id={uuid}&userid={userid}";

var ua_vers   = parseInt(navigator.appVersion);
/////////////////////////////////////////////////////////////////
// Визуальные эффекты
/////////////////////////////////////////////////////////////////
//  shows element
//_______________________________________________________________
function show_element( _id ){
    var el = document.getElementById( _id );
    el.style.display = "block";
}
//  hides element
//_______________________________________________________________
function hide_element( _id ){
    var el = document.getElementById( _id );
    el.style.display = "none";
}
//  shows or hides element by ID
//_______________________________________________________________
function showhide_element( _id ){
    with($('#'+_id)){
        if(hasClass('hidden'))removeClass('hidden');
        else addClass('hidden');
    }
    //if( el.style.display == "block" ) el.style.display = "none";
    //else el.style.display = "block";
}
// checking 2 passwords
//_______________________________________________________________
function checkPass( value1, value2, _id ){
    var val1 = document.getElementById( value1 ).value;
    var val2 = document.getElementById( value2 ).value;
    var _img = document.getElementById( _id );
    if ( !val1 || !val2 ) _img.src = cur_page + '/skins/img/glob_img/spacer.gif';
    else if( val1 == val2 ) _img.src = cur_page + '/skins/img/glob_img/accept.png';
    else _img.src = cur_page + '/skins/img/glob_img/cancel.png';
}
// checking is email valid
//_______________________________________________________________
function checkEmail( email ) {
    var response = (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test( email );
    if( response == true ) return 'OK';
    else if( response == false ) return 'FALSE';
}
//
//_______________________________________________________________
function formatText(index, panel){
    return index + "";
}
// Retriving information from local catalog
function UpdateCatalog(){
    var catalog = drm.queryCatalog();
	var catalogDoc = XMLEnvironment.createDocument();
	catalogDoc.async = false;
	catalogDoc.loadXML(catalog);
	var games = new Array();
	$('Game',catalogDoc).each(function(i, _item){
		if ($(_item).attr('shop')==shop_id) {
			games.push($(this).attr("id"));
		}
	});
    $.ajax({
        type: "POST",
        url: cur_page + '/classes/get_games.php?lang='+language,
        data: 'catalog=' + $.toJSON(games),
        success: function(data) {
            $('#local_games').html(data);
			$('#calcksize').click();
        }
    });
};
// JQuery
//_______________________________________________________________
$(document).ready(function(){
    var payment_result = Cookie.Get('x-json');
    if(payment_result){
        var buyWindow = new BuyWindow();
        buyWindow.OnBuy(payment_result);
        Cookie.Delete('x-json', {path: '/'});
    }
	$('#calcksize').click(function(){
		var catalog = drm.queryCatalog();
		var catalogDoc = XMLEnvironment.createDocument();
		catalogDoc.async = false;
		catalogDoc.loadXML(catalog);
		var size_local = 0;
		var size_total = 0;
		var games = Array();
		var games_buy = Array();
		var games_sub = Array();
		$('.game_size').each(function() {
			var size = 0;
			var size2 = 0;
			var name_for_size = $(this).attr('name_for_size');
			var who = $(this).attr('who');
			$('Game',catalogDoc).each(function(i, _item){
				if ($(_item).attr('image')==name_for_size) {
					if ($(_item).attr('size') && $(_item).attr('size')!='undefined') {
						if (who=='local') {
							size = $(_item).attr('sizeOnDisk');
							size = Math.round(size / (1024*1024));
							if (games[name_for_size]==undefined) size_local += parseInt(size);
							size2 = $(_item).attr('size');
							size2 = Math.round(size2 / (1024*1024));
							if (games[name_for_size]==undefined) size_total += parseInt(size2);
							games[name_for_size] = size+ ' / ' + size2;
						} else if (who=='subscribe') {
							size = $(_item).attr('size');
							size = Math.round(size / (1024*1024));
							games_sub[name_for_size] = size;
						} else {
							size = $(_item).attr('size');
							size = Math.round(size / (1024*1024));
							games_buy[name_for_size] = size;
						}
					}
				}
			});
			if(size2>0)
				$(this).html(size + ' / ' + size2 + ' MB');
			else
				if(size>0)
					$(this).html(size + ' MB');
	    });
		$('#size_local_games').html(size_local + ' / ' + size_total +' MB');
    });
    $('#register').click(function(){
        $(document).trigger({type:Events.Register.PageSubmit});
        me = this;
        userManager.Register(
            $("#email_reg").val(),
    		$("#password_reg").val(),
    		$("#password_reg_conf").val(),
    		$("#name").val(),
    		(document.getElementById('newsletter').checked)?1:0,
			'Page',
            function(data){
                $('#authMainForm').html(data);
                ReloadWindow($(me).attr('href'), false);
            },
            function(data){
                $('#glob_errors').html(data);
                $('#email_reg').focus();
            }
        );
        return false;
    });
    $('.reg_link').click(function(){
        $(document).trigger({type:Events.Register.PageOpen});
    });
    $('.plugin').live('click', function() {
        $(document).trigger({type:Events.Download.Plugin});
    });
    // On Consultant button click
    $('#consultant').click(function(){
        $(document).trigger({type:Events.Consultant.Click});
    });
    // On Play button click
    $('#launch_but').click(function(){
        GameManager.OnPlayClick();
    });
    $('#retest_but').click(function(){
		SysreqManager.FillGameReq();
	});
    // On Play button click
    $('#play_but').click(function(event){
        (new SysReqForm()).ShowForm(Function.emptyFunction, Function.emptyFunction, this);
    });
    if($('#play_but').val()){
        $(document).trigger({type:Events.Game.Details});
		if(!$('#play_but').attr("disabled")){
			$(document).trigger({type:Events.Game.DetailsDemo});
		}
    }
    
    // On Buy button click
    $('#buy_but').click(function(){
        uuid = $(this).attr("uuid");
        buyWizard.Start(Function.emptyFunction, Function.emptyFunction, {uuid: uuid, pp_param: 'game_id'});
    });
    // On stop button click
    $('#stop_but').click(function(){
		$("#block_stop").hide();
        ProdownFrame.Stop();
    });
    // On Buy button click
    $('#online_game').click(function(){
        data = {};
        data.UUID = $(this).attr("uuid");
        data.rate = 'play';
        RatingManager.Rate(data);
    });
    $("#my_games_menu").click(function(event){
		loginWizard.Start(
            function(){ReloadWindow($(event.currentTarget).attr('href'), false);},
            function(){ReloadWindow($(event.currentTarget).attr('href'), false);},
            null
        );
        return false;
    });
    $('.button.sub').click(function(event){
        uuid = $(event.currentTarget).attr('uuid');
        buyWizard.Start(Function.emptyFunction, Function.emptyFunction, {uuid: uuid, pp_param: 'sub_id'});
        return false;
    });
    $('.button.rent').click(function(event){
        uuid = $(event.currentTarget).attr('uuid');
        game_id = $(event.currentTarget).attr('game_id');
        buyWizard.Start(Function.emptyFunction, Function.emptyFunction, {uuid: uuid, pp_param: 'rent_id', game_id: game_id});
        return false;
    });
    $('#sub_but').click(function(){
        uuid = $(this).attr("uuid");
        buyWizard.Start(Function.emptyFunction, Function.emptyFunction, {uuid: uuid, pp_param: 'sub_id'});
        return false;
    });
    // Player
    var launched = false;
    var stopped = false;
    var showMsgStartGame = (Cookie.Get('showMsgStartGame')) ? Cookie.Get('showMsgStartGame') : 'false';
    var startTime;
    var finishTime;
    var playTime;
    function checkstatus(){
    	var status = ProdownFrame.getStatus();
        $(document).trigger({type:Events.Game.Tracker, status: status});
    	var gameTitle = Cookie.Get("gameTitle");
        switch(status){
    	    case StatManager.PluginEvent.Loading:
			case StatManager.PluginEvent.Ready:
			case StatManager.PluginEvent.Launched:
        	    $("#gameButtons").hide();
                $("#plugin_error").hide();
        	    $("#loader").show();
                $("#prodownstatus").show();
				$("#block_stop").show();
        	    $("#game_title").text(gameTitle);
                $("#buy_game_title").text(gameTitle);
				$("#head_loader").show();
				$("#body_loader").show();
                $(".play_btn").hide();
                $(".buy_btn").hide();
                $(".load_btn").hide();
                $(".delete_btn").hide();
				if(status==StatManager.PluginEvent.Launched){
                    if(!launched){
                		startTime = parseInt(new Date().getTime() / 1000);
                		launched = true;
                    }
                    $("#block_play").hide();
        	    }
                if(status==StatManager.PluginEvent.Ready){
                    if(Cookie.Get('autoStart')=='true') GameManager.OnPlayClick();
                    else if(showMsgStartGame=='false'){
                        (new StartGameForm()).ShowForm(Function.emptyFunction, Function.emptyFunction, null );
                        Cookie.Set('showMsgStartGame', 'true', {path: '/'});
                        showMsgStartGame = 'true';
                    }
                    $("#block_play").show();
                }
        	    break;
            case StatManager.PluginEvent.Stopping:
				$("#block_stop").hide();
                Cookie.Delete('showMsgStartGame', {path: '/'});
                Cookie.Delete('autoStart', {path: '/'});
        	    if(launched && !stopped){
            		finishTime = parseInt(new Date().getTime() / 1000);
            		playTime = finishTime - startTime;
            		if(playTime>=180){
            		    if(Cookie.Get('gameType')=='free')(new GlobalBuyForm()).ShowForm(Function.emptyFunction, Function.emptyFunction, null);
                    }
                    else{
                        if(Cookie.Get('gameType')=='free')(new GlobalProblemForm()).ShowForm(Function.emptyFunction, Function.emptyFunction, null);
                    }
            		stopped = true;
        	    }
        	    break;
        	case StatManager.PluginEvent.Idle:
        	    $("#gameButtons").show();
        	    $("#loader").hide();
				$("#head_loader").hide();
				$("#body_loader").hide();
				$("#block_play").hide();
                $(".play_btn").show();
                $(".buy_btn").show();
                $(".load_btn").show();
                $(".delete_btn").show();
        	    break;
    	}
        status = null;
        gameTitle = null;
        return null;
    }
    // On auth form submit
    $('#auth_go').click(function(){
        $(document).trigger({type:Events.Login.PageSubmit});
        if($('#enter_login').val().length>0&&$('#enter_password').val().length>0){
    		userManager.Login(
                $('#enter_login').val(),
                $('#enter_password').val(),
				'Page',
                function(data){
                    $(document).trigger({type:Events.Login.PageSuccess});
                    player.Refresh();
                    $('#authMainForm').html(data);
                },
                function(){
                    jAlert(authError, alert_header);
                    $('#enter_login').focus();
                }
            );
        }
        return false;
	});
    $('#send_but').click(function(){
        var name = $("#name").val();
        var email = $("#email").val();
        var subject = $("#subject").val();
        var message = $("#message").val();
        if(name!=''&&email!=''&&subject!=''&&message!=''){
            if(email.isEmailAddress()){
    	$.ajax({
    		type: "GET",
    	    url: cur_page + "/classes/send_email.php?name="+name+"&email="+email+"&subject="+subject+"&message="+message,
    	    success: function(data){
    	        var text = '';
    	        switch(data){
            	            case "send":
                                $("#name").val('');
                                $("#email").val('');
                                $("#subject").val('');
                                $("#message").val('');
                                text = messageSent;
                                break;
                    case "error_send": text = messageNotSent; break;
                    case "error_fill": text = messageNotFill; break;
                    default: text = messageNotSent; break;
    	        }
                var infoForm = new InfoForm();
                infoForm.ShowForm(
                    Function.emptyFunction,
        			Function.emptyFunction,
        			{header: req_test_noplug, message: text}
                );
    	    }
        });
            }
            else{
                var infoForm = new InfoForm();
                    infoForm.ShowForm(
                    Function.emptyFunction,
        			Function.emptyFunction,
        			{header: req_test_noplug, message: messageEmailError}
                );
            }
        }
        else{
            var infoForm = new InfoForm();
            infoForm.ShowForm(
                Function.emptyFunction,
    			Function.emptyFunction,
    			{header: req_test_noplug, message: messageNotFill}
            );
        }
    });
    // Checking email if valid
    $('#email_reg').blur(function(e){
        if($("#email_reg").val()!=''){
        	$.ajax({
        		type: "GET",
        	    url: cur_page + "/classes/check_email.php?email="+($("#email_reg").val()),
        	    success: function(data){
      			    if(data=='OK'){
                        if(checkEmail(($("#email_reg").val())) == 'OK')$('#check_email').attr('src', cur_page + '/skins/img/glob_img/accept.png');
                        else $('#check_email').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
                    }
      			    else $('#check_email').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
        	    }
            });
        }
        else $('#check_email').attr('src', cur_page + '/skins/img/glob_img/spacer.gif');
	});
    // For choising date of birth from calendar
    $('.bd').datepicker({
    	changeMonth: true,
    	changeYear: true,
        yearRange: '-90:+0'
    });
    // Making accordion for "My games"
    $("#accordion").accordion({
        autoHeight: false,
    	navigation: true
    });
    // Making tabs for account history
	$("#tabs").tabs();
    // Making style to buttons
    $("button, input:submit.submit, .load_btn, .button", 'body').button();
    // For my games, the list of games
    ProdownFrame = new ProgressiveDownloadFrame(ProdownFrameXslt);

	if(page_url=='cabinet/games') UpdateCatalog();
	
    if(SysreqManager.IsPluginInit){
        var localImagesTimer = $.timer(1000, function(timer) {
            checkstatus();
            timer.reset(1000);
        });
    }
    else {
		$("#loader").hide();
		if(SysreqManager.IsOldPlugin)
			$("#download_block td").addClass("old_plugin");
		else 
			$("#download_block td").addClass("no_plugin");
		$("#download_block td").click(function(){ location.href="http://st.playfast.ru/playfast-setup.exe";	});
		$("#download_block").show();
	}
});
;function BuyWizard(){
    this.init();
};
BuyWizard.prototype = {
    init: function(){},
    Start: function(onSucces, onFail, obj){
        $(document).trigger({type:Events.Game.Buy});
        var me = this;
        userManager.IsAnonym() ?
            this.ShowRegister(
                Function.createDelegate(
                    {onSucces: onSucces, onFail: onFail, context: obj},
                    function(){me.ShowBuyWindow(this.onSucces, this.onFail, this.context)}),
                onFail,
                obj) :
            this.ShowBuyWindow(onSucces, onFail, obj);
    },
    ShowLogin: function(onSucces, onFail, obj){
        var loginForm = new LoginForm();
        loginForm.ShowForm(onSucces, onFail, obj);
    },
    ShowRegister: function(onSucces, onFail, obj){
        var registerForm = new RegisterForm();
        registerForm.ShowForm(onSucces, onFail, obj);
    },
    ShowRemind: function(onSucces, onFail, obj){
        var remindForm = new RemindForm();
        remindForm.ShowForm(onSucces, onFail, obj);
    },
    ShowBuyWindow: function(onSucces, onFail, obj){
        var buyWindow = new BuyWindow();
        buyWindow.ShowForm(onSucces, onFail, obj);
    }
};
$(document).ready(function(){
    buyWizard = new BuyWizard();
});
;function LoginWizard(){
    this.init();
};
LoginWizard.prototype = {
    init: function(){},
    Start: function(onSucces, onFail, obj){
        userManager.IsAnonym() ? this.ShowLogin(onSucces, onFail, obj) : onFail();
    },
    ShowLogin: function(onSucces, onFail, obj){
        var loginForm = new LoginForm();
        loginForm.ShowForm(onSucces, onFail, obj);
    },
    ShowRegister: function(onSucces, onFail, obj){
        var registerForm = new RegisterForm();
        registerForm.ShowForm(onSucces, onFail, obj);
    },
    ShowRemind: function(onSucces, onFail, obj){
        var remindForm = new RemindForm();
        remindForm.ShowForm(onSucces, onFail, obj);
    }
};
$(document).ready(function(){
    loginWizard = new LoginWizard();
});
;function LoginForm(){
    this.template = '\
        <form name="authForm" id="authForm" method="post">\
            <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
                <tr>\
                    <td class="windowTabHeader">\
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                            <tr>\
                                <td width="27">&nbsp;</td>\
                                <td width="*" align="center">{authHeader}</td>\
                                <td width="27"><a id="loginForm_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td align="left" class="windowTabMsg">{authMsg}</td>\
                </tr>\
                <tr>\
                    <td align="center">\
                        <table class="windowTabBody" cellpadding="0" cellspacing="7" border="0">\
                            <tr>\
                                <td align="left">{enterLogin}</td>\
                                <td align="right" class="windowTabBody_td"><input type="text" name="enterLogin" id="enterLogin"></td>\
                                <td width="16"><img id="loginForm_checkEmail" src="{cur_page}/skins/img/glob_img/spacer.gif" width="16" height="16" alt="" border="0" /></td>\
                            </tr>\
                            <tr>\
                                <td align="left">{enterPassw}</td>\
                                <td align="right" class="windowTabBody_td"><input type="password" name="enterPassw" id="enterPassw"></td>\
                                <td width="16"><img id="loginForm_checkPass" src="{cur_page}/skins/img/glob_img/spacer.gif" width="16" height="16" alt="" border="0" /></td>\
                            </tr>\
                            <tr>\
                                <td colspan="2">\
                                    <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                                        <tr>\
                                            <td align="left"><a id="loginForm_remind_but">{remindForm}</a></td>\
                                            <td align="right"><a class="reg" id="loginForm_register_but">{regButReg}</a></td>\
                                        </tr>\
                                    </table>\
                                </td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td class="windowTabLine">&nbsp;</td>\
                </tr>\
                <tr>\
                    <td class="windowTabButtons">\
                        <input type="button" class="windowTabButton" id="loginForm_login_but" value="{Login}" />\
                        <input type="button" class="windowTabButton" id="loginForm_cancel_but" value="{closeForm}" />\
                    </td>\
                </tr>\
            </table>\
        </form>\
    ';
    this.imgUrlTemplate = '{cur_page}/skins/img/glob_img/{status}.png';
    this.onSuccess = null;
    this.onFail = null;
    this.context = null;
	this.width = 325;
    this.height = 'auto';
    this.init();
};
LoginForm.prototype = {
    init: function(){
        this.onLoginClick       = Function.createDelegate(this, this.OnLoginClick);
        this.onCloseClick       = Function.createDelegate(this, this.OnCloseClick);
        this.onRemindClick      = Function.createDelegate(this, this.OnRemindClick);
        this.onRegClick         = Function.createDelegate(this, this.OnRegClick);
        this.onCancelClick      = Function.createDelegate(this, this.OnCancelClick);
		this.onLoginKeypress    = Function.createDelegate(this, this.OnLoginKeypress);
		this.onLoginBlur	    = Function.createDelegate(this, this.OnLoginBlur);
		this.onPasswordKeypress = Function.createDelegate(this, this.OnPasswordKeypress);
    },
    ShowForm: function(onSuccess, onFail, obj){
		$(document).trigger({type:Events.Login.WizardOpen});
        this.onSuccess = onSuccess;
        this.onFail = onFail;
        this.context = obj;
        $.blockUI({
			message: this.template.template({
				authHeader: authHeader,
				authMsg: authMsg,
				enterLogin: enterLogin,
				enterPassw: enterPassw,
				Login: Login,
				closeForm: closeForm,
				remindForm: remindForm,
				regButReg: regButReg,
				cur_page: cur_page
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
            overlayCSS:{
                cursor: null
            },
			focusInput: true
		});
        $('.blockOverlay').click(this.HideForm);
        $('#loginForm_login_but').click(this.onLoginClick);
        $('#loginForm_close_but').click(this.onCloseClick);
		$('#loginForm_remind_but').click(this.onRemindClick);
		$('#loginForm_register_but').click(this.onRegClick);
		$('#loginForm_cancel_but').click(this.onCancelClick);
		$('#enterLogin').keypress(this.onLoginKeypress).blur(this.onLoginBlur);
		$('#enterPassw').keypress(this.onPasswordKeypress);
    },
    HideForm: function(){
        $.unblockUI();
    },
    CloseForm: function(){
        $(document).trigger({type:Events.Login.WizardCancel});
        this.HideForm();
    },
    OnLoginKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#enterPassw').focus();
		}
	},
    OnLoginBlur: function(){
        $('#loginForm_checkEmail').attr('src',
            this.imgUrlTemplate.template({
              cur_page: cur_page,
              status: $('#enterLogin').val().isEmailAddress() ? 'accept' : 'cancel'
            })
        );
	},
	OnPasswordKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#loginForm_login_but').click();
		}
    },
    OnLoginClick: function(){
        $(document).trigger({type:Events.Login.WizardSubmit});
        var me = this;
        if(this.IsValidForm()){
            userManager.Login(
                $('#enterLogin').val(),
                $('#enterPassw').val(),
				'Wizard',
                function(data){
                    $(document).trigger({type:Events.Login.WizardSuccess});
                    $('#authMainForm').html(data);
                    me.HideForm();
                    me.onSuccess();
                },
                function(){
                    $('#enterLogin').focus();
                    $('#loginForm_checkPass').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
        			Effects.Shake($('.blockMsg'));
                    //me.onFail();
                }
            );
        }
        else{
            $('#enterLogin').focus();
            $('#loginForm_checkPass').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
            Effects.Shake($('.blockMsg'));
        }
    },
    OnCancelClick: function(){
        this.CloseForm();
    },
    OnCloseClick: function(){
        this.CloseForm();
    },
    OnRemindClick: function(){
        this.HideForm();
        var remindForm = new RemindForm();
        remindForm.ShowForm(this.onSuccess, this.onFail, this.context);
    },
    OnRegClick: function(){
        this.HideForm();
        var registerForm = new RegisterForm();
        registerForm.ShowForm(this.onSuccess, this.onFail, this.context);
    },
    IsValidForm: function(){
        return $('#enterLogin').val().isEmailAddress()&&$('#enterPassw').val().length>0;
    },
    CheckEmail: function(){
		$.ajax({
			type: "GET",
			url: '{cur_page}/classes/check_email.php?email={email}'.template({	cur_page: cur_page, email: $("#enterLogin").val()}),
			success: function(data){
                if(data!='OK') $('#loginForm_checkEmail').attr('src', cur_page + '/skins/img/glob_img/accept.png');
                else $('#loginForm_checkEmail').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
            },
            error: WindowManager.ShowErrorWindow
		});
    }
};

;function RegisterForm(){
    this.template = '\
        <form action="" method="post" name="regform">\
            <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
                <tr>\
                    <td class="windowTabHeader">\
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                            <tr>\
                                <td width="27">&nbsp;</td>\
                                <td width="*" align="center">{regHeader}</td>\
                                <td width="27"><a id="regForm_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td align="left" class="windowTabMsg">{regMsg}</td>\
                </tr>\
                <tr>\
                    <td align="left" id="regMsg"></td>\
                </tr>\
                <tr>\
                    <td align="center">\
                        <table class="windowTabBody" cellpadding="0" cellspacing="7" border="0">\
                            <tr>\
                                <td align="left">{regEmail}: </td>\
                                <td align="right" class="windowTabBody_td"><input type="text" name="regEmail" id="regEmail"></td>\
                                <td><img src="{cur_page}/skins/img/glob_img/spacer.gif" id="regForm_checkEmail" width="16" height="16" alt="" border="0"></td>\
                            </tr>\
                            <tr>\
                                <td align="left">{regPassword}: </td>\
                                <td align="right" class="windowTabBody_td"><input type="password" name="regPassword" id="regPassword"></td>\
                                <td><img src="{cur_page}/skins/img/glob_img/spacer.gif" id="regForm_checkPassw" width="16" height="16" alt="" border="0"></td>\
                            </tr>\
                            <tr>\
                                <td align="left">{regPasswordConf}: </td>\
                                <td align="right" class="windowTabBody_td"><input type="password" name="regPasswordConf" id="regPasswordConf"></td>\
                                <td></td>\
                            </tr>\
                            <tr>\
                                <td align="left">{regNickname}: </td>\
                                <td align="right" class="windowTabBody_td"><input type="text" name="regNickname" id="regNickname"></td>\
                                <td><img src="{cur_page}/skins/img/glob_img/spacer.gif" id="regForm_checkNick" width="16" height="16" alt="" border="0"></td>\
                            </tr>\
                            <tr>\
                                <td align="left">{regReciveNews}: </td>\
                                <td align="left" class="windowTabBody_td"><input type="checkbox" name="regReciveNews" class="checkbox" id="regReciveNews" checked="checked"></td>\
                                <td width="16"></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td class="windowTabLine">&nbsp;</td>\
                </tr>\
                <tr>\
                    <td class="windowTabButtons" align="center">\
                        <input type="button" class="windowTabButton" name="regForm_reg_but" id="regForm_reg_but" value="{regButReg}">&nbsp;\
                        <input type="button" class="windowTabButton" name="regForm_cancel_but" id="regForm_cancel_but" value="{regButCancel}">&nbsp;\
                        <input type="button" class="windowTabButton" name="regForm_login_but" id="regForm_login_but" value="{regButLogin}">\
                    </td>\
                </tr>\
            </table>\
        </form>\
    ';
    this.imgUrlTemplate = '{cur_page}/skins/img/glob_img/{status}.png';
    this.onSucces = null;
    this.onFail = null;
    this.context = null;
    this.width = 377;
    this.height = 'auto';
    this.init();
};
RegisterForm.prototype = {
    init: function(){
        this.onRegClick         = Function.createDelegate(this, this.OnRegClick);
        this.onCloseClick       = Function.createDelegate(this, this.OnCloseClick);
        this.onLoginClick       = Function.createDelegate(this, this.OnLoginClick);
        this.onCancelClick      = Function.createDelegate(this, this.OnCancelClick);
        this.onLoginKeypress    = Function.createDelegate(this, this.OnLoginKeypress);
		this.onLoginBlur	    = Function.createDelegate(this, this.OnLoginBlur);
		this.onPasswKeypress    = Function.createDelegate(this, this.OnPasswKeypress);
        this.onPasswBlur	    = Function.createDelegate(this, this.OnPasswBlur);
		this.onPasswCKeypress   = Function.createDelegate(this, this.OnPasswCKeypress);
        this.onPasswCBlur	    = Function.createDelegate(this, this.OnPasswCBlur);
		this.onNickKeypress     = Function.createDelegate(this, this.OnNickKeypress);
        this.onNickBlur	        = Function.createDelegate(this, this.OnNickBlur);
    },
    ShowForm: function(onSucces, onFail, obj){
        $(document).trigger({type:Events.Register.WizardOpen});
        this.onSucces = onSucces;
        this.onFail = onFail;
        this.context = obj;
        var me = this;
        $.blockUI({
			message: this.template.template({
				regHeader       : regHeader,
				regMsg          : regMsg,
				regEmail        : regEmail,
				regPassword     : regPassword,
				regPasswordConf : regPasswordConf,
				regNickname     : regNickname,
				regReciveNews   : regReciveNews,
				regButReg       : regButReg,
				regButCancel    : regButCancel,
				regButLogin     : regButLogin,
				cur_page: cur_page
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{
                cursor: null
            }
		});
        $('.blockOverlay').click(this.HideForm);
        $('#regForm_reg_but').click(this.onRegClick);
        $('#regForm_cancel_but').click(this.onCancelClick);
        $('#regForm_login_but').click(this.onLoginClick);
        $('#regForm_close_but').click(this.onCloseClick);
        $('#regEmail').keypress(this.onLoginKeypress).blur(this.onLoginBlur);
		$('#regPassword').keypress(this.onPasswKeypress).blur(this.onPasswBlur);
        $('#regPasswordConf').keypress(this.onPasswCKeypress).blur(this.onPasswCBlur);
		$('#regNickname').keypress(this.onNickKeypress).blur(this.onNickBlur);
    },
    HideForm: function(){
        $.unblockUI();
    },
    OnLoginKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#regPassword').focus();
		}
	},
    OnLoginBlur: function(){
        var isValid = $('#regEmail').val().isEmailAddress();
        $('#regForm_checkEmail').attr('src',
            this.imgUrlTemplate.template({
              cur_page: cur_page,
              status: isValid ? 'spacer' : 'cancel'
            })
        );
        if(isValid){
            this.CheckEmail();
        }
	},
	OnPasswKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#regPasswordConf').focus();
		}
    },
    OnPasswBlur: function(){
        if($('#regPassword').val()!=''&&$('#regPasswordConf').val()!=''){
            if($('#regPassword').val()==$('#regPasswordConf').val()) $('#regForm_checkPassw').attr('src', cur_page + '/skins/img/glob_img/accept.png');
            else $('#regForm_checkPassw').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
        }
	},
    OnPasswCKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#regNickname').focus();
		}
    },
    OnPasswCBlur: function(){
        if($('#regPassword').val()!=''&&$('#regPassword').val()==$('#regPasswordConf').val()) $('#regForm_checkPassw').attr('src', cur_page + '/skins/img/glob_img/accept.png');
        else $('#regForm_checkPassw').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
	},
    OnNickKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#regForm_reg_but').click();
		}
    },
    OnNickBlur: function(){
        if($('#regNickname').val()!='') $('#regForm_checkNick').attr('src', cur_page + '/skins/img/glob_img/accept.png');
        else $('#regForm_checkNick').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
	},
    OnRegClick: function(){
        $(document).trigger({type:Events.Register.WizardSubmit});
        var me = this;
        if(this.IsValidForm()){
            userManager.Register(
                $("#regEmail").val(),
  				$("#regPassword").val(),
  				$("#regPasswordConf").val(),
  				$("#regNickname").val(),
  				(document.getElementById('regReciveNews').checked)?1:0,
				'Wizard',
                function(data){
                    $('#authMainForm').html(data);
                    me.HideForm();
                    me.onSucces();
                },
                function(){
                    $('#regEmail').focus();
			        Effects.Shake($('.blockMsg'));
                }
            );
        }
        else{
            $(document).trigger({type:Events.Register.WizardFail});
            $('#regEmail').focus();
            Effects.Shake($('.blockMsg'));
        }
    },
    OnCancelClick: function(){
        this.CloseForm();
    },
    OnCloseClick: function(){
        this.CloseForm();
    },
    CloseForm: function(){
        $(document).trigger({type:Events.Register.WizardCancel});
        this.HideForm();
    },
    OnLoginClick: function(){
        this.HideForm();
        buyWizard.ShowLogin(this.onSucces, this.onFail, this.context);
    },
    IsValidForm: function(){
        return  $('#regEmail').val().isEmailAddress()&&
                $('#regPassword').val().length>0&&
                $('#regPassword').val()==$('#regPasswordConf').val()&&
                $('#regNickname').val().length>0;
    },
    CheckEmail: function(){
		$.ajax({
			type: "GET",
			url: '{cur_page}/classes/check_email.php?email={email}'.template({	cur_page: cur_page, email: $("#regEmail").val()}),
			success: function(data){
                if(data=='OK') $('#regForm_checkEmail').attr('src', cur_page + '/skins/img/glob_img/accept.png');
                else $('#regForm_checkEmail').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
            },
            error: WindowManager.ShowErrorWindow 
		});
    }
};
;function RemindForm(){
    this.template = '\
        <form name="remindForm" id="remindForm" method="post">\
            <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
                <tr>\
                    <td class="windowTabHeader">\
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                            <tr>\
                                <td width="27">&nbsp;</td>\
                                <td width="*" align="center">{remindHeader}</td>\
                                <td width="27"><a id="remindForm_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td align="left" class="windowTabMsg">{remindMsg}</td>\
                </tr>\
                <tr>\
                    <td align="center">\
                        <table class="windowTabBody" cellpadding="0" cellspacing="7" border="0">\
                            <tr>\
                                <td align="left">{remindEmail}</td>\
                                <td align="left"><input type="text" name="remindEmail" id="remindEmail"></td>\
                                <td width="16"><img id="remindForm_checkEmail" src="{cur_page}/skins/img/glob_img/spacer.gif" width="16" height="16" alt="" border="0" /></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td class="windowTabLine">&nbsp;</td>\
                </tr>\
                <tr>\
                    <td class="windowTabButtons">\
                        <input type="button" class="windowTabButton" id="remindForm_login_but" value="{Remind}" />\
                        <input type="button" class="windowTabButton" id="remindForm_cancel_but" value="{closeForm}" />\
                    </td>\
                </tr>\
            </table\
        </form>\
    ';
    this.onSucces = null;
    this.onFail = null;
    this.context = null;
    this.width = 360;
    this.height = 'auto';
    this.init();
};
RemindForm.prototype = {
    init: function(){
        this.onRemindSucces     = Function.createDelegate(this, this.OnRemindSucces);
        this.onRemindClick      = Function.createDelegate(this, this.OnRemindClick);
        this.onCloseClick       = Function.createDelegate(this, this.OnCloseClick);
        this.onCancelClick      = Function.createDelegate(this, this.OnCancelClick);
        this.onRemindKeypress   = Function.createDelegate(this, this.OnRemindKeypress);
    },
    ShowForm: function(onSucces, onFail, obj){
        this.onSucces = onSucces;
        this.onFail = onFail;
        this.context = obj;
        var me = this;
        $.blockUI({
			message: this.template.template({
				remindHeader: remindHeader,
				remindMsg: remindMsg,
				remindEmail: remindEmail,
				Remind: Remind,
				cur_page: cur_page,
				closeForm: closeForm,
				cur_page: cur_page
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{
                cursor: null
            }
		});
        $('.blockOverlay').click($.unblockUI);
		$('#remindForm_login_but').click(this.onRemindClick);
        $('#remindForm_close_but').click(this.onCloseClick);
        $('#remindForm_cancel_but').click(this.onCancelClick);
        $('#remindEmail').keypress(this.onRemindKeypress).blur(this.onRemindBlur);
    },
    HideForm: function(){
        $.unblockUI();
    },
    OnRemindSucces: function(data){
        if(data=='OK'){
            this.HideForm();
            var infoForm= new InfoForm();
            infoForm.ShowForm(this.onSucces, this.onFail, {message:RemindOkMessage});
            //this.onSucces();
    	}
        else{
            $('#remindEmail').focus();
            $('#remindForm_checkEmail').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
            $('#remindForm_checkEmail').attr('alt', data);
			Effects.Shake($('.blockMsg'));
            //this.onFail();
		}
    },
    OnRemindKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#remindForm_login_but').click();
		}
		return false;
	},
    OnRemindClick: function(){
        if(this.IsValidForm()){
            $.ajax({
    			type: "GET",
    			url: '{cur_page}/classes/remind.php?email={email}&lang={lang}'.template({
    				cur_page: cur_page,
    				lang: language,
    				email: $("#remindEmail").val()
    				}),
    			success: this.onRemindSucces,
                error: WindowManager.ShowErrorWindow 
    		});
        }
        else{
            $('#regEmail').focus();
            Effects.Shake($('.blockMsg'));
        }
		return false;
    },
    OnCancelClick: function(){
        this.HideForm();
		return false;
    },
    OnCloseClick: function(){
        this.HideForm();
		return false;
    },
    IsValidForm: function(){
        return $('#remindEmail').val().isEmailAddress();
    }
};
;function BuyWindow(){
    this.template = '\
        <div>\
            <div style="float:left;width: 120px; height: 20px; text-align:left;">\
                <a style="margin-right:6px;margin-top:6px;" href="javascript://" id="buyWindowBackButton">\
                    <img src="{cur_page}/skins/img/glob_img/back_buybox.png">\
                </a>\
            </div>\
            <div style="float:right;width:15px;height:15px;">\
                <a style="margin-right:6px;margin-top:6px;" href="javascript://" id="buyWindowButton">\
                    <img src="{cur_page}/skins/img/glob_img/close_buybox.gif">\
                </a>\
            </div>\
        </div>\
        <div style="text-align:center;margin-top:300px;width:100%;z-index:1" id="frameLoader">{pageLoadingMsg}</div>\
        <iframe frameborder="0" hspace="0" name="pp_frame" id="pp_frame" src="{link}" width="800" height="600" border="0" style="display:none;"></iframe>\
    ';
	this.alQuery = "{api_url}?api=lcr&lic_type={license}&game_id={uuid}&userid={userid}";
	this.frameUrl = "{api_url}?api=pp&{pp_param}={uuid}{pp_param2}&userid={userId}";
    this.onSucces = null;
    this.onFail = null;
    this.context = null;
    this.width = 800;
	this.height = 610;
    this.init();
};
BuyWindow.prototype = {
    init: function(){
        this.onCloseClick = Function.createDelegate(this, this.OnCloseClick);
        this.onBackClick = Function.createDelegate(this, this.OnBackClick);
        this.onLoadFrame = Function.createDelegate({context:this}, this.OnLoadFrame);
    },
    ShowForm: function(onSucces, onFail, obj){
        $(document).trigger({type:Events.Buy.Open});
        if(obj.pp_param=='game_id'){
            obj.rate = 'buy';
            RatingManager.Rate(obj);
        }
        var me = this;
        this.onSucces = onSucces;
        this.onFail = onFail;
        this.context = obj;
        $.blockUI({
            message: this.template.template({
                cur_page: cur_page,
                link: this.frameUrl.template({
                    api_url: api_url,
                    uuid: this.context.uuid,
                    pp_param: this.context.pp_param,
                    pp_param2: (this.context.game_id)?'&game_id='+this.context.game_id:'',
                    userId: Cookie.Get('account').userid
                }),
                pageLoadingMsg: pageLoadingMsg
            }),
            css:{
                height: this.height + 'px',
                width: this.width + 'px',
                top:  ($(window).height() - this.height)/2 + 'px',
                left: ($(window).width() - this.width)/2 + 'px'
            },
			overlayCSS:{
                cursor: null
            }
        });
        $('#pp_frame').bind('load', this.onLoadFrame);
        //$('.blockOverlay').click(this.HideForm);
        $('#buyWindowButton').click(this.onCloseClick);
        $('#buyWindowBackButton').click(this.onBackClick);
    },
    HideForm: function(){
        $.unblockUI();
    },
    OnLoadFrame: function(){
        if($("#pp_frame:visible").length == 0){
   			$("#frameLoader").hide();
            var frame = $("#pp_frame");
            var frameDocument = frame[0].contentDocument;
			frame.show();
            $("#webmoney", frameDocument).click(function(){$(document).trigger({type:Events.Buy.WebMoney});});
            $("#yandex", frameDocument).click(function(){$(document).trigger({type:Events.Buy.YandexMoney});});
            $("#qiwi", frameDocument).click(function(){$(document).trigger({type:Events.Buy.Qiwi});});
            $("#moneymail", frameDocument).click(function(){$(document).trigger({type:Events.Buy.MoneyMail});});
            $("#wallet1", frameDocument).click(function(){$(document).trigger({type:Events.Buy.W1});});
            $("#rbkmoney", frameDocument).click(function(){$(document).trigger({type:Events.Buy.RbkMoney});});
            $("#send_promocode", frameDocument).click(function(){$(document).trigger({type:Events.Buy.PromoCode});});
            $("#send_code", frameDocument).click(function(){$(document).trigger({type:Events.Buy.Sms});});
        }
		var result = Cookie.Get('x-json');
        if(result){
			this.context.OnBuy(result);
            Cookie.Delete('x-json', {path: '/'});
        }
    },
    OnCloseClick: function(){
        $(document).trigger({type:Events.Buy.Close});
        this.HideForm();
        return false;
    },
    OnBackClick: function(){
        frames.pp_frame.history.back();
        return false;
    },
    OnBuy: function(result){
        this.HideForm();
		// TODO: Remove direct wondow call, use callBack instead
        var infoForm = new InfoForm();
		var parentLocation = $(window)[0].parent.location;
		var url = 'http://{host}{uri}'.template({ host: parentLocation.hostname, uri: uri });
		if(result.status){
		    $(document).trigger({type:Events.Buy.Success});
			var _header = onSuccesBuyHeader;
            switch(result.type){
                case "game": msg = onSuccesBuyMsg_game; break;
                case "sub": msg = onSuccesBuyMsg_sub; break;
                //case "subs_extend": msg = onSuccesBuyMsg_subext; break;
                case "rent": msg = onSuccesBuyMsg_rent; break;
                //case "rent_extend": msg = onSuccesBuyMsg_rentext; break;
            }
			if(result.serial)
				msg += serialWarn.template({serial: result.serial});
			if(result.type=="game")
				drm.acquireLicense(this.alQuery.template({api_url: api_url, license: "buy", uuid: result.game_id, userid: Cookie.Get(Cookie.BaseName) ? Cookie.Get(Cookie.BaseName).userid : ''}));
		}
		else{
		    $(document).trigger({type:Events.Buy.Fail});
			var _header = onErrorBuyHeader;
			msg = onErrorBuyMsg;
		}

        infoForm.ShowForm(
            function(){$(window)[0].location.href=url;},
			Function.emptyFunction,
			{header: _header, message: msg}
        );
    }
};
;function RemindForm(){
    this.template = '\
        <form name="remindForm" id="remindForm" method="post">\
            <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
                <tr>\
                    <td class="windowTabHeader">\
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                            <tr>\
                                <td width="27">&nbsp;</td>\
                                <td width="*" align="center">{remindHeader}</td>\
                                <td width="27"><a id="remindForm_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td align="left" class="windowTabMsg">{remindMsg}</td>\
                </tr>\
                <tr>\
                    <td align="center">\
                        <table class="windowTabBody" cellpadding="0" cellspacing="7" border="0">\
                            <tr>\
                                <td align="left">{remindEmail}</td>\
                                <td align="left"><input type="text" name="remindEmail" id="remindEmail"></td>\
                                <td width="16"><img id="remindForm_checkEmail" src="{cur_page}/skins/img/glob_img/spacer.gif" width="16" height="16" alt="" border="0" /></td>\
                            </tr>\
                        </table>\
                    </td>\
                </tr>\
                <tr>\
                    <td class="windowTabLine">&nbsp;</td>\
                </tr>\
                <tr>\
                    <td class="windowTabButtons">\
                        <input type="button" class="windowTabButton" id="remindForm_login_but" value="{Remind}" />\
                        <input type="button" class="windowTabButton" id="remindForm_cancel_but" value="{closeForm}" />\
                    </td>\
                </tr>\
            </table\
        </form>\
    ';
    this.onSucces = null;
    this.onFail = null;
    this.context = null;
    this.width = 360;
    this.height = 'auto';
    this.init();
};
RemindForm.prototype = {
    init: function(){
        this.onRemindSucces     = Function.createDelegate(this, this.OnRemindSucces);
        this.onRemindClick      = Function.createDelegate(this, this.OnRemindClick);
        this.onCloseClick       = Function.createDelegate(this, this.OnCloseClick);
        this.onCancelClick      = Function.createDelegate(this, this.OnCancelClick);
        this.onRemindKeypress   = Function.createDelegate(this, this.OnRemindKeypress);
    },
    ShowForm: function(onSucces, onFail, obj){
        this.onSucces = onSucces;
        this.onFail = onFail;
        this.context = obj;
        var me = this;
        $.blockUI({
			message: this.template.template({
				remindHeader: remindHeader,
				remindMsg: remindMsg,
				remindEmail: remindEmail,
				Remind: Remind,
				cur_page: cur_page,
				closeForm: closeForm,
				cur_page: cur_page
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{
                cursor: null
            }
		});
        $('.blockOverlay').click($.unblockUI);
		$('#remindForm_login_but').click(this.onRemindClick);
        $('#remindForm_close_but').click(this.onCloseClick);
        $('#remindForm_cancel_but').click(this.onCancelClick);
        $('#remindEmail').keypress(this.onRemindKeypress).blur(this.onRemindBlur);
    },
    HideForm: function(){
        $.unblockUI();
    },
    OnRemindSucces: function(data){
        if(data=='OK'){
            this.HideForm();
            var infoForm= new InfoForm();
            infoForm.ShowForm(this.onSucces, this.onFail, {message:RemindOkMessage});
            //this.onSucces();
    	}
        else{
            $('#remindEmail').focus();
            $('#remindForm_checkEmail').attr('src', cur_page + '/skins/img/glob_img/cancel.png');
            $('#remindForm_checkEmail').attr('alt', data);
			Effects.Shake($('.blockMsg'));
            //this.onFail();
		}
    },
    OnRemindKeypress: function(e){
		if(isEnterKey(e)){
			e.preventDefault();
			$('#remindForm_login_but').click();
		}
		return false;
	},
    OnRemindClick: function(){
        if(this.IsValidForm()){
            $.ajax({
    			type: "GET",
    			url: '{cur_page}/classes/remind.php?email={email}&lang={lang}'.template({
    				cur_page: cur_page,
    				lang: language,
    				email: $("#remindEmail").val()
    				}),
    			success: this.onRemindSucces,
                error: WindowManager.ShowErrorWindow 
    		});
        }
        else{
            $('#regEmail').focus();
            Effects.Shake($('.blockMsg'));
        }
		return false;
    },
    OnCancelClick: function(){
        this.HideForm();
		return false;
    },
    OnCloseClick: function(){
        this.HideForm();
		return false;
    },
    IsValidForm: function(){
        return $('#remindEmail').val().isEmailAddress();
    }
};
;function InfoForm(){
    this.template = '\
    <form name="infoForm" id="infoForm" method="post">\
        <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
            <tr>\
                <td class="windowTabHeader">\
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                        <tr>\
                            <td width="27">&nbsp;</td>\
                            <td width="*" align="center">{infoHeader}</td>\
                            <td width="27"><a id="infoForm_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td align="center">\
                    <table class="windowTabBody2" cellpadding="0" cellspacing="7" border="0">\
                        <tr>\
                            <td align="left">\
                                <div class="infoForm" align="center">\
	                                {message}\
                                </div>\
                            </td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td class="windowTabLine">&nbsp;</td>\
            </tr>\
            <tr>\
                <td class="windowTabButtons">\
                    <input type="button" id="infoForm_ok_but" value="{okForm}" />\
                </td>\
            </tr>\
        </table>\
    </form>\
    ';
    this.onSucces = null;
    this.onFail = null;
	this.context = null;
    this.width = 350;
	this.height = 'auto';
	this.init();
};
InfoForm.prototype = {
    init: function(){
        this.onOkClick = Function.createDelegate(this, this.OnOkClick);
        this.onCloseClick = Function.createDelegate(this, this.OnCloseClick);
    },
    ShowForm: function(onSucces, onFail, obj){
        this.onSucces = onSucces;
        this.onFail = onFail;
		this.context = obj;
		if (this.context.width!=undefined) this.width = this.context.width;
		if (this.context.height!=undefined) this.height = this.context.height;
        $.blockUI({
            message: this.template.template({
				cur_page: cur_page,
				message: this.context.message,
				infoHeader: this.context.header,
				okForm: okForm
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{cursor: null}
        });
        $('.blockOverlay').click(this.HideForm);
		$('#infoForm_ok_but').click(this.onOkClick);
		$('#infoForm_close_but').click(this.onCloseClick);
    },
    HideForm: function(){
        $.unblockUI();
    },
    OnOkClick: function(){
		this.HideForm();
        this.onSucces();
        return false;
	},
	OnCloseClick: function(){
        this.HideForm();
	}
};

;function SysReqForm(){
    this.template = '\
        <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
            <tr>\
                <td class="windowTabHeader">\
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                        <tr>\
                            <td width="27">&nbsp;</td>\
                            <td width="*" align="center">{SRHeader}</td>\
                            <td width="27"><a id="sysreqWin_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td align="left" class="windowTabMsg" id="sysReqCont" style="padding: 10px 5px;">{SRMsg}</td>\
            </tr>\
            <tr>\
                <td class="windowTabLine">&nbsp;</td>\
            </tr>\
            <tr>\
                <td class="windowTabButtons">\
                    <input type="button" class="windowTabButton{hideOK}" id="sysreqWin_ok_but" value="{SRokBut}" />\
                    <input type="button" class="windowTabButton{hidePlay}" id="sysreqWin_retest_but" value="{SRtestBut}" />\
                    <input type="button" class="windowTabButton{hideTest}" id="sysreqWin_play_but" value="{SRPlayBut}" />\
                    <input type="button" class="windowTabButton" id="sysreqWin_cancel_but" value="{SRcancelBut}" />\
                </td>\
            </tr>\
        </table>\
    ';
    this.templatePluginNotInstalled = '\
        <div style="float: right; width: 15px; height: 15px;"><a style="margin-right:6px;margin-top:6px;" href="javascript://" id="sysreqWin_close_but"><img src="{cur_page}/skins/img/glob_img/close_buybox.gif"></a></div>\
        <div class="windowTabMsg">\
            <p class="no-pluginMsgHeader">{SRHeader_pni}</span></p>\
            <div class="smile-div"><img src="{cur_page}/skins/img/glob_img/smile1.jpg" width="235" height="185" class="smile-img"></div>\
            <div class="smile-div"><img src="{cur_page}/skins/img/glob_img/smile2.jpg" width="235" height="185" class="smile-img"></div>\
            <div class="texts">\
                <b>{SRMsg_pni1}</b><br />\
                <ul>\
                    <li>{SRMsg_pni2}</li>\
                    <li>{SRMsg_pni3}</li>\
                    <li>{SRMsg_pni4}</li>\
                    <li>{SRMsg_pni5}</li>\
                </ul>\
            </div>\
            <div class="texts">\
                <a class="plugin" href="http://st.playfast.ru/playfast-setup.exe" rel="nofollow"><img src="{cur_page}/skins/img/glob_img/no-plugin.png" width="218" height="51"></a><br /><br />\
                {SRMsg_pni6}<br />\
                <p class="windowTabButtons">\
                    <p style="text-align:justify;font-size:11px;line-height:12px;padding-right:10px;">{SRMsg_pni8}</p>\
                </p>\
                <div>\
                    <input type="button" class="windowTabButton" id="sysreqWin_ok_but" value="{SRokBut}" style="float:right;width:60px;margin-right:10px;" />\
                </div>\
            </div>\
        </div>\
    ';
    this.reqTemplate = '<a href="{url}">{name}</a><br />';
    this.onSucces = null;
    this.onFail = null;
    this.context = null;
	this.width = 608;
    this.height = 515;
    this.init();
};
SysReqForm.prototype = {
    init: function(){
        this.onOKClick          = Function.createDelegate(this, this.OnOKClick);
        this.onCloseClick       = Function.createDelegate(this, this.OnCloseClick);
        this.onCancelClick      = Function.createDelegate(this, this.OnCancelClick);
        this.onPlayClick        = Function.createDelegate(this, this.OnPlayClick);
        this.onRetestClick      = Function.createDelegate(this, this.OnRetestClick);
    },
    ShowForm: function(onSucces, onFail, obj){
        if(SysreqManager.IsOldPlugin){
            this.width = 360;
            this.height = 'auto';
            var bodyMsg = SRMsg2;
            var bodyHeader = SRHeader;
            msgBuild = this.template.template({
  				SRHeader: bodyHeader,
  				SRMsg: bodyMsg,
  				SRokBut: SRokBut,
  				SRtestBut: SRtestBut,
  				SRPlayBut: SRPlayBut,
  				SRcancelBut: SRcancelBut,
  				cur_page: cur_page,
                hideOK: (SysreqManager.IsPluginInit)?' hidden':'',
                hidePlay: (SysreqManager.IsPluginInit)?'':' hidden',
                hideTest: (SysreqManager.IsPluginInit)?'':' hidden'
  			});
        }
        $(document).trigger({type:Events.Game.Play, license: obj.attributes[2].value});
        if(SysreqManager.IsPluginInit){
            this.width = 360;
            this.height = 'auto';
            $(document).trigger({type: Events.Game.PluginTrue});
            //$(document).trigger({type: Events.Game.SysReqFalse});
            bodyMsg = this.GetWindowContent();
            bodyHeader = SRHeader2;
            msgBuild = this.template.template({
  				SRHeader: bodyHeader,
  				SRMsg: bodyMsg,
  				SRokBut: SRokBut,
  				SRtestBut: SRtestBut,
  				SRPlayBut: SRPlayBut,
  				SRcancelBut: SRcancelBut,
  				cur_page: cur_page,
                hideOK: (SysreqManager.IsPluginInit)?' hidden':'',
                hidePlay: (SysreqManager.IsPluginInit)?'':' hidden',
                hideTest: (SysreqManager.IsPluginInit)?'':' hidden'
  			});
        }
        else if(!SysreqManager.IsOldPlugin){
            var bodyMsg = SRMsg3;
            msgBuild = this.templatePluginNotInstalled.template({
  				cur_page: cur_page,
                SRHeader_pni: SRHeader_pni,
                SRokBut: SRokBut,
                SRMsg_pni1: SRMsg_pni1,
                SRMsg_pni2: SRMsg_pni2,
                SRMsg_pni3: SRMsg_pni3,
                SRMsg_pni4: SRMsg_pni4,
                SRMsg_pni5: SRMsg_pni5,
                SRMsg_pni6: SRMsg_pni6,
                SRMsg_pni7: SRMsg_pni7,
                SRMsg_pni8: SRMsg_pni8
  			});
            $(document).trigger({type: Events.Game.PluginFalse});
            $('#sysreqWin_play_but').hide();
            $('#sysreqWin_retest_but').hide();
        }
        if(!bodyMsg.IsEmpty()){
            this.onSucces = onSucces;
            this.onFail = onFail;
            this.context = obj;
            $.blockUI({
    			message: msgBuild,
                css:{
                    cursor: null,
                    width: (this.width!='auto') ? this.width + 'px' : 'auto',
                    height: (this.height!='auto') ? this.height + 'px' : 'auto',
                    top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                    left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
                },
                overlayCSS:{cursor: null}
    		});
            $('.blockOverlay').click(this.HideForm);
            $('#sysreqWin_ok_but').click(this.onOKClick);
            $('#sysreqWin_close_but').click(this.onCloseClick);
            $('#sysreqWin_cancel_but').click(this.onCancelClick);
            $('#sysreqWin_play_but').click(this.onPlayClick);
            $('#sysreqWin_retest_but').click(this.onRetestClick);
        }
        else{
            //$(document).trigger({type: Events.Game.SysReqTrue});
            this.StartGame();
        }
    },
    HideForm: function(){
        $.unblockUI();
    },
    OnOKClick: function(){
        ReloadWindow(null,true);
	},
    OnCancelClick: function(){
        this.HideForm();
    },
    OnCloseClick: function(){
        this.HideForm();
    },
    OnPlayClick: function(){
        //$(document).trigger({type: Events.Game.SysReqFalseOverride});
        this.HideForm();
        this.StartGame();
    },
    StartGame: function(){
        var play_btn = $('#play_but');
        obj = {};
        obj.uuid = play_btn.attr('uuid');
        obj.license = play_btn.attr('license');
        GameManager.OnLoadClick(obj);
    },
    OnRetestClick: function(){
        this.UpdateWindow();
    },
    GetReqHTML: function(data){
        var result = String.Empty;
        for(var i=0;i<data.length;i++){
            var item = data[i];
            if(!item.status)result += this.reqTemplate.template({url:item.url,name:item.name});
        }
        return result;
    },
    UpdateWindow: function(){
        $('#sysReqCont').html(this.GetWindowContent());
    },
    GetWindowContent: function(){
      return this.GetReqHTML(SysreqManager.Check());
    }
};

;function GlobalBuyForm(){
    this.template = '\
	<form name="globalForm" id="globalForm" method="post">\
        <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
            <tr>\
                <td class="windowTabHeader">\
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                        <tr>\
                            <td width="27">&nbsp;</td>\
                            <td width="*" align="center">{globalBWinHeader}</td>\
                            <td width="27"><a id="buyWin_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td align="center">\
                    <table class="windowTabBody" cellpadding="0" cellspacing="7" border="0">\
                        <tr>\
                            <td align="left">{globalBWinMsg}</td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td class="windowTabLine">&nbsp;</td>\
            </tr>\
            <tr>\
                <td class="windowTabButtons">\
                    <input type="button" class="windowTabButton" id="buyWin_buy_but" value="{globalBWinBuyBut}" />&nbsp;\
                    <input type="button" class="windowTabButton" id="buyWin_cancel_but" value="{globalBWinCancelBut}" />\
                </td>\
            </tr>\
        </table>\
    </form>\
	';
    this.onSucces = null;
    this.onFail = null;
	this.context = null;
    this.width = 360;
	this.height = 'auto';
	this.init();
};
GlobalBuyForm.prototype = {
    init: function(){
        this.onCloseClick = Function.createDelegate(this, this.OnCloseClick);
        this.onCancelClick = Function.createDelegate(this, this.OnCancelClick);
        this.onBuyClick = Function.createDelegate(this, this.OnBuyClick);
    },
    ShowForm: function(onSucces, onFail, obj){
		$(document).trigger({type:Events.Game.LongPlay});
        this.onSucces = onSucces;
        this.onFail = onFail;
		this.context = obj;
        $.blockUI({
            message: this.template.template({
				cur_page: cur_page,
				globalBWinMsg: globalBWinMsg,
				globalBWinHeader: globalBWinHeader,
				globalBWinBuyBut: globalBWinBuyBut,
				globalBWinCancelBut: globalBWinCancelBut
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{
                cursor: null
            }
        });
        $('.blockOverlay').click(this.HideForm);
		$('#buyWin_buy_but').click(this.onBuyClick);
		$('#buyWin_close_but').click(this.onCloseClick);
		$('#buyWin_cancel_but').click(this.onCancelClick);
    },
    HideForm: function(){
        $.unblockUI();
    },
	OnCloseClick: function(){
        this.HideForm();
    },
	OnCancelClick: function(){
        this.HideForm();
    },
	OnBuyClick: function(){
	    var runGame = Cookie.Get('runGame');
        buyWizard.Start(Function.emptyFunction, Function.emptyFunction, {uuid: runGame, pp_param: 'game_id'});
    }
};

;function GlobalProblemForm(){
    this.template = '\
	<form name="globalForm" id="globalForm" method="post">\
        <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
            <tr>\
                <td class="windowTabHeader">\
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                        <tr>\
                            <td width="27">&nbsp;</td>\
                            <td width="*" align="center">{globalPWinHeader}</td>\
                            <td width="27"><a id="problemWin_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td align="center">\
                    <table class="windowTabBody2" cellpadding="0" cellspacing="7" border="0">\
                        <tr>\
                        	<td>{globalPWinMsg2}</td>\
                            <td width="15">&nbsp;</td>\
                            <td><input type="button" class="windowTabButton" id="problemWin_help_but" value="{globalPWinHelpBut}" /></td>\
                        </tr>\
                        <tr>\
                        	<td>{globalPWinMsg3}</td>\
                            <td width="15">&nbsp;</td>\
                            <td><input type="button" class="windowTabButton" id="problemWin_buy_but" value="{globalPWinBuyBut}" /></td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td class="windowTabLine">&nbsp;</td>\
            </tr>\
            <tr>\
                <td class="windowTabButtons">\
                    <input type="button" class="windowTabButton" id="problemWin_cancel_but" value="{globalPWinCancelBut}" />\
                </td>\
            </tr>\
        </table>\
    </form>\
	';
    this.onSucces = null;
    this.onFail = null;
	this.context = null;
    this.width = 460;
	this.height = 'auto';
	this.init();
};
GlobalProblemForm.prototype = {
    init: function(){
        this.onCloseClick = Function.createDelegate(this, this.OnCloseClick);
        this.onCancelClick = Function.createDelegate(this, this.OnCancelClick);
        this.onBuyClick = Function.createDelegate(this, this.OnBuyClick);
        this.onHelpClick = Function.createDelegate(this, this.OnHelpClick);
    },
    ShowForm: function(onSucces, onFail, obj){
        $(document).trigger({type:Events.Game.ShortPlay});
        this.onSucces = onSucces;
        this.onFail = onFail;
		this.context = obj;
        $.blockUI({
            message: this.template.template({
				cur_page: cur_page,
				globalPWinHeader: globalPWinHeader,
				globalPWinMsg1: globalPWinMsg1,
				globalPWinMsg2: globalPWinMsg2,
				globalPWinMsg3: globalPWinMsg3,
				globalPWinHelpBut: globalPWinHelpBut,
				globalPWinBuyBut: globalPWinBuyBut,
				globalPWinCancelBut: globalPWinCancelBut
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{
                cursor: null
            }
        });
        $('.blockOverlay').click(this.HideForm);
		$('#problemWin_buy_but').click(this.onBuyClick);
		$('#problemWin_close_but').click(this.onCloseClick);
		$('#problemWin_help_but').click(this.onHelpClick);
		$('#problemWin_cancel_but').click(this.onCancelClick);
    },
    HideForm: function(){
        $.unblockUI();
    },
	OnCloseClick: function(){
        this.HideForm();
    },
	OnCancelClick: function(){
        this.HideForm();
    },
	OnBuyClick: function(){
	    var runGame = Cookie.Get('runGame');
        buyWizard.Start(Function.emptyFunction, Function.emptyFunction, {uuid: runGame, pp_param: 'game_id'});
    },
	OnHelpClick: function(){
        document.location.href= '{cur_page}{language}/help/'.template({cur_page: cur_page, language: language});
    }
};

;function StartGameForm(){
    this.template = '\
        <table class="windowTab" cellpadding="0" cellspacing="3" border="0">\
            <tr>\
                <td class="windowTabHeader">\
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                        <tr>\
                            <td width="27">&nbsp;</td>\
                            <td width="*" align="center">{sgWinHeader}</td>\
                            <td width="27"><a id="sgWin_close_but"><img src="{cur_page}/skins/img/glob_img/windowTabCloseBut.gif" width="27" height="24" alt="" /></a></td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td align="center">\
                    <table class="windowTabBody2" cellpadding="0" cellspacing="7" border="0">\
                        <tr>\
                        	<td>{sgWinMsg}</td>\
                        </tr>\
                    </table>\
                </td>\
            </tr>\
            <tr>\
                <td class="windowTabLine">&nbsp;</td>\
            </tr>\
            <tr>\
                <td class="windowTabButtons">\
                    <input type="button" class="windowTabButton" id="sgWin_play_but" value="{sgWinPlayBut}" />\
                    <input type="button" class="windowTabButton" id="sgWin_cancel_but" value="{sgWinCancelBut}" />\
                </td>\
            </tr>\
        </table>\
	';
    this.onSucces = null;
    this.onFail = null;
	this.context = null;
    this.width = 360;
	this.height = 'auto';
	this.init();
};
StartGameForm.prototype = {
    init: function(){
        this.onCloseClick = Function.createDelegate(this, this.OnCloseClick);
        this.onCancelClick = Function.createDelegate(this, this.OnCancelClick);
        this.onPlayClick = Function.createDelegate(this, this.OnPlayClick);
    },
    ShowForm: function(onSucces, onFail, obj){
        this.onSucces = onSucces;
        this.onFail = onFail;
		this.context = obj;
        $.blockUI({
            message: this.template.template({
				cur_page: cur_page,
				sgWinHeader: sgWinHeader,
				sgWinMsg: sgWinMsg,
				sgWinPlayBut: sgWinPlayBut,
				sgWinCancelBut: sgWinCancelBut
			}),
            css:{
                cursor: null,
                width: (this.width!='auto') ? this.width + 'px' : 'auto',
                height: (this.height!='auto') ? this.height + 'px' : 'auto',
                top:  (this.height!='auto')?($(window).height() - this.height)/2 + 'px':'40%',
                left: (this.width!='auto')?($(window).width() - this.width)/2 + 'px':'35%'
            },
			overlayCSS:{
                cursor: null
            }
        });
        $('.blockOverlay').click(this.HideForm);
		$('#sgWin_play_but').click(this.onPlayClick);
		$('#sgWin_close_but').click(this.onCloseClick);
		$('#sgWin_cancel_but').click(this.onCancelClick);
    },
    HideForm: function(){
        $.unblockUI();
    },
	OnCloseClick: function(){
        this.HideForm();
    },
	OnCancelClick: function(){
        this.HideForm();
    },
	OnPlayClick: function(){
	    this.HideForm();
	    GameManager.OnPlayClick();
    }
};
;(function(){var aa="_gat",ba="_gaq",r=true,v=false,w=undefined,ca=document,da="4.7.2",y="length",z="cookie",A="location",ea="_gaUserPrefs",fa="ioo",B="&",C="=",D="__utma=",F="__utmb=",G="__utmc=",ga="__utmk=",H="__utmv=",K="__utmz=",L="__utmx=",ha="GASO=";var M=function(i){return w==i||"-"==i||""==i},ia=function(i){return i[y]>0&&" \n\r\t".indexOf(i)>-1},O=function(i,f,m){var u="-",l;if(!M(i)&&!M(f)&&!M(m)){l=i.indexOf(f);if(l>-1){m=i.indexOf(m,l);if(m<0)m=i[y];u=N(i,l+f.indexOf(C)+1,m)}}return u},ka=function(i){var f=v,m=0,u,l;if(!M(i)){f=r;for(u=0;u<i[y];u++){l=i.charAt(u);m+="."==l?1:0;f=f&&m<=1&&(0==u&&"-"==l||".0123456789".indexOf(l)>-1)}}return f},P=function(i,f){var m=encodeURIComponent;return m instanceof Function?f?encodeURI(i):m(i):escape(i)},
Q=function(i,f){var m=decodeURIComponent,u;i=i.split("+").join(" ");if(m instanceof Function)try{u=f?decodeURI(i):m(i)}catch(l){u=unescape(i)}else u=unescape(i);return u},R=function(i,f){return i.indexOf(f)>-1},S=function(i,f){i[i[y]]=f},U=function(i){return i.toLowerCase()},V=function(i,f){return i.split(f)},la=function(i,f){return i.indexOf(f)},N=function(i,f,m){m=w==m?i[y]:m;return i.substring(f,m)},ma=function(i,f){return i.join(f)},na=function(i){var f=1,m=0,u;if(!M(i)){f=0;for(u=i[y]-1;u>=0;u--){m=
i.charCodeAt(u);f=(f<<6&268435455)+m+(m<<14);m=f&266338304;f=m!=0?f^m>>21:f}}return f},oa=function(){var i=window,f=w;if(i&&i.gaGlobal&&i.gaGlobal.hid)f=i.gaGlobal.hid;else{f=W();i.gaGlobal=i.gaGlobal?i.gaGlobal:{};i.gaGlobal.hid=f}return f},W=function(){return Math.round(Math.random()*2147483647)},pa=function(i,f){var m=ca.createElement("script");m.type="text/javascript";m.src=i;if(f)m.id=f;(ca.getElementsByTagName("head")[0]||ca.getElementsByTagName("body")[0]).appendChild(m)};var ra=function(i,f){this.Wa=i;this.jb=f},sa=function(){function i(m){var u=[];m=m.split(",");for(var l,o=0;o<m.length;o++){l=m[o].split(":");u.push(new ra(l[0],l[1]))}return u}var f=this;f.Ba="utm_campaign";f.Ca="utm_content";f.Da="utm_id";f.Ea="utm_medium";f.Fa="utm_nooverride";f.Ga="utm_source";f.Ha="utm_term";f.Ia="gclid";f.Y=0;f.z=0;f.Ma=15768E6;f.pb=18E5;f.w=63072E6;f.oa=[];f.qa=[];f.ac="cse";f.bc="q";f.kb=5;f.R=i("daum:q,eniro:search_word,naver:query,images.google:q,google:q,yahoo:p,msn:q,bing:q,aol:query,aol:encquery,lycos:query,ask:q,altavista:q,netscape:query,cnn:query,about:terms,mamma:query,alltheweb:q,voila:rdata,virgilio:qs,live:q,baidu:wd,alice:qs,yandex:text,najdi:q,aol:q,mama:query,seznam:q,search:q,wp:szukaj,onet:qt,szukacz:q,yam:k,pchome:q,kvasir:q,sesam:q,ozu:q,terra:query,mynet:q,ekolay:q,rambler:words");
f.u=w;f.hb=v;f.h="/";f.S=100;f.ja="/__utm.gif";f.aa=1;f.ba=1;f.v="|";f.$=1;f.Na=1;f.Ka=1;f.c="auto";f.G=1;f.ma=1E3;f.wc=10;f.Hb=10;f.xc=0.2;f.o=w;f.a=document;f.e=window};var ta=function(i){function f(d,a,j,c){var n="",s=0;n=O(d,"2"+a,";");if(!M(n)){d=n.indexOf("^"+j+".");if(d<0)return["",0];n=N(n,d+j[y]+2);if(n.indexOf("^")>0)n=n.split("^")[0];j=n.split(":");n=j[1];s=parseInt(j[0],10);if(!c&&s<o.s)n=""}if(M(n))n="";return[n,s]}function m(d,a){return"^"+ma([[a,d[1]].join("."),d[0]],":")}function u(d,a){var j=d+"; path="+k.h+"; "+a+o.ab();k.a[z]=j}function l(d){var a=new Date;d=new Date(a.getTime()+d);return"expires="+d.toGMTString()+"; "}var o=this,k=i;o.s=(new Date).getTime();
var g=[D,F,G,K,H,L,ha];o.k=function(){var d=k.a[z];return k.o?o.Ob(d,k.o):d};o.Ob=function(d,a){var j=[],c,n;for(c=0;c<g[y];c++){n=f(d,g[c],a)[0];M(n)||(j[j[y]]=g[c]+n+";")}return j.join("")};o.m=function(d,a,j){var c=j>0?l(j):"";if(k.o){a=o.Yb(k.a[z],d,k.o,a,j);d="2"+d;c=j>0?l(k.w):""}u(d+a,c)};o.Yb=function(d,a,j,c,n){var s="";n=n||k.w;c=m([c,o.s+n*1],j);s=O(d,"2"+a,";");if(!M(s)){d=m(f(d,a,j,r),j);s=ma(s.split(d),"");return s=c+s}return c};o.ab=function(){return M(k.c)?"":"domain="+k.c+";"}};var ua=function(i){function f(q){q=q instanceof Array?q.join("."):"";return M(q)?"-":q}function m(q,b){var e=[],h;if(!M(q)){e=q.split(".");if(b)for(h=0;h<e[y];h++)ka(e[h])||(e[h]="-")}return e}function u(q,b,e){var h=c.K,p,t;for(p=0;p<h[y];p++){t=h[p][0];t+=M(b)?b:b+h[p][4];h[p][2](O(q,t,e))}}var l,o,k,g,d,a,j,c=this,n,s=i;c.j=new ta(i);c.gb=function(){return w==n||n==c.N()};c.k=function(){return c.j.k()};c.ha=function(){return d?d:"-"};c.sb=function(q){d=q};c.ua=function(q){n=ka(q)?q*1:"-"};c.ga=
function(){return f(a)};c.va=function(q){a=m(q)};c.Nb=function(){c.j.m(H,"",-1)};c.Zb=function(){return n?n:"-"};c.ab=function(){return M(s.c)?"":"domain="+s.c+";"};c.ea=function(){return f(l)};c.qb=function(q){l=m(q,1)};c.B=function(){return f(o)};c.ta=function(q){o=m(q,1)};c.fa=function(){return f(k)};c.rb=function(q){k=m(q,1)};c.ia=function(){return f(g)};c.tb=function(q){g=m(q);for(q=0;q<g[y];q++)if(q<4&&!ka(g[q]))g[q]="-"};c.Vb=function(){return j};c.qc=function(q){j=q};c.Kb=function(){l=[];
o=[];k=[];g=[];d=w;a=[];n=w};c.N=function(){var q="",b;for(b=0;b<c.K[y];b++)q+=c.K[b][1]();return na(q)};c.pa=function(q){var b=c.k(),e=v;if(b){u(b,q,";");c.ua(c.N());e=r}return e};c.mc=function(q){u(q,"",B);c.ua(O(q,ga,B))};c.uc=function(){var q=c.K,b=[],e;for(e=0;e<q[y];e++)S(b,q[e][0]+q[e][1]());S(b,ga+c.N());return b.join(B)};c.Bc=function(q,b){var e=c.K,h=s.h,p;c.pa(q);s.h=b;for(p=0;p<e[y];p++)M(e[p][1]())||e[p][3]();s.h=h};c.Ab=function(){c.j.m(D,c.ea(),s.w)};c.ya=function(){c.j.m(F,c.B(),s.pb)};
c.Bb=function(){c.j.m(G,c.fa(),0)};c.Aa=function(){c.j.m(K,c.ia(),s.Ma)};c.Cb=function(){c.j.m(L,c.ha(),s.w)};c.za=function(){c.j.m(H,c.ga(),s.w)};c.Dc=function(){c.j.m(ha,c.Vb(),0)};c.K=[[D,c.ea,c.qb,c.Ab,"."],[F,c.B,c.ta,c.ya,""],[G,c.fa,c.rb,c.Bb,""],[L,c.ha,c.sb,c.Cb,""],[K,c.ia,c.tb,c.Aa,"."],[H,c.ga,c.va,c.za,"."]]};var wa=function(i){var f=this,m=i,u=new ua(m),l=!X.Cc(),o=function(){},k=function(g){var d=(new Date).getTime(),a;a=(d-g[3])*(m.xc/1E3);if(a>=1){g[2]=Math.min(Math.floor(g[2]*1+a),m.Hb);g[3]=d}return g};f.F=function(g,d,a,j,c,n){var s,q=m.G,b=m.a[A];u.pa(a);s=V(u.B(),".");if(s[1]<500||j){if(c)s=k(s);if(j||!c||s[2]>=1){if(!j&&c)s[2]=s[2]*1-1;s[1]=s[1]*1+1;g="?utmwv="+da+"&utmn="+W()+(M(b.hostname)?"":"&utmhn="+P(b.hostname))+(m.S==100?"":"&utmsp="+P(m.S))+g;if(0==q||2==q){j=2==q?o:n||o;l&&f.Ta(m.ja+
g,j)}if(1==q||2==q){g=("https:"==b.protocol?"https://ssl.google-analytics.com/__utm.gif":"http://www.google-analytics.com/__utm.gif")+g+"&utmac="+d+"&utmcc="+f.Rb(a);if(va)g+="&gaq=1";if(X.Va)g+="&aip=1";l&&f.Ta(g,n)}}}u.ta(s.join("."));u.ya()};f.Ta=function(g,d){var a=new Image(1,1);a.src=g;a.onload=function(){a.onload=null;(d||o)()}};f.Rb=function(g){var d=[],a=[D,K,H,L],j,c=u.k(),n;for(j=0;j<a[y];j++){n=O(c,a[j]+g,";");if(!M(n)){if(a[j]==H){n=V(n.split(g+".")[1],"|")[0];if(M(n))continue;n=g+"."+
n}S(d,a[j]+n+";")}}return P(d.join("+"))}};var Y=function(){var i=this;i.W=[];i.db=function(f){var m,u=i.W,l;for(l=0;l<u.length;l++)m=f==u[l].q?u[l]:m;return m};i.Gb=function(f,m,u,l,o,k,g,d){var a=i.db(f);if(w==a){a=new Y.Eb(f,m,u,l,o,k,g,d);S(i.W,a)}else{a.Ja=m;a.xb=u;a.wb=l;a.ub=o;a.Qa=k;a.vb=g;a.Sa=d}return a}};Y.Db=function(i,f,m,u,l,o){var k=this;k.zb=i;k.wa=f;k.r=m;k.Oa=u;k.mb=l;k.nb=o;k.xa=function(){return"&"+["utmt=item","tid="+P(k.zb),"ipc="+P(k.wa),"ipn="+P(k.r),"iva="+P(k.Oa),"ipr="+P(k.mb),"iqt="+P(k.nb)].join("&utm")}};
Y.Eb=function(i,f,m,u,l,o,k,g){var d=this;d.q=i;d.Ja=f;d.xb=m;d.wb=u;d.ub=l;d.Qa=o;d.vb=k;d.Sa=g;d.P=[];d.Fb=function(a,j,c,n,s){var q=d.Wb(a),b=d.q;if(w==q)S(d.P,new Y.Db(b,a,j,c,n,s));else{q.zb=b;q.wa=a;q.r=j;q.Oa=c;q.mb=n;q.nb=s}};d.Wb=function(a){var j,c=d.P,n;for(n=0;n<c.length;n++)j=a==c[n].wa?c[n]:j;return j};d.xa=function(){return"&"+["utmt=tran","id="+P(d.q),"st="+P(d.Ja),"to="+P(d.xb),"tx="+P(d.wb),"sp="+P(d.ub),"ci="+P(d.Qa),"rg="+P(d.vb),"co="+P(d.Sa)].join("&utmt")}};var xa=function(i){function f(){var k,g,d;g="ShockwaveFlash";var a="$version",j=l.d?l.d.plugins:w;if(j&&j[y]>0)for(k=0;k<j[y]&&!d;k++){g=j[k];if(R(g.name,"Shockwave Flash"))d=g.description.split("Shockwave Flash ")[1]}else{g=g+"."+g;try{k=new ActiveXObject(g+".7");d=k.GetVariable(a)}catch(c){}if(!d)try{k=new ActiveXObject(g+".6");d="WIN 6,0,21,0";k.AllowScriptAccess="always";d=k.GetVariable(a)}catch(n){}if(!d)try{k=new ActiveXObject(g);d=k.GetVariable(a)}catch(s){}if(d){d=V(d.split(" ")[1],",");d=
d[0]+"."+d[1]+" r"+d[2]}}return d?d:o}var m=i,u=m.e,l=this,o="-";l.T=u.screen;l.La=!l.T&&u.java?java.awt.Toolkit.getDefaultToolkit():w;l.d=u.navigator;l.U=o;l.sa=o;l.Pa=o;l.la=o;l.ka=1;l.Za=o;l.Sb=function(){var k;if(u.screen){l.U=l.T.width+"x"+l.T.height;l.sa=l.T.colorDepth+"-bit"}else if(l.La)try{k=l.La.getScreenSize();l.U=k.width+"x"+k.height}catch(g){}l.la=U(l.d&&l.d.language?l.d.language:l.d&&l.d.browserLanguage?l.d.browserLanguage:o);l.ka=l.d&&l.d.javaEnabled()?1:0;l.Za=m.ba?f():o;l.Pa=P(m.a.characterSet?
m.a.characterSet:m.a.charset?m.a.charset:o)};l.vc=function(){return B+"utm"+["cs="+P(l.Pa),"sr="+l.U,"sc="+l.sa,"ul="+l.la,"je="+l.ka,"fl="+P(l.Za)].join("&utm")};l.Qb=function(){var k=m.a,g=u.history[y];k=l.d.appName+l.d.version+l.la+l.d.platform+l.d.userAgent+l.ka+l.U+l.sa+(k[z]?k[z]:"")+(k.referrer?k.referrer:"");for(var d=k[y];g>0;)k+=g--^d++;return na(k)}};var Z=function(i,f,m,u){function l(d){var a="";d=U(d.split("://")[1]);if(R(d,"/")){d=d.split("/")[1];if(R(d,"?"))a=d.split("?")[0]}return a}function o(d){var a="";a=U(d.split("://")[1]);if(R(a,"/"))a=a.split("/")[0];return a}var k=u,g=this;g.b=i;g.ob=f;g.s=m;g.cb=function(d){var a=g.da();return new Z.t(O(d,k.Da+C,B),O(d,k.Ga+C,B),O(d,k.Ia+C,B),g.O(d,k.Ba,"(not set)"),g.O(d,k.Ea,"(not set)"),g.O(d,k.Ha,a&&!M(a.I)?Q(a.I):w),g.O(d,k.Ca,w))};g.fb=function(d){var a=o(d),j=l(d);if(R(a,"google")){d=d.split("?").join(B);
if(R(d,B+k.bc+C))if(j==k.ac)return r}return v};g.da=function(){var d,a=g.ob,j,c,n=k.R;if(!(M(a)||"0"==a||!R(a,"://")||g.fb(a))){d=o(a);for(j=0;j<n[y];j++){c=n[j];if(R(d,U(c.Wa))){a=a.split("?").join(B);if(R(a,B+c.jb+C)){d=a.split(B+c.jb+C)[1];if(R(d,B))d=d.split(B)[0];return new Z.t(w,c.Wa,w,"(organic)","organic",d,w)}}}}};g.O=function(d,a,j){d=O(d,a+C,B);return j=!M(d)?Q(d):!M(j)?j:"-"};g.hc=function(d){var a=k.oa,j=v,c;if(d&&"organic"==d.Q){d=U(Q(d.I));for(c=0;c<a[y];c++)j=j||U(a[c])==d}return j};
g.bb=function(){var d="",a="";d=g.ob;if(!(M(d)||"0"==d||!R(d,"://")||g.fb(d))){d=d.split("://")[1];if(R(d,"/")){a=N(d,d.indexOf("/"));a=a.split("?")[0];d=U(d.split("/")[0])}if(0==d.indexOf("www."))d=N(d,4);return new Z.t(w,d,w,"(referral)","referral",w,a)}};g.$a=function(d){var a="";if(k.Y){a=d&&d.hash?d.href.substring(d.href.indexOf("#")):"";a=""!=a?a+B:a}a+=d.search;return a};g.Tb=function(){return new Z.t(w,"(direct)",w,"(direct)","(none)",w,w)};g.ic=function(d){var a=v,j,c=k.qa;if(d&&"referral"==
d.Q){d=U(P(d.V));for(j=0;j<c[y];j++)a=a||R(d,U(c[j]))}return a};g.l=function(d){return w!=d&&d.ib()};g.isNewCampaign=function(d){d=O(d,K+g.b+".",";");var a=d.split(".");d=new Z.t;d.lb(a.slice(4).join("."));if(!g.l(d))return true;a=k.a[A];a=g.$a(a);a=g.cb(a);if(!g.l(a)){a=g.da();g.l(a)||(a=g.bb())}return g.l(a)&&U(d.J())!=U(a.J())};g.getCampaignInformation=function(d,a){if(k.Na){var j="",c="-",n,s=0,q,b,e=g.b;if(d){b=d.k();j=g.$a(k.a[A]);if(k.z&&d.gb()){c=d.ia();if(!M(c)&&!R(c,";")){d.Aa();return}}c=
O(b,K+e+".",";");n=g.cb(j);if(g.l(n)){j=O(j,k.Fa+C,B);if("1"==j&&!M(c))return}if(!g.l(n)){n=g.da();if(!M(c)&&g.hc(n))return}if(!g.l(n)&&a){n=g.bb();if(!M(c)&&g.ic(n))return}if(!g.l(n))if(M(c)&&a)n=g.Tb();if(g.l(n)){if(!M(c)){s=c.split(".");q=new Z.t;q.lb(s.slice(4).join("."));q=U(q.J())==U(n.J());s=s[3]*1}if(!q||a){b=O(b,D+e+".",";");q=b.lastIndexOf(".");b=q>9?N(b,q+1)*1:0;s++;b=0==b?1:b;d.tb([e,g.s,b,s,n.J()].join("."));d.Aa()}}}}}};
Z.t=function(i,f,m,u,l,o,k){var g=this;g.q=i;g.V=f;g.Z=m;g.r=u;g.Q=l;g.I=o;g.Ra=k;g.J=function(){var d=[],a=[["cid",g.q],["csr",g.V],["gclid",g.Z],["ccn",g.r],["cmd",g.Q],["ctr",g.I],["cct",g.Ra]],j,c;if(g.ib())for(j=0;j<a[y];j++)if(!M(a[j][1])){c=a[j][1].split("+").join("%20");c=c.split(" ").join("%20");S(d,"utm"+a[j][0]+C+c)}return d.join("|")};g.ib=function(){return!(M(g.q)&&M(g.V)&&M(g.Z))};g.lb=function(d){var a=function(j){return Q(O(d,"utm"+j+C,"|"))};g.q=a("cid");g.V=a("csr");g.Z=a("gclid");
g.r=a("ccn");g.Q=a("cmd");g.I=a("ctr");g.Ra=a("cct")}};var ya=function(i,f,m,u){function l(j,c,n){var s;if(!M(n)){n=n.split(",");for(var q=0;q<n[y];q++){s=n[q];if(!M(s)){s=s.split(g);if(s[y]==4)c[s[0]]=[s[1],s[2],j]}}}}var o=this,k=f,g=C,d=i,a=u;o.L=m;o.na="";o.p={};o.gc=function(){var j;j=V(O(o.L.k(),H+k+".",";"),k+".")[1];if(!M(j)){j=j.split("|");l(1,o.p,j[1]);o.na=j[0];o.X()}};o.X=function(){o.Ib();var j=o.na,c,n,s="";for(c in o.p)if((n=o.p[c])&&1===n[2])s+=c+g+n[0]+g+n[1]+g+1+",";M(s)||(j+="|"+s);if(M(j))o.L.Nb();else{o.L.va(k+"."+j);o.L.za()}};o.rc=
function(j){o.na=j;o.X()};o.pc=function(j,c,n,s){if(1!=s&&2!=s&&3!=s)s=3;var q=v;if(c&&n&&j>0&&j<=d.kb){c=P(c);n=P(n);if(c[y]+n[y]<=64){o.p[j]=[c,n,s];o.X();q=r}}return q};o.$b=function(j){if((j=o.p[j])&&1===j[2])return j[1]};o.Mb=function(j){var c=o.p;if(c[j]){delete c[j];o.X()}};o.Ib=function(){a._clearKey(8);a._clearKey(9);a._clearKey(11);var j=o.p,c,n;for(n in j)if(c=j[n]){a._setKey(8,n,c[0]);a._setKey(9,n,c[1]);(c=c[2])&&3!=c&&a._setKey(11,n,""+c)}}};var $=function(){function i(h,p,t,x){if(w==k[h])k[h]={};if(w==k[h][p])k[h][p]=[];k[h][p][t]=x}function f(h,p){if(w!=k[h]&&w!=k[h][p]){k[h][p]=w;var t=r,x;for(x=0;x<a[y];x++)if(w!=k[h][a[x]]){t=v;break}if(t)k[h]=w}}function m(h){var p="",t=v,x,E;for(x=0;x<a[y];x++){E=h[a[x]];if(w!=E){if(t)p+=a[x];p+=u(E);t=v}else t=r}return p}function u(h){var p=[],t,x;for(x=0;x<h[y];x++)if(w!=h[x]){t="";if(x!=e&&w==h[x-1])t+=x.toString()+s;t+=l(h[x]);S(p,t)}return j+p.join(n)+c}function l(h){var p="",t,x,E;for(t=
0;t<h[y];t++){x=h.charAt(t);E=b[x];p+=w!=E?E:x}return p}var o=this,k={},g="k",d="v",a=[g,d],j="(",c=")",n="*",s="!",q="'",b={};b[q]="'0";b[c]="'1";b[n]="'2";b[s]="'3";var e=1;o.dc=function(h){return w!=k[h]};o.D=function(){var h="",p;for(p in k)if(w!=k[p])h+=p.toString()+m(k[p]);return h};o.nc=function(h){if(h==w)return o.D();var p=h.D(),t;for(t in k)if(w!=k[t]&&!h.dc(t))p+=t.toString()+m(k[t]);return p};o._setKey=function(h,p,t){if(typeof t!="string")return v;i(h,g,p,t);return r};o._setValue=function(h,
p,t){if(typeof t!="number"&&(w==Number||!(t instanceof Number))||Math.round(t)!=t||t==NaN||t==Infinity)return v;i(h,d,p,t.toString());return r};o._getKey=function(h,p){return w!=k[h]&&w!=k[h][g]?k[h][g][p]:w};o._getValue=function(h,p){return w!=k[h]&&w!=k[h][d]?k[h][d][p]:w};o._clearKey=function(h){f(h,g)};o._clearValue=function(h){f(h,d)}};var za=function(i,f){var m=this;m.Fc=f;m.jc=i;m._trackEvent=function(u,l,o){return f._trackEvent(m.jc,u,l,o)}};var Aa=function(i,f,m){function u(){if("auto"==c.c){var b=c.a.domain;if("www."==N(b,0,4))b=N(b,4);c.c=b}c.c=U(c.c)}function l(){u();var b=c.c,e=b.indexOf("www.google.")*b.indexOf(".google.")*b.indexOf("google.");return e||"/"!=c.h||b.indexOf("google.org")>-1}function o(b,e,h){if(M(b)||M(e)||M(h))return"-";b=O(b,D+a.b+".",e);if(!M(b)){b=b.split(".");b[5]=b[5]?b[5]*1+1:1;b[3]=b[4];b[4]=h;b=b.join(".")}return b}function k(){return"file:"!=c.a[A].protocol&&l()}function g(b){if(!b||""==b)return"";for(;ia(b.charAt(0));)b=
N(b,1);for(;ia(b.charAt(b[y]-1));)b=N(b,0,b[y]-1);return b}function d(b,e,h,p){if(!M(b())){e(p?Q(b()):b());R(b(),";")||h()}}var a=this,j=w,c=new sa,n=v,s=w;a.e=window;a.r=i;a.s=Math.round((new Date).getTime()/1E3);a.n=f||"UA-XXXXX-X";a.Ua=c.a.referrer;a.ca=w;a.f=w;a.M=w;a.C=v;a.A=w;a.g=w;a.Xa=w;a.b=w;a.i=w;c.o=m?P(m):w;var q=function(b){var e,h=""!=b&&c.a[A].host!=b;if(h)for(e=0;e<c.u[y];e++)h=h&&la(U(b),U(c.u[e]))==-1;return h};a.lc=function(){if(!a.M)return null;var b=a.M.match(/^(?:\|([-0-9a-z.]{1,30})(?::(\d{4,5}))?\|)?([-.\w]{10,1200})$/i);
if(!b)return null;return{domain:b[1]||null,port:b[2]||null,token:b[3]}};a.Xb=function(){return W()^a.A.Qb()&2147483647};a.Ub=function(){if(!c.c||""==c.c||"none"==c.c){c.c="";return 1}u();return c.Ka?na(c.c):1};a.Pb=function(b,e){if(M(b))b="-";else{e+=c.h&&"/"!=c.h?c.h:"";var h=b.indexOf(e);b=h>=0&&h<=8?"0":"["==b.charAt(0)&&"]"==b.charAt(b[y]-1)?"-":b}return b};a.ra=function(b){var e="",h=c.a;e+=c.$?a.A.vc():"";e+=c.aa&&!M(h.title)?"&utmdt="+P(h.title):"";e+="&utmhid="+oa()+"&utmr="+P(a.ca)+"&utmp="+
P(a.oc(b));return e};a.oc=function(b){var e=c.a[A];return b=w!=b&&""!=b?P(b,r):P(e.pathname+e.search,r)};a.yc=function(b){if(a.H()){var e="";if(a.g!=w&&a.g.D()[y]>0)e+="&utme="+P(a.g.D());e+=a.ra(b);j.F(e,a.n,a.b)}};a.Lb=function(){var b=new ua(c);return b.pa(a.b)?b.uc():w};a._getLinkerUrl=function(b,e){var h=b.split("#"),p=b,t=a.Lb();if(t)if(e&&1>=h[y])p+="#"+t;else if(!e||1>=h[y])if(1>=h[y])p+=(R(b,"?")?B:"?")+t;else p=h[0]+(R(b,"?")?B:"?")+t+"#"+h[1];return p};a.sc=function(){var b=a.lc();if(b){a.i.qc(a.M);
a.i.Dc();X._gasoDomain=c.c;X._gasoCPath=c.h;var e="www.google.com";if(b.domain)e=b.domain+".google.com"+(b.port?":"+b.port:"");var h="https://www.google.com/analytics/reporting/overlay_js?gaso=";if(b.domain)h="https://"+e+"/analytics/reporting/overlay_js?gaso=";h+=b.token+B+W();pa(h,"_gasojs")}};a.cc=function(){var b=a.s,e=a.i,h=e.k(),p=a.b+"",t=c.e,x=t?t.gaGlobal:w,E,ja=R(h,D+p+"."),Ba=R(h,F+p),Ca=R(h,G+p),I,J=[],T="",qa=v;h=M(h)?"":h;if(c.z){E=c.a[A]&&c.a[A].hash?c.a[A].href.substring(c.a[A].href.indexOf("#")):
"";if(c.Y&&!M(E))T=E+B;T+=c.a[A].search;if(!M(T)&&R(T,D)){e.mc(T);e.gb()||e.Kb();I=e.ea()}d(e.ha,e.sb,e.Cb,true);d(e.ga,e.va,e.za)}if(M(I))if(ja)if(!Ba||!Ca||0){I=o(h,";",b);a.C=r}else{I=O(h,D+p+".",";");J=V(O(h,F+p,";"),".")}else{I=ma([p,a.Xb(),b,b,b,1],".");qa=a.C=r}else if(M(e.B())||M(e.fa())){I=o(T,B,b);a.C=r}else{J=V(e.B(),".");p=J[0]}I=I.split(".");if(t&&x&&x.dh==p&&!c.o){I[4]=x.sid?x.sid:I[4];if(qa){I[3]=x.sid?x.sid:I[4];if(x.vid){b=x.vid.split(".");I[1]=b[0];I[2]=b[1]}}}e.qb(I.join("."));
J[0]=p;J[1]=J[1]?J[1]:0;J[2]=w!=J[2]?J[2]:c.wc;J[3]=J[3]?J[3]:I[4];e.ta(J.join("."));e.rb(p);M(e.Zb())||e.ua(e.N());e.Ab();e.ya();e.Bb()};a.ec=function(){j=new wa(c)};a._getName=function(){return a.r};a._initData=function(){var b;if(!n){if(!a.A){a.A=new xa(c);a.A.Sb()}a.b=a.Ub();a.i=new ua(c);a.g=new $;s=new ya(c,a.b,a.i,a.g);a.ec()}if(k()){if(!n){a.ca=a.Pb(a.Ua,c.a.domain);b=new Z(a.b,a.ca,a.s,c)}a.cc(b);s.gc()}if(!n){k()&&b.getCampaignInformation(a.i,a.C);a.Xa=new $;n=r}a.fc()};a._visitCode=function(){a._initData();
var b=O(a.i.k(),D+a.b+".",";");b=b.split(".");return b[y]<4?"":b[1]};a._cookiePathCopy=function(b){a._initData();a.i&&a.i.Bc(a.b,b)};a.fc=function(){if(!X.eb){var b=c.a[A].hash;if(b&&1==b.indexOf("gaso="))b=O(b,"gaso=",B);else b=(b=c.e.name)&&0<=b.indexOf("gaso=")?O(b,"gaso=",B):O(a.i.k(),ha,";");if(b[y]>=10){a.M=b;a.sc()}X.eb=r}};a.H=function(){return a._visitCode()%1E4<c.S*100};a.tc=function(){var b,e,h=c.a.links;if(!c.hb){b=c.a.domain;if("www."==N(b,0,4))b=N(b,4);c.u.push("."+b)}for(b=0;b<h[y]&&
(c.ma==-1||b<c.ma);b++){e=h[b];if(q(e.host))if(!e.gatcOnclick){e.gatcOnclick=e.onclick?e.onclick:a.kc;e.onclick=function(p){var t=!this.target||this.target=="_self"||this.target=="_top"||this.target=="_parent";t=t&&!a.Jb(p);a.zc(p,this,t);return t?v:this.gatcOnclick?this.gatcOnclick(p):r}}}};a.kc=function(){};a._trackPageview=function(b){if(k()){a._initData();c.u&&a.tc();a.yc(b);a.C=v}};a._trackTrans=function(){var b=a.b,e=[],h,p,t;a._initData();if(a.f&&a.H()){for(h=0;h<a.f.W[y];h++){p=a.f.W[h];S(e,
p.xa());for(t=0;t<p.P[y];t++)S(e,p.P[t].xa())}for(h=0;h<e[y];h++)j.F(e[h],a.n,b,r)}};a._setTrans=function(){var b=c.a,e,h,p;b=b.getElementById?b.getElementById("utmtrans"):b.utmform&&b.utmform.utmtrans?b.utmform.utmtrans:w;a._initData();if(b&&b.value){a.f=new Y;p=b.value.split("UTM:");c.v=!c.v||""==c.v?"|":c.v;for(b=0;b<p[y];b++){p[b]=g(p[b]);e=p[b].split(c.v);for(h=0;h<e[y];h++)e[h]=g(e[h]);if("T"==e[0])a._addTrans(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]);else"I"==e[0]&&a._addItem(e[1],e[2],e[3],
e[4],e[5],e[6])}}};a._addTrans=function(b,e,h,p,t,x,E,ja){a.f=a.f?a.f:new Y;return a.f.Gb(b,e,h,p,t,x,E,ja)};a._addItem=function(b,e,h,p,t,x){var E;a.f=a.f?a.f:new Y;(E=a.f.db(b))||(E=a._addTrans(b,"","","","","","",""));E.Fb(e,h,p,t,x)};a._setVar=function(b){if(b&&""!=b&&l()){a._initData();s.rc(P(b));a.H()&&j.F("&utmt=var",a.n,a.b)}};a._setCustomVar=function(b,e,h,p){a._initData();return s.pc(b,e,h,p)};a._deleteCustomVar=function(b){a._initData();s.Mb(b)};a._getVisitorCustomVar=function(b){a._initData();
return s.$b(b)};a._setMaxCustomVariables=function(b){c.kb=b};a._link=function(b,e){if(c.z&&b){a._initData();c.a[A].href=a._getLinkerUrl(b,e)}};a._linkByPost=function(b,e){if(c.z&&b&&b.action){a._initData();b.action=a._getLinkerUrl(b.action,e)}};a._setXKey=function(b,e,h){a.g._setKey(b,e,h)};a._setXValue=function(b,e,h){a.g._setValue(b,e,h)};a._getXKey=function(b,e){return a.g._getKey(b,e)};a._getXValue=function(b,e){return a.g.getValue(b,e)};a._clearXKey=function(b){a.g._clearKey(b)};a._clearXValue=
function(b){a.g._clearValue(b)};a._createXObj=function(){a._initData();return new $};a._sendXEvent=function(b){var e="";a._initData();if(a.H()){e+="&utmt=event&utme="+P(a.g.nc(b))+a.ra();j.F(e,a.n,a.b,v,r)}};a._createEventTracker=function(b){a._initData();return new za(b,a)};a._trackEvent=function(b,e,h,p){a._initData();var t=a.Xa;if(w!=b&&w!=e&&""!=b&&""!=e){t._clearKey(5);t._clearValue(5);(b=t._setKey(5,1,b)&&t._setKey(5,2,e)&&(w==h||t._setKey(5,3,h))&&(w==p||t._setValue(5,1,p)))&&a._sendXEvent(t)}else b=
v;return b};a.zc=function(b,e,h){a._initData();if(a.H()){var p=new $;p._setKey(6,1,e.href);var t=h?function(){a.Ya(b,e)}:w;j.F("&utmt=event&utme="+P(p.D())+a.ra(),a.n,a.b,v,r,t);h&&c.e.setTimeout(function(){a.Ya(b,e)},500)}};a.Ya=function(b,e){if(!b)b=c.e.event;var h=r;if(e.gatcOnclick)h=e.gatcOnclick(b);if(h||typeof h=="undefined")if(!e.target||e.target=="_self")c.e[A]=e.href;else if(e.target=="_top")c.e.top.document[A]=e.href;else if(e.target=="_parent")c.e.parent.document[A]=e.href};a.Jb=function(b){if(!b)b=
c.e.event;var e=b.shiftKey||b.ctrlKey||b.altKey;if(!e)if(b.modifiers&&c.e.Event)e=b.modifiers&c.e.Event.CONTROL_MASK||b.modifiers&c.e.Event.SHIFT_MASK||b.modifiers&c.e.Event.ALT_MASK;return e};a.Ec=function(){return c};a._setDomainName=function(b){c.c=b};a._addOrganic=function(b,e,h){c.R.splice(h?0:c.R.length,0,new ra(b,e))};a._clearOrganic=function(){c.R=[]};a._addIgnoredOrganic=function(b){S(c.oa,b)};a._clearIgnoredOrganic=function(){c.oa=[]};a._addIgnoredRef=function(b){S(c.qa,b)};a._clearIgnoredRef=
function(){c.qa=[]};a._setAllowHash=function(b){c.Ka=b?1:0};a._setCampaignTrack=function(b){c.Na=b?1:0};a._setClientInfo=function(b){c.$=b?1:0};a._getClientInfo=function(){return c.$};a._setCookiePath=function(b){c.h=b};a._setTransactionDelim=function(b){c.v=b};a._setCookieTimeout=function(b){a._setCampaignCookieTimeout(b*1E3)};a._setCampaignCookieTimeout=function(b){c.Ma=b};a._setDetectFlash=function(b){c.ba=b?1:0};a._getDetectFlash=function(){return c.ba};a._setDetectTitle=function(b){c.aa=b?1:
0};a._getDetectTitle=function(){return c.aa};a._setLocalGifPath=function(b){c.ja=b};a._getLocalGifPath=function(){return c.ja};a._setLocalServerMode=function(){c.G=0};a._setRemoteServerMode=function(){c.G=1};a._setLocalRemoteServerMode=function(){c.G=2};a._getServiceMode=function(){return c.G};a._setSampleRate=function(b){c.S=b};a._setSessionTimeout=function(b){a._setSessionCookieTimeout(b*1E3)};a._setSessionCookieTimeout=function(b){c.pb=b};a._setAllowLinker=function(b){c.z=b?1:0};a._setAllowAnchor=
function(b){c.Y=b?1:0};a._setCampNameKey=function(b){c.Ba=b};a._setCampContentKey=function(b){c.Ca=b};a._setCampIdKey=function(b){c.Da=b};a._setCampMediumKey=function(b){c.Ea=b};a._setCampNOKey=function(b){c.Fa=b};a._setCampSourceKey=function(b){c.Ga=b};a._setCampTermKey=function(b){c.Ha=b};a._setCampCIdKey=function(b){c.Ia=b};a._getAccount=function(){return a.n};a._setAccount=function(b){a.n=b};a._setNamespace=function(b){c.o=b?P(b):w};a._getVersion=function(){return da};a._setAutoTrackOutbound=
function(b){c.u=[];if(b)c.u=b};a._setTrackOutboundSubdomains=function(b){c.hb=b};a._setHrefExamineLimit=function(b){c.ma=b};a._setReferrerOverride=function(b){a.Ua=b};a._setCookiePersistence=function(b){a._setVisitorCookieTimeout(b)};a._setVisitorCookieTimeout=function(b){c.w=b}};var Da=function(){var i=this;i.Va=v;i.yb={};i.Ac=0;i.eb=v;i._gasoDomain=w;i._gasoCPath=w;i._getTracker=function(f,m){return i._createTracker(f,w,m)};i._createTracker=function(f,m,u){if(m==w)m="~"+X.Ac++;return X.yb[m]=new Aa(m,f,u)};i._getTrackerByName=function(f){f=f||"";return X.yb[f]||X._createTracker(undefined,f)};i.Cc=function(){var f=window[ea];return f&&f[fa]&&f[fa]()};i._anonymizeIp=function(){i.Va=r}};var va=v,Fa=function(){var i=this;i._createAsyncTracker=function(f,m){return X._createTracker(f,m||"")};i._getAsyncTracker=function(f){return X._getTrackerByName(f)};i.push=function(){var f=arguments,m=0;va=r;for(var u=0;u<f[y];u++)try{if(typeof f[u]==="function")f[u]();else{var l="",o=f[u][0],k=o.lastIndexOf(".");if(k>0){l=N(o,0,k);o=N(o,k+1)}var g=l==aa?X:l==ba?Ea:X._getTrackerByName(l);g[o].apply(g,f[u].slice(1))}}catch(d){m++}return m}};function Ga(){var i=window[aa];if(i&&typeof i._getTracker=="function")X=i;else window[aa]=X}function Ha(){var i=window[ba],f=v;if(i&&typeof i.push=="function"){f=i.constructor==Array;if(!f)return}window[ba]=Ea;f&&Ea.push.apply(Ea,i)}var X=new Da;Ga();var Ea=new Fa;Ha();})()

;