// Version       : 1.0
// Last modified : 18.08.2003
// Author        : BBDO InterOne Hamburg (W. Rauch)
// Copyright     : BMW Group 2002-2003

// Unique scripting solutions that are provided for  BMW Group sites are for use exclusively
// within  BMW Group projects.  No other use of these solutions is permitted.

if(top.frames.length != 0){
  if(self.location.search == ""){
	if (document.referrer.indexOf('home.asp') != -1) initContentURL = ""
	top.location.href = self.location.href
  } else {
    top.location.href = self.location.href.substring(0, self.location.href.indexOf(self.location.search));
  }
}


// Height of the Top-Frame
var topMin            = 105;
var user_agent        = window.navigator.userAgent;
var isUserAgentNT     = ((user_agent.toLowerCase().indexOf("winnt") != -1) || (user_agent.toLowerCase().indexOf("windows nt") != -1));
// Height of the Bottom-Frame
var bottMin           = isUserAgentNT ? 20 : 26;  
var win_height        = window.innerHeight;
var height_percent    = (win_height/100);
var curr_width        = window.innerWidth;
var curr_height       = window.innerHeight;
var tmpTop            = 0;
var tmpBottom         = 0;
var checkTopHeight    = true;
var checkBottomHeight = true;
var frameSetHeader    = "";
var topFrameParam     = "";
var contentFrameParam = "";
var bottomFrameParam  = "";
var topFrame          = "";
var contentFrame      = "";
var bottomFrame       = "";
var startPos          = self.location.href.indexOf(countryLanguageId);
var tempUrl           = self.location.href.substr(0,(self.location.href.lastIndexOf("/")+1));
var contentPathParameter  = tempUrl.substr(startPos,tempUrl.length)+ "default.";

// This script defines the heights of the Top and bottom Frames depending on the Browser being used.
// The variable frameSetHeader, which contains the HTML-Code for the "frameset"-Tag, is constructed from these values
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion.substring(0,1)) < 5)) {
  for (i = 1; i < 100; i++) {
    if (checkTopHeight) {
      if (Math.floor(height_percent*i) >= topMin) {
        tmpTop = i;
        checkTopHeight = false;
      }
    }
    if (checkBottomHeight) {
      if (Math.floor(height_percent*i) >= bottMin) {
        tmpBottom = i;
        checkBottomHeight = false;
      }
    }
  }
  frameSetHeader = '<frameset onResize="if(document.layers){self.location.reload();}" rows="' + tmpTop + '%,*,' + tmpBottom + '%" framespacing="0" frameborder="no" border="0">';
}
else {
  frameSetHeader = '<frameset rows="' + topMin + ',*,' + bottMin + '" framespacing="0" frameborder="no" border="0">';
 }
 
// If the variable contentPathParameter in the Frameset is not empty(""), its contents are attached to the 3 frame URLs
if(contentPathParameter != ""){
  contentFrameParam += (contentFrameParam != "")?"&":"?";
  contentFrameParam += escape("contentPath="+contentPathParameter);
  bottomFrameParam  += (bottomFrameParam != "")?"&":"?";
  bottomFrameParam  += escape("contentPath="+contentPathParameter);
  topFrameParam     += (topFrameParam != "")?"&":"?";
  topFrameParam     += escape("contentPath="+contentPathParameter);
}

// If the variable rubricHeaderSource in the Frameset is not empty(""), its contents are attached to the Top-Frame-URL
if(rubricHeaderSource != ""){
  topFrameParam += (topFrameParam != "")?"&":"?";
  topFrameParam += escape("rubricHeaderSource="+rubricHeaderSource);
}

function setMacVariables(){
  topFrame       = parent.frames[0]; //Top-Frame Object
  contentFrame   = parent.frames[1]; //Content-Frame Object
  bottomFrame    = parent.frames[2]; //Bottom-Frame Object
  framesetStatus = true;
  window.clearTimeout(macTimer);
}

// The frameset is written here
macTimer = window.setTimeout('setMacVariables()',500);
document.writeln(frameSetHeader);
document.writeln('<frame src="' + topFrameSource    + topFrameParam     + '" name="'+ topFrameName     +'" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" noresize="noresize" />');

if( initContentURL.indexOf('=') != -1 )
{
	document.writeln('<frame src="' + initContentURL + '&' + contentFrameParam.substring(1) + '" name="'+ contentFrameName +'" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />');
}
else
{
	document.writeln('<frame src="' + initContentURL + contentFrameParam + '" name="'+ contentFrameName +'" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />');
}

document.writeln('<frame src="' + bottomFrameSource + bottomFrameParam  + '" name="'+ bottomFrameName  +'" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" noresize="noresize" />');
document.writeln('</frameset>');

if(navigator.appVersion.indexOf("Mac") == -1){
  topFrame       = parent.frames[0]; //Top-Frame Object
  contentFrame   = parent.frames[1]; //Content-Frame Object
  bottomFrame    = parent.frames[2]; //Bottom-Frame Object
  framesetStatus = true;
}
