
var wapoEnv;

function WapoSite(name, url, visId) {
		this.name = name;
		this.url = url;
		this.visId = visId;
}

function WapoEnv() {
		this.wapolabs_js = 'http://bunsen.wapolabs.com/wapolabs/1.5.2/js/wapo.min.js';
		this.waposites_js = 'http://bunsen.wapolabs.com/identity/js/wapo_sites.js';
		this.cdn_identity = 'http://bunsen.wapolabs.com/identity/1.6.3/';
		this.fb_key = '52a18260b5da1ffde3a414221fb211e3';
		this.fb_xd_receiver = 'http://www.trove.com/facebook/xd_receiver';
		this.fb_app_id = '173895319314603';
		this.publicationName = 'Trove';
		this.site_base_domain  = 'trove.com';
        this.site_path = "/";
		this.wapo_secure_protocol  = 'https:';
		this.wapo_site_url  = '//id.trove.com/identity/';
		this.site_url = '//trove.com/';
		this.wapo_public_protocol  = 'http:';
		this.customLoginTrigger = true;
		
		this.param_name_jsonp_callback = 'jsonp_callback';
		this.param_name_nonce = 'wp_id_n';
		this.param_name_email_nonce  = 'wp_em_n';
		this.meta_tag_groups  = 'wapoGroups';
		this.param_name_redirect  = 'next_url';
		this.param_name_previous_url  = 'previous_url';
		this.param_name_no_cancel  = 'wp_no_cancel';
		this.param_name_regis_group_name  = 'reg_group';
		this.param_name_login_id  = 'loginId';
		this.param_name_show_registration  = 'show_registration';
		this.param_name_registration_redirect = 'wp_regis_redirect';
		this.param_name_login_redirect = 'wp_login_redirect';
		this.place_holder  = 'ph';
		this.cookie_display  = 'wapo_display';
		this.cookie_groups  = 'wapo_groups';
		this.cookie_vis_id  = 'wapo_vis_id';
		this.cookie_login_id  = 'wapo_login_id';
		this.cookie_previous_ip  = 'wapo_saved_ip';
		this.cookie_last_ip  = 'wapo_last_ip';
		this.cookie_omniture  = 's_vi';
		this.cookie_previous_omniture  = 'wapo_saved_omnitureid';
		this.cookie_previous_ip  = 'wapo_saved_ip';
		this.cookie_block_registration  = 'wapo_block_registration';
		this.visitor_session_length  = '30'; //this is in minutes
		this.cookie_session_id  = 'wapo_sess_id';
		this.cookie_wpni_id = 'wapo_login_id';
    this.identity_iframe_id = 'identity-iframe';
    this.jskit_commenting_group = 'comments';
    this.wapo_reg_url = 'http://id.trove.com/identity/public/login/options?';
    this.identity_reset_thickbox_event = 'closeModalDialog'; // Event to be triggered

    this.event_name_login = 'wapoLogin';
    this.event_name_new_registration = 'wapoRegister';
    this.event_name_logout = 'wapoLogout';
}

wapoEnv = new WapoEnv();

// silly? a little.
window.$wpjQ = typeof window.$wpjQ !== 'undefined' && window.$wpjQ || jQuery;


$wpjQ(document).trigger('wapo_env_init');


$wpjQ(document).ready(function($){

    if(typeof wapoEvent !== 'undefined' && typeof wapoEvent.eventHost !== 'undefined')
    {
	wapoEvent.eventHost = "id.trove.com/identity";
    }

    $.getScript(wapoEnv.waposites_js, function(){
	$.getScript(wapoEnv.cdn_identity + 'js/identity.solo.js', function(){
	    $.getScript(wapoEnv.cdn_identity + 'js/wapo_jskit_addon.js', function(){
		if(typeof Echo !== 'undefined'){
		    wapoIdentityInit();
		}
	    });
	});
    });
});


