var urlList = new Object();
urlList['de'] = "http://r.bluewin.ch/?id=80508";
urlList['fr'] = "http://r.bluewin.ch/?id=80509";
urlList['it'] = "http://r.bluewin.ch/?id=80510";
urlList['en'] = "http://r.bluewin.ch/?id=80511";

var alertMsgs = new Object();
alertMsgs['de'] = "Die gew\xFCnschte Nummer konnte nicht gew\xE4hlt werden.\nUm die gew\xFCnschte Funktion nutzen zu k\xF6nnen m\xFCssen Sie den Service Bluewin Phone abonniert und das Soft Phone auf Ihrem Computer installiert haben.\nMehr Informationen dazu unter http://www.phone.bluewin.ch";
alertMsgs['fr'] = "Le num\xE9ro demand\xE9 n'a pas pu \xEAtre form\xE9.\nPour pouvoir utiliser la fonction souhait\xE9e, vous devez souscrire un abonnement au service Bluewin Phone et installer Soft Phone sur votre ordinateur.\nPour plus d'informations sur Bluewin Phone http://fr.bluewin.ch/services/bluewin_phone";
alertMsgs['it'] = "Il numero desiderato non ha potuto essere selezionato.\nPer poter utilizzare la funzionalit\xE0 desiderata dovete essere abbonati al servizio Bluewin Phone e avere installato Soft Phone sul vostro computer.\nMaggiori informazioni su Bluewin Phone http://it.bluewin.ch/services/bluewin_phone";
alertMsgs['en'] = "The desired number could not be dialled.\nTo do so, you must be a Bluewin Phone subscriber and have Soft Phone installed on your computer.\nMore information on the Bluewin Phone can be found under http://www.phone.bluewin.ch";

function bluewinPhoneCheck(language)
{
	var applicationMimeType = new Array("application/x-swisscom_bwp", "application/x-swisscom_ggp");
	var applicationID = new Array("swisscom_bwp.detect","swisscom_ggp.detect");
	var returnWhenNotDetectable = true;		// What to return when not _detectable_, e.g. Opera
	var displayHint = false;

	// Currently we only support windows desktop clients
	if (navigator.platform != "Win32") {
		return false
	}

	// First skip those that are not detectable
	if (navigator.userAgent.indexOf('Opera') != -1) {
		// Not detectable
		return returnWhenNotDetectable;	
	} else {
		// Then we try to read the mimeType. E.g. IE does not support this
		if (navigator.mimeTypes.length != 0) {
			// Software found
			for (var i=0; i < applicationMimeType.length; i++) {
	 			if (navigator.mimeTypes[applicationMimeType[i]]) {
					return true;
				}
			}
			// Software NOT found
			if (displayHint) {
				popPhoneUpsellWindow(language);
			}
			return false;
		}

		// Then try it with ActiveX, if WinIE and > V4
		var useActiveX = (((navigator.userAgent.indexOf("MSIE") != -1) && (parseInt(navigator.appVersion) >= 4 )));
		if (useActiveX) {
			var myApp;
			for (var j=0; j < applicationID.length; j++) {
				try {
					var myApp = new ActiveXObject(applicationID[j]);
				} catch (e) {
					// Do Nothing
				}
			}
			if (myApp) {
				return true;
			} else {
				if (displayHint) {
					popPhoneUpsellWindow(language);
				}
				return false;
			}
		}
	}
	// just in case
	return false;
}

function popPhoneUpsellWindow(language)
{
	if (language != null) {
		var name="";
		var directories="no";
		var location="no";
		var status="no";
		var toolbar="no";
		var menubar="no";
		var scrollbars="no";
		var resizable="yes";
		var	width="680";
		var height="460";
		var etc = "toolbar="+toolbar+",status="+status+",location="+location+",directories="+directories+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",width="+width+",height="+height;
	
		if (urlList[language.toLowerCase()] == null) {
			// 'invalid' language, set to "de" as default
			language = "de";
		}
	
		var newWin = window.open(urlList[language.toLowerCase()],name,etc);
		if (newWin == null) {
			alert(alertMsgs[language.toLowerCase()]);
		} else {
			newWin.focus();
			return newWin;
		}
	}
}

