/////////////////////////////////////////////////////////////////////
//
// ubmweb.js - common functions
//
// 29.06.02 =pd=
//
/////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////

function setMinBrowserSize(nMinWidth, nMinHeight)
{
var nWidth;
var nHeight;
var xPos;
var yPos;

if (screen == null || window.resizeTo == null || window.moveTo == null)
{
return false;
}

nWidth = getBrowserWidth();
nHeight = getBrowserHeight();

if (nHeight < 10 || nWidth < 10)
{
return false;
}

if (nWidth >= screen.availWidth-6 && nHeight >= screen.availHeight+6)
{
return true;
}

if (nWidth > nMinWidth && nHeight > nMinHeight)
{
return true;
}

// set min size
if (nWidth < nMinWidth)
{
nWidth = nMinWidth;
}

if (nHeight < nMinHeight)
{
nHeight = nMinHeight;
}

if (nWidth > screen.availWidth-6)
{
nWidth = screen.availWidth-6;
}

if (nHeight > screen.availHeight-6)
{
nHeight = screen.availHeight-6;
}

window.resizeTo(nWidth, nHeight);

// set window position
xPos = (screen.availWidth-nWidth) / 2;

if (xPos < 0)
{
xPos = 0;
}

yPos = (screen.availHeight-nHeight) / 2;

if (yPos < 0)
{
yPos = 0;
}

window.moveTo(xPos, yPos);

return true;
}

function getBrowserWidth()
{
if (window.outerWidth)
{
return window.outerWidth;
}
else if (document.body)
{
if (document.body.offsetWidth)
{
return document.body.offsetWidth+32;
}
}

return 0;
}

function getBrowserHeight()
{
if (window.outerHeight)
{
return window.outerWidth;
}
else if (document.body)
{
if (document.body.offsetHeight)
{
return document.body.offsetHeight+140;
}
}

return 0;
}

function isPageLonely(wndPage)
{
var strHref;

// Is lonely? 
if (wndPage.parent)
{
if (wndPage.parent.head)
{
return false;
}
}

strHref = "http://www1.ubm.de/servlet/CreateFrames?javascript=1&main=" + wndPage.location.href;
top.window.location.href = strHref;
return true;
}

function getInternetExplorerVersion()
{
var appVersion;
var iePos;
var iePos2;
var nVersion;

// convert all characters to lowercase to simplify testing
appVersion = navigator.appVersion.toLowerCase();

iePos = appVersion.indexOf('msie');
iePos2 = appVersion.indexOf(';', iePos+5);

if (iePos != -1 && iePos2 != -1)
{
nVersion = parseFloat(appVersion.substring(iePos+5,iePos2));
return nVersion;
}

return 0.0;
}

function isInternetExplorer()
{
// convert all characters to lowercase to simplify testing
appVersion = navigator.appVersion.toLowerCase();

if (appVersion.indexOf('msie') == -1)
return false;

return true;
}

function isFlashInstalled()
{
var i;
var nVersion;
var nPluginVersion;
var strWords;    

if (navigator.plugins == null)
{
return false;
}

if (navigator.plugins.length < 1)
{
return false;
}

if (navigator.plugins["Shockwave Flash"] == null)
{
return false;
}

if (navigator.mimeTypes == null)
{
return false;
}

if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
{
return false;
}

if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin == null)
{
return false;
} 

if (navigator.mimeTypes["application/x-shockwave-flash"].suffixes.indexOf("swf") == -1)
{
return false;
}

strWords = navigator.plugins["Shockwave Flash"].description.split(" ");
nPluginVersion = 0;

for (i=0; i<strWords.length; i++)
{
nVersion = parseInt(strWords[i]);

if (nVersion == Number.NaN)
{
continue;
}

nPluginVersion = nVersion;
break;
}

if (nPluginVersion < 5)
{
return false;
}

return true;
}

function isEmailAddress(strEmail)
{
var nPos1;
var nPos2;

nPos1 = strEmail.indexOf('@');

if (nPos1 < 1)
{
return false;
}

if (nPos1+4 >= strEmail.length)
{
return false;
}

nPos2 = strEmail.lastIndexOf('.');

if (nPos2 == -1)
{
return false;
}

if (nPos1+2 > nPos2)
{
return false;
}

if (nPos2+2 >= strEmail.length)
{
return false;
}

return true;

}