if (document.all) {
	document.writeln('<!--[if lt IE 7]>');
	document.writeln('<link href="/common/inc/css/content_ie.css" rel="stylesheet" type="text/css" media="screen">');
	document.writeln('<![endif]-->');
}

/* Erweiterung Artikelliste [ms20111015] */
function openArticleList(url) {
	alert('openArticleList');
	var articleListWindow = window.open(url, 'articleList');
	articleListWindow.focus();
	return false;
}
function loadArticleList(url) {
	alert('loadArticleList' + url);
	if (articleListWindow) {
		articleListWindow.location = url;
	}
}

function getNodeId() {
    var idx = document.location.href.lastIndexOf("nodeId=");
	var tmp2 = document.location.href.substr(idx+7);
	//alert(tmp);
    return document.location.href.substr(idx+7);
}
function getNodeIdNext() {
    var id = getNodeId();
    //var nr = Number(id.substr(-3)) + 1;
	var nr = Number(id.substr(id.length-3,id.length))+1;
    var pad = nr < 10 ? "00" : nr < 100 ? "0" : "";
    return id.substring(0,id.length - 3)+pad+nr;
}
function getNodeIdPrevious() {
    var id = getNodeId();
    //var nr = Number(id.substr(-3)) - 1;
	var nr = Number(id.substr(id.length-3,id.length))-1;
    var pad = nr < 10 ? "00" : nr < 100 ? "0" : "";
    return id.substring(0,id.length - 3)+pad+nr;
}

function next(link) {
    var href = link+"?nodeId="+getNodeIdNext();
    document.location.href = href;
}
function previous(link) {
    var href = link+"?nodeId="+getNodeIdPrevious();
    document.location.href = href;
}

function makePrinterFriendlyVersion() {
	//printPage();
	self.print();
}

function loadPage(n) {
	//alert('loadPage');
	top.frames['navi'].location.href = '/common/navi.jsp';
	top.frames['main'].location.href = n;
}
function loadNavi() {
	//alert('loadNavi');
	top.frames['navi'].location.href = '/common/navi.jsp';
}
function loadHomeNavi() {
	//alert('loadHomeNavi');
	top.frames['navi'].location.href = '/common/navi-home.jsp';
	top.frames['header'].location.href = '/common/header.jsp';
}
function unLoadNavi() {
	//alert('unLoadNavi');
	top.frames['navi'].location.href = '/common/empty.jsp';
	top.frames['header'].location.href = '/common/header.jsp';
}
function searchfocus() {
	if ( document.searchform ) {
		document.searchform.sucheingabe.focus();
	}
}
// Nur den Content der Seite printen -> Werkstattplanung
function printPage() {
	if (top.frames['main']) {
		if (document.all && typeof document.body.style.maxHeight != "undefined") {
			// cartool ie6 schmiert sonst grundlos ab
			top.frames['main'].focus();
			self.print();
		} else {
			top.frames['main'].print();
		}
	} else {
		self.print();
	}
}

function mainShows(pageArray) {
	if (pageArray) {
	    with(top.frames['main'].location) {
			for (var i = 0; i < pageArray.length; i++) {
				if ( href.indexOf(pageArray[i]) != -1) return true;
			}
    	}
	}
    return false;
}

//Seiten auf denen weder contact noch help angezeigt werden soll, ausserdem keine navi:
var nchPages = new Array("new.jsp","login.jsp","logout.jsp");
//Seiten auf denen Hilfe angezeigt werden soll:
var helpPages = new Array("address.jsp","cart.jsp","detail.jsp","display.jsp","editpass.jsp","intern.jsp","order.jsp","preorder.jsp","printconfirm.jsp","search.jsp","vergleich.jsp");
//Seiten auf denen Hilfe NICHT angezeigt werden soll:
var noHelpPages = new Array("index.jsp","index.html","editpass.jsp");
//Seiten auf denen Kontakt NICHT angezeigt werden soll:
var noContactPages = new Array("shop.jsp",".html","downloads.jsp","rechtlicherhinweis.jsp");
function frameCheck(param)
{
	if ( ! top.frames) return;
	if ( ! top.frames.header) return;
    with(top.frames['header'].document) {
        //alert(top.frames['main'].location);
        //Kontakt ist fast immer da

        if (mainShows(noContactPages)) {
            if (getElementById('contact') != null)
                getElementById('contact').style.display = 'none';
        }
        else {
            if (getElementById('contact') != null)
                getElementById('contact').style.display = 'block';
        }

        //Seiten ohne contact und hilfe und ohne linke navi:
        if (mainShows(nchPages)) {
            if (getElementById('contact') != null)
                getElementById('contact').style.display = 'none';
            if (getElementById('help') != null)
                getElementById('help').style.display = 'none';
            top.frames['navi'].location.href="/common/empty.jsp";
        }
        //Seiten mit angezeigter Hilfe
        if (mainShows(helpPages)) {
            if (getElementById('help') != null)
                getElementById('help').style.display = 'block';
        }
        if (mainShows(noHelpPages)) {
            if (getElementById('help') != null)
                getElementById('help').style.display = 'none';
        }

        //Auf Login Seite ist home nicht sichtbar
        if (mainShows(new Array("login.jsp"))) {
            if (getElementById('homebutton') != null)
                getElementById('homebutton').style.display = 'none';
        }
        else {
            if (getElementById('homebutton') != null)
                getElementById('homebutton').style.display = 'block';
        }
    }

    //Spezialfall intern auf detail.jsp:
    if (arguments.length > 0) {
        top.frames['header'].location.href='/common/header.jsp?'+param;
        top.frames['header'].document.getElementById('intern').style.display = 'block';
	}
	else {
	    if (top.frames['header'].document.getElementById('intern') != null)
	        top.frames['header'].document.getElementById('intern').style.display = 'none';
    }

	if (self.parent.frames.length==0)
	{
		location = "/bmw/index.jsp"
	}
}
function setFrames() {
  if(parent != null && parent != self) {
    var host=parent.location.hostname;
    if(host != "http://cartool.ampersand.loc") {
      	top.location.href=self.location.href;
    }
  }
}

function showLayer(n) {
	document.getElementById(n).style.visibility = 'visible';
}
function hideLayer(n) {
	document.getElementById(n).style.visibility = 'visible';
}
function switchLayer(n) {
	if (document.getElementById(n).style.visibility == 'visible') {
			document.getElementById(n).style.visibility = 'hidden';
		} else {
			document.getElementById(n).style.visibility = 'visible';
		}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

