hzoomWin = null;
//================================================================
//Scripts for Subnav-Menu (SR3.5)
//===============================================================
//hilite-image method
function createHiliteObj(picsrcLo, picsrcHi){
	this.offimg = new Image();
    this.offimg.src = picsrcLo;
	this.onimg = new Image();
	this.onimg.src = picsrcHi;
}
//creating Subnav-Menu
function sr35_subMenu(whichMenu,whichImg,picsrcLo,picsrcHi){
	//creating mouseover-Images
	this.imgname = new Object(whichImg);
	this.imgname.createHiliteImages = createHiliteObj;
	this.imgname.createHiliteImages(picsrcLo,picsrcHi);
	//props for checking img-position
	this.imgPosChecked = 0;
	this.menuPos = 0;
	this.menuTop = 0;
	this.imgHeight = 0;
	this.imgWidth = 0;
	this.menuWidth = 0;
	//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++) {
			this.subMenuItemsList += this.activeMenu[i+1] + this.activeMenu[i] + "</a>";
			i = i + 1;
		}
	this.subMenuItemsList = "<div id='subnav_sub_list'>" + this.subMenuItemsList + "</div>";	
	}
	
}
//function for subnav-popup
//args = name of menuset,Hilite-Toggle (1 = Hilite on, 0 = hilite off) 
function sr35_showSubMenu(whichMenu,whichPic) {
	
	// Hide mainnavx if still visible
	try {
		document.getElementById("main_sub_container").style.visibility="hidden";
		document.getElementById("main_sub_container").style.display="none";
	}
	catch (ex) {
	  // ignore
	}
	//reset old hilite and show new
	resetHighlight();
	if(whichPic == 0) showHighlight(whichMenu.imgname);	
	
	//workaround mozilla menuwidth bug
	if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("MSIE 7") == -1){
		document.getElementById("subnav_submenu").style.width = 20 + "px";
		}
	else{
		document.getElementById("subnav_submenu").style.width = "auto";
	}
	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";
	}
	
	//check img-position to get menu position
	if(whichMenu.activeMenu != 0 && whichMenu.imgPosChecked == 0) {
		whichMenu.menuPos = eval("document." + whichMenu.imgname + ".offsetLeft");
		whichMenu.menuTop = document.getElementById("subnav").offsetTop;
		whichMenu.imgHeight = eval("document." + whichMenu.imgname + ".offsetHeight");
		whichMenu.menuTop = whichMenu.menuTop + whichMenu.imgHeight;
		whichMenu.imgWidth = eval("document." + whichMenu.imgname + ".offsetWidth");
		whichMenu.menuWidth = document.getElementById("subnav_sub_list").offsetWidth;
		if(whichMenu.menuWidth < whichMenu.imgWidth) whichMenu.menuWidth = whichMenu.imgWidth;
		var currWidth = whichMenu.menuPos + whichMenu.menuWidth;
		if(currWidth >= 780){
	 		whichMenu.menuPos = (780 - whichMenu.menuWidth);			
		}
		
		whichMenu.imgPosChecked = 1;
	}
	//writing html-strings, positioning menu-layers
	if(whichMenu.activeMenu != 0) {
		document.getElementById("subnav_submenu").innerHTML = whichMenu.subMenuItemsList;
		document.getElementById("subnav_submenu").style.left= whichMenu.menuPos + "px";
		document.getElementById("subnav_submenu").style.top = whichMenu.menuTop + "px";
		document.getElementById("subnav_submenu").style.width = whichMenu.menuWidth + "px";
		document.getElementById("subnav_submenu").style.visibility = "visible";
		document.getElementById("subnav_submenu").style.display = "block";		
	}
	//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(vwcms_common_menu_close);	
}
function sr35_submenuCollapse(){
		//reset hilite
		resetHighlight();
		//hide popup-menu
		window.clearTimeout(vwcms_common_menu_close);
		document.getElementById("subnav_submenu").style.visibility="hidden";
		document.getElementById("subnav_submenu").style.display="none";		
}
//================================================================
//Scripts for Tab panels (SR3.5)
//===============================================================
var tabCount = 1; //initialy only one tab
/*
* Changes the tab-button i to be active and the other tab-buttons
* to be inactive. 0 < i < number of tab-buttons - 1
*/
function changeActiveTab(i) {
	for( j=0; j < tabCount; ++j ) {
		if( i==j ) { activateTab(j); }
		else { deactivateTab(j); }
	}
}
/*
* Activates the tab-button i and shows it's content panel.
*/
function activateTab(i) {
	var obj = document.getElementById( "tab-bg:"+i );
	if(obj) {obj.className="tab_on";}
	document.getElementById( "tab-body:"+i ).style.display='block';
}
/*
* Deactivates the tab-button i and hides it's content panel.
*/
function deactivateTab(i) {
	var obj = document.getElementById( "tab-bg:"+i );
	if(obj) {obj.className="tab_off";}
	document.getElementById( "tab-body:"+i ).style.display='none';
}
/*
* Call this function before calling any other function.
* Set parameter i to the number of tab-buttons when calling.
* Initialises the script.
*/
function initTabScript(i) {
	tabCount = i;
}
//===============================
//POPUP-Scripte
//==============================
//Scripte Galerie
function ImgObj(w,h)
{
  this.w=w;
  this.h=h;
}
gallery=new Array(),zoomWin=null,currentID=1;
/*gallery[1]=new ImgObj(660,420);
gallery[2]=new ImgObj(660,420);
gallery[3]=new ImgObj(660,420);
gallery[4]=new ImgObj(660,420);
gallery[5]=new ImgObj(660,420);
gallery[6]=new ImgObj(660,420);
gallery[7]=new ImgObj(660,420);
gallery[8]=new ImgObj(660,420);
gallery[9]=new ImgObj(660,420);
gallery[10]=new ImgObj(660,420);
gallery[11]=new ImgObj(660,420);
gallery[12]=new ImgObj(660,420);
gallery[13]=new ImgObj(660,420);
gallery[14]=new ImgObj(660,420);*/
function show(id, picMed, picPopUp, txtAlt, plusIcon) 
{ 
  currentID=id; 
  currentPicMed=picMed; 
  currentPicPopUp=picPopUp; 
  document.images.bigpic.src=picMed;
  document.images.bigpic.alt=txtAlt;
  document.images.bigpic.title=txtAlt;
  
  var isPlusVisible = true;
  if(plusIcon==null || plusIcon.length==0) {
	document.images.plusimage.src="";
	isPlusVisible = false;
  }
  else {
  	document.images.plusimage.src=plus;
  }
  
  try {
  	var plusdiv = document.getElementById("icon_plus");
  	if(isPlusVisible) {
  		plusdiv.style.visibility="visible";
  		plusdiv.style.display = "block";
	} else {
		plusdiv.style.visibility="hidden";
		plusdiv.style.display = "none";
  	}
  }
  catch (ex) {
	// ignore
  }
}
function zoom()
{
  if(currentPicPopUp.length==0)return;
  var macie=navigator.platform=="MacPPC"&&navigator.appName=='Microsoft Internet Explorer',w=gallery[currentID].w,h=gallery[currentID].h;
  if(zoomWin&&!zoomWin.closed)zoomWin.close();
  zoomWin=window.open(currentPicPopUp,"volkswagen_gallery","width="+(macie?w-16:w)+",height="+(macie?h-16:h)+",scrollbars=no,resizable=no,screenX=100,screenY=100");
}
//===============================
//Control-Script for Checkboxes
//===============================
var minAnzahlCheckboxActivated = 0;
var maxAnzahlCheckboxActivated = 4;
var checkboxPattern ="checkbox";
	
function controlCheck(obj, pFormName) 
{  
	var frm;
	if(pFormName) {
		frm = document.getElementById(pFormName);
	} else {
		frm = document.forms["ausstattungsform"];
	}
	var countActiveCheckBoxes = 0;
	for (var i=0; i < frm.elements.length; i++) {
		if (frm.elements[i].id.indexOf(checkboxPattern) != -1) 		{
			//if (frm.elements[i].id == obj.id)	{
				if (frm.elements[i].checked == true) {
	       	countActiveCheckBoxes++;
        }                         
        /* less than min */
        if (countActiveCheckBoxes < minAnzahlCheckboxActivated) {
           countActiveCheckBoxes=minAnzahlCheckboxActivated;
           obj.checked = true;
        }
        /* more than max */
        if (countActiveCheckBoxes > maxAnzahlCheckboxActivated) {
		        countActiveCheckBoxes=maxAnzahlCheckboxActivated;
            obj.checked = false;
        }
      //}
    }
  } 
}
