/** PLEASE INITIALIZATION DATA for initialData, widgetData and window.tunnelURI */

/** Add details of the widgets for which configuration is created. This
 inludes symbolic name, the encrypted configuration key and the domain on which the widgets are hosted */

/** These are the IFrame atrributes that are added to the iframe added for the widget. 
 Update these attributes if there are any chages required to match the UI of the site these widgets will be integrated to. */
/*window.iframeAttributes = {
	style : {
		border :"0pt none"
	},
	allowTransparency :"-1",
	allowtransparency :"true",
	scrolling :"no",
	width :"100%",
	height :"100%",
	frameborder :"0"
};*/

/** The tunnel.html needs to be hosted on the site on which the widgets will be integrated. This html needs to be placed 
 on your site. Please note that this html code refernces js files. Based on the location of this html on your site, update the 
 js include paths in it.*/

/** These are the IFrame atrributes that are added to the iframe added for the widget. 
 Update these attributes if there are any chages required to match the UI of the site these widgets will be integrated to. */
/*window.iframeAttributes = {
	style : {
		border :"0pt none",
		background :"white"
	},
	scrolling :"no",
	width :"100%",
	height :"100%",
	frameborder :"0"
};*/

window.iframeAttributes = {
	allowTransparency:"true",
	style : {
		border :"0pt none",
		background :"none"
	},
	scrolling :"no",
	width :"100%",
	height :"100%",
	frameBorder :"0"
};

/** PLEASE INITIALIZATION DATA for initialData, widgetData and window.tunnelURI */

var arr = window.location.href.match(/^http:(\/\/)?([^\/\s]+)/);
var currentDomain = arr[0];

 getMatchedSiteConfig = function() {
	for (var i=0;i<siteConfigs.sites.length;i++) {
		if (siteConfigs.sites[i].siteDomain == currentDomain) {
			return siteConfigs.sites[i];
		}
	}
	currentDomain = 'widget.'+window.location.hostname;
}

 getMatchedWidgetsDomain = function() {
 	if(typeof getMatchedSiteConfig() === 'undefined') {
		return 'http://' + currentDomain;
	} else {
		return getMatchedSiteConfig().widgetsDomain;
	}
 }
 
  getMatchedSecureWidgetsDomain = function() {
 	if(typeof getMatchedSiteConfig() === 'undefined') {
		return 'https://' + currentDomain;
	} else {
		return getMatchedSiteConfig().widgetsSecureDomain;
	}
 }

 getMatchedTunnelURI = function() {
	if(typeof getMatchedSiteConfig() === 'undefined') {
		return arr[0] + "/widget-explorer/tunnel.html";
	} else {
		return getMatchedSiteConfig().tunnelURI;
	}
 }

 
var siteConfigs = {'sites': [
	/**	To point widget explorer to env IST		**/
	/**{'siteDomain': 'http://10.210.6.173:9084', 'widgetsDomain': 'http://216.33.74.231', 'widgetsSecureDomain': 'https://216.33.74.231', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://10.210.6.173:9447', 'widgetsDomain': 'https://216.33.74.231', 'widgetsSecureDomain': 'https://216.33.74.231', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},**/

	/** To point widget explorer to env VirtualTest		**/
	{'siteDomain': 'http://64.14.236.26', 'widgetsDomain': 'http://64.14.236.23', 'widgetsSecureDomain': 'https://64.14.236.23', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'http://10.210.6.173:9084', 'widgetsDomain': 'http://64.14.236.23', 'widgetsSecureDomain': 'https://64.14.236.23', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://10.210.6.173:9447', 'widgetsDomain': 'https://64.14.236.23', 'widgetsSecureDomain': 'https://64.14.236.23', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},

	{'siteDomain': 'http://64.14.225.67', 'widgetsDomain': 'http://216.33.74.227', 'widgetsSecureDomain': 'https://64.14.225.67', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://64.14.225.67', 'widgetsDomain': 'https://216.33.74.227', 'widgetsSecureDomain': 'https://64.14.225.67', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'http://64.14.225.79', 'widgetsDomain': 'http://216.33.74.223', 'widgetsSecureDomain': 'https://64.14.225.79', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://64.14.225.79', 'widgetsDomain': 'https://216.33.74.223', 'widgetsSecureDomain': 'https://64.14.225.79', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},

    // Test 
    {'siteDomain': 'http://216.33.74.19', 'widgetsDomain': 'http://widgets.veist.mix.icoke.com', 'widgetsSecureDomain':'https://widgets.veist.mix.icoke.com','tunnelURI': currentDomain + "/widget-explorer/tunnel.html" },
    {'siteDomain': 'https://216.33.74.19', 'widgetsDomain': 'http://widgets.veist.mix.icoke.com', 'widgetsSecureDomain':'https://widgets.veist.mix.icoke.com','tunnelURI': currentDomain + "/widget-explorer/tunnel.html" },

    // Production 
    {'siteDomain': 'http://football.coca-cola.ru', 'widgetsDomain': 'http://eu.widgets.icoke.com', 'widgetsSecureDomain':'https://eu.widgets.icoke.com','tunnelURI': currentDomain + "/widget-explorer/tunnel.html" },
    {'siteDomain': 'https://football.coca-cola.ru', 'widgetsDomain': 'http://eu.widgets.icoke.com', 'widgetsSecureDomain':'https://eu.widgets.icoke.com','tunnelURI': currentDomain + "/widget-explorer/tunnel.html" }
]
};
var widgetPath = '/widgets-server/widget/';
var widgetMetaData = {'widgets': [
{'widget': {'widgetType':'TellAFriendWidget', 'secureViews':['tellAFriend','confirmation']}},
{'widget': {'widgetType':'ListItemsWidget', 'secureViews':['showItemList']}},
{'widget': {'widgetType':'UpdatePrizeInfoWidget', 'secureViews':['updatePrizeInfoConfirmation','updateContactInformation']}},
{'widget': {'widgetType':'LoginWidget', 'secureViews':['start','preLogin','login','welcome','postLogin','confirmEmailAddress','inboundSSO','confirmationRequired','externalLogin','facebookStart','unlinkExternalAccount','logout']}},
{'widget': {'widgetType':'ProfileWidget', 'secureViews':['viewPassword','updatePassword','confirmEmailAddress','viewEmailAddress','updateEmailAddress','processConfirmation','viewEmailOptions','updateEmailOptions','viewMobileOptions','updateMobileOptions','viewProfileInfo','updateProfileInfo','viewEntireProfile','updateEntireProfile']}},
{'widget': {'widgetType':'ReferAFriendWidget', 'secureViews':['referAFriend','confirmation','unsubscribe','unsubscribeConfirm']}},
{'widget': {'widgetType':'ForgotResetPasswordWidget', 'secureViews':['start','resetPassword','forgotConfirm','resetConfirm']}},
{'widget': {'widgetType':'ItemDetailWidget', 'secureViews':['showItemDetails']}},
{'widget': {'widgetType':'RegistrationWidget', 'secureViews':['confirmation','registerUser','registerUserStepOne','registerUserStepTwo','externalRegisterUser','externalRegisterUserStepOne']}},
{'widget': {'widgetType':'ViewHistoryWidget', 'secureViews':['start','pointsHistory','rewardsPrizesHistory','sweepstakesHistory']}},
{'widget': {'widgetType':'PurchaseRewardWidget', 'secureViews':['start','confirmationContactInfo']}},
{'widget': {'widgetType':'ContactUsWidget', 'secureViews':['contactUs']}}
]};
var widgetData = {'widgets': [
{'widget': {'name': 'ViewHistoryWidget','configKey': 'a1cf8ac1e94b21a2623621710682fb16','type': 'ViewHistoryWidget'}},
{'widget': {'name': 'MyShareSessionWidget','configKey': '0f90c31f4112688b85e85736f56c3971','type': 'ShareSessionWidget'}},
{'widget': {'name': 'MyContactUsWidget','configKey': 'd474bb27fc6da8391af5d7c6c3d48d7c','type': 'ContactUsWidget'}},
{'widget': {'name': 'MyUpdatePrizeInfoWidget_Config2_Eng','configKey': 'd2505a642765d180a91c0c2885042f17','type': 'UpdatePrizeInfoWidget'}},
{'widget': {'name': 'MyTellAFriendWidget','configKey': '6cda5139cf91731af59ac518c91b1ace','type': 'TellAFriendWidget'}},
{'widget': {'name': 'MyPointBalanceWidget','configKey': '359939dd31e229f14a497c11aff2d52f','type': 'PointBalanceWidget'}},
{'widget': {'name': 'MyItemDetailsWidget','configKey': '3723367bfdd22a17546c121494830964','type': 'ItemDetailWidget'}},
{'widget': {'name': 'MyItemListWidget','configKey': 'c1cc2cbbb50f1c362e2c5249cba277fb','type': 'ListItemsWidget'}},
{'widget': {'name': 'MyLoginWidget','configKey': '28b5a95b554b501de22e2049609e86b5','type': 'LoginWidget'}},
{'widget': {'name': 'MyProfileWidget','configKey': '88659762383c57cddb346421dd8eaaaa','type': 'ProfileWidget'}},
{'widget': {'name': 'MyRegistrationWidget','configKey': '4ff2a5c6727d4acd5c10947697e0e2b5','type': 'RegistrationWidget'}},
{'widget': {'name': 'MyPurchaseRewardWidget','configKey': '58a426eb3d1e96fdf2d009dc47ca1a2d','type': 'PurchaseRewardWidget'}},
{'widget': {'name': 'MyForgotResetPasswordWidget','configKey': '6951672a2c3acf6bed328940a102e40b','type': 'ForgotResetPasswordWidget'}},
{'widget': {'name': 'MyRedeemPinWidget','configKey': 'fef266833e07a95402d896935ec724ac','type': 'RedeemPinWidget'}},
{'widget': {'name': 'MyReferAFriendWidget','configKey': '43ca1d121b473fb602750dd31d77af34','type': 'ReferAFriendWidget'}}
]};

/** The tunnel.html needs to be hosted on the site on which the widgets will be integrated. This html needs to be placed 
on your site. Please note that this html code refernces js files. Based on the location of this html on your site, update the 
js include paths in it.*/

window.tunnelURI = getMatchedTunnelURI();

/**
 * Widget http > http (vice-versa) url switch configuration
 */
window.widgetURLSwitch = {'http' : null, 'https' : null};

