// Version       : 1.1
// Last modified : (K. Breynck) 18.11.2003
// Author        : BBDO InterOne Hamburg
// 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.

function writeMiniFrame (frameWidth,frameHeight,frameColor,contentColor,miniFrameLayer,framePosH,framePosV,frameZIndex,frameBorder) {
  var myMiniFrameLayer;

  if (miniFrameLayer != null) {
    myMiniFrameLayer = DynLayer.getInline(miniFrameLayer);

    if ((framePosH != null) && (framePosV != null)) { myMiniFrameLayer.setLocation(framePosH,framePosV); }
    if (frameZIndex != null)            { myMiniFrameLayer.setZIndex(frameZIndex); }
  }

  var thisBorder       = (frameBorder != null) ? frameBorder : 10;
  var thisContentColor = (contentColor != null) ? contentColor : "#000000";
  var miniFrameString  = '<table cellpadding="0" cellspacing="0" width="' + (frameWidth+1) + '" height="' + (frameHeight+1) + '" border="0">';
      miniFrameString += '  <tr>';
      miniFrameString += '    <td bgcolor="' + frameColor + '" colspan="3"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="1" /></td>';
      miniFrameString += '    <td><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="' + thisBorder + '" /></td>';
      miniFrameString += '  </tr>';
      miniFrameString += '  <tr>';
      miniFrameString += '    <td bgcolor="' + frameColor + '"      ><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="1" /></td>';
      miniFrameString += '    <td bgcolor="' + thisContentColor + '"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="1" /></td>';
      miniFrameString += '    <td bgcolor="' + frameColor + '"      ><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="1" /></td>';
      miniFrameString += '    <td><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="' + (frameHeight-(thisBorder*2)) + '" /></td>';
      miniFrameString += '  </tr>';
      miniFrameString += '  <tr>';
      miniFrameString += '    <td bgcolor="' + frameColor + '" colspan="3"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="1" /></td>';
      miniFrameString += '    <td><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="' + thisBorder + '" /></td>';
      miniFrameString += '  </tr>';
      miniFrameString += '  <tr>';
      miniFrameString += '    <td width="' + thisBorder + '"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="' + thisBorder + '" height="1" /></td>';
      miniFrameString += '    <td width="' + (frameWidth-(thisBorder*2)) + '"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="' + (frameWidth-(thisBorder*2)) + '" height="1" /></td>';
      miniFrameString += '    <td width="' + thisBorder + '"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="' + thisBorder + '" height="1" /></td>';
      miniFrameString += '    <td width="1"><img src="'+ rootpath + '/common/_img/1x1_trans.gif" width="1" height="1" /></td>';
      miniFrameString += '  </tr>';
      miniFrameString += '</table>';
  return miniFrameString;
}

var popupManager = {};
    popupManager.anonymus = [];

function centerPopup(popupName,popupUrl,popupWidth,popupHeight,myWidth,myHeight,myScrollbar) {
	if(!myWidth)     {myWidth = 10;}
	if(!myHeight)    {myHeight = 50;}
	if(!myScrollbar) {myScrollbar = 0;}
	
	var popupLeft = (window.screen.width/2)  - (popupWidth/2 + myWidth);
	var popupTop  = (window.screen.height/2) - (popupHeight/2 + myHeight);
  
  if (isString(popupName) && (popupName !== "")) {
    popupManager[popupName] = window.open(popupUrl,popupName,("toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popupWidth + ",height=" + popupHeight + ",left=" + popupLeft + ",top=" + popupTop + ",screenX=" + popupLeft + ",screenY=" + popupTop));
    popupManager[popupName].focus();
  } else {
    popupManager.anonymus[popupManager.anonymus.length] = window.open(popupUrl,popupName,("toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popupWidth + ",height=" + popupHeight + ",left=" + popupLeft + ",top=" + popupTop + ",screenX=" + popupLeft + ",screenY=" + popupTop));
    popupManager.anonymus[popupManager.anonymus.length-1].focus();
  }
}

function justifyPopup(popupName,popupUrl,popupWidth,popupHeight,myScrollbar,myLeft,myTop) {
  if(!myScrollbar) {myScrollbar = 0;}
  if(!myLeft)      {myLeft      = 0;}
  if(!myTop)       {myTop       = 0;}

  var popupLeft = ((document.all) ? window.screenLeft + myLeft : window.screenX);
  var popupTop  = ((document.all) ? window.screenTop  + myTop  : window.screenY);

  if (isString(popupName) && (popupName !== "")) {
    popupManager[popupName] = window.open(popupUrl,popupName,("toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popupWidth + ",height=" + popupHeight + ",left=" + popupLeft + ",top=" + popupTop + ",screenX=" + popupLeft + ",screenY=" + popupTop));
    popupManager[popupName].focus();
  } else {
    popupManager.anonymus[popupManager.anonymus.length] = window.open(popupUrl,popupName,("toolbar=no,location=no,status=no,menubar=no,scrollbars=" + myScrollbar + ",resizable=no,width=" + popupWidth + ",height=" + popupHeight + ",left=" + popupLeft + ",top=" + popupTop + ",screenX=" + popupLeft + ",screenY=" + popupTop));
    popupManager.anonymus[popupManager.anonymus.length-1].focus();
  }
}
