/** PLEASE INITIALIZATION DATA for initialData, widgetData and window.tunnelURI */

var arr = window.location.href.match(/^(http(s)*?:\/\/)?([^\/\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];
		}
	}
 }

 getMatchedWidgetsDomain = function() {
	return getMatchedSiteConfig().widgetsDomain;
 }
 getMatchedTunnelURI = function() {
	return getMatchedSiteConfig().tunnelURI;
 }


var siteConfigs = {'sites': [
	{'siteDomain': 'http://10.210.6.173:9084', 'widgetsDomain': 'http://10.210.6.173:9084', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://10.210.6.173:9447', 'widgetsDomain': 'http://10.210.6.173:9447', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'http://preview.coca-cola.com', 'widgetsDomain': 'http://216.33.74.231', 'tunnelURI': currentDomain+"/content-store/es_CL/Red/tunnel.html"},
	{'siteDomain': 'https://preview.coca-cola.com', 'widgetsDomain': 'http://216.33.74.231', 'tunnelURI': currentDomain+"/content-store/es_CL/Red/tunnel.html"},
	{'siteDomain': 'http://www.coca-cola.com', 'widgetsDomain': 'http://sh.widgets.icoke.com', 'tunnelURI': currentDomain+"/content-store/es_CL/Red/tunnel.html"},
	{'siteDomain': 'https://www.coca-cola.com', 'widgetsDomain': 'https://sh.widgets.icoke.com', 'tunnelURI': currentDomain+"/content-store/es_CL/Red/tunnel.html"},
	{'siteDomain': 'http://www.coca-cola.cl', 'widgetsDomain': 'http://sh.widgets.icoke.com', 'tunnelURI': currentDomain+"/es/tunnel.html"},
	{'siteDomain': 'https://www.coca-cola.cl', 'widgetsDomain': 'https://sh.widgets.icoke.com', 'tunnelURI': currentDomain+"/es/tunnel.html"},
	{'siteDomain': 'http://<<virtual ip>>', 'widgetsDomain': 'http://64.14.236.23', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://<<virtual ip>>', 'widgetsDomain': 'https://64.14.236.23', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'http://64.14.236.42', 'widgetsDomain': 'http://64.14.225.252', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
	{'siteDomain': 'https://64.14.236.42', 'widgetsDomain': 'https://64.14.225.252', 'tunnelURI': currentDomain+"/widget-explorer/tunnel.html"},
]
};

var baseWidgetUrl = ''+getMatchedWidgetsDomain()+'/widgets-server/widget/';

/** Add details of the widgets for which configuration is created. This
includes symbolic name, the encrypted configuration key and the domain on which the widgets are hosted */
var widgetData = {'widgets': [
		{'widget': {
			'name': 'MyLoginWidget',
			'configKey': 'ca52aa23978af5ec1cf919c7824ae1aa',
			'url': baseWidgetUrl,
			'type': 'LoginWidget'
			}
  		},
		{'widget': {
			'name': 'MyProfileWidget',
			'configKey': '5bf566498e423414ec580b7fbf49bdf6',
			'url': baseWidgetUrl,
			'type': 'ProfileWidget'
			}
  		},
		{'widget': {
			'name': 'MyRegistrationWidget',
			'configKey': '2c562b3f74331567bae8a23184142630',
			'url': baseWidgetUrl,
			'type': 'RegistrationWidget'
			}
  		},
		{'widget': {
			'name': 'MyPopupWidget',
			'configKey': '4a819c21b63c3e1cf033305b343291f5',
			'url': baseWidgetUrl,
			'type': 'PopupWidget'
			}
  		},
		{'widget': {
			'name': 'MyContactUsWidget',
			'configKey': '022b8e877d1aa09a8cbefa38328c2386',
			'url': baseWidgetUrl,
			'type': 'ContactUsWidget'
			}
  		},
		{'widget': {
			'name': 'MyDeleteProfileWidget',
			'configKey': '31a4b913d4b410d84c98e7bf4ff41c08',
			'url': baseWidgetUrl,
			'type': 'DeleteProfileWidget'
			}
  		},
		{'widget': {
			'name': 'MyForgotResetPasswordWidget',
			'configKey': '0b7df19abc88890ccfffa3cf3fe365d8',
			'url': baseWidgetUrl,
			'type': 'ForgotResetPasswordWidget'
			}
  		}
	]
};

/** 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", Frameborder:"No"};


/** 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};

