/*
 * File........: navcontrol.js
 * Created.....: 2005/05/30
 * Copyright...: (c) 2005 All Rights Reserved.
 */

// Abfrage des Browsers und einbinden der Stylesheet-Datei
function Is () {
    
    var agt = navigator.userAgent.toLowerCase()
    var applName = navigator.appName;
    
	if ((applName == 'Netscape') && (agt.indexOf('firefox') == -1) || (agt.indexOf('mozilla') == -1)) {
		document.write('<link REL=STYLESHEET HREF="css/styles_ie_de.css" TYPE="text/css"><style type="text/css">@import url(css/styles.css);</style>');
	}
	else {
		document.write('<link REL=STYLESHEET HREF="css/styles_ie_de.css" TYPE="text/css">');
	}
	if ((applName == 'Opera'))  {
		document.write('<link REL=STYLESHEET HREF="css/styles_ie_de.css" TYPE="text/css">');
	}
}

Is();

var ie = (document.all) ? 1 : 0;
var ns = navigator.appName == 'Netscape';
var ns4 = (document.layers) ? 1 : 0;
var ns6 = (!document.all && document.getElementById) ? 1 : 0;

var param = document.location.search.slice(document.location.search.lastIndexOf("=")+1);

var name="nav"
var lstay = ""

function navCol(nr)
{
  lstay = name + nr;
  var ele=document.getElementById(lstay);
  if (ele==null)
      return;
        
  if (ns6) 
    document.getElementById(lstay).style.color = "#5C5C61";
  if (ie)
    document.all[lstay].style.color = "#5C5C61";
}

function navColu(nr)
{
  lstay = name + nr;
  var ele=document.getElementById(lstay);
  if (ele==null)
      return;
        
  if (ns6) 
    document.getElementById(lstay).style.color = "#000000";
  if (ie)
    document.all[lstay].style.color = "#000000";
}

// Änderung der Ansicht
function changeView(act, i)
{
  document.p.act.value = act;
  document.p.v.value = i;
  document.p.submit();
}

// Änderung der Fahrzeugauswahl
function changeSelection(i)
{
  document.p.act.value = "search";
  document.p.tab.value = (i) ? 'all' : 'chg';
  document.p.submit();
}

// Ruecksetzen der Fahrzeugauswahl 
function resetSelection(i)
{
  document.p.act.value = "search";
  document.p.v.value = i;  
  document.p.tab.value = 'all';
  document.p.submit();
}

var errStr = "";
function SSOLogin()
{
	var ok=true;
	if(document.regist.user_name.value.length<3){
		errStr = "Bitte%20geben%20Sie%20einen%20Benutzer-%20namen%20ein,%20der%20mindestens%203%20Zeichen%20lang%20ist.";
		ok=false;
	} else
	if(document.regist.password.value.length<6){
		errStr = "Bitte%20geben%20Sie%20ein%20Passwort%20ein,%20das%20mindestens%206%20Zeichen%20lang%20ist.";
		ok=false;
	}
	if(ok){
		document.regist.submit();
	}else{
		document.location.href=document.regist.redirect_url.value + "&err_code=2&err_string=" + errStr;
	}
}

// Setzen des Cursors an ein geschwünschtes Textfeld
function focusOnError(name)
{
	self.focus();
	document.getElementsByName(name)[0].focus();
}

function visible(id) {
	var ele = document.getElementById(id);
	if(!ele)return;
  var equTabStyle = ele.style;
  equTabStyle.display = (equTabStyle.display == "none") ? "" : "none";
  var iSrc = (equTabStyle.display == "none") ? "img/but_on.gif" : "img/but_off.gif";
  switch(id)
  { case "a1": document.images.But1.src=iSrc; break;
    case "a2": document.images.But2.src=iSrc; break;
    case "a3": document.images.But3.src=iSrc; break;
    case "a4": document.images.But4.src=iSrc; break;
    case "a5": document.images.But5.src=iSrc; break;
    case "a6": document.images.But6.src=iSrc; break;
    case "a7": document.images.But7.src=iSrc; break;
    case "a8": document.images.But8.src=iSrc; break;
  }
}

function visibleEquip(id) {
	var ele = document.getElementById(id);
	if(!ele)return;
  var equTabStyle = ele.style;
  equTabStyle.display = "";
  var iSrc = "img/but_off.gif";
  switch(id)
  { case "a1": document.images.But1.src=iSrc; break;
    case "a2": document.images.But2.src=iSrc; break;
    case "a3": document.images.But3.src=iSrc; break;
  }
  scroll(0,500);
}

// Ein- und Ausblenden der Menupunkte
function visibleMenu(id, changeStat) {
  var ele = document.getElementById("n" + id);
  if (ele==null || !changeStat)
    return;
  var equTabStyle = ele.style;
  if(changeStat)
    equTabStyle.display = (equTabStyle.display == "none") ? "" : "none";
  for(i=1;i<=2;i++){
	var equTabStyleAll = document.getElementById("n" + i).style;
	if(i != id){
   	  equTabStyleAll.display = "none";	
	}
  }
}

function getViewStat() {
  var count=8;
  var stat = '';
  for (i=1;i<=count;i++)
  {
    var ele=document.getElementById("a" + i);
    if (ele==null)
      return stat;
    var equTabStyle = ele.style;
    stat += (equTabStyle.display == "none") ? "0" : "1";
  } 
  return stat;
}

function setViewStat() {
  var count=8;
  var show = window.location.search;
  var aShow = show.split("=");
  var bShow = aShow[1];
  if(typeof(bShow)=="undefined")
    return;
  for (i=1;i<=count;i++)
  {
    if (bShow.length>=i)
    {
      if ((bShow.substr(i-1,1)) == '1')
        visible("a" + i);
    }    
  } 
}

// Detailansicht eines Fahrzeugs
function carDetails()
{ 
  document.p.act.value = "offer";
  document.p.submit();
}

function callSearchAgent(url,action,view,backtrack,title,width,height){
 fenster=window.open(url+"act=" + action + "&backTrack=" + backtrack + "&v=" + view, title,"width=" + width + ", height=" + height + ",scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes,location=yes");
 self.focus;
}
function openDealerImprint(url){
	fenster=window.open(url, "Impressum", "width=400, height=325,scrollbars=no,resizable=no,menubar=no,toolbar=no");
 	self.focus;
}
