﻿var PickPhoneManager =
{
	_popupManager: null,
	_phonePopupUrl: null,
	_countryCode: null,
	_languageCode: null,
	_trackClicks: null,
	_otherPhoneNavigateUrl: null,
	
	Init: function(popupManager, phonePopupUrl, countryCode, languageCode, trackClicks, ajaxLoadingImageUrl, otherPhoneNavigateUrl, initialPopupId) {
		this._popupManager = popupManager;
		this._phonePopupUrl = phonePopupUrl;
		this._countryCode = countryCode;
		this._languageCode = languageCode;
		this._trackClicks = trackClicks;
		this._otherPhoneNavigateUrl = otherPhoneNavigateUrl;

		this._popupManager.Init("#popup-container", "#popup-content", ajaxLoadingImageUrl, languageCode);
		
		if(initialPopupId && initialPopupId != "" && initialPopupId != "other")
		{
			PickPhoneManager.Pick(initialPopupId);
		}
	},

	Pick: function(phoneIdentifier, releaseDate)
	{
		if(phoneIdentifier == "other")
		{
			window.location = this._otherPhoneNavigateUrl;
			return;
		}

		if(phoneIdentifier != null && phoneIdentifier != '')
		{
			if(PickPhoneManager._trackClicks)
				trackLink(this, phoneIdentifier + ' navigate link', PickPhoneManager._countryCode, PickPhoneManager._languageCode);
			
			PickPhoneManager._popupManager.Show(PickPhoneManager._phonePopupUrl, phoneIdentifier, releaseDate);
			
			//var isLessThanIE7 = $.browser.msie && parseInt( $.browser.version ) < 7;
			//if(isLessThanIE7)
			window.scrollTo(0, 0);
		}
	}
}
