/** PLEASE INITIALIZATION DATA for initialData, widgetData and window.tunnelURI */
var locale = 'en_AU';

var arr = window.location.href.match(/^(http|https):(\/\/)?([^\/\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' : [
		{
			'siteDomain' :'http://www.coca-cola.com.au',
			'widgetsDomain' :'https://ap.widgets.icoke.com',
			'widgetsSecureDomain' :'https://ap.widgets.icoke.com',
			'tunnelURI' :currentDomain + "/tunnel.html"
		}, {
			'siteDomain' :'https://www.coca-cola.com.au',
			'widgetsDomain' :'https://ap.widgets.icoke.com',
			'widgetsSecureDomain' :'https://ap.widgets.icoke.com',
			'tunnelURI' :currentDomain + "/tunnel.html"
		}, {
			'siteDomain' :'https://secure.coca-cola.com.au',
			'widgetsDomain' :'https://ap.widgets.icoke.com',
			'widgetsSecureDomain' :'https://ap.widgets.icoke.com',
			'tunnelURI' :currentDomain + "/tunnel.html"
		}, {
			'siteDomain' : 'http://localhost:8001',
			'widgetsDomain' :'http://widgets.veist.mix.icoke.com',
			'widgetsSecureDomain' :'https://widgets.veist.mix.icoke.com',
			'tunnelURI' :currentDomain + "/tunnel.html"
		}, {
			'siteDomain' : 'https://64.14.236.67',
			'widgetsDomain' :'http://widgets.veist.mix.icoke.com',
			'widgetsSecureDomain' :'https://widgets.veist.mix.icoke.com',
			'tunnelURI' :currentDomain + "/tunnel.html"
		},  {
			'siteDomain' :'http://64.14.236.67',
			'widgetsDomain' :'http://widgets.veist.mix.icoke.com',
			'widgetsSecureDomain' :'https://widgets.veist.mix.icoke.com',
			'tunnelURI' :currentDomain + "/tunnel.html"
		} ]
};
 
var widgetPath = '/widgets-server/widget/';

var widgetMetaData = {
		'widgets' : [
				{
					'widget' : {
						'widgetType' :'ProfileWidget',
						'secureViews' : [ 'viewProfileInfo', 'viewPassword',
								'updatePassword', 'confirmEmailAddress',
								'viewEmailAddress', 'updateEmailAddress',
								'processConfirmation', 'viewEmailOptions',
								'updateEmailOptions', 'viewMobileOptions',
								'updateMobileOptions', 'mobileNumber',
								'updateProfileInfo', 'viewGeneralQuesInfo',
								'updateGeneralQuesInfo', 'viewEntireProfile',
								'updateEntireProfile' ]
					}
				},
				{
					'widget' : {
						'widgetType' :'LoginWidget',
						'secureViews' : [ 'confirmationRequired', 'welcome',
								'login', 'preLogin', 'postLogin',
								'confirmEmailAddress', 'start', 'inboundSSO',
								'logout', 'facebookStart', 'unlinkExternalAccount',
								'externalLogin' ]
					}
				},
				{
					'widget' : {
						'widgetType' :'ForgotResetPasswordWidget',
						'secureViews' : [ 'forgotConfirm', 'resetPassword',
								'start', 'resetConfirm' ]

					}
				},			
				{
					'widget' : {
						'widgetType' :'RegistrationWidget',
						'secureViews' : [ 'registerUserStepTwo',
								'externalRegisterUserStepOne', 'confirmation',
								'registerUser', 'externalRegisterUser',
								'registerUserStepOne' ]
					}
				} ]
	};

var widgetData = {
'widgets' : [ 
	{
		'widget' : {
			'name' :'MyLoginWidget',
			'configKey' :'0fc0ce11359f80fa1632c02d3b3b84e1',
			'type' :'LoginWidget'
		}
	}, {
		'widget' : {
		'name' :'MyPromoLoginWidget',
		'configKey' :'f5c3782b658c4771fe17202158d2ad9e',
		'type' :'LoginWidget'
		}
	}, {
		'widget' : {
			'name' :'MyProfileWidget',
			'configKey' :'9a80c2318190f68a6bbdcb3059de76ef',
			'type' :'ProfileWidget'
		}
	}, {
		'widget' : {
			'name' :'MyRegistrationWidget',
			'configKey' :'bae8a5045f7a84eced5922519549f7e0',
			'type' :'RegistrationWidget'
		}
	}, {'widget': {
			'name': 'ShareSessionWidget',
			'configKey': '8f626f6cb2929ee1876f125dec55d140',
			'type': 'ShareSessionWidget'
			}
  	} ,{'widget': {
		'name': 'MyForgotResetPasswordWidget',
		'configKey': 'e83e00b6c21e8d3fd2addb8fddb81b11',
		'type': 'ForgotResetPasswordWidget'
		}
  	},{'widget': {
		'name': 'MyNewDuplicateLoginWidget',
		'configKey': 'cdc591f4a5236a2cf004c683e16f0fcd',
		'type': 'LoginWidget'
		}
  	},{'widget': {
		'name': 'MyNewLoginWidget',
		'configKey': '494aaecb96e40781df42df2052962221',
		'type': 'LoginWidget'
		}
	},{'widget': {
		'name': 'MyNewLoginWidget1',
		'configKey': '21512d6c5a885ec41b84498554e0565e',
		'type': 'LoginWidget'
		}
	}
]};
	var widget_MyForgotResetPasswordWidget_config = {
		divId : 'passwordWidget',
		 height : '410px',
		 width: '700px'
	};
	
	var widget_MyLoginWidget_config = {
			divId : 'loginWidget',
		    width : '400px',
		    height : '75px'
		};

	var widget_MyLoginWidget_start_config = {
		divId : 'loginWidget',
	    width : '400px',
	    height : '75px'
	};
	
	var widget_MyLoginWidget_postLogin_config = {
			divId : 'loginWidget',
		    width : '720px',
		    height : '580px'
	};
	
	var widget_MyNewLoginWidget_postLogin_config = {
			divId : 'loginWidget',
			width : '720px',
			height : '580px'
	};
	
	
	var widget_MyNewLoginWidget_start_config = {
			divId : 'inlineLoginWidget',
		    width : '400px',
		    height : '230px'
	};
	var widget_MyNewLoginWidget_welcome_config = {
			divId : 'inlineLoginWidget',
		    width : '0px',
		    height : '0px'
		};
	
	
	var widget_MyPromoLoginWidget_start_config = {
			divId : 'inlineLoginWidget',
			width : '330px',
			height : '165px'
	};
	
	var widget_MyPromoLoginWidget_postLogin_config = {
			divId : 'loginWidget',
			width : '720px',
			height : '580px'
	};
	
	var widget_MyPromoLoginWidget_welcome_config = {
			divId : 'inlineLoginWidget',
			width : '0px',
			height : '0px'
	};
	
	var widget_MyLoginWidget_welcome_config = {
			divId : 'loginWidget',
		    width : '200px',
		    height : '75px'
		};

	var widget_MyRegistrationWidget_config = {
		divId : 'registrationWidget',
	    height : '730px',
	    width: '730px'
	};
	
	var widget_ShareSessionWidget_config = {
			divId : 'sessionWidget',
			isInline: true,
			width: '0px',
			height: '0px'
	};
	
	var widget_MyProfileWidget_config = {
			divId : 'myAccountWidget',
			width : '305px',
			height : '400px',
			isInline : true
	};
	
	var widget_MyProfileWidget_updateEmailOptions_config = {
			divId : 'myAccountWidget',
			width : '345px',
			height : '400px',
			isInline : true
	};
	
	var widget_MyProfileWidget_updateEmailAddress_config = {
			divId : 'myAccountWidget',
			width : '390px',
			height : '390px',
			isInline : true
	};
	
	var widget_MyNewLoginWidget1_start_config = {
			divId : 'inlineLoginWidget',
			width : '330px',
			height : '195px'
	};
	
	var widget_MyNewLoginWidget1_postLogin_config = {
			divId : 'loginWidget',
			width : '720px',
			height : '580px'
	};
	
	var widget_MyNewLoginWidget1_welcome_config = {
			divId : 'inlineLoginWidget',
			width : '0px',
			height : '0px'
	};
	
	var widget_default_config = {
			divId: 'widget',
			locale: 'en_AU',
			inputFormat : 'html',
			outputFormat : 'html',
			isInline : true
		};


/** 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 = {
	allowTransparency:"true",
	style : {
		border :"0pt none",
		background :"none"
	},
	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.*/

window.tunnelURI = getMatchedTunnelURI();

/**
 * Widget http > http (vice-versa) url switch configuration
 */
window.widgetURLSwitch = {
	'http' :null,
	'https' :null
};

