   help_folder_open      = new Image(33,14);
    help_folder_open.src  = '/tools/wip_v4/admin/img/icon_up.gif';
    help_folder_close     = new Image(33,14);
    help_folder_close.src = '/tools/wip_v4/admin/img/icon_down.gif';
    var helpactive = '';

    function togglehelp(timage, tdiv, tlink, open, empty){
      if ( timage ) {
	if ( timage.src==help_folder_open.src ){
	  timage.src=help_folder_close.src;
	}
	else {
	  timage.src=help_folder_open.src;
	}
      }
      if ( tdiv ) {
	if ( tdiv.display=='block' && !open ) {
	  tdiv.display='none';
	}
	else {
	  tdiv.display='block';
	}
      }
      if ( tlink ) {
	active.background='#ffffff';
	active.color='#000000';
	tlink.background='#666666';
	tlink.color='#ffffff';
	helpactive=tlink;
      }
    }

function choose_image(img, form, size, colors, width, height, format, filesize, imagesize) {
  if (size) {
    window.opener.document.images[form].src = '/photoalbum/view/?size=' + size + '&id='+img;
  } else {
    window.opener.document.images[form].src = '/photoalbum/view/?size=thumb&id='+img;
  }
  window.opener.document.edit.elements[form + '_path'].value=img;
  if(window.opener.document.edit.elements[form + '_colors']){ window.opener.document.edit.elements[form + '_colors'].value=colors; }
  if(window.opener.document.edit.elements[form + '_width']){ window.opener.document.edit.elements[form + '_width'].value=colors; }
  if(window.opener.document.edit.elements[form + '_height']){ window.opener.document.edit.elements[form + '_height'].value=colors; }
  if(window.opener.document.edit.elements[form + '_format']){ window.opener.document.edit.elements[form + '_format'].value=colors; }
  if(window.opener.document.edit.elements[form + '_filesize']){ window.opener.document.edit.elements[form + '_filesize'].value=colors; }
  if(window.opener.document.edit.elements[form + '_imagesize']){ window.opener.document.edit.elements[form + '_imagesize'].value=colors; }

  if (confirm("Picture is placed into article...\nClose this window?")) {
    self.close();
  }
  else {
    return true;
  }
}


function vindu(url,title,width,height) {
  newwin=window.open(url,title,'width='+width+',height='+height+',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
  newwin.resizeTo(width,height);
  newwin.focus();
  x = screen.width;
  y = screen.height;
  newwin.moveTo((x/2)-(width/2),(y/2)-(height/2));
}


  function vindu_popup_1(url,title,width,height) {
  newwin = window.open(url,title,'width='+width+',height='+height+',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
  newwin.focus();
  x = screen.width;
  y = screen.height;
//newwin.moveTo((x/2)-(width/2),(y/2)-(height/2));
}



window.onresize = checkSubnavPos;


//mouseover function for graphic links
function showLinkHilite(whichImgObj){
  try {
		whichImgObj.src = whichImgObj.onimg.src;
	}
	catch (e) {
	  // ignore
	}
}

//mouseout function for graphic links
function resetLinkHilite(whichImgObj){
  try {
		whichImgObj.src = whichImgObj.offimg.src;
	}
	catch (e) {
	  // ignore
	}
}

//constructor for image objects of graphic links
function createGraphicLink(whichImg,lowsrc,hisrc){
	//erzeugen der mouseover-Images
	if(!whichImg.counter){
		whichImg.counter = 1;
		whichImg.offimg = new Image();
		whichImg.offimg.src = lowsrc;
		whichImg.onimg = new Image();
		whichImg.onimg.src = hisrc;
		}
}

//function carline_OnMouseOver(element) {
//  element.className = "carline_on";
//}

//function carline_OnMouseOut(element) {
//  element.className = "carline_off";
//}

//================================================================
//Scripts for Subnav-Menu
//===============================================================

//Variable f&uuml;r den popup-timer
var zu;

var subMenuActivated = 0;

//creating Subnav-SubMenu (dropdownbox)
function subMenu(whichMenu,whichLevel,whichPreselected){
	//props for checking subnav-submenu-position
	if(whichLevel == 2){
		this.top = 8;
		}
	else{
		this.top = 28;
	}	
	//reading Menu-Array, writing HTML-Codes
	this.activeMenu = eval(whichMenu);

	this.subMenuItemsList = "";
	if(this.activeMenu != 0) {
		for(var i = 0; i < this.activeMenu.length; i+=2) {
  		this.subMenuItemsList +=  this.activeMenu[i+1] + this.activeMenu[i] + "</a>";
		}
	this.subMenuItemsList = "<div id='subnav_sub_list'>" + this.subMenuItemsList + "</div>";	
	}
	
}

//function for subnav-submenu-popup (dropdownbox)
//args = name of menuset 

function showSubMenu(whichMenu) {
	//workaround mozilla menuwidth bug
	if(navigator.appVersion.indexOf("MSIE") != -1){
		document.getElementById("subnav_submenu").style.width = 155 + "px";
		}
	else{
		//document.getElementById("subnav_submenu").style.width = "auto";
		document.getElementById("subnav_submenu").style.width = 155 + "px";
		//mozilla clipping workaround
		document.getElementById("subnav").style.clip = "rect(auto,auto,800px,0px)";
	}
	document.getElementById("subnav_submenu").style.visibility = "hidden";
	document.getElementById("subnav_submenu").style.display = "none";
	//writing html-strings
	if(whichMenu.activeMenu != 0) {
		document.getElementById("subnav_submenu").innerHTML = whichMenu.subMenuItemsList;
		document.getElementById("subnav_submenu").style.display = "block";
	}
	//positioning menu-layers
	if(whichMenu.activeMenu != 0) {
		document.getElementById("subnav_submenu").style.top = whichMenu.top + "px";
		document.getElementById("subnav_submenu").style.visibility = "visible";
		document.getElementById("subnav_submenu").style.display = "block";				
        document.getElementById("subnav_submenu").style.backgroundImage = "url(" + global_staticpath_images + "/bg_subnav_submenu.gif)";
	}
	//if there is no submenu
	else if(whichMenu.activeMenu == 0) {
		document.getElementById("subnav_submenu").style.visibility = "hidden";
		document.getElementById("subnav_submenu").style.display = "none";
		}
	//reset timeout
	window.clearTimeout(zu);	
}


function submenuCollaps(){
		//verstecken des popup-menues
		window.clearTimeout(zu);
		document.getElementById("subnav_submenu").style.visibility="hidden";
		document.getElementById("subnav_submenu").style.display="none";		
}
//************************************************************//
//functions for subnavigation fold show/hide
var subnavzu;
var subnavauf;
var slidetimer;
slidetoggle = 0;
var isIE = '';
if(navigator.appVersion.indexOf("MSIE") != -1) isIE = true;

function subnavTimer(){
	if(!document.getElementById('subnav')) return;
	window.clearTimeout(subnavzu);
	try {
		if (parseInt(currSubnavLeft) < 640){ subnavauf = window.setTimeout("showSubnav()",50);}
	}
	catch (e) {
	  // ignore
	}
}

function showSubnav(){	
		if(slidetoggle==1) return;
		window.clearTimeout(subnavauf);				
		document.getElementById("subnav").style.visibility="visible";
		document.getElementById("subnav").style.display = "block";
		document.getElementById("subnav").style.clip = "rect(auto,160px,auto,160px)";
		mycurrentwidth = 160;
		slidecount = 4;
		slideSubnavOn();
		slidetoggle=1;		
}

function subnavCollaps(){
	if(!document.getElementById('subnav')) return;
	try {
		if(parseInt(currSubnavLeft) < 640){
			window.clearTimeout(subnavauf);	 
			window.clearTimeout(subnavzu);
			slidecount = 8;
			mycurrentwidth=0;
			//window.clearTimeout(slidetimer);
			slideSubnavOff();
			slidetoggle=0;
		}
	}
	catch (e) {
	  // ignore
	}			
}
function dropdown_subnavmouseEnter() {
	window.clearTimeout(subnavzu);
	window.clearTimeout(slidetimer);
	}

//**************************************************************//
function dropdown_mouseEnter() {
	window.clearTimeout(zu);
	}

function dropdown_mouseLeave(whichMenu) {
	switch (whichMenu) {
			case 'main':
			zu = window.setTimeout("menuCollaps()",50);
			break;
			case 'sub':
			zu = window.setTimeout("submenuCollaps()",300);
			break;
			case 'subnav':
			subnavzu = window.setTimeout("subnavCollaps()",500);
			break;
			}			
	}
	
//===================================================
//functions for subnav-positioning
//===================================================

//detect mouse-over image position for correct layer positioning

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getElementByClass(pClassName)
{
	elements = window.document.getElementsByTagName('*');

	for (i=0; i<elements.length; i++) {
		if (elements[i].className == pClassName) {
			return elements[i];
		}
	}
}

function checkSubnavPos(){

	// Stretch the content frame at least as high as the mainnav
	var frame = getElementByClass("screen_4");
	var mainnav_end = document.getElementById("mainnav_end");
	if (frame && mainnav_end) {
		var posY = findPosY(mainnav_end);
		if ((findPosY(frame) + frame.offsetHeight) < posY) {
			var height = posY - findPosY(frame);
			if (navigator.appVersion.indexOf("MSIE") != -1) {
				frame.style.height = height + "px";
			} else {
				frame.style.minHeight = height + "px";
			}
		}
	}

	if(!document.getElementById('subnav')) {
		// Set the background unconditionally if there's no subnav
	    if (document.body.background.indexOf("/bg.gif") == -1) {
            document.body.background = global_staticpath_images + "/bg.gif";
        }
        return;
	}
	var currLeft = findPosX(document.getElementById('mainnav'));
	var currWidth = currLeft - 640;
	if(currWidth > 160) {
	document.getElementById("subnav").style.left = (currLeft - currWidth) + "px";
	document.getElementById("subnav").style.width = currWidth + "px";
	}
	else{
	document.getElementById("subnav").style.left = (currLeft - 160) + "px";
	document.getElementById("subnav").style.width = 160 + "px";
	}
	currSubnavLeft = document.getElementById("subnav").style.left;
	if(parseInt(currSubnavLeft) < 640){
		document.getElementById("subnav").style.visibility = "hidden";
	}
	else{
	document.getElementById("subnav").style.visibility = "visible";
	document.getElementById("subnav").style.display = "block";
	document.getElementById("subnav").style.clip = "rect(auto,auto,auto,0px)";
	}

    // resize the fold and set the background image depending on the subnav height
    var mysubnavheight = document.getElementById("subnav").offsetHeight;
    if (mysubnavheight < 228) {
        document.getElementById("subnav").style.height = 228 + "px";
        if (document.body.background.indexOf("/bg.gif") == -1) {
            document.body.background = global_staticpath_images + "/bg.gif";
        }
    } else if (mysubnavheight > 228 && mysubnavheight < 396) {
        document.getElementById("subnav").style.height = 396 + "px";
        if (document.body.background.indexOf("/bg_long.gif") == -1) {
            document.body.background = global_staticpath_images + "/bg_long.gif";
        }
    }

	//abfrage fold-height
	var checkSubnavLong = getElementbyClass("subnav_content_long");
	if(checkSubnavLong==true){
		var mysubnavheight = document.getElementById("subnav").offsetHeight;
	//alert(mysubnavheight);
		var mymainnavheight = document.getElementById("mainnav").offsetHeight - 72;
		if(mysubnavheight > mymainnavheight) document.getElementById("mainnav").style.height = (mysubnavheight + 72) + "px";
	}	
} 

//check if subnav_content_long class is present
function getElementbyClass(classname){
	var divtags=document.all? document.all : document.getElementsByTagName("div");
	for (i=0; i<divtags.length; i++){
		if (divtags[i].className==classname){
		return true;
		return;
		}
	}
}

//slide function for subnav fold
function slideSubnavOn(){
	slidecount = slidecount*2;	
	mycurrentwidth = (mycurrentwidth - slidecount);	
	var mycurrentrect = "rect(auto,160px,auto," + mycurrentwidth + "px)";
	if(isIE){
		document.getElementById("subnav").style.clip = mycurrentrect; 
	}
	else{
		document.getElementById("subnav").style.visibility = "hidden";
		document.getElementById("subnav").style.clip = "rect(auto,160px,auto,0px)";
		document.getElementById("subnav").style.clip = mycurrentrect;
		document.getElementById("subnav").style.visibility = "visible";
	}
	if (mycurrentwidth<=0){
		
		window.clearTimeout(slidetimer);slidetimer=0;
		}
	else{
		slidetimer = window.setTimeout("slideSubnavOn()",5);
		}
}

function slideSubnavOff(){
	slidecount = slidecount*3;
	mycurrentwidth = mycurrentwidth + slidecount;
	var mycurrentrect = "rect(auto,160px,auto," + mycurrentwidth + "px)";
	if(isIE){
		document.getElementById("subnav").style.clip = mycurrentrect; 
	}
	else{
		document.getElementById("subnav").style.visibility = "hidden";
		document.getElementById("subnav").style.clip = "rect(auto,160px,auto,0px)";
		document.getElementById("subnav").style.clip = mycurrentrect;
		document.getElementById("subnav").style.visibility = "visible";
	}
	if (mycurrentwidth>=160){
		
		window.clearTimeout(slidetimer);slidetimer=0;
		}
	else{
		slidetimer = window.setTimeout("slideSubnavOff()",1);
		}
}


//===============================
//image hilite without submenu-popup
//==============================
function mainButton(whichImg,offsrc,onsrc){
	this.imgname = new Object(whichImg);
	this.imgname.createHiliteImages = createImgObjs;
	this.imgname.createHiliteImages(offsrc,onsrc,'');
		
}

//function for module m581
function stageButton(whichImg,offsrc,onsrc,hisrc){
	this.imgname = new Object(whichImg);
	this.imgname.createHiliteImages = createImgObjs;
	this.imgname.createHiliteImages(offsrc,onsrc,hisrc);
}

//hilite-image method
function createImgObjs(offsrc,onsrc,hisrc,midsrc,big800,big1024,big1280){
	this.offimg = new Image();
    this.offimg.src = offsrc;
	this.onimg = new Image();
	this.onimg.src = onsrc;
	this.hiliteimg = new Image();
	this.hiliteimg.src = hisrc;
	if(arguments.length > 3) {
		this.midimg = midsrc;
		this.big800 = big800;
		if(big1024) this.big1024 = big1024;
		if(big1280) this.big1280 = big1280;
		}
	}

function showHigh(whichButton,whichPic){
	if(whichPic == 0) document.images[whichButton.imgname].src = whichButton.imgname.onimg.src;	
}

function resetHigh(whichButton,whichPic){
	if(whichPic == 0) document.images[whichButton.imgname].src = whichButton.imgname.offimg.src;
}

//functions for m581 hilite
var activeStagePic;

function changeStageHigh(whichButton,whichPic){
	if(whichPic == 0) {
	if(activeStagePic && activeStagePic != whichButton.imgname)  document.images[activeStagePic].src = activeStagePic.offimg.src;
	activeStagePic = whichButton.imgname;
	document.images['m621_img'].src = whichButton.imgname.hiliteimg.src;
	}
}

function showStageHigh(whichButton,whichPic){
	if(whichPic == 0) {
	document.images[whichButton.imgname].src = whichButton.imgname.onimg.src;	
	}
}

function resetStageHigh(whichButton,whichPic){
	if(whichPic == 0 && activeStagePic != whichButton.imgname) {
	document.images[whichButton.imgname].src = whichButton.imgname.offimg.src;
	}
}

function setOffStage(whichImg){
	stageimgsrc = whichImg;
}

//=========================================
// JS for m614_linkbox_gallery_1col
//=========================================

// Constructor for objects that contain all information about the available download versions
// of a Media Gallery Item
function MediaDownloadVersions() {
  this.smallUrl = null
  this.smallWidth = 0;  
  this.smallHeight = 0;
  this.smallSize = 0;
  
  this.mediumUrl = null;
  this.mediumWidth = 0;  
  this.mediumHeight = 0;
  this.mediumSize = 0;  
  
  this.largeUrl = null;
  this.largeWidth = 0;  
  this.largeHeight = 0;
  this.largeSize = 0;
}

// an instance of MediaDownloadVersions containing the download versions of the currently selected Media Gallery Item
var selectedDownloadVersions = null;

// update the automatic linkbox module and optionally switch the currently selected GalleryItem
function updateLinkBox(downloadVersions) {
  if (downloadVersions) {
    selectedDownloadVersions = downloadVersions;
  }
  var linkboxDiv = document.getElementById('imagegallery_linkbox_div');
  if (!linkboxDiv) {
    // do nothing if the div does not exist
    // alert("failed to access element with id 'imagegallery_linkbox_div'");
    return; 
  }
  
  if (!selectedDownloadVersions) {
    linkboxDiv.innerHTML = '';
    return;
  }
  
  var newHTML = '';
  if (selectedDownloadVersions.smallUrl) {
    newHTML+= constructMediaDownloadLink(selectedDownloadVersions.smallUrl, selectedDownloadVersions.smallWidth, selectedDownloadVersions.smallHeight, selectedDownloadVersions.smallSize);
  }
  if (selectedDownloadVersions.mediumUrl) {
    newHTML+= constructMediaDownloadLink(selectedDownloadVersions.mediumUrl, selectedDownloadVersions.mediumWidth, selectedDownloadVersions.mediumHeight, selectedDownloadVersions.mediumSize);
  }
  if (selectedDownloadVersions.largeUrl) {
    newHTML+= constructMediaDownloadLink(selectedDownloadVersions.largeUrl, selectedDownloadVersions.largeWidth, selectedDownloadVersions.largeHeight, selectedDownloadVersions.largeSize);
  }
  linkboxDiv.innerHTML = newHTML;

}

function constructMediaDownloadLink(url, width, height, size) {

  return '<div class="box_link">' +
         '<a href="'+url+'" target="_blank"><img src="/author/cms4imp_base/audi/images/arrow_orange.gif" alt="&gt;" class="arrow" height="9" width="9"></a>' +
         '<a href="'+url+'" target="_blank">' + width + ' x ' + height + '</a>'+
         '</div>';  
}





//=========================================
//popup
//=========================================

function sWindow (swin) {
window.open(swin,null,"height=540,width=420,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes");
}

//=========================================
//functions for crossbox
//=========================================

var inactiveEntry = '';
var activeEntry = '';
var activeEntryContent = '';
tabArray = new Array();

function switchBox(whichBox){
		
	if(activeEntry){
		document.getElementById(activeEntry).style.visibility = "hidden";
		document.getElementById(activeEntry).style.display = "none";
		document.getElementById(activeEntryContent).style.visibility = "hidden";
		document.getElementById(activeEntryContent).style.display = "none";
		if(activeEntry.indexOf("worldwide")!= -1){
			document.getElementById('crossbox_world').style.visibility = "hidden";
			document.getElementById('crossbox_world').style.display = "none";
		}
		document.getElementById(inactiveEntry).style.visibility = "visible";
		document.getElementById(inactiveEntry).style.display = "block";
		if(navigator.appVersion.indexOf("MSIE") == -1){
			document.getElementById(inactiveEntry).style.height = 17 + "px";
			document.getElementById(inactiveEntry).style.borderTop = "solid 1px #262626";
			document.getElementById(inactiveEntry).style.paddingTop = "2px";
		}		
		}
	var myEntry = whichBox + "_a";
	var myEntryContent = whichBox + "_b";
	activeEntry = myEntry;
	activeEntryContent = myEntryContent;
	inactiveEntry = whichBox;
	if(navigator.appVersion.indexOf("MSIE") == -1){
		document.getElementById(whichBox).style.height = 0 + "px";
		document.getElementById(whichBox).style.border = 0 + "px";
		document.getElementById(whichBox).style.padding = 0 + "px";
	}
	else{
		document.getElementById(whichBox).style.visibility = "hidden";
		document.getElementById(whichBox).style.display = "none";	
	}	
	document.getElementById(activeEntry).style.visibility = "visible";
	document.getElementById(activeEntry).style.display = "block";
	document.getElementById(activeEntryContent).style.visibility = "visible";
	document.getElementById(activeEntryContent).style.display = "block";
	document.getElementById(activeEntryContent).style.height = 67 + "px";
	if(whichBox.indexOf("worldwide")!= -1){
			document.getElementById('crossbox_world').style.visibility = "visible";
			document.getElementById('crossbox_world').style.display = "block";
		}
	
}

var crossboxInitialized = false;

function initCrossbox(whichCB){

	var CBnum = tabArray.length;
	for(i=0;i<CBnum;i++){
		var myEntry = tabArray[i] + "_a";
		var myEntryContent = tabArray[i] + "_b";
		document.getElementById(myEntry).style.visibility = "hidden";
		document.getElementById(myEntry).style.display = "none";
		document.getElementById(myEntryContent).style.visibility = "hidden";
		document.getElementById(myEntryContent).style.display = "none";	
	}

	if (document.getElementById(whichCB)) {
		var myEntry = whichCB + "_a";
		var myEntryContent = whichCB + "_b";
		activeEntry = myEntry;
		activeEntryContent = myEntryContent;
		inactiveEntry = whichCB;
		document.getElementById(whichCB).style.visibility = "hidden";
		document.getElementById(whichCB).style.display = "none";
		document.getElementById(activeEntry).style.visibility = "visible";
		document.getElementById(activeEntry).style.display = "block";
		document.getElementById(activeEntryContent).style.visibility = "visible";
		document.getElementById(activeEntryContent).style.display = "block";
	}
	//special case for worldwide
	if(whichCB == "worldwide"){
		document.getElementById('crossbox_world').style.visibility = "visible";
		document.getElementById('crossbox_world').style.display = "block";
  }
  
	crossboxInitialized = true;  
}

//counting tabs for default ibox display
function countTab(whichTab){
	tabArray[tabArray.length] = whichTab;	
}

//=========================================
//functions for item_select
//=========================================
function handleSelection(whichForm){
	try {
		eval(whichForm.item_select.options[whichForm.item_select.selectedIndex].value);
	} catch (ex) {
		// Ignore
	}
	return false;
}

//=========================================
//functions for popups
//=========================================

function isBlockedByCookie(pSrcHandle){
	if (document.cookie) {
		if (document.cookie.lastIndexOf(pSrcHandle) >= 0) {
			return true;
		}
	}
	return false;
}

function openWindow(pUrl, pTarget, pParameter, pSrcHandle, pWidth, pHeight, pTracking) {

	if (pSrcHandle && isBlockedByCookie(pSrcHandle)) {
		// open once per session only.
		return;
	}
	
	// center popup on screen
	if (pWidth) {
		var winX = (screen.availWidth/2)-(pWidth/2);
		pParameter += ",width=" + pWidth + ",left=" + winX + ",scrX=" + winX;
	}
	
	if (pHeight) {
		var winY = (screen.availHeight/2)-(pHeight/2);
		pParameter += ",height=" + pHeight + ",top=" + winY + ",scrY=" + winY;
	}

	if (pTracking) {
		var win = tc_open_window(pTarget, pUrl, '', pParameter);
	} else {
		var win = window.open(pUrl, pTarget, pParameter);
	}
	
	try {
		if (win) {
			if (pSrcHandle && document.cookie) {
				// set cookie
				document.cookie = pSrcHandle + "=true; Path=/";
			}
			win.focus();
			win.setTimeout("try { self.focus() } catch (ex) {}", 1000);
		}
	}
	catch (e) {
	  // ignore
	}

	return win;
}

//=========================================
//functions for timeline modules
//=========================================

function showTimelineLayer(pLayerIndex, pMediaURL1, pMediaURL2) {
	var index = 0;
	while (layer = document.getElementById("timeline_layer_" + index)) {
		if (index == pLayerIndex) {
			layer.style.visibility = "visible";
		} else {
			layer.style.visibility = "hidden";
		}
		index++;
	}
	
	var imgElement = document.getElementById("m625_img");
	if (imgElement && pMediaURL1) {
		imgElement.src = pMediaURL1;
	}
	
	imgElement = document.getElementById("m626_img");
	if (imgElement && pMediaURL2) {
		imgElement.src = pMediaURL2;
	}
	
}

//=========================================
// image popup
//=========================================

function showImagePopup(pImageURL, pWidth, pHeight, pTitle) {
  if (!pImageURL) {
    return;
  }
  var windowFeatures = 'toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=no,'
    + 'width=' + pWidth + ',height=' + pHeight;
  if (!pTitle || pTitle=='') {
    pTitle = 'Audi';
  }
  var popup = window.open('', 'imagePopup', windowFeatures);
  if (popup) {
    popup.document.clear();
    popup.focus();
    popup.document.writeln('<html><head><title>' + pTitle + '</title></head>');
    popup.document.writeln('<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" style="margin:0px">');
    popup.document.writeln('<center><img src="' + pImageURL + '" border="0" alt=""></center>');
    popup.document.writeln('</body>');
    popup.document.writeln('</html>');
    popup.document.close();
    popup.focus();
  }
}

/**
 * Gets the value of the specified cookie.
 * name  Name of the desired cookie.
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

function renderLoginArea(pLoggedOutLinks, pLoggedInLinks, pText) {
	var name = getCookie("myAudi.name");
	if (name != null) {
		pText = pText.replace(/\{0\}/, name);
		document.write("<div class=\"crossbox_text\">");
		document.write(pText);
		document.write("</div>");
		for (var i in pLoggedInLinks) {
			renderLink(pLoggedInLinks[i]);
		}
		initCrossbox('login');
	} else {
		for (var i in pLoggedOutLinks) {
			renderLink(pLoggedOutLinks[i]);
		}
	}
}

function renderLink(pLink) {
  document.write("<div class=\"crossbox_link\">");
  if (pLink.url.length > 0) {
		document.write("<a href=\"" + pLink.url + "\">");
	}
  document.write("<img src=\"" + global_staticpath_images + "/arrow_orange.gif\" width=\"9\" height=\"9\" alt=\"&gt;\" class=\"crossbox_arrow\">");
	if (pLink.url.length > 0) {
	    document.write("</a>");
	}
	if (pLink.url.length > 0) {
		document.write("<a href=\"" + pLink.url + "\">");
	}
	document.write(pLink.title);
	if (pLink.url.length > 0) {
	    document.write("</a>");
	}
  document.write("</div>");
}

/**
 * Defines a link reference.
 * @param pTitle Link title.
 * @param pURL for link. Can be URL or javascript: call (optional).
 */
var crossbox_link = function(pTitle, pURL) {
  this.title = pTitle;
  this.url = pURL;
}
